diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 49fe2333dac632..2c689a6328b8e2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,5 +1,5 @@ -# Help +# Help #### The issues section is for bug reports and feature requests only. If you need help, please use the [forum](http://discourse.threejs.org/) or [stackoverflow](http://stackoverflow.com/questions/tagged/three.js). --- # Bugs @@ -25,4 +25,5 @@ 2. Fork the repository on GitHub. 3. Check the [Contribution Guidelines](https://github.com/mrdoob/three.js/wiki/How-to-contribute-to-three.js). 4. Make changes to your clone of the repository. -5. Submit a pull request. Don't include build files in the PR. +5. If your changes leads to a change in examples, make a new screenshot with `npm run make-screenshot `. +6. Submit a pull request. Don't include build files in the PR. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 7d3d370d77ce26..4442b1946f877b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -17,7 +17,7 @@ Please also include a live example if possible. You can start from these templat ##### Three.js version - [ ] Dev -- [ ] r112 +- [ ] r116 - [ ] ... ##### Browser diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000000..5682d868df6486 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,117 @@ +name: CI + +on: + pull_request: + paths-ignore: + - 'build/**' + - 'docs/**' + - 'files/**' + push: + paths-ignore: + - 'build/**' + - 'docs/**' + - 'files/**' + +jobs: + + lint: + name: "Linting" + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - name: Restore cache + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-ci-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-ci-${{ env.cache-name }}- + - name: Install packages + run: npm ci + + - name: === Linting === + run: npm run test-lint + + unit: + name: "Unit testing" + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - name: Restore cache + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-ci-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-ci-${{ env.cache-name }}- + - name: Install packages + run: npm ci && npm run build-test + + - name: === Unit testing === + run: npm run test-unit + + e2e: + name: "E2E testing" + runs-on: ubuntu-latest + strategy: + matrix: + CI: [ 0, 1, 2, 3 ] + env: + CI: ${{ matrix.CI }} + FORCE_COLOR: 1 + steps: + - name: Git checkout + uses: actions/checkout@v2 + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - name: Restore cache + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-ci-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-ci-${{ env.cache-name }}- + - name: Install packages + run: npm ci && sudo apt-get install xvfb && npm run build + + - name: === E2E testing === + run: xvfb-run --auto-servernum npm run test-e2e + + e2e-cov: + name: "Ready for release" + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - name: Restore cache + uses: actions/cache@v1 + env: + cache-name: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-ci-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: ${{ runner.os }}-ci-${{ env.cache-name }}- + - name: Install packages + run: npm ci + + - name: === Ready for release === + run: npm run test-e2e-cov diff --git a/.gitignore b/.gitignore index e5f2db52a401b0..9b69ecf9e473c7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ node_modules npm-debug.log .jshintrc .vs/ -test/unit/three.*.unit.js +test/unit/three.*.unit.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2e53aa5fa7d4f9..00000000000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - node -script: - - npm run travis diff --git a/LICENSE b/LICENSE index d3400897d5960f..9ef721c2749c95 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright © 2010-2019 three.js authors +Copyright © 2010-2020 three.js authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 04fa48c9ab223b..9c2ca95b417522 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ three.js ======== -[![NPM package][npm]][npm-url] +[![NPM Package][npm]][npm-url] [![Build Size][build-size]][build-size-url] -[![Build Status][build-status]][build-status-url] -[![Dependencies][dependencies]][dependencies-url] +[![NPM Downloads][npm-downloads]][npmtrends-url] [![Dev Dependencies][dev-dependencies]][dev-dependencies-url] [![Language Grade][lgtm]][lgtm-url] @@ -18,21 +17,16 @@ The aim of the project is to create an easy to use, lightweight, 3D library with [Migrating](https://github.com/mrdoob/three.js/wiki/Migration-Guide) — [Questions](http://stackoverflow.com/questions/tagged/three.js) — [Forum](https://discourse.threejs.org/) — -[Gitter](https://gitter.im/mrdoob/three.js) — -[Slack](https://join.slack.com/t/threejs/shared_invite/enQtMzYxMzczODM2OTgxLTQ1YmY4YTQxOTFjNDAzYmQ4NjU2YzRhNzliY2RiNDEyYjU2MjhhODgyYWQ5Y2MyZTU3MWNkOGVmOGRhOTQzYTk) +[Slack](https://join.slack.com/t/threejs/shared_invite/enQtMzYxMzczODM2OTgxLTQ1YmY4YTQxOTFjNDAzYmQ4NjU2YzRhNzliY2RiNDEyYjU2MjhhODgyYWQ5Y2MyZTU3MWNkOGVmOGRhOTQzYTk) — +[Discord](https://discordapp.com/invite/HF4UdyF) ### Usage ### -Download the [minified library](http://threejs.org/build/three.min.js) and include it in your HTML, or install and import it as a [module](http://threejs.org/docs/#manual/introduction/Import-via-modules), -Alternatively, see [how to build the library yourself](https://github.com/mrdoob/three.js/wiki/Build-instructions). - -```html - -``` - This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the `document.body` element. Finally, it animates the cube within the scene for the camera. ```javascript +import * as THREE from 'js/three.module.js'; + var camera, scene, renderer; var geometry, material, mesh; @@ -70,22 +64,20 @@ function animate() { } ``` -If everything went well you should see [this](https://jsfiddle.net/f2Lommf5/). +If everything went well, you should see [this](https://jsfiddle.net/8kubjpL5/). ### Change log ### [Releases](https://github.com/mrdoob/three.js/releases) -[npm]: https://img.shields.io/npm/v/three.svg +[npm]: https://img.shields.io/npm/v/three [npm-url]: https://www.npmjs.com/package/three [build-size]: https://badgen.net/bundlephobia/minzip/three [build-size-url]: https://bundlephobia.com/result?p=three -[build-status]: https://travis-ci.org/mrdoob/three.js.svg?branch=dev -[build-status-url]: https://travis-ci.org/mrdoob/three.js -[dependencies]: https://img.shields.io/david/mrdoob/three.js.svg -[dependencies-url]: https://david-dm.org/mrdoob/three.js -[dev-dependencies]: https://img.shields.io/david/dev/mrdoob/three.js.svg +[npm-downloads]: https://img.shields.io/npm/dw/three +[npmtrends-url]: https://www.npmtrends.com/three +[dev-dependencies]: https://img.shields.io/david/dev/mrdoob/three.js [dev-dependencies-url]: https://david-dm.org/mrdoob/three.js#info=devDependencies -[lgtm]: https://img.shields.io/lgtm/grade/javascript/g/mrdoob/three.js.svg?label=code%20quality +[lgtm]: https://img.shields.io/lgtm/alerts/github/mrdoob/three.js [lgtm-url]: https://lgtm.com/projects/g/mrdoob/three.js/ diff --git a/build/three.js b/build/three.js index f86eb66441bae4..241428a24a2641 100644 --- a/build/three.js +++ b/build/three.js @@ -97,7 +97,7 @@ } - var REVISION = '112'; + var REVISION = '116'; var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }; var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }; var CullFaceNone = 0; @@ -115,9 +115,6 @@ 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; @@ -215,6 +212,8 @@ var RGBA_PVRTC_4BPPV1_Format = 35842; var RGBA_PVRTC_2BPPV1_Format = 35843; var RGB_ETC1_Format = 36196; + var RGB_ETC2_Format = 37492; + var RGBA_ETC2_EAC_Format = 37496; var RGBA_ASTC_4x4_Format = 37808; var RGBA_ASTC_5x4_Format = 37809; var RGBA_ASTC_5x5_Format = 37810; @@ -229,6 +228,21 @@ var RGBA_ASTC_10x10_Format = 37819; var RGBA_ASTC_12x10_Format = 37820; var RGBA_ASTC_12x12_Format = 37821; + var RGBA_BPTC_Format = 36492; + var SRGB8_ALPHA8_ASTC_4x4_Format = 37840; + var SRGB8_ALPHA8_ASTC_5x4_Format = 37841; + var SRGB8_ALPHA8_ASTC_5x5_Format = 37842; + var SRGB8_ALPHA8_ASTC_6x5_Format = 37843; + var SRGB8_ALPHA8_ASTC_6x6_Format = 37844; + var SRGB8_ALPHA8_ASTC_8x5_Format = 37845; + var SRGB8_ALPHA8_ASTC_8x6_Format = 37846; + var SRGB8_ALPHA8_ASTC_8x8_Format = 37847; + var SRGB8_ALPHA8_ASTC_10x5_Format = 37848; + var SRGB8_ALPHA8_ASTC_10x6_Format = 37849; + var SRGB8_ALPHA8_ASTC_10x8_Format = 37850; + var SRGB8_ALPHA8_ASTC_10x10_Format = 37851; + var SRGB8_ALPHA8_ASTC_12x10_Format = 37852; + var SRGB8_ALPHA8_ASTC_12x12_Format = 37853; var LoopOnce = 2200; var LoopRepeat = 2201; var LoopPingPong = 2202; @@ -238,6 +252,8 @@ var ZeroCurvatureEnding = 2400; var ZeroSlopeEnding = 2401; var WrapAroundEnding = 2402; + var NormalAnimationBlendMode = 2500; + var AdditiveAnimationBlendMode = 2501; var TrianglesDrawMode = 0; var TriangleStripDrawMode = 1; var TriangleFanDrawMode = 2; @@ -352,6 +368,7 @@ event.target = this; + // Make a copy, in case listeners are removed while iterating. var array = listenerArray.slice( 0 ); for ( var i = 0, l = array.length; i < l; i ++ ) { @@ -369,6 +386,8 @@ /** * @author alteredq / http://alteredqualia.com/ * @author mrdoob / http://mrdoob.com/ + * @author WestLangley / http://github.com/WestLangley + * @author thezwap */ var _lut = []; @@ -379,7 +398,7 @@ } - var _Math = { + var MathUtils = { DEG2RAD: Math.PI / 180, RAD2DEG: 180 / Math.PI, @@ -483,13 +502,13 @@ degToRad: function ( degrees ) { - return degrees * _Math.DEG2RAD; + return degrees * MathUtils.DEG2RAD; }, radToDeg: function ( radians ) { - return radians * _Math.RAD2DEG; + return radians * MathUtils.RAD2DEG; }, @@ -509,6 +528,62 @@ return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) ); + }, + + setQuaternionFromProperEuler: function ( q, a, b, c, order ) { + + // Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles + + // rotations are applied to the axes in the order specified by 'order' + // rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c' + // angles are in radians + + var cos = Math.cos; + var sin = Math.sin; + + var c2 = cos( b / 2 ); + var s2 = sin( b / 2 ); + + var c13 = cos( ( a + c ) / 2 ); + var s13 = sin( ( a + c ) / 2 ); + + var c1_3 = cos( ( a - c ) / 2 ); + var s1_3 = sin( ( a - c ) / 2 ); + + var c3_1 = cos( ( c - a ) / 2 ); + var s3_1 = sin( ( c - a ) / 2 ); + + switch ( order ) { + + case 'XYX': + q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 ); + break; + + case 'YZY': + q.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 ); + break; + + case 'ZXZ': + q.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 ); + break; + + case 'XZX': + q.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 ); + break; + + case 'YXY': + q.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 ); + break; + + case 'ZYZ': + q.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 ); + break; + + default: + console.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order ); + + } + } }; @@ -895,9 +970,7 @@ // 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; } + var angle = Math.atan2( - this.y, - this.x ) + Math.PI; return angle; @@ -999,671 +1072,812 @@ return this; + }, + + random: function () { + + this.x = Math.random(); + this.y = Math.random(); + + return this; + } } ); /** - * @author mikael emtinger / http://gomo.se/ * @author alteredq / http://alteredqualia.com/ * @author WestLangley / http://github.com/WestLangley * @author bhouston / http://clara.io + * @author tschw */ - function Quaternion( x, y, z, w ) { + function Matrix3() { - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this._w = ( w !== undefined ) ? w : 1; + this.elements = [ - } + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 - Object.assign( Quaternion, { + ]; - slerp: function ( qa, qb, qm, t ) { + if ( arguments.length > 0 ) { - return qm.copy( qa ).slerp( qb, t ); + console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); - }, + } - slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { + } - // fuzz-free, array-based Quaternion SLERP operation + Object.assign( Matrix3.prototype, { - var x0 = src0[ srcOffset0 + 0 ], - y0 = src0[ srcOffset0 + 1 ], - z0 = src0[ srcOffset0 + 2 ], - w0 = src0[ srcOffset0 + 3 ], + isMatrix3: true, - x1 = src1[ srcOffset1 + 0 ], - y1 = src1[ srcOffset1 + 1 ], - z1 = src1[ srcOffset1 + 2 ], - w1 = src1[ srcOffset1 + 3 ]; + set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { - if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { + var te = this.elements; - var s = 1 - t, + te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; + te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; + te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; - cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, + return this; - dir = ( cos >= 0 ? 1 : - 1 ), - sqrSin = 1 - cos * cos; + }, - // Skip the Slerp for tiny steps to avoid numeric problems: - if ( sqrSin > Number.EPSILON ) { + identity: function () { - var sin = Math.sqrt( sqrSin ), - len = Math.atan2( sin, cos * dir ); + this.set( - s = Math.sin( s * len ) / sin; - t = Math.sin( t * len ) / sin; + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 - } + ); - var tDir = t * dir; + return this; - x0 = x0 * s + x1 * tDir; - y0 = y0 * s + y1 * tDir; - z0 = z0 * s + z1 * tDir; - w0 = w0 * s + w1 * tDir; + }, - // Normalize in case we just did a lerp: - if ( s === 1 - t ) { + clone: function () { - var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); + return new this.constructor().fromArray( this.elements ); - x0 *= f; - y0 *= f; - z0 *= f; - w0 *= f; + }, - } + copy: function ( m ) { - } + var te = this.elements; + var me = m.elements; - dst[ dstOffset ] = x0; - dst[ dstOffset + 1 ] = y0; - dst[ dstOffset + 2 ] = z0; - dst[ dstOffset + 3 ] = w0; + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; + te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; + te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; - } + return this; - } ); + }, - Object.defineProperties( Quaternion.prototype, { + extractBasis: function ( xAxis, yAxis, zAxis ) { - x: { + xAxis.setFromMatrix3Column( this, 0 ); + yAxis.setFromMatrix3Column( this, 1 ); + zAxis.setFromMatrix3Column( this, 2 ); - get: function () { + return this; - return this._x; + }, - }, + setFromMatrix4: function ( m ) { - set: function ( value ) { + var me = m.elements; - this._x = value; - this._onChangeCallback(); + this.set( - } + me[ 0 ], me[ 4 ], me[ 8 ], + me[ 1 ], me[ 5 ], me[ 9 ], + me[ 2 ], me[ 6 ], me[ 10 ] - }, + ); - y: { + return this; - get: function () { + }, - return this._y; + multiply: function ( m ) { - }, + return this.multiplyMatrices( this, m ); - set: function ( value ) { + }, - this._y = value; - this._onChangeCallback(); + premultiply: function ( m ) { - } + return this.multiplyMatrices( m, this ); }, - z: { + multiplyMatrices: function ( a, b ) { - get: function () { + var ae = a.elements; + var be = b.elements; + var te = this.elements; - return this._z; + var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; + var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; + var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; - }, + var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; + var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; + var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; - set: function ( value ) { + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; + te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; + te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; - this._z = value; - this._onChangeCallback(); + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; + te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; + te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; - } + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; + te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; + te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + + return this; }, - w: { + multiplyScalar: function ( s ) { - get: function () { + var te = this.elements; - return this._w; + te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; + te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; + te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; - }, + return this; - set: function ( value ) { + }, - this._w = value; - this._onChangeCallback(); + determinant: function () { - } + var te = this.elements; - } + var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], + d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], + g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; - } ); + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; - Object.assign( Quaternion.prototype, { + }, - isQuaternion: true, + getInverse: function ( matrix, throwOnDegenerate ) { - set: function ( x, y, z, w ) { + if ( throwOnDegenerate !== undefined ) { - this._x = x; - this._y = y; - this._z = z; - this._w = w; + console.warn( "THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate." ); - this._onChangeCallback(); + } - return this; + var me = matrix.elements, + te = this.elements, - }, + n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], + n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ], + n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ], - clone: function () { + t11 = n33 * n22 - n32 * n23, + t12 = n32 * n13 - n33 * n12, + t13 = n23 * n12 - n22 * n13, - return new this.constructor( this._x, this._y, this._z, this._w ); + det = n11 * t11 + n21 * t12 + n31 * t13; - }, + if ( det === 0 ) { return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 ); } - copy: function ( quaternion ) { + var detInv = 1 / det; - this._x = quaternion.x; - this._y = quaternion.y; - this._z = quaternion.z; - this._w = quaternion.w; + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; + te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; - this._onChangeCallback(); + te[ 3 ] = t12 * detInv; + te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; + te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + + te[ 6 ] = t13 * detInv; + te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; + te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; return this; }, - setFromEuler: function ( euler, update ) { - - if ( ! ( euler && euler.isEuler ) ) { - - throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); - - } + transpose: function () { - var x = euler._x, y = euler._y, z = euler._z, order = euler.order; + var tmp, m = this.elements; - // http://www.mathworks.com/matlabcentral/fileexchange/ - // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ - // content/SpinCalc.m + tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; + tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; + tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; - var cos = Math.cos; - var sin = Math.sin; + return this; - var c1 = cos( x / 2 ); - var c2 = cos( y / 2 ); - var c3 = cos( z / 2 ); + }, - var s1 = sin( x / 2 ); - var s2 = sin( y / 2 ); - var s3 = sin( z / 2 ); + getNormalMatrix: function ( matrix4 ) { - if ( order === 'XYZ' ) { + return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + }, - } else if ( order === 'YXZ' ) { + transposeIntoArray: function ( r ) { - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + var m = this.elements; - } else if ( order === 'ZXY' ) { + r[ 0 ] = m[ 0 ]; + r[ 1 ] = m[ 3 ]; + r[ 2 ] = m[ 6 ]; + r[ 3 ] = m[ 1 ]; + r[ 4 ] = m[ 4 ]; + r[ 5 ] = m[ 7 ]; + r[ 6 ] = m[ 2 ]; + r[ 7 ] = m[ 5 ]; + r[ 8 ] = m[ 8 ]; - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + return this; - } else if ( order === 'ZYX' ) { + }, - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) { - } else if ( order === 'YZX' ) { + var c = Math.cos( rotation ); + var s = Math.sin( rotation ); - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + this.set( + sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, + - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, + 0, 0, 1 + ); - } else if ( order === 'XZY' ) { + }, - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + scale: function ( sx, sy ) { - } + var te = this.elements; - if ( update !== false ) { this._onChangeCallback(); } + te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; + te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; return this; }, - setFromAxisAngle: function ( axis, angle ) { + rotate: function ( theta ) { - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + var c = Math.cos( theta ); + var s = Math.sin( theta ); - // assumes axis is normalized + var te = this.elements; - var halfAngle = angle / 2, s = Math.sin( halfAngle ); + var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; + var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; - this._x = axis.x * s; - this._y = axis.y * s; - this._z = axis.z * s; - this._w = Math.cos( halfAngle ); + te[ 0 ] = c * a11 + s * a21; + te[ 3 ] = c * a12 + s * a22; + te[ 6 ] = c * a13 + s * a23; - this._onChangeCallback(); + te[ 1 ] = - s * a11 + c * a21; + te[ 4 ] = - s * a12 + c * a22; + te[ 7 ] = - s * a13 + c * a23; return this; }, - setFromRotationMatrix: function ( m ) { - - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - - // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + translate: function ( tx, ty ) { - var te = m.elements, + var te = this.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 ], + te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; + te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; - trace = m11 + m22 + m33, - s; + return this; - if ( trace > 0 ) { + }, - s = 0.5 / Math.sqrt( trace + 1.0 ); + equals: function ( matrix ) { - this._w = 0.25 / s; - this._x = ( m32 - m23 ) * s; - this._y = ( m13 - m31 ) * s; - this._z = ( m21 - m12 ) * s; + var te = this.elements; + var me = matrix.elements; - } else if ( m11 > m22 && m11 > m33 ) { + for ( var i = 0; i < 9; i ++ ) { - s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); + if ( te[ i ] !== me[ i ] ) { return false; } - this._w = ( m32 - m23 ) / s; - this._x = 0.25 * s; - this._y = ( m12 + m21 ) / s; - this._z = ( m13 + m31 ) / s; + } - } else if ( m22 > m33 ) { + return true; - s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); + }, - this._w = ( m13 - m31 ) / s; - this._x = ( m12 + m21 ) / s; - this._y = 0.25 * s; - this._z = ( m23 + m32 ) / s; + fromArray: function ( array, offset ) { - } else { + if ( offset === undefined ) { offset = 0; } - s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + for ( var i = 0; i < 9; i ++ ) { - this._w = ( m21 - m12 ) / s; - this._x = ( m13 + m31 ) / s; - this._y = ( m23 + m32 ) / s; - this._z = 0.25 * s; + this.elements[ i ] = array[ i + offset ]; } - this._onChangeCallback(); - return this; }, - setFromUnitVectors: function ( vFrom, vTo ) { + toArray: function ( array, offset ) { - // assumes direction vectors vFrom and vTo are normalized + if ( array === undefined ) { array = []; } + if ( offset === undefined ) { offset = 0; } - var EPS = 0.000001; + var te = this.elements; - var r = vFrom.dot( vTo ) + 1; + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; - if ( r < EPS ) { + array[ offset + 3 ] = te[ 3 ]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; - r = 0; + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + array[ offset + 8 ] = te[ 8 ]; - if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + return array; - this._x = - vFrom.y; - this._y = vFrom.x; - this._z = 0; - this._w = r; + } - } else { + } ); - this._x = 0; - this._y = - vFrom.z; - this._z = vFrom.y; - this._w = r; + /** + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * @author szimek / https://github.com/szimek/ + */ - } + var _canvas; - } else { + var ImageUtils = { - // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 + getDataURL: function ( image ) { - this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; - this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; - this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; - this._w = r; + var canvas; - } + if ( typeof HTMLCanvasElement == 'undefined' ) { - return this.normalize(); + return image.src; - }, + } else if ( image instanceof HTMLCanvasElement ) { - angleTo: function ( q ) { + canvas = image; - return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) ); + } else { - }, + if ( _canvas === undefined ) { _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); } - rotateTowards: function ( q, step ) { + _canvas.width = image.width; + _canvas.height = image.height; - var angle = this.angleTo( q ); + var context = _canvas.getContext( '2d' ); - if ( angle === 0 ) { return this; } + if ( image instanceof ImageData ) { - var t = Math.min( 1, step / angle ); + context.putImageData( image, 0, 0 ); - this.slerp( q, t ); + } else { - return this; + context.drawImage( image, 0, 0, image.width, image.height ); - }, + } - inverse: function () { + canvas = _canvas; - // quaternion is assumed to have unit length + } - return this.conjugate(); + if ( canvas.width > 2048 || canvas.height > 2048 ) { - }, + return canvas.toDataURL( 'image/jpeg', 0.6 ); - conjugate: function () { + } else { - this._x *= - 1; - this._y *= - 1; - this._z *= - 1; + return canvas.toDataURL( 'image/png' ); - this._onChangeCallback(); + } - return this; + } - }, + }; - dot: function ( v ) { + /** + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * @author szimek / https://github.com/szimek/ + */ - return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; + var textureId = 0; - }, + function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - lengthSq: function () { + Object.defineProperty( this, 'id', { value: textureId ++ } ); - return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + this.uuid = MathUtils.generateUUID(); - }, + this.name = ''; - length: function () { + this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; + this.mipmaps = []; - return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); + this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; - }, + this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; + this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; - normalize: function () { - - var l = this.length(); + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; - if ( l === 0 ) { + this.anisotropy = anisotropy !== undefined ? anisotropy : 1; - this._x = 0; - this._y = 0; - this._z = 0; - this._w = 1; + this.format = format !== undefined ? format : RGBAFormat; + this.internalFormat = null; + this.type = type !== undefined ? type : UnsignedByteType; - } else { + this.offset = new Vector2( 0, 0 ); + this.repeat = new Vector2( 1, 1 ); + this.center = new Vector2( 0, 0 ); + this.rotation = 0; - l = 1 / l; + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); - this._x = this._x * l; - this._y = this._y * l; - this._z = this._z * l; - this._w = this._w * l; + 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._onChangeCallback(); + this.version = 0; + this.onUpdate = null; - return this; + } - }, + Texture.DEFAULT_IMAGE = undefined; + Texture.DEFAULT_MAPPING = UVMapping; - multiply: function ( q, p ) { + Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { - if ( p !== undefined ) { + constructor: Texture, - console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); - return this.multiplyQuaternions( q, p ); + isTexture: true, - } + updateMatrix: function () { - return this.multiplyQuaternions( this, q ); + this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); }, - premultiply: function ( q ) { + clone: function () { - return this.multiplyQuaternions( q, this ); + return new this.constructor().copy( this ); }, - multiplyQuaternions: function ( a, b ) { + copy: function ( source ) { - // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + this.name = source.name; - var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; - var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; + this.image = source.image; + this.mipmaps = source.mipmaps.slice( 0 ); - this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; - this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; - this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; - this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + this.mapping = source.mapping; - this._onChangeCallback(); + 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.internalFormat = source.internalFormat; + this.type = source.type; + + this.offset.copy( source.offset ); + this.repeat.copy( source.repeat ); + this.center.copy( source.center ); + this.rotation = source.rotation; + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrix.copy( source.matrix ); + + this.generateMipmaps = source.generateMipmaps; + this.premultiplyAlpha = source.premultiplyAlpha; + this.flipY = source.flipY; + this.unpackAlignment = source.unpackAlignment; + this.encoding = source.encoding; return this; }, - slerp: function ( qb, t ) { + toJSON: function ( meta ) { - if ( t === 0 ) { return this; } - if ( t === 1 ) { return this.copy( qb ); } + var isRootObject = ( meta === undefined || typeof meta === 'string' ); - var x = this._x, y = this._y, z = this._z, w = this._w; + if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { - // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + return meta.textures[ this.uuid ]; - var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; + } - if ( cosHalfTheta < 0 ) { + var output = { - this._w = - qb._w; - this._x = - qb._x; - this._y = - qb._y; - this._z = - qb._z; + metadata: { + version: 4.5, + type: 'Texture', + generator: 'Texture.toJSON' + }, - cosHalfTheta = - cosHalfTheta; + uuid: this.uuid, + name: this.name, - } else { + mapping: this.mapping, - this.copy( qb ); + repeat: [ this.repeat.x, this.repeat.y ], + offset: [ this.offset.x, this.offset.y ], + center: [ this.center.x, this.center.y ], + rotation: this.rotation, - } + wrap: [ this.wrapS, this.wrapT ], - if ( cosHalfTheta >= 1.0 ) { + format: this.format, + type: this.type, + encoding: this.encoding, - this._w = w; - this._x = x; - this._y = y; - this._z = z; + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, - return this; + flipY: this.flipY, - } + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment - var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; + }; - if ( sqrSinHalfTheta <= Number.EPSILON ) { + if ( this.image !== undefined ) { - var s = 1 - t; - this._w = s * w + t * this._w; - this._x = s * x + t * this._x; - this._y = s * y + t * this._y; - this._z = s * z + t * this._z; + // TODO: Move to THREE.Image - this.normalize(); - this._onChangeCallback(); + var image = this.image; - return this; + if ( image.uuid === undefined ) { + + image.uuid = MathUtils.generateUUID(); // UGH + + } + + if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + + var url; + + if ( Array.isArray( image ) ) { + + // process array of images e.g. CubeTexture + + url = []; + + for ( var i = 0, l = image.length; i < l; i ++ ) { + + url.push( ImageUtils.getDataURL( image[ i ] ) ); + + } + + } else { + + // process single image + + url = ImageUtils.getDataURL( image ); + + } + + meta.images[ image.uuid ] = { + uuid: image.uuid, + url: url + }; + + } + + output.image = image.uuid; } - var sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); - var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); - var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, - ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + if ( ! isRootObject ) { - this._w = ( w * ratioA + this._w * ratioB ); - this._x = ( x * ratioA + this._x * ratioB ); - this._y = ( y * ratioA + this._y * ratioB ); - this._z = ( z * ratioA + this._z * ratioB ); + meta.textures[ this.uuid ] = output; - this._onChangeCallback(); + } - return this; + return output; }, - equals: function ( quaternion ) { + dispose: function () { - return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); + this.dispatchEvent( { type: 'dispose' } ); }, - fromArray: function ( array, offset ) { + transformUv: function ( uv ) { - if ( offset === undefined ) { offset = 0; } + if ( this.mapping !== UVMapping ) { return uv; } - this._x = array[ offset ]; - this._y = array[ offset + 1 ]; - this._z = array[ offset + 2 ]; - this._w = array[ offset + 3 ]; + uv.applyMatrix3( this.matrix ); - this._onChangeCallback(); + if ( uv.x < 0 || uv.x > 1 ) { - return this; + switch ( this.wrapS ) { - }, + case RepeatWrapping: - toArray: function ( array, offset ) { + uv.x = uv.x - Math.floor( uv.x ); + break; - if ( array === undefined ) { array = []; } - if ( offset === undefined ) { offset = 0; } + case ClampToEdgeWrapping: - array[ offset ] = this._x; - array[ offset + 1 ] = this._y; - array[ offset + 2 ] = this._z; - array[ offset + 3 ] = this._w; + uv.x = uv.x < 0 ? 0 : 1; + break; - return array; + case MirroredRepeatWrapping: - }, + if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) { - _onChange: function ( callback ) { + uv.x = Math.ceil( uv.x ) - uv.x; - this._onChangeCallback = callback; + } else { - return this; + uv.x = uv.x - Math.floor( uv.x ); - }, + } - _onChangeCallback: function () {} + 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; + + } + + return uv; + + } + + } ); + + Object.defineProperty( Texture.prototype, "needsUpdate", { + + set: function ( value ) { + + if ( value === true ) { this.version ++; } + + } } ); /** - * @author mrdoob / http://mrdoob.com/ - * @author kile / http://kile.stravaganza.org/ + * @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 */ - var _vector = new Vector3(); - var _quaternion = new Quaternion(); - - function Vector3( x, y, z ) { + 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( Vector3.prototype, { + Object.defineProperties( Vector4.prototype, { - isVector3: true, + "width": { - set: function ( x, y, z ) { + get: function () { + + return this.z; + + }, + + set: function ( value ) { + + this.z = value; + + } + + }, + + "height": { + + get: function () { + + return this.w; + + }, + + set: function ( value ) { + + this.w = value; + + } + + } + + } ); + + 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; @@ -1674,6 +1888,7 @@ this.x = scalar; this.y = scalar; this.z = scalar; + this.w = scalar; return this; @@ -1703,6 +1918,14 @@ }, + setW: function ( w ) { + + this.w = w; + + return this; + + }, + setComponent: function ( index, value ) { switch ( index ) { @@ -1710,6 +1933,7 @@ 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 ); } @@ -1725,6 +1949,7 @@ 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 ); } @@ -1733,7 +1958,7 @@ clone: function () { - return new this.constructor( this.x, this.y, this.z ); + return new this.constructor( this.x, this.y, this.z, this.w ); }, @@ -1742,6 +1967,7 @@ this.x = v.x; this.y = v.y; this.z = v.z; + this.w = ( v.w !== undefined ) ? v.w : 1; return this; @@ -1751,7 +1977,7 @@ if ( w !== undefined ) { - console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } @@ -1759,6 +1985,7 @@ this.x += v.x; this.y += v.y; this.z += v.z; + this.w += v.w; return this; @@ -1769,6 +1996,7 @@ this.x += s; this.y += s; this.z += s; + this.w += s; return this; @@ -1779,6 +2007,7 @@ 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; @@ -1789,6 +2018,7 @@ this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; + this.w += v.w * s; return this; @@ -1798,7 +2028,7 @@ if ( w !== undefined ) { - console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } @@ -1806,6 +2036,7 @@ this.x -= v.x; this.y -= v.y; this.z -= v.z; + this.w -= v.w; return this; @@ -1816,6 +2047,7 @@ this.x -= s; this.y -= s; this.z -= s; + this.w -= s; return this; @@ -1826,23 +2058,7 @@ this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; - - return this; - - }, - - multiply: function ( v, w ) { - - if ( w !== undefined ) { - - console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); - return this.multiplyVectors( v, w ); - - } - - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; + this.w = a.w - b.w; return this; @@ -1853,136 +2069,187 @@ this.x *= scalar; this.y *= scalar; this.z *= scalar; + this.w *= scalar; return this; }, - multiplyVectors: function ( a, b ) { + applyMatrix4: function ( m ) { - this.x = a.x * b.x; - this.y = a.y * b.y; - this.z = a.z * b.z; + 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; }, - applyEuler: function ( euler ) { + divideScalar: function ( scalar ) { - if ( ! ( euler && euler.isEuler ) ) { + return this.multiplyScalar( 1 / scalar ); - console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + }, - } + setAxisAngleFromQuaternion: function ( q ) { - return this.applyQuaternion( _quaternion.setFromEuler( euler ) ); + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm - }, + // q is assumed to be normalized - applyAxisAngle: function ( axis, angle ) { + this.w = 2 * Math.acos( q.w ); - return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); + var s = Math.sqrt( 1 - q.w * q.w ); - }, + if ( s < 0.0001 ) { - applyMatrix3: function ( m ) { + this.x = 1; + this.y = 0; + this.z = 0; - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + } else { - this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; - this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; - this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; + this.x = q.x / s; + this.y = q.y / s; + this.z = q.z / s; + + } return this; }, - applyNormalMatrix: function ( m ) { + setAxisAngleFromRotationMatrix: function ( m ) { - return this.applyMatrix3( m ).normalize(); + // 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) - applyMatrix4: function ( m ) { + 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 - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + te = m.elements, - var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); + 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 ]; - 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; + if ( ( Math.abs( m12 - m21 ) < epsilon ) && + ( Math.abs( m13 - m31 ) < epsilon ) && + ( Math.abs( m23 - m32 ) < epsilon ) ) { - return this; + // 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 ) ) { - applyQuaternion: function ( q ) { + // this singularity is identity matrix so angle = 0 - var x = this.x, y = this.y, z = this.z; - var qx = q.x, qy = q.y, qz = q.z, qw = q.w; + this.set( 1, 0, 0, 0 ); - // calculate quat * vector + return this; // zero angle, arbitrary axis - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = - qx * x - qy * y - qz * z; + } - // calculate result * inverse quat + // otherwise this singularity is angle = 180 - this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; - this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; - this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; + angle = Math.PI; - return this; + 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 ) ) { - project: function ( camera ) { + // m11 is the largest diagonal term - return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); + if ( xx < epsilon ) { - }, + x = 0; + y = 0.707106781; + z = 0.707106781; - unproject: function ( camera ) { + } else { - return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); + x = Math.sqrt( xx ); + y = xy / x; + z = xz / x; - }, + } - transformDirection: function ( m ) { + } else if ( yy > zz ) { - // input: THREE.Matrix4 affine matrix - // vector interpreted as a direction + // m22 is the largest diagonal term - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + if ( yy < epsilon ) { - this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; - this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; - this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; + x = 0.707106781; + y = 0; + z = 0.707106781; - return this.normalize(); + } else { - }, + y = Math.sqrt( yy ); + x = xy / y; + z = yz / y; - divide: function ( v ) { + } - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; + } else { - return this; + // m33 is the largest diagonal term so base result on this - }, + if ( zz < epsilon ) { - divideScalar: function ( scalar ) { + x = 0.707106781; + y = 0.707106781; + z = 0; - return this.multiplyScalar( 1 / scalar ); + } 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; }, @@ -1991,6 +2258,7 @@ 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; @@ -2001,6 +2269,7 @@ 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; @@ -2013,6 +2282,7 @@ 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; @@ -2023,6 +2293,7 @@ this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); return this; @@ -2041,6 +2312,7 @@ 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; @@ -2051,6 +2323,7 @@ this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); this.z = Math.ceil( this.z ); + this.w = Math.ceil( this.w ); return this; @@ -2061,6 +2334,7 @@ this.x = Math.round( this.x ); this.y = Math.round( this.y ); this.z = Math.round( this.z ); + this.w = Math.round( this.w ); return this; @@ -2071,6 +2345,7 @@ 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 ); this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); return this; @@ -2081,6 +2356,7 @@ this.x = - this.x; this.y = - this.y; this.z = - this.z; + this.w = - this.w; return this; @@ -2088,27 +2364,25 @@ dot: function ( v ) { - return this.x * v.x + this.y * v.y + this.z * v.z; + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; }, - // TODO lengthSquared? - lengthSq: function () { - return this.x * this.x + this.y * this.y + this.z * this.z; + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; }, length: function () { - return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); }, manhattanLength: function () { - return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); }, @@ -2129,6 +2403,7 @@ this.x += ( v.x - this.x ) * alpha; this.y += ( v.y - this.y ) * alpha; this.z += ( v.z - this.z ) * alpha; + this.w += ( v.w - this.w ) * alpha; return this; @@ -2140,201 +2415,187 @@ }, - cross: function ( v, w ) { - - if ( w !== undefined ) { - - console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); - return this.crossVectors( v, w ); - - } + equals: function ( v ) { - return this.crossVectors( this, v ); + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); }, - crossVectors: function ( a, b ) { + fromArray: function ( array, offset ) { - var ax = a.x, ay = a.y, az = a.z; - var bx = b.x, by = b.y, bz = b.z; + if ( offset === undefined ) { offset = 0; } - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + this.w = array[ offset + 3 ]; return this; }, - projectOnVector: function ( v ) { + toArray: function ( array, offset ) { - // v cannot be the zero v + if ( array === undefined ) { array = []; } + if ( offset === undefined ) { offset = 0; } - var scalar = v.dot( this ) / v.lengthSq(); + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + array[ offset + 3 ] = this.w; - return this.copy( v ).multiplyScalar( scalar ); + return array; }, - projectOnPlane: function ( planeNormal ) { - - _vector.copy( this ).projectOnVector( planeNormal ); + fromBufferAttribute: function ( attribute, index, offset ) { - return this.sub( _vector ); + if ( offset !== undefined ) { - }, + console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); - reflect: function ( normal ) { + } - // reflect incident vector off plane orthogonal to normal - // normal is assumed to have unit length + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + this.w = attribute.getW( index ); - return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); + return this; }, - angleTo: function ( v ) { - - var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); + random: function () { - if ( denominator === 0 ) { console.error( 'THREE.Vector3: angleTo() can\'t handle zero length vectors.' ); } + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + this.w = Math.random(); - var theta = this.dot( v ) / denominator; + return this; - // clamp, to handle numerical problems + } - return Math.acos( _Math.clamp( theta, - 1, 1 ) ); + } ); - }, + /** + * @author szimek / https://github.com/szimek/ + * @author alteredq / http://alteredqualia.com/ + * @author Marius Kintel / https://github.com/kintel + */ - distanceTo: function ( v ) { + /* + In options, we can specify: + * Texture parameters for an auto-generated target texture + * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers + */ + function WebGLRenderTarget( width, height, options ) { - return Math.sqrt( this.distanceToSquared( v ) ); + this.width = width; + this.height = height; - }, + this.scissor = new Vector4( 0, 0, width, height ); + this.scissorTest = false; - distanceToSquared: function ( v ) { + this.viewport = new Vector4( 0, 0, width, height ); - var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + options = options || {}; - return dx * dx + dy * dy + dz * dz; + this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); - }, + this.texture.image = {}; + this.texture.image.width = width; + this.texture.image.height = height; - manhattanDistanceTo: function ( v ) { + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; - return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); + this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; + this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; + this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; - }, + } - setFromSpherical: function ( s ) { + WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { - return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); + constructor: WebGLRenderTarget, - }, + isWebGLRenderTarget: true, - setFromSphericalCoords: function ( radius, phi, theta ) { + setSize: function ( width, height ) { - var sinPhiRadius = Math.sin( phi ) * radius; + if ( this.width !== width || this.height !== height ) { - this.x = sinPhiRadius * Math.sin( theta ); - this.y = Math.cos( phi ) * radius; - this.z = sinPhiRadius * Math.cos( theta ); + this.width = width; + this.height = height; - return this; + this.texture.image.width = width; + this.texture.image.height = height; - }, + this.dispose(); - setFromCylindrical: function ( c ) { + } - return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); + this.viewport.set( 0, 0, width, height ); + this.scissor.set( 0, 0, width, height ); }, - setFromCylindricalCoords: function ( radius, theta, y ) { - - this.x = radius * Math.sin( theta ); - this.y = y; - this.z = radius * Math.cos( theta ); + clone: function () { - return this; + return new this.constructor().copy( this ); }, - setFromMatrixPosition: function ( m ) { - - var e = m.elements; - - this.x = e[ 12 ]; - this.y = e[ 13 ]; - this.z = e[ 14 ]; - - return this; + copy: function ( source ) { - }, + this.width = source.width; + this.height = source.height; - setFromMatrixScale: function ( m ) { + this.viewport.copy( source.viewport ); - var sx = this.setFromMatrixColumn( m, 0 ).length(); - var sy = this.setFromMatrixColumn( m, 1 ).length(); - var sz = this.setFromMatrixColumn( m, 2 ).length(); + this.texture = source.texture.clone(); - this.x = sx; - this.y = sy; - this.z = sz; + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; return this; }, - setFromMatrixColumn: function ( m, index ) { - - return this.fromArray( m.elements, index * 4 ); - - }, - - equals: function ( v ) { - - return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); - - }, - - fromArray: function ( array, offset ) { + dispose: function () { - if ( offset === undefined ) { offset = 0; } + this.dispatchEvent( { type: 'dispose' } ); - this.x = array[ offset ]; - this.y = array[ offset + 1 ]; - this.z = array[ offset + 2 ]; + } - return this; + } ); - }, + /** + * @author Mugen87 / https://github.com/Mugen87 + * @author Matt DesLauriers / @mattdesl + */ - toArray: function ( array, offset ) { + function WebGLMultisampleRenderTarget( width, height, options ) { - if ( array === undefined ) { array = []; } - if ( offset === undefined ) { offset = 0; } + WebGLRenderTarget.call( this, width, height, options ); - array[ offset ] = this.x; - array[ offset + 1 ] = this.y; - array[ offset + 2 ] = this.z; + this.samples = 4; - return array; + } - }, + WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { - fromBufferAttribute: function ( attribute, index, offset ) { + constructor: WebGLMultisampleRenderTarget, - if ( offset !== undefined ) { + isWebGLMultisampleRenderTarget: true, - console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + copy: function ( source ) { - } + WebGLRenderTarget.prototype.copy.call( this, source ); - this.x = attribute.getX( index ); - this.y = attribute.getY( index ); - this.z = attribute.getZ( index ); + this.samples = source.samples; return this; @@ -2343,822 +2604,703 @@ } ); /** + * @author mikael emtinger / http://gomo.se/ * @author alteredq / http://alteredqualia.com/ * @author WestLangley / http://github.com/WestLangley * @author bhouston / http://clara.io - * @author tschw */ - var _vector$1 = new Vector3(); + function Quaternion( x, y, z, w ) { - function Matrix3() { + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this._w = ( w !== undefined ) ? w : 1; - this.elements = [ + } - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 + Object.assign( Quaternion, { - ]; + slerp: function ( qa, qb, qm, t ) { - if ( arguments.length > 0 ) { + return qm.copy( qa ).slerp( qb, t ); - console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); + }, - } + slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { - } + // fuzz-free, array-based Quaternion SLERP operation - Object.assign( Matrix3.prototype, { + var x0 = src0[ srcOffset0 + 0 ], + y0 = src0[ srcOffset0 + 1 ], + z0 = src0[ srcOffset0 + 2 ], + w0 = src0[ srcOffset0 + 3 ], - isMatrix3: true, + x1 = src1[ srcOffset1 + 0 ], + y1 = src1[ srcOffset1 + 1 ], + z1 = src1[ srcOffset1 + 2 ], + w1 = src1[ srcOffset1 + 3 ]; - set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { + if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { - var te = this.elements; + var s = 1 - t, - te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; - te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; - te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; + cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, - return this; + dir = ( cos >= 0 ? 1 : - 1 ), + sqrSin = 1 - cos * cos; - }, + // Skip the Slerp for tiny steps to avoid numeric problems: + if ( sqrSin > Number.EPSILON ) { - identity: function () { + var sin = Math.sqrt( sqrSin ), + len = Math.atan2( sin, cos * dir ); - this.set( + s = Math.sin( s * len ) / sin; + t = Math.sin( t * len ) / sin; - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 + } - ); + var tDir = t * dir; - return this; + x0 = x0 * s + x1 * tDir; + y0 = y0 * s + y1 * tDir; + z0 = z0 * s + z1 * tDir; + w0 = w0 * s + w1 * tDir; - }, + // Normalize in case we just did a lerp: + if ( s === 1 - t ) { - clone: function () { + var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); - return new this.constructor().fromArray( this.elements ); + x0 *= f; + y0 *= f; + z0 *= f; + w0 *= f; - }, + } - copy: function ( m ) { + } - var te = this.elements; - var me = m.elements; + dst[ dstOffset ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; - te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; - te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; - te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; + }, - return this; + multiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) { - }, + var x0 = src0[ srcOffset0 ]; + var y0 = src0[ srcOffset0 + 1 ]; + var z0 = src0[ srcOffset0 + 2 ]; + var w0 = src0[ srcOffset0 + 3 ]; - setFromMatrix4: function ( m ) { + var x1 = src1[ srcOffset1 ]; + var y1 = src1[ srcOffset1 + 1 ]; + var z1 = src1[ srcOffset1 + 2 ]; + var w1 = src1[ srcOffset1 + 3 ]; - var me = m.elements; + dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1; + dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1; + dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1; + dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1; - this.set( + return dst; - me[ 0 ], me[ 4 ], me[ 8 ], - me[ 1 ], me[ 5 ], me[ 9 ], - me[ 2 ], me[ 6 ], me[ 10 ] + } - ); + } ); - return this; + Object.defineProperties( Quaternion.prototype, { - }, + x: { - applyToBufferAttribute: function ( attribute ) { + get: function () { - for ( var i = 0, l = attribute.count; i < l; i ++ ) { + return this._x; - _vector$1.x = attribute.getX( i ); - _vector$1.y = attribute.getY( i ); - _vector$1.z = attribute.getZ( i ); + }, - _vector$1.applyMatrix3( this ); + set: function ( value ) { - attribute.setXYZ( i, _vector$1.x, _vector$1.y, _vector$1.z ); + this._x = value; + this._onChangeCallback(); } - return attribute; - }, - multiply: function ( m ) { + y: { - return this.multiplyMatrices( this, m ); + get: function () { - }, + return this._y; - premultiply: function ( m ) { + }, - return this.multiplyMatrices( m, this ); + set: function ( value ) { - }, + this._y = value; + this._onChangeCallback(); - multiplyMatrices: function ( a, b ) { + } - var ae = a.elements; - var be = b.elements; - var te = this.elements; + }, - var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; - var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; - var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; + z: { - var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; - var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; - var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; + get: function () { - te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; - te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; - te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; + return this._z; - te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; - te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; - te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; + }, - te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; - te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; - te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + set: function ( value ) { - return this; + this._z = value; + this._onChangeCallback(); + + } }, - multiplyScalar: function ( s ) { + w: { - var te = this.elements; + get: function () { - te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; - te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; - te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; + return this._w; - return this; + }, - }, + set: function ( value ) { - determinant: function () { + this._w = value; + this._onChangeCallback(); - var te = this.elements; + } - var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], - d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], - g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; + } - return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; + } ); - }, + Object.assign( Quaternion.prototype, { - getInverse: function ( matrix, throwOnDegenerate ) { + isQuaternion: true, - if ( matrix && matrix.isMatrix4 ) { + set: function ( x, y, z, w ) { - console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." ); + this._x = x; + this._y = y; + this._z = z; + this._w = w; - } + this._onChangeCallback(); - var me = matrix.elements, - te = this.elements, + return this; - n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], - n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ], - n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ], + }, - t11 = n33 * n22 - n32 * n23, - t12 = n32 * n13 - n33 * n12, - t13 = n23 * n12 - n22 * n13, - - det = n11 * t11 + n21 * t12 + n31 * t13; - - if ( det === 0 ) { - - var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0"; - - if ( throwOnDegenerate === true ) { - - throw new Error( msg ); - - } else { - - console.warn( msg ); - - } - - return this.identity(); + clone: function () { - } + return new this.constructor( this._x, this._y, this._z, this._w ); - var detInv = 1 / det; + }, - te[ 0 ] = t11 * detInv; - te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; - te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; + copy: function ( quaternion ) { - te[ 3 ] = t12 * detInv; - te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; - te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + this._x = quaternion.x; + this._y = quaternion.y; + this._z = quaternion.z; + this._w = quaternion.w; - te[ 6 ] = t13 * detInv; - te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; - te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; + this._onChangeCallback(); return this; }, - transpose: function () { - - var tmp, m = this.elements; + setFromEuler: function ( euler, update ) { - tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; - tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; - tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; + if ( ! ( euler && euler.isEuler ) ) { - return this; + throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); - }, + } - getNormalMatrix: function ( matrix4 ) { + var x = euler._x, y = euler._y, z = euler._z, order = euler.order; - return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); + // http://www.mathworks.com/matlabcentral/fileexchange/ + // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ + // content/SpinCalc.m - }, + var cos = Math.cos; + var sin = Math.sin; - transposeIntoArray: function ( r ) { + var c1 = cos( x / 2 ); + var c2 = cos( y / 2 ); + var c3 = cos( z / 2 ); - var m = this.elements; + var s1 = sin( x / 2 ); + var s2 = sin( y / 2 ); + var s3 = sin( z / 2 ); - r[ 0 ] = m[ 0 ]; - r[ 1 ] = m[ 3 ]; - r[ 2 ] = m[ 6 ]; - r[ 3 ] = m[ 1 ]; - r[ 4 ] = m[ 4 ]; - r[ 5 ] = m[ 7 ]; - r[ 6 ] = m[ 2 ]; - r[ 7 ] = m[ 5 ]; - r[ 8 ] = m[ 8 ]; + switch ( order ) { - return this; + case 'XYZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - }, + case 'YXZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) { + case 'ZXY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - var c = Math.cos( rotation ); - var s = Math.sin( rotation ); + case 'ZYX': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - this.set( - sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, - - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, - 0, 0, 1 - ); + case 'YZX': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - }, + case 'XZY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - scale: function ( sx, sy ) { + default: + console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order ); - var te = this.elements; + } - te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; - te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; + if ( update !== false ) { this._onChangeCallback(); } return this; }, - rotate: function ( theta ) { + setFromAxisAngle: function ( axis, angle ) { - var c = Math.cos( theta ); - var s = Math.sin( theta ); + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm - var te = this.elements; + // assumes axis is normalized - var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; - var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; + var halfAngle = angle / 2, s = Math.sin( halfAngle ); - te[ 0 ] = c * a11 + s * a21; - te[ 3 ] = c * a12 + s * a22; - te[ 6 ] = c * a13 + s * a23; + this._x = axis.x * s; + this._y = axis.y * s; + this._z = axis.z * s; + this._w = Math.cos( halfAngle ); - te[ 1 ] = - s * a11 + c * a21; - te[ 4 ] = - s * a12 + c * a22; - te[ 7 ] = - s * a13 + c * a23; + this._onChangeCallback(); return this; }, - translate: function ( tx, ty ) { + setFromRotationMatrix: function ( m ) { - var te = this.elements; + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; - te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - return this; + var 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 ], - equals: function ( matrix ) { + trace = m11 + m22 + m33, + s; - var te = this.elements; - var me = matrix.elements; + if ( trace > 0 ) { - for ( var i = 0; i < 9; i ++ ) { + s = 0.5 / Math.sqrt( trace + 1.0 ); - if ( te[ i ] !== me[ i ] ) { return false; } + this._w = 0.25 / s; + this._x = ( m32 - m23 ) * s; + this._y = ( m13 - m31 ) * s; + this._z = ( m21 - m12 ) * s; - } + } else if ( m11 > m22 && m11 > m33 ) { - return true; + s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); - }, + this._w = ( m32 - m23 ) / s; + this._x = 0.25 * s; + this._y = ( m12 + m21 ) / s; + this._z = ( m13 + m31 ) / s; - fromArray: function ( array, offset ) { + } else if ( m22 > m33 ) { - if ( offset === undefined ) { offset = 0; } + s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); - for ( var i = 0; i < 9; i ++ ) { + this._w = ( m13 - m31 ) / s; + this._x = ( m12 + m21 ) / s; + this._y = 0.25 * s; + this._z = ( m23 + m32 ) / s; - this.elements[ i ] = array[ i + offset ]; + } else { + + s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + + this._w = ( m21 - m12 ) / s; + this._x = ( m13 + m31 ) / s; + this._y = ( m23 + m32 ) / s; + this._z = 0.25 * s; } + this._onChangeCallback(); + return this; }, - toArray: function ( array, offset ) { + setFromUnitVectors: function ( vFrom, vTo ) { - if ( array === undefined ) { array = []; } - if ( offset === undefined ) { offset = 0; } + // assumes direction vectors vFrom and vTo are normalized - var te = this.elements; + var EPS = 0.000001; - array[ offset ] = te[ 0 ]; - array[ offset + 1 ] = te[ 1 ]; - array[ offset + 2 ] = te[ 2 ]; + var r = vFrom.dot( vTo ) + 1; - array[ offset + 3 ] = te[ 3 ]; - array[ offset + 4 ] = te[ 4 ]; - array[ offset + 5 ] = te[ 5 ]; + if ( r < EPS ) { - array[ offset + 6 ] = te[ 6 ]; - array[ offset + 7 ] = te[ 7 ]; - array[ offset + 8 ] = te[ 8 ]; + r = 0; - return array; + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { - } + this._x = - vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; - } ); + } else { - /** - * @author mrdoob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * @author szimek / https://github.com/szimek/ - */ + this._x = 0; + this._y = - vFrom.z; + this._z = vFrom.y; + this._w = r; - var _canvas; + } - var ImageUtils = { + } else { - getDataURL: function ( image ) { + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 - var canvas; + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; - if ( typeof HTMLCanvasElement == 'undefined' ) { + } - return image.src; + return this.normalize(); - } else if ( image instanceof HTMLCanvasElement ) { + }, - canvas = image; + angleTo: function ( q ) { - } else { + return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) ); - if ( _canvas === undefined ) { _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); } + }, - _canvas.width = image.width; - _canvas.height = image.height; + rotateTowards: function ( q, step ) { - var context = _canvas.getContext( '2d' ); + var angle = this.angleTo( q ); - if ( image instanceof ImageData ) { + if ( angle === 0 ) { return this; } - context.putImageData( image, 0, 0 ); + var t = Math.min( 1, step / angle ); - } else { + this.slerp( q, t ); - context.drawImage( image, 0, 0, image.width, image.height ); + return this; - } + }, - canvas = _canvas; + inverse: function () { - } + // quaternion is assumed to have unit length - if ( canvas.width > 2048 || canvas.height > 2048 ) { + return this.conjugate(); - return canvas.toDataURL( 'image/jpeg', 0.6 ); + }, - } else { + conjugate: function () { - return canvas.toDataURL( 'image/png' ); + this._x *= - 1; + this._y *= - 1; + this._z *= - 1; - } + this._onChangeCallback(); - } + return this; - }; + }, - /** - * @author mrdoob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * @author szimek / https://github.com/szimek/ - */ + dot: function ( v ) { - var textureId = 0; + return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; - function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { + }, - Object.defineProperty( this, 'id', { value: textureId ++ } ); + lengthSq: function () { - this.uuid = _Math.generateUUID(); + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; - this.name = ''; + }, - this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; - this.mipmaps = []; + length: function () { - this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; + return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); - this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; - this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; + }, - this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; - this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; + normalize: function () { - this.anisotropy = anisotropy !== undefined ? anisotropy : 1; + var l = this.length(); - this.format = format !== undefined ? format : RGBAFormat; - this.internalFormat = null; - this.type = type !== undefined ? type : UnsignedByteType; + if ( l === 0 ) { - this.offset = new Vector2( 0, 0 ); - this.repeat = new Vector2( 1, 1 ); - this.center = new Vector2( 0, 0 ); - this.rotation = 0; + this._x = 0; + this._y = 0; + this._z = 0; + this._w = 1; - this.matrixAutoUpdate = true; - this.matrix = new Matrix3(); + } else { - 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) + l = 1 / l; - // 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._x = this._x * l; + this._y = this._y * l; + this._z = this._z * l; + this._w = this._w * l; - this.version = 0; - this.onUpdate = null; + } - } + this._onChangeCallback(); - Texture.DEFAULT_IMAGE = undefined; - Texture.DEFAULT_MAPPING = UVMapping; + return this; - Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { + }, - constructor: Texture, + multiply: function ( q, p ) { - isTexture: true, + if ( p !== undefined ) { - updateMatrix: function () { + console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); + return this.multiplyQuaternions( q, p ); - this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); + } + + return this.multiplyQuaternions( this, q ); }, - clone: function () { + premultiply: function ( q ) { - return new this.constructor().copy( this ); + return this.multiplyQuaternions( q, this ); }, - copy: function ( source ) { + multiplyQuaternions: function ( a, b ) { - this.name = source.name; + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm - this.image = source.image; - this.mipmaps = source.mipmaps.slice( 0 ); + var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; + var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; - this.mapping = source.mapping; + this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; - this.wrapS = source.wrapS; - this.wrapT = source.wrapT; + this._onChangeCallback(); - this.magFilter = source.magFilter; - this.minFilter = source.minFilter; + return this; - this.anisotropy = source.anisotropy; + }, - this.format = source.format; - this.internalFormat = source.internalFormat; - this.type = source.type; + slerp: function ( qb, t ) { - this.offset.copy( source.offset ); - this.repeat.copy( source.repeat ); - this.center.copy( source.center ); - this.rotation = source.rotation; + if ( t === 0 ) { return this; } + if ( t === 1 ) { return this.copy( qb ); } - this.matrixAutoUpdate = source.matrixAutoUpdate; - this.matrix.copy( source.matrix ); + var x = this._x, y = this._y, z = this._z, w = this._w; - this.generateMipmaps = source.generateMipmaps; - this.premultiplyAlpha = source.premultiplyAlpha; - this.flipY = source.flipY; - this.unpackAlignment = source.unpackAlignment; - this.encoding = source.encoding; + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ - return this; + var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; - }, + if ( cosHalfTheta < 0 ) { - toJSON: function ( meta ) { + this._w = - qb._w; + this._x = - qb._x; + this._y = - qb._y; + this._z = - qb._z; - var isRootObject = ( meta === undefined || typeof meta === 'string' ); + cosHalfTheta = - cosHalfTheta; - if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { + } else { - return meta.textures[ this.uuid ]; + this.copy( qb ); } - var output = { - - metadata: { - version: 4.5, - type: 'Texture', - generator: 'Texture.toJSON' - }, + if ( cosHalfTheta >= 1.0 ) { - uuid: this.uuid, - name: this.name, + this._w = w; + this._x = x; + this._y = y; + this._z = z; - mapping: this.mapping, + return this; - repeat: [ this.repeat.x, this.repeat.y ], - offset: [ this.offset.x, this.offset.y ], - center: [ this.center.x, this.center.y ], - rotation: this.rotation, + } - wrap: [ this.wrapS, this.wrapT ], + var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; - format: this.format, - type: this.type, - encoding: this.encoding, + if ( sqrSinHalfTheta <= Number.EPSILON ) { - minFilter: this.minFilter, - magFilter: this.magFilter, - anisotropy: this.anisotropy, + var s = 1 - t; + this._w = s * w + t * this._w; + this._x = s * x + t * this._x; + this._y = s * y + t * this._y; + this._z = s * z + t * this._z; - flipY: this.flipY, + this.normalize(); + this._onChangeCallback(); - premultiplyAlpha: this.premultiplyAlpha, - unpackAlignment: this.unpackAlignment + return this; - }; + } - if ( this.image !== undefined ) { + var sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); + var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); + var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; - // TODO: Move to THREE.Image + this._w = ( w * ratioA + this._w * ratioB ); + this._x = ( x * ratioA + this._x * ratioB ); + this._y = ( y * ratioA + this._y * ratioB ); + this._z = ( z * ratioA + this._z * ratioB ); - var image = this.image; + this._onChangeCallback(); - if ( image.uuid === undefined ) { + return this; - image.uuid = _Math.generateUUID(); // UGH + }, - } + equals: function ( quaternion ) { - if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); - var url; + }, - if ( Array.isArray( image ) ) { + fromArray: function ( array, offset ) { - // process array of images e.g. CubeTexture + if ( offset === undefined ) { offset = 0; } - url = []; + this._x = array[ offset ]; + this._y = array[ offset + 1 ]; + this._z = array[ offset + 2 ]; + this._w = array[ offset + 3 ]; - for ( var i = 0, l = image.length; i < l; i ++ ) { + this._onChangeCallback(); - url.push( ImageUtils.getDataURL( image[ i ] ) ); + return this; - } + }, - } else { + toArray: function ( array, offset ) { - // process single image + if ( array === undefined ) { array = []; } + if ( offset === undefined ) { offset = 0; } - url = ImageUtils.getDataURL( image ); + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._w; - } + return array; - meta.images[ image.uuid ] = { - uuid: image.uuid, - url: url - }; + }, - } + fromBufferAttribute: function ( attribute, index ) { - output.image = image.uuid; + this._x = attribute.getX( index ); + this._y = attribute.getY( index ); + this._z = attribute.getZ( index ); + this._w = attribute.getW( index ); - } + return this; - if ( ! isRootObject ) { + }, - meta.textures[ this.uuid ] = output; + _onChange: function ( callback ) { - } + this._onChangeCallback = callback; - return output; + return this; }, - dispose: function () { - - this.dispatchEvent( { type: 'dispose' } ); - - }, - - transformUv: function ( uv ) { - - if ( this.mapping !== UVMapping ) { return uv; } - - uv.applyMatrix3( this.matrix ); - - 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; - - } - - return uv; - - } - - } ); - - Object.defineProperty( Texture.prototype, "needsUpdate", { - - set: function ( value ) { - - if ( value === true ) { this.version ++; } - - } + _onChangeCallback: function () {} } ); /** - * @author supereggbert / http://www.paulbrunt.co.uk/ + * @author mrdoob / http://mrdoob.com/ + * @author kile / http://kile.stravaganza.org/ * @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 ) { + var _vector = new Vector3(); + var _quaternion = new Quaternion(); + + function Vector3( x, y, z ) { this.x = x || 0; this.y = y || 0; this.z = z || 0; - this.w = ( w !== undefined ) ? w : 1; } - Object.defineProperties( Vector4.prototype, { - - "width": { - - get: function () { - - return this.z; - - }, - - set: function ( value ) { - - this.z = value; - - } - - }, - - "height": { - - get: function () { - - return this.w; - - }, - - set: function ( value ) { - - this.w = value; - - } - - } - - } ); - - Object.assign( Vector4.prototype, { + Object.assign( Vector3.prototype, { - isVector4: true, + isVector3: true, - set: function ( x, y, z, w ) { + set: function ( x, y, z ) { this.x = x; this.y = y; this.z = z; - this.w = w; return this; @@ -3169,7 +3311,6 @@ this.x = scalar; this.y = scalar; this.z = scalar; - this.w = scalar; return this; @@ -3199,14 +3340,6 @@ }, - setW: function ( w ) { - - this.w = w; - - return this; - - }, - setComponent: function ( index, value ) { switch ( index ) { @@ -3214,7 +3347,6 @@ 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 ); } @@ -3230,7 +3362,6 @@ 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 ); } @@ -3239,7 +3370,7 @@ clone: function () { - return new this.constructor( this.x, this.y, this.z, this.w ); + return new this.constructor( this.x, this.y, this.z ); }, @@ -3248,7 +3379,6 @@ this.x = v.x; this.y = v.y; this.z = v.z; - this.w = ( v.w !== undefined ) ? v.w : 1; return this; @@ -3258,7 +3388,7 @@ if ( w !== undefined ) { - console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } @@ -3266,7 +3396,6 @@ this.x += v.x; this.y += v.y; this.z += v.z; - this.w += v.w; return this; @@ -3277,7 +3406,6 @@ this.x += s; this.y += s; this.z += s; - this.w += s; return this; @@ -3288,7 +3416,6 @@ 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; @@ -3299,7 +3426,6 @@ this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; - this.w += v.w * s; return this; @@ -3309,7 +3435,7 @@ if ( w !== undefined ) { - console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } @@ -3317,7 +3443,6 @@ this.x -= v.x; this.y -= v.y; this.z -= v.z; - this.w -= v.w; return this; @@ -3328,7 +3453,6 @@ this.x -= s; this.y -= s; this.z -= s; - this.w -= s; return this; @@ -3339,198 +3463,163 @@ 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; + multiply: function ( v, w ) { - }, + if ( w !== undefined ) { - applyMatrix4: function ( m ) { + console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); + return this.multiplyVectors( v, w ); - 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; + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; return this; }, - divideScalar: function ( scalar ) { - - return this.multiplyScalar( 1 / scalar ); + multiplyScalar: function ( scalar ) { - }, + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; - setAxisAngleFromQuaternion: function ( q ) { + return this; - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + }, - // q is assumed to be normalized + multiplyVectors: function ( a, b ) { - this.w = 2 * Math.acos( q.w ); + this.x = a.x * b.x; + this.y = a.y * b.y; + this.z = a.z * b.z; - var s = Math.sqrt( 1 - q.w * q.w ); + return this; - if ( s < 0.0001 ) { + }, - this.x = 1; - this.y = 0; - this.z = 0; + applyEuler: function ( euler ) { - } else { + if ( ! ( euler && euler.isEuler ) ) { - this.x = q.x / s; - this.y = q.y / s; - this.z = q.z / s; + console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); } - return this; + return this.applyQuaternion( _quaternion.setFromEuler( euler ) ); }, - 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, + applyAxisAngle: function ( axis, angle ) { - 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 ]; + return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); - 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 + applyMatrix3: function ( m ) { - if ( ( Math.abs( m12 + m21 ) < epsilon2 ) && - ( Math.abs( m13 + m31 ) < epsilon2 ) && - ( Math.abs( m23 + m32 ) < epsilon2 ) && - ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - // this singularity is identity matrix so angle = 0 + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; + this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; - this.set( 1, 0, 0, 0 ); + return this; - return this; // zero angle, arbitrary axis + }, - } + applyNormalMatrix: function ( m ) { - // otherwise this singularity is angle = 180 + return this.applyMatrix3( m ).normalize(); - 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; + applyMatrix4: function ( m ) { - if ( ( xx > yy ) && ( xx > zz ) ) { + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - // m11 is the largest diagonal term + var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); - if ( xx < epsilon ) { + 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; - x = 0; - y = 0.707106781; - z = 0.707106781; + return this; - } else { + }, - x = Math.sqrt( xx ); - y = xy / x; - z = xz / x; + applyQuaternion: function ( q ) { - } + var x = this.x, y = this.y, z = this.z; + var qx = q.x, qy = q.y, qz = q.z, qw = q.w; - } else if ( yy > zz ) { + // calculate quat * vector - // m22 is the largest diagonal term + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = - qx * x - qy * y - qz * z; - if ( yy < epsilon ) { + // calculate result * inverse quat - x = 0.707106781; - y = 0; - z = 0.707106781; + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; - } else { + return this; - y = Math.sqrt( yy ); - x = xy / y; - z = yz / y; + }, - } + project: function ( camera ) { - } else { + return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); - // m33 is the largest diagonal term so base result on this + }, - if ( zz < epsilon ) { + unproject: function ( camera ) { - x = 0.707106781; - y = 0.707106781; - z = 0; + return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); - } else { + }, - z = Math.sqrt( zz ); - x = xz / z; - y = yz / z; + transformDirection: function ( m ) { - } + // input: THREE.Matrix4 affine matrix + // vector interpreted as a direction - } + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - this.set( x, y, z, angle ); + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; - return this; // return 180 deg rotation + return this.normalize(); - } + }, - // as we have reached here there are no singularities so we can handle normally + divide: function ( v ) { - var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) + - ( m13 - m31 ) * ( m13 - m31 ) + - ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; - if ( Math.abs( s ) < 0.001 ) { s = 1; } + return this; - // 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 ); + divideScalar: function ( scalar ) { - return this; + return this.multiplyScalar( 1 / scalar ); }, @@ -3539,7 +3628,6 @@ 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; @@ -3550,7 +3638,6 @@ 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; @@ -3563,7 +3650,6 @@ 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; @@ -3574,7 +3660,6 @@ this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); - this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); return this; @@ -3593,7 +3678,6 @@ 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; @@ -3604,7 +3688,6 @@ this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); this.z = Math.ceil( this.z ); - this.w = Math.ceil( this.w ); return this; @@ -3615,7 +3698,6 @@ this.x = Math.round( this.x ); this.y = Math.round( this.y ); this.z = Math.round( this.z ); - this.w = Math.round( this.w ); return this; @@ -3626,7 +3708,6 @@ 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 ); this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); - this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); return this; @@ -3637,7 +3718,6 @@ this.x = - this.x; this.y = - this.y; this.z = - this.z; - this.w = - this.w; return this; @@ -3645,25 +3725,27 @@ dot: function ( v ) { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + return this.x * v.x + this.y * v.y + this.z * v.z; }, + // TODO lengthSquared? + lengthSq: function () { - return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + return this.x * this.x + this.y * this.y + this.z * this.z; }, length: function () { - return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); }, manhattanLength: function () { - return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); }, @@ -3684,7 +3766,6 @@ this.x += ( v.x - this.x ) * alpha; this.y += ( v.y - this.y ) * alpha; this.z += ( v.z - this.z ) * alpha; - this.w += ( v.w - this.w ) * alpha; return this; @@ -3696,176 +3777,219 @@ }, - equals: function ( v ) { + cross: function ( v, w ) { - return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); + return this.crossVectors( v, w ); + + } + + return this.crossVectors( this, v ); }, - fromArray: function ( array, offset ) { + crossVectors: function ( a, b ) { - if ( offset === undefined ) { offset = 0; } + var ax = a.x, ay = a.y, az = a.z; + var bx = b.x, by = b.y, bz = b.z; - this.x = array[ offset ]; - this.y = array[ offset + 1 ]; - this.z = array[ offset + 2 ]; - this.w = array[ offset + 3 ]; + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; return this; }, - toArray: function ( array, offset ) { + projectOnVector: function ( v ) { - if ( array === undefined ) { array = []; } - if ( offset === undefined ) { offset = 0; } + var denominator = v.lengthSq(); - array[ offset ] = this.x; - array[ offset + 1 ] = this.y; - array[ offset + 2 ] = this.z; - array[ offset + 3 ] = this.w; + if ( denominator === 0 ) { return this.set( 0, 0, 0 ); } - return array; + var scalar = v.dot( this ) / denominator; + + return this.copy( v ).multiplyScalar( scalar ); }, - fromBufferAttribute: function ( attribute, index, offset ) { + projectOnPlane: function ( planeNormal ) { - if ( offset !== undefined ) { + _vector.copy( this ).projectOnVector( planeNormal ); - console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); + return this.sub( _vector ); - } + }, - this.x = attribute.getX( index ); - this.y = attribute.getY( index ); - this.z = attribute.getZ( index ); - this.w = attribute.getW( index ); + reflect: function ( normal ) { - return this; + // reflect incident vector off plane orthogonal to normal + // normal is assumed to have unit length - } + return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); - } ); + }, - /** - * @author szimek / https://github.com/szimek/ - * @author alteredq / http://alteredqualia.com/ - * @author Marius Kintel / https://github.com/kintel - */ + angleTo: function ( v ) { - /* - In options, we can specify: - * Texture parameters for an auto-generated target texture - * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers - */ - function WebGLRenderTarget( width, height, options ) { + var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); - this.width = width; - this.height = height; + if ( denominator === 0 ) { return Math.PI / 2; } - this.scissor = new Vector4( 0, 0, width, height ); - this.scissorTest = false; + var theta = this.dot( v ) / denominator; - this.viewport = new Vector4( 0, 0, width, height ); + // clamp, to handle numerical problems - options = options || {}; + return Math.acos( MathUtils.clamp( theta, - 1, 1 ) ); - this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + }, - this.texture.image = {}; - this.texture.image.width = width; - this.texture.image.height = height; + distanceTo: function ( v ) { - this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; - this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + return Math.sqrt( this.distanceToSquared( v ) ); - this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; - this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; - this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + }, - } + distanceToSquared: function ( v ) { - WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { + var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; - constructor: WebGLRenderTarget, + return dx * dx + dy * dy + dz * dz; - isWebGLRenderTarget: true, + }, - setSize: function ( width, height ) { + manhattanDistanceTo: function ( v ) { - if ( this.width !== width || this.height !== height ) { + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); - this.width = width; - this.height = height; + }, - this.texture.image.width = width; - this.texture.image.height = height; + setFromSpherical: function ( s ) { - this.dispose(); + return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); - } + }, - this.viewport.set( 0, 0, width, height ); - this.scissor.set( 0, 0, width, height ); + setFromSphericalCoords: function ( radius, phi, theta ) { - }, + var sinPhiRadius = Math.sin( phi ) * radius; - clone: function () { + this.x = sinPhiRadius * Math.sin( theta ); + this.y = Math.cos( phi ) * radius; + this.z = sinPhiRadius * Math.cos( theta ); - return new this.constructor().copy( this ); + return this; }, - copy: function ( source ) { + setFromCylindrical: function ( c ) { - this.width = source.width; - this.height = source.height; + return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); - this.viewport.copy( source.viewport ); + }, - this.texture = source.texture.clone(); + setFromCylindricalCoords: function ( radius, theta, y ) { - this.depthBuffer = source.depthBuffer; - this.stencilBuffer = source.stencilBuffer; - this.depthTexture = source.depthTexture; + this.x = radius * Math.sin( theta ); + this.y = y; + this.z = radius * Math.cos( theta ); return this; }, - dispose: function () { + setFromMatrixPosition: function ( m ) { - this.dispatchEvent( { type: 'dispose' } ); + var e = m.elements; - } + this.x = e[ 12 ]; + this.y = e[ 13 ]; + this.z = e[ 14 ]; - } ); + return this; - /** - * @author Mugen87 / https://github.com/Mugen87 - * @author Matt DesLauriers / @mattdesl - */ + }, - function WebGLMultisampleRenderTarget( width, height, options ) { + setFromMatrixScale: function ( m ) { - WebGLRenderTarget.call( this, width, height, options ); + var sx = this.setFromMatrixColumn( m, 0 ).length(); + var sy = this.setFromMatrixColumn( m, 1 ).length(); + var sz = this.setFromMatrixColumn( m, 2 ).length(); - this.samples = 4; + this.x = sx; + this.y = sy; + this.z = sz; - } + return this; - WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { + }, - constructor: WebGLMultisampleRenderTarget, + setFromMatrixColumn: function ( m, index ) { - isWebGLMultisampleRenderTarget: true, + return this.fromArray( m.elements, index * 4 ); - copy: function ( source ) { + }, - WebGLRenderTarget.prototype.copy.call( this, source ); + setFromMatrix3Column: function ( m, index ) { - this.samples = source.samples; + return this.fromArray( m.elements, index * 3 ); + + }, + + equals: function ( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); + + }, + + fromArray: function ( array, offset ) { + + if ( offset === undefined ) { offset = 0; } + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + + return this; + + }, + + toArray: function ( array, offset ) { + + if ( array === undefined ) { array = []; } + if ( offset === undefined ) { offset = 0; } + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + + return array; + + }, + + fromBufferAttribute: function ( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + + return this; + + }, + + random: function () { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); return this; @@ -4288,24 +4412,6 @@ }, - applyToBufferAttribute: function ( attribute ) { - - for ( var i = 0, l = attribute.count; i < l; i ++ ) { - - _v1.x = attribute.getX( i ); - _v1.y = attribute.getY( i ); - _v1.z = attribute.getZ( i ); - - _v1.applyMatrix4( this ); - - attribute.setXYZ( i, _v1.x, _v1.y, _v1.z ); - - } - - return attribute; - - }, - determinant: function () { var te = this.elements; @@ -4397,6 +4503,12 @@ getInverse: function ( m, throwOnDegenerate ) { + if ( throwOnDegenerate !== undefined ) { + + console.warn( "THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate." ); + + } + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm var te = this.elements, me = m.elements, @@ -4413,23 +4525,7 @@ var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14; - if ( det === 0 ) { - - var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0"; - - if ( throwOnDegenerate === true ) { - - throw new Error( msg ); - - } else { - - console.warn( msg ); - - } - - return this.identity(); - - } + if ( det === 0 ) { return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); } var detInv = 1 / det; @@ -4923,7 +5019,7 @@ setFromRotationMatrix: function ( m, order, update ) { - var clamp = _Math.clamp; + var clamp = MathUtils.clamp; // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) @@ -4934,105 +5030,119 @@ order = order || this._order; - if ( order === 'XYZ' ) { + switch ( order ) { - this._y = Math.asin( clamp( m13, - 1, 1 ) ); + case 'XYZ': - if ( Math.abs( m13 ) < 0.9999999 ) { + this._y = Math.asin( clamp( m13, - 1, 1 ) ); - this._x = Math.atan2( - m23, m33 ); - this._z = Math.atan2( - m12, m11 ); + if ( Math.abs( m13 ) < 0.9999999 ) { - } else { + this._x = Math.atan2( - m23, m33 ); + this._z = Math.atan2( - m12, m11 ); - this._x = Math.atan2( m32, m22 ); - this._z = 0; + } else { - } + this._x = Math.atan2( m32, m22 ); + this._z = 0; - } else if ( order === 'YXZ' ) { + } - this._x = Math.asin( - clamp( m23, - 1, 1 ) ); + break; - if ( Math.abs( m23 ) < 0.9999999 ) { + case 'YXZ': - this._y = Math.atan2( m13, m33 ); - this._z = Math.atan2( m21, m22 ); + this._x = Math.asin( - clamp( m23, - 1, 1 ) ); - } else { + if ( Math.abs( m23 ) < 0.9999999 ) { - this._y = Math.atan2( - m31, m11 ); - this._z = 0; + this._y = Math.atan2( m13, m33 ); + this._z = Math.atan2( m21, m22 ); - } + } else { - } else if ( order === 'ZXY' ) { + this._y = Math.atan2( - m31, m11 ); + this._z = 0; - this._x = Math.asin( clamp( m32, - 1, 1 ) ); + } - if ( Math.abs( m32 ) < 0.9999999 ) { + break; - this._y = Math.atan2( - m31, m33 ); - this._z = Math.atan2( - m12, m22 ); + case 'ZXY': - } else { + this._x = Math.asin( clamp( m32, - 1, 1 ) ); - this._y = 0; - this._z = Math.atan2( m21, m11 ); + if ( Math.abs( m32 ) < 0.9999999 ) { - } + this._y = Math.atan2( - m31, m33 ); + this._z = Math.atan2( - m12, m22 ); - } else if ( order === 'ZYX' ) { + } else { - this._y = Math.asin( - clamp( m31, - 1, 1 ) ); + this._y = 0; + this._z = Math.atan2( m21, m11 ); - if ( Math.abs( m31 ) < 0.9999999 ) { + } - this._x = Math.atan2( m32, m33 ); - this._z = Math.atan2( m21, m11 ); + break; - } else { + case 'ZYX': - this._x = 0; - this._z = Math.atan2( - m12, m22 ); + this._y = Math.asin( - clamp( m31, - 1, 1 ) ); - } + if ( Math.abs( m31 ) < 0.9999999 ) { - } else if ( order === 'YZX' ) { + this._x = Math.atan2( m32, m33 ); + this._z = Math.atan2( m21, m11 ); + + } else { - this._z = Math.asin( clamp( m21, - 1, 1 ) ); + this._x = 0; + this._z = Math.atan2( - m12, m22 ); - if ( Math.abs( m21 ) < 0.9999999 ) { + } - this._x = Math.atan2( - m23, m22 ); - this._y = Math.atan2( - m31, m11 ); + break; - } else { + case 'YZX': - this._x = 0; - this._y = Math.atan2( m13, m33 ); + this._z = Math.asin( clamp( m21, - 1, 1 ) ); - } + if ( Math.abs( m21 ) < 0.9999999 ) { - } else if ( order === 'XZY' ) { + this._x = Math.atan2( - m23, m22 ); + this._y = Math.atan2( - m31, m11 ); - this._z = Math.asin( - clamp( m12, - 1, 1 ) ); + } else { - if ( Math.abs( m12 ) < 0.9999999 ) { + this._x = 0; + this._y = Math.atan2( m13, m33 ); - this._x = Math.atan2( m32, m22 ); - this._y = Math.atan2( m13, m11 ); + } - } else { + break; - this._x = Math.atan2( - m23, m33 ); - this._y = 0; + case 'XZY': - } + this._z = Math.asin( - clamp( m12, - 1, 1 ) ); - } else { + if ( Math.abs( m12 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m22 ); + this._y = Math.atan2( m13, m11 ); + + } else { + + this._x = Math.atan2( - m23, m33 ); + this._y = 0; + + } + + break; + + default: - console.warn( 'THREE.Euler: .setFromRotationMatrix() given unsupported order: ' + order ); + console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order ); } @@ -5213,7 +5323,7 @@ Object.defineProperty( this, 'id', { value: _object3DId ++ } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Object3D'; @@ -5303,7 +5413,7 @@ onBeforeRender: function () {}, onAfterRender: function () {}, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { if ( this.matrixAutoUpdate ) { this.updateMatrix(); } @@ -5570,7 +5680,7 @@ } - object.applyMatrix( _m1$1 ); + object.applyMatrix4( _m1$1 ); object.updateWorldMatrix( false, false ); @@ -5977,6 +6087,7 @@ values.push( data ); } + return values; } @@ -6115,7 +6226,7 @@ new Vector3() ]; - var _vector$2 = new Vector3(); + var _vector$1 = new Vector3(); var _box = new Box3(); @@ -6244,7 +6355,7 @@ setFromCenterAndSize: function ( center, size ) { - var halfSize = _vector$2.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$1.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -6366,8 +6477,7 @@ _box.copy( geometry.boundingBox ); _box.applyMatrix4( object.matrixWorld ); - this.expandByPoint( _box.min ); - this.expandByPoint( _box.max ); + this.union( _box ); } @@ -6431,10 +6541,10 @@ intersectsSphere: function ( sphere ) { // Find the point on the AABB closest to the sphere center. - this.clampPoint( sphere.center, _vector$2 ); + this.clampPoint( sphere.center, _vector$1 ); // If that point is inside the sphere, the AABB and sphere intersect. - return _vector$2.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + return _vector$1.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); }, @@ -6553,7 +6663,7 @@ distanceToPoint: function ( point ) { - var clampedPoint = _vector$2.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$1.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); @@ -6570,7 +6680,7 @@ this.getCenter( target.center ); - target.radius = this.getSize( _vector$2 ).length() * 0.5; + target.radius = this.getSize( _vector$1 ).length() * 0.5; return target; @@ -6673,7 +6783,7 @@ function Sphere( center, radius ) { this.center = ( center !== undefined ) ? center : new Vector3(); - this.radius = ( radius !== undefined ) ? radius : 0; + this.radius = ( radius !== undefined ) ? radius : - 1; } @@ -6731,9 +6841,18 @@ }, - empty: function () { + isEmpty: function () { + + return ( this.radius < 0 ); + + }, + + makeEmpty: function () { + + this.center.set( 0, 0, 0 ); + this.radius = - 1; - return ( this.radius <= 0 ); + return this; }, @@ -6802,6 +6921,14 @@ } + if ( this.isEmpty() ) { + + // Empty sphere produces empty bounding box + target.makeEmpty(); + return target; + + } + target.set( this.center, this.center ); target.expandByScalar( this.radius ); @@ -6834,7 +6961,7 @@ } ); - var _vector$3 = new Vector3(); + var _vector$2 = new Vector3(); var _segCenter = new Vector3(); var _segDir = new Vector3(); var _diff = new Vector3(); @@ -6903,7 +7030,7 @@ recast: function ( t ) { - this.origin.copy( this.at( t, _vector$3 ) ); + this.origin.copy( this.at( t, _vector$2 ) ); return this; @@ -6940,7 +7067,7 @@ distanceSqToPoint: function ( point ) { - var directionDistance = _vector$3.subVectors( point, this.origin ).dot( this.direction ); + var directionDistance = _vector$2.subVectors( point, this.origin ).dot( this.direction ); // point behind the ray @@ -6950,9 +7077,9 @@ } - _vector$3.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + _vector$2.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); - return _vector$3.distanceToSquared( point ); + return _vector$2.distanceToSquared( point ); }, @@ -7077,9 +7204,9 @@ intersectSphere: function ( sphere, target ) { - _vector$3.subVectors( sphere.center, this.origin ); - var tca = _vector$3.dot( this.direction ); - var d2 = _vector$3.dot( _vector$3 ) - tca * tca; + _vector$2.subVectors( sphere.center, this.origin ); + var tca = _vector$2.dot( this.direction ); + var d2 = _vector$2.dot( _vector$2 ) - tca * tca; var radius2 = sphere.radius * sphere.radius; if ( d2 > radius2 ) { return null; } @@ -7249,7 +7376,7 @@ intersectsBox: function ( box ) { - return this.intersectBox( box, _vector$3 ) !== null; + return this.intersectBox( box, _vector$2 ) !== null; }, @@ -8030,9 +8157,9 @@ setHSL: function ( h, s, l ) { // h,s,l ranges are in 0.0 - 1.0 - h = _Math.euclideanModulo( h, 1 ); - s = _Math.clamp( s, 0, 1 ); - l = _Math.clamp( l, 0, 1 ); + h = MathUtils.euclideanModulo( h, 1 ); + s = MathUtils.clamp( s, 0, 1 ); + l = MathUtils.clamp( l, 0, 1 ); if ( s === 0 ) { @@ -8440,9 +8567,9 @@ this.getHSL( _hslA ); color.getHSL( _hslB ); - var h = _Math.lerp( _hslA.h, _hslB.h, alpha ); - var s = _Math.lerp( _hslA.s, _hslB.s, alpha ); - var l = _Math.lerp( _hslA.l, _hslB.l, alpha ); + var h = MathUtils.lerp( _hslA.h, _hslB.h, alpha ); + var s = MathUtils.lerp( _hslA.s, _hslB.s, alpha ); + var l = MathUtils.lerp( _hslA.l, _hslB.l, alpha ); this.setHSL( h, s, l ); @@ -8560,7 +8687,7 @@ Object.defineProperty( this, 'id', { value: materialId ++ } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Material'; @@ -8570,8 +8697,7 @@ this.blending = NormalBlending; this.side = FrontSide; this.flatShading = false; - this.vertexTangents = false; - this.vertexColors = NoColors; // THREE.NoColors, THREE.VertexColors, THREE.FaceColors + this.vertexColors = false; this.opacity = 1; this.transparent = false; @@ -8725,6 +8851,18 @@ if ( this.clearcoat !== undefined ) { data.clearcoat = this.clearcoat; } if ( this.clearcoatRoughness !== undefined ) { data.clearcoatRoughness = this.clearcoatRoughness; } + if ( this.clearcoatMap && this.clearcoatMap.isTexture ) { + + data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) { + + data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid; + + } + if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) { data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid; @@ -8796,7 +8934,7 @@ if ( this.blending !== NormalBlending ) { data.blending = this.blending; } if ( this.flatShading === true ) { data.flatShading = this.flatShading; } if ( this.side !== FrontSide ) { data.side = this.side; } - if ( this.vertexColors !== NoColors ) { data.vertexColors = this.vertexColors; } + if ( this.vertexColors ) { data.vertexColors = true; } if ( this.opacity < 1 ) { data.opacity = this.opacity; } if ( this.transparent === true ) { data.transparent = this.transparent; } @@ -8893,7 +9031,6 @@ this.blending = source.blending; this.side = source.side; this.flatShading = source.flatShading; - this.vertexTangents = source.vertexTangents; this.vertexColors = source.vertexColors; this.opacity = source.opacity; @@ -9095,7 +9232,7 @@ * @author mrdoob / http://mrdoob.com/ */ - var _vector$4 = new Vector3(); + var _vector$3 = new Vector3(); function BufferAttribute( array, itemSize, normalized ) { @@ -9284,13 +9421,13 @@ for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyMatrix3( m ); + _vector$3.applyMatrix3( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9302,13 +9439,13 @@ for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyMatrix4( m ); + _vector$3.applyMatrix4( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9320,13 +9457,13 @@ for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyNormalMatrix( m ); + _vector$3.applyNormalMatrix( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9338,13 +9475,13 @@ for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.transformDirection( m ); + _vector$3.transformDirection( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9886,13 +10023,13 @@ var _offset = new Vector3(); var _box$2 = new Box3(); var _boxMorphTargets = new Box3(); - var _vector$5 = new Vector3(); + var _vector$4 = new Vector3(); function BufferGeometry() { Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'BufferGeometry'; @@ -9987,7 +10124,7 @@ }, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { var position = this.attributes.position; @@ -10043,7 +10180,7 @@ _m1$2.makeRotationX( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10055,7 +10192,7 @@ _m1$2.makeRotationY( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10067,7 +10204,7 @@ _m1$2.makeRotationZ( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10079,7 +10216,7 @@ _m1$2.makeTranslation( x, y, z ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10091,7 +10228,7 @@ _m1$2.makeScale( x, y, z ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10103,7 +10240,7 @@ _obj.updateMatrix(); - this.applyMatrix( _obj.matrix ); + this.applyMatrix4( _obj.matrix ); return this; @@ -10440,11 +10577,11 @@ if ( this.morphTargetsRelative ) { - _vector$5.addVectors( this.boundingBox.min, _box$2.min ); - this.boundingBox.expandByPoint( _vector$5 ); + _vector$4.addVectors( this.boundingBox.min, _box$2.min ); + this.boundingBox.expandByPoint( _vector$4 ); - _vector$5.addVectors( this.boundingBox.max, _box$2.max ); - this.boundingBox.expandByPoint( _vector$5 ); + _vector$4.addVectors( this.boundingBox.max, _box$2.max ); + this.boundingBox.expandByPoint( _vector$4 ); } else { @@ -10501,11 +10638,11 @@ if ( this.morphTargetsRelative ) { - _vector$5.addVectors( _box$2.min, _boxMorphTargets.min ); - _box$2.expandByPoint( _vector$5 ); + _vector$4.addVectors( _box$2.min, _boxMorphTargets.min ); + _box$2.expandByPoint( _vector$4 ); - _vector$5.addVectors( _box$2.max, _boxMorphTargets.max ); - _box$2.expandByPoint( _vector$5 ); + _vector$4.addVectors( _box$2.max, _boxMorphTargets.max ); + _box$2.expandByPoint( _vector$4 ); } else { @@ -10527,9 +10664,9 @@ for ( var i = 0, il = position.count; i < il; i ++ ) { - _vector$5.fromBufferAttribute( position, i ); + _vector$4.fromBufferAttribute( position, i ); - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$5 ) ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } @@ -10544,16 +10681,16 @@ for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { - _vector$5.fromBufferAttribute( morphAttribute, j ); + _vector$4.fromBufferAttribute( morphAttribute, j ); if ( morphTargetsRelative ) { _offset.fromBufferAttribute( position, j ); - _vector$5.add( _offset ); + _vector$4.add( _offset ); } - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$5 ) ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } @@ -10737,13 +10874,13 @@ for ( var i = 0, il = normals.count; i < il; i ++ ) { - _vector$5.x = normals.getX( i ); - _vector$5.y = normals.getY( i ); - _vector$5.z = normals.getZ( i ); + _vector$4.x = normals.getX( i ); + _vector$4.y = normals.getY( i ); + _vector$4.z = normals.getZ( i ); - _vector$5.normalize(); + _vector$4.normalize(); - normals.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z ); + normals.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); } @@ -11139,7 +11276,7 @@ this.type = 'Mesh'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new MeshBasicMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new MeshBasicMaterial(); this.updateMorphTargets(); @@ -11518,6 +11655,14 @@ } + if ( object.isSkinnedMesh ) { + + object.boneTransform( a, _vA ); + object.boneTransform( b, _vB ); + object.boneTransform( c, _vC ); + + } + var intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint ); if ( intersection ) { @@ -11571,7 +11716,7 @@ Object.defineProperty( this, 'id', { value: _geometryId += 2 } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Geometry'; @@ -11610,7 +11755,7 @@ isGeometry: true, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { var normalMatrix = new Matrix3().getNormalMatrix( matrix ); @@ -11659,7 +11804,7 @@ _m1$3.makeRotationX( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11671,7 +11816,7 @@ _m1$3.makeRotationY( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11683,7 +11828,7 @@ _m1$3.makeRotationZ( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11695,7 +11840,7 @@ _m1$3.makeTranslation( x, y, z ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11707,7 +11852,7 @@ _m1$3.makeScale( x, y, z ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11719,7 +11864,7 @@ _obj$1.updateMatrix(); - this.applyMatrix( _obj$1.matrix ); + this.applyMatrix4( _obj$1.matrix ); return this; @@ -11894,7 +12039,7 @@ 0, 0, 0, 1 ); - this.applyMatrix( matrix ); + this.applyMatrix4( matrix ); return this; @@ -13484,6 +13629,14 @@ }, + updateWorldMatrix: function ( updateParents, updateChildren ) { + + Object3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren ); + + this.matrixWorldInverse.getInverse( this.matrixWorld ); + + }, + clone: function () { return new this.constructor().copy( this ); @@ -13562,7 +13715,7 @@ // see http://www.bobatkins.com/photography/technical/field_of_view.html var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength; - this.fov = _Math.RAD2DEG * 2 * Math.atan( vExtentSlope ); + this.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope ); this.updateProjectionMatrix(); }, @@ -13572,7 +13725,7 @@ */ getFocalLength: function () { - var vExtentSlope = Math.tan( _Math.DEG2RAD * 0.5 * this.fov ); + var vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ); return 0.5 * this.getFilmHeight() / vExtentSlope; @@ -13580,8 +13733,8 @@ getEffectiveFOV: function () { - return _Math.RAD2DEG * 2 * Math.atan( - Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom ); + return MathUtils.RAD2DEG * 2 * Math.atan( + Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom ); }, @@ -13679,7 +13832,7 @@ updateProjectionMatrix: function () { var near = this.near, - top = near * Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom, + top = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom, height = 2 * top, width = this.aspect * height, left = - 0.5 * width, @@ -13777,7 +13930,7 @@ options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter }; - this.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options ); + this.renderTarget = new WebGLCubeRenderTarget( cubeResolution, options ); this.renderTarget.texture.name = "CubeCamera"; this.update = function ( renderer, scene ) { @@ -13843,18 +13996,26 @@ * @author WestLangley / http://github.com/WestLangley */ - function WebGLRenderTargetCube( width, height, options ) { + function WebGLCubeRenderTarget( size, options, dummy ) { - WebGLRenderTarget.call( this, width, height, options ); + if ( Number.isInteger( options ) ) { + + console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' ); + + options = dummy; + + } + + WebGLRenderTarget.call( this, size, size, options ); } - WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype ); - WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube; + WebGLCubeRenderTarget.prototype = Object.create( WebGLRenderTarget.prototype ); + WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget; - WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true; + WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true; - WebGLRenderTargetCube.prototype.fromEquirectangularTexture = function ( renderer, texture ) { + WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer, texture ) { this.texture.type = texture.type; this.texture.format = texture.format; @@ -13980,7 +14141,7 @@ */ var _sphere$1 = new Sphere(); - var _vector$6 = new Vector3(); + var _vector$5 = new Vector3(); function Frustum( p0, p1, p2, p3, p4, p5 ) { @@ -14034,7 +14195,7 @@ }, - setFromMatrix: function ( m ) { + setFromProjectionMatrix: function ( m ) { var planes = this.planes; var me = m.elements; @@ -14108,11 +14269,11 @@ // corner at max distance - _vector$6.x = plane.normal.x > 0 ? box.max.x : box.min.x; - _vector$6.y = plane.normal.y > 0 ? box.max.y : box.min.y; - _vector$6.z = plane.normal.z > 0 ? box.max.z : box.min.z; + _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z; - if ( plane.distanceToPoint( _vector$6 ) < 0 ) { + if ( plane.distanceToPoint( _vector$5 ) < 0 ) { return false; @@ -14144,1216 +14305,1232 @@ } ); - var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; + /** + * Uniforms library for shared webgl shaders + */ - var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + var UniformsLib = { - var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif"; + common: { - var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, - var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; + map: { value: null }, + uvTransform: { value: new Matrix3() }, + uv2Transform: { value: new Matrix3() }, - var begin_vertex = "vec3 transformed = vec3( position );"; + alphaMap: { value: null }, - var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; + }, - var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif"; + specularmap: { - var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; + specularMap: { value: null }, - var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; + }, - var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; + envmap: { - var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif"; + envMap: { value: null }, + flipEnvMap: { value: - 1 }, + reflectivity: { value: 1.0 }, + refractionRatio: { value: 0.98 }, + maxMipLevel: { value: 0 } - var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif"; + }, - var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif"; + aomap: { - var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; + aoMap: { value: null }, + aoMapIntensity: { value: 1 } - var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; + }, - var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; + lightmap: { - var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}"; + lightMap: { value: null }, + lightMapIntensity: { value: 1 } - var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif"; + }, - var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; + emissivemap: { - var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; + emissiveMap: { value: null } - var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; + }, - var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; + bumpmap: { - var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; + bumpMap: { value: null }, + bumpScale: { value: 1 } - var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; + }, - var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; + normalmap: { - var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; + normalMap: { value: null }, + normalScale: { value: new Vector2( 1, 1 ) } - var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; + }, - var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; + displacementmap: { - var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; + displacementMap: { value: null }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 } - var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; + }, - var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif"; + roughnessmap: { - var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; + roughnessMap: { value: null } - var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; + }, - var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; + metalnessmap: { - var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; + metalnessMap: { value: null } - var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif"; + }, - var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; + gradientmap: { - var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif"; + gradientMap: { value: null } - var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif"; + }, - var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif"; + fog: { - var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + fogDensity: { value: 0.00025 }, + fogNear: { value: 1 }, + fogFar: { value: 2000 }, + fogColor: { value: new Color( 0xffffff ) } - var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; + }, - var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + lights: { - var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; + ambientLightColor: { value: [] }, - var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif"; + lightProbe: { value: [] }, - var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; + directionalLights: { value: [], properties: { + direction: {}, + color: {} + } }, - var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; + directionalLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, - var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif"; + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, - var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; + spotLights: { value: [], properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } }, - var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; + spotLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, - var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; + spotShadowMap: { value: [] }, + spotShadowMatrix: { value: [] }, - var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; + pointLights: { value: [], properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } }, - var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; + pointLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } }, - var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif"; + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, - var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; + hemisphereLights: { value: [], properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } }, - var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {} + } } - var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + }, - var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; + points: { - var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, + size: { value: 1.0 }, + scale: { value: 1.0 }, + map: { value: null }, + alphaMap: { value: null }, + uvTransform: { value: new Matrix3() } - var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif"; + }, - var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif"; + sprite: { - var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, + center: { value: new Vector2( 0.5, 0.5 ) }, + rotation: { value: 0.0 }, + map: { value: null }, + alphaMap: { value: null }, + uvTransform: { value: new Matrix3() } - var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; + } - var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif"; + }; - var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; + /** + * @author mrdoob / http://mrdoob.com/ + */ - var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; + function WebGLAnimation() { - var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif"; + var context = null; + var isAnimating = false; + var animationLoop = null; - var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; + function onAnimationFrame( time, frame ) { - var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; + if ( isAnimating === false ) { return; } - var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; + animationLoop( time, frame ); - var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; + context.requestAnimationFrame( onAnimationFrame ); - var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; + } - var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; + return { - var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; + start: function () { - var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; + if ( isAnimating === true ) { return; } + if ( animationLoop === null ) { return; } - var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; + context.requestAnimationFrame( onAnimationFrame ); - var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; + isAnimating = true; - var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif"; + }, - var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}"; + stop: function () { - var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; + isAnimating = false; - var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; + }, - var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; + setAnimationLoop: function ( callback ) { - var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; + animationLoop = callback; - var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; + }, - var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; + setContext: function ( value ) { - var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; + context = value; - var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; + } - var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; + }; - var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; + } - var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; + /** + * @author mrdoob / http://mrdoob.com/ + */ - var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; + function WebGLAttributes( gl, capabilities ) { - var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; + var isWebGL2 = capabilities.isWebGL2; - var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; + var buffers = new WeakMap(); - var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; + function createBuffer( attribute, bufferType ) { - var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; + var array = attribute.array; + var usage = attribute.usage; - var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; + var buffer = gl.createBuffer(); - var cube_frag = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; + gl.bindBuffer( bufferType, buffer ); + gl.bufferData( bufferType, array, usage ); - var cube_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; + attribute.onUploadCallback(); - var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}"; + var type = 5126; - var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + if ( array instanceof Float32Array ) { - var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; + type = 5126; - var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; + } else if ( array instanceof Float64Array ) { - var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; + console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); - var equirect_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint16Array ) { - var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5123; - var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Int16Array ) { - var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5122; - var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint32Array ) { - var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5125; - var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Int32Array ) { - var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5124; - var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; + } else if ( array instanceof Int8Array ) { - var meshtoon_frag = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5120; - var meshtoon_vert = "#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint8Array ) { - var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5121; - var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } - var meshphysical_frag = "#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + return { + buffer: buffer, + type: type, + bytesPerElement: array.BYTES_PER_ELEMENT, + version: attribute.version + }; - var meshphysical_vert = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + } - var normal_frag = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; + function updateBuffer( buffer, attribute, bufferType ) { - var normal_vert = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; + var array = attribute.array; + var updateRange = attribute.updateRange; - var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + gl.bindBuffer( bufferType, buffer ); - var points_vert = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + if ( updateRange.count === - 1 ) { - var shadow_frag = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}"; + // Not using update ranges - var shadow_vert = "#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + gl.bufferSubData( bufferType, 0, array ); - var sprite_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}"; + } else { - var sprite_vert = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + if ( isWebGL2 ) { - var ShaderChunk = { - alphamap_fragment: alphamap_fragment, - alphamap_pars_fragment: alphamap_pars_fragment, - alphatest_fragment: alphatest_fragment, - aomap_fragment: aomap_fragment, - aomap_pars_fragment: aomap_pars_fragment, - begin_vertex: begin_vertex, - beginnormal_vertex: beginnormal_vertex, - bsdfs: bsdfs, - bumpmap_pars_fragment: bumpmap_pars_fragment, - clipping_planes_fragment: clipping_planes_fragment, - clipping_planes_pars_fragment: clipping_planes_pars_fragment, - clipping_planes_pars_vertex: clipping_planes_pars_vertex, - clipping_planes_vertex: clipping_planes_vertex, - color_fragment: color_fragment, - color_pars_fragment: color_pars_fragment, - color_pars_vertex: color_pars_vertex, - color_vertex: color_vertex, - common: common, - cube_uv_reflection_fragment: cube_uv_reflection_fragment, - defaultnormal_vertex: defaultnormal_vertex, - displacementmap_pars_vertex: displacementmap_pars_vertex, - displacementmap_vertex: displacementmap_vertex, - emissivemap_fragment: emissivemap_fragment, - emissivemap_pars_fragment: emissivemap_pars_fragment, - encodings_fragment: encodings_fragment, - encodings_pars_fragment: encodings_pars_fragment, - envmap_fragment: envmap_fragment, - envmap_common_pars_fragment: envmap_common_pars_fragment, - envmap_pars_fragment: envmap_pars_fragment, - envmap_pars_vertex: envmap_pars_vertex, - envmap_physical_pars_fragment: envmap_physical_pars_fragment, - envmap_vertex: envmap_vertex, - fog_vertex: fog_vertex, - fog_pars_vertex: fog_pars_vertex, - fog_fragment: fog_fragment, - fog_pars_fragment: fog_pars_fragment, - gradientmap_pars_fragment: gradientmap_pars_fragment, - lightmap_fragment: lightmap_fragment, - lightmap_pars_fragment: lightmap_pars_fragment, - lights_lambert_vertex: lights_lambert_vertex, - lights_pars_begin: lights_pars_begin, - lights_toon_fragment: lights_toon_fragment, - lights_toon_pars_fragment: lights_toon_pars_fragment, - lights_phong_fragment: lights_phong_fragment, - lights_phong_pars_fragment: lights_phong_pars_fragment, - lights_physical_fragment: lights_physical_fragment, - lights_physical_pars_fragment: lights_physical_pars_fragment, - lights_fragment_begin: lights_fragment_begin, - lights_fragment_maps: lights_fragment_maps, - lights_fragment_end: lights_fragment_end, - logdepthbuf_fragment: logdepthbuf_fragment, - logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, - logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, - logdepthbuf_vertex: logdepthbuf_vertex, - map_fragment: map_fragment, - map_pars_fragment: map_pars_fragment, - map_particle_fragment: map_particle_fragment, - map_particle_pars_fragment: map_particle_pars_fragment, - metalnessmap_fragment: metalnessmap_fragment, - metalnessmap_pars_fragment: metalnessmap_pars_fragment, - morphnormal_vertex: morphnormal_vertex, - morphtarget_pars_vertex: morphtarget_pars_vertex, - morphtarget_vertex: morphtarget_vertex, - normal_fragment_begin: normal_fragment_begin, - normal_fragment_maps: normal_fragment_maps, - normalmap_pars_fragment: normalmap_pars_fragment, - clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, - clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, - clearcoat_normalmap_pars_fragment: clearcoat_normalmap_pars_fragment, - packing: packing, - premultiplied_alpha_fragment: premultiplied_alpha_fragment, - project_vertex: project_vertex, - dithering_fragment: dithering_fragment, - dithering_pars_fragment: dithering_pars_fragment, - roughnessmap_fragment: roughnessmap_fragment, - roughnessmap_pars_fragment: roughnessmap_pars_fragment, - shadowmap_pars_fragment: shadowmap_pars_fragment, - shadowmap_pars_vertex: shadowmap_pars_vertex, - shadowmap_vertex: shadowmap_vertex, - shadowmask_pars_fragment: shadowmask_pars_fragment, - skinbase_vertex: skinbase_vertex, - skinning_pars_vertex: skinning_pars_vertex, - skinning_vertex: skinning_vertex, - skinnormal_vertex: skinnormal_vertex, - specularmap_fragment: specularmap_fragment, - specularmap_pars_fragment: specularmap_pars_fragment, - tonemapping_fragment: tonemapping_fragment, - tonemapping_pars_fragment: tonemapping_pars_fragment, - uv_pars_fragment: uv_pars_fragment, - uv_pars_vertex: uv_pars_vertex, - uv_vertex: uv_vertex, - uv2_pars_fragment: uv2_pars_fragment, - uv2_pars_vertex: uv2_pars_vertex, - uv2_vertex: uv2_vertex, - worldpos_vertex: worldpos_vertex, + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array, updateRange.offset, updateRange.count ); - background_frag: background_frag, - background_vert: background_vert, - cube_frag: cube_frag, - cube_vert: cube_vert, - depth_frag: depth_frag, - depth_vert: depth_vert, - distanceRGBA_frag: distanceRGBA_frag, - distanceRGBA_vert: distanceRGBA_vert, - equirect_frag: equirect_frag, - equirect_vert: equirect_vert, - linedashed_frag: linedashed_frag, - linedashed_vert: linedashed_vert, - meshbasic_frag: meshbasic_frag, - meshbasic_vert: meshbasic_vert, - meshlambert_frag: meshlambert_frag, - meshlambert_vert: meshlambert_vert, - meshmatcap_frag: meshmatcap_frag, - meshmatcap_vert: meshmatcap_vert, - meshtoon_frag: meshtoon_frag, - meshtoon_vert: meshtoon_vert, - meshphong_frag: meshphong_frag, - meshphong_vert: meshphong_vert, - meshphysical_frag: meshphysical_frag, - meshphysical_vert: meshphysical_vert, - normal_frag: normal_frag, - normal_vert: normal_vert, - points_frag: points_frag, - points_vert: points_vert, - shadow_frag: shadow_frag, - shadow_vert: shadow_vert, - sprite_frag: sprite_frag, - sprite_vert: sprite_vert - }; + } else { - /** - * Uniforms library for shared webgl shaders - */ + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); - var UniformsLib = { + } - common: { + updateRange.count = - 1; // reset range - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, + } - map: { value: null }, - uvTransform: { value: new Matrix3() }, - uv2Transform: { value: new Matrix3() }, + } - alphaMap: { value: null }, + // - }, + function get( attribute ) { - specularmap: { + if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } - specularMap: { value: null }, + return buffers.get( attribute ); - }, + } - envmap: { + function remove( attribute ) { - envMap: { value: null }, - flipEnvMap: { value: - 1 }, - reflectivity: { value: 1.0 }, - refractionRatio: { value: 0.98 }, - maxMipLevel: { value: 0 } + if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } - }, + var data = buffers.get( attribute ); - aomap: { + if ( data ) { - aoMap: { value: null }, - aoMapIntensity: { value: 1 } + gl.deleteBuffer( data.buffer ); - }, + buffers.delete( attribute ); - lightmap: { + } - lightMap: { value: null }, - lightMapIntensity: { value: 1 } + } - }, + function update( attribute, bufferType ) { - emissivemap: { + if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } - emissiveMap: { value: null } + var data = buffers.get( attribute ); - }, + if ( data === undefined ) { - bumpmap: { + buffers.set( attribute, createBuffer( attribute, bufferType ) ); - bumpMap: { value: null }, - bumpScale: { value: 1 } + } else if ( data.version < attribute.version ) { - }, + updateBuffer( data.buffer, attribute, bufferType ); - normalmap: { + data.version = attribute.version; - normalMap: { value: null }, - normalScale: { value: new Vector2( 1, 1 ) } + } - }, + } - displacementmap: { + return { - displacementMap: { value: null }, - displacementScale: { value: 1 }, - displacementBias: { value: 0 } + get: get, + remove: remove, + update: update - }, + }; - roughnessmap: { + } - roughnessMap: { value: null } + /** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ - }, + // PlaneGeometry - metalnessmap: { + function PlaneGeometry( width, height, widthSegments, heightSegments ) { - metalnessMap: { value: null } + Geometry.call( this ); - }, + this.type = 'PlaneGeometry'; - gradientmap: { + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; - gradientMap: { value: null } + this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); + this.mergeVertices(); - }, + } - fog: { + PlaneGeometry.prototype = Object.create( Geometry.prototype ); + PlaneGeometry.prototype.constructor = PlaneGeometry; - fogDensity: { value: 0.00025 }, - fogNear: { value: 1 }, - fogFar: { value: 2000 }, - fogColor: { value: new Color( 0xffffff ) } + // PlaneBufferGeometry - }, + function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) { - lights: { + BufferGeometry.call( this ); - ambientLightColor: { value: [] }, + this.type = 'PlaneBufferGeometry'; - lightProbe: { value: [] }, + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; - directionalLights: { value: [], properties: { - direction: {}, - color: {}, + width = width || 1; + height = height || 1; - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } }, + var width_half = width / 2; + var height_half = height / 2; - directionalShadowMap: { value: [] }, - directionalShadowMatrix: { value: [] }, + var gridX = Math.floor( widthSegments ) || 1; + var gridY = Math.floor( heightSegments ) || 1; - spotLights: { value: [], properties: { - color: {}, - position: {}, - direction: {}, - distance: {}, - coneCos: {}, - penumbraCos: {}, - decay: {}, + var gridX1 = gridX + 1; + var gridY1 = gridY + 1; - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } }, + var segment_width = width / gridX; + var segment_height = height / gridY; - spotShadowMap: { value: [] }, - spotShadowMatrix: { value: [] }, + var ix, iy; - pointLights: { value: [], properties: { - color: {}, - position: {}, - decay: {}, - distance: {}, + // buffers - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {}, - shadowCameraNear: {}, - shadowCameraFar: {} - } }, + var indices = []; + var vertices = []; + var normals = []; + var uvs = []; - pointShadowMap: { value: [] }, - pointShadowMatrix: { value: [] }, + // generate vertices, normals and uvs - hemisphereLights: { value: [], properties: { - direction: {}, - skyColor: {}, - groundColor: {} - } }, + for ( iy = 0; iy < gridY1; iy ++ ) { - // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src - rectAreaLights: { value: [], properties: { - color: {}, - position: {}, - width: {}, - height: {} - } } + var y = iy * segment_height - height_half; - }, + for ( ix = 0; ix < gridX1; ix ++ ) { - points: { + var x = ix * segment_width - width_half; - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, - size: { value: 1.0 }, - scale: { value: 1.0 }, - map: { value: null }, - alphaMap: { value: null }, - uvTransform: { value: new Matrix3() } + vertices.push( x, - y, 0 ); - }, + normals.push( 0, 0, 1 ); - sprite: { + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, - center: { value: new Vector2( 0.5, 0.5 ) }, - rotation: { value: 0.0 }, - map: { value: null }, - alphaMap: { value: null }, - uvTransform: { value: new Matrix3() } + } } - }; + // indices - /** - * @author alteredq / http://alteredqualia.com/ - * @author mrdoob / http://mrdoob.com/ - * @author mikael emtinger / http://gomo.se/ - */ + for ( iy = 0; iy < gridY; iy ++ ) { - var ShaderLib = { + for ( ix = 0; ix < gridX; ix ++ ) { - basic: { + var a = ix + gridX1 * iy; + var b = ix + gridX1 * ( iy + 1 ); + var c = ( ix + 1 ) + gridX1 * ( iy + 1 ); + var d = ( ix + 1 ) + gridX1 * iy; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.fog - ] ), + // faces - vertexShader: ShaderChunk.meshbasic_vert, - fragmentShader: ShaderChunk.meshbasic_frag + indices.push( a, b, d ); + indices.push( b, c, d ); - }, + } - lambert: { + } - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) } - } - ] ), + // build geometry - vertexShader: ShaderChunk.meshlambert_vert, - fragmentShader: ShaderChunk.meshlambert_frag + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); - }, + } - phong: { + PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); + PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - specular: { value: new Color( 0x111111 ) }, - shininess: { value: 30 } - } - ] ), + var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; - vertexShader: ShaderChunk.meshphong_vert, - fragmentShader: ShaderChunk.meshphong_frag + var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; - }, + var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif"; - standard: { + var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.roughnessmap, - UniformsLib.metalnessmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - roughness: { value: 0.5 }, - metalness: { value: 0.5 }, - envMapIntensity: { value: 1 } // temporary - } - ] ), + var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; - vertexShader: ShaderChunk.meshphysical_vert, - fragmentShader: ShaderChunk.meshphysical_frag + var begin_vertex = "vec3 transformed = vec3( position );"; - }, + var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; - toon: { + var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.gradientmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - specular: { value: new Color( 0x111111 ) }, - shininess: { value: 30 } - } - ] ), + var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; - vertexShader: ShaderChunk.meshtoon_vert, - fragmentShader: ShaderChunk.meshtoon_frag + var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; - }, + var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; - matcap: { + var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.fog, - { - matcap: { value: null } - } - ] ), + var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif"; - vertexShader: ShaderChunk.meshmatcap_vert, - fragmentShader: ShaderChunk.meshmatcap_frag + var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif"; - }, + var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; - points: { + var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.points, - UniformsLib.fog - ] ), + var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; - vertexShader: ShaderChunk.points_vert, - fragmentShader: ShaderChunk.points_frag + var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}"; - }, + var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif"; - dashed: { + var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.fog, - { - scale: { value: 1 }, - dashSize: { value: 1 }, - totalSize: { value: 2 } - } - ] ), + var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; - vertexShader: ShaderChunk.linedashed_vert, - fragmentShader: ShaderChunk.linedashed_frag + var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; - }, + var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; - depth: { + var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.displacementmap - ] ), + var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; - vertexShader: ShaderChunk.depth_vert, - fragmentShader: ShaderChunk.depth_frag + var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; - }, + var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; - normal: { + var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - { - opacity: { value: 1.0 } - } - ] ), + var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; - vertexShader: ShaderChunk.normal_vert, - fragmentShader: ShaderChunk.normal_frag + var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; - }, + var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; - sprite: { + var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.sprite, - UniformsLib.fog - ] ), + var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; - vertexShader: ShaderChunk.sprite_vert, - fragmentShader: ShaderChunk.sprite_frag + var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; - }, + var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; - background: { + var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; - uniforms: { - uvTransform: { value: new Matrix3() }, - t2D: { value: null }, - }, + var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif"; - vertexShader: ShaderChunk.background_vert, - fragmentShader: ShaderChunk.background_frag + var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; - }, - /* ------------------------------------------------------------------------- - // Cube map shader - ------------------------------------------------------------------------- */ + var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif"; - cube: { + var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.envmap, - { - opacity: { value: 1.0 } - } - ] ), + var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif"; - vertexShader: ShaderChunk.cube_vert, - fragmentShader: ShaderChunk.cube_frag + var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; - }, + var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; - equirect: { + var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; - uniforms: { - tEquirect: { value: null }, - }, + var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; - vertexShader: ShaderChunk.equirect_vert, - fragmentShader: ShaderChunk.equirect_frag + var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif"; - }, + var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; - distanceRGBA: { + var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.displacementmap, - { - referencePosition: { value: new Vector3() }, - nearDistance: { value: 1 }, - farDistance: { value: 1000 } - } - ] ), + var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif"; - vertexShader: ShaderChunk.distanceRGBA_vert, - fragmentShader: ShaderChunk.distanceRGBA_frag + var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; - }, + var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; - shadow: { + var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.lights, - UniformsLib.fog, - { - color: { value: new Color( 0x00000 ) }, - opacity: { value: 1.0 } - } ] ), + var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; - vertexShader: ShaderChunk.shadow_vert, - fragmentShader: ShaderChunk.shadow_frag + var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; - } + var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif"; - }; + var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; - ShaderLib.physical = { + var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; - uniforms: mergeUniforms( [ - ShaderLib.standard.uniforms, - { - transparency: { value: 0 }, - clearcoat: { value: 0 }, - clearcoatRoughness: { value: 0 }, - sheen: { value: new Color( 0x000000 ) }, - clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, - clearcoatNormalMap: { value: null }, - } - ] ), + var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; - vertexShader: ShaderChunk.meshphysical_vert, - fragmentShader: ShaderChunk.meshphysical_frag + var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; - }; + var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; - /** - * @author mrdoob / http://mrdoob.com/ - */ + var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif"; - function WebGLAnimation() { + var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif"; - var context = null; - var isAnimating = false; - var animationLoop = null; + var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif"; - function onAnimationFrame( time, frame ) { + var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; - if ( isAnimating === false ) { return; } + var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif"; - animationLoop( time, frame ); + var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; - context.requestAnimationFrame( onAnimationFrame ); + var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; - } + var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif"; - return { + var clearcoat_pars_fragment = "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; - start: function () { + var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; - if ( isAnimating === true ) { return; } - if ( animationLoop === null ) { return; } + var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; - context.requestAnimationFrame( onAnimationFrame ); + var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; - isAnimating = true; + var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; - }, + var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; - stop: function () { + var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; - isAnimating = false; + var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; - }, + var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; - setAnimationLoop: function ( callback ) { + var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; - animationLoop = callback; + var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif"; - }, + var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}"; - setContext: function ( value ) { + var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; - context = value; + var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; - } + var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; - }; + var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; - } + var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; - /** - * @author mrdoob / http://mrdoob.com/ - */ + var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; - function WebGLAttributes( gl ) { + var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; - var buffers = new WeakMap(); + var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; - function createBuffer( attribute, bufferType ) { + var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; - var array = attribute.array; - var usage = attribute.usage; + var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; - var buffer = gl.createBuffer(); + var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; - gl.bindBuffer( bufferType, buffer ); - gl.bufferData( bufferType, array, usage ); + var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; - attribute.onUploadCallback(); + var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; - var type = 5126; + var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; - if ( array instanceof Float32Array ) { + var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; - type = 5126; + var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; - } else if ( array instanceof Float64Array ) { + var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; - console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); + var cube_frag = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; - } else if ( array instanceof Uint16Array ) { + var cube_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; - type = 5123; + var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}"; - } else if ( array instanceof Int16Array ) { + var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}"; - type = 5122; + var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; - } else if ( array instanceof Uint32Array ) { + var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; - type = 5125; + var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; - } else if ( array instanceof Int32Array ) { + var equirect_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; - type = 5124; + var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } else if ( array instanceof Int8Array ) { + var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - type = 5120; + var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } else if ( array instanceof Uint8Array ) { + var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - type = 5121; + var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } + var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - return { - buffer: buffer, - type: type, - bytesPerElement: array.BYTES_PER_ELEMENT, - version: attribute.version - }; + var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } + var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; - function updateBuffer( buffer, attribute, bufferType ) { + var meshtoon_frag = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - var array = attribute.array; - var updateRange = attribute.updateRange; + var meshtoon_vert = "#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; - gl.bindBuffer( bufferType, buffer ); + var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - if ( updateRange.count === - 1 ) { + var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - // Not using update ranges + var meshphysical_frag = "#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - gl.bufferSubData( bufferType, 0, array ); + var meshphysical_vert = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; - } else { + var normal_frag = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; - gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, - array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); + var normal_vert = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; - updateRange.count = - 1; // reset range + var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } + var points_vert = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } + var shadow_frag = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}"; - // + var shadow_vert = "#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - function get( attribute ) { + var sprite_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}"; - if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } + var sprite_vert = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; - return buffers.get( attribute ); + var ShaderChunk = { + alphamap_fragment: alphamap_fragment, + alphamap_pars_fragment: alphamap_pars_fragment, + alphatest_fragment: alphatest_fragment, + aomap_fragment: aomap_fragment, + aomap_pars_fragment: aomap_pars_fragment, + begin_vertex: begin_vertex, + beginnormal_vertex: beginnormal_vertex, + bsdfs: bsdfs, + bumpmap_pars_fragment: bumpmap_pars_fragment, + clipping_planes_fragment: clipping_planes_fragment, + clipping_planes_pars_fragment: clipping_planes_pars_fragment, + clipping_planes_pars_vertex: clipping_planes_pars_vertex, + clipping_planes_vertex: clipping_planes_vertex, + color_fragment: color_fragment, + color_pars_fragment: color_pars_fragment, + color_pars_vertex: color_pars_vertex, + color_vertex: color_vertex, + common: common, + cube_uv_reflection_fragment: cube_uv_reflection_fragment, + defaultnormal_vertex: defaultnormal_vertex, + displacementmap_pars_vertex: displacementmap_pars_vertex, + displacementmap_vertex: displacementmap_vertex, + emissivemap_fragment: emissivemap_fragment, + emissivemap_pars_fragment: emissivemap_pars_fragment, + encodings_fragment: encodings_fragment, + encodings_pars_fragment: encodings_pars_fragment, + envmap_fragment: envmap_fragment, + envmap_common_pars_fragment: envmap_common_pars_fragment, + envmap_pars_fragment: envmap_pars_fragment, + envmap_pars_vertex: envmap_pars_vertex, + envmap_physical_pars_fragment: envmap_physical_pars_fragment, + envmap_vertex: envmap_vertex, + fog_vertex: fog_vertex, + fog_pars_vertex: fog_pars_vertex, + fog_fragment: fog_fragment, + fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, + lightmap_fragment: lightmap_fragment, + lightmap_pars_fragment: lightmap_pars_fragment, + lights_lambert_vertex: lights_lambert_vertex, + lights_pars_begin: lights_pars_begin, + lights_toon_fragment: lights_toon_fragment, + lights_toon_pars_fragment: lights_toon_pars_fragment, + lights_phong_fragment: lights_phong_fragment, + lights_phong_pars_fragment: lights_phong_pars_fragment, + lights_physical_fragment: lights_physical_fragment, + lights_physical_pars_fragment: lights_physical_pars_fragment, + lights_fragment_begin: lights_fragment_begin, + lights_fragment_maps: lights_fragment_maps, + lights_fragment_end: lights_fragment_end, + logdepthbuf_fragment: logdepthbuf_fragment, + logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, + logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, + logdepthbuf_vertex: logdepthbuf_vertex, + map_fragment: map_fragment, + map_pars_fragment: map_pars_fragment, + map_particle_fragment: map_particle_fragment, + map_particle_pars_fragment: map_particle_pars_fragment, + metalnessmap_fragment: metalnessmap_fragment, + metalnessmap_pars_fragment: metalnessmap_pars_fragment, + morphnormal_vertex: morphnormal_vertex, + morphtarget_pars_vertex: morphtarget_pars_vertex, + morphtarget_vertex: morphtarget_vertex, + normal_fragment_begin: normal_fragment_begin, + normal_fragment_maps: normal_fragment_maps, + normalmap_pars_fragment: normalmap_pars_fragment, + clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, + clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, + clearcoat_pars_fragment: clearcoat_pars_fragment, + packing: packing, + premultiplied_alpha_fragment: premultiplied_alpha_fragment, + project_vertex: project_vertex, + dithering_fragment: dithering_fragment, + dithering_pars_fragment: dithering_pars_fragment, + roughnessmap_fragment: roughnessmap_fragment, + roughnessmap_pars_fragment: roughnessmap_pars_fragment, + shadowmap_pars_fragment: shadowmap_pars_fragment, + shadowmap_pars_vertex: shadowmap_pars_vertex, + shadowmap_vertex: shadowmap_vertex, + shadowmask_pars_fragment: shadowmask_pars_fragment, + skinbase_vertex: skinbase_vertex, + skinning_pars_vertex: skinning_pars_vertex, + skinning_vertex: skinning_vertex, + skinnormal_vertex: skinnormal_vertex, + specularmap_fragment: specularmap_fragment, + specularmap_pars_fragment: specularmap_pars_fragment, + tonemapping_fragment: tonemapping_fragment, + tonemapping_pars_fragment: tonemapping_pars_fragment, + uv_pars_fragment: uv_pars_fragment, + uv_pars_vertex: uv_pars_vertex, + uv_vertex: uv_vertex, + uv2_pars_fragment: uv2_pars_fragment, + uv2_pars_vertex: uv2_pars_vertex, + uv2_vertex: uv2_vertex, + worldpos_vertex: worldpos_vertex, - } + background_frag: background_frag, + background_vert: background_vert, + cube_frag: cube_frag, + cube_vert: cube_vert, + depth_frag: depth_frag, + depth_vert: depth_vert, + distanceRGBA_frag: distanceRGBA_frag, + distanceRGBA_vert: distanceRGBA_vert, + equirect_frag: equirect_frag, + equirect_vert: equirect_vert, + linedashed_frag: linedashed_frag, + linedashed_vert: linedashed_vert, + meshbasic_frag: meshbasic_frag, + meshbasic_vert: meshbasic_vert, + meshlambert_frag: meshlambert_frag, + meshlambert_vert: meshlambert_vert, + meshmatcap_frag: meshmatcap_frag, + meshmatcap_vert: meshmatcap_vert, + meshtoon_frag: meshtoon_frag, + meshtoon_vert: meshtoon_vert, + meshphong_frag: meshphong_frag, + meshphong_vert: meshphong_vert, + meshphysical_frag: meshphysical_frag, + meshphysical_vert: meshphysical_vert, + normal_frag: normal_frag, + normal_vert: normal_vert, + points_frag: points_frag, + points_vert: points_vert, + shadow_frag: shadow_frag, + shadow_vert: shadow_vert, + sprite_frag: sprite_frag, + sprite_vert: sprite_vert + }; - function remove( attribute ) { + /** + * @author alteredq / http://alteredqualia.com/ + * @author mrdoob / http://mrdoob.com/ + * @author mikael emtinger / http://gomo.se/ + */ - if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } + var ShaderLib = { - var data = buffers.get( attribute ); + basic: { - if ( data ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.fog + ] ), + + vertexShader: ShaderChunk.meshbasic_vert, + fragmentShader: ShaderChunk.meshbasic_frag + + }, + + lambert: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) } + } + ] ), - gl.deleteBuffer( data.buffer ); + vertexShader: ShaderChunk.meshlambert_vert, + fragmentShader: ShaderChunk.meshlambert_frag - buffers.delete( attribute ); + }, - } + phong: { - } + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + specular: { value: new Color( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), - function update( attribute, bufferType ) { + vertexShader: ShaderChunk.meshphong_vert, + fragmentShader: ShaderChunk.meshphong_frag - if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; } + }, - var data = buffers.get( attribute ); + standard: { - if ( data === undefined ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.roughnessmap, + UniformsLib.metalnessmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + roughness: { value: 1.0 }, + metalness: { value: 0.0 }, + envMapIntensity: { value: 1 } // temporary + } + ] ), - buffers.set( attribute, createBuffer( attribute, bufferType ) ); + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag - } else if ( data.version < attribute.version ) { + }, - updateBuffer( data.buffer, attribute, bufferType ); + toon: { - data.version = attribute.version; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.gradientmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + specular: { value: new Color( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), - } + vertexShader: ShaderChunk.meshtoon_vert, + fragmentShader: ShaderChunk.meshtoon_frag - } + }, - return { + matcap: { - get: get, - remove: remove, - update: update + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + { + matcap: { value: null } + } + ] ), - }; + vertexShader: ShaderChunk.meshmatcap_vert, + fragmentShader: ShaderChunk.meshmatcap_frag - } + }, - /** - * @author mrdoob / http://mrdoob.com/ - * @author Mugen87 / https://github.com/Mugen87 - */ + points: { - // PlaneGeometry + uniforms: mergeUniforms( [ + UniformsLib.points, + UniformsLib.fog + ] ), - function PlaneGeometry( width, height, widthSegments, heightSegments ) { + vertexShader: ShaderChunk.points_vert, + fragmentShader: ShaderChunk.points_frag - Geometry.call( this ); + }, - this.type = 'PlaneGeometry'; + dashed: { - this.parameters = { - width: width, - height: height, - widthSegments: widthSegments, - heightSegments: heightSegments - }; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 } + } + ] ), - this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); - this.mergeVertices(); + vertexShader: ShaderChunk.linedashed_vert, + fragmentShader: ShaderChunk.linedashed_frag - } + }, - PlaneGeometry.prototype = Object.create( Geometry.prototype ); - PlaneGeometry.prototype.constructor = PlaneGeometry; + depth: { - // PlaneBufferGeometry + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap + ] ), - function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) { + vertexShader: ShaderChunk.depth_vert, + fragmentShader: ShaderChunk.depth_frag - BufferGeometry.call( this ); + }, - this.type = 'PlaneBufferGeometry'; + normal: { - this.parameters = { - width: width, - height: height, - widthSegments: widthSegments, - heightSegments: heightSegments - }; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + { + opacity: { value: 1.0 } + } + ] ), - width = width || 1; - height = height || 1; + vertexShader: ShaderChunk.normal_vert, + fragmentShader: ShaderChunk.normal_frag - var width_half = width / 2; - var height_half = height / 2; + }, - var gridX = Math.floor( widthSegments ) || 1; - var gridY = Math.floor( heightSegments ) || 1; + sprite: { - var gridX1 = gridX + 1; - var gridY1 = gridY + 1; + uniforms: mergeUniforms( [ + UniformsLib.sprite, + UniformsLib.fog + ] ), - var segment_width = width / gridX; - var segment_height = height / gridY; + vertexShader: ShaderChunk.sprite_vert, + fragmentShader: ShaderChunk.sprite_frag - var ix, iy; + }, - // buffers + background: { - var indices = []; - var vertices = []; - var normals = []; - var uvs = []; + uniforms: { + uvTransform: { value: new Matrix3() }, + t2D: { value: null }, + }, - // generate vertices, normals and uvs + vertexShader: ShaderChunk.background_vert, + fragmentShader: ShaderChunk.background_frag - for ( iy = 0; iy < gridY1; iy ++ ) { + }, + /* ------------------------------------------------------------------------- + // Cube map shader + ------------------------------------------------------------------------- */ - var y = iy * segment_height - height_half; + cube: { - for ( ix = 0; ix < gridX1; ix ++ ) { + uniforms: mergeUniforms( [ + UniformsLib.envmap, + { + opacity: { value: 1.0 } + } + ] ), - var x = ix * segment_width - width_half; + vertexShader: ShaderChunk.cube_vert, + fragmentShader: ShaderChunk.cube_frag - vertices.push( x, - y, 0 ); + }, - normals.push( 0, 0, 1 ); + equirect: { - uvs.push( ix / gridX ); - uvs.push( 1 - ( iy / gridY ) ); + uniforms: { + tEquirect: { value: null }, + }, - } + vertexShader: ShaderChunk.equirect_vert, + fragmentShader: ShaderChunk.equirect_frag - } + }, - // indices + distanceRGBA: { - for ( iy = 0; iy < gridY; iy ++ ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap, + { + referencePosition: { value: new Vector3() }, + nearDistance: { value: 1 }, + farDistance: { value: 1000 } + } + ] ), - for ( ix = 0; ix < gridX; ix ++ ) { + vertexShader: ShaderChunk.distanceRGBA_vert, + fragmentShader: ShaderChunk.distanceRGBA_frag - var a = ix + gridX1 * iy; - var b = ix + gridX1 * ( iy + 1 ); - var c = ( ix + 1 ) + gridX1 * ( iy + 1 ); - var d = ( ix + 1 ) + gridX1 * iy; + }, - // faces + shadow: { - indices.push( a, b, d ); - indices.push( b, c, d ); + uniforms: mergeUniforms( [ + UniformsLib.lights, + UniformsLib.fog, + { + color: { value: new Color( 0x00000 ) }, + opacity: { value: 1.0 } + } ] ), - } + vertexShader: ShaderChunk.shadow_vert, + fragmentShader: ShaderChunk.shadow_frag } - // build geometry + }; - this.setIndex( indices ); - this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); - this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); - this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); + ShaderLib.physical = { - } + uniforms: mergeUniforms( [ + ShaderLib.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, + clearcoatNormalMap: { value: null }, + sheen: { value: new Color( 0x000000 ) }, + transparency: { value: 0 }, + } + ] ), - PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); - PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry; + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + + }; /** * @author mrdoob / http://mrdoob.com/ @@ -15366,10 +15543,10 @@ var planeMesh; var boxMesh; - // Store the current background texture and its `version` - // so we can recompile the material accordingly. + var currentBackground = null; var currentBackgroundVersion = 0; + var currentTonemapping = null; function render( renderList, scene, camera, forceClear ) { @@ -15390,15 +15567,11 @@ if ( background === null ) { setClear( clearColor, clearAlpha ); - currentBackground = null; - currentBackgroundVersion = 0; } else if ( background && background.isColor ) { setClear( background, 1 ); forceClear = true; - currentBackground = null; - currentBackgroundVersion = 0; } @@ -15408,7 +15581,7 @@ } - if ( background && ( background.isCubeTexture || background.isWebGLRenderTargetCube || background.mapping === CubeUVReflectionMapping ) ) { + if ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) { if ( boxMesh === undefined ) { @@ -15450,18 +15623,20 @@ } - var texture = background.isWebGLRenderTargetCube ? background.texture : background; + var texture = background.isWebGLCubeRenderTarget ? background.texture : background; boxMesh.material.uniforms.envMap.value = texture; boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1; if ( currentBackground !== background || - currentBackgroundVersion !== texture.version ) { + currentBackgroundVersion !== texture.version || + currentTonemapping !== renderer.toneMapping ) { boxMesh.material.needsUpdate = true; currentBackground = background; currentBackgroundVersion = texture.version; + currentTonemapping = renderer.toneMapping; } @@ -15514,12 +15689,14 @@ planeMesh.material.uniforms.uvTransform.value.copy( background.matrix ); if ( currentBackground !== background || - currentBackgroundVersion !== background.version ) { + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { planeMesh.material.needsUpdate = true; currentBackground = background; currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; } @@ -15904,6 +16081,7 @@ } scope.numPlanes = nPlanes; + scope.numIntersection = 0; return dstArray; @@ -16456,7 +16634,7 @@ function WebGLObjects( gl, geometries, attributes, info ) { - var updateList = {}; + var updateMap = new WeakMap(); function update( object ) { @@ -16467,7 +16645,7 @@ // Update once per frame - if ( updateList[ buffergeometry.id ] !== frame ) { + if ( updateMap.get( buffergeometry ) !== frame ) { if ( geometry.isGeometry ) { @@ -16477,7 +16655,7 @@ geometries.update( buffergeometry ); - updateList[ buffergeometry.id ] = frame; + updateMap.set( buffergeometry, frame ); } @@ -16493,7 +16671,7 @@ function dispose() { - updateList = {}; + updateMap = new WeakMap(); } @@ -17066,6 +17244,20 @@ } + // uint + + function setValueV1ui( gl, v ) { + + var cache = this.cache; + + if ( cache[ 0 ] === v ) { return; } + + gl.uniform1ui( this.addr, v ); + + cache[ 0 ] = v; + + } + // Helper to pick the right setter for the singular case function getSingularSetter( type ) { @@ -17081,16 +17273,37 @@ case 0x8b5b: return setValueM3; // _MAT3 case 0x8b5c: return setValueM4; // _MAT4 - case 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES - case 0x8b5f: return setValueT3D1; // SAMPLER_3D - case 0x8b60: return setValueT6; // SAMPLER_CUBE - case 0x8DC1: return setValueT2DArray1; // SAMPLER_2D_ARRAY - case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2 case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3 case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4 + case 0x1405: return setValueV1ui; // UINT + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3D1; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArray1; + } } @@ -17229,22 +17442,24 @@ case 0x8b5b: return setValueM3Array; // _MAT3 case 0x8b5c: return setValueM4Array; // _MAT4 + case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 + case 0x8b5e: // SAMPLER_2D case 0x8d66: // SAMPLER_EXTERNAL_OES case 0x8dca: // INT_SAMPLER_2D case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW return setValueT1Array; case 0x8b60: // SAMPLER_CUBE case 0x8dcc: // INT_SAMPLER_CUBE - case 0x8dd4: // UNSIGNED_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW return setValueT6Array; - case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL - case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 - case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 - case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 - } } @@ -17581,15 +17796,13 @@ } - function generateExtensions( extensions, parameters, rendererExtensions ) { - - extensions = extensions || {}; + function generateExtensions( parameters ) { var chunks = [ - ( extensions.derivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', - ( extensions.fragDepth || parameters.logarithmicDepthBuffer ) && rendererExtensions.get( 'EXT_frag_depth' ) ? '#extension GL_EXT_frag_depth : enable' : '', - ( extensions.drawBuffers ) && rendererExtensions.get( 'WEBGL_draw_buffers' ) ? '#extension GL_EXT_draw_buffers : require' : '', - ( extensions.shaderTextureLOD || parameters.envMap ) && rendererExtensions.get( 'EXT_shader_texture_lod' ) ? '#extension GL_EXT_shader_texture_lod : enable' : '' + ( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', + ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', + ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '', + ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : '' ]; return chunks.filter( filterEmptyLine ).join( '\n' ); @@ -17689,11 +17902,21 @@ // Unroll Loops - var loopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; + var deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; + var unrollLoopPattern = /#pragma unroll_loop_start[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g; function unrollLoops( string ) { - return string.replace( loopPattern, loopReplacer ); + return string + .replace( unrollLoopPattern, loopReplacer ) + .replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer ); + + } + + function deprecatedLoopReplacer( match, start, end, snippet ) { + + console.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' ); + return loopReplacer( match, start, end, snippet ); } @@ -17843,14 +18066,14 @@ } - function WebGLProgram( renderer, extensions, cacheKey, material, shader, parameters ) { + function WebGLProgram( renderer, cacheKey, parameters ) { var gl = renderer.getContext(); - var defines = material.defines; + var defines = parameters.defines; - var vertexShader = shader.vertexShader; - var fragmentShader = shader.fragmentShader; + var vertexShader = parameters.vertexShader; + var fragmentShader = parameters.fragmentShader; var shadowMapTypeDefine = generateShadowMapTypeDefine( parameters ); var envMapTypeDefine = generateEnvMapTypeDefine( parameters ); var envMapModeDefine = generateEnvMapModeDefine( parameters ); @@ -17859,7 +18082,7 @@ var gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0; - var customExtensions = parameters.isWebGL2 ? '' : generateExtensions( material.extensions, parameters, extensions ); + var customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters ); var customDefines = generateDefines( defines ); @@ -17867,9 +18090,7 @@ var prefixVertex, prefixFragment; - var numMultiviewViews = parameters.numMultiviewViews; - - if ( material.isRawShaderMaterial ) { + if ( parameters.isRawShaderMaterial ) { prefixVertex = [ @@ -17902,7 +18123,7 @@ generatePrecision( parameters ), - '#define SHADER_NAME ' + shader.name, + '#define SHADER_NAME ' + parameters.shaderName, customDefines, @@ -17926,6 +18147,8 @@ ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', @@ -17954,7 +18177,7 @@ parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', @@ -18028,7 +18251,7 @@ generatePrecision( parameters ), - '#define SHADER_NAME ' + shader.name, + '#define SHADER_NAME ' + parameters.shaderName, customDefines, @@ -18052,6 +18275,8 @@ parameters.normalMap ? '#define USE_NORMALMAP' : '', ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', @@ -18080,9 +18305,9 @@ parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', - ( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( parameters.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', + ( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', @@ -18103,7 +18328,7 @@ parameters.lightMapEncoding ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '', parameters.outputEncoding ? getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ) : '', - parameters.depthPacking ? '#define DEPTH_PACKING ' + material.depthPacking : '', + parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n' @@ -18122,13 +18347,13 @@ vertexShader = unrollLoops( vertexShader ); fragmentShader = unrollLoops( fragmentShader ); - if ( parameters.isWebGL2 && ! material.isRawShaderMaterial ) { + if ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) { var isGLSL3ShaderMaterial = false; var versionRegex = /^\s*#version\s+300\s+es\s*\n/; - if ( material.isShaderMaterial && + if ( parameters.isShaderMaterial && vertexShader.match( versionRegex ) !== null && fragmentShader.match( versionRegex ) !== null ) { @@ -18165,59 +18390,6 @@ '#define textureCubeGradEXT textureGrad' ].join( '\n' ) + '\n' + prefixFragment; - // Multiview - - if ( numMultiviewViews > 0 ) { - - prefixVertex = prefixVertex.replace( - '#version 300 es\n', - [ - '#version 300 es\n', - '#extension GL_OVR_multiview2 : require', - 'layout(num_views = ' + numMultiviewViews + ') in;', - '#define VIEW_ID gl_ViewID_OVR' - ].join( '\n' ) - ); - - prefixVertex = prefixVertex.replace( - [ - 'uniform mat4 modelViewMatrix;', - 'uniform mat4 projectionMatrix;', - 'uniform mat4 viewMatrix;', - 'uniform mat3 normalMatrix;' - ].join( '\n' ), - [ - 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];', - 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];', - 'uniform mat4 viewMatrices[' + numMultiviewViews + '];', - 'uniform mat3 normalMatrices[' + numMultiviewViews + '];', - - '#define modelViewMatrix modelViewMatrices[VIEW_ID]', - '#define projectionMatrix projectionMatrices[VIEW_ID]', - '#define viewMatrix viewMatrices[VIEW_ID]', - '#define normalMatrix normalMatrices[VIEW_ID]' - ].join( '\n' ) - ); - - prefixFragment = prefixFragment.replace( - '#version 300 es\n', - [ - '#version 300 es\n', - '#extension GL_OVR_multiview2 : require', - '#define VIEW_ID gl_ViewID_OVR' - ].join( '\n' ) - ); - - prefixFragment = prefixFragment.replace( - 'uniform mat4 viewMatrix;', - [ - 'uniform mat4 viewMatrices[' + numMultiviewViews + '];', - '#define viewMatrix viewMatrices[VIEW_ID]' - ].join( '\n' ) - ); - - } - } var vertexGlsl = prefixVertex + vertexShader; @@ -18234,9 +18406,9 @@ // Force a particular attribute to index 0. - if ( material.index0AttributeName !== undefined ) { + if ( parameters.index0AttributeName !== undefined ) { - gl.bindAttribLocation( program, 0, material.index0AttributeName ); + gl.bindAttribLocation( program, 0, parameters.index0AttributeName ); } else if ( parameters.morphTargets === true ) { @@ -18281,7 +18453,6 @@ this.diagnostics = { runnable: runnable, - material: material, programLog: programLog, @@ -18305,7 +18476,11 @@ } - // clean up + // Clean up + + // Crashes in iOS9 and iOS10. #18402 + // gl.detachShader( program, glVertexShader ); + // gl.detachShader( program, glFragmentShader ); gl.deleteShader( glVertexShader ); gl.deleteShader( glFragmentShader ); @@ -18353,14 +18528,13 @@ // - this.name = shader.name; + this.name = parameters.shaderName; this.id = programIdCount ++; this.cacheKey = cacheKey; this.usedTimes = 1; this.program = program; this.vertexShader = glVertexShader; this.fragmentShader = glFragmentShader; - this.numMultiviewViews = numMultiviewViews; return this; @@ -18400,9 +18574,9 @@ }; var parameterNames = [ - "precision", "isWebGL2", "supportsVertexTextures", "outputEncoding", "instancing", "numMultiviewViews", + "precision", "isWebGL2", "supportsVertexTextures", "outputEncoding", "instancing", "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "envMapCubeUV", - "lightMap", "lightMapEncoding", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "tangentSpaceNormalMap", "clearcoatNormalMap", "displacementMap", "specularMap", + "lightMap", "lightMapEncoding", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "tangentSpaceNormalMap", "clearcoatMap", "clearcoatRoughnessMap", "clearcoatNormalMap", "displacementMap", "specularMap", "roughnessMap", "metalnessMap", "gradientMap", "alphaMap", "combine", "vertexColors", "vertexTangents", "vertexUvs", "uvsVertexOnly", "fog", "useFog", "fogExp2", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", @@ -18415,6 +18589,35 @@ "sheen" ]; + function getShaderObject( material, shaderID ) { + + var shaderobject; + + if ( shaderID ) { + + var shader = ShaderLib[ shaderID ]; + + shaderobject = { + name: material.type, + uniforms: UniformsUtils.clone( shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + }; + + } else { + + shaderobject = { + name: material.type, + uniforms: material.uniforms, + vertexShader: material.vertexShader, + fragmentShader: material.fragmentShader + }; + + } + + return shaderobject; + + } function allocateBones( object ) { @@ -18501,21 +18704,31 @@ } + var shaderobject = getShaderObject( material, shaderID ); + material.onBeforeCompile( shaderobject, renderer ); + var currentRenderTarget = renderer.getRenderTarget(); - var numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0; var parameters = { isWebGL2: isWebGL2, shaderID: shaderID, + shaderName: shaderobject.name, + + uniforms: shaderobject.uniforms, + vertexShader: shaderobject.vertexShader, + fragmentShader: shaderobject.fragmentShader, + defines: material.defines, + + isRawShaderMaterial: material.isRawShaderMaterial, + isShaderMaterial: material.isShaderMaterial, precision: precision, instancing: object.isInstancedMesh === true, supportsVertexTextures: vertexTextures, - numMultiviewViews: numMultiviewViews, outputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding, map: !! material.map, mapEncoding: getTextureEncodingFromMap( material.map ), @@ -18534,6 +18747,8 @@ normalMap: !! material.normalMap, objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap, tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap, + clearcoatMap: !! material.clearcoatMap, + clearcoatRoughnessMap: !! material.clearcoatRoughnessMap, clearcoatNormalMap: !! material.clearcoatNormalMap, displacementMap: !! material.displacementMap, roughnessMap: !! material.roughnessMap, @@ -18549,7 +18764,7 @@ vertexTangents: ( material.normalMap && material.vertexTangents ), vertexColors: material.vertexColors, - vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || !! material.displacementMap, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap, uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap, fog: !! fog, @@ -18597,7 +18812,20 @@ doubleSided: material.side === DoubleSide, flipSided: material.side === BackSide, - depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false + depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false, + + index0AttributeName: material.index0AttributeName, + + extensionDerivatives: material.extensions && material.extensions.derivatives, + extensionFragDepth: material.extensions && material.extensions.fragDepth, + extensionDrawBuffers: material.extensions && material.extensions.drawBuffers, + extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD, + + rendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null, + rendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null, + rendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null, + + onBeforeCompile: material.onBeforeCompile }; @@ -18605,7 +18833,7 @@ }; - this.getProgramCacheKey = function ( material, parameters ) { + this.getProgramCacheKey = function ( parameters ) { var array = []; @@ -18615,23 +18843,23 @@ } else { - array.push( material.fragmentShader ); - array.push( material.vertexShader ); + array.push( parameters.fragmentShader ); + array.push( parameters.vertexShader ); } - if ( material.defines !== undefined ) { + if ( parameters.defines !== undefined ) { - for ( var name in material.defines ) { + for ( var name in parameters.defines ) { array.push( name ); - array.push( material.defines[ name ] ); + array.push( parameters.defines[ name ] ); } } - if ( material.isRawShaderMaterial === undefined ) { + if ( parameters.isRawShaderMaterial === undefined ) { for ( var i = 0; i < parameterNames.length; i ++ ) { @@ -18644,13 +18872,13 @@ } - array.push( material.onBeforeCompile.toString() ); + array.push( parameters.onBeforeCompile.toString() ); return array.join(); }; - this.acquireProgram = function ( material, shader, parameters, cacheKey ) { + this.acquireProgram = function ( parameters, cacheKey ) { var program; @@ -18672,7 +18900,7 @@ if ( program === undefined ) { - program = new WebGLProgram( renderer, extensions, cacheKey, material, shader, parameters ); + program = new WebGLProgram( renderer, cacheKey, parameters ); programs.push( program ); } @@ -18891,6 +19119,27 @@ } + function finish() { + + // Clear references from inactive renderItems in the list + + for ( var i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) { + + var renderItem = renderItems[ i ]; + + if ( renderItem.id === null ) { break; } + + renderItem.id = null; + renderItem.object = null; + renderItem.geometry = null; + renderItem.material = null; + renderItem.program = null; + renderItem.group = null; + + } + + } + return { opaque: opaque, transparent: transparent, @@ -18898,6 +19147,7 @@ init: init, push: push, unshift: unshift, + finish: finish, sort: sort }; @@ -18984,12 +19234,7 @@ case 'DirectionalLight': uniforms = { direction: new Vector3(), - color: new Color(), - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2() + color: new Color() }; break; @@ -19001,12 +19246,7 @@ distance: 0, coneCos: 0, penumbraCos: 0, - decay: 0, - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2() + decay: 0 }; break; @@ -19015,14 +19255,7 @@ position: new Vector3(), color: new Color(), distance: 0, - decay: 0, - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2(), - shadowCameraNear: 1, - shadowCameraFar: 1000 + decay: 0 }; break; @@ -19040,7 +19273,6 @@ position: new Vector3(), halfWidth: new Vector3(), halfHeight: new Vector3() - // TODO (abelnation): set RectAreaLight shadow uniforms }; break; @@ -19056,6 +19288,66 @@ } + function ShadowUniformsCache() { + + var lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + var uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'SpotLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'PointLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + shadowCameraNear: 1, + shadowCameraFar: 1000 + }; + break; + + // TODO (abelnation): set RectAreaLight shadow uniforms + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + + } + + + var nextVersion = 0; function shadowCastingLightsFirst( lightA, lightB ) { @@ -19068,6 +19360,8 @@ var cache = new UniformsCache(); + var shadowCache = ShadowUniformsCache(); + var state = { version: 0, @@ -19081,26 +19375,25 @@ numDirectionalShadows: - 1, numPointShadows: - 1, - numSpotShadows: - 1, + numSpotShadows: - 1 }, ambient: [ 0, 0, 0 ], probe: [], directional: [], + directionalShadow: [], directionalShadowMap: [], directionalShadowMatrix: [], spot: [], + spotShadow: [], spotShadowMap: [], spotShadowMatrix: [], rectArea: [], point: [], + pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], - hemi: [], - - numDirectionalShadows: - 1, - numPointShadows: - 1, - numSpotShadows: - 1 + hemi: [] }; @@ -19164,16 +19457,17 @@ uniforms.direction.sub( vector3 ); uniforms.direction.transformDirection( viewMatrix ); - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + state.directionalShadow[ directionalLength ] = shadowUniforms; state.directionalShadowMap[ directionalLength ] = shadowMap; state.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix; @@ -19204,16 +19498,17 @@ uniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) ); uniforms.decay = light.decay; - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + state.spotShadow[ spotLength ] = shadowUniforms; state.spotShadowMap[ spotLength ] = shadowMap; state.spotShadowMatrix[ spotLength ] = light.shadow.matrix; @@ -19268,18 +19563,19 @@ uniforms.distance = light.distance; uniforms.decay = light.decay; - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; - uniforms.shadowCameraNear = shadow.camera.near; - uniforms.shadowCameraFar = shadow.camera.far; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + shadowUniforms.shadowCameraNear = shadow.camera.near; + shadowUniforms.shadowCameraFar = shadow.camera.far; + state.pointShadow[ pointLength ] = shadowUniforms; state.pointShadowMap[ pointLength ] = shadowMap; state.pointShadowMatrix[ pointLength ] = light.shadow.matrix; @@ -19331,8 +19627,11 @@ state.point.length = pointLength; state.hemi.length = hemiLength; + state.directionalShadow.length = numDirectionalShadows; state.directionalShadowMap.length = numDirectionalShadows; + state.pointShadow.length = numPointShadows; state.pointShadowMap.length = numPointShadows; + state.spotShadow.length = numSpotShadows; state.spotShadowMap.length = numSpotShadows; state.directionalShadowMatrix.length = numDirectionalShadows; state.pointShadowMatrix.length = numPointShadows; @@ -19741,8 +20040,6 @@ if ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) { - console.warn( 'THREE.WebGLShadowMap:', light, 'has shadow exceeding max texture size, reducing' ); - if ( _shadowMapSize.x > maxTextureSize ) { _viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x ); @@ -19899,9 +20196,7 @@ } - function getDepthMaterial( object, material, light, shadowCameraNear, shadowCameraFar, type ) { - - var geometry = object.geometry; + function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) { var result = null; @@ -19921,15 +20216,7 @@ if ( material.morphTargets === true ) { - if ( geometry.isBufferGeometry === true ) { - - useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0; - - } else if ( geometry.isGeometry === true ) { - - useMorphing = geometry.morphTargets && geometry.morphTargets.length > 0; - - } + useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0; } @@ -20048,7 +20335,7 @@ if ( groupMaterial && groupMaterial.visible ) { - var depthMaterial = getDepthMaterial( object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); + var depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group ); @@ -20058,7 +20345,7 @@ } else if ( material.visible ) { - var depthMaterial = getDepthMaterial( object, material, light, shadowCamera.near, shadowCamera.far, type ); + var depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null ); @@ -20541,6 +20828,20 @@ } + function vertexAttribPointer( index, size, type, normalized, stride, offset ) { + + if ( isWebGL2 === true && ( type === 5124 || type === 5125 ) ) { + + gl.vertexAttribIPointer( index, size, type, normalized, stride, offset ); + + } else { + + gl.vertexAttribPointer( index, size, type, normalized, stride, offset ); + + } + + } + function enable( id ) { if ( enabledCapabilities[ id ] !== true ) { @@ -21057,6 +21358,7 @@ enableAttribute: enableAttribute, enableAttributeAndDivisor: enableAttributeAndDivisor, disableUnusedAttributes: disableUnusedAttributes, + vertexAttribPointer: vertexAttribPointer, enable: enable, disable: disable, @@ -21153,7 +21455,7 @@ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { - var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor; + var floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor; var width = floor( scale * image.width ); var height = floor( scale * image.height ); @@ -21194,7 +21496,7 @@ function isPowerOfTwo( image ) { - return _Math.isPowerOfTwo( image.width ) && _Math.isPowerOfTwo( image.height ); + return MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height ); } @@ -21268,10 +21570,6 @@ extensions.get( 'EXT_color_buffer_float' ); - } else if ( internalFormat === 34843 || internalFormat === 34837 ) { - - console.warn( 'THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.' ); - } return internalFormat; @@ -21357,7 +21655,7 @@ } - if ( renderTarget.isWebGLRenderTargetCube ) { + if ( renderTarget.isWebGLCubeRenderTarget ) { for ( var i = 0; i < 6; i ++ ) { @@ -21370,21 +21668,9 @@ _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer ); if ( renderTargetProperties.__webglDepthbuffer ) { _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); } - - } - - if ( renderTarget.isWebGLMultiviewRenderTarget ) { - - _gl.deleteTexture( renderTargetProperties.__webglColorTexture ); - _gl.deleteTexture( renderTargetProperties.__webglDepthStencilTexture ); - - info.memory.textures -= 2; - - for ( var i = 0, il = renderTargetProperties.__webglViewFramebuffers.length; i < il; i ++ ) { - - _gl.deleteFramebuffer( renderTargetProperties.__webglViewFramebuffers[ i ] ); - - } + if ( renderTargetProperties.__webglMultisampledFramebuffer ) { _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer ); } + if ( renderTargetProperties.__webglColorRenderbuffer ) { _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer ); } + if ( renderTargetProperties.__webglDepthRenderbuffer ) { _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer ); } } @@ -21500,7 +21786,7 @@ _gl.pixelStorei( 37440, texture.flipY ); - var isCompressed = ( texture && texture.isCompressedTexture ); + var isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) ); var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); var cubeImage = []; @@ -21754,18 +22040,38 @@ glInternalFormat = 6402; - if ( texture.type === FloatType ) { + if ( isWebGL2 ) { + + if ( texture.type === FloatType ) { + + glInternalFormat = 36012; - if ( isWebGL2 === false ) { throw new Error( 'Float Depth Texture only supported in WebGL2.0' ); } - glInternalFormat = 36012; + } else if ( texture.type === UnsignedIntType ) { - } else if ( isWebGL2 ) { + glInternalFormat = 33190; - // WebGL 2.0 requires signed internalformat for glTexImage2D - glInternalFormat = 33189; + } else if ( texture.type === UnsignedInt248Type ) { + + glInternalFormat = 35056; + + } else { + + glInternalFormat = 33189; // WebGL2 requires sized internalformat for glTexImage2D + + } + + } else { + + if ( texture.type === FloatType ) { + + console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' ); + + } } + // validation checks for WebGL 1 + if ( texture.format === DepthFormat && glInternalFormat === 6402 ) { // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are @@ -21782,10 +22088,10 @@ } - // Depth stencil textures need the DEPTH_STENCIL internal format - // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) - if ( texture.format === DepthStencilFormat ) { + if ( texture.format === DepthStencilFormat && glInternalFormat === 6402 ) { + // Depth stencil textures need the DEPTH_STENCIL internal format + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) glInternalFormat = 34041; // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are @@ -21802,6 +22108,8 @@ } + // + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); } else if ( texture.isDataTexture ) { @@ -21930,15 +22238,33 @@ if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) { + var glInternalFormat = 33189; + if ( isMultisample ) { + var depthTexture = renderTarget.depthTexture; + + if ( depthTexture && depthTexture.isDepthTexture ) { + + if ( depthTexture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( depthTexture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } + + } + var samples = getRenderTargetSamples( renderTarget ); - _gl.renderbufferStorageMultisample( 36161, samples, 33189, renderTarget.width, renderTarget.height ); + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); } else { - _gl.renderbufferStorage( 36161, 33189, renderTarget.width, renderTarget.height ); + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); } @@ -21988,7 +22314,7 @@ // Setup resources for a Depth Texture for a FBO (needs an extension) function setupDepthTexture( framebuffer, renderTarget ) { - var isCube = ( renderTarget && renderTarget.isWebGLRenderTargetCube ); + var isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget ); if ( isCube ) { throw new Error( 'Depth Texture with cube render targets is not supported' ); } _gl.bindFramebuffer( 36160, framebuffer ); @@ -22035,7 +22361,7 @@ var renderTargetProperties = properties.get( renderTarget ); - var isCube = ( renderTarget.isWebGLRenderTargetCube === true ); + var isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); if ( renderTarget.depthTexture ) { @@ -22053,7 +22379,7 @@ _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer[ i ] ); renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget ); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false ); } @@ -22061,7 +22387,7 @@ _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget ); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false ); } @@ -22083,11 +22409,20 @@ info.memory.textures ++; - var isCube = ( renderTarget.isWebGLRenderTargetCube === true ); + var isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true ); - var isMultiview = ( renderTarget.isWebGLMultiviewRenderTarget === true ); var supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2; + // Handles WebGL2 RGBFormat fallback - #18858 + + if ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) { + + renderTarget.texture.format = RGBAFormat; + + console.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' ); + + } + // Setup framebuffer if ( isCube ) { @@ -22139,48 +22474,6 @@ } - } else if ( isMultiview ) { - - var width = renderTarget.width; - var height = renderTarget.height; - var numViews = renderTarget.numViews; - - _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); - - var ext = extensions.get( 'OVR_multiview2' ); - - info.memory.textures += 2; - - var colorTexture = _gl.createTexture(); - _gl.bindTexture( 35866, colorTexture ); - _gl.texParameteri( 35866, 10240, 9728 ); - _gl.texParameteri( 35866, 10241, 9728 ); - _gl.texImage3D( 35866, 0, 32856, width, height, numViews, 0, 6408, 5121, null ); - ext.framebufferTextureMultiviewOVR( 36160, 36064, colorTexture, 0, 0, numViews ); - - var depthStencilTexture = _gl.createTexture(); - _gl.bindTexture( 35866, depthStencilTexture ); - _gl.texParameteri( 35866, 10240, 9728 ); - _gl.texParameteri( 35866, 10241, 9728 ); - _gl.texImage3D( 35866, 0, 35056, width, height, numViews, 0, 34041, 34042, null ); - ext.framebufferTextureMultiviewOVR( 36160, 33306, depthStencilTexture, 0, 0, numViews ); - - var viewFramebuffers = new Array( numViews ); - for ( var i = 0; i < numViews; ++ i ) { - - viewFramebuffers[ i ] = _gl.createFramebuffer(); - _gl.bindFramebuffer( 36160, viewFramebuffers[ i ] ); - _gl.framebufferTextureLayer( 36160, 36064, colorTexture, 0, i ); - - } - - renderTargetProperties.__webglColorTexture = colorTexture; - renderTargetProperties.__webglDepthStencilTexture = depthStencilTexture; - renderTargetProperties.__webglViewFramebuffers = viewFramebuffers; - - _gl.bindFramebuffer( 36160, null ); - _gl.bindTexture( 35866, null ); - } } @@ -22206,7 +22499,7 @@ state.bindTexture( 34067, null ); - } else if ( ! isMultiview ) { + } else { state.bindTexture( 3553, textureProperties.__webglTexture ); setTextureParameters( 3553, renderTarget.texture, supportsMips ); @@ -22239,7 +22532,7 @@ if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - var target = renderTarget.isWebGLRenderTargetCube ? 34067 : 3553; + var target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553; var webglTexture = properties.get( texture ).__webglTexture; state.bindTexture( target, webglTexture ); @@ -22270,6 +22563,8 @@ _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 ); + _gl.bindFramebuffer( 36160, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905 + } else { console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); @@ -22328,7 +22623,7 @@ function safeSetTextureCube( texture, slot ) { - if ( texture && texture.isWebGLRenderTargetCube ) { + if ( texture && texture.isWebGLCubeRenderTarget ) { if ( warnedTextureCube === false ) { @@ -22341,7 +22636,7 @@ } - // currently relying on the fact that WebGLRenderTargetCube.texture is a Texture and NOT a CubeTexture + // currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture // TODO: unify these code paths if ( ( texture && texture.isCubeTexture ) || ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) { @@ -22353,7 +22648,7 @@ } else { - // assumed: texture property of THREE.WebGLRenderTargetCube + // assumed: texture property of THREE.WebGLCubeRenderTarget setTextureCubeDynamic( texture, slot ); } @@ -22494,11 +22789,29 @@ } + if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc' ); + + if ( extension !== null ) { + + if ( p === RGB_ETC2_Format ) { return extension.COMPRESSED_RGB8_ETC2; } + if ( p === RGBA_ETC2_EAC_Format ) { return extension.COMPRESSED_RGBA8_ETC2_EAC; } + + } + + } + if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || - p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) { + p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format || + p === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format || + p === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format || + p === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format || + p === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format || + p === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) { extension = extensions.get( 'WEBGL_compressed_texture_astc' ); @@ -22516,6 +22829,24 @@ } + if ( p === RGBA_BPTC_Format ) { + + extension = extensions.get( 'EXT_texture_compression_bptc' ); + + if ( extension !== null ) { + + // TODO Complete? + + return p; + + } else { + + return null; + + } + + } + if ( p === UnsignedInt248Type ) { if ( isWebGL2 ) { return 34042; } @@ -22541,307 +22872,179 @@ } /** - * @author fernandojsg / http://fernandojsg.com - * @author Takahiro https://github.com/takahirox + * @author mrdoob / http://mrdoob.com/ */ - function WebGLMultiviewRenderTarget( width, height, numViews, options ) { - - WebGLRenderTarget.call( this, width, height, options ); + function ArrayCamera( array ) { - this.depthBuffer = false; - this.stencilBuffer = false; + PerspectiveCamera.call( this ); - this.numViews = numViews; + this.cameras = array || []; } - WebGLMultiviewRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { - - constructor: WebGLMultiviewRenderTarget, - - isWebGLMultiviewRenderTarget: true, - - copy: function ( source ) { - - WebGLRenderTarget.prototype.copy.call( this, source ); - - this.numViews = source.numViews; - - return this; - - }, - - setNumViews: function ( numViews ) { - - if ( this.numViews !== numViews ) { - - this.numViews = numViews; - this.dispose(); - - } + ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), { - return this; + constructor: ArrayCamera, - } + isArrayCamera: true } ); /** - * @author fernandojsg / http://fernandojsg.com - * @author Takahiro https://github.com/takahirox + * @author mrdoob / http://mrdoob.com/ */ - function WebGLMultiview( renderer, gl ) { + function Group() { - var DEFAULT_NUMVIEWS = 2; + Object3D.call( this ); - var extensions = renderer.extensions; - var properties = renderer.properties; + this.type = 'Group'; - var renderTarget, currentRenderTarget; - var mat3, mat4, cameraArray, renderSize; + } - var available; - var maxNumViews = 0; + Group.prototype = Object.assign( Object.create( Object3D.prototype ), { - // + constructor: Group, - function isAvailable() { + isGroup: true - if ( available === undefined ) { + } ); - var extension = extensions.get( 'OVR_multiview2' ); + /** + * @author Mugen87 / https://github.com/Mugen87 + */ - available = extension !== null && gl.getContextAttributes().antialias === false; + function WebXRController() { - if ( available ) { + this._targetRay = null; + this._grip = null; - maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR ); - renderTarget = new WebGLMultiviewRenderTarget( 0, 0, DEFAULT_NUMVIEWS ); + } - renderSize = new Vector2(); - mat4 = []; - mat3 = []; - cameraArray = []; + Object.assign( WebXRController.prototype, { - for ( var i = 0; i < maxNumViews; i ++ ) { + constructor: WebXRController, - mat4[ i ] = new Matrix4(); - mat3[ i ] = new Matrix3(); + getTargetRaySpace: function () { - } + if ( this._targetRay === null ) { - } + this._targetRay = new Group(); + this._targetRay.matrixAutoUpdate = false; + this._targetRay.visible = false; } - return available; - - } - - function getCameraArray( camera ) { + return this._targetRay; - if ( camera.isArrayCamera ) { return camera.cameras; } - - cameraArray[ 0 ] = camera; - - return cameraArray; - - } - - function updateCameraProjectionMatricesUniform( camera, uniforms ) { + }, - var cameras = getCameraArray( camera ); + getGripSpace: function () { - for ( var i = 0; i < cameras.length; i ++ ) { + if ( this._grip === null ) { - mat4[ i ].copy( cameras[ i ].projectionMatrix ); + this._grip = new Group(); + this._grip.matrixAutoUpdate = false; + this._grip.visible = false; } - uniforms.setValue( gl, 'projectionMatrices', mat4 ); + return this._grip; - } - - function updateCameraViewMatricesUniform( camera, uniforms ) { + }, - var cameras = getCameraArray( camera ); + dispatchEvent: function ( event ) { - for ( var i = 0; i < cameras.length; i ++ ) { + if ( this._targetRay !== null ) { - mat4[ i ].copy( cameras[ i ].matrixWorldInverse ); + this._targetRay.dispatchEvent( event ); } - uniforms.setValue( gl, 'viewMatrices', mat4 ); - - } - - function updateObjectMatricesUniforms( object, camera, uniforms ) { - - var cameras = getCameraArray( camera ); + if ( this._grip !== null ) { - for ( var i = 0; i < cameras.length; i ++ ) { - - mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld ); - mat3[ i ].getNormalMatrix( mat4[ i ] ); + this._grip.dispatchEvent( event ); } - uniforms.setValue( gl, 'modelViewMatrices', mat4 ); - uniforms.setValue( gl, 'normalMatrices', mat3 ); - - } - - function isMultiviewCompatible( camera ) { - - if ( camera.isArrayCamera === undefined ) { return true; } - - var cameras = camera.cameras; - - if ( cameras.length > maxNumViews ) { return false; } - - for ( var i = 1, il = cameras.length; i < il; i ++ ) { - - if ( cameras[ 0 ].viewport.z !== cameras[ i ].viewport.z || - cameras[ 0 ].viewport.w !== cameras[ i ].viewport.w ) { return false; } - - } - - return true; - - } + return this; - function resizeRenderTarget( camera ) { + }, - if ( currentRenderTarget ) { + disconnect: function ( inputSource ) { - renderSize.set( currentRenderTarget.width, currentRenderTarget.height ); + this.dispatchEvent( { type: 'disconnected', data: inputSource } ); - } else { + if ( this._targetRay !== null ) { - renderer.getDrawingBufferSize( renderSize ); + this._targetRay.visible = false; } - if ( camera.isArrayCamera ) { - - var viewport = camera.cameras[ 0 ].viewport; - - renderTarget.setSize( viewport.z, viewport.w ); - renderTarget.setNumViews( camera.cameras.length ); + if ( this._grip !== null ) { - } else { - - renderTarget.setSize( renderSize.x, renderSize.y ); - renderTarget.setNumViews( DEFAULT_NUMVIEWS ); + this._grip.visible = false; } - } - - function attachCamera( camera ) { + return this; - if ( isMultiviewCompatible( camera ) === false ) { return; } + }, - currentRenderTarget = renderer.getRenderTarget(); - resizeRenderTarget( camera ); - renderer.setRenderTarget( renderTarget ); + update: function ( inputSource, frame, referenceSpace ) { - } + var inputPose = null; + var gripPose = null; - function detachCamera( camera ) { + var targetRay = this._targetRay; + var grip = this._grip; - if ( renderTarget !== renderer.getRenderTarget() ) { return; } + if ( inputSource ) { - renderer.setRenderTarget( currentRenderTarget ); + if ( targetRay !== null ) { - flush( camera ); + inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); - } - - function flush( camera ) { + if ( inputPose !== null ) { - var srcRenderTarget = renderTarget; - var numViews = srcRenderTarget.numViews; + targetRay.matrix.fromArray( inputPose.transform.matrix ); + targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale ); - var srcFramebuffers = properties.get( srcRenderTarget ).__webglViewFramebuffers; + } - var viewWidth = srcRenderTarget.width; - var viewHeight = srcRenderTarget.height; + } - if ( camera.isArrayCamera ) { + if ( grip !== null && inputSource.gripSpace ) { - for ( var i = 0; i < numViews; i ++ ) { + gripPose = frame.getPose( inputSource.gripSpace, referenceSpace ); - var viewport = camera.cameras[ i ].viewport; + if ( gripPose !== null ) { - var x1 = viewport.x; - var y1 = viewport.y; - var x2 = x1 + viewport.z; - var y2 = y1 + viewport.w; + grip.matrix.fromArray( gripPose.transform.matrix ); + grip.matrix.decompose( grip.position, grip.rotation, grip.scale ); - gl.bindFramebuffer( 36008, srcFramebuffers[ i ] ); - gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, x1, y1, x2, y2, 16384, 9728 ); + } } - } else { - - gl.bindFramebuffer( 36008, srcFramebuffers[ 0 ] ); - gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, 0, 0, renderSize.x, renderSize.y, 16384, 9728 ); - } - } - - this.isAvailable = isAvailable; - this.attachCamera = attachCamera; - this.detachCamera = detachCamera; - this.updateCameraProjectionMatricesUniform = updateCameraProjectionMatricesUniform; - this.updateCameraViewMatricesUniform = updateCameraViewMatricesUniform; - this.updateObjectMatricesUniforms = updateObjectMatricesUniforms; + if ( targetRay !== null ) { - } + targetRay.visible = ( inputPose !== null ); - /** - * @author mrdoob / http://mrdoob.com/ - */ - - function ArrayCamera( array ) { - - PerspectiveCamera.call( this ); - - this.cameras = array || []; - - } - - ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), { - - constructor: ArrayCamera, - - isArrayCamera: true - - } ); - - /** - * @author mrdoob / http://mrdoob.com/ - */ - - function Group() { - - Object3D.call( this ); + } - this.type = 'Group'; + if ( grip !== null ) { - } + grip.visible = ( gripPose !== null ); - Group.prototype = Object.assign( Object.create( Object3D.prototype ), { + } - constructor: Group, + return this; - isGroup: true + } } ); @@ -22855,7 +23058,7 @@ var session = null; - // var framebufferScaleFactor = 1.0; + var framebufferScaleFactor = 1.0; var referenceSpace = null; var referenceSpaceType = 'local-floor'; @@ -22875,31 +23078,48 @@ cameraR.layers.enable( 2 ); cameraR.viewport = new Vector4(); - var cameraVR = new ArrayCamera( [ cameraL, cameraR ] ); + var cameras = [ cameraL, cameraR ]; + + var cameraVR = new ArrayCamera(); cameraVR.layers.enable( 1 ); cameraVR.layers.enable( 2 ); + var _currentDepthNear = null; + var _currentDepthFar = null; + // this.enabled = false; this.isPresenting = false; - this.getController = function ( id ) { + this.getController = function ( index ) { - var controller = controllers[ id ]; + var controller = controllers[ index ]; if ( controller === undefined ) { - controller = new Group(); - controller.matrixAutoUpdate = false; - controller.visible = false; + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getTargetRaySpace(); + + }; - controllers[ id ] = controller; + this.getControllerGrip = function ( index ) { + + var controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; } - return controller; + return controller.getGripSpace(); }; @@ -22921,8 +23141,7 @@ inputSourcesMap.forEach( function ( controller, inputSource ) { - controller.dispatchEvent( { type: 'disconnected', data: inputSource } ); - controller.visible = false; + controller.disconnect( inputSource ); } ); @@ -22934,10 +23153,10 @@ renderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830 animation.stop(); - scope.dispatchEvent( { type: 'sessionend' } ); - scope.isPresenting = false; + scope.dispatchEvent( { type: 'sessionend' } ); + } function onRequestReferenceSpace( value ) { @@ -22947,15 +23166,21 @@ animation.setContext( session ); animation.start(); - scope.dispatchEvent( { type: 'sessionstart' } ); - scope.isPresenting = true; + scope.dispatchEvent( { type: 'sessionstart' } ); + } - this.setFramebufferScaleFactor = function ( /* value */ ) { + this.setFramebufferScaleFactor = function ( value ) { + + framebufferScaleFactor = value; - // framebufferScaleFactor = value; + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' ); + + } }; @@ -22963,6 +23188,12 @@ referenceSpaceType = value; + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' ); + + } + }; this.getReferenceSpace = function () { @@ -22997,7 +23228,8 @@ antialias: attributes.antialias, alpha: attributes.alpha, depth: attributes.depth, - stencil: attributes.stencil + stencil: attributes.stencil, + framebufferScaleFactor: framebufferScaleFactor }; // eslint-disable-next-line no-undef @@ -23140,6 +23372,23 @@ this.getCamera = function ( camera ) { + cameraVR.near = cameraR.near = cameraL.near = camera.near; + cameraVR.far = cameraR.far = cameraL.far = camera.far; + + if ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) { + + // Note that the new renderState won't apply until the next frame. See #18320 + + session.updateRenderState( { + depthNear: cameraVR.near, + depthFar: cameraVR.far + } ); + + _currentDepthNear = cameraVR.near; + _currentDepthFar = cameraVR.far; + + } + var parent = camera.parent; var cameras = cameraVR.cameras; @@ -23163,7 +23412,19 @@ } - setProjectionFromUnion( cameraVR, cameraL, cameraR ); + // update projection matrix for proper view frustum culling + + if ( cameras.length === 2 ) { + + setProjectionFromUnion( cameraVR, cameraL, cameraR ); + + } else { + + // assume single camera setup (AR) + + cameraVR.projectionMatrix.copy( cameraL.projectionMatrix ); + + } return cameraVR; @@ -23184,14 +23445,24 @@ renderer.setFramebuffer( baseLayer.framebuffer ); + var cameraVRNeedsUpdate = false; + + // check if it's necessary to rebuild cameraVR's camera list + + if ( views.length !== cameraVR.cameras.length ) { + + cameraVR.cameras.length = 0; + cameraVRNeedsUpdate = true; + + } + for ( var i = 0; i < views.length; i ++ ) { var view = views[ i ]; var viewport = baseLayer.getViewport( view ); - var viewMatrix = view.transform.inverse.matrix; - var camera = cameraVR.cameras[ i ]; - camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix ); + var camera = cameras[ i ]; + camera.matrix.fromArray( view.transform.matrix ); camera.projectionMatrix.fromArray( view.projectionMatrix ); camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height ); @@ -23201,6 +23472,12 @@ } + if ( cameraVRNeedsUpdate === true ) { + + cameraVR.cameras.push( camera ); + + } + } } @@ -23212,26 +23489,9 @@ for ( var i = 0; i < controllers.length; i ++ ) { var controller = controllers[ i ]; - var inputSource = inputSources[ i ]; - if ( inputSource ) { - - var inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); - - if ( inputPose !== null ) { - - controller.matrix.fromArray( inputPose.transform.matrix ); - controller.matrix.decompose( controller.position, controller.rotation, controller.scale ); - controller.visible = true; - - continue; - - } - - } - - controller.visible = false; + controller.update( inputSource, frame, referenceSpace ); } @@ -23322,7 +23582,7 @@ // tone mapping - this.toneMapping = LinearToneMapping; + this.toneMapping = NoToneMapping; this.toneMappingExposure = 1.0; this.toneMappingWhitePoint = 1.0; @@ -23492,7 +23752,7 @@ info = new WebGLInfo( _gl ); properties = new WebGLProperties(); textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ); - attributes = new WebGLAttributes( _gl ); + attributes = new WebGLAttributes( _gl, capabilities ); geometries = new WebGLGeometries( _gl, attributes, info ); objects = new WebGLObjects( _gl, geometries, attributes, info ); morphtargets = new WebGLMorphtargets( _gl ); @@ -23524,10 +23784,6 @@ this.xr = xr; - // Multiview - - var multiview = new WebGLMultiview( _this, _gl ); - // shadow map var shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize ); @@ -23965,6 +24221,12 @@ } + if ( object.isInstancedMesh === true ) { + + updateBuffers = true; + + } + // var index = geometry.index; @@ -24159,7 +24421,7 @@ } _gl.bindBuffer( 34962, buffer ); - _gl.vertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement ); + state.vertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement ); } else { @@ -24180,7 +24442,7 @@ } _gl.bindBuffer( 34962, buffer ); - _gl.vertexAttribPointer( programAttribute, size, type, normalized, 0, 0 ); + state.vertexAttribPointer( programAttribute, size, type, normalized, 0, 0 ); } @@ -24269,6 +24531,8 @@ currentRenderState.setupLights( camera ); + var compiled = {}; + scene.traverse( function ( object ) { if ( object.material ) { @@ -24277,13 +24541,19 @@ for ( var i = 0; i < object.material.length; i ++ ) { - initMaterial( object.material[ i ], scene, object ); + if ( object.material[ i ].uuid in compiled === false ) { + + initMaterial( object.material[ i ], scene, object ); + compiled[ object.material[ i ].uuid ] = true; + + } } - } else { + } else if ( object.material.uuid in compiled === false ) { initMaterial( object.material, scene, object ); + compiled[ object.material.uuid ] = true; } @@ -24370,14 +24640,13 @@ } // + scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget ); currentRenderState = renderStates.get( scene, camera ); currentRenderState.init(); - scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget ); - _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); - _frustum.setFromMatrix( _projScreenMatrix ); + _frustum.setFromProjectionMatrix( _projScreenMatrix ); _localClippingEnabled = this.localClippingEnabled; _clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera ); @@ -24387,6 +24656,8 @@ projectObject( scene, camera, 0, _this.sortObjects ); + currentRenderList.finish(); + if ( _this.sortObjects === true ) { currentRenderList.sort( _opaqueSort, _transparentSort ); @@ -24415,12 +24686,6 @@ } - if ( xr.enabled && multiview.isAvailable() ) { - - multiview.attachCamera( camera ); - - } - // background.render( currentRenderList, scene, camera, forceClear ); @@ -24475,16 +24740,6 @@ state.setPolygonOffset( false ); - if ( xr.enabled ) { - - if ( multiview.isAvailable() ) { - - multiview.detachCamera( camera ); - - } - - } - // _gl.finish(); currentRenderList = null; @@ -24632,27 +24887,19 @@ _currentArrayCamera = camera; - if ( xr.enabled && multiview.isAvailable() ) { - - renderObject( object, scene, camera, geometry, material, group ); - - } else { - - var cameras = camera.cameras; + var cameras = camera.cameras; - for ( var j = 0, jl = cameras.length; j < jl; j ++ ) { + for ( var j = 0, jl = cameras.length; j < jl; j ++ ) { - var camera2 = cameras[ j ]; + var camera2 = cameras[ j ]; - if ( object.layers.test( camera2.layers ) ) { + if ( object.layers.test( camera2.layers ) ) { - state.viewport( _currentViewport.copy( camera2.viewport ) ); + state.viewport( _currentViewport.copy( camera2.viewport ) ); - currentRenderState.setupLights( camera2 ); + currentRenderState.setupLights( camera2 ); - renderObject( object, scene, camera2, geometry, material, group ); - - } + renderObject( object, scene, camera2, geometry, material, group ); } @@ -24710,10 +24957,8 @@ var lightsStateVersion = lights.state.version; - var parameters = programCache.getParameters( - material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object ); - - var programCacheKey = programCache.getProgramCacheKey( material, parameters ); + var parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object ); + var programCacheKey = programCache.getProgramCacheKey( parameters ); var program = materialProperties.program; var programChange = true; @@ -24748,38 +24993,11 @@ if ( programChange ) { - if ( parameters.shaderID ) { - - var shader = ShaderLib[ parameters.shaderID ]; - - materialProperties.shader = { - name: material.type, - uniforms: cloneUniforms( shader.uniforms ), - vertexShader: shader.vertexShader, - fragmentShader: shader.fragmentShader - }; - - } else { - - materialProperties.shader = { - name: material.type, - uniforms: material.uniforms, - vertexShader: material.vertexShader, - fragmentShader: material.fragmentShader - }; - - } - - material.onBeforeCompile( materialProperties.shader, _this ); - - // Computing cache key again as onBeforeCompile may have changed the shaders - programCacheKey = programCache.getProgramCacheKey( material, parameters ); - - program = programCache.acquireProgram( material, materialProperties.shader, parameters, programCacheKey ); + program = programCache.acquireProgram( parameters, programCacheKey ); materialProperties.program = program; - materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; - materialProperties.outputEncoding = _this.outputEncoding; + materialProperties.uniforms = parameters.uniforms; + materialProperties.outputEncoding = parameters.outputEncoding; material.program = program; } @@ -24818,7 +25036,7 @@ } - var uniforms = materialProperties.shader.uniforms; + var uniforms = materialProperties.uniforms; if ( ! material.isShaderMaterial && ! material.isRawShaderMaterial || @@ -24830,6 +25048,7 @@ } + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; materialProperties.fog = scene.fog; // store the light setup it was created for @@ -24844,9 +25063,12 @@ uniforms.ambientLightColor.value = lights.state.ambient; uniforms.lightProbe.value = lights.state.probe; uniforms.directionalLights.value = lights.state.directional; + uniforms.directionalLightShadows.value = lights.state.directionalShadow; uniforms.spotLights.value = lights.state.spot; + uniforms.spotLightShadows.value = lights.state.spotShadow; uniforms.rectAreaLights.value = lights.state.rectArea; uniforms.pointLights.value = lights.state.point; + uniforms.pointLightShadows.value = lights.state.pointShadow; uniforms.hemisphereLights.value = lights.state.hemi; uniforms.directionalShadowMap.value = lights.state.directionalShadowMap; @@ -24873,6 +25095,7 @@ var fog = scene.fog; var environment = material.isMeshStandardMaterial ? scene.environment : null; + var encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding; var materialProperties = properties.get( material ); var lights = currentRenderState.state.lights; @@ -24900,35 +25123,33 @@ if ( materialProperties.program === undefined ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( material.fog && materialProperties.fog !== fog ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.environment !== environment ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.numClippingPlanes !== undefined && ( materialProperties.numClippingPlanes !== _clipping.numPlanes || materialProperties.numIntersection !== _clipping.numIntersection ) ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); - } else if ( materialProperties.outputEncoding !== _this.outputEncoding ) { + } else if ( materialProperties.outputEncoding !== encoding ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } - } - - if ( material.version !== materialProperties.__version ) { + } else { initMaterial( material, scene, object ); materialProperties.__version = material.version; @@ -24941,7 +25162,7 @@ var program = materialProperties.program, p_uniforms = program.getUniforms(), - m_uniforms = materialProperties.shader.uniforms; + m_uniforms = materialProperties.uniforms; if ( state.useProgram( program.program ) ) { @@ -24961,15 +25182,7 @@ if ( refreshProgram || _currentCamera !== camera ) { - if ( program.numMultiviewViews > 0 ) { - - multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); - - } + p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); if ( capabilities.logarithmicDepthBuffer ) { @@ -25030,15 +25243,7 @@ material.isShaderMaterial || material.skinning ) { - if ( program.numMultiviewViews > 0 ) { - - multiview.updateCameraViewMatricesUniform( camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); - - } + p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); } @@ -25046,7 +25251,7 @@ // skinning uniforms must be set even if material didn't change // auto-setting of texture unit for bone texture must go before other textures - // not sure why, but otherwise weird things happen + // otherwise textures used for skinning can take over texture units reserved for other material textures if ( material.skinning ) { @@ -25072,7 +25277,7 @@ var size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix - size = _Math.ceilPowerOfTwo( size ); + size = MathUtils.ceilPowerOfTwo( size ); size = Math.max( size, 4 ); var boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel @@ -25243,17 +25448,8 @@ // common matrices - if ( program.numMultiviewViews > 0 ) { - - multiview.updateObjectMatricesUniforms( object, camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); - p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); - - } - + p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); + p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); return program; @@ -25302,10 +25498,6 @@ uniforms.envMap.value = envMap; - // don't flip CubeTexture envMaps, flip everything else: - // WebGLRenderTargetCube will be flipped for backwards compatibility - // WebGLRenderTargetCube.texture will be flipped because it's a Texture and NOT a CubeTexture - // this check must be handled differently, or removed entirely, if WebGLRenderTargetCube uses a CubeTexture in the future uniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1; uniforms.reflectivity.value = material.reflectivity; @@ -25718,6 +25910,18 @@ uniforms.clearcoatRoughness.value = material.clearcoatRoughness; if ( material.sheen ) { uniforms.sheen.value.copy( material.sheen ); } + if ( material.clearcoatMap ) { + + uniforms.clearcoatMap.value = material.clearcoatMap; + + } + + if ( material.clearcoatRoughnessMap ) { + + uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap; + + } + if ( material.clearcoatNormalMap ) { uniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale ); @@ -25833,8 +26037,11 @@ uniforms.lightProbe.needsUpdate = value; uniforms.directionalLights.needsUpdate = value; + uniforms.directionalLightShadows.needsUpdate = value; uniforms.pointLights.needsUpdate = value; + uniforms.pointLightShadows.needsUpdate = value; uniforms.spotLights.needsUpdate = value; + uniforms.spotLightShadows.needsUpdate = value; uniforms.rectAreaLights.needsUpdate = value; uniforms.hemisphereLights.needsUpdate = value; @@ -25894,7 +26101,7 @@ var __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer; - if ( renderTarget.isWebGLRenderTargetCube ) { + if ( renderTarget.isWebGLCubeRenderTarget ) { framebuffer = __webglFramebuffer[ activeCubeFace || 0 ]; isCube = true; @@ -25952,7 +26159,7 @@ var framebuffer = properties.get( renderTarget ).__webglFramebuffer; - if ( renderTarget.isWebGLRenderTargetCube && activeCubeFaceIndex !== undefined ) { + if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) { framebuffer = framebuffer[ activeCubeFaceIndex ]; @@ -26041,6 +26248,8 @@ this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) { + if ( level === undefined ) { level = 0; } + var width = srcTexture.image.width; var height = srcTexture.image.height; var glFormat = utils.convert( dstTexture.format ); @@ -26050,14 +26259,25 @@ if ( srcTexture.isDataTexture ) { - _gl.texSubImage2D( 3553, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); + _gl.texSubImage2D( 3553, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); } else { - _gl.texSubImage2D( 3553, level || 0, position.x, position.y, glFormat, glType, srcTexture.image ); + if ( srcTexture.isCompressedTexture ) { + + _gl.compressedTexSubImage2D( 3553, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data ); + + } else { + + _gl.texSubImage2D( 3553, level, position.x, position.y, glFormat, glType, srcTexture.image ); + + } } + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) { _gl.generateMipmap( 3553 ); } + state.unbindTexture(); }; @@ -26250,7 +26470,7 @@ * @author benaadams / https://twitter.com/ben_a_adams */ - var _vector$7 = new Vector3(); + var _vector$6 = new Vector3(); function InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normalized ) { @@ -26294,13 +26514,13 @@ for ( var i = 0, l = this.data.count; i < l; i ++ ) { - _vector$7.x = this.getX( i ); - _vector$7.y = this.getY( i ); - _vector$7.z = this.getZ( i ); + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); - _vector$7.applyMatrix4( m ); + _vector$6.applyMatrix4( m ); - this.setXYZ( i, _vector$7.x, _vector$7.y, _vector$7.z ); + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); } @@ -26652,6 +26872,8 @@ Object3D.call( this ); + this._currentLevel = 0; + this.type = 'LOD'; Object.defineProperties( this, { @@ -26717,6 +26939,12 @@ }, + getCurrentLevel: function () { + + return this._currentLevel; + + }, + getObjectForDistance: function ( distance ) { var levels = this.levels; @@ -26766,7 +26994,7 @@ _v1$4.setFromMatrixPosition( camera.matrixWorld ); _v2$2.setFromMatrixPosition( this.matrixWorld ); - var distance = _v1$4.distanceTo( _v2$2 ); + var distance = _v1$4.distanceTo( _v2$2 ) / camera.zoom; levels[ 0 ].object.visible = true; @@ -26785,6 +27013,8 @@ } + this._currentLevel = i - 1; + for ( ; i < l; i ++ ) { levels[ i ].object.visible = false; @@ -26932,7 +27162,51 @@ return new this.constructor( this.geometry, this.material ).copy( this ); - } + }, + + boneTransform: ( function () { + + var basePosition = new Vector3(); + + var skinIndex = new Vector4(); + var skinWeight = new Vector4(); + + var vector = new Vector3(); + var matrix = new Matrix4(); + + return function ( index, target ) { + + var skeleton = this.skeleton; + var geometry = this.geometry; + + skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index ); + skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index ); + + basePosition.fromBufferAttribute( geometry.attributes.position, index ).applyMatrix4( this.bindMatrix ); + + target.set( 0, 0, 0 ); + + for ( var i = 0; i < 4; i ++ ) { + + var weight = skinWeight.getComponent( i ); + + if ( weight !== 0 ) { + + var boneIndex = skinIndex.getComponent( i ); + + matrix.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] ); + + target.addScaledVector( vector.copy( basePosition ).applyMatrix4( matrix ), weight ); + + } + + } + + return target.applyMatrix4( this.bindMatrixInverse ); + + }; + + }() ) } ); @@ -27104,6 +27378,18 @@ return undefined; + }, + + dispose: function ( ) { + + if ( this.boneTexture ) { + + this.boneTexture.dispose(); + + this.boneTexture = undefined; + + } + } } ); @@ -27149,6 +27435,8 @@ this.count = count; + this.frustumCulled = false; + } InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { @@ -27189,17 +27477,17 @@ // process the result of raycast - if ( _instanceIntersects.length > 0 ) { - - _instanceIntersects[ 0 ].instanceId = instanceId; - _instanceIntersects[ 0 ].object = this; - - intersects.push( _instanceIntersects[ 0 ] ); + for ( var i = 0, l = _instanceIntersects.length; i < l; i ++ ) { - _instanceIntersects.length = 0; + var intersect = _instanceIntersects[ i ]; + intersect.instanceId = instanceId; + intersect.object = this; + intersects.push( intersect ); } + _instanceIntersects.length = 0; + } }, @@ -27288,7 +27576,7 @@ this.type = 'Line'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new LineBasicMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new LineBasicMaterial(); } @@ -27351,10 +27639,9 @@ raycast: function ( raycaster, intersects ) { - var precision = raycaster.linePrecision; - var geometry = this.geometry; var matrixWorld = this.matrixWorld; + var threshold = raycaster.params.Line.threshold; // Checking boundingSphere distance to ray @@ -27362,7 +27649,7 @@ _sphere$2.copy( geometry.boundingSphere ); _sphere$2.applyMatrix4( matrixWorld ); - _sphere$2.radius += precision; + _sphere$2.radius += threshold; if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) { return; } @@ -27371,8 +27658,8 @@ _inverseMatrix$1.getInverse( matrixWorld ); _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 ); - var localPrecision = precision / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); - var localPrecisionSq = localPrecision * localPrecision; + var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + var localThresholdSq = localThreshold * localThreshold; var vStart = new Vector3(); var vEnd = new Vector3(); @@ -27400,7 +27687,7 @@ var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); - if ( distSq > localPrecisionSq ) { continue; } + if ( distSq > localThresholdSq ) { continue; } interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27432,7 +27719,7 @@ var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); - if ( distSq > localPrecisionSq ) { continue; } + if ( distSq > localThresholdSq ) { continue; } interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27466,7 +27753,7 @@ var distSq = _ray$1.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment ); - if ( distSq > localPrecisionSq ) { continue; } + if ( distSq > localThresholdSq ) { continue; } interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27674,7 +27961,7 @@ this.type = 'Points'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new PointsMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new PointsMaterial(); this.updateMorphTargets(); @@ -28133,7 +28420,7 @@ * @author Mugen87 / https://github.com/Mugen87 * * Parametric Surfaces Geometry - * based on the brilliant article by @prideout http://prideout.net/blog/?p=44 + * based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html */ // ParametricGeometry @@ -29415,7 +29702,7 @@ /** * @author Mugen87 / https://github.com/Mugen87 - * Port from https://github.com/mapbox/earcut (v2.1.5) + * Port from https://github.com/mapbox/earcut (v2.2.2) */ var Earcut = { @@ -29571,7 +29858,7 @@ } else if ( pass === 1 ) { - ear = cureLocalIntersections( ear, triangles, dim ); + ear = cureLocalIntersections( filterPoints( ear ), triangles, dim ); earcutLinked( ear, triangles, dim, minX, minY, invSize, 2 ); // as a last resort, try splitting the remaining polygon into two @@ -29701,7 +29988,7 @@ } while ( p !== start ); - return p; + return filterPoints( p ); } @@ -29784,6 +30071,9 @@ if ( outerNode ) { var b = splitPolygon( outerNode, hole ); + + // filter collinear points around the cuts + filterPoints( outerNode, outerNode.next ); filterPoints( b, b.next ); } @@ -29828,7 +30118,7 @@ if ( ! m ) { return null; } - if ( hx === qx ) { return m.prev; } // hole touches outer segment; pick lower endpoint + if ( hx === qx ) { return m; } // hole touches outer segment; pick leftmost endpoint // look for points inside the triangle of hole point, segment intersection and endpoint; // if there are no points found, we have a valid connection; @@ -29840,16 +30130,16 @@ tanMin = Infinity, tan; - p = m.next; + p = m; - while ( p !== stop ) { + do { if ( hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) { tan = Math.abs( hy - p.y ) / ( hx - p.x ); // tangential - if ( ( tan < tanMin || ( tan === tanMin && p.x > m.x ) ) && locallyInside( p, hole ) ) { + if ( locallyInside( p, hole ) && ( tan < tanMin || ( tan === tanMin && ( p.x > m.x || ( p.x === m.x && sectorContainsSector( m, p ) ) ) ) ) ) { m = p; tanMin = tan; @@ -29860,12 +30150,19 @@ p = p.next; - } + } while ( p !== stop ); return m; } + // whether sector in vertex m contains sector in vertex p in the same coordinates + function sectorContainsSector( m, p ) { + + return area( m.prev, m, p.prev ) < 0 && area( p.next, m, m.next ) < 0; + + } + // interlink polygon nodes in z-order function indexCurve( start, minX, minY, invSize ) { @@ -29993,16 +30290,18 @@ function pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) { return ( cx - px ) * ( ay - py ) - ( ax - px ) * ( cy - py ) >= 0 && - ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 && - ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0; + ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 && + ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0; } // check if a diagonal between two polygon nodes is valid (lies in polygon interior) function isValidDiagonal( a, b ) { - return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && - locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ); + return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // dones't intersect other edges + ( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible + ( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors + equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case } @@ -30023,10 +30322,32 @@ // check if two segments intersect function intersects( p1, q1, p2, q2 ) { - if ( ( equals( p1, p2 ) && equals( q1, q2 ) ) || - ( equals( p1, q2 ) && equals( p2, q1 ) ) ) { return true; } - return area( p1, q1, p2 ) > 0 !== area( p1, q1, q2 ) > 0 && - area( p2, q2, p1 ) > 0 !== area( p2, q2, q1 ) > 0; + var o1 = sign( area( p1, q1, p2 ) ); + var o2 = sign( area( p1, q1, q2 ) ); + var o3 = sign( area( p2, q2, p1 ) ); + var o4 = sign( area( p2, q2, q1 ) ); + + if ( o1 !== o2 && o3 !== o4 ) { return true; } // general case + + if ( o1 === 0 && onSegment( p1, p2, q1 ) ) { return true; } // p1, q1 and p2 are collinear and p2 lies on p1q1 + if ( o2 === 0 && onSegment( p1, q2, q1 ) ) { return true; } // p1, q1 and q2 are collinear and q2 lies on p1q1 + if ( o3 === 0 && onSegment( p2, p1, q2 ) ) { return true; } // p2, q2 and p1 are collinear and p1 lies on p2q2 + if ( o4 === 0 && onSegment( p2, q1, q2 ) ) { return true; } // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; + + } + + // for collinear points p, q, r, check if point q lies on segment pr + function onSegment( p, q, r ) { + + return q.x <= Math.max( p.x, r.x ) && q.x >= Math.min( p.x, r.x ) && q.y <= Math.max( p.y, r.y ) && q.y >= Math.min( p.y, r.y ); + + } + + function sign( num ) { + + return num > 0 ? 1 : num < 0 ? - 1 : 0; } @@ -31521,7 +31842,7 @@ // clamp phiLength so it's in range of [ 0, 2PI ] - phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 ); + phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 ); // buffers @@ -31884,7 +32205,7 @@ // helper variables - var thresholdDot = Math.cos( _Math.DEG2RAD * thresholdAngle ); + var thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle ); var edge = [ 0, 0 ], edges = {}, edge1, edge2; var key, keys = [ 'a', 'b', 'c' ]; @@ -32438,8 +32759,6 @@ CircleBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); CircleBufferGeometry.prototype.constructor = CircleBufferGeometry; - - var Geometries = /*#__PURE__*/Object.freeze({ __proto__: null, WireframeGeometry: WireframeGeometry, @@ -32646,6 +32965,8 @@ this.morphTargets = false; this.morphNormals = false; + this.vertexTangents = false; + this.setValues( parameters ); } @@ -32708,6 +33029,8 @@ this.morphTargets = source.morphTargets; this.morphNormals = source.morphNormals; + this.vertexTangents = source.vertexTangents; + return this; }; @@ -32716,14 +33039,18 @@ * @author WestLangley / http://github.com/WestLangley * * parameters = { - * reflectivity: - * clearcoat: - * clearcoatRoughness: - * - * sheen: - * + * clearcoat: , + * clearcoatMap: new THREE.Texture( ), + * clearcoatRoughness: , + * clearcoatRoughnessMap: new THREE.Texture( ), * clearcoatNormalScale: , * clearcoatNormalMap: new THREE.Texture( ), + * + * reflectivity: , + * + * sheen: , + * + * transparency: * } */ @@ -32740,16 +33067,17 @@ this.type = 'MeshPhysicalMaterial'; - this.reflectivity = 0.5; // maps to F0 = 0.04 - this.clearcoat = 0.0; + this.clearcoatMap = null; this.clearcoatRoughness = 0.0; - - this.sheen = null; // null will disable sheen bsdf - + this.clearcoatRoughnessMap = null; this.clearcoatNormalScale = new Vector2( 1, 1 ); this.clearcoatNormalMap = null; + this.reflectivity = 0.5; // maps to F0 = 0.04 + + this.sheen = null; // null will disable sheen bsdf + this.transparency = 0.0; this.setValues( parameters ); @@ -32772,17 +33100,25 @@ }; - this.reflectivity = source.reflectivity; - this.clearcoat = source.clearcoat; + this.clearcoatMap = source.clearcoatMap; this.clearcoatRoughness = source.clearcoatRoughness; - - if ( source.sheen ) { this.sheen = ( this.sheen || new Color() ).copy( source.sheen ); } - else { this.sheen = null; } - + this.clearcoatRoughnessMap = source.clearcoatRoughnessMap; this.clearcoatNormalMap = source.clearcoatNormalMap; this.clearcoatNormalScale.copy( source.clearcoatNormalScale ); + this.reflectivity = source.reflectivity; + + if ( source.sheen ) { + + this.sheen = ( this.sheen || new Color() ).copy( source.sheen ); + + } else { + + this.sheen = null; + + } + this.transparency = source.transparency; return this; @@ -33467,8 +33803,6 @@ }; - - var Materials = /*#__PURE__*/Object.freeze({ __proto__: null, ShadowMaterial: ShadowMaterial, @@ -33724,6 +34058,112 @@ return clip; + }, + + makeClipAdditive: function ( targetClip, referenceFrame, referenceClip, fps ) { + + if ( referenceFrame === undefined ) { referenceFrame = 0; } + if ( referenceClip === undefined ) { referenceClip = targetClip; } + if ( fps === undefined || fps <= 0 ) { fps = 30; } + + var numTracks = targetClip.tracks.length; + var referenceTime = referenceFrame / fps; + + // Make each track's values relative to the values at the reference frame + for ( var i = 0; i < numTracks; ++ i ) { + + var referenceTrack = referenceClip.tracks[ i ]; + var referenceTrackType = referenceTrack.ValueTypeName; + + // Skip this track if it's non-numeric + if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) { continue; } + + // Find the track in the target clip whose name and type matches the reference track + var targetTrack = targetClip.tracks.find( function ( track ) { + + return track.name === referenceTrack.name + && track.ValueTypeName === referenceTrackType; + + } ); + + if ( targetTrack === undefined ) { continue; } + + var valueSize = referenceTrack.getValueSize(); + var lastIndex = referenceTrack.times.length - 1; + var referenceValue; + + // Find the value to subtract out of the track + if ( referenceTime <= referenceTrack.times[ 0 ] ) { + + // Reference frame is earlier than the first keyframe, so just use the first keyframe + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, 0, referenceTrack.valueSize ); + + } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { + + // Reference frame is after the last keyframe, so just use the last keyframe + var startIndex = lastIndex * valueSize; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex ); + + } else { + + // Interpolate to the reference value + var interpolant = referenceTrack.createInterpolant(); + interpolant.evaluate( referenceTime ); + referenceValue = interpolant.resultBuffer; + + } + + // Conjugate the quaternion + if ( referenceTrackType === 'quaternion' ) { + + var referenceQuat = new Quaternion( + referenceValue[ 0 ], + referenceValue[ 1 ], + referenceValue[ 2 ], + referenceValue[ 3 ] + ).normalize().conjugate(); + referenceQuat.toArray( referenceValue ); + + } + + // Subtract the reference value from all of the track values + + var numTimes = targetTrack.times.length; + for ( var j = 0; j < numTimes; ++ j ) { + + var valueStart = j * valueSize; + + if ( referenceTrackType === 'quaternion' ) { + + // Multiply the conjugate for quaternion track types + Quaternion.multiplyQuaternionsFlat( + targetTrack.values, + valueStart, + referenceValue, + 0, + targetTrack.values, + valueStart + ); + + } else { + + // Subtract each value for all other numeric track types + for ( var k = 0; k < valueSize; ++ k ) { + + targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; + + } + + } + + } + + } + + targetClip.blendMode = AdditiveAnimationBlendMode; + + return targetClip; + } }; @@ -33974,7 +34414,7 @@ } ); - //!\ DECLARE ALIAS AFTER assign prototype ! + // DECLARE ALIAS AFTER assign prototype Object.assign( Interpolant.prototype, { //( 0, t, t0 ), returns this.resultBuffer @@ -34447,7 +34887,12 @@ if ( from !== 0 || to !== nKeys ) { // empty tracks are forbidden, so keep at least one keyframe - if ( from >= to ) { to = Math.max( to, 1 ), from = to - 1; } + if ( from >= to ) { + + to = Math.max( to, 1 ); + from = to - 1; + + } var stride = this.getValueSize(); this.times = AnimationUtils.arraySlice( times, from, to ); @@ -34540,8 +34985,9 @@ // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) optimize: function () { - var times = this.times, - values = this.values, + // times or values may be shared with other tracks, so overwriting is unsafe + var times = AnimationUtils.arraySlice( this.times ), + values = AnimationUtils.arraySlice( this.values ), stride = this.getValueSize(), smoothInterpolation = this.getInterpolation() === InterpolateSmooth, @@ -34636,6 +35082,11 @@ this.times = AnimationUtils.arraySlice( times, 0, writeIndex ); this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride ); + } else { + + this.times = times; + this.values = values; + } return this; @@ -34891,13 +35342,14 @@ * @author David Sarno / http://lighthaus.us/ */ - function AnimationClip( name, duration, tracks ) { + function AnimationClip( name, duration, tracks, blendMode ) { this.name = name; this.tracks = tracks; this.duration = ( duration !== undefined ) ? duration : - 1; + this.blendMode = ( blendMode !== undefined ) ? blendMode : NormalAnimationBlendMode; - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); // this means it should figure out its duration by scanning the tracks if ( this.duration < 0 ) { @@ -34999,7 +35451,7 @@ } - return new AnimationClip( json.name, json.duration, tracks ); + return new AnimationClip( json.name, json.duration, tracks, json.blendMode ); }, @@ -35013,7 +35465,8 @@ 'name': clip.name, 'duration': clip.duration, 'tracks': tracks, - 'uuid': clip.uuid + 'uuid': clip.uuid, + 'blendMode': clip.blendMode }; @@ -35175,6 +35628,7 @@ // automatic length determination in AnimationClip. var duration = animation.length || - 1; var fps = animation.fps || 30; + var blendMode = animation.blendMode; var hierarchyTracks = animation.hierarchy || []; @@ -35256,7 +35710,7 @@ } - var clip = new AnimationClip( clipName, duration, tracks ); + var clip = new AnimationClip( clipName, duration, tracks, blendMode ); return clip; @@ -35332,7 +35786,7 @@ } - return new AnimationClip( this.name, this.duration, tracks ); + return new AnimationClip( this.name, this.duration, tracks, this.blendMode ); } @@ -35541,6 +35995,18 @@ load: function ( /* url, onLoad, onProgress, onError */ ) {}, + loadAsync: function ( url, onProgress ) { + + var scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.load( url, resolve, onProgress, reject ); + + } ); + + }, + parse: function ( /* data */ ) {}, setCrossOrigin: function ( crossOrigin ) { @@ -36109,6 +36575,7 @@ texture.format = texData.format; } + if ( texData.type !== undefined ) { texture.type = texData.type; @@ -36335,8 +36802,8 @@ * Extensible curve object * * Some common of curve methods: - * .getPoint( t, optionalTarget ), .getTangent( t ) - * .getPointAt( u, optionalTarget ), .getTangentAt( u ) + * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget ) + * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget ) * .getPoints(), .getSpacedPoints() * .getLength() * .updateArcLengths() @@ -36565,7 +37032,7 @@ // 2 points a small delta apart will be used to find its gradient // which seems to give a reasonable approximation - getTangent: function ( t ) { + getTangent: function ( t, optionalTarget ) { var delta = 0.0001; var t1 = t - delta; @@ -36579,15 +37046,18 @@ var pt1 = this.getPoint( t1 ); var pt2 = this.getPoint( t2 ); - var vec = pt2.clone().sub( pt1 ); - return vec.normalize(); + var tangent = optionalTarget || ( ( pt1.isVector2 ) ? new Vector2() : new Vector3() ); + + tangent.copy( pt2 ).sub( pt1 ).normalize(); + + return tangent; }, - getTangentAt: function ( u ) { + getTangentAt: function ( u, optionalTarget ) { var t = this.getUtoTmapping( u ); - return this.getTangent( t ); + return this.getTangent( t, optionalTarget ); }, @@ -36612,7 +37082,7 @@ u = i / segments; - tangents[ i ] = this.getTangentAt( u ); + tangents[ i ] = this.getTangentAt( u, new Vector3() ); tangents[ i ].normalize(); } @@ -36667,7 +37137,7 @@ vec.normalize(); - theta = Math.acos( _Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors + theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) ); @@ -36681,7 +37151,7 @@ if ( closed === true ) { - theta = Math.acos( _Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) ); + theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) ); theta /= segments; if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) { @@ -37432,11 +37902,13 @@ }; - LineCurve.prototype.getTangent = function ( /* t */ ) { + LineCurve.prototype.getTangent = function ( t, optionalTarget ) { + + var tangent = optionalTarget || new Vector2(); - var tangent = this.v2.clone().sub( this.v1 ); + var tangent = tangent.copy( this.v2 ).sub( this.v1 ).normalize(); - return tangent.normalize(); + return tangent; }; @@ -37777,8 +38249,6 @@ }; - - var Curves = /*#__PURE__*/Object.freeze({ __proto__: null, ArcCurve: ArcCurve, @@ -38257,7 +38727,7 @@ Path.call( this, points ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.type = 'Shape'; @@ -38512,7 +38982,7 @@ shadowCamera.updateMatrixWorld(); projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse ); - this._frustum.setFromMatrix( projScreenMatrix ); + this._frustum.setFromProjectionMatrix( projScreenMatrix ); shadowMatrix.set( 0.5, 0.0, 0.0, 0.5, @@ -38594,7 +39064,7 @@ var camera = this.camera; - var fov = _Math.RAD2DEG * 2 * light.angle; + var fov = MathUtils.RAD2DEG * 2 * light.angle; var aspect = this.mapSize.width / this.mapSize.height; var far = light.distance || camera.far; @@ -38755,7 +39225,7 @@ shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z ); projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); - this._frustum.setFromMatrix( projScreenMatrix ); + this._frustum.setFromProjectionMatrix( projScreenMatrix ); } @@ -38921,15 +39391,13 @@ if ( this.view !== null && this.view.enabled ) { - var zoomW = this.zoom / ( this.view.width / this.view.fullWidth ); - var zoomH = this.zoom / ( this.view.height / this.view.fullHeight ); - var scaleW = ( this.right - this.left ) / this.view.width; - var scaleH = ( this.top - this.bottom ) / this.view.height; + var scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom; + var scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom; - left += scaleW * ( this.view.offsetX / zoomW ); - right = left + scaleW * ( this.view.width / zoomW ); - top -= scaleH * ( this.view.offsetY / zoomH ); - bottom = top - scaleH * ( this.view.height / zoomH ); + left += scaleW * this.view.offsetX; + right = left + scaleW * this.view.width; + top -= scaleH * this.view.offsetY; + bottom = top - scaleH * this.view.height; } @@ -39090,6 +39558,311 @@ } ); + /** + * @author bhouston / http://clara.io + * @author WestLangley / http://github.com/WestLangley + * + * Primary reference: + * https://graphics.stanford.edu/papers/envmap/envmap.pdf + * + * Secondary reference: + * https://www.ppsloan.org/publications/StupidSH36.pdf + */ + + // 3-band SH defined by 9 coefficients + + function SphericalHarmonics3() { + + this.coefficients = []; + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients.push( new Vector3() ); + + } + + } + + Object.assign( SphericalHarmonics3.prototype, { + + isSphericalHarmonics3: true, + + set: function ( coefficients ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].copy( coefficients[ i ] ); + + } + + return this; + + }, + + zero: function () { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].set( 0, 0, 0 ); + + } + + return this; + + }, + + // get the radiance in the direction of the normal + // target is a Vector3 + getAt: function ( normal, target ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + var coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.282095 ); + + // band 1 + target.addScaledVector( coeff[ 1 ], 0.488603 * y ); + target.addScaledVector( coeff[ 2 ], 0.488603 * z ); + target.addScaledVector( coeff[ 3 ], 0.488603 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 1.092548 * ( x * y ) ); + target.addScaledVector( coeff[ 5 ], 1.092548 * ( y * z ) ); + target.addScaledVector( coeff[ 6 ], 0.315392 * ( 3.0 * z * z - 1.0 ) ); + target.addScaledVector( coeff[ 7 ], 1.092548 * ( x * z ) ); + target.addScaledVector( coeff[ 8 ], 0.546274 * ( x * x - y * y ) ); + + return target; + + }, + + // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal + // target is a Vector3 + // https://graphics.stanford.edu/papers/envmap/envmap.pdf + getIrradianceAt: function ( normal, target ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + var coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.886227 ); // π * 0.282095 + + // band 1 + target.addScaledVector( coeff[ 1 ], 2.0 * 0.511664 * y ); // ( 2 * π / 3 ) * 0.488603 + target.addScaledVector( coeff[ 2 ], 2.0 * 0.511664 * z ); + target.addScaledVector( coeff[ 3 ], 2.0 * 0.511664 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 2.0 * 0.429043 * x * y ); // ( π / 4 ) * 1.092548 + target.addScaledVector( coeff[ 5 ], 2.0 * 0.429043 * y * z ); + target.addScaledVector( coeff[ 6 ], 0.743125 * z * z - 0.247708 ); // ( π / 4 ) * 0.315392 * 3 + target.addScaledVector( coeff[ 7 ], 2.0 * 0.429043 * x * z ); + target.addScaledVector( coeff[ 8 ], 0.429043 * ( x * x - y * y ) ); // ( π / 4 ) * 0.546274 + + return target; + + }, + + add: function ( sh ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].add( sh.coefficients[ i ] ); + + } + + return this; + + }, + + addScaledSH: function ( sh, s ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].addScaledVector( sh.coefficients[ i ], s ); + + } + + return this; + + }, + + scale: function ( s ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].multiplyScalar( s ); + + } + + return this; + + }, + + lerp: function ( sh, alpha ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].lerp( sh.coefficients[ i ], alpha ); + + } + + return this; + + }, + + equals: function ( sh ) { + + for ( var i = 0; i < 9; i ++ ) { + + if ( ! this.coefficients[ i ].equals( sh.coefficients[ i ] ) ) { + + return false; + + } + + } + + return true; + + }, + + copy: function ( sh ) { + + return this.set( sh.coefficients ); + + }, + + clone: function () { + + return new this.constructor().copy( this ); + + }, + + fromArray: function ( array, offset ) { + + if ( offset === undefined ) { offset = 0; } + + var coefficients = this.coefficients; + + for ( var i = 0; i < 9; i ++ ) { + + coefficients[ i ].fromArray( array, offset + ( i * 3 ) ); + + } + + return this; + + }, + + toArray: function ( array, offset ) { + + if ( array === undefined ) { array = []; } + if ( offset === undefined ) { offset = 0; } + + var coefficients = this.coefficients; + + for ( var i = 0; i < 9; i ++ ) { + + coefficients[ i ].toArray( array, offset + ( i * 3 ) ); + + } + + return array; + + } + + } ); + + Object.assign( SphericalHarmonics3, { + + // evaluate the basis functions + // shBasis is an Array[ 9 ] + getBasisAt: function ( normal, shBasis ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + // band 0 + shBasis[ 0 ] = 0.282095; + + // band 1 + shBasis[ 1 ] = 0.488603 * y; + shBasis[ 2 ] = 0.488603 * z; + shBasis[ 3 ] = 0.488603 * x; + + // band 2 + shBasis[ 4 ] = 1.092548 * x * y; + shBasis[ 5 ] = 1.092548 * y * z; + shBasis[ 6 ] = 0.315392 * ( 3 * z * z - 1 ); + shBasis[ 7 ] = 1.092548 * x * z; + shBasis[ 8 ] = 0.546274 * ( x * x - y * y ); + + } + + } ); + + /** + * @author WestLangley / http://github.com/WestLangley + * + * A LightProbe is a source of indirect-diffuse light + */ + + function LightProbe( sh, intensity ) { + + Light.call( this, undefined, intensity ); + + this.type = 'LightProbe'; + + this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3(); + + } + + LightProbe.prototype = Object.assign( Object.create( Light.prototype ), { + + constructor: LightProbe, + + isLightProbe: true, + + copy: function ( source ) { + + Light.prototype.copy.call( this, source ); + + this.sh.copy( source.sh ); + + return this; + + }, + + fromJSON: function ( json ) { + + this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); + this.sh.fromArray( json.sh ); + + return this; + + }, + + toJSON: function ( meta ) { + + var data = Light.prototype.toJSON.call( this, meta ); + + data.object.sh = this.sh.toArray(); + + return data; + + } + + } ); + /** * @author mrdoob / http://mrdoob.com/ */ @@ -39149,7 +39922,6 @@ if ( json.shininess !== undefined ) { material.shininess = json.shininess; } if ( json.clearcoat !== undefined ) { material.clearcoat = json.clearcoat; } if ( json.clearcoatRoughness !== undefined ) { material.clearcoatRoughness = json.clearcoatRoughness; } - if ( json.vertexColors !== undefined ) { material.vertexColors = json.vertexColors; } if ( json.fog !== undefined ) { material.fog = json.fog; } if ( json.flatShading !== undefined ) { material.flatShading = json.flatShading; } if ( json.blending !== undefined ) { material.blending = json.blending; } @@ -39192,12 +39964,28 @@ if ( json.morphNormals !== undefined ) { material.morphNormals = json.morphNormals; } if ( json.dithering !== undefined ) { material.dithering = json.dithering; } + if ( json.vertexTangents !== undefined ) { material.vertexTangents = json.vertexTangents; } + if ( json.visible !== undefined ) { material.visible = json.visible; } if ( json.toneMapped !== undefined ) { material.toneMapped = json.toneMapped; } if ( json.userData !== undefined ) { material.userData = json.userData; } + if ( json.vertexColors !== undefined ) { + + if ( typeof json.vertexColors === 'number' ) { + + material.vertexColors = ( json.vertexColors > 0 ) ? true : false; + + } else { + + material.vertexColors = json.vertexColors; + + } + + } + // Shader Material if ( json.uniforms !== undefined ) { @@ -39274,12 +40062,7 @@ if ( json.map !== undefined ) { material.map = getTexture( json.map ); } if ( json.matcap !== undefined ) { material.matcap = getTexture( json.matcap ); } - if ( json.alphaMap !== undefined ) { - - material.alphaMap = getTexture( json.alphaMap ); - material.transparent = true; - - } + if ( json.alphaMap !== undefined ) { material.alphaMap = getTexture( json.alphaMap ); } if ( json.bumpMap !== undefined ) { material.bumpMap = getTexture( json.bumpMap ); } if ( json.bumpScale !== undefined ) { material.bumpScale = json.bumpScale; } @@ -39328,6 +40111,8 @@ if ( json.gradientMap !== undefined ) { material.gradientMap = getTexture( json.gradientMap ); } + if ( json.clearcoatMap !== undefined ) { material.clearcoatMap = getTexture( json.clearcoatMap ); } + if ( json.clearcoatRoughnessMap !== undefined ) { material.clearcoatRoughnessMap = getTexture( json.clearcoatRoughnessMap ); } if ( json.clearcoatNormalMap !== undefined ) { material.clearcoatNormalMap = getTexture( json.clearcoatNormalMap ); } if ( json.clearcoatNormalScale !== undefined ) { material.clearcoatNormalScale = new Vector2().fromArray( json.clearcoatNormalScale ); } @@ -40000,17 +40785,7 @@ case 'Geometry': - if ( 'THREE' in window && 'LegacyJSONLoader' in THREE ) { - - var geometryLoader = new THREE.LegacyJSONLoader(); - geometry = geometryLoader.parse( data, this.resourcePath ).geometry; - - - } else { - - console.error( 'THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".' ); - - } + console.error( 'THREE.ObjectLoader: Loading "Geometry" is not supported anymore.' ); break; @@ -40409,6 +41184,12 @@ break; + case 'LightProbe': + + object = new LightProbe().fromJSON( data ); + + break; + case 'SkinnedMesh': console.warn( 'THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.' ); @@ -40418,15 +41199,7 @@ var geometry = getGeometry( data.geometry ); var material = getMaterial( data.material ); - if ( geometry.bones && geometry.bones.length > 0 ) { - - object = new SkinnedMesh( geometry, material ); - - } else { - - object = new Mesh( geometry, material ); - - } + object = new Mesh( geometry, material ); break; @@ -40806,6 +41579,7 @@ edgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy; } + if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) { continue; } if ( inPt.y === edgeLowPt.y ) { @@ -40945,6 +41719,7 @@ } } + if ( hole_unassigned ) { betterShapeHoles[ sIdx ].push( ho ); @@ -40955,6 +41730,7 @@ } // console.log("ambiguous: ", ambiguous); + if ( toChange.length > 0 ) { // console.log("to change: ", toChange); @@ -41027,7 +41803,7 @@ function createPaths( text, size, data ) { - var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988 + var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // workaround for IE11, see #13988 var scale = size / data.resolution; var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale; @@ -41253,290 +42029,6 @@ } ); - /** - * @author bhouston / http://clara.io - * @author WestLangley / http://github.com/WestLangley - * - * Primary reference: - * https://graphics.stanford.edu/papers/envmap/envmap.pdf - * - * Secondary reference: - * https://www.ppsloan.org/publications/StupidSH36.pdf - */ - - // 3-band SH defined by 9 coefficients - - function SphericalHarmonics3() { - - this.coefficients = []; - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients.push( new Vector3() ); - - } - - } - - Object.assign( SphericalHarmonics3.prototype, { - - isSphericalHarmonics3: true, - - set: function ( coefficients ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].copy( coefficients[ i ] ); - - } - - return this; - - }, - - zero: function () { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].set( 0, 0, 0 ); - - } - - return this; - - }, - - // get the radiance in the direction of the normal - // target is a Vector3 - getAt: function ( normal, target ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - var coeff = this.coefficients; - - // band 0 - target.copy( coeff[ 0 ] ).multiplyScalar( 0.282095 ); - - // band 1 - target.addScale( coeff[ 1 ], 0.488603 * y ); - target.addScale( coeff[ 2 ], 0.488603 * z ); - target.addScale( coeff[ 3 ], 0.488603 * x ); - - // band 2 - target.addScale( coeff[ 4 ], 1.092548 * ( x * y ) ); - target.addScale( coeff[ 5 ], 1.092548 * ( y * z ) ); - target.addScale( coeff[ 6 ], 0.315392 * ( 3.0 * z * z - 1.0 ) ); - target.addScale( coeff[ 7 ], 1.092548 * ( x * z ) ); - target.addScale( coeff[ 8 ], 0.546274 * ( x * x - y * y ) ); - - return target; - - }, - - // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal - // target is a Vector3 - // https://graphics.stanford.edu/papers/envmap/envmap.pdf - getIrradianceAt: function ( normal, target ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - var coeff = this.coefficients; - - // band 0 - target.copy( coeff[ 0 ] ).multiplyScalar( 0.886227 ); // π * 0.282095 - - // band 1 - target.addScale( coeff[ 1 ], 2.0 * 0.511664 * y ); // ( 2 * π / 3 ) * 0.488603 - target.addScale( coeff[ 2 ], 2.0 * 0.511664 * z ); - target.addScale( coeff[ 3 ], 2.0 * 0.511664 * x ); - - // band 2 - target.addScale( coeff[ 4 ], 2.0 * 0.429043 * x * y ); // ( π / 4 ) * 1.092548 - target.addScale( coeff[ 5 ], 2.0 * 0.429043 * y * z ); - target.addScale( coeff[ 6 ], 0.743125 * z * z - 0.247708 ); // ( π / 4 ) * 0.315392 * 3 - target.addScale( coeff[ 7 ], 2.0 * 0.429043 * x * z ); - target.addScale( coeff[ 8 ], 0.429043 * ( x * x - y * y ) ); // ( π / 4 ) * 0.546274 - - return target; - - }, - - add: function ( sh ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].add( sh.coefficients[ i ] ); - - } - - return this; - - }, - - - scale: function ( s ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].multiplyScalar( s ); - - } - - return this; - - }, - - lerp: function ( sh, alpha ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].lerp( sh.coefficients[ i ], alpha ); - - } - - return this; - - }, - - equals: function ( sh ) { - - for ( var i = 0; i < 9; i ++ ) { - - if ( ! this.coefficients[ i ].equals( sh.coefficients[ i ] ) ) { - - return false; - - } - - } - - return true; - - }, - - copy: function ( sh ) { - - return this.set( sh.coefficients ); - - }, - - clone: function () { - - return new this.constructor().copy( this ); - - }, - - fromArray: function ( array, offset ) { - - if ( offset === undefined ) { offset = 0; } - - var coefficients = this.coefficients; - - for ( var i = 0; i < 9; i ++ ) { - - coefficients[ i ].fromArray( array, offset + ( i * 3 ) ); - - } - - return this; - - }, - - toArray: function ( array, offset ) { - - if ( array === undefined ) { array = []; } - if ( offset === undefined ) { offset = 0; } - - var coefficients = this.coefficients; - - for ( var i = 0; i < 9; i ++ ) { - - coefficients[ i ].toArray( array, offset + ( i * 3 ) ); - - } - - return array; - - } - - } ); - - Object.assign( SphericalHarmonics3, { - - // evaluate the basis functions - // shBasis is an Array[ 9 ] - getBasisAt: function ( normal, shBasis ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - // band 0 - shBasis[ 0 ] = 0.282095; - - // band 1 - shBasis[ 1 ] = 0.488603 * y; - shBasis[ 2 ] = 0.488603 * z; - shBasis[ 3 ] = 0.488603 * x; - - // band 2 - shBasis[ 4 ] = 1.092548 * x * y; - shBasis[ 5 ] = 1.092548 * y * z; - shBasis[ 6 ] = 0.315392 * ( 3 * z * z - 1 ); - shBasis[ 7 ] = 1.092548 * x * z; - shBasis[ 8 ] = 0.546274 * ( x * x - y * y ); - - } - - } ); - - /** - * @author WestLangley / http://github.com/WestLangley - * - * A LightProbe is a source of indirect-diffuse light - */ - - function LightProbe( sh, intensity ) { - - Light.call( this, undefined, intensity ); - - this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3(); - - } - - LightProbe.prototype = Object.assign( Object.create( Light.prototype ), { - - constructor: LightProbe, - - isLightProbe: true, - - copy: function ( source ) { - - Light.prototype.copy.call( this, source ); - - this.sh.copy( source.sh ); - this.intensity = source.intensity; - - return this; - - }, - - toJSON: function ( meta ) { - - var data = Light.prototype.toJSON.call( this, meta ); - - // data.sh = this.sh.toArray(); // todo - - return data; - - } - - } ); - /** * @author WestLangley / http://github.com/WestLangley */ @@ -41688,7 +42180,7 @@ var projectionMatrix = camera.projectionMatrix.clone(); var eyeSepHalf = cache.eyeSep / 2; var eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus; - var ymax = ( cache.near * Math.tan( _Math.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom; + var ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom; var xmin, xmax; // translate xOffset @@ -41964,7 +42456,7 @@ this.sourceType = 'empty'; this._startedAt = 0; - this._pausedAt = 0; + this._progress = 0; this.filters = []; @@ -42050,7 +42542,7 @@ source.loopStart = this.loopStart; source.loopEnd = this.loopEnd; source.onended = this.onEnded.bind( this ); - source.start( this._startedAt, this._pausedAt + this.offset, this.duration ); + source.start( this._startedAt, this._progress + this.offset, this.duration ); this.isPlaying = true; @@ -42074,7 +42566,17 @@ if ( this.isPlaying === true ) { - this._pausedAt = ( this.context.currentTime - this._startedAt ) * this.playbackRate; + // update current progress + + this._progress += Math.max( this.context.currentTime - this._startedAt, 0 ) * this.playbackRate; + + if ( this.loop === true ) { + + // ensure _progress does not exceed duration with looped audios + + this._progress = this._progress % ( this.duration || this.buffer.duration ); + + } this.source.stop(); this.source.onended = null; @@ -42096,7 +42598,7 @@ } - this._pausedAt = 0; + this._progress = 0; this.source.stop(); this.source.onended = null; @@ -42500,41 +43002,67 @@ this.binding = binding; this.valueSize = valueSize; - var bufferType = Float64Array, - mixFunction; + var mixFunction, + mixFunctionAdditive, + setIdentity; + + // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ] + // + // interpolators can use .buffer as their .result + // the data then goes to 'incoming' + // + // 'accu0' and 'accu1' are used frame-interleaved for + // the cumulative result and are compared to detect + // changes + // + // 'orig' stores the original state of the property + // + // 'add' is used for additive cumulative results + // + // 'work' is optional and is only present for quaternion types. It is used + // to store intermediate quaternion multiplication results switch ( typeName ) { case 'quaternion': mixFunction = this._slerp; + mixFunctionAdditive = this._slerpAdditive; + setIdentity = this._setAdditiveIdentityQuaternion; + + this.buffer = new Float64Array( valueSize * 6 ); + this._workIndex = 5; break; case 'string': case 'bool': - bufferType = Array; mixFunction = this._select; + + // Use the regular mix function and for additive on these types, + // additive is not relevant for non-numeric types + mixFunctionAdditive = this._select; + + setIdentity = this._setAdditiveIdentityOther; + + this.buffer = new Array( valueSize * 5 ); break; default: mixFunction = this._lerp; + mixFunctionAdditive = this._lerpAdditive; + setIdentity = this._setAdditiveIdentityNumeric; - } + this.buffer = new Float64Array( valueSize * 5 ); - this.buffer = new bufferType( valueSize * 4 ); - // layout: [ incoming | accu0 | accu1 | orig ] - // - // interpolators can use .buffer as their .result - // the data then goes to 'incoming' - // - // 'accu0' and 'accu1' are used frame-interleaved for - // the cumulative result and are compared to detect - // changes - // - // 'orig' stores the original state of the property + } this._mixBufferRegion = mixFunction; + this._mixBufferRegionAdditive = mixFunctionAdditive; + this._setIdentity = setIdentity; + this._origIndex = 3; + this._addIndex = 4; this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; this.useCount = 0; this.referenceCount = 0; @@ -42581,6 +43109,28 @@ }, + // accumulate data in the 'incoming' region into 'add' + accumulateAdditive: function ( weight ) { + + var buffer = this.buffer, + stride = this.valueSize, + offset = stride * this._addIndex; + + if ( this.cumulativeWeightAdditive === 0 ) { + + // add = identity + + this._setIdentity(); + + } + + // add := add + incoming * weight + + this._mixBufferRegionAdditive( buffer, offset, 0, weight, stride ); + this.cumulativeWeightAdditive += weight; + + }, + // apply the state of 'accu' to the binding when accus differ apply: function ( accuIndex ) { @@ -42589,22 +43139,32 @@ offset = accuIndex * stride + stride, weight = this.cumulativeWeight, + weightAdditive = this.cumulativeWeightAdditive, binding = this.binding; this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; if ( weight < 1 ) { // accuN := accuN + original * ( 1 - cumulativeWeight ) - var originalValueOffset = stride * 3; + var originalValueOffset = stride * this._origIndex; this._mixBufferRegion( buffer, offset, originalValueOffset, 1 - weight, stride ); } + if ( weightAdditive > 0 ) { + + // accuN := accuN + additive accuN + + this._mixBufferRegionAdditive( buffer, offset, this._addIndex * stride, 1, stride ); + + } + for ( var i = stride, e = stride + stride; i !== e; ++ i ) { if ( buffer[ i ] !== buffer[ i + stride ] ) { @@ -42628,7 +43188,7 @@ var buffer = this.buffer, stride = this.valueSize, - originalValueOffset = stride * 3; + originalValueOffset = stride * this._origIndex; binding.getValue( buffer, originalValueOffset ); @@ -42639,7 +43199,11 @@ } + // Add to identity for additive + this._setIdentity(); + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; }, @@ -42651,6 +43215,30 @@ }, + _setAdditiveIdentityNumeric: function () { + + var startIndex = this._addIndex * this.valueSize; + + this.buffer.fill( 0, startIndex, startIndex + this.valueSize ); + + }, + + _setAdditiveIdentityQuaternion: function () { + + this._setAdditiveIdentityNumeric(); + this.buffer[ this._addIndex * 4 + 3 ] = 1; + + }, + + _setAdditiveIdentityOther: function () { + + var startIndex = this._origIndex * this.valueSize; + var targetIndex = this._addIndex * this.valueSize; + + this.buffer.copyWithin( targetIndex, startIndex, this.valueSize ); + + }, + // mix functions @@ -42674,6 +43262,18 @@ }, + _slerpAdditive: function ( buffer, dstOffset, srcOffset, t, stride ) { + + var workOffset = this._workIndex * stride; + + // Store result in intermediate buffer offset + Quaternion.multiplyQuaternionsFlat( buffer, workOffset, buffer, dstOffset, buffer, srcOffset ); + + // Slerp to the intermediate result + Quaternion.slerpFlat( buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t ); + + }, + _lerp: function ( buffer, dstOffset, srcOffset, t, stride ) { var s = 1 - t; @@ -42686,6 +43286,18 @@ } + }, + + _lerpAdditive: function ( buffer, dstOffset, srcOffset, t, stride ) { + + for ( var i = 0; i !== stride; ++ i ) { + + var j = dstOffset + i; + + buffer[ j ] = buffer[ j ] + buffer[ srcOffset + i ] * t; + + } + } } ); @@ -42890,7 +43502,7 @@ findNode: function ( root, nodeName ) { - if ( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { + if ( ! nodeName || nodeName === "" || nodeName === "." || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { return root; @@ -43394,7 +44006,7 @@ } ); - //!\ DECLARE ALIAS AFTER assign prototype ! + // DECLARE ALIAS AFTER assign prototype Object.assign( PropertyBinding.prototype, { // initial state of these methods that calls 'bind' @@ -43436,7 +44048,7 @@ function AnimationObjectGroup() { - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); // cached objects followed by the active ones this._objects = Array.prototype.slice.call( arguments ); @@ -43790,11 +44402,12 @@ * */ - function AnimationAction( mixer, clip, localRoot ) { + function AnimationAction( mixer, clip, localRoot, blendMode ) { this._mixer = mixer; this._clip = clip; this._localRoot = localRoot || null; + this.blendMode = blendMode || clip.blendMode; var tracks = clip.tracks, nTracks = tracks.length, @@ -44153,10 +44766,28 @@ var interpolants = this._interpolants; var propertyMixers = this._propertyBindings; - for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + switch ( this.blendMode ) { + + case AdditiveAnimationBlendMode: - interpolants[ j ].evaluate( clipTime ); - propertyMixers[ j ].accumulate( accuIndex, weight ); + for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulateAdditive( weight ); + + } + + break; + + case NormalAnimationBlendMode: + default: + + for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulate( accuIndex, weight ); + + } } @@ -44974,7 +45605,7 @@ // return an action for a clip optionally using a custom root target // object (this method allocates a lot of dynamic memory in case a // previously unknown clip/root combination is specified) - clipAction: function ( clip, optionalRoot ) { + clipAction: function ( clip, optionalRoot, blendMode ) { var root = optionalRoot || this._root, rootUuid = root.uuid, @@ -44987,12 +45618,26 @@ actionsForClip = this._actionsByClip[ clipUuid ], prototypeAction = null; + if ( blendMode === undefined ) { + + if ( clipObject !== null ) { + + blendMode = clipObject.blendMode; + + } else { + + blendMode = NormalAnimationBlendMode; + + } + + } + if ( actionsForClip !== undefined ) { var existingAction = actionsForClip.actionByRoot[ rootUuid ]; - if ( existingAction !== undefined ) { + if ( existingAction !== undefined && existingAction.blendMode === blendMode ) { return existingAction; @@ -45012,7 +45657,7 @@ if ( clipObject === null ) { return null; } // allocate all resources required to run it - var newAction = new AnimationAction( this, clipObject, optionalRoot ); + var newAction = new AnimationAction( this, clipObject, optionalRoot, blendMode ); this._bindAction( newAction, prototypeAction ); @@ -45294,10 +45939,11 @@ this.near = near || 0; this.far = far || Infinity; this.camera = null; + this.layers = new Layers(); this.params = { Mesh: {}, - Line: {}, + Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} @@ -45324,9 +45970,11 @@ function intersectObject( object, raycaster, intersects, recursive ) { - if ( object.visible === false ) { return; } + if ( object.layers.test( raycaster.layers ) ) { - object.raycast( raycaster, intersects ); + object.raycast( raycaster, intersects ); + + } if ( recursive === true ) { @@ -45344,8 +45992,6 @@ Object.assign( Raycaster.prototype, { - linePrecision: 1, - set: function ( origin, direction ) { // direction is assumed to be normalized (for accurate distance calculations) @@ -45489,7 +46135,7 @@ } else { this.theta = Math.atan2( x, z ); - this.phi = Math.acos( _Math.clamp( y / this.radius, - 1, 1 ) ); + this.phi = Math.acos( MathUtils.clamp( y / this.radius, - 1, 1 ) ); } @@ -45566,7 +46212,7 @@ * @author bhouston / http://clara.io */ - var _vector$8 = new Vector2(); + var _vector$7 = new Vector2(); function Box2( min, max ) { @@ -45602,7 +46248,7 @@ setFromCenterAndSize: function ( center, size ) { - var halfSize = _vector$8.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$7.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -45752,7 +46398,7 @@ distanceToPoint: function ( point ) { - var clampedPoint = _vector$8.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$7.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); }, @@ -45895,7 +46541,7 @@ if ( clampToLine ) { - t = _Math.clamp( t, 0, 1 ); + t = MathUtils.clamp( t, 0, 1 ); } @@ -45959,7 +46605,7 @@ * @author WestLangley / http://github.com/WestLangley */ - var _vector$9 = new Vector3(); + var _vector$8 = new Vector3(); function SpotLightHelper( light, color ) { @@ -45997,7 +46643,7 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); - var material = new LineBasicMaterial( { fog: false } ); + var material = new LineBasicMaterial( { fog: false, toneMapped: false } ); this.cone = new LineSegments( geometry, material ); this.add( this.cone ); @@ -46025,9 +46671,9 @@ this.cone.scale.set( coneWidth, coneWidth, coneLength ); - _vector$9.setFromMatrixPosition( this.light.target.matrixWorld ); + _vector$8.setFromMatrixPosition( this.light.target.matrixWorld ); - this.cone.lookAt( _vector$9 ); + this.cone.lookAt( _vector$8 ); if ( this.color !== undefined ) { @@ -46049,7 +46695,7 @@ * @author Mugen87 / https://github.com/Mugen87 */ - var _vector$a = new Vector3(); + var _vector$9 = new Vector3(); var _boneMatrix = new Matrix4(); var _matrixWorldInv = new Matrix4(); @@ -46103,10 +46749,12 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } ); + var material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } ); LineSegments.call( this, geometry, material ); + this.type = 'SkeletonHelper'; + this.root = object; this.bones = bones; @@ -46118,6 +46766,8 @@ SkeletonHelper.prototype = Object.create( LineSegments.prototype ); SkeletonHelper.prototype.constructor = SkeletonHelper; + SkeletonHelper.prototype.isSkeletonHelper = true; + SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { var bones = this.bones; @@ -46134,12 +46784,12 @@ if ( bone.parent && bone.parent.isBone ) { _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld ); - _vector$a.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j, _vector$a.x, _vector$a.y, _vector$a.z ); + _vector$9.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j, _vector$9.x, _vector$9.y, _vector$9.z ); _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld ); - _vector$a.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j + 1, _vector$a.x, _vector$a.y, _vector$a.z ); + _vector$9.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j + 1, _vector$9.x, _vector$9.y, _vector$9.z ); j += 2; @@ -46166,10 +46816,12 @@ this.color = color; var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); - var material = new MeshBasicMaterial( { wireframe: true, fog: false } ); + var material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); Mesh.call( this, geometry, material ); + this.type = 'PointLightHelper'; + this.matrix = this.light.matrixWorld; this.matrixAutoUpdate = false; @@ -46245,7 +46897,7 @@ * @author Mugen87 / https://github.com/Mugen87 */ - var _vector$b = new Vector3(); + var _vector$a = new Vector3(); var _color1 = new Color(); var _color2 = new Color(); @@ -46264,8 +46916,8 @@ var geometry = new OctahedronBufferGeometry( size ); geometry.rotateY( Math.PI * 0.5 ); - this.material = new MeshBasicMaterial( { wireframe: true, fog: false } ); - if ( this.color === undefined ) { this.material.vertexColors = VertexColors; } + this.material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); + if ( this.color === undefined ) { this.material.vertexColors = true; } var position = geometry.getAttribute( 'position' ); var colors = new Float32Array( position.count * 3 ); @@ -46315,7 +46967,7 @@ } - mesh.lookAt( _vector$b.setFromMatrixPosition( this.light.matrixWorld ).negate() ); + mesh.lookAt( _vector$a.setFromMatrixPosition( this.light.matrixWorld ).negate() ); }; @@ -46354,10 +47006,12 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'GridHelper'; + } GridHelper.prototype = Object.assign( Object.create( LineSegments.prototype ), { @@ -46461,10 +47115,12 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'PolarGridHelper'; + } PolarGridHelper.prototype = Object.create( LineSegments.prototype ); @@ -46503,7 +47159,7 @@ - size, size, 0 ], 3 ) ); - var material = new LineBasicMaterial( { fog: false } ); + var material = new LineBasicMaterial( { fog: false, toneMapped: false } ); this.lightPlane = new Line( geometry, material ); this.add( this.lightPlane ); @@ -46565,13 +47221,13 @@ * http://evanw.github.com/lightgl.js/tests/shadowmap.html */ - var _vector$c = new Vector3(); + var _vector$b = new Vector3(); var _camera = new Camera(); function CameraHelper( camera ) { var geometry = new BufferGeometry(); - var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } ); + var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } ); var vertices = []; var colors = []; @@ -46660,6 +47316,8 @@ LineSegments.call( this, geometry, material ); + this.type = 'CameraHelper'; + this.camera = camera; if ( this.camera.updateProjectionMatrix ) { this.camera.updateProjectionMatrix(); } @@ -46730,7 +47388,7 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) { - _vector$c.set( x, y, z ).unproject( camera ); + _vector$b.set( x, y, z ).unproject( camera ); var points = pointMap[ point ]; @@ -46740,7 +47398,7 @@ for ( var i = 0, l = points.length; i < l; i ++ ) { - position.setXYZ( points[ i ], _vector$c.x, _vector$c.y, _vector$c.z ); + position.setXYZ( points[ i ], _vector$b.x, _vector$b.y, _vector$b.z ); } @@ -46768,7 +47426,9 @@ geometry.setIndex( new BufferAttribute( indices, 1 ) ); geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) ); - LineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + LineSegments.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'BoxHelper'; this.matrixAutoUpdate = false; @@ -46880,7 +47540,9 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); - LineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + LineSegments.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'Box3Helper'; this.geometry.computeBoundingSphere(); @@ -46911,8 +47573,6 @@ function PlaneHelper( plane, size, hex ) { - this.type = 'PlaneHelper'; - this.plane = plane; this.size = ( size === undefined ) ? 1 : size; @@ -46925,7 +47585,9 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); geometry.computeBoundingSphere(); - Line.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + Line.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'PlaneHelper'; // @@ -46935,7 +47597,7 @@ geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); geometry2.computeBoundingSphere(); - this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false } ) ) ); + this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false } ) ) ); } @@ -46983,6 +47645,8 @@ Object3D.call( this ); + this.type = 'ArrowHelper'; + if ( dir === undefined ) { dir = new Vector3( 0, 0, 1 ); } if ( origin === undefined ) { origin = new Vector3( 0, 0, 0 ); } if ( length === undefined ) { length = 1; } @@ -47002,11 +47666,11 @@ this.position.copy( origin ); - this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color } ) ); + this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); this.line.matrixAutoUpdate = false; this.add( this.line ); - this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color } ) ); + this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color, toneMapped: false } ) ); this.cone.matrixAutoUpdate = false; this.add( this.cone ); @@ -47105,10 +47769,12 @@ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'AxesHelper'; + } AxesHelper.prototype = Object.create( LineSegments.prototype ); @@ -47131,15 +47797,19 @@ var LOD_MIN = 4; var LOD_MAX = 8; var SIZE_MAX = Math.pow( 2, LOD_MAX ); + // The standard deviations (radians) associated with the extra mips. These are // chosen to approximate a Trowbridge-Reitz distribution function times the // geometric shadowing function. These sigma values squared must match the // variance #defines in cube_uv_reflection_fragment.glsl.js. var EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ]; + var TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; + // The maximum length of the blur for loop. Smaller sigmas will use fewer // samples and exit early, but not recompile the shader. var MAX_SAMPLES = 20; + var ENCODINGS = {}; ENCODINGS[ LinearEncoding ] = 0; ENCODINGS[ sRGBEncoding ] = 1; @@ -47150,20 +47820,16 @@ ENCODINGS[ GammaEncoding ] = 6; var _flatCamera = new OrthographicCamera(); - var _blurMaterial = _getBlurShader( MAX_SAMPLES ); - var _equirectShader = null; - var _cubemapShader = null; - var ref = _createPlanes(); var _lodPlanes = ref._lodPlanes; var _sizeLods = ref._sizeLods; var _sigmas = ref._sigmas; - var _pingPongRenderTarget = null; - var _renderer = null; + var _oldTarget = null; // Golden Ratio var PHI = ( 1 + Math.sqrt( 5 ) ) / 2; var INV_PHI = 1 / PHI; + // Vertices of a dodecahedron (except the opposites, which represent the // same axis), used as axis directions evenly spread on a sphere. var _axisDirections = [ @@ -47180,8 +47846,14 @@ function PMREMGenerator( renderer ) { - _renderer = renderer; - _compileMaterial( _blurMaterial ); + this._renderer = renderer; + this._pingPongRenderTarget = null; + + this._blurMaterial = _getBlurShader( MAX_SAMPLES ); + this._equirectShader = null; + this._cubemapShader = null; + + this._compileMaterial( this._blurMaterial ); } @@ -47202,16 +47874,18 @@ if ( far === void 0 ) far = 100; - var cubeUVRenderTarget = _allocateTargets(); - _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); + _oldTarget = this._renderer.getRenderTarget(); + var cubeUVRenderTarget = this._allocateTargets(); + + this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); if ( sigma > 0 ) { - _blur( cubeUVRenderTarget, 0, 0, sigma ); + this._blur( cubeUVRenderTarget, 0, 0, sigma ); } - _applyPMREM( cubeUVRenderTarget ); - _cleanup(); - cubeUVRenderTarget.scissorTest = false; + + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); return cubeUVRenderTarget; @@ -47239,11 +47913,11 @@ */ fromCubemap: function ( cubemap ) { - var cubeUVRenderTarget = _allocateTargets( cubemap ); - _textureToCubeUV( cubemap, cubeUVRenderTarget ); - _applyPMREM( cubeUVRenderTarget ); - _cleanup(); - cubeUVRenderTarget.scissorTest = false; + _oldTarget = this._renderer.getRenderTarget(); + var cubeUVRenderTarget = this._allocateTargets( cubemap ); + this._textureToCubeUV( cubemap, cubeUVRenderTarget ); + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); return cubeUVRenderTarget; @@ -47255,10 +47929,10 @@ */ compileCubemapShader: function () { - if ( _cubemapShader == null ) { + if ( this._cubemapShader === null ) { - _cubemapShader = _getCubemapShader(); - _compileMaterial( _cubemapShader ); + this._cubemapShader = _getCubemapShader(); + this._compileMaterial( this._cubemapShader ); } @@ -47270,10 +47944,10 @@ */ compileEquirectangularShader: function () { - if ( _equirectShader == null ) { + if ( this._equirectShader === null ) { - _equirectShader = _getEquirectShader(); - _compileMaterial( _equirectShader ); + this._equirectShader = _getEquirectShader(); + this._compileMaterial( this._equirectShader ); } @@ -47286,10 +47960,10 @@ */ dispose: function () { - _blurMaterial.dispose(); + this._blurMaterial.dispose(); - if ( _cubemapShader != null ) { _cubemapShader.dispose(); } - if ( _equirectShader != null ) { _equirectShader.dispose(); } + if ( this._cubemapShader !== null ) { this._cubemapShader.dispose(); } + if ( this._equirectShader !== null ) { this._equirectShader.dispose(); } for ( var i = 0; i < _lodPlanes.length; i ++ ) { @@ -47299,371 +47973,397 @@ }, - }; + // private interface - function _createPlanes() { + _cleanup: function ( outputTarget ) { - var _lodPlanes = []; - var _sizeLods = []; - var _sigmas = []; + this._pingPongRenderTarget.dispose(); + this._renderer.setRenderTarget( _oldTarget ); + outputTarget.scissorTest = false; + // reset viewport and scissor + outputTarget.setSize( outputTarget.width, outputTarget.height ); - var lod = LOD_MAX; - for ( var i = 0; i < TOTAL_LODS; i ++ ) { + }, - var sizeLod = Math.pow( 2, lod ); - _sizeLods.push( sizeLod ); - var sigma = 1.0 / sizeLod; - if ( i > LOD_MAX - LOD_MIN ) { + _allocateTargets: function ( equirectangular ) { - sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; + var params = { + magFilter: NearestFilter, + minFilter: NearestFilter, + generateMipmaps: false, + type: UnsignedByteType, + format: RGBEFormat, + encoding: _isLDR( equirectangular ) ? equirectangular.encoding : RGBEEncoding, + depthBuffer: false, + stencilBuffer: false + }; - } else if ( i == 0 ) { + var cubeUVRenderTarget = _createRenderTarget( params ); + cubeUVRenderTarget.depthBuffer = equirectangular ? false : true; + this._pingPongRenderTarget = _createRenderTarget( params ); + return cubeUVRenderTarget; - sigma = 0; + }, - } - _sigmas.push( sigma ); + _compileMaterial: function ( material ) { - var texelSize = 1.0 / ( sizeLod - 1 ); - var min = - texelSize / 2; - var max = 1 + texelSize / 2; - var uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; + var tmpScene = new Scene(); + tmpScene.add( new Mesh( _lodPlanes[ 0 ], material ) ); + this._renderer.compile( tmpScene, _flatCamera ); - var cubeFaces = 6; - var vertices = 6; - var positionSize = 3; - var uvSize = 2; - var faceIndexSize = 1; + }, - var position = new Float32Array( positionSize * vertices * cubeFaces ); - var uv = new Float32Array( uvSize * vertices * cubeFaces ); - var faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); + _sceneToCubeUV: function ( scene, near, far, cubeUVRenderTarget ) { - for ( var face = 0; face < cubeFaces; face ++ ) { + var fov = 90; + var aspect = 1; + var cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); + var upSign = [ 1, 1, 1, 1, - 1, 1 ]; + var forwardSign = [ 1, 1, - 1, - 1, - 1, 1 ]; + var renderer = this._renderer; - var x = ( face % 3 ) * 2 / 3 - 1; - var y = face > 2 ? 0 : - 1; - var coordinates = [ - x, y, 0, - x + 2 / 3, y, 0, - x + 2 / 3, y + 1, 0, - x, y, 0, - x + 2 / 3, y + 1, 0, - x, y + 1, 0 - ]; - position.set( coordinates, positionSize * vertices * face ); - uv.set( uv1, uvSize * vertices * face ); - var fill = [ face, face, face, face, face, face ]; - faceIndex.set( fill, faceIndexSize * vertices * face ); + var outputEncoding = renderer.outputEncoding; + var toneMapping = renderer.toneMapping; + var toneMappingExposure = renderer.toneMappingExposure; + var clearColor = renderer.getClearColor(); + var clearAlpha = renderer.getClearAlpha(); + + renderer.toneMapping = LinearToneMapping; + renderer.toneMappingExposure = 1.0; + renderer.outputEncoding = LinearEncoding; + scene.scale.z *= - 1; + + var background = scene.background; + if ( background && background.isColor ) { + + background.convertSRGBToLinear(); + // Convert linear to RGBE + var maxComponent = Math.max( background.r, background.g, background.b ); + var fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 ); + background = background.multiplyScalar( Math.pow( 2.0, - fExp ) ); + var alpha = ( fExp + 128.0 ) / 255.0; + renderer.setClearColor( background, alpha ); + scene.background = null; } - var planes = new BufferGeometry(); - planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); - planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); - planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); - _lodPlanes.push( planes ); - if ( lod > LOD_MIN ) { + for ( var i = 0; i < 6; i ++ ) { - lod --; + var col = i % 3; + if ( col == 0 ) { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + + } else if ( col == 1 ) { + + cubeCamera.up.set( 0, 0, upSign[ i ] ); + cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + + } else { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + + } + + _setViewport( cubeUVRenderTarget, + col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( scene, cubeCamera ); } - } - return { _lodPlanes: _lodPlanes, _sizeLods: _sizeLods, _sigmas: _sigmas }; + renderer.toneMapping = toneMapping; + renderer.toneMappingExposure = toneMappingExposure; + renderer.outputEncoding = outputEncoding; + renderer.setClearColor( clearColor, clearAlpha ); + scene.scale.z *= - 1; - } + }, - function _allocateTargets( equirectangular ) { + _textureToCubeUV: function ( texture, cubeUVRenderTarget ) { - var params = { - magFilter: NearestFilter, - minFilter: NearestFilter, - generateMipmaps: false, - type: equirectangular ? equirectangular.type : UnsignedByteType, - format: equirectangular ? equirectangular.format : RGBEFormat, - encoding: equirectangular ? equirectangular.encoding : RGBEEncoding, - depthBuffer: false, - stencilBuffer: false - }; - var cubeUVRenderTarget = _createRenderTarget( params ); - cubeUVRenderTarget.depthBuffer = equirectangular ? false : true; - _pingPongRenderTarget = _createRenderTarget( params ); - return cubeUVRenderTarget; + var scene = new Scene(); + var renderer = this._renderer; - } + if ( texture.isCubeTexture ) { - function _cleanup() { + if ( this._cubemapShader == null ) { - _pingPongRenderTarget.dispose(); - _renderer.setRenderTarget( null ); - var size = _renderer.getSize( new Vector2() ); - _renderer.setViewport( 0, 0, size.x, size.y ); + this._cubemapShader = _getCubemapShader(); - } + } + + } else { + + if ( this._equirectShader == null ) { - function _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ) { + this._equirectShader = _getEquirectShader(); - var fov = 90; - var aspect = 1; - var cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); - var upSign = [ 1, 1, 1, 1, - 1, 1 ]; - var forwardSign = [ 1, 1, - 1, - 1, - 1, 1 ]; + } + + } - var outputEncoding = _renderer.outputEncoding; - var toneMapping = _renderer.toneMapping; - var toneMappingExposure = _renderer.toneMappingExposure; - var clearColor = _renderer.getClearColor(); - var clearAlpha = _renderer.getClearAlpha(); + var material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader; + scene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - _renderer.toneMapping = LinearToneMapping; - _renderer.toneMappingExposure = 1.0; - _renderer.outputEncoding = LinearEncoding; - scene.scale.z *= - 1; + var uniforms = material.uniforms; - var background = scene.background; - if ( background && background.isColor ) { + uniforms[ 'envMap' ].value = texture; - background.convertSRGBToLinear(); - // Convert linear to RGBE - var maxComponent = Math.max( background.r, background.g, background.b ); - var fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 ); - background = background.multiplyScalar( Math.pow( 2.0, - fExp ) ); - var alpha = ( fExp + 128.0 ) / 255.0; - _renderer.setClearColor( background, alpha ); - scene.background = null; + if ( ! texture.isCubeTexture ) { - } + uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); - _renderer.setRenderTarget( cubeUVRenderTarget ); - for ( var i = 0; i < 6; i ++ ) { + } + + uniforms[ 'inputEncoding' ].value = ENCODINGS[ texture.encoding ]; + uniforms[ 'outputEncoding' ].value = ENCODINGS[ cubeUVRenderTarget.texture.encoding ]; - var col = i % 3; - if ( col == 0 ) { + _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); - cubeCamera.up.set( 0, upSign[ i ], 0 ); - cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( scene, _flatCamera ); - } else if ( col == 1 ) { + }, - cubeCamera.up.set( 0, 0, upSign[ i ] ); - cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + _applyPMREM: function ( cubeUVRenderTarget ) { - } else { + var renderer = this._renderer; + var autoClear = renderer.autoClear; + renderer.autoClear = false; - cubeCamera.up.set( 0, upSign[ i ], 0 ); - cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + for ( var i = 1; i < TOTAL_LODS; i ++ ) { + + var sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); + + var poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ]; + + this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); } - _setViewport( - col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); - _renderer.render( scene, cubeCamera ); - } + renderer.autoClear = autoClear; - _renderer.toneMapping = toneMapping; - _renderer.toneMappingExposure = toneMappingExposure; - _renderer.outputEncoding = outputEncoding; - _renderer.setClearColor( clearColor, clearAlpha ); - scene.scale.z *= - 1; + }, - } + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur: function ( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { - function _textureToCubeUV( texture, cubeUVRenderTarget ) { + var pingPongRenderTarget = this._pingPongRenderTarget; - var scene = new Scene(); - if ( texture.isCubeTexture ) { + this._halfBlur( + cubeUVRenderTarget, + pingPongRenderTarget, + lodIn, + lodOut, + sigma, + 'latitudinal', + poleAxis ); + + this._halfBlur( + pingPongRenderTarget, + cubeUVRenderTarget, + lodOut, + lodOut, + sigma, + 'longitudinal', + poleAxis ); + + }, - if ( _cubemapShader == null ) { + _halfBlur: function ( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { - _cubemapShader = _getCubemapShader(); + var renderer = this._renderer; + var blurMaterial = this._blurMaterial; + + if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { + + console.error( + 'blur direction must be either latitudinal or longitudinal!' ); } - } else { + // Number of standard deviations at which to cut off the discrete approximation. + var STANDARD_DEVIATIONS = 3; + + var blurScene = new Scene(); + blurScene.add( new Mesh( _lodPlanes[ lodOut ], blurMaterial ) ); + var blurUniforms = blurMaterial.uniforms; - if ( _equirectShader == null ) { + var pixels = _sizeLods[ lodIn ] - 1; + var radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); + var sigmaPixels = sigmaRadians / radiansPerPixel; + var samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; - _equirectShader = _getEquirectShader(); + if ( samples > MAX_SAMPLES ) { + + console.warn( ("sigmaRadians, " + sigmaRadians + ", is too large and will clip, as it requested " + samples + " samples when the maximum is set to " + MAX_SAMPLES) ); } - } - var material = texture.isCubeTexture ? _cubemapShader : _equirectShader; - scene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - var uniforms = material.uniforms; + var weights = []; + var sum = 0; - uniforms[ 'envMap' ].value = texture; - if ( ! texture.isCubeTexture ) { + for ( var i = 0; i < MAX_SAMPLES; ++ i ) { - uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); + var x = i / sigmaPixels; + var weight = Math.exp( - x * x / 2 ); + weights.push( weight ); - } - uniforms[ 'inputEncoding' ].value = ENCODINGS[ texture.encoding ]; - uniforms[ 'outputEncoding' ].value = ENCODINGS[ texture.encoding ]; + if ( i == 0 ) { - _renderer.setRenderTarget( cubeUVRenderTarget ); - _setViewport( 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); - _renderer.render( scene, _flatCamera ); + sum += weight; - } + } else if ( i < samples ) { - function _compileMaterial( material ) { + sum += 2 * weight; - var tmpScene = new Scene(); - tmpScene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - _renderer.compile( tmpScene, _flatCamera ); + } - } + } - function _createRenderTarget( params ) { + for ( var i = 0; i < weights.length; i ++ ) { - var cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); - cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; - cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; - cubeUVRenderTarget.scissorTest = true; - return cubeUVRenderTarget; + weights[ i ] = weights[ i ] / sum; - } + } - function _setViewport( x, y, width, height ) { + blurUniforms[ 'envMap' ].value = targetIn.texture; + blurUniforms[ 'samples' ].value = samples; + blurUniforms[ 'weights' ].value = weights; + blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; - var invDpr = 1.0 / _renderer.getPixelRatio(); - x *= invDpr; - y *= invDpr; - width *= invDpr; - height *= invDpr; - _renderer.setViewport( x, y, width, height ); - _renderer.setScissor( x, y, width, height ); + if ( poleAxis ) { - } + blurUniforms[ 'poleAxis' ].value = poleAxis; - function _applyPMREM( cubeUVRenderTarget ) { + } - var autoClear = _renderer.autoClear; - _renderer.autoClear = false; + blurUniforms[ 'dTheta' ].value = radiansPerPixel; + blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; + blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; + blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; - for ( var i = 1; i < TOTAL_LODS; i ++ ) { + var outputSize = _sizeLods[ lodOut ]; + var x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); + var y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); - var sigma = Math.sqrt( - _sigmas[ i ] * _sigmas[ i ] - - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); - var poleAxis = - _axisDirections[ ( i - 1 ) % _axisDirections.length ]; - _blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); + _setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize ); + renderer.setRenderTarget( targetOut ); + renderer.render( blurScene, _flatCamera ); } - _renderer.autoClear = autoClear; - - } + }; - /** - * This is a two-pass Gaussian blur for a cubemap. Normally this is done - * vertically and horizontally, but this breaks down on a cube. Here we apply - * the blur latitudinally (around the poles), and then longitudinally (towards - * the poles) to approximate the orthogonally-separable blur. It is least - * accurate at the poles, but still does a decent job. - */ - function _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { + function _isLDR( texture ) { - _halfBlur( - cubeUVRenderTarget, - _pingPongRenderTarget, - lodIn, - lodOut, - sigma, - 'latitudinal', - poleAxis ); + if ( texture === undefined || texture.type !== UnsignedByteType ) { return false; } - _halfBlur( - _pingPongRenderTarget, - cubeUVRenderTarget, - lodOut, - lodOut, - sigma, - 'longitudinal', - poleAxis ); + return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding; } - function _halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { - - if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { + function _createPlanes() { - console.error( - 'blur direction must be either latitudinal or longitudinal!' ); + var _lodPlanes = []; + var _sizeLods = []; + var _sigmas = []; - } + var lod = LOD_MAX; - // Number of standard deviations at which to cut off the discrete approximation. - var STANDARD_DEVIATIONS = 3; + for ( var i = 0; i < TOTAL_LODS; i ++ ) { - var blurScene = new Scene(); - blurScene.add( new Mesh( _lodPlanes[ lodOut ], _blurMaterial ) ); - var blurUniforms = _blurMaterial.uniforms; + var sizeLod = Math.pow( 2, lod ); + _sizeLods.push( sizeLod ); + var sigma = 1.0 / sizeLod; - var pixels = _sizeLods[ lodIn ] - 1; - var radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); - var sigmaPixels = sigmaRadians / radiansPerPixel; - var samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; + if ( i > LOD_MAX - LOD_MIN ) { - if ( samples > MAX_SAMPLES ) { + sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; - console.warn( ("sigmaRadians, " + sigmaRadians + ", is too large and will clip, as it requested " + samples + " samples when the maximum is set to " + MAX_SAMPLES) ); + } else if ( i == 0 ) { - } + sigma = 0; - var weights = []; - var sum = 0; + } - for ( var i = 0; i < MAX_SAMPLES; ++ i ) { + _sigmas.push( sigma ); - var x = i / sigmaPixels; - var weight = Math.exp( - x * x / 2 ); - weights.push( weight ); + var texelSize = 1.0 / ( sizeLod - 1 ); + var min = - texelSize / 2; + var max = 1 + texelSize / 2; + var uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; - if ( i == 0 ) { + var cubeFaces = 6; + var vertices = 6; + var positionSize = 3; + var uvSize = 2; + var faceIndexSize = 1; - sum += weight; + var position = new Float32Array( positionSize * vertices * cubeFaces ); + var uv = new Float32Array( uvSize * vertices * cubeFaces ); + var faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); - } else if ( i < samples ) { + for ( var face = 0; face < cubeFaces; face ++ ) { - sum += 2 * weight; + var x = ( face % 3 ) * 2 / 3 - 1; + var y = face > 2 ? 0 : - 1; + var coordinates = [ + x, y, 0, + x + 2 / 3, y, 0, + x + 2 / 3, y + 1, 0, + x, y, 0, + x + 2 / 3, y + 1, 0, + x, y + 1, 0 + ]; + position.set( coordinates, positionSize * vertices * face ); + uv.set( uv1, uvSize * vertices * face ); + var fill = [ face, face, face, face, face, face ]; + faceIndex.set( fill, faceIndexSize * vertices * face ); } - } + var planes = new BufferGeometry(); + planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); + planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); + planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); + _lodPlanes.push( planes ); + + if ( lod > LOD_MIN ) { - for ( var i = 0; i < weights.length; i ++ ) { + lod --; - weights[ i ] = weights[ i ] / sum; + } } - blurUniforms[ 'envMap' ].value = targetIn.texture; - blurUniforms[ 'samples' ].value = samples; - blurUniforms[ 'weights' ].value = weights; - blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; - if ( poleAxis ) { + return { _lodPlanes: _lodPlanes, _sizeLods: _sizeLods, _sigmas: _sigmas }; - blurUniforms[ 'poleAxis' ].value = poleAxis; + } - } - blurUniforms[ 'dTheta' ].value = radiansPerPixel; - blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; - blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; - blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; + function _createRenderTarget( params ) { + + var cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); + cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; + cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; + cubeUVRenderTarget.scissorTest = true; + return cubeUVRenderTarget; - var outputSize = _sizeLods[ lodOut ]; - var x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); - var y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + - 2 * outputSize * - ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); + } - _renderer.setRenderTarget( targetOut ); - _setViewport( x, y, 3 * outputSize, 2 * outputSize ); - _renderer.render( blurScene, _flatCamera ); + function _setViewport( target, x, y, width, height ) { + + target.viewport.set( x, y, width, height ); + target.scissor.set( x, y, width, height ); } @@ -47689,7 +48389,7 @@ vertexShader: _getCommonVertexShader(), - fragmentShader: ("\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n" + (_getEncodings()) + "\n\n#define ENVMAP_TYPE_CUBE_UV\n#include \n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfor (int dir = -1; dir < 2; dir += 2) {\n\t\t\tif (i == 0 && dir == 1)\n\t\t\t\tcontinue;\n\t\t\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\t\t\tif (all(equal(axis, vec3(0.0))))\n\t\t\t\taxis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);\n\t\t\taxis = normalize(axis);\n\t\t\tfloat theta = dTheta * float(dir * i);\n\t\t\tfloat cosTheta = cos(theta);\n\t\t\t// Rodrigues' axis-angle rotation\n\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t\t\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\t\t\tgl_FragColor.rgb +=\n\t\t\t\t\tweights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);\n\t\t}\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"), + fragmentShader: ("\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n" + (_getEncodings()) + "\n\n#define ENVMAP_TYPE_CUBE_UV\n#include \n\nvec3 getSample(float theta, vec3 axis) {\n\tfloat cosTheta = cos(theta);\n\t// Rodrigues' axis-angle rotation\n\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\treturn bilinearCubeUV(envMap, sampleDirection, mipInt);\n}\n\nvoid main() {\n\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\tif (all(equal(axis, vec3(0.0))))\n\t\taxis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\taxis = normalize(axis);\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\tfor (int i = 1; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfloat theta = dTheta * float(i);\n\t\tgl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n\t\tgl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"), blending: NoBlending, depthTest: false, @@ -47781,8 +48481,10 @@ } var LineStrip = 0; - var LinePieces = 1; + var NoColors = 0; + var FaceColors = 1; + var VertexColors = 2; function MeshFaceMaterial( materials ) { @@ -47803,6 +48505,7 @@ return materials.slice(); }; + return materials; } @@ -47860,8 +48563,8 @@ function DynamicBufferAttribute( array, itemSize ) { - console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' ); - return new BufferAttribute( array, itemSize ).setDynamic( true ); + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.' ); + return new BufferAttribute( array, itemSize ).setUsage( DynamicDrawUsage ); } @@ -48220,6 +48923,24 @@ } } ); + Object.assign( Sphere.prototype, { + + empty: function () { + + console.warn( 'THREE.Sphere: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + + }, + + } ); + + Frustum.prototype.setFromMatrix = function ( m ) { + + console.warn( 'THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().' ); + return this.setFromProjectionMatrix( m ); + + }; + Line3.prototype.center = function ( optionalTarget ) { console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); @@ -48227,7 +48948,7 @@ }; - Object.assign( _Math, { + Object.assign( MathUtils, { random16: function () { @@ -48239,14 +48960,14 @@ nearestPowerOfTwo: function ( value ) { console.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' ); - return _Math.floorPowerOfTwo( value ); + return MathUtils.floorPowerOfTwo( value ); }, nextPowerOfTwo: function ( value ) { console.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' ); - return _Math.ceilPowerOfTwo( value ); + return MathUtils.ceilPowerOfTwo( value ); } @@ -48271,10 +48992,10 @@ console.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' ); }, - applyToBuffer: function ( buffer /*, offset, length */ ) { + applyToBufferAttribute: function ( attribute ) { - console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); - return this.applyToBufferAttribute( buffer ); + console.warn( 'THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.' ); + return attribute.applyMatrix3( this ); }, applyToVector3Array: function ( /* array, offset, length */ ) { @@ -48370,10 +49091,10 @@ console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); }, - applyToBuffer: function ( buffer /*, offset, length */ ) { + applyToBufferAttribute: function ( attribute ) { - console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); - return this.applyToBufferAttribute( buffer ); + console.warn( 'THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.' ); + return attribute.applyMatrix4( this ); }, applyToVector3Array: function ( /* array, offset, length */ ) { @@ -48612,6 +49333,12 @@ console.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } } ); @@ -48639,6 +49366,12 @@ console.error( 'THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.' ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } } ); @@ -48959,6 +49692,7 @@ console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); } + console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); this.addGroup( start, count ); @@ -48985,7 +49719,14 @@ return this.deleteAttribute( name ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } + } ); Object.defineProperties( BufferGeometry.prototype, { @@ -49009,6 +49750,25 @@ } ); + Object.defineProperties( Raycaster.prototype, { + + linePrecision: { + get: function () { + + console.warn( 'THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.' ); + return this.params.Line.threshold; + + }, + set: function ( value ) { + + console.warn( 'THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.' ); + this.params.Line.threshold = value; + + } + } + + } ); + Object.defineProperties( InterleavedBuffer.prototype, { dynamic: { @@ -49476,26 +50236,12 @@ } ); - // - - Object.defineProperties( WebGLRenderTargetCube.prototype, { - - activeCubeFace: { - set: function ( /* value */ ) { - - console.warn( 'THREE.WebGLRenderTargetCube: .activeCubeFace has been removed. It is now the second parameter of WebGLRenderer.setRenderTarget().' ); - - } - }, - activeMipMapLevel: { - set: function ( /* value */ ) { - - console.warn( 'THREE.WebGLRenderTargetCube: .activeMipMapLevel has been removed. It is now the third parameter of WebGLRenderer.setRenderTarget().' ); + function WebGLRenderTargetCube( width, height, options ) { - } - } + console.warn( 'THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).' ); + return new WebGLCubeRenderTarget( width, options ); - } ); + } // @@ -49786,19 +50532,19 @@ createMultiMaterialObject: function ( /* geometry, materials */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); }, detach: function ( /* child, parent, scene */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); }, attach: function ( /* child, scene, parent */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); } @@ -49808,7 +50554,7 @@ function LensFlare() { - console.error( 'THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js' ); + console.error( 'THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js' ); } @@ -49825,6 +50571,7 @@ exports.ACESFilmicToneMapping = ACESFilmicToneMapping; exports.AddEquation = AddEquation; exports.AddOperation = AddOperation; + exports.AdditiveAnimationBlendMode = AdditiveAnimationBlendMode; exports.AdditiveBlending = AdditiveBlending; exports.AlphaFormat = AlphaFormat; exports.AlwaysDepth = AlwaysDepth; @@ -50038,7 +50785,8 @@ exports.MOUSE = MOUSE; exports.Material = Material; exports.MaterialLoader = MaterialLoader; - exports.Math = _Math; + exports.Math = MathUtils; + exports.MathUtils = MathUtils; exports.Matrix3 = Matrix3; exports.Matrix4 = Matrix4; exports.MaxEquation = MaxEquation; @@ -50070,6 +50818,7 @@ exports.NoBlending = NoBlending; exports.NoColors = NoColors; exports.NoToneMapping = NoToneMapping; + exports.NormalAnimationBlendMode = NormalAnimationBlendMode; exports.NormalBlending = NormalBlending; exports.NotEqualDepth = NotEqualDepth; exports.NotEqualStencilFunc = NotEqualStencilFunc; @@ -50135,6 +50884,8 @@ exports.RGBA_ASTC_8x5_Format = RGBA_ASTC_8x5_Format; exports.RGBA_ASTC_8x6_Format = RGBA_ASTC_8x6_Format; exports.RGBA_ASTC_8x8_Format = RGBA_ASTC_8x8_Format; + exports.RGBA_BPTC_Format = RGBA_BPTC_Format; + exports.RGBA_ETC2_EAC_Format = RGBA_ETC2_EAC_Format; exports.RGBA_PVRTC_2BPPV1_Format = RGBA_PVRTC_2BPPV1_Format; exports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format; exports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format; @@ -50148,6 +50899,7 @@ exports.RGBM16Encoding = RGBM16Encoding; exports.RGBM7Encoding = RGBM7Encoding; exports.RGB_ETC1_Format = RGB_ETC1_Format; + exports.RGB_ETC2_Format = RGB_ETC2_Format; exports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format; exports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format; exports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format; @@ -50165,6 +50917,20 @@ exports.ReverseSubtractEquation = ReverseSubtractEquation; exports.RingBufferGeometry = RingBufferGeometry; exports.RingGeometry = RingGeometry; + exports.SRGB8_ALPHA8_ASTC_10x10_Format = SRGB8_ALPHA8_ASTC_10x10_Format; + exports.SRGB8_ALPHA8_ASTC_10x5_Format = SRGB8_ALPHA8_ASTC_10x5_Format; + exports.SRGB8_ALPHA8_ASTC_10x6_Format = SRGB8_ALPHA8_ASTC_10x6_Format; + exports.SRGB8_ALPHA8_ASTC_10x8_Format = SRGB8_ALPHA8_ASTC_10x8_Format; + exports.SRGB8_ALPHA8_ASTC_12x10_Format = SRGB8_ALPHA8_ASTC_12x10_Format; + exports.SRGB8_ALPHA8_ASTC_12x12_Format = SRGB8_ALPHA8_ASTC_12x12_Format; + exports.SRGB8_ALPHA8_ASTC_4x4_Format = SRGB8_ALPHA8_ASTC_4x4_Format; + exports.SRGB8_ALPHA8_ASTC_5x4_Format = SRGB8_ALPHA8_ASTC_5x4_Format; + exports.SRGB8_ALPHA8_ASTC_5x5_Format = SRGB8_ALPHA8_ASTC_5x5_Format; + exports.SRGB8_ALPHA8_ASTC_6x5_Format = SRGB8_ALPHA8_ASTC_6x5_Format; + exports.SRGB8_ALPHA8_ASTC_6x6_Format = SRGB8_ALPHA8_ASTC_6x6_Format; + exports.SRGB8_ALPHA8_ASTC_8x5_Format = SRGB8_ALPHA8_ASTC_8x5_Format; + exports.SRGB8_ALPHA8_ASTC_8x6_Format = SRGB8_ALPHA8_ASTC_8x6_Format; + exports.SRGB8_ALPHA8_ASTC_8x8_Format = SRGB8_ALPHA8_ASTC_8x8_Format; exports.Scene = Scene; exports.SceneUtils = SceneUtils; exports.ShaderChunk = ShaderChunk; @@ -50254,6 +51020,7 @@ exports.Vertex = Vertex; exports.VertexColors = VertexColors; exports.VideoTexture = VideoTexture; + exports.WebGLCubeRenderTarget = WebGLCubeRenderTarget; exports.WebGLMultisampleRenderTarget = WebGLMultisampleRenderTarget; exports.WebGLRenderTarget = WebGLRenderTarget; exports.WebGLRenderTargetCube = WebGLRenderTargetCube; diff --git a/build/three.min.js b/build/three.min.js index a95a436a8b170d..53c77f3193d05e 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -1,615 +1,624 @@ // threejs.org/license -(function(h,Fa){"object"===typeof exports&&"undefined"!==typeof module?Fa(exports):"function"===typeof define&&define.amd?define(["exports"],Fa):(h=h||self,Fa(h.THREE={}))})(this,function(h){function Fa(){}function x(a,b){this.x=a||0;this.y=b||0}function Da(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function za(){this.elements=[1,0,0,0,1,0,0,0,1];0k)return!1}return!0}function qb(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:0}function Wb(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n(0,0,-1)}function Ta(a,b){this.normal=void 0!==a?a:new n(1,0,0);this.constant=void 0!== -b?b:0}function ma(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function y(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function bg(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function cg(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function dg(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function Dc(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&& -d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new y;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function L(){Object.defineProperty(this,"id",{value:oj++});this.uuid=O.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexTangents=this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha= +(function(l,ua){"object"===typeof exports&&"undefined"!==typeof module?ua(exports):"function"===typeof define&&define.amd?define(["exports"],ua):(l=l||self,ua(l.THREE={}))})(this,function(l){function ua(){}function v(a,b){this.x=a||0;this.y=b||0}function xa(){this.elements=[1,0,0,0,1,0,0,0,1];0h)return!1}return!0}function cb(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:-1}function Wb(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n(0,0,-1)}function Ta(a,b){this.normal=void 0!==a?a:new n(1, +0,0);this.constant=void 0!==b?b:0}function wa(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function A(a,b,c){return void 0===b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function Zf(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function $f(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function ag(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function yc(a,b,c,d,e,f){this.a=a;this.b= +b;this.c=c;this.normal=d&&d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new A;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0}function J(){Object.defineProperty(this,"id",{value:jj++});this.uuid=M.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexColors=this.flatShading=!1;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha= this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilWriteMask=255;this.stencilFunc=519;this.stencilRef=0;this.stencilFuncMask=255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha= -!1;this.toneMapped=this.visible=!0;this.userData={};this.version=0}function Oa(a){L.call(this);this.type="MeshBasicMaterial";this.color=new y(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphTargets=this.skinning=!1;this.setValues(a)} -function K(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.usage=35044;this.updateRange={offset:0,count:-1};this.version=0}function Ad(a,b,c){K.call(this,new Int8Array(a),b,c)}function Bd(a,b,c){K.call(this,new Uint8Array(a),b,c)}function Cd(a,b,c){K.call(this,new Uint8ClampedArray(a),b,c)}function Dd(a,b,c){K.call(this,new Int16Array(a), -b,c)}function Xb(a,b,c){K.call(this,new Uint16Array(a),b,c)}function Ed(a,b,c){K.call(this,new Int32Array(a),b,c)}function Yb(a,b,c){K.call(this,new Uint32Array(a),b,c)}function C(a,b,c){K.call(this,new Float32Array(a),b,c)}function Fd(a,b,c){K.call(this,new Float64Array(a),b,c)}function vh(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate= -this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function wh(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;cb&&(b=a[c]);return b}function G(){Object.defineProperty(this,"id",{value:pj+=2});this.uuid=O.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.morphTargetsRelative=!1;this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}; -this.userData={}}function ca(a,b){D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new G;this.material=void 0!==b?b:new Oa({color:16777215*Math.random()});this.updateMorphTargets()}function xh(a,b,c,d,e,f,g,k){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,k):d.intersectTriangle(e,f,g,2!==b.side,k)))return null;Je.copy(k);Je.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Je);return bc.far?null:{distance:b,point:Je.clone(),object:a}}function Ke(a,b,c,d,e,f,g,k,l,m,v,p){Zb.fromBufferAttribute(e, -m);$b.fromBufferAttribute(e,v);ac.fromBufferAttribute(e,p);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Le.set(0,0,0);Me.set(0,0,0);Ne.set(0,0,0);for(var q=0,t=f.length;qg;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function Eb(a,b,c){va.call(this,a,b,c)}function cc(a,b,c,d,e,f,g,k,l,m,v,p){T.call(this,null,f,g,k,l,m,d,e,v,p);this.image={data:a||null,width:b||1,height:c||1};this.magFilter=void 0!==l?l:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1;this.needsUpdate=!0}function Hd(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Ta,void 0!==b?b:new Ta,void 0!==c?c:new Ta,void 0!== -d?d:new Ta,void 0!==e?e:new Ta,void 0!==f?f:new Ta]}function yh(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function rj(a){function b(b,c){var d=b.array,e=b.usage,k=a.createBuffer();a.bindBuffer(c,k);a.bufferData(c,d,e);b.onUploadCallback();c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array? -console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array?c=5120:d instanceof Uint8Array&&(c=5121);return{buffer:k,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var c=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return c.get(a)},remove:function(b){b.isInterleavedBufferAttribute&& -(b=b.data);var d=c.get(b);d&&(a.deleteBuffer(d.buffer),c.delete(b))},update:function(d,e){d.isInterleavedBufferAttribute&&(d=d.data);var f=c.get(d);if(void 0===f)c.set(d,b(d,e));else if(f.versionm;m++){if(p=d[m])if(l=p[0],p=p[1]){v&&e.setAttribute("morphTarget"+m,v[l]);f&&e.setAttribute("morphNormal"+m,f[l]);c[m]=p;k+=p;continue}c[m]=0}e=e.morphTargetsRelative?1:1-k;g.getUniforms().setValue(a,"morphTargetBaseInfluence",e);g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function Cj(a,b,c,d){var e={};return{update:function(a){var f=d.render.frame,k=a.geometry,l=b.get(a,k);e[l.id]!==f&&(k.isGeometry&&l.updateFromObject(a),b.update(l),e[l.id]=f);a.isInstancedMesh&& -c.update(a.instanceMatrix,34962);return l},dispose:function(){e={}}}}function rb(a,b,c,d,e,f,g,k,l,m){a=void 0!==a?a:[];T.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,k,l,m);this.flipY=!1}function Ic(a,b,c,d){T.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Jc(a,b,c,d){T.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1}; -this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Kc(a,b,c){var d=a[0];if(0>=d||0");return a.replace(jg,ig)}function Oh(a,b,c,d){a="";for(b=parseInt(b);bc;c++)b.probe.push(new n);var d=new n,e=new P,f=new P;return{setup:function(c,k,l){for(var g=0,v=0,p=0,h=0;9>h;h++)b.probe[h].set(0,0,0);var t=k=0,r=0, -u=0,n=0,w=0,B=0,U=0;l=l.matrixWorldInverse;c.sort(Ak);h=0;for(var wa=c.length;hqa;qa++)b.probe[qa].addScaledVector(A.sh.coefficients[qa],xa);else if(A.isDirectionalLight){var F=a.get(A);F.color.copy(A.color).multiplyScalar(A.intensity);F.direction.setFromMatrixPosition(A.matrixWorld);d.setFromMatrixPosition(A.target.matrixWorld); -F.direction.sub(d);F.direction.transformDirection(l);if(F.shadow=A.castShadow)xa=A.shadow,F.shadowBias=xa.bias,F.shadowRadius=xa.radius,F.shadowMapSize=xa.mapSize,b.directionalShadowMap[k]=qa,b.directionalShadowMatrix[k]=A.shadow.matrix,w++;b.directional[k]=F;k++}else if(A.isSpotLight){F=a.get(A);F.position.setFromMatrixPosition(A.matrixWorld);F.position.applyMatrix4(l);F.color.copy(aa).multiplyScalar(xa);F.distance=x;F.direction.setFromMatrixPosition(A.matrixWorld);d.setFromMatrixPosition(A.target.matrixWorld); -F.direction.sub(d);F.direction.transformDirection(l);F.coneCos=Math.cos(A.angle);F.penumbraCos=Math.cos(A.angle*(1-A.penumbra));F.decay=A.decay;if(F.shadow=A.castShadow)xa=A.shadow,F.shadowBias=xa.bias,F.shadowRadius=xa.radius,F.shadowMapSize=xa.mapSize,b.spotShadowMap[r]=qa,b.spotShadowMatrix[r]=A.shadow.matrix,U++;b.spot[r]=F;r++}else if(A.isRectAreaLight)F=a.get(A),F.color.copy(aa).multiplyScalar(xa),F.position.setFromMatrixPosition(A.matrixWorld),F.position.applyMatrix4(l),f.identity(),e.copy(A.matrixWorld), -e.premultiply(l),f.extractRotation(e),F.halfWidth.set(.5*A.width,0,0),F.halfHeight.set(0,.5*A.height,0),F.halfWidth.applyMatrix4(f),F.halfHeight.applyMatrix4(f),b.rectArea[u]=F,u++;else if(A.isPointLight){F=a.get(A);F.position.setFromMatrixPosition(A.matrixWorld);F.position.applyMatrix4(l);F.color.copy(A.color).multiplyScalar(A.intensity);F.distance=A.distance;F.decay=A.decay;if(F.shadow=A.castShadow)xa=A.shadow,F.shadowBias=xa.bias,F.shadowRadius=xa.radius,F.shadowMapSize=xa.mapSize,F.shadowCameraNear= -xa.camera.near,F.shadowCameraFar=xa.camera.far,b.pointShadowMap[t]=qa,b.pointShadowMatrix[t]=A.shadow.matrix,B++;b.point[t]=F;t++}else A.isHemisphereLight&&(F=a.get(A),F.direction.setFromMatrixPosition(A.matrixWorld),F.direction.transformDirection(l),F.direction.normalize(),F.skyColor.copy(A.color).multiplyScalar(xa),F.groundColor.copy(A.groundColor).multiplyScalar(xa),b.hemi[n]=F,n++)}b.ambient[0]=g;b.ambient[1]=v;b.ambient[2]=p;c=b.hash;if(c.directionalLength!==k||c.pointLength!==t||c.spotLength!== -r||c.rectAreaLength!==u||c.hemiLength!==n||c.numDirectionalShadows!==w||c.numPointShadows!==B||c.numSpotShadows!==U)b.directional.length=k,b.spot.length=r,b.rectArea.length=u,b.point.length=t,b.hemi.length=n,b.directionalShadowMap.length=w,b.pointShadowMap.length=B,b.spotShadowMap.length=U,b.directionalShadowMatrix.length=w,b.pointShadowMatrix.length=B,b.spotShadowMatrix.length=U,c.directionalLength=k,c.pointLength=t,c.spotLength=r,c.rectAreaLength=u,c.hemiLength=n,c.numDirectionalShadows=w,c.numPointShadows= -B,c.numSpotShadows=U,b.version=Ck++},state:b}}function Sh(){var a=new Bk,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}}function Dk(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){if(!1===b.has(c)){var e=new Sh;b.set(c,new WeakMap);b.get(c).set(d,e);c.addEventListener("dispose", -a)}else!1===b.get(c).has(d)?(e=new Sh,b.get(c).set(d,e)):e=b.get(c).get(d);return e},dispose:function(){b=new WeakMap}}}function Gb(a){L.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.fog=!1;this.setValues(a)}function Hb(a){L.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance= -1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.fog=!1;this.setValues(a)}function Th(a,b,c){function d(a,b,c){c=a<<0|b<<1|c<<2;var d=p[c];void 0===d&&(d=new Gb({depthPacking:3201,morphTargets:a,skinning:b}),p[c]=d);return d}function e(a,b,c){c=a<<0|b<<1|c<<2;var d=h[c];void 0===d&&(d=new Hb({morphTargets:a,skinning:b}),h[c]=d);return d}function f(b,c,f,g,k,l){var m=b.geometry,p=d,v=b.customDepthMaterial; -!0===f.isPointLight&&(p=e,v=b.customDistanceMaterial);void 0===v?(v=!1,!0===c.morphTargets&&(!0===m.isBufferGeometry?v=m.morphAttributes&&m.morphAttributes.position&&0\nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}), -n=u.clone();n.defines.HORIZONAL_PASS=1;var w=new G;w.setAttribute("position",new K(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var B=new ca(w,u),U=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(d,e,f){if(!1!==U.enabled&&(!1!==U.autoUpdate||!1!==U.needsUpdate)&&0!==d.length){var p=a.getRenderTarget(),h=a.getActiveCubeFace(),q=a.getActiveMipmapLevel(),r=a.state;r.setBlending(0);r.buffers.color.setClear(1,1,1,1);r.buffers.depth.setTest(!0);r.setScissorTest(!1); -for(var t=0,z=d.length;tc||l.y>c)console.warn("THREE.WebGLShadowMap:",w,"has shadow exceeding max texture size, reducing"),l.x>c&&(m.x=Math.floor(c/aa.x),l.x=m.x*aa.x,A.mapSize.x=m.x),l.y>c&&(m.y=Math.floor(c/aa.y),l.y=m.y*aa.y,A.mapSize.y=m.y);null!==A.map||A.isPointLightShadow||3!==this.type||(aa={minFilter:1006, -magFilter:1006,format:1023},A.map=new va(l.x,l.y,aa),A.map.texture.name=w.name+".shadowMap",A.mapPass=new va(l.x,l.y,aa),A.camera.updateProjectionMatrix());null===A.map&&(aa={minFilter:1003,magFilter:1003,format:1023},A.map=new va(l.x,l.y,aa),A.map.texture.name=w.name+".shadowMap",A.camera.updateProjectionMatrix());a.setRenderTarget(A.map);a.clear();aa=A.getViewportCount();for(var wa=0;wad||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if("undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&a instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&a instanceof ImageBitmap)return d=b?O.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===I&&(I=k(b,e)),c=c?k(b,e):I,c.width=b,c.height=e, -c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+b+"x"+e+")."),c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return O.isPowerOfTwo(a.width)&&O.isPowerOfTwo(a.height)}function v(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function p(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e, -f))*Math.LOG2E}function h(c,d,e){if(!1===qa)return d;if(null!==c){if(void 0!==a[c])return a[c];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+c+"'")}c=d;6403===d&&(5126===e&&(c=33326),5131===e&&(c=33325),5121===e&&(c=33321));6407===d&&(5126===e&&(c=34837),5131===e&&(c=34843),5121===e&&(c=32849));6408===d&&(5126===e&&(c=34836),5131===e&&(c=34842),5121===e&&(c=32856));33325===c||33326===c||34842===c||34836===c?b.get("EXT_color_buffer_float"):(34843===c||34837=== -c)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");return c}function t(a){return 1003===a||1004===a||1005===a?9728:9729}function r(b){b=b.target;b.removeEventListener("dispose",r);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&G.delete(b);g.memory.textures--}function u(b){b=b.target;b.removeEventListener("dispose",u);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&& -a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);if(b.isWebGLMultiviewRenderTarget){a.deleteTexture(c.__webglColorTexture);a.deleteTexture(c.__webglDepthStencilTexture);g.memory.textures-=2;e=0;for(var f=c.__webglViewFramebuffers.length;e< -f;e++)a.deleteFramebuffer(c.__webglViewFramebuffers[e])}d.remove(b.texture);d.remove(b)}g.memory.textures--}function n(a,b){var e=d.get(a);if(a.isVideoTexture){var f=g.render.frame;G.get(a)!==f&&(G.set(a,f),a.update())}if(0q;q++)r[q]=k||e?e?b.image[q].image:b.image[q]:l(b.image[q],!1,!0,E);var t=r[0],u=m(t)||qa,n=f.convert(b.format),A=f.convert(b.type),w=h(b.internalFormat,n,A);U(34067,b,u);if(k){for(q= -0;6>q;q++){var z=r[q].mipmaps;for(k=0;kq;q++)if(e)for(c.texImage2D(34069+q,0,w,r[q].width,r[q].height,0,n,A,r[q].data),k=0;k=F&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+F);K+=1;return a};this.resetTextureUnits=function(){K=0};this.setTexture2D=n;this.setTexture2DArray=function(a,b){var e= -d.get(a);0A;A++)k.__webglFramebuffer[A]=a.createFramebuffer()}else if(k.__webglFramebuffer=a.createFramebuffer(),r)if(qa){k.__webglMultisampledFramebuffer=a.createFramebuffer();k.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,k.__webglColorRenderbuffer);r=f.convert(e.texture.format);var w=f.convert(e.texture.type);r=h(e.texture.internalFormat,r,w);w= -C(e);a.renderbufferStorageMultisample(36161,w,r,e.width,e.height);a.bindFramebuffer(36160,k.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,k.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);e.depthBuffer&&(k.__webglDepthRenderbuffer=a.createRenderbuffer(),x(k.__webglDepthRenderbuffer,e,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(t){A=e.width;var B=e.height;r=e.numViews; -a.bindFramebuffer(36160,k.__webglFramebuffer);var wa=b.get("OVR_multiview2");g.memory.textures+=2;w=a.createTexture();a.bindTexture(35866,w);a.texParameteri(35866,10240,9728);a.texParameteri(35866,10241,9728);a.texImage3D(35866,0,32856,A,B,r,0,6408,5121,null);wa.framebufferTextureMultiviewOVR(36160,36064,w,0,0,r);var F=a.createTexture();a.bindTexture(35866,F);a.texParameteri(35866,10240,9728);a.texParameteri(35866,10241,9728);a.texImage3D(35866,0,35056,A,B,r,0,34041,34042,null);wa.framebufferTextureMultiviewOVR(36160, -33306,F,0,0,r);B=Array(r);for(A=0;AA;A++)aa(k.__webglFramebuffer[A],e,36064,34069+A);v(e.texture,z)&&p(34067,e.texture,e.width,e.height);c.bindTexture(34067,null)}else t||(c.bindTexture(3553, -l.__webglTexture),U(3553,e.texture,z),aa(k.__webglFramebuffer,e,36064,3553),v(e.texture,z)&&p(3553,e.texture,e.width,e.height),c.bindTexture(3553,null));if(e.depthBuffer){k=d.get(e);l=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(l)throw Error("target.depthTexture not supported in Cube render targets");if(e&&e.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(36160,k.__webglFramebuffer);if(!e.depthTexture||!e.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture"); -d.get(e.depthTexture).__webglTexture&&e.depthTexture.image.width===e.width&&e.depthTexture.image.height===e.height||(e.depthTexture.image.width=e.width,e.depthTexture.image.height=e.height,e.depthTexture.needsUpdate=!0);n(e.depthTexture,0);k=d.get(e.depthTexture).__webglTexture;if(1026===e.depthTexture.format)a.framebufferTexture2D(36160,36096,3553,k,0);else if(1027===e.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,k,0);else throw Error("Unknown depthTexture format");}else if(l)for(k.__webglDepthbuffer= -[],l=0;6>l;l++)a.bindFramebuffer(36160,k.__webglFramebuffer[l]),k.__webglDepthbuffer[l]=a.createRenderbuffer(),x(k.__webglDepthbuffer[l],e);else a.bindFramebuffer(36160,k.__webglFramebuffer),k.__webglDepthbuffer=a.createRenderbuffer(),x(k.__webglDepthbuffer,e);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,e=m(a)||qa;if(v(b,e)){e=a.isWebGLRenderTargetCube?34067:3553;var f=d.get(b).__webglTexture;c.bindTexture(e,f);p(e,b,a.width,a.height);c.bindTexture(e, -null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(qa){var c=d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer);c=b.width;var e=b.height,f=16384;b.depthBuffer&&(f|=256);b.stencilBuffer&&(f|=1024);a.blitFramebuffer(0,0,c,e,0,0,c,e,f,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(a,b){a&&a.isWebGLRenderTarget&& -(!1===ha&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),ha=!0),a=a.texture);n(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLRenderTargetCube&&(!1===P&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),P=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?w(a,b):B(a,b)}}function Vh(a,b,c){var d= -c.isWebGL2;return{convert:function(a){if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(d)return 5131;var c=b.get("OES_texture_half_float");return null!==c?c.HALF_FLOAT_OES:null}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410; -if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(1029===a)return 36244;if(1030===a)return 33319;if(1031===a)return 33320;if(1032===a)return 36248;if(1033===a)return 36249;if(33776===a||33777===a||33778===a||33779===a)if(c=b.get("WEBGL_compressed_texture_s3tc"),null!==c){if(33776===a)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null; -if(35840===a||35841===a||35842===a||35843===a)if(c=b.get("WEBGL_compressed_texture_pvrtc"),null!==c){if(35840===a)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===a)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(36196===a)return c=b.get("WEBGL_compressed_texture_etc1"),null!==c?c.COMPRESSED_RGB_ETC1_WEBGL:null;if(37808===a||37809===a||37810===a||37811===a||37812===a||37813=== -a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a)return c=b.get("WEBGL_compressed_texture_astc"),null!==c?a:null;if(1020===a){if(d)return 34042;c=b.get("WEBGL_depth_texture");return null!==c?c.UNSIGNED_INT_24_8_WEBGL:null}}}}function og(a,b,c,d){va.call(this,a,b,d);this.stencilBuffer=this.depthBuffer=!1;this.numViews=c}function Gk(a,b){function c(a){if(a.isArrayCamera)return a.cameras;v[0]=a;return v}function d(a){if(void 0===a.isArrayCamera)return!0;a=a.cameras; -if(a.length>t)return!1;for(var b=1,c=a.length;bf.matrixWorld.determinant(),l=h(a,c,e,f);Z.setMaterial(e,k);var m=!1;if(b!==d.id||da!==l.id||ha!==(!0===e.wireframe))b=d.id,da=l.id,ha=!0===e.wireframe,m=!0;if(e.morphTargets||e.morphNormals)Aa.update(f,d,e,l),m=!0;a=d.index;c=d.attributes.position; -if(null===a){if(void 0===c||0===c.count)return}else if(0===a.count)return;var p=1;!0===e.wireframe&&(a=za.getWireframeAttribute(d),p=2);k=Ba;if(null!==a){var v=ma.get(a);k=Da;k.setIndex(v)}if(m){if(!1!==Ha.isWebGL2||!f.isInstancedMesh&&!d.isInstancedBufferGeometry||null!==sa.get("ANGLE_instanced_arrays")){Z.initAttributes();m=d.attributes;l=l.getAttributes();var q=e.defaultAttributeValues;for(x in l){var r=l[x];if(0<=r){var t=m[x];if(void 0!==t){var n=t.normalized,u=t.itemSize,z=ma.get(t);if(void 0!== -z){var w=z.buffer,A=z.type;z=z.bytesPerElement;if(t.isInterleavedBufferAttribute){var B=t.data,U=B.stride;t=t.offset;B&&B.isInstancedInterleavedBuffer?(Z.enableAttributeAndDivisor(r,B.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=B.meshPerAttribute*B.count)):Z.enableAttribute(r);H.bindBuffer(34962,w);H.vertexAttribPointer(r,u,A,n,U*z,t*z)}else t.isInstancedBufferAttribute?(Z.enableAttributeAndDivisor(r,t.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=t.meshPerAttribute* -t.count)):Z.enableAttribute(r),H.bindBuffer(34962,w),H.vertexAttribPointer(r,u,A,n,0,0)}}else if("instanceMatrix"===x)z=ma.get(f.instanceMatrix),void 0!==z&&(w=z.buffer,A=z.type,Z.enableAttributeAndDivisor(r+0,1),Z.enableAttributeAndDivisor(r+1,1),Z.enableAttributeAndDivisor(r+2,1),Z.enableAttributeAndDivisor(r+3,1),H.bindBuffer(34962,w),H.vertexAttribPointer(r+0,4,A,!1,64,0),H.vertexAttribPointer(r+1,4,A,!1,64,16),H.vertexAttribPointer(r+2,4,A,!1,64,32),H.vertexAttribPointer(r+3,4,A,!1,64,48));else if(void 0!== -q&&(n=q[x],void 0!==n))switch(n.length){case 2:H.vertexAttrib2fv(r,n);break;case 3:H.vertexAttrib3fv(r,n);break;case 4:H.vertexAttrib4fv(r,n);break;default:H.vertexAttrib1fv(r,n)}}}Z.disableUnusedAttributes()}null!==a&&H.bindBuffer(34963,v.buffer)}var x=d.drawRange.start*p;m=null!==g?g.start*p:0;v=Math.max(x,m);g=Math.max(0,Math.min(null!==a?a.count:c.count,x+d.drawRange.count*p,m+(null!==g?g.count*p:Infinity))-1-v+1);0!==g&&(f.isMesh?!0===e.wireframe?(Z.setLineWidth(e.wireframeLinewidth*(null=== -N?R:1)),k.setMode(1)):k.setMode(4):f.isLine?(e=e.linewidth,void 0===e&&(e=1),Z.setLineWidth(e*(null===N?R:1)),f.isLineSegments?k.setMode(1):f.isLineLoop?k.setMode(2):k.setMode(3)):f.isPoints?k.setMode(0):f.isSprite&&k.setMode(4),f.isInstancedMesh?k.renderInstances(d,v,g,f.count):d.isInstancedBufferGeometry?k.renderInstances(d,v,g,d.maxInstancedCount):k.render(v,g))};this.compile=function(a,b){F=va.get(a,b);F.init();a.traverse(function(a){a.isLight&&(F.pushLight(a),a.castShadow&&F.pushShadow(a))}); -F.setupLights(b);a.traverse(function(b){if(b.material)if(Array.isArray(b.material))for(var c=0;ce.far||f.push({distance:a,distanceToRay:Math.sqrt(k),point:c,index:b,face:null,object:g}))} -function tg(a,b,c,d,e,f,g,k,l){T.call(this,a,b,c,d,e,f,g,k,l);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1}function Pc(a,b,c,d,e,f,g,k,l,m,h,p){T.call(this,null,f,g,k,l,m,d,e,h,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Ud(a,b,c,d,e,f,g,k,l){T.call(this,a,b,c,d,e,f,g,k,l);this.needsUpdate=!0}function Vd(a,b,c,d,e,f,g,k,l,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); -void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);T.call(this,null,d,e,f,g,k,m,c,l);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==k?k:1003;this.generateMipmaps=this.flipY=!1}function Qc(a){G.call(this);this.type="WireframeGeometry";var b=[],c,d,e,f=[0,0],g={},k=["a","b","c"];if(a&&a.isGeometry){var l=a.faces;var m=0;for(d=l.length;mc;c++){var p=h[k[c]];var q=h[k[(c+1)%3]];f[0]=Math.min(p,q);f[1]=Math.max(p,q);p=f[0]+ -","+f[1];void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]})}}for(p in g)m=g[p],k=a.vertices[m.index1],b.push(k.x,k.y,k.z),k=a.vertices[m.index2],b.push(k.x,k.y,k.z)}else if(a&&a.isBufferGeometry)if(k=new n,null!==a.index){l=a.attributes.position;h=a.index;var t=a.groups;0===t.length&&(t=[{start:0,count:h.count,materialIndex:0}]);a=0;for(e=t.length;ac;c++)p=h.getX(m+c),q=h.getX(m+(c+1)%3),f[0]=Math.min(p,q),f[1]=Math.max(p,q),p=f[0]+","+ -f[1],void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]});for(p in g)m=g[p],k.fromBufferAttribute(l,m.index1),b.push(k.x,k.y,k.z),k.fromBufferAttribute(l,m.index2),b.push(k.x,k.y,k.z)}else for(l=a.attributes.position,m=0,d=l.count/3;mc;c++)g=3*m+c,k.fromBufferAttribute(l,g),b.push(k.x,k.y,k.z),g=3*m+(c+1)%3,k.fromBufferAttribute(l,g),b.push(k.x,k.y,k.z);this.setAttribute("position",new C(b,3))}function Wd(a,b,c){M.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b, -stacks:c};this.fromBufferGeometry(new Rc(a,b,c));this.mergeVertices()}function Rc(a,b,c){G.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],k=new n,l=new n,m=new n,h=new n,p=new n,q,t;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var r=b+1;for(q=0;q<=c;q++){var u=q/c;for(t=0;t<=b;t++){var z=t/b;a(z,u,l);e.push(l.x,l.y,l.z);0<=z-1E-5?(a(z-1E-5,u,m),h.subVectors(l,m)):(a(z+ -1E-5,u,m),h.subVectors(m,l));0<=u-1E-5?(a(z,u-1E-5,m),p.subVectors(l,m)):(a(z,u+1E-5,m),p.subVectors(m,l));k.crossVectors(h,p).normalize();f.push(k.x,k.y,k.z);g.push(z,u)}}for(q=0;qd&&1===a.x&&(l[b]=a.x-1);0===c.x&&0===c.z&&(l[b]=d/2/Math.PI+.5)}G.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var k=[],l=[];(function(a){for(var c=new n,d=new n,g=new n,k=0;ke&&(.2>b&&(l[a+0]+=1),.2>c&&(l[a+2]+=1),.2>d&&(l[a+4]+=1))})();this.setAttribute("position",new C(k,3));this.setAttribute("normal",new C(k.slice(),3));this.setAttribute("uv",new C(l,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Yd(a,b){M.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sc(a,b));this.mergeVertices()} -function Sc(a,b){Ga.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Zd(a,b){M.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new ec(a,b));this.mergeVertices()}function ec(a,b){Ga.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters= -{radius:a,detail:b}}function $d(a,b){M.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Tc(a,b));this.mergeVertices()}function Tc(a,b){var c=(1+Math.sqrt(5))/2;Ga.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters= -{radius:a,detail:b}}function ae(a,b){M.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Uc(a,b));this.mergeVertices()}function Uc(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;Ga.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2, -6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function be(a,b,c,d,e,f){M.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new fc(a,b,c,d,e);this.tangents=a.tangents;this.normals= -a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function fc(a,b,c,d,e){function f(e){h=a.getPointAt(e/b,h);var f=g.normals[e];e=g.binormals[e];for(q=0;q<=d;q++){var m=q/d*Math.PI*2,p=Math.sin(m);m=-Math.cos(m);l.x=m*f.x+p*e.x;l.y=m*f.y+p*e.y;l.z=m*f.z+p*e.z;l.normalize();r.push(l.x,l.y,l.z);k.x=h.x+c*l.x;k.y=h.y+c*l.y;k.z=h.z+c*l.z;t.push(k.x,k.y,k.z)}}G.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d, -closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var k=new n,l=new n,m=new x,h=new n,p,q,t=[],r=[],u=[],z=[];for(p=0;p=b;e-=d)f=$h(e,a[e],a[e+1],f);f&&gc(f,f.next)&&(ee(f),f=f.next);return f}function fe(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!gc(a,a.next)&&0!==ta(a.prev,a,a.next))a=a.next;else{ee(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function ge(a,b,c,d,e,f,g){if(a){if(!g&&f){var k=a,l=k;do null===l.z&&(l.z=ug(l.x,l.y,d,e,f)),l.prevZ=l.prev,l=l.nextZ= -l.next;while(l!==k);l.prevZ.nextZ=null;l.prevZ=null;k=l;var m,h,p,q,t=1;do{l=k;var r=k=null;for(h=0;l;){h++;var n=l;for(m=p=0;mn!==r.next.y>n&&r.next.y!==r.y&&p<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(h=!h),r=r.next;while(r!==l);r=h}l=r}if(l){a=bi(g,k);g=fe(g,g.next);a=fe(a,a.next);ge(g,b,c,d,e,f);ge(a,b,c,d,e,f);break a}k=k.next}g=g.next}while(g!==a)}break}}}}function Hk(a,b,c,d){var e=a.prev,f=a.next;if(0<=ta(e,a,f))return!1;var g=e.x>a.x? -e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,k=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,l=ug(e.x=l&&d&&d.z<=b;){if(c!==a.prev&&c!==a.next&&Xc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=ta(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&Xc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=ta(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=l;){if(c!==a.prev&&c!==a.next&&Xc(e.x,e.y,a.x,a.y, -f.x,f.y,c.x,c.y)&&0<=ta(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&Xc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=ta(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function Ik(a,b){return a.x-b.x}function Jk(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var k=c.x=c.x&&c.x>=g&&d!==c.x&&Xc(ek.x)&&he(c,a)&&(k=c,m=h)}c=c.next}return k}function ug(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function Kk(a){var b=a,c=a;do{if(b.xta(a.prev,a,a.next)?0<=ta(a,b,a.next)&&0<=ta(a,a.prev,b):0>ta(a,b,a.prev)|| -0>ta(a,a.next,b)}function bi(a,b){var c=new vg(a.i,a.x,a.y),d=new vg(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function $h(a,b,c,d){a=new vg(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function ee(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function vg(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next= -this.prev=null;this.steiner=!1}function ci(a){var b=a.length;2Number.EPSILON){var l=Math.sqrt(k),m=Math.sqrt(f*f+g*g);k=b.x-e/l;b=b.y+d/l;g=((c.x-g/m-k)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=k+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new x(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(k)):(f=d,d=e,e=Math.sqrt(k/2));return new x(f/e,d/e)}function k(a,b){for(J=a.length;0<= ---J;){var c=J;var f=J-1;0>f&&(f=a.length-1);var g,k=B+2*C;for(g=0;gh;h++){var p= -m[f[h]];var q=m[f[(h+1)%3]];d[0]=Math.min(p,q);d[1]=Math.max(p,q);p=d[0]+","+d[1];void 0===e[p]?e[p]={index1:d[0],index2:d[1],face1:k,face2:void 0}:e[p].face2=k}for(p in e)if(d=e[p],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.setAttribute("position",new C(c,3))}function lc(a,b,c,d,e,f,g,k){M.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e, -openEnded:f,thetaStart:g,thetaLength:k};this.fromBufferGeometry(new ub(a,b,c,d,e,f,g,k));this.mergeVertices()}function ub(a,b,c,d,e,f,g,k){function l(c){var e,f=new x,l=new n,v=0,u=!0===c?a:b,B=!0===c?1:-1;var y=r;for(e=1;e<=d;e++)p.push(0,z*B,0),q.push(0,B,0),t.push(.5,.5),r++;var F=r;for(e=0;e<=d;e++){var C=e/d*k+g,G=Math.cos(C);C=Math.sin(C);l.x=u*C;l.y=z*B;l.z=u*G;p.push(l.x,l.y,l.z);q.push(0,B,0);f.x=.5*G+.5;f.y=.5*C*B+.5;t.push(f.x,f.y);r++}for(e=0;ethis.duration&&this.resetDuration()}function Mk(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return cd;case "vector":case "vector2":case "vector3":case "vector4":return dd; -case "color":return Ze;case "quaternion":return qe;case "bool":case "boolean":return Ye;case "string":return af}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Nk(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Mk(a.type);if(void 0===a.times){var c=[],d=[];ea.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function wg(a,b,c){var d=this,e= -!1,f=0,g=0,k=void 0,l=[];this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return k?k(a):a};this.setURLModifier=function(a){k=a;return this};this.addHandler=function(a,b){l.push(a,b);return this}; -this.removeHandler=function(a){a=l.indexOf(a);-1!==a&&l.splice(a,2);return this};this.getHandler=function(a){for(var b=0,c=l.length;ba;a++)this.coefficients.push(new n)}function ab(a,b){ba.call(this,void 0,b);this.sh=void 0!==a?a:new tf}function Fg(a,b,c){ab.call(this,void 0,c);a=(new y).set(a);c=(new y).set(b);b=new n(a.r,a.g,a.b);a=new n(c.r,c.g,c.b); -c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function Gg(a,b){ab.call(this,void 0,b);a=(new y).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}function ii(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new pa;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new pa;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate= -!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Hg(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Ig(){D.call(this);this.type="AudioListener";this.context=Jg.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0;this._clock=new Hg}function hd(a){D.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain= -this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.loopEnd=this.loopStart=0;this.duration=void 0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this._pausedAt=this._startedAt=0;this.filters=[]}function Kg(a){hd.call(this,a);this.panner=this.context.createPanner();this.panner.panningModel="HRTF";this.panner.connect(this.gain)}function Lg(a,b){this.analyser=a.context.createAnalyser(); -this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function Mg(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function ji(a,b,c){c=c||Ba.parseTrackName(b);this._targetGroup=a;this._bindings= -a.subscribe_(b,c)}function Ba(a,b,c){this.path=b;this.parsedPath=c||Ba.parseTrackName(b);this.node=Ba.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function ki(){this.uuid=O.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length}, -get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function li(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop= -2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Ng(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function uf(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Og(a,b,c){sb.call(this, -a,b);this.meshPerAttribute=c||1}function mi(a,b,c,d){this.ray=new Wb(a,b);this.near=c||0;this.far=d||Infinity;this.camera=null;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function ni(a,b){return a.distance-b.distance}function Pg(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e= -a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.setAttribute("position",new C(b,3));b=new ja({fog:!1});this.cone=new la(a,b);this.add(this.cone);this.update()}function qi(a){var b=[];a&&a.isBone&&b.push(a);for(var c= -0;cr;++r)e=r/h,e=Math.exp(-e*e/2),q.push(e),0==r?n+=e:r\n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"} -function Ci(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");Aa.call(this,a);this.type="catmullrom";this.closed=!0}function Di(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");Aa.call(this,a);this.type="catmullrom"}function Zg(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");Aa.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2, +!1;this.toneMapped=this.visible=!0;this.userData={};this.version=0}function Na(a){J.call(this);this.type="MeshBasicMaterial";this.color=new A(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphTargets=this.skinning=!1;this.setValues(a)} +function N(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.usage=35044;this.updateRange={offset:0,count:-1};this.version=0}function xd(a,b,c){N.call(this,new Int8Array(a),b,c)}function yd(a,b,c){N.call(this,new Uint8Array(a),b,c)}function zd(a,b,c){N.call(this,new Uint8ClampedArray(a),b,c)}function Ad(a,b,c){N.call(this,new Int16Array(a), +b,c)}function Xb(a,b,c){N.call(this,new Uint16Array(a),b,c)}function Bd(a,b,c){N.call(this,new Int32Array(a),b,c)}function Yb(a,b,c){N.call(this,new Uint32Array(a),b,c)}function y(a,b,c){N.call(this,new Float32Array(a),b,c)}function Cd(a,b,c){N.call(this,new Float64Array(a),b,c)}function uh(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate= +this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function vh(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;cb&&(b=a[c]);return b}function B(){Object.defineProperty(this,"id",{value:kj+=2});this.uuid=M.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.morphTargetsRelative=!1;this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}; +this.userData={}}function ja(a,b){E.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new B;this.material=void 0!==b?b:new Na;this.updateMorphTargets()}function wh(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;De.copy(h);De.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(De);return bc.far?null:{distance:b,point:De.clone(),object:a}}function Ee(a,b,c,d,e,f,g,h,k,m,z,p){Cb.fromBufferAttribute(e,m);Db.fromBufferAttribute(e, +z);Eb.fromBufferAttribute(e,p);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Fe.set(0,0,0);Ge.set(0,0,0);He.set(0,0,0);for(var u=0,r=f.length;ug;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function Fb(a,b,c){Number.isInteger(b)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),b=c);za.call(this,a,a,b)}function Zb(a,b,c,d,e,f,g,h,k,m,z,p){V.call(this,null,f,g,h,k,m,d,e,z,p);this.image={data:a||null,width:b||1,height:c||1};this.magFilter=void 0!==k?k:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment= +1;this.needsUpdate=!0}function Ec(a,b,c,d,e,f){this.planes=[void 0!==a?a:new Ta,void 0!==b?b:new Ta,void 0!==c?c:new Ta,void 0!==d?d:new Ta,void 0!==e?e:new Ta,void 0!==f?f:new Ta]}function xh(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function mj(a,b){function c(b,c){var d=b.array,e=b.usage,f=a.createBuffer(); +a.bindBuffer(c,f);a.bufferData(c,d,e);b.onUploadCallback();c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array?c=5120:d instanceof Uint8Array&&(c=5121);return{buffer:f,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var d=b.isWebGL2,e=new WeakMap; +return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return e.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var c=e.get(b);c&&(a.deleteBuffer(c.buffer),e.delete(b))},update:function(b,g){b.isInterleavedBufferAttribute&&(b=b.data);var f=e.get(b);if(void 0===f)e.set(b,c(b,g));else if(f.versionm;m++){if(p=d[m])if(k=p[0],p=p[1]){z&&e.setAttribute("morphTarget"+m,z[k]); +f&&e.setAttribute("morphNormal"+m,f[k]);c[m]=p;h+=p;continue}c[m]=0}e=e.morphTargetsRelative?1:1-h;g.getUniforms().setValue(a,"morphTargetBaseInfluence",e);g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function xj(a,b,c,d){var e=new WeakMap;return{update:function(a){var f=d.render.frame,h=a.geometry,k=b.get(a,h);e.get(k)!==f&&(h.isGeometry&&k.updateFromObject(a),b.update(k),e.set(k,f));a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return k},dispose:function(){e=new WeakMap}}}function pb(a, +b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];V.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,k,m);this.flipY=!1}function Fc(a,b,c,d){V.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Gc(a,b,c,d){V.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps= +!1;this.needsUpdate=!0}function Hc(a,b,c){var d=a[0];if(0>=d||0");return a.replace(gg,fg)}function Nh(a,b,c,d){console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.");return hg(a,b,c,d)}function hg(a,b,c,d){a="";for(b=parseInt(b);bd;d++)c.probe.push(new n);var e=new n,f=new P,g=new P;return{setup:function(d,k,m){for(var h=0,p=0,l=0,r=0;9>r;r++)c.probe[r].set(0,0,0);var q=k=0,t=0,n=0,x=0,w=0,ha=0,U=0;m=m.matrixWorldInverse;d.sort(wk);r=0;for(var Z=d.length;rFa;Fa++)c.probe[Fa].addScaledVector(C.sh.coefficients[Fa],ma);else if(C.isDirectionalLight){var I=a.get(C);I.color.copy(C.color).multiplyScalar(C.intensity);I.direction.setFromMatrixPosition(C.matrixWorld);e.setFromMatrixPosition(C.target.matrixWorld);I.direction.sub(e);I.direction.transformDirection(m);C.castShadow&&(ma=C.shadow,v=b.get(C),v.shadowBias=ma.bias,v.shadowRadius=ma.radius,v.shadowMapSize=ma.mapSize, +c.directionalShadow[k]=v,c.directionalShadowMap[k]=Fa,c.directionalShadowMatrix[k]=C.shadow.matrix,w++);c.directional[k]=I;k++}else C.isSpotLight?(I=a.get(C),I.position.setFromMatrixPosition(C.matrixWorld),I.position.applyMatrix4(m),I.color.copy(v).multiplyScalar(ma),I.distance=Ba,I.direction.setFromMatrixPosition(C.matrixWorld),e.setFromMatrixPosition(C.target.matrixWorld),I.direction.sub(e),I.direction.transformDirection(m),I.coneCos=Math.cos(C.angle),I.penumbraCos=Math.cos(C.angle*(1-C.penumbra)), +I.decay=C.decay,C.castShadow&&(ma=C.shadow,v=b.get(C),v.shadowBias=ma.bias,v.shadowRadius=ma.radius,v.shadowMapSize=ma.mapSize,c.spotShadow[t]=v,c.spotShadowMap[t]=Fa,c.spotShadowMatrix[t]=C.shadow.matrix,U++),c.spot[t]=I,t++):C.isRectAreaLight?(I=a.get(C),I.color.copy(v).multiplyScalar(ma),I.position.setFromMatrixPosition(C.matrixWorld),I.position.applyMatrix4(m),g.identity(),f.copy(C.matrixWorld),f.premultiply(m),g.extractRotation(f),I.halfWidth.set(.5*C.width,0,0),I.halfHeight.set(0,.5*C.height, +0),I.halfWidth.applyMatrix4(g),I.halfHeight.applyMatrix4(g),c.rectArea[n]=I,n++):C.isPointLight?(I=a.get(C),I.position.setFromMatrixPosition(C.matrixWorld),I.position.applyMatrix4(m),I.color.copy(C.color).multiplyScalar(C.intensity),I.distance=C.distance,I.decay=C.decay,C.castShadow&&(ma=C.shadow,v=b.get(C),v.shadowBias=ma.bias,v.shadowRadius=ma.radius,v.shadowMapSize=ma.mapSize,v.shadowCameraNear=ma.camera.near,v.shadowCameraFar=ma.camera.far,c.pointShadow[q]=v,c.pointShadowMap[q]=Fa,c.pointShadowMatrix[q]= +C.shadow.matrix,ha++),c.point[q]=I,q++):C.isHemisphereLight&&(I=a.get(C),I.direction.setFromMatrixPosition(C.matrixWorld),I.direction.transformDirection(m),I.direction.normalize(),I.skyColor.copy(C.color).multiplyScalar(ma),I.groundColor.copy(C.groundColor).multiplyScalar(ma),c.hemi[x]=I,x++)}c.ambient[0]=h;c.ambient[1]=p;c.ambient[2]=l;d=c.hash;if(d.directionalLength!==k||d.pointLength!==q||d.spotLength!==t||d.rectAreaLength!==n||d.hemiLength!==x||d.numDirectionalShadows!==w||d.numPointShadows!== +ha||d.numSpotShadows!==U)c.directional.length=k,c.spot.length=t,c.rectArea.length=n,c.point.length=q,c.hemi.length=x,c.directionalShadow.length=w,c.directionalShadowMap.length=w,c.pointShadow.length=ha,c.pointShadowMap.length=ha,c.spotShadow.length=U,c.spotShadowMap.length=U,c.directionalShadowMatrix.length=w,c.pointShadowMatrix.length=ha,c.spotShadowMatrix.length=U,d.directionalLength=k,d.pointLength=q,d.spotLength=t,d.rectAreaLength=n,d.hemiLength=x,d.numDirectionalShadows=w,d.numPointShadows=ha, +d.numSpotShadows=U,c.version=yk++},state:c}}function Th(){var a=new xk,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}}function zk(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){if(!1===b.has(c)){var e=new Th;b.set(c,new WeakMap);b.get(c).set(d,e);c.addEventListener("dispose", +a)}else!1===b.get(c).has(d)?(e=new Th,b.get(c).set(d,e)):e=b.get(c).get(d);return e},dispose:function(){b=new WeakMap}}}function Hb(a){J.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.fog=!1;this.setValues(a)}function Ib(a){J.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance= +1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.fog=!1;this.setValues(a)}function Uh(a,b,c){function d(a,b,c){c=a<<0|b<<1|c<<2;var d=p[c];void 0===d&&(d=new Hb({depthPacking:3201,morphTargets:a,skinning:b}),p[c]=d);return d}function e(a,b,c){c=a<<0|b<<1|c<<2;var d=l[c];void 0===d&&(d=new Ib({morphTargets:a,skinning:b}),l[c]=d);return d}function f(b,c,f,g,h,k,m){var p=d,l=b.customDepthMaterial; +!0===g.isPointLight&&(p=e,l=b.customDistanceMaterial);void 0===l?(l=!1,!0===f.morphTargets&&(l=c.morphAttributes&&c.morphAttributes.position&&0\nvoid main() {\n float mean = 0.0;\n float squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n #ifdef HORIZONAL_PASS\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n float std_dev = sqrt( squared_mean - mean * mean );\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}), +n=t.clone();n.defines.HORIZONAL_PASS=1;var x=new B;x.setAttribute("position",new N(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var w=new ja(x,t),ha=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(d,e,f){if(!1!==ha.enabled&&(!1!==ha.autoUpdate||!1!==ha.needsUpdate)&&0!==d.length){var p=a.getRenderTarget(),l=a.getActiveCubeFace(),u=a.getActiveMipmapLevel(),q=a.state;q.setBlending(0);q.buffers.color.setClear(1,1,1,1);q.buffers.depth.setTest(!0);q.setScissorTest(!1); +for(var r=0,F=d.length;rc||k.y>c)k.x>c&&(m.x=Math.floor(c/v.x),k.x=m.x*v.x,C.mapSize.x=m.x),k.y>c&&(m.y=Math.floor(c/v.y),k.y=m.y*v.y,C.mapSize.y=m.y);null!==C.map||C.isPointLightShadow||3!==this.type||(v={minFilter:1006,magFilter:1006,format:1023},C.map=new za(k.x,k.y,v),C.map.texture.name=x.name+".shadowMap", +C.mapPass=new za(k.x,k.y,v),C.camera.updateProjectionMatrix());null===C.map&&(v={minFilter:1003,magFilter:1003,format:1023},C.map=new za(k.x,k.y,v),C.map.texture.name=x.name+".shadowMap",C.camera.updateProjectionMatrix());a.setRenderTarget(C.map);a.clear();v=C.getViewportCount();for(var Z=0;Zd||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if("undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&a instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&a instanceof ImageBitmap)return d=b?M.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===G&&(G=h(b,e)),c=c?h(b,e):G,c.width=b,c.height=e, +c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+b+"x"+e+")."),c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return M.isPowerOfTwo(a.width)&&M.isPowerOfTwo(a.height)}function l(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function p(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e, +f))*Math.LOG2E}function u(c,d,e){if(!1===Ba)return d;if(null!==c){if(void 0!==a[c])return a[c];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+c+"'")}c=d;6403===d&&(5126===e&&(c=33326),5131===e&&(c=33325),5121===e&&(c=33321));6407===d&&(5126===e&&(c=34837),5131===e&&(c=34843),5121===e&&(c=32849));6408===d&&(5126===e&&(c=34836),5131===e&&(c=34842),5121===e&&(c=32856));33325!==c&&33326!==c&&34842!==c&&34836!==c||b.get("EXT_color_buffer_float");return c}function r(a){return 1003=== +a||1004===a||1005===a?9728:9729}function q(b){b=b.target;b.removeEventListener("dispose",q);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&B.delete(b);g.memory.textures--}function t(b){b=b.target;b.removeEventListener("dispose",t);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLCubeRenderTarget)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]), +c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer),c.__webglMultisampledFramebuffer&&a.deleteFramebuffer(c.__webglMultisampledFramebuffer),c.__webglColorRenderbuffer&&a.deleteRenderbuffer(c.__webglColorRenderbuffer),c.__webglDepthRenderbuffer&&a.deleteRenderbuffer(c.__webglDepthRenderbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function n(a,b){var e=d.get(a); +if(a.isVideoTexture){var f=g.render.frame;B.get(a)!==f&&(B.set(a,f),a.update())}if(0q;q++)z[q]=h||e?e?b.image[q].image:b.image[q]:k(b.image[q],!1,!0,I);var r=z[0],t=m(r)||Ba,n=f.convert(b.format),F=f.convert(b.type),w=u(b.internalFormat,n,F);v(34067,b,t);if(h){for(q=0;6>q;q++){var x=z[q].mipmaps;for(h=0;hq;q++)if(e)for(c.texImage2D(34069+q,0,w,z[q].width,z[q].height,0,n,F,z[q].data),h=0;h=Fa&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+Fa);N+=1;return a};this.resetTextureUnits=function(){N=0};this.setTexture2D=n;this.setTexture2DArray=function(a,b){var e=d.get(a);0z;z++)e.__webglFramebuffer[z]=a.createFramebuffer();else if(e.__webglFramebuffer=a.createFramebuffer(),z)if(Ba){e.__webglMultisampledFramebuffer=a.createFramebuffer();e.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161, +e.__webglColorRenderbuffer);z=f.convert(b.texture.format);var r=f.convert(b.texture.type);z=u(b.texture.internalFormat,z,r);r=D(b);a.renderbufferStorageMultisample(36161,r,z,b.width,b.height);a.bindFramebuffer(36160,e.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,e.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);b.depthBuffer&&(e.__webglDepthRenderbuffer=a.createRenderbuffer(),y(e.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); +if(k){c.bindTexture(34067,h.__webglTexture);v(34067,b.texture,q);for(z=0;6>z;z++)C(e.__webglFramebuffer[z],b,36064,34069+z);l(b.texture,q)&&p(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,h.__webglTexture),v(3553,b.texture,q),C(e.__webglFramebuffer,b,36064,3553),l(b.texture,q)&&p(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){e=d.get(b);h=!0===b.isWebGLCubeRenderTarget;if(b.depthTexture){if(h)throw Error("target.depthTexture not supported in Cube render targets"); +if(b&&b.isWebGLCubeRenderTarget)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(36160,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0); +n(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(36160,36096,3553,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,e,0);else throw Error("Unknown depthTexture format");}else if(h)for(e.__webglDepthbuffer=[],h=0;6>h;h++)a.bindFramebuffer(36160,e.__webglFramebuffer[h]),e.__webglDepthbuffer[h]=a.createRenderbuffer(),y(e.__webglDepthbuffer[h],b,!1);else a.bindFramebuffer(36160,e.__webglFramebuffer),e.__webglDepthbuffer= +a.createRenderbuffer(),y(e.__webglDepthbuffer,b,!1);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,e=m(a)||Ba;if(l(b,e)){e=a.isWebGLCubeRenderTarget?34067:3553;var f=d.get(b).__webglTexture;c.bindTexture(e,f);p(e,b,a.width,a.height);c.bindTexture(e,null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(Ba){var c=d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer); +var e=b.width,f=b.height,g=16384;b.depthBuffer&&(g|=256);b.stencilBuffer&&(g|=1024);a.blitFramebuffer(0,0,e,f,0,0,e,f,g,9728);a.bindFramebuffer(36160,c.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(a,b){a&&a.isWebGLRenderTarget&&(!1===P&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),P=!0),a=a.texture); +n(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLCubeRenderTarget&&(!1===L&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),L=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?x(a,b):w(a,b)}}function Wh(a,b,c){var d=c.isWebGL2;return{convert:function(a){if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120; +if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(d)return 5131;var c=b.get("OES_texture_half_float");return null!==c?c.HALF_FLOAT_OES:null}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(1029===a)return 36244;if(1030===a)return 33319;if(1031===a)return 33320;if(1032=== +a)return 36248;if(1033===a)return 36249;if(33776===a||33777===a||33778===a||33779===a)if(c=b.get("WEBGL_compressed_texture_s3tc"),null!==c){if(33776===a)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(35840===a||35841===a||35842===a||35843===a)if(c=b.get("WEBGL_compressed_texture_pvrtc"),null!==c){if(35840===a)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; +if(35841===a)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(36196===a)return c=b.get("WEBGL_compressed_texture_etc1"),null!==c?c.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===a||37496===a)if(c=b.get("WEBGL_compressed_texture_etc"),null!==c){if(37492===a)return c.COMPRESSED_RGB8_ETC2;if(37496===a)return c.COMPRESSED_RGBA8_ETC2_EAC}if(37808===a||37809===a||37810===a||37811===a||37812=== +a||37813===a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a||37840===a||37841===a||37842===a||37843===a||37844===a||37845===a||37846===a||37847===a||37848===a||37849===a||37850===a||37851===a||37852===a||37853===a)return c=b.get("WEBGL_compressed_texture_astc"),null!==c?a:null;if(36492===a)return c=b.get("EXT_texture_compression_bptc"),null!==c?a:null;if(1020===a){if(d)return 34042;c=b.get("WEBGL_depth_texture");return null!==c?c.UNSIGNED_INT_24_8_WEBGL:null}}}} +function Ke(a){ba.call(this);this.cameras=a||[]}function Jc(){E.call(this);this.type="Group"}function Le(){this._grip=this._targetRay=null}function Xh(a,b){function c(a){var b=q.get(a.inputSource);b&&b.dispatchEvent({type:a.type})}function d(){q.forEach(function(a,b){a.disconnect(b)});q.clear();a.setFramebuffer(null);a.setRenderTarget(a.getRenderTarget());D.stop();h.isPresenting=!1;h.dispatchEvent({type:"sessionend"})}function e(a){l=a;D.setContext(k);D.start();h.isPresenting=!0;h.dispatchEvent({type:"sessionstart"})} +function f(a){for(var b=k.inputSources,c=0;cf.matrixWorld.determinant(),k=u(a,c,e,f);Y.setMaterial(e,h);var m=!1;if(b!==d.id||fa!==k.id||Je!==(!0===e.wireframe))b=d.id,fa=k.id,Je=!0===e.wireframe,m=!0;if(e.morphTargets||e.morphNormals)ya.update(f,d,e,k),m=!0;!0===f.isInstancedMesh&&(m=!0);a=d.index;c=d.attributes.position;if(null===a){if(void 0===c||0===c.count)return}else if(0===a.count)return;var p=1;!0===e.wireframe&&(a=wa.getWireframeAttribute(d), +p=2);h=Aa;if(null!==a){var l=la.get(a);h=Ca;h.setIndex(l)}if(m){if(!1!==Ga.isWebGL2||!f.isInstancedMesh&&!d.isInstancedBufferGeometry||null!==ra.get("ANGLE_instanced_arrays")){Y.initAttributes();m=d.attributes;k=k.getAttributes();var z=e.defaultAttributeValues;for(ha in k){var q=k[ha];if(0<=q){var r=m[ha];if(void 0!==r){var t=r.normalized,n=r.itemSize,w=la.get(r);if(void 0!==w){var F=w.buffer,x=w.type;w=w.bytesPerElement;if(r.isInterleavedBufferAttribute){var v=r.data,C=v.stride;r=r.offset;v&&v.isInstancedInterleavedBuffer? +(Y.enableAttributeAndDivisor(q,v.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=v.meshPerAttribute*v.count)):Y.enableAttribute(q);H.bindBuffer(34962,F);Y.vertexAttribPointer(q,n,x,t,C*w,r*w)}else r.isInstancedBufferAttribute?(Y.enableAttributeAndDivisor(q,r.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=r.meshPerAttribute*r.count)):Y.enableAttribute(q),H.bindBuffer(34962,F),Y.vertexAttribPointer(q,n,x,t,0,0)}}else if("instanceMatrix"===ha)w=la.get(f.instanceMatrix), +void 0!==w&&(F=w.buffer,x=w.type,Y.enableAttributeAndDivisor(q+0,1),Y.enableAttributeAndDivisor(q+1,1),Y.enableAttributeAndDivisor(q+2,1),Y.enableAttributeAndDivisor(q+3,1),H.bindBuffer(34962,F),H.vertexAttribPointer(q+0,4,x,!1,64,0),H.vertexAttribPointer(q+1,4,x,!1,64,16),H.vertexAttribPointer(q+2,4,x,!1,64,32),H.vertexAttribPointer(q+3,4,x,!1,64,48));else if(void 0!==z&&(t=z[ha],void 0!==t))switch(t.length){case 2:H.vertexAttrib2fv(q,t);break;case 3:H.vertexAttrib3fv(q,t);break;case 4:H.vertexAttrib4fv(q, +t);break;default:H.vertexAttrib1fv(q,t)}}}Y.disableUnusedAttributes()}null!==a&&H.bindBuffer(34963,l.buffer)}var ha=d.drawRange.start*p;m=null!==g?g.start*p:0;l=Math.max(ha,m);g=Math.max(0,Math.min(null!==a?a.count:c.count,ha+d.drawRange.count*p,m+(null!==g?g.count*p:Infinity))-1-l+1);0!==g&&(f.isMesh?!0===e.wireframe?(Y.setLineWidth(e.wireframeLinewidth*(null===L?R:1)),h.setMode(1)):h.setMode(4):f.isLine?(e=e.linewidth,void 0===e&&(e=1),Y.setLineWidth(e*(null===L?R:1)),f.isLineSegments?h.setMode(1): +f.isLineLoop?h.setMode(2):h.setMode(3)):f.isPoints?h.setMode(0):f.isSprite&&h.setMode(4),f.isInstancedMesh?h.renderInstances(d,l,g,f.count):d.isInstancedBufferGeometry?h.renderInstances(d,l,g,d.maxInstancedCount):h.render(l,g))};this.compile=function(a,b){A=va.get(a,b);A.init();a.traverse(function(a){a.isLight&&(A.pushLight(a),a.castShadow&&A.pushShadow(a))});A.setupLights(b);var c={};a.traverse(function(b){if(b.material)if(Array.isArray(b.material))for(var d=0;de.far||f.push({distance:a,distanceToRay:Math.sqrt(h),point:c,index:b,face:null,object:g}))}function qg(a,b,c,d,e,f,g,h,k){V.call(this,a,b,c,d,e,f,g,h,k);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1}function Nc(a,b,c,d,e,f,g,h,k,m,l,p){V.call(this,null,f,g,h,k,m,d,e,l,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Od(a,b,c,d,e,f,g,h,k){V.call(this, +a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function Pd(a,b,c,d,e,f,g,h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);V.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Oc(a){B.call(this);this.type="WireframeGeometry";var b= +[],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&a.isGeometry){var k=a.faces;var m=0;for(d=k.length;mc;c++){var p=l[h[c]];var u=l[h[(c+1)%3]];f[0]=Math.min(p,u);f[1]=Math.max(p,u);p=f[0]+","+f[1];void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]})}}for(p in g)m=g[p],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new n,null!==a.index){k=a.attributes.position;l=a.index;var r=a.groups;0===r.length&&(r=[{start:0, +count:l.count,materialIndex:0}]);a=0;for(e=r.length;ac;c++)p=l.getX(m+c),u=l.getX(m+(c+1)%3),f[0]=Math.min(p,u),f[1]=Math.max(p,u),p=f[0]+","+f[1],void 0===g[p]&&(g[p]={index1:f[0],index2:f[1]});for(p in g)m=g[p],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d=k.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x, +h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.setAttribute("position",new y(b,3))}function Qd(a,b,c){O.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Pc(a,b,c));this.mergeVertices()}function Pc(a,b,c){B.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n,k=new n,m=new n,l=new n,p=new n,u,r;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter."); +var q=b+1;for(u=0;u<=c;u++){var t=u/c;for(r=0;r<=b;r++){var F=r/b;a(F,t,k);e.push(k.x,k.y,k.z);0<=F-1E-5?(a(F-1E-5,t,m),l.subVectors(k,m)):(a(F+1E-5,t,m),l.subVectors(m,k));0<=t-1E-5?(a(F,t-1E-5,m),p.subVectors(k,m)):(a(F,t+1E-5,m),p.subVectors(m,k));h.crossVectors(l,p).normalize();f.push(h.x,h.y,h.z);g.push(F,t)}}for(u=0;ud&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}B.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a, +indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.setAttribute("position",new y(h,3));this.setAttribute("normal",new y(h.slice(),3));this.setAttribute("uv",new y(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Sd(a, +b){O.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qc(a,b));this.mergeVertices()}function Qc(a,b){Ea.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Td(a,b){O.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new ac(a,b));this.mergeVertices()}function ac(a,b){Ea.call(this,[1,0,0, +-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Ud(a,b){O.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rc(a,b));this.mergeVertices()}function Rc(a,b){var c=(1+Math.sqrt(5))/2;Ea.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5, +11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Vd(a,b){O.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sc(a,b));this.mergeVertices()}function Sc(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;Ea.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c, +0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Wd(a,b,c,d,e,f){O.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d, +closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new bc(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function bc(a,b,c,d,e){function f(e){l=a.getPointAt(e/b,l);var f=g.normals[e];e=g.binormals[e];for(u=0;u<=d;u++){var m=u/d*Math.PI*2,p=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+p*e.x;k.y=m*f.y+p*e.y;k.z=m*f.z+p*e.z;k.normalize();q.push(k.x,k.y,k.z);h.x=l.x+c*k.x;h.y=l.y+c*k.y;h.z= +l.z+c*k.z;r.push(h.x,h.y,h.z)}}B.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,k=new n,m=new v,l=new n,p,u,r=[],q=[],t=[],F=[];for(p=0;p=b;e-=d)f=ai(e,a[e],a[e+1],f);f&&Te(f,f.next)&&(Zd(f),f=f.next);return f}function Lb(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!Te(a,a.next)&&0!==Q(a.prev,a,a.next))a=a.next;else{Zd(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b} +function $d(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=rg(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,l,p,u,r=1;do{k=h;var q=h=null;for(l=0;k;){l++;var n=k;for(m=p=0;mr!==q.next.y>r&&q.next.y!==q.y&&p<(q.next.x-q.x)*(r-q.y)/(q.next.y-q.y)+q.x&&(l=!l),q=q.next;while(q!==k);q=l}q=q&&(Q(k.prev,k,n.prev)||Q(k,n.prev,n))||Te(k,n)&&0a.x?e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,h=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,k=rg(e.x=k&&d&&d.z<=b;){if(c!==a.prev&&c!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y, +c.x,c.y)&&0<=Q(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=Q(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=k;){if(c!==a.prev&&c!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=Q(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=Q(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function Dk(a,b){return a.x-b.x}function Ek(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&& +e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x=c.x&&c.x>=g&&d!==c.x&&Vc(eh.x)&&(p=c.x===h.x)){p=h;var u=c;p=0>Q(p.prev,p,u.prev)&&0>Q(u.next,p,p.next)}p&& +(h=c,m=l)}c=c.next}while(c!==b);return h}function rg(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function Fk(a){var b=a,c=a;do{if(b.x=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function Ue(a){return 0a?-1:0}function ae(a,b){return 0>Q(a.prev,a,a.next)?0<=Q(a,b,a.next)&&0<= +Q(a,a.prev,b):0>Q(a,b,a.prev)||0>Q(a,a.next,b)}function ci(a,b){var c=new sg(a.i,a.x,a.y),d=new sg(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function ai(a,b,c,d){a=new sg(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function Zd(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function sg(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ= +this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function di(a){var b=a.length;2Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new v(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new v(f/e,d/ +e)}function h(a,b){for(K=a.length;0<=--K;){var c=K;var f=K-1;0>f&&(f=a.length-1);var g,h=w+2*y;for(g=0;gl;l++){var p=m[f[l]];var u=m[f[(l+1)%3]];d[0]=Math.min(p,u);d[1]=Math.max(p,u);p=d[0]+","+d[1];void 0===e[p]?e[p]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[p].face2=h}for(p in e)if(d=e[p],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.setAttribute("position",new y(c,3))}function gc(a,b,c,d,e,f,g,h){O.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d, +heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new sb(a,b,c,d,e,f,g,h));this.mergeVertices()}function sb(a,b,c,d,e,f,g,h){function k(c){var e,f=new v,k=new n,z=0,t=!0===c?a:b,w=!0===c?1:-1;var A=q;for(e=1;e<=d;e++)p.push(0,F*w,0),u.push(0,w,0),r.push(.5,.5),q++;var y=q;for(e=0;e<=d;e++){var B=e/d*h+g,D=Math.cos(B);B=Math.sin(B);k.x=t*B;k.y=F*w;k.z=t*D;p.push(k.x,k.y,k.z);u.push(0,w,0);f.x=.5*D+.5;f.y=.5*B*w+.5;r.push(f.x,f.y);q++}for(e=0;ethis.duration&&this.resetDuration()}function Hk(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ad; +case "vector":case "vector2":case "vector3":case "vector4":return bd;case "color":return Ze;case "quaternion":return je;case "bool":case "boolean":return Ye;case "string":return af}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Ik(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Hk(a.type);if(void 0===a.times){var c=[],d=[];ka.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name, +a.times,a.values,a.interpolation)}function tg(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0,k=[];this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h= +a;return this};this.addHandler=function(a,b){k.push(a,b);return this};this.removeHandler=function(a){a=k.indexOf(a);-1!==a&&k.splice(a,2);return this};this.getHandler=function(a){for(var b=0,c=k.length;ba;a++)this.coefficients.push(new n)}function Ra(a,b){S.call(this,void 0,b);this.type="LightProbe";this.sh=void 0!==a?a:new nf}function of(a){X.call(this,a);this.textures={}}function pf(){B.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function qf(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));N.call(this,a,b,c);this.meshPerAttribute=d||1}function rf(a){X.call(this, +a)}function sf(a){X.call(this,a)}function yg(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");X.call(this,a);this.options=void 0}function zg(){this.type="ShapePath";this.color=new A;this.subPaths=[];this.currentPath=null}function Ag(a){this.type="Font";this.data=a}function Bg(a){X.call(this,a)}function tf(a){X.call(this,a)}function Cg(a, +b,c){Ra.call(this,void 0,c);a=(new A).set(a);c=(new A).set(b);b=new n(a.r,a.g,a.b);a=new n(c.r,c.g,c.b);c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function Dg(a,b){Ra.call(this,void 0,b);a=(new A).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}function ji(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new ba;this.cameraL.layers.enable(1); +this.cameraL.matrixAutoUpdate=!1;this.cameraR=new ba;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Eg(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Fg(){E.call(this);this.type="AudioListener";this.context=Gg.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta= +0;this._clock=new Eg}function fd(a){E.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.loopEnd=this.loopStart=0;this.duration=void 0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this._progress=this._startedAt=0;this.filters=[]}function Hg(a){fd.call(this,a);this.panner=this.context.createPanner(); +this.panner.panningModel="HRTF";this.panner.connect(this.gain)}function Ig(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function Jg(a,b,c){this.binding=a;this.valueSize=c;switch(b){case "quaternion":a=this._slerp;b=this._slerpAdditive;var d=this._setAdditiveIdentityQuaternion;this.buffer=new Float64Array(6*c);this._workIndex=5;break;case "string":case "bool":b=a= +this._select;d=this._setAdditiveIdentityOther;this.buffer=Array(5*c);break;default:a=this._lerp,b=this._lerpAdditive,d=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*c)}this._mixBufferRegion=a;this._mixBufferRegionAdditive=b;this._setIdentity=d;this._origIndex=3;this._addIndex=4;this.referenceCount=this.useCount=this.cumulativeWeightAdditive=this.cumulativeWeight=0}function ki(a,b,c){c=c||ya.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function ya(a,b,c){this.path= +b;this.parsedPath=c||ya.parseTrackName(b);this.node=ya.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function li(){this.uuid=M.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total- +d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function mi(a,b,c,d){this._mixer=a;this._clip=b;this._localRoot=c||null;this.blendMode=d||b.blendMode;a=b.tracks;b=a.length;c=Array(b);d={endingStart:2400,endingEnd:2400};for(var e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop= +2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Kg(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function uf(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Lg(a,b,c){qb.call(this, +a,b);this.meshPerAttribute=c||1}function Mg(a,b,c,d){this.ray=new Wb(a,b);this.near=c||0;this.far=d||Infinity;this.camera=null;this.layers=new Ce;this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function ni(a,b){return a.distance-b.distance}function Ng(a,b,c,d){a.layers.test(b.layers)&&a.raycast(b, +c);if(!0===d){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.setAttribute("position",new y(b,3));b=new da({fog:!1,toneMapped:!1});this.cone=new na(a,b);this.add(this.cone);this.update()} +function qi(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c\n\nvec3 getSample(float theta, vec3 axis) {\n\tfloat cosTheta = cos(theta);\n\t// Rodrigues' axis-angle rotation\n\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\treturn bilinearCubeUV(envMap, sampleDirection, mipInt);\n}\n\nvoid main() {\n\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\tif (all(equal(axis, vec3(0.0))))\n\t\taxis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\taxis = normalize(axis);\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\tfor (int i = 1; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfloat theta = dTheta * float(i);\n\t\tgl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n\t\tgl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1});a.type="SphericalGaussianBlur";this._blurMaterial=a;this._cubemapShader=this._equirectShader=null;this._compileMaterial(this._blurMaterial)}function ri(a){a=new za(3*lb,3*lb,a);a.texture.mapping=306;a.texture.name="PMREM.cubeUv";a.scissorTest=!0;return a}function Ug(a,b,c,d,e){a.viewport.set(b,c,d,e);a.scissor.set(b,c,d,e)}function si(){var a=new v(1,1);a=new tb({uniforms:{envMap:{value:null},texelSize:{value:a},inputEncoding:{value:kb[3E3]},outputEncoding:{value:kb[3E3]}}, +vertexShader:Sg(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n"+Tg()+"\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1});a.type="EquirectangularToCubeUV";return a}function ti(){var a=new tb({uniforms:{envMap:{value:null},inputEncoding:{value:kb[3E3]},outputEncoding:{value:kb[3E3]}},vertexShader:Sg(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n"+Tg()+"\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t", +blending:0,depthTest:!1,depthWrite:!1});a.type="CubemapToCubeUV";return a}function Sg(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"} +function Tg(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include \n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"} +function ui(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");pa.call(this,a);this.type="catmullrom";this.closed=!0}function vi(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");pa.call(this,a);this.type="catmullrom"}function Vg(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");pa.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2, -52));void 0===Number.isInteger&&(Number.isInteger=function(a){return"number"===typeof a&&isFinite(a)&&Math.floor(a)===a});void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0ze;ze++)ya[ze]=(16>ze?"0":"")+ze.toString(16);var O={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()| -0,d=4294967295*Math.random()|0;return(ya[a&255]+ya[a>>8&255]+ya[a>>16&255]+ya[a>>24&255]+"-"+ya[b&255]+ya[b>>8&255]+"-"+ya[b>>16&15|64]+ya[b>>24&255]+"-"+ya[c&63|128]+ya[c>>8&255]+"-"+ya[c>>16&255]+ya[c>>24&255]+ya[d&255]+ya[d>>8&255]+ya[d>>16&255]+ya[d>>24&255]).toUpperCase()},clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a, -b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*O.DEG2RAD},radToDeg:function(a){return a*O.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2, -Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}};Object.defineProperties(x.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(x.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this}, -setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), +Object(a),c=1;cre;re++)ta[re]=(16>re?"0":"")+re.toString(16);var M={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()| +0,d=4294967295*Math.random()|0;return(ta[a&255]+ta[a>>8&255]+ta[a>>16&255]+ta[a>>24&255]+"-"+ta[b&255]+ta[b>>8&255]+"-"+ta[b>>16&15|64]+ta[b>>24&255]+"-"+ta[c&63|128]+ta[c>>8&255]+"-"+ta[c>>16&255]+ta[c>>24&255]+ta[d&255]+ta[d>>8&255]+ta[d>>16&255]+ta[d>>24&255]).toUpperCase()},clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a, +b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*M.DEG2RAD},radToDeg:function(a){return a*M.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2, +Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},setQuaternionFromProperEuler:function(a,b,c,d,e){var f=Math.cos,g=Math.sin,h=f(c/2);c=g(c/2);var k=f((b+d)/2),m=g((b+d)/2),l=f((b-d)/2),p=g((b-d)/2);f=f((d-b)/2);b=g((d-b)/2);switch(e){case "XYX":a.set(h*m,c*l,c*p,h*k);break;case "YZY":a.set(c*p,h*m,c*l,h*k);break;case "ZXZ":a.set(c*l,c*p,h*m,h*k);break;case "XZX":a.set(h*m,c*b,c*f,h*k);break;case "YXY":a.set(c*f,h*m,c*b,h*k);break;case "ZYZ":a.set(c* +b,c*f,h*m,h*k);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+e)}}};Object.defineProperties(v.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(v.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y= +a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this}, subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this}, max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},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=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x* -this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+ -Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a, -b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(Da,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var k=c[d+0],l=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var h=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||k!==d||l!==h||m!== -p){f=1-g;var q=k*d+l*h+m*p+c*e,n=0<=q?1:-1,r=1-q*q;r>Number.EPSILON&&(r=Math.sqrt(r),q=Math.atan2(r,q*n),f=Math.sin(f*q)/r,g=Math.sin(g*q)/r);n*=g;k=k*f+d*n;l=l*f+h*n;m=m*f+p*n;c=c*f+e*n;f===1-g&&(g=1/Math.sqrt(k*k+l*l+m*m+c*c),k*=g,l*=g,m*=g,c*=g)}a[b]=k;a[b+1]=l;a[b+2]=m;a[b+3]=c}});Object.defineProperties(Da.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z}, -set:function(a){this._z=a;this._onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=a;this._onChangeCallback()}}});Object.assign(Da.prototype,{isQuaternion:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this._onChangeCallback();return this},setFromEuler:function(a,b){if(!a|| -!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,k=f(c/2),l=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*l*f+k*d*e,this._y=k*d*f-c*l*e,this._z=k*l*e+c*d*f,this._w=k*l*f-c*d*e):"YXZ"===a?(this._x=c*l*f+k*d*e,this._y=k*d*f-c*l*e,this._z=k*l*e-c*d*f,this._w=k*l*f+c*d*e):"ZXY"===a?(this._x=c*l*f-k*d*e,this._y=k*d*f+c*l*e,this._z=k*l*e+c*d*f,this._w= -k*l*f-c*d*e):"ZYX"===a?(this._x=c*l*f-k*d*e,this._y=k*d*f+c*l*e,this._z=k*l*e-c*d*f,this._w=k*l*f+c*d*e):"YZX"===a?(this._x=c*l*f+k*d*e,this._y=k*d*f+c*l*e,this._z=k*l*e-c*d*f,this._w=k*l*f-c*d*e):"XZY"===a&&(this._x=c*l*f-k*d*e,this._y=k*d*f-c*l*e,this._z=k*l*e+c*d*f,this._w=k*l*f+c*d*e);!1!==b&&this._onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this._onChangeCallback();return this},setFromRotationMatrix:function(a){var b= -a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],k=b[2],l=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(l-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+k)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-k)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+l)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+k)/c,this._y=(g+l)/c,this._z=.25*c);this._onChangeCallback();return this},setFromUnitVectors:function(a, -b){var c=a.dot(b)+1;1E-6>c?(c=0,Math.abs(a.x)>Math.abs(a.z)?(this._x=-a.y,this._y=a.x,this._z=0):(this._x=0,this._y=-a.z,this._z=a.y)):(this._x=a.y*b.z-a.z*b.y,this._y=a.z*b.x-a.x*b.z,this._z=a.x*b.y-a.y*b.x);this._w=c;return this.normalize()},angleTo:function(a){return 2*Math.acos(Math.abs(O.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*= --1;this._y*=-1;this._z*=-1;this._onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this._onChangeCallback();return this}, -multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,k=b._z;b=b._w;this._x=c*b+a*f+d*k-e*g;this._y=d*b+a*g+e*f-c*k;this._z=e*b+a*k+c*g-d*f;this._w=a*b-c*f-d*g-e*k;this._onChangeCallback(); -return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize(),this._onChangeCallback(),this;a=Math.sqrt(a);var k=Math.atan2(a, -g);g=Math.sin((1-b)*k)/a;b=Math.sin(b*k)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this._onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+ -3]=this._w;return a},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});var $g=new n,Ei=new Da;Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z= -b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a, -b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-= -a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this}, -applyEuler:function(a){a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(Ei.setFromEuler(a))},applyAxisAngle:function(a,b){return this.applyQuaternion(Ei.setFromAxisAngle(a,b))},applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyNormalMatrix:function(a){return this.applyMatrix3(a).normalize()}, -applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var k=a*b+f*d-g*c,l=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=k*a+b*-e+l*-g-m*-f;this.y=l*a+b*-f+m*-e-k*-g;this.z=m*a+b*-g+k*-f-l*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)}, +this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y- +a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!== +c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this},random:function(){this.x=Math.random();this.y=Math.random();return this}});Object.assign(xa.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]= +k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},extractBasis:function(a,b,c){a.setFromMatrix3Column(this,0);b.setFromMatrix3Column(this,1);c.setFromMatrix3Column(this,2);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1], +a[5],a[9],a[2],a[6],a[10]);return this},multiply:function(a){return this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[3],f=c[6],g=c[1],h=c[4],k=c[7],m=c[2],l=c[5];c=c[8];var p=d[0],n=d[3],r=d[6],q=d[1],t=d[4],v=d[7],x=d[2],w=d[5];d=d[8];b[0]=a*p+e*q+f*x;b[3]=a*n+e*t+f*w;b[6]=a*r+e*v+f*d;b[1]=g*p+h*q+k*x;b[4]=g*n+h*t+k*w;b[7]=g*r+h*v+k*d;b[2]=m*p+l*q+c*x;b[5]=m*n+l* +t+c*w;b[8]=m*r+l*v+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;b[5]*=a;b[8]*=a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7];a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){void 0!==b&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var c=a.elements;a=this.elements;b=c[0];var d=c[1], +e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7];c=c[8];var l=c*g-h*m,p=h*k-c*f,n=m*f-g*k,r=b*l+d*p+e*n;if(0===r)return this.set(0,0,0,0,0,0,0,0,0);r=1/r;a[0]=l*r;a[1]=(e*m-c*d)*r;a[2]=(h*d-e*g)*r;a[3]=p*r;a[4]=(c*b-e*k)*r;a[5]=(e*f-h*b)*r;a[6]=n*r;a[7]=(d*k-m*b)*r;a[8]=(g*b-d*f)*r;return this},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[3];a[3]=b;b=a[2];a[2]=a[6];a[6]=b;b=a[5];a[5]=a[7];a[7]=b;return this},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()}, +transposeIntoArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this},setUvTransform:function(a,b,c,d,e,f,g){var h=Math.cos(e);e=Math.sin(e);this.set(c*h,c*e,-c*(h*f+e*g)+f+a,-d*e,d*h,-d*(-e*f+h*g)+g+b,0,0,1)},scale:function(a,b){var c=this.elements;c[0]*=a;c[3]*=a;c[6]*=a;c[1]*=b;c[4]*=b;c[7]*=b;return this},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);var c=this.elements,d=c[0],e=c[3],f=c[6],g=c[1],h=c[4], +k=c[7];c[0]=b*d+a*g;c[3]=b*e+a*h;c[6]=b*f+a*k;c[1]=-a*d+b*g;c[4]=-a*e+b*h;c[7]=-a*f+b*k;return this},translate:function(a,b){var c=this.elements;c[0]+=a*c[2];c[3]+=a*c[5];c[6]+=a*c[8];c[1]+=b*c[2];c[4]+=b*c[5];c[7]+=b*c[8];return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;9>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c= +this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var kd,Ob={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===kd&&(kd=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));kd.width=a.width;kd.height=a.height;var b=kd.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=kd}return 2048< +a.width||2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(V.prototype, +"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.defineProperties(ca.prototype,{width:{get:function(){return this.z},set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(ca.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z= +a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x= +a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;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(a,b){this.x+=a.x* +b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;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(a){this.x*=a;this.y*=a;this.z*= +a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a= +a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var k=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+k)/4;b>f&&b>m?.01>b?(k=0,c=h=.707106781):(k=Math.sqrt(b),h=c/k,c=d/k):f>m?.01>f?(k=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),k=c/h,c=g/h):.01>m?(h=k=.707106781,c=0):(c= +Math.sqrt(m),k=d/c,h=g/c);this.set(k,h,c,a);return this}a=Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(k-g)/a;this.y=(d-h)/a;this.z=(e-c)/a;this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a, +b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},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.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y); +this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+ +Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0=== +b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this},random:function(){this.x=Math.random();this.y=Math.random();this.z=Math.random();this.w=Math.random(); +return this}});za.prototype=Object.assign(Object.create(ua.prototype),{constructor:za,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer= +a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Xf.prototype=Object.assign(Object.create(za.prototype),{constructor:Xf,isWebGLMultisampleRenderTarget:!0,copy:function(a){za.prototype.copy.call(this,a);this.samples=a.samples;return this}});Object.assign(la,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l= +e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==p){f=1-g;var n=h*d+k*l+m*p+c*e,r=0<=n?1:-1,q=1-n*n;q>Number.EPSILON&&(q=Math.sqrt(q),n=Math.atan2(q,n*r),f=Math.sin(f*n)/q,g=Math.sin(g*n)/q);r*=g;h=h*f+d*r;k=k*f+l*r;m=m*f+p*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c},multiplyQuaternionsFlat:function(a,b,c,d,e,f){var g=c[d],h=c[d+1],k=c[d+2];c=c[d+3];d=e[f];var m=e[f+1],l=e[f+2];e=e[f+3];a[b]=g*e+c*d+h*l-k*m;a[b+1]=h*e+c*m+k*d-g* +l;a[b+2]=k*e+c*l+g*m-h*d;a[b+3]=c*e-g*d-h*m-k*l;return a}});Object.defineProperties(la.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this._onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=a;this._onChangeCallback()}}});Object.assign(la.prototype,{isQuaternion:!0,set:function(a, +b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this._onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2); +f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);switch(a){case "XYZ":this._x=c*k*f+h*d*e;this._y=h*d*f-c*k*e;this._z=h*k*e+c*d*f;this._w=h*k*f-c*d*e;break;case "YXZ":this._x=c*k*f+h*d*e;this._y=h*d*f-c*k*e;this._z=h*k*e-c*d*f;this._w=h*k*f+c*d*e;break;case "ZXY":this._x=c*k*f-h*d*e;this._y=h*d*f+c*k*e;this._z=h*k*e+c*d*f;this._w=h*k*f-c*d*e;break;case "ZYX":this._x=c*k*f-h*d*e;this._y=h*d*f+c*k*e;this._z=h*k*e-c*d*f;this._w=h*k*f+c*d*e;break;case "YZX":this._x=c*k*f+h*d*e;this._y=h*d*f+c*k*e;this._z=h*k*e-c* +d*f;this._w=h*k*f-c*d*e;break;case "XZY":this._x=c*k*f-h*d*e;this._y=h*d*f-c*k*e;this._z=h*k*e+c*d*f;this._w=h*k*f+c*d*e;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}!1!==b&&this._onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this._onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1], +f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this._onChangeCallback();return this},setFromUnitVectors:function(a,b){var c=a.dot(b)+1;1E-6> +c?(c=0,Math.abs(a.x)>Math.abs(a.z)?(this._x=-a.y,this._y=a.x,this._z=0):(this._x=0,this._y=-a.z,this._z=a.y)):(this._x=a.y*b.z-a.z*b.y,this._y=a.z*b.x-a.x*b.z,this._z=a.x*b.y-a.y*b.x);this._w=c;return this.normalize()},angleTo:function(a){return 2*Math.acos(Math.abs(M.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*= +-1;this._onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this._onChangeCallback();return this},multiply:function(a, +b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this._onChangeCallback();return this}, +slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize(),this._onChangeCallback(),this;a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1- +b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this._onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a}, +fromBufferAttribute:function(a,b){this._x=a.getX(b);this._y=a.getY(b);this._z=a.getZ(b);this._w=a.getW(b);return this},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});var Wg=new n,wi=new la;Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this}, +setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), +this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z; +return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x* +b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(a){a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(wi.setFromEuler(a))},applyAxisAngle:function(a,b){return this.applyQuaternion(wi.setFromAxisAngle(a,b))},applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyNormalMatrix:function(a){return this.applyMatrix3(a).normalize()}, +applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)}, unproject:function(a){return this.applyMatrix4(a.projectionMatrixInverse).applyMatrix4(a.matrixWorld)},transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z, a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c|| 1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z= 0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)}, lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this}, -projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(a){$g.copy(this).projectOnVector(a);return this.sub($g)},reflect:function(a){return this.sub($g.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){var b=Math.sqrt(this.lengthSq()*a.lengthSq());0===b&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");a=this.dot(a)/b;return Math.acos(O.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))}, +projectOnVector:function(a){var b=a.lengthSq();if(0===b)return this.set(0,0,0);b=a.dot(this)/b;return this.copy(a).multiplyScalar(b)},projectOnPlane:function(a){Wg.copy(this).projectOnVector(a);return this.sub(Wg)},reflect:function(a){return this.sub(Wg.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){var b=Math.sqrt(this.lengthSq()*a.lengthSq());if(0===b)return Math.PI/2;a=this.dot(a)/b;return Math.acos(M.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))}, distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){return this.setFromSphericalCoords(a.radius,a.phi,a.theta)},setFromSphericalCoords:function(a,b,c){var d=Math.sin(b)*a;this.x=d*Math.sin(c);this.y=Math.cos(b)*a;this.z=d*Math.cos(c);return this},setFromCylindrical:function(a){return this.setFromCylindricalCoords(a.radius,a.theta, -a.y)},setFromCylindricalCoords:function(a,b,c){this.x=a*Math.sin(b);this.y=c;this.z=a*Math.cos(b);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z=a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x=== -this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});var tc=new n;Object.assign(za.prototype,{isMatrix3:!0,set:function(a, -b,c,d,e,f,g,k,l){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=k;m[6]=c;m[7]=f;m[8]=l;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this}, -applyToBufferAttribute:function(a){for(var b=0,c=a.count;bc;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var nd,Mb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===nd&&(nd=document.createElementNS("http://www.w3.org/1999/xhtml", -"canvas"));nd.width=a.width;nd.height=a.height;var b=nd.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=nd}return 2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0> -a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(T.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.defineProperties(S.prototype,{width:{get:function(){return this.z},set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(S.prototype, -{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x; -case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this}, -addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;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(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-= -a;this.y-=a;this.z-=a;this.w-=a;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(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/ -a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var k=a[2];var l=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-k)&&.01>Math.abs(g-l)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+k)&&.1>Math.abs(g+l)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI; -b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+k)/4;g=(g+l)/4;b>f&&b>m?.01>b?(l=0,c=k=.707106781):(l=Math.sqrt(b),k=c/l,c=d/l):f>m?.01>f?(l=.707106781,k=0,c=.707106781):(k=Math.sqrt(f),l=c/k,c=g/k):.01>m?(k=l=.707106781,c=0):(c=Math.sqrt(m),l=d/c,k=g/c);this.set(l,k,c,a);return this}a=Math.sqrt((l-g)*(l-g)+(d-k)*(d-k)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(l-g)/a;this.y=(d-k)/a;this.z=(e-c)/a;this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y, -a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b, -this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},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.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x= -Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z* -a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z- -this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."); -this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});va.prototype=Object.assign(Object.create(Fa.prototype),{constructor:va,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport); -this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Zf.prototype=Object.assign(Object.create(va.prototype),{constructor:Zf,isWebGLMultisampleRenderTarget:!0,copy:function(a){va.prototype.copy.call(this,a);this.samples=a.samples;return this}});var Ma=new n,W=new P,Ok=new n(0,0,0),Pk=new n(1,1,1),Nb=new n,Cf=new n,ka=new n;Object.assign(P.prototype,{isMatrix4:!0, -set:function(a,b,c,d,e,f,g,k,l,m,h,p,q,n,r,u){var v=this.elements;v[0]=a;v[4]=b;v[8]=c;v[12]=d;v[1]=e;v[5]=f;v[9]=g;v[13]=k;v[2]=l;v[6]=m;v[10]=h;v[14]=p;v[3]=q;v[7]=n;v[11]=r;v[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new P).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11]; -b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(a){var b=this.elements,c=a.elements,d=1/Ma.setFromMatrixColumn(a,0).length(), -e=1/Ma.setFromMatrixColumn(a,1).length();a=1/Ma.setFromMatrixColumn(a,2).length();b[0]=c[0]*d;b[1]=c[1]*d;b[2]=c[2]*d;b[3]=0;b[4]=c[4]*e;b[5]=c[5]*e;b[6]=c[6]*e;b[7]=0;b[8]=c[8]*a;b[9]=c[9]*a;b[10]=c[10]*a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d); -d=Math.sin(d);var k=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*k;var l=f*e,m=c*k,h=c*e;b[0]=g*k;b[4]=-g*e;b[8]=d;b[1]=l+m*d;b[5]=a-h*d;b[9]=-c*g;b[2]=h-a*d;b[6]=m+l*d;b[10]=f*g}else"YXZ"===a.order?(a=g*k,l=g*e,m=d*k,h=d*e,b[0]=a+h*c,b[4]=m*c-l,b[8]=f*d,b[1]=f*e,b[5]=f*k,b[9]=-c,b[2]=l*c-m,b[6]=h+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*k,l=g*e,m=d*k,h=d*e,b[0]=a-h*c,b[4]=-f*e,b[8]=m+l*c,b[1]=l+m*c,b[5]=f*k,b[9]=h-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*k,l=f*e,m=c*k,h=c*e,b[0]=g*k, -b[4]=m*d-l,b[8]=a*d+h,b[1]=g*e,b[5]=h*d+a,b[9]=l*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,l=f*d,m=c*g,h=c*d,b[0]=g*k,b[4]=h-a*e,b[8]=m*e+l,b[1]=e,b[5]=f*k,b[9]=-c*k,b[2]=-d*k,b[6]=l*e+m,b[10]=a-h*e):"XZY"===a.order&&(a=f*g,l=f*d,m=c*g,h=c*d,b[0]=g*k,b[4]=-e,b[8]=d*k,b[1]=a*e+h,b[5]=f*k,b[9]=l*e-m,b[2]=m*e-l,b[6]=c*k,b[10]=h*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){return this.compose(Ok,a,Pk)},lookAt:function(a,b, -c){var d=this.elements;ka.subVectors(a,b);0===ka.lengthSq()&&(ka.z=1);ka.normalize();Nb.crossVectors(c,ka);0===Nb.lengthSq()&&(1===Math.abs(c.z)?ka.x+=1E-4:ka.z+=1E-4,ka.normalize(),Nb.crossVectors(c,ka));Nb.normalize();Cf.crossVectors(ka,Nb);d[0]=Nb.x;d[4]=Cf.x;d[8]=ka.x;d[1]=Nb.y;d[5]=Cf.y;d[9]=ka.y;d[2]=Nb.z;d[6]=Cf.z;d[10]=ka.z;return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), -this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],k=c[1],l=c[5],m=c[9],h=c[13],p=c[2],q=c[6],n=c[10],r=c[14],u=c[3],z=c[7],w=c[11];c=c[15];var B=d[0],x=d[4],y=d[8],A=d[12],C=d[1],G=d[5],D=d[9],E=d[13],F=d[2],I=d[6],K=d[10],L=d[14],M=d[3],N=d[7],O=d[11];d=d[15];b[0]=a*B+e*C+f*F+g*M;b[4]=a*x+e*G+f*I+g*N;b[8]=a*y+e*D+f*K+ -g*O;b[12]=a*A+e*E+f*L+g*d;b[1]=k*B+l*C+m*F+h*M;b[5]=k*x+l*G+m*I+h*N;b[9]=k*y+l*D+m*K+h*O;b[13]=k*A+l*E+m*L+h*d;b[2]=p*B+q*C+n*F+r*M;b[6]=p*x+q*G+n*I+r*N;b[10]=p*y+q*D+n*K+r*O;b[14]=p*A+q*E+n*L+r*d;b[3]=u*B+z*C+w*F+c*M;b[7]=u*x+z*G+w*I+c*N;b[11]=u*y+z*D+w*K+c*O;b[15]=u*A+z*E+w*L+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(a){for(var b= -0,c=a.count;bthis.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];W.copy(this);a=1/e;d=1/f;var k=1/g;W.elements[0]*=a;W.elements[1]*=a;W.elements[2]*=a;W.elements[4]*=d;W.elements[5]*=d;W.elements[6]*=d;W.elements[8]*=k;W.elements[9]*=k;W.elements[10]*=k;b.setFromRotationMatrix(W);c.x=e;c.y=f;c.z=g;return this},makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."); -var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,k=1/(b-a),l=1/(c-d),m=1/(f-e);g[0]=2*k;g[4]=0;g[8]=0;g[12]=-((b+a)*k);g[1]=0;g[5]=2*l;g[9]=0;g[13]=-((c+d)*l);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements; -a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});var Fi=new P,Gi=new Da;Ub.RotationOrders= -"XYZ YZX ZXY XZY YXZ ZYX".split(" ");Ub.DefaultOrder="XYZ";Object.defineProperties(Ub.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this._onChangeCallback()}},order:{get:function(){return this._order},set:function(a){this._order=a;this._onChangeCallback()}}});Object.assign(Ub.prototype,{isEuler:!0,set:function(a, -b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=O.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],k=e[1],l=e[5],m=e[9],h=e[2],p=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.9999999>Math.abs(g)? -(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,l),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.9999999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(k,l)):(this._y=Math.atan2(-h,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.9999999>Math.abs(p)?(this._y=Math.atan2(-h,e),this._z=Math.atan2(-f,l)):(this._y=0,this._z=Math.atan2(k,a))):"ZYX"===b?(this._y=Math.asin(-d(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(p,e),this._z=Math.atan2(k,a)): -(this._x=0,this._z=Math.atan2(-f,l))):"YZX"===b?(this._z=Math.asin(d(k,-1,1)),.9999999>Math.abs(k)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.9999999>Math.abs(f)?(this._x=Math.atan2(p,l),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a, -b,c){Fi.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(Fi,b,c)},setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(a){Gi.setFromEuler(this);return this.setFromQuaternion(Gi,a)},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a= -[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new n(this._x,this._y,this._z)},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});Object.assign($f.prototype,{set:function(a){this.mask=1<e&&(e=m);h>f&&(f=h);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,k=0,l=a.count;ke&&(e=h);n>f&&(f=n);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"), -b=new n);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(a){this.clampPoint(a.center,Be);return Be.distanceToSquared(a.center)<=a.radius*a.radius},intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(a){if(this.isEmpty())return!1;this.getCenter(Ce);Ff.subVectors(this.max,Ce);pd.subVectors(a.a,Ce);qd.subVectors(a.b,Ce);rd.subVectors(a.c, -Ce);Ob.subVectors(qd,pd);Pb.subVectors(rd,qd);uc.subVectors(pd,rd);a=[0,-Ob.z,Ob.y,0,-Pb.z,Pb.y,0,-uc.z,uc.y,Ob.z,0,-Ob.x,Pb.z,0,-Pb.x,uc.z,0,-uc.x,-Ob.y,Ob.x,0,-Pb.y,Pb.x,0,-uc.y,uc.x,0];if(!ag(a,pd,qd,rd,Ff))return!1;a=[1,0,0,0,1,0,0,0,1];if(!ag(a,pd,qd,rd,Ff))return!1;Gf.crossVectors(Ob,Pb);a=[Gf.x,Gf.y,Gf.z];return ag(a,pd,qd,rd,Ff)},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return Be.copy(a).clamp(this.min, -this.max).sub(a).length()},getBoundingSphere:function(a){void 0===a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center);a.radius=.5*this.getSize(Be).length();return a},intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(a){if(this.isEmpty())return this;Ab[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a); -Ab[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a);Ab[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);Ab[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a);Ab[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);Ab[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);Ab[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);Ab[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a);this.setFromPoints(Ab);return this},translate:function(a){this.min.add(a);this.max.add(a); -return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var Uk=new Sa;Object.assign(qb.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(a,b){var c=this.center;void 0!==b?c.copy(b):Uk.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;d=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a, -b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new n);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Sa);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a); -this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});var Bb=new n,ah=new n,Hf=new n,Qb=new n,bh=new n,If=new n,ch=new n;Object.assign(Wb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this}, -at:function(a,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new n);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(a){this.origin.copy(this.at(a,Bb));return this},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new n);b.subVectors(a,this.origin);a=b.dot(this.direction);return 0>a? -b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(a){var b=Bb.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);Bb.copy(this.direction).multiplyScalar(b).add(this.origin);return Bb.distanceToSquared(a)},distanceSqToSegment:function(a,b,c,d){ah.copy(a).add(b).multiplyScalar(.5);Hf.copy(b).sub(a).normalize();Qb.copy(this.origin).sub(ah); -var e=.5*a.distanceTo(b),f=-this.direction.dot(Hf),g=Qb.dot(this.direction),k=-Qb.dot(Hf),l=Qb.lengthSq(),h=Math.abs(1-f*f);if(0=-n?b<=n?(e=1/h,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*k)+l):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*k)+l):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*k)+l):b<=-n?(a=Math.max(0,-(-f*e+g)),b=0a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius* -a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z, -f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var k=(a.min.y-f.y)*d;d*=a.max.y-f.y}else k=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||k>c)return null;if(k>g||g!==g)g=k;if(da||k>c)return null;if(k>g||g!==g)g=k;if(ac?null:this.at(0<=g?g:c,b)},intersectsBox:function(a){return null!==this.intersectBox(a,Bb)},intersectTriangle:function(a, -b,c,d,e){bh.subVectors(b,a);If.subVectors(c,a);ch.crossVectors(bh,If);b=this.direction.dot(ch);if(0b)d=-1,b=-b;else return null;Qb.subVectors(this.origin,a);a=d*this.direction.dot(If.crossVectors(Qb,If));if(0>a)return null;c=d*this.direction.dot(bh.cross(Qb));if(0>c||a+c>b)return null;a=-d*Qb.dot(ch);return 0>a?null:this.at(a/b,e)},applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&& -a.direction.equals(this.direction)}});var dh=new n,Vk=new n,Wk=new za;Object.assign(Ta.prototype,{isPlane:!0,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(a,b,c){b=dh.subVectors(c,b).cross(Vk.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b, -a);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a, -b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new n);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(a,b){void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new n);var c=a.delta(dh),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||1b&&0a&&0=Db.x+Db.y},getUV:function(a,b,c,d,e,f,g,k){this.getBarycoord(a,b,c,d,Db);k.set(0,0);k.addScaledVector(e,Db.x);k.addScaledVector(f,Db.y);k.addScaledVector(g,Db.z);return k},isFrontFacing:function(a,b,c,d){bb.subVectors(c,b);Cb.subVectors(a,b);return 0>bb.cross(Cb).dot(d)?!0:!1}});Object.assign(ma.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]); -return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){bb.subVectors(this.c,this.b);Cb.subVectors(this.a,this.b);return.5*bb.cross(Cb).length()},getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ma.getNormal(this.a,this.b, -this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new Ta);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return ma.getBarycoord(a,this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return ma.getUV(a,this.a,this.b,this.c,b,c,d,e)},containsPoint:function(a){return ma.containsPoint(a,this.a,this.b,this.c)},isFrontFacing:function(a){return ma.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)}, -closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new n);var c=this.a,d=this.b,e=this.c;sd.subVectors(d,c);td.subVectors(e,c);fh.subVectors(a,c);var f=sd.dot(fh),g=td.dot(fh);if(0>=f&&0>=g)return b.copy(c);gh.subVectors(a,d);var k=sd.dot(gh),l=td.dot(gh);if(0<=k&&l<=k)return b.copy(d);var h=f*l-k*g;if(0>=h&&0<=f&&0>=k)return d=f/(f-k),b.copy(c).addScaledVector(sd,d);hh.subVectors(a,e);a=sd.dot(hh);var v=td.dot(hh);if(0<= -v&&a<=v)return b.copy(e);f=a*g-f*v;if(0>=f&&0<=g&&0>=v)return h=g/(g-v),b.copy(c).addScaledVector(td,h);g=k*v-a*l;if(0>=g&&0<=l-k&&0<=a-v)return Li.subVectors(e,d),h=(l-k)/(l-k+(a-v)),b.copy(d).addScaledVector(Li,h);e=1/(g+f+h);d=f*e;h*=e;return b.copy(c).addScaledVector(sd,d).addScaledVector(td,h)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});var Mi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244, -black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347, -darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365, -lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683, -mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910, -purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074}, -Ca={h:0,s:0,l:0},Jf={h:0,s:0,l:0};Object.assign(y.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(a,b,c){a=O.euclideanModulo(a,1);b=O.clamp(b, -0,1);c=O.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=bg(c,b,a+1/3),this.g=bg(c,b,a),this.b=bg(c,b,a-1/3));return this},setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1], -10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/360;var e=parseInt(c[2], -10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return a&&0=k?l/(e+f):l/(2-e-f);switch(e){case b:g=(c-d)/l+(cthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;d.stencilWriteMask=this.stencilWriteMask;d.stencilFunc=this.stencilFunc;d.stencilRef=this.stencilRef; -d.stencilFuncMask=this.stencilFuncMask;d.stencilFail=this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize); -void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0this.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];aa.copy(this);a=1/e;d=1/f;var h=1/g;aa.elements[0]*=a;aa.elements[1]*=a;aa.elements[2]*= +a;aa.elements[4]*=d;aa.elements[5]*=d;aa.elements[6]*=d;aa.elements[8]*=h;aa.elements[9]*=h;aa.elements[10]*=h;b.setFromRotationMatrix(aa);c.x=e;c.y=f;c.z=g;return this},makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e); +g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this}, +toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});var xi=new P,yi=new la;Ub.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");Ub.DefaultOrder="XYZ";Object.defineProperties(Ub.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}}, +y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this._onChangeCallback()}},order:{get:function(){return this._order},set:function(a){this._order=a;this._onChangeCallback()}}});Object.assign(Ub.prototype,{isEuler:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)}, +copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=M.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],p=e[6];e=e[10];b=b||this._order;switch(b){case "XYZ":this._y=Math.asin(d(g,-1,1));.9999999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0);break;case "YXZ":this._x=Math.asin(-d(m,-1,1));.9999999>Math.abs(m)?(this._y= +Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0);break;case "ZXY":this._x=Math.asin(d(p,-1,1));.9999999>Math.abs(p)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a));break;case "ZYX":this._y=Math.asin(-d(l,-1,1));.9999999>Math.abs(l)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k));break;case "YZX":this._z=Math.asin(d(h,-1,1));.9999999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l, +a)):(this._x=0,this._y=Math.atan2(g,e));break;case "XZY":this._z=Math.asin(-d(f,-1,1));.9999999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+b)}this._order=b;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a,b,c){xi.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(xi,b,c)},setFromVector3:function(a,b){return this.set(a.x, +a.y,a.z,b||this._order)},reorder:function(a){yi.setFromEuler(this);return this.setFromQuaternion(yi,a)},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x, +this._y,this._z):new n(this._x,this._y,this._z)},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});Object.assign(Ce.prototype,{set:function(a){this.mask=1<e&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;he&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new n);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x|| +a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(a){this.clampPoint(a.center,te);return te.distanceToSquared(a.center)<=a.radius*a.radius},intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(a){if(this.isEmpty())return!1;this.getCenter(ue);Bf.subVectors(this.max,ue);nd.subVectors(a.a,ue);od.subVectors(a.b,ue);pd.subVectors(a.c,ue);Qb.subVectors(od,nd);Rb.subVectors(pd,od);pc.subVectors(nd,pd);a=[0,-Qb.z,Qb.y,0,-Rb.z,Rb.y,0,-pc.z,pc.y,Qb.z,0,-Qb.x,Rb.z,0,-Rb.x,pc.z,0,-pc.x,-Qb.y,Qb.x,0,-Rb.y,Rb.x,0,-pc.y,pc.x,0];if(!Yf(a,nd,od,pd,Bf))return!1; +a=[1,0,0,0,1,0,0,0,1];if(!Yf(a,nd,od,pd,Bf))return!1;Cf.crossVectors(Qb,Rb);a=[Cf.x,Cf.y,Cf.z];return Yf(a,nd,od,pd,Bf)},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return te.copy(a).clamp(this.min,this.max).sub(a).length()},getBoundingSphere:function(a){void 0===a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center); +a.radius=.5*this.getSize(te).length();return a},intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(a){if(this.isEmpty())return this;yb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a);yb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a);yb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);yb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a); +yb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);yb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);yb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);yb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a);this.setFromPoints(yb);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var Pk=new Sa;Object.assign(cb.prototype,{set:function(a,b){this.center.copy(a);this.radius= +b;return this},setFromPoints:function(a,b){var c=this.center;void 0!==b?c.copy(b):Pk.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;dthis.radius},makeEmpty:function(){this.center.set(0,0,0);this.radius=-1;return this},containsPoint:function(a){return a.distanceToSquared(this.center)<= +this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"), +b=new n);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Sa);if(this.isEmpty())return a.makeEmpty(),a;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a); +return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});var zb=new n,Yg=new n,Df=new n,Sb=new n,Zg=new n,Ef=new n,$g=new n;Object.assign(Wb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new n); +return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(a){this.origin.copy(this.at(a,zb));return this},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new n);b.subVectors(a,this.origin);a=b.dot(this.direction);return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))}, +distanceSqToPoint:function(a){var b=zb.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);zb.copy(this.direction).multiplyScalar(b).add(this.origin);return zb.distanceToSquared(a)},distanceSqToSegment:function(a,b,c,d){Yg.copy(a).add(b).multiplyScalar(.5);Df.copy(b).sub(a).normalize();Sb.copy(this.origin).sub(Yg);var e=.5*a.distanceTo(b),f=-this.direction.dot(Df),g=Sb.dot(this.direction),h=-Sb.dot(Df),k=Sb.lengthSq(),m=Math.abs(1-f*f);if(0=-l?b<=l?(e=1/m,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*h)+k):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+k):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+k):b<=-l?(a=Math.max(0,-(-f*e+g)),b=0a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+ +a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y- +f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(da||h>c)return null;if(h>g||g!==g)g=h;if(ac?null:this.at(0<=g?g:c,b)},intersectsBox:function(a){return null!==this.intersectBox(a,zb)},intersectTriangle:function(a,b,c,d,e){Zg.subVectors(b,a);Ef.subVectors(c,a);$g.crossVectors(Zg,Ef);b=this.direction.dot($g);if(0b)d=-1,b=-b;else return null; +Sb.subVectors(this.origin,a);a=d*this.direction.dot(Ef.crossVectors(Sb,Ef));if(0>a)return null;c=d*this.direction.dot(Zg.cross(Sb));if(0>c||a+c>b)return null;a=-d*Sb.dot($g);return 0>a?null:this.at(a/b,e)},applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});var ah=new n,Qk=new n,Rk=new xa;Object.assign(Ta.prototype,{isPlane:!0,set:function(a,b){this.normal.copy(a); +this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(a,b,c){b=ah.subVectors(c,b).cross(Qk.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b,a);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant; +return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new n);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)}, +intersectLine:function(a,b){void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new n);var c=a.delta(ah),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||1b&&0a&&0=Bb.x+Bb.y},getUV:function(a,b,c,d,e,f,g,h){this.getBarycoord(a,b,c,d,Bb);h.set(0,0);h.addScaledVector(e,Bb.x);h.addScaledVector(f,Bb.y);h.addScaledVector(g,Bb.z);return h},isFrontFacing:function(a, +b,c,d){ab.subVectors(c,b);Ab.subVectors(a,b);return 0>ab.cross(Ab).dot(d)?!0:!1}});Object.assign(wa.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){ab.subVectors(this.c,this.b);Ab.subVectors(this.a, +this.b);return.5*ab.cross(Ab).length()},getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return wa.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new Ta);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return wa.getBarycoord(a, +this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return wa.getUV(a,this.a,this.b,this.c,b,c,d,e)},containsPoint:function(a){return wa.containsPoint(a,this.a,this.b,this.c)},isFrontFacing:function(a){return wa.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new n);var c=this.a,d=this.b,e=this.c;qd.subVectors(d,c);rd.subVectors(e, +c);ch.subVectors(a,c);var f=qd.dot(ch),g=rd.dot(ch);if(0>=f&&0>=g)return b.copy(c);dh.subVectors(a,d);var h=qd.dot(dh),k=rd.dot(dh);if(0<=h&&k<=h)return b.copy(d);var m=f*k-h*g;if(0>=m&&0<=f&&0>=h)return d=f/(f-h),b.copy(c).addScaledVector(qd,d);eh.subVectors(a,e);a=qd.dot(eh);var l=rd.dot(eh);if(0<=l&&a<=l)return b.copy(e);f=a*g-f*l;if(0>=f&&0<=g&&0>=l)return m=g/(g-l),b.copy(c).addScaledVector(rd,m);g=h*l-a*k;if(0>=g&&0<=k-h&&0<=a-l)return Di.subVectors(e,d),m=(k-h)/(k-h+(a-l)),b.copy(d).addScaledVector(Di, +m);e=1/(g+f+m);d=f*e;m*=e;return b.copy(c).addScaledVector(qd,d).addScaledVector(rd,m)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});var Ei={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388, +crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146, +floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323, +lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273, +moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638, +sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Da={h:0,s:0,l:0},Ff={h:0,s:0,l:0};Object.assign(A.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"=== +typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(a,b,c){a=M.euclideanModulo(a,1);b=M.clamp(b,0,1);c=M.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=Zf(c,b,a+1/3),this.g=Zf(c,b,a),this.b=Zf(c,b,a-1/3));return this},setStyle:function(a){function b(b){void 0!== +b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r= +Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+ +c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}return a&&0=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;d.stencilWriteMask=this.stencilWriteMask; +d.stencilFunc=this.stencilFunc;d.stencilRef=this.stencilRef;d.stencilFuncMask=this.stencilFuncMask;d.stencilFail=this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(d.linewidth= +this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=this.faceVertexUvs.length;c\n\t#include \n}", -fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}",side:1,blending:0});d.uniforms.tEquirect.value=b;b=new ca(new Jd(5, -5,5),d);c.add(b);d=new Hc(1,10,1);d.renderTarget=this;d.renderTarget.texture.name="CubeCameraTexture";d.update(a,c);b.geometry.dispose();b.material.dispose();return this};cc.prototype=Object.create(T.prototype);cc.prototype.constructor=cc;cc.prototype.isDataTexture=!0;var vd=new qb,Lf=new n;Object.assign(Hd.prototype,{set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)}, -copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],k=c[5],h=c[6],m=c[7],n=c[8],p=c[9],q=c[10],t=c[11],r=c[12],u=c[13],z=c[14];c=c[15];b[0].setComponents(f-a,m-g,t-n,c-r).normalize();b[1].setComponents(f+a,m+g,t+n,c+r).normalize();b[2].setComponents(f+d,m+k,t+p,c+u).normalize();b[3].setComponents(f-d,m-k,t-p,c-u).normalize();b[4].setComponents(f-e,m-h,t-q,c-z).normalize(); -b[5].setComponents(f+e,m+h,t+q,c+z).normalize();return this},intersectsObject:function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();vd.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(vd)},intersectsSprite:function(a){vd.center.set(0,0,0);vd.radius=.7071067811865476;vd.applyMatrix4(a.matrixWorld);return this.intersectsSphere(vd)},intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)< -a)return!1;return!0},intersectsBox:function(a){for(var b=this.planes,c=0;6>c;c++){var d=b[c];Lf.x=0d.distanceToPoint(Lf))return!1}return!0},containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var N={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif", -alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif", -aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif", +a.lineDistancesNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var ih=function(a){function b(b,d,e,f,g,h){a.call(this);this.type="BoxGeometry";this.parameters={width:b,height:d,depth:e,widthSegments:f,heightSegments:g,depthSegments:h};this.fromBufferGeometry(new Fd(b,d,e,f,g,h));this.mergeVertices()}a&&(b.__proto__=a);b.prototype=Object.create(a&&a.prototype);return b.prototype.constructor=b}(O),Fd=function(a){function b(b, +d,e,f,g,h){function c(a,b,c,d,e,f,g,h,k,z,v){var w=f/k,x=g/z,y=f/2,F=g/2,A=h/2;g=k+1;var C=z+1,B=f=0,D,E,G=new n;for(E=0;E\n\t#include \n}",fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}", +side:1,blending:0});d.uniforms.tEquirect.value=b;b=new ja(new Fd(5,5,5),d);c.add(b);d=new Dc(1,10,1);d.renderTarget=this;d.renderTarget.texture.name="CubeCameraTexture";d.update(a,c);b.geometry.dispose();b.material.dispose();return this};Zb.prototype=Object.create(V.prototype);Zb.prototype.constructor=Zb;Zb.prototype.isDataTexture=!0;var td=new cb,Hf=new n;Object.assign(Ec.prototype,{set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f); +return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromProjectionMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],p=c[9],n=c[10],r=c[11],q=c[12],t=c[13],v=c[14];c=c[15];b[0].setComponents(f-a,m-g,r-l,c-q).normalize();b[1].setComponents(f+a,m+g,r+l,c+q).normalize();b[2].setComponents(f+d,m+h,r+p,c+t).normalize();b[3].setComponents(f- +d,m-h,r-p,c-t).normalize();b[4].setComponents(f-e,m-k,r-n,c-v).normalize();b[5].setComponents(f+e,m+k,r+n,c+v).normalize();return this},intersectsObject:function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();td.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(td)},intersectsSprite:function(a){td.center.set(0,0,0);td.radius=.7071067811865476;td.applyMatrix4(a.matrixWorld);return this.intersectsSphere(td)},intersectsSphere:function(a){var b=this.planes, +c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)c;c++){var d=b[c];Hf.x=0d.distanceToPoint(Hf))return!1}return!0},containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var D={common:{diffuse:{value:new A(15658734)},opacity:{value:1},map:{value:null}, +uvTransform:{value:new xa},uv2Transform:{value:new xa},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new v(1, +1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new A(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{}, +shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{}, +shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new A(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new xa}},sprite:{diffuse:{value:new A(15658734)},opacity:{value:1},center:{value:new v(.5, +.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new xa}}};Ed.prototype=Object.create(O.prototype);Ed.prototype.constructor=Ed;$b.prototype=Object.create(B.prototype);$b.prototype.constructor=$b;var L={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif", +aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif", +begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif", bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif", -clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif", -clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}", +clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif", +clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif", +color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}", cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif", -defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif", -displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif", -encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", -envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif", +defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif", +displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif", +emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", +envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif", envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif", -envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", +envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif", fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif", -lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif", -lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif", +lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif", +lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif", lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)", lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)", -lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif", +lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif", lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", -lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif", +lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif", lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif", lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif", logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif", @@ -620,411 +629,420 @@ morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInf normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;", normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif", normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif", -clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif", +clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif", packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}", premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif", -roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", +roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif", -shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif", -shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}", +shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif", +shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}", skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif", skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif", specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}", uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif", uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}", background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}", -cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}", -depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}", +depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}", distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}", distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}", equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}", -equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", -linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}", -meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", +meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}", normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}", -points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", +points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}", points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}", -shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}", sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"}, -E={common:{diffuse:{value:new y(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new za},uv2Transform:{value:new za},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null}, -bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new x(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new y(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{}, -color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{}, -shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new y(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new za}},sprite:{diffuse:{value:new y(15658734)},opacity:{value:1},center:{value:new x(.5,.5)},rotation:{value:0},map:{value:null}, -alphaMap:{value:null},uvTransform:{value:new za}}},eb={basic:{uniforms:na([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.fog]),vertexShader:N.meshbasic_vert,fragmentShader:N.meshbasic_frag},lambert:{uniforms:na([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.fog,E.lights,{emissive:{value:new y(0)}}]),vertexShader:N.meshlambert_vert,fragmentShader:N.meshlambert_frag},phong:{uniforms:na([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap, -E.displacementmap,E.fog,E.lights,{emissive:{value:new y(0)},specular:{value:new y(1118481)},shininess:{value:30}}]),vertexShader:N.meshphong_vert,fragmentShader:N.meshphong_frag},standard:{uniforms:na([E.common,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.roughnessmap,E.metalnessmap,E.fog,E.lights,{emissive:{value:new y(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag}, -toon:{uniforms:na([E.common,E.specularmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.gradientmap,E.fog,E.lights,{emissive:{value:new y(0)},specular:{value:new y(1118481)},shininess:{value:30}}]),vertexShader:N.meshtoon_vert,fragmentShader:N.meshtoon_frag},matcap:{uniforms:na([E.common,E.bumpmap,E.normalmap,E.displacementmap,E.fog,{matcap:{value:null}}]),vertexShader:N.meshmatcap_vert,fragmentShader:N.meshmatcap_frag},points:{uniforms:na([E.points,E.fog]),vertexShader:N.points_vert, -fragmentShader:N.points_frag},dashed:{uniforms:na([E.common,E.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:N.linedashed_vert,fragmentShader:N.linedashed_frag},depth:{uniforms:na([E.common,E.displacementmap]),vertexShader:N.depth_vert,fragmentShader:N.depth_frag},normal:{uniforms:na([E.common,E.bumpmap,E.normalmap,E.displacementmap,{opacity:{value:1}}]),vertexShader:N.normal_vert,fragmentShader:N.normal_frag},sprite:{uniforms:na([E.sprite,E.fog]),vertexShader:N.sprite_vert, -fragmentShader:N.sprite_frag},background:{uniforms:{uvTransform:{value:new za},t2D:{value:null}},vertexShader:N.background_vert,fragmentShader:N.background_frag},cube:{uniforms:na([E.envmap,{opacity:{value:1}}]),vertexShader:N.cube_vert,fragmentShader:N.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:N.equirect_vert,fragmentShader:N.equirect_frag},distanceRGBA:{uniforms:na([E.common,E.displacementmap,{referencePosition:{value:new n},nearDistance:{value:1},farDistance:{value:1E3}}]), -vertexShader:N.distanceRGBA_vert,fragmentShader:N.distanceRGBA_frag},shadow:{uniforms:na([E.lights,E.fog,{color:{value:new y(0)},opacity:{value:1}}]),vertexShader:N.shadow_vert,fragmentShader:N.shadow_frag}};eb.physical={uniforms:na([eb.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new y(0)},clearcoatNormalScale:{value:new x(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag};Id.prototype= -Object.create(M.prototype);Id.prototype.constructor=Id;dc.prototype=Object.create(G.prototype);dc.prototype.constructor=dc;rb.prototype=Object.create(T.prototype);rb.prototype.constructor=rb;rb.prototype.isCubeTexture=!0;Object.defineProperty(rb.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Ic.prototype=Object.create(T.prototype);Ic.prototype.constructor=Ic;Ic.prototype.isDataTexture2DArray=!0;Jc.prototype=Object.create(T.prototype);Jc.prototype.constructor= -Jc;Jc.prototype.isDataTexture3D=!0;var Fh=new T,Mj=new Ic,Oj=new Jc,Gh=new rb,zh=[],Bh=[],Eh=new Float32Array(16),Dh=new Float32Array(9),Ch=new Float32Array(4);Hh.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ia(b,a)};Ih.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var hg=/([\w\d_]+)(\])?(\[|\.)?/g;Fb.prototype.setValue=function(a,b,c, -d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Fb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Fb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],k=c[g.id];!1!==k.needsUpdate&&g.setValue(a,k.value,d)}};Fb.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var tk=0,jg=/^[ \t]*#include +<([\w\d./]+)>/gm,Qh=/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g, -Ck=0;Gb.prototype=Object.create(L.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isMeshDepthMaterial=!0;Gb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this}; -Hb.prototype=Object.create(L.prototype);Hb.prototype.constructor=Hb;Hb.prototype.isMeshDistanceMaterial=!0;Hb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias; -return this};og.prototype=Object.assign(Object.create(va.prototype),{constructor:og,isWebGLMultiviewRenderTarget:!0,copy:function(a){va.prototype.copy.call(this,a);this.numViews=a.numViews;return this},setNumViews:function(a){this.numViews!==a&&(this.numViews=a,this.dispose());return this}});Pe.prototype=Object.assign(Object.create(pa.prototype),{constructor:Pe,isArrayCamera:!0});Od.prototype=Object.assign(Object.create(D.prototype),{constructor:Od,isGroup:!0});Object.assign(Wh.prototype,Fa.prototype); -Object.assign(Qe.prototype,{isFogExp2:!0,clone:function(){return new Qe(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(Re.prototype,{isFog:!0,clone:function(){return new Re(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(sb.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(sb.prototype, -{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(a){this.usage=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.usage=a.usage;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;da.far||b.push({distance:e,point:Ee.clone(),uv:ma.getUV(Ee,Mf,Fe,Nf,Oi,mh,Pi,new x),face:null,object:this})},clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){D.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}}); -var Of=new n,Qi=new n;Sd.prototype=Object.assign(Object.create(D.prototype),{constructor:Sd,isLOD:!0,copy:function(a){D.prototype.copy.call(this,a,!1);for(var b=a.levels,c=0,d=b.length;c=b[c].distance)b[c- -1].object.visible=!1,b[c].object.visible=!0;else break;for(;cc||(k.applyMatrix4(this.matrixWorld),q=a.ray.origin.distanceTo(k),qa.far||b.push({distance:q,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}else for(d=0,p=v.length/3-1;dc||(k.applyMatrix4(this.matrixWorld),q=a.ray.origin.distanceTo(k),qa.far||b.push({distance:q,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null, -object:this}))}else if(d.isGeometry)for(f=d.vertices,g=f.length,d=0;dc||(k.applyMatrix4(this.matrixWorld),q=a.ray.origin.distanceTo(k),qa.far||b.push({distance:q,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Qf=new n,Rf=new n;la.prototype=Object.assign(Object.create(Ja.prototype),{constructor:la, -isLineSegments:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;d= -a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Pc.prototype=Object.create(T.prototype);Pc.prototype.constructor=Pc;Pc.prototype.isCompressedTexture=!0;Ud.prototype=Object.create(T.prototype);Ud.prototype.constructor=Ud;Ud.prototype.isCanvasTexture=!0;Vd.prototype=Object.create(T.prototype);Vd.prototype.constructor=Vd;Vd.prototype.isDepthTexture=!0;Qc.prototype=Object.create(G.prototype);Qc.prototype.constructor=Qc;Wd.prototype=Object.create(M.prototype);Wd.prototype.constructor=Wd;Rc.prototype=Object.create(G.prototype); -Rc.prototype.constructor=Rc;Xd.prototype=Object.create(M.prototype);Xd.prototype.constructor=Xd;Ga.prototype=Object.create(G.prototype);Ga.prototype.constructor=Ga;Yd.prototype=Object.create(M.prototype);Yd.prototype.constructor=Yd;Sc.prototype=Object.create(Ga.prototype);Sc.prototype.constructor=Sc;Zd.prototype=Object.create(M.prototype);Zd.prototype.constructor=Zd;ec.prototype=Object.create(Ga.prototype);ec.prototype.constructor=ec;$d.prototype=Object.create(M.prototype);$d.prototype.constructor= -$d;Tc.prototype=Object.create(Ga.prototype);Tc.prototype.constructor=Tc;ae.prototype=Object.create(M.prototype);ae.prototype.constructor=ae;Uc.prototype=Object.create(Ga.prototype);Uc.prototype.constructor=Uc;be.prototype=Object.create(M.prototype);be.prototype.constructor=be;fc.prototype=Object.create(G.prototype);fc.prototype.constructor=fc;fc.prototype.toJSON=function(){var a=G.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};ce.prototype=Object.create(M.prototype);ce.prototype.constructor= -ce;Vc.prototype=Object.create(G.prototype);Vc.prototype.constructor=Vc;de.prototype=Object.create(M.prototype);de.prototype.constructor=de;Wc.prototype=Object.create(G.prototype);Wc.prototype.constructor=Wc;var Zk={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=Zh(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var k;if(d){var h=c;d=[];var m;var n=0;for(m=b.length;n80*c){var t=k=a[0];var r=d=a[1];for(h=c;hk&&(k=n),b>d&&(d=b);k=Math.max(k-t,d-r);k=0!==k?1/k:0}ge(f,g,c,t,r,k);return g}},tb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;etb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];ci(a);di(c,a);var f=a.length;b.forEach(ci); -for(a=0;aMath.abs(g-h)?[new x(a,1-c),new x(k,1-d),new x(m,1-e),new x(p,1-b)]:[new x(g,1-c),new x(h,1-d),new x(n,1-e),new x(q,1-b)]}};ie.prototype=Object.create(M.prototype); -ie.prototype.constructor=ie;Yc.prototype=Object.create(gb.prototype);Yc.prototype.constructor=Yc;je.prototype=Object.create(M.prototype);je.prototype.constructor=je;ic.prototype=Object.create(G.prototype);ic.prototype.constructor=ic;ke.prototype=Object.create(M.prototype);ke.prototype.constructor=ke;Zc.prototype=Object.create(G.prototype);Zc.prototype.constructor=Zc;le.prototype=Object.create(M.prototype);le.prototype.constructor=le;$c.prototype=Object.create(G.prototype);$c.prototype.constructor= -$c;jc.prototype=Object.create(M.prototype);jc.prototype.constructor=jc;jc.prototype.toJSON=function(){var a=M.prototype.toJSON.call(this);return fi(this.parameters.shapes,a)};kc.prototype=Object.create(G.prototype);kc.prototype.constructor=kc;kc.prototype.toJSON=function(){var a=G.prototype.toJSON.call(this);return fi(this.parameters.shapes,a)};ad.prototype=Object.create(G.prototype);ad.prototype.constructor=ad;lc.prototype=Object.create(M.prototype);lc.prototype.constructor=lc;ub.prototype=Object.create(G.prototype); -ub.prototype.constructor=ub;me.prototype=Object.create(lc.prototype);me.prototype.constructor=me;ne.prototype=Object.create(ub.prototype);ne.prototype.constructor=ne;oe.prototype=Object.create(M.prototype);oe.prototype.constructor=oe;bd.prototype=Object.create(G.prototype);bd.prototype.constructor=bd;var ua=Object.freeze({__proto__:null,WireframeGeometry:Qc,ParametricGeometry:Wd,ParametricBufferGeometry:Rc,TetrahedronGeometry:Yd,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Zd,OctahedronBufferGeometry:ec, -IcosahedronGeometry:$d,IcosahedronBufferGeometry:Tc,DodecahedronGeometry:ae,DodecahedronBufferGeometry:Uc,PolyhedronGeometry:Xd,PolyhedronBufferGeometry:Ga,TubeGeometry:be,TubeBufferGeometry:fc,TorusKnotGeometry:ce,TorusKnotBufferGeometry:Vc,TorusGeometry:de,TorusBufferGeometry:Wc,TextGeometry:ie,TextBufferGeometry:Yc,SphereGeometry:je,SphereBufferGeometry:ic,RingGeometry:ke,RingBufferGeometry:Zc,PlaneGeometry:Id,PlaneBufferGeometry:dc,LatheGeometry:le,LatheBufferGeometry:$c,ShapeGeometry:jc,ShapeBufferGeometry:kc, -ExtrudeGeometry:hc,ExtrudeBufferGeometry:gb,EdgesGeometry:ad,ConeGeometry:me,ConeBufferGeometry:ne,CylinderGeometry:lc,CylinderBufferGeometry:ub,CircleGeometry:oe,CircleBufferGeometry:bd,BoxGeometry:lh,BoxBufferGeometry:Jd});mc.prototype=Object.create(L.prototype);mc.prototype.constructor=mc;mc.prototype.isShadowMaterial=!0;mc.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);return this};vb.prototype=Object.create(oa.prototype);vb.prototype.constructor=vb;vb.prototype.isRawShaderMaterial= -!0;hb.prototype=Object.create(L.prototype);hb.prototype.constructor=hb;hb.prototype.isMeshStandardMaterial=!0;hb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity; +eb={basic:{uniforms:va([D.common,D.specularmap,D.envmap,D.aomap,D.lightmap,D.fog]),vertexShader:L.meshbasic_vert,fragmentShader:L.meshbasic_frag},lambert:{uniforms:va([D.common,D.specularmap,D.envmap,D.aomap,D.lightmap,D.emissivemap,D.fog,D.lights,{emissive:{value:new A(0)}}]),vertexShader:L.meshlambert_vert,fragmentShader:L.meshlambert_frag},phong:{uniforms:va([D.common,D.specularmap,D.envmap,D.aomap,D.lightmap,D.emissivemap,D.bumpmap,D.normalmap,D.displacementmap,D.fog,D.lights,{emissive:{value:new A(0)}, +specular:{value:new A(1118481)},shininess:{value:30}}]),vertexShader:L.meshphong_vert,fragmentShader:L.meshphong_frag},standard:{uniforms:va([D.common,D.envmap,D.aomap,D.lightmap,D.emissivemap,D.bumpmap,D.normalmap,D.displacementmap,D.roughnessmap,D.metalnessmap,D.fog,D.lights,{emissive:{value:new A(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:L.meshphysical_vert,fragmentShader:L.meshphysical_frag},toon:{uniforms:va([D.common,D.specularmap,D.aomap,D.lightmap, +D.emissivemap,D.bumpmap,D.normalmap,D.displacementmap,D.gradientmap,D.fog,D.lights,{emissive:{value:new A(0)},specular:{value:new A(1118481)},shininess:{value:30}}]),vertexShader:L.meshtoon_vert,fragmentShader:L.meshtoon_frag},matcap:{uniforms:va([D.common,D.bumpmap,D.normalmap,D.displacementmap,D.fog,{matcap:{value:null}}]),vertexShader:L.meshmatcap_vert,fragmentShader:L.meshmatcap_frag},points:{uniforms:va([D.points,D.fog]),vertexShader:L.points_vert,fragmentShader:L.points_frag},dashed:{uniforms:va([D.common, +D.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:L.linedashed_vert,fragmentShader:L.linedashed_frag},depth:{uniforms:va([D.common,D.displacementmap]),vertexShader:L.depth_vert,fragmentShader:L.depth_frag},normal:{uniforms:va([D.common,D.bumpmap,D.normalmap,D.displacementmap,{opacity:{value:1}}]),vertexShader:L.normal_vert,fragmentShader:L.normal_frag},sprite:{uniforms:va([D.sprite,D.fog]),vertexShader:L.sprite_vert,fragmentShader:L.sprite_frag},background:{uniforms:{uvTransform:{value:new xa}, +t2D:{value:null}},vertexShader:L.background_vert,fragmentShader:L.background_frag},cube:{uniforms:va([D.envmap,{opacity:{value:1}}]),vertexShader:L.cube_vert,fragmentShader:L.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:L.equirect_vert,fragmentShader:L.equirect_frag},distanceRGBA:{uniforms:va([D.common,D.displacementmap,{referencePosition:{value:new n},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:L.distanceRGBA_vert,fragmentShader:L.distanceRGBA_frag},shadow:{uniforms:va([D.lights, +D.fog,{color:{value:new A(0)},opacity:{value:1}}]),vertexShader:L.shadow_vert,fragmentShader:L.shadow_frag}};eb.physical={uniforms:va([eb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new v(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new A(0)},transparency:{value:0}}]),vertexShader:L.meshphysical_vert,fragmentShader:L.meshphysical_frag};pb.prototype=Object.create(V.prototype);pb.prototype.constructor= +pb;pb.prototype.isCubeTexture=!0;Object.defineProperty(pb.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Fc.prototype=Object.create(V.prototype);Fc.prototype.constructor=Fc;Fc.prototype.isDataTexture2DArray=!0;Gc.prototype=Object.create(V.prototype);Gc.prototype.constructor=Gc;Gc.prototype.isDataTexture3D=!0;var Eh=new V,Hj=new Fc,Jj=new Gc,Fh=new pb,yh=[],Ah=[],Dh=new Float32Array(16),Ch=new Float32Array(9),Bh=new Float32Array(4);Gh.prototype.updateCache=function(a){var b= +this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ia(b,a)};Hh.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var eg=/([\w\d_]+)(\])?(\[|\.)?/g;Gb.prototype.setValue=function(a,b,c,d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Gb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Gb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e], +h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Gb.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var ok=0,gg=/^[ \t]*#include +<([\w\d./]+)>/gm,Qh=/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Ph=/#pragma unroll_loop_start[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g,yk=0;Hb.prototype=Object.create(J.prototype);Hb.prototype.constructor= +Hb;Hb.prototype.isMeshDepthMaterial=!0;Hb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};Ib.prototype=Object.create(J.prototype);Ib.prototype.constructor= +Ib;Ib.prototype.isMeshDistanceMaterial=!0;Ib.prototype.copy=function(a){J.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;return this};Ke.prototype=Object.assign(Object.create(ba.prototype), +{constructor:Ke,isArrayCamera:!0});Jc.prototype=Object.assign(Object.create(E.prototype),{constructor:Jc,isGroup:!0});Object.assign(Le.prototype,{constructor:Le,getTargetRaySpace:function(){null===this._targetRay&&(this._targetRay=new Jc,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1);return this._targetRay},getGripSpace:function(){null===this._grip&&(this._grip=new Jc,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1);return this._grip},dispatchEvent:function(a){null!==this._targetRay&& +this._targetRay.dispatchEvent(a);null!==this._grip&&this._grip.dispatchEvent(a);return this},disconnect:function(a){this.dispatchEvent({type:"disconnected",data:a});null!==this._targetRay&&(this._targetRay.visible=!1);null!==this._grip&&(this._grip.visible=!1);return this},update:function(a,b,c){var d=null,e=null,f=this._targetRay,g=this._grip;a&&(null!==f&&(d=b.getPose(a.targetRaySpace,c),null!==d&&(f.matrix.fromArray(d.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale))),null!== +g&&a.gripSpace&&(e=b.getPose(a.gripSpace,c),null!==e&&(g.matrix.fromArray(e.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale))));null!==f&&(f.visible=null!==d);null!==g&&(g.visible=null!==e);return this}});Object.assign(Xh.prototype,ua.prototype);Object.assign(Me.prototype,{isFogExp2:!0,clone:function(){return new Me(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(Ne.prototype,{isFog:!0,clone:function(){return new Ne(this.color, +this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(qb.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(qb.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(a){this.usage=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.usage=a.usage;return this},copyAt:function(a,b,c){a*=this.stride; +c*=b.stride;for(var d=0,e=this.stride;da.far||b.push({distance:e,point:we.clone(),uv:wa.getUV(we,If,xe,Jf,Gi,jh,Hi,new v),face:null,object:this})},clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){E.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});var Kf=new n,Ii=new n;Nd.prototype=Object.assign(Object.create(E.prototype),{constructor:Nd,isLOD:!0,copy:function(a){E.prototype.copy.call(this,a,!1);for(var b=a.levels,c=0,d=b.length;c=b[c].distance)b[c-1].object.visible=!1,b[c].object.visible=!0;else break;for(this._currentLevel=c-1;cf;f++)if(k=c.getComponent(f), +0!==k){var m=b.getComponent(f);e.multiplyMatrices(h.bones[m].matrixWorld,h.boneInverses[m]);g.addScaledVector(d.copy(a).applyMatrix4(e),k)}return g.applyMatrix4(this.bindMatrixInverse)}}()});var Ji=new P,Sk=new P;Object.assign(Qe.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;ad||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this}))}}else for(c=0,p=l.length/3-1;cd||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:c, +face:null,faceIndex:null,object:this}))}else if(c.isGeometry)for(f=c.vertices,g=f.length,c=0;cd||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:c,face:null,faceIndex:null,object:this}))}},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Nf=new n,Of=new n;na.prototype=Object.assign(Object.create(Ja.prototype), +{constructor:na,isLineSegments:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;d= +a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Nc.prototype=Object.create(V.prototype);Nc.prototype.constructor=Nc;Nc.prototype.isCompressedTexture=!0;Od.prototype=Object.create(V.prototype);Od.prototype.constructor=Od;Od.prototype.isCanvasTexture=!0;Pd.prototype=Object.create(V.prototype);Pd.prototype.constructor=Pd;Pd.prototype.isDepthTexture=!0;Oc.prototype=Object.create(B.prototype);Oc.prototype.constructor=Oc;Qd.prototype=Object.create(O.prototype);Qd.prototype.constructor=Qd;Pc.prototype=Object.create(B.prototype); +Pc.prototype.constructor=Pc;Rd.prototype=Object.create(O.prototype);Rd.prototype.constructor=Rd;Ea.prototype=Object.create(B.prototype);Ea.prototype.constructor=Ea;Sd.prototype=Object.create(O.prototype);Sd.prototype.constructor=Sd;Qc.prototype=Object.create(Ea.prototype);Qc.prototype.constructor=Qc;Td.prototype=Object.create(O.prototype);Td.prototype.constructor=Td;ac.prototype=Object.create(Ea.prototype);ac.prototype.constructor=ac;Ud.prototype=Object.create(O.prototype);Ud.prototype.constructor= +Ud;Rc.prototype=Object.create(Ea.prototype);Rc.prototype.constructor=Rc;Vd.prototype=Object.create(O.prototype);Vd.prototype.constructor=Vd;Sc.prototype=Object.create(Ea.prototype);Sc.prototype.constructor=Sc;Wd.prototype=Object.create(O.prototype);Wd.prototype.constructor=Wd;bc.prototype=Object.create(B.prototype);bc.prototype.constructor=bc;bc.prototype.toJSON=function(){var a=B.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};Xd.prototype=Object.create(O.prototype);Xd.prototype.constructor= +Xd;Tc.prototype=Object.create(B.prototype);Tc.prototype.constructor=Tc;Yd.prototype=Object.create(O.prototype);Yd.prototype.constructor=Yd;Uc.prototype=Object.create(B.prototype);Uc.prototype.constructor=Uc;var Tk={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=$h(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var h;if(d){var k=c;d=[];var m;var l=0;for(m=b.length;l80*c){var r=h=a[0];var q=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-r,d-q);h=0!==h?1/h:0}$d(f,g,c,r,q,h);return g}},rb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;erb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];di(a);ei(c,a);var f= +a.length;b.forEach(di);for(a=0;aMath.abs(g-k)?[new v(a,1-c),new v(h,1-d),new v(l,1-e),new v(p,1-b)]:[new v(g,1-c),new v(k,1-d),new v(n,1-e),new v(u,1-b)]}};be.prototype=Object.create(O.prototype); +be.prototype.constructor=be;Wc.prototype=Object.create(fb.prototype);Wc.prototype.constructor=Wc;ce.prototype=Object.create(O.prototype);ce.prototype.constructor=ce;dc.prototype=Object.create(B.prototype);dc.prototype.constructor=dc;de.prototype=Object.create(O.prototype);de.prototype.constructor=de;Xc.prototype=Object.create(B.prototype);Xc.prototype.constructor=Xc;ee.prototype=Object.create(O.prototype);ee.prototype.constructor=ee;Yc.prototype=Object.create(B.prototype);Yc.prototype.constructor= +Yc;ec.prototype=Object.create(O.prototype);ec.prototype.constructor=ec;ec.prototype.toJSON=function(){var a=O.prototype.toJSON.call(this);return gi(this.parameters.shapes,a)};fc.prototype=Object.create(B.prototype);fc.prototype.constructor=fc;fc.prototype.toJSON=function(){var a=B.prototype.toJSON.call(this);return gi(this.parameters.shapes,a)};Zc.prototype=Object.create(B.prototype);Zc.prototype.constructor=Zc;gc.prototype=Object.create(O.prototype);gc.prototype.constructor=gc;sb.prototype=Object.create(B.prototype); +sb.prototype.constructor=sb;fe.prototype=Object.create(gc.prototype);fe.prototype.constructor=fe;ge.prototype=Object.create(sb.prototype);ge.prototype.constructor=ge;he.prototype=Object.create(O.prototype);he.prototype.constructor=he;$c.prototype=Object.create(B.prototype);$c.prototype.constructor=$c;var qa=Object.freeze({__proto__:null,WireframeGeometry:Oc,ParametricGeometry:Qd,ParametricBufferGeometry:Pc,TetrahedronGeometry:Sd,TetrahedronBufferGeometry:Qc,OctahedronGeometry:Td,OctahedronBufferGeometry:ac, +IcosahedronGeometry:Ud,IcosahedronBufferGeometry:Rc,DodecahedronGeometry:Vd,DodecahedronBufferGeometry:Sc,PolyhedronGeometry:Rd,PolyhedronBufferGeometry:Ea,TubeGeometry:Wd,TubeBufferGeometry:bc,TorusKnotGeometry:Xd,TorusKnotBufferGeometry:Tc,TorusGeometry:Yd,TorusBufferGeometry:Uc,TextGeometry:be,TextBufferGeometry:Wc,SphereGeometry:ce,SphereBufferGeometry:dc,RingGeometry:de,RingBufferGeometry:Xc,PlaneGeometry:Ed,PlaneBufferGeometry:$b,LatheGeometry:ee,LatheBufferGeometry:Yc,ShapeGeometry:ec,ShapeBufferGeometry:fc, +ExtrudeGeometry:cc,ExtrudeBufferGeometry:fb,EdgesGeometry:Zc,ConeGeometry:fe,ConeBufferGeometry:ge,CylinderGeometry:gc,CylinderBufferGeometry:sb,CircleGeometry:he,CircleBufferGeometry:$c,BoxGeometry:ih,BoxBufferGeometry:Fd});hc.prototype=Object.create(J.prototype);hc.prototype.constructor=hc;hc.prototype.isShadowMaterial=!0;hc.prototype.copy=function(a){J.prototype.copy.call(this,a);this.color.copy(a.color);return this};tb.prototype=Object.create(Aa.prototype);tb.prototype.constructor=tb;tb.prototype.isRawShaderMaterial= +!0;gb.prototype=Object.create(J.prototype);gb.prototype.constructor=gb;gb.prototype.isMeshStandardMaterial=!0;gb.prototype.copy=function(a){J.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity; this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth= -a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};nc.prototype=Object.create(hb.prototype);nc.prototype.constructor=nc;nc.prototype.isMeshPhysicalMaterial=!0;nc.prototype.copy=function(a){hb.prototype.copy.call(this,a);this.defines={STANDARD:"",PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearcoat=a.clearcoat;this.clearcoatRoughness= -a.clearcoatRoughness;this.sheen=a.sheen?(this.sheen||new y).copy(a.sheen):null;this.clearcoatNormalMap=a.clearcoatNormalMap;this.clearcoatNormalScale.copy(a.clearcoatNormalScale);this.transparency=a.transparency;return this};Kb.prototype=Object.create(L.prototype);Kb.prototype.constructor=Kb;Kb.prototype.isMeshPhongMaterial=!0;Kb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap= -a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap= -a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};oc.prototype=Object.create(L.prototype);oc.prototype.constructor=oc;oc.prototype.isMeshToonMaterial= -!0;oc.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.gradientMap=a.gradientMap;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType= -a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};pc.prototype= -Object.create(L.prototype);pc.prototype.constructor=pc;pc.prototype.isMeshNormalMaterial=!0;pc.prototype.copy=function(a){L.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning= -a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};qc.prototype=Object.create(L.prototype);qc.prototype.constructor=qc;qc.prototype.isMeshLambertMaterial=!0;qc.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity= -a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};rc.prototype=Object.create(L.prototype);rc.prototype.constructor= -rc;rc.prototype.isMeshMatcapMaterial=!0;rc.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning; -this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};sc.prototype=Object.create(ja.prototype);sc.prototype.constructor=sc;sc.prototype.isLineDashedMaterial=!0;sc.prototype.copy=function(a){ja.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var $k=Object.freeze({__proto__:null,ShadowMaterial:mc,SpriteMaterial:Jb,RawShaderMaterial:vb,ShaderMaterial:oa,PointsMaterial:Va,MeshPhysicalMaterial:nc,MeshStandardMaterial:hb, -MeshPhongMaterial:Kb,MeshToonMaterial:oc,MeshNormalMaterial:pc,MeshLambertMaterial:qc,MeshDepthMaterial:Gb,MeshDistanceMaterial:Hb,MeshBasicMaterial:Oa,MeshMatcapMaterial:rc,LineDashedMaterial:sc,LineBasicMaterial:ja,Material:L}),ea={arraySlice:function(a,b,c){return ea.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&& -!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var k=c[f]*b,h=0;h!==b;++h)e[g++]=a[k+h];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)), -f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}},subclip:function(a,b,c,d,e){e=e||30;a=a.clone();a.name=b;var f=[];for(b=0;b=d))for(h.push(g.times[n]),p=0;pa.tracks[b].times[0]&&(c=a.tracks[b].times[0]);for(b=0;b=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=ea.arraySlice(c,e,f),this.values=ea.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.", -this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ea.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values, -c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;g=d))for(k.push(g.times[n]),p=0;pa.tracks[b].times[0]&&(c=a.tracks[b].times[0]);for(b=0;b=d)d=30;var e=a.tracks.length;b/=d;for(d=0;d=f.times[l]?l=ka.arraySlice(f.values,l*k):(l=f.createInterpolant(),l.evaluate(b),l=l.resultBuffer);"quaternion"===g&&(new la(l[0],l[1],l[2],l[3])).normalize().conjugate().toArray(l); +for(var n=h.times.length,p=0;p= +e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f, +1),e=f-1),a=this.getValueSize(),this.times=ka.arraySlice(c,e,f),this.values=ka.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.", +this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ka.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=ka.arraySlice(this.times),b=ka.arraySlice(this.values),c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gg)e=a+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(O.clamp(d[h-1].dot(d[h]),-1,1)),e[h].applyMatrix4(k.makeRotationAxis(g,c))),f[h].crossVectors(d[h],e[h]);if(!0===b)for(c=Math.acos(O.clamp(e[0].dot(e[a]),-1,1)),c/=a,0d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>l&&(l=e);nh.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,l);oh.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,l);ph.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,l)}else"catmullrom"===this.curveType&&(nh.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),oh.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),ph.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(nh.calc(a),oh.calc(a),ph.calc(a));return b};Aa.prototype.copy=function(a){I.prototype.copy.call(this, -a);this.points=[];for(var b=0,c=a.points.length;bc.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(hi(d,e.x,f.x,g.x,c.x),hi(d,e.y,f.y,g.y,c.y));return b};Za.prototype.copy=function(a){I.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()}, -getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d} -var e=tb.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new Lb;h.curves=g.curves;b.push(h);return b}var l=!e(f[0].getPoints());l=a?!l:l;h=[];var m=[],n=[],p=0;m[p]=void 0;n[p]=[];for(var q=0,t=f.length;qb;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095); -b.addScale(e[1],.488603*d);b.addScale(e[2],.488603*a);b.addScale(e[3],.488603*c);b.addScale(e[4],1.092548*c*d);b.addScale(e[5],1.092548*d*a);b.addScale(e[6],.315392*(3*a*a-1));b.addScale(e[7],1.092548*c*a);b.addScale(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScale(e[1],1.023328*d);b.addScale(e[2],1.023328*a);b.addScale(e[3],1.023328*c);b.addScale(e[4],.858086*c*d);b.addScale(e[5],.858086* -d*a);b.addScale(e[6],.743125*a*a-.247708);b.addScale(e[7],.858086*c*a);b.addScale(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b=0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c],b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0}, -copy:function(a){return this.set(a.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(a,b){void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].fromArray(a,b+3*d);return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].toArray(a,b+3*d);return a}});Object.assign(tf,{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d; -b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*c*a;b[8]=.546274*(c*c-d*d)}});ab.prototype=Object.assign(Object.create(ba.prototype),{constructor:ab,isLightProbe:!0,copy:function(a){ba.prototype.copy.call(this,a);this.sh.copy(a.sh);this.intensity=a.intensity;return this},toJSON:function(a){return ba.prototype.toJSON.call(this,a)}});Fg.prototype=Object.assign(Object.create(ab.prototype),{constructor:Fg,isHemisphereLightProbe:!0,copy:function(a){ab.prototype.copy.call(this,a);return this},toJSON:function(a){return ab.prototype.toJSON.call(this, -a)}});Gg.prototype=Object.assign(Object.create(ab.prototype),{constructor:Gg,isAmbientLightProbe:!0,copy:function(a){ab.prototype.copy.call(this,a);return this},toJSON:function(a){return ab.prototype.toJSON.call(this,a)}});var $i=new P,aj=new P;Object.assign(ii.prototype,{update:function(a){var b=this._cache;if(b.focus!==a.focus||b.fov!==a.fov||b.aspect!==a.aspect*this.aspect||b.near!==a.near||b.far!==a.far||b.zoom!==a.zoom||b.eyeSep!==this.eyeSep){b.focus=a.focus;b.fov=a.fov;b.aspect=a.aspect*this.aspect; -b.near=a.near;b.far=a.far;b.zoom=a.zoom;b.eyeSep=this.eyeSep;var c=a.projectionMatrix.clone(),d=b.eyeSep/2,e=d*b.near/b.focus,f=b.near*Math.tan(O.DEG2RAD*b.fov*.5)/b.zoom;aj.elements[12]=-d;$i.elements[12]=d;d=-f*b.aspect+e;var g=f*b.aspect+e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraL.projectionMatrix.copy(c);d=-f*b.aspect-e;g=f*b.aspect-e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(a.matrixWorld).multiply(aj); -this.cameraR.matrixWorld.copy(a.matrixWorld).multiply($i)}});Object.assign(Hg.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0},stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance? -Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});var yc=new n,bj=new Da,bl=new n,zc=new n;Ig.prototype=Object.assign(Object.create(D.prototype),{constructor:Ig,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!== -this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(a){D.prototype.updateMatrixWorld.call(this,a);a=this.context.listener; -var b=this.up;this.timeDelta=this._clock.getDelta();this.matrixWorld.decompose(yc,bj,bl);zc.set(0,0,-1).applyQuaternion(bj);if(a.positionX){var c=this.context.currentTime+this.timeDelta;a.positionX.linearRampToValueAtTime(yc.x,c);a.positionY.linearRampToValueAtTime(yc.y,c);a.positionZ.linearRampToValueAtTime(yc.z,c);a.forwardX.linearRampToValueAtTime(zc.x,c);a.forwardY.linearRampToValueAtTime(zc.y,c);a.forwardZ.linearRampToValueAtTime(zc.z,c);a.upX.linearRampToValueAtTime(b.x,c);a.upY.linearRampToValueAtTime(b.y, -c);a.upZ.linearRampToValueAtTime(b.z,c)}else a.setPosition(yc.x,yc.y,yc.z),a.setOrientation(zc.x,zc.y,zc.z,b.x,b.y,b.z)}});hd.prototype=Object.assign(Object.create(D.prototype),{constructor:hd,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect(); -return this},setMediaStreamSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaStreamNode";this.source=this.context.createMediaStreamSource(a);this.connect();return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(a){void 0===a&&(a=0);if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control."); -else return this._startedAt=this.context.currentTime+a,a=this.context.createBufferSource(),a.buffer=this.buffer,a.loop=this.loop,a.loopStart=this.loopStart,a.loopEnd=this.loopEnd,a.onended=this.onEnded.bind(this),a.start(this._startedAt,this._pausedAt+this.offset,this.duration),this.isPlaying=!0,this.source=a,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control."); -else return!0===this.isPlaying&&(this._pausedAt=(this.context.currentTime-this._startedAt)*this.playbackRate,this.source.stop(),this.source.onended=null,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this._pausedAt=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this},connect:function(){if(0d&&this._mixBufferRegion(c,a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]= -a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){Da.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});var dl=/[\[\]\.:\/]/g,el="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",fl=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),gl=/(WCOD+)?/.source.replace("WCOD",el), -hl=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),il=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),jl=new RegExp("^"+fl+gl+hl+il+"$"),kl=["material","materials","bones"];Object.assign(ji.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a= -this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(Ba,{Composite:ji,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new Ba.Composite(a,b,c):new Ba(a,b,c)},sanitizeNodeName:function(a){return a.replace(/\s/g,"_").replace(dl,"")},parseTrackName:function(a){var b=jl.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+ -a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&b.nodeName.lastIndexOf(".");if(void 0!==c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==kl.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+a);return b},findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a; -if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=0;cg)e=a+1;else if(0c&&(c=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(M.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(M.clamp(e[0].dot(e[a]),-1,1)),c/=a,0d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);kh.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);lh.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);mh.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(kh.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),lh.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),mh.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(kh.calc(a), +lh.calc(a),mh.calc(a));return b};pa.prototype.copy=function(a){G.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;bc.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(ii(d,e.x,f.x,g.x,c.x),ii(d,e.y,f.y,g.y,c.y));return b};Za.prototype.copy=function(a){G.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0=== +c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cb;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095);b.addScaledVector(e[1],.488603*d);b.addScaledVector(e[2],.488603*a);b.addScaledVector(e[3], +.488603*c);b.addScaledVector(e[4],1.092548*c*d);b.addScaledVector(e[5],1.092548*d*a);b.addScaledVector(e[6],.315392*(3*a*a-1));b.addScaledVector(e[7],1.092548*c*a);b.addScaledVector(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScaledVector(e[1],1.023328*d);b.addScaledVector(e[2],1.023328*a);b.addScaledVector(e[3],1.023328*c);b.addScaledVector(e[4],.858086*c*d);b.addScaledVector(e[5],.858086* +d*a);b.addScaledVector(e[6],.743125*a*a-.247708);b.addScaledVector(e[7],.858086*c*a);b.addScaledVector(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b=0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);return this},addScaledSH:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].addScaledVector(a.coefficients[c],b);return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c], +b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0},copy:function(a){return this.set(a.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(a,b){void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].fromArray(a,b+3*d);return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].toArray(a,b+3*d);return a}});Object.assign(nf, +{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d;b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*c*a;b[8]=.546274*(c*c-d*d)}});Ra.prototype=Object.assign(Object.create(S.prototype),{constructor:Ra,isLightProbe:!0,copy:function(a){S.prototype.copy.call(this,a);this.sh.copy(a.sh);return this},fromJSON:function(a){this.intensity=a.intensity;this.sh.fromArray(a.sh);return this},toJSON:function(a){a=S.prototype.toJSON.call(this, +a);a.object.sh=this.sh.toArray();return a}});of.prototype=Object.assign(Object.create(X.prototype),{constructor:of,load:function(a,b,c,d){var e=this,f=new Qa(e.manager);f.setPath(e.path);f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){function b(a){void 0===c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Uk[a.type];void 0!==a.uuid&&(d.uuid=a.uuid);void 0!==a.name&&(d.name=a.name);void 0!==a.color&&d.color.setHex(a.color); +void 0!==a.roughness&&(d.roughness=a.roughness);void 0!==a.metalness&&(d.metalness=a.metalness);void 0!==a.sheen&&(d.sheen=(new A).setHex(a.sheen));void 0!==a.emissive&&d.emissive.setHex(a.emissive);void 0!==a.specular&&d.specular.setHex(a.specular);void 0!==a.shininess&&(d.shininess=a.shininess);void 0!==a.clearcoat&&(d.clearcoat=a.clearcoat);void 0!==a.clearcoatRoughness&&(d.clearcoatRoughness=a.clearcoatRoughness);void 0!==a.fog&&(d.fog=a.fog);void 0!==a.flatShading&&(d.flatShading=a.flatShading); +void 0!==a.blending&&(d.blending=a.blending);void 0!==a.combine&&(d.combine=a.combine);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=a.opacity);void 0!==a.transparent&&(d.transparent=a.transparent);void 0!==a.alphaTest&&(d.alphaTest=a.alphaTest);void 0!==a.depthTest&&(d.depthTest=a.depthTest);void 0!==a.depthWrite&&(d.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(d.colorWrite=a.colorWrite);void 0!==a.stencilWrite&&(d.stencilWrite=a.stencilWrite);void 0!==a.stencilWriteMask&&(d.stencilWriteMask= +a.stencilWriteMask);void 0!==a.stencilFunc&&(d.stencilFunc=a.stencilFunc);void 0!==a.stencilRef&&(d.stencilRef=a.stencilRef);void 0!==a.stencilFuncMask&&(d.stencilFuncMask=a.stencilFuncMask);void 0!==a.stencilFail&&(d.stencilFail=a.stencilFail);void 0!==a.stencilZFail&&(d.stencilZFail=a.stencilZFail);void 0!==a.stencilZPass&&(d.stencilZPass=a.stencilZPass);void 0!==a.wireframe&&(d.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(d.wireframeLinewidth=a.wireframeLinewidth);void 0!==a.wireframeLinecap&& +(d.wireframeLinecap=a.wireframeLinecap);void 0!==a.wireframeLinejoin&&(d.wireframeLinejoin=a.wireframeLinejoin);void 0!==a.rotation&&(d.rotation=a.rotation);1!==a.linewidth&&(d.linewidth=a.linewidth);void 0!==a.dashSize&&(d.dashSize=a.dashSize);void 0!==a.gapSize&&(d.gapSize=a.gapSize);void 0!==a.scale&&(d.scale=a.scale);void 0!==a.polygonOffset&&(d.polygonOffset=a.polygonOffset);void 0!==a.polygonOffsetFactor&&(d.polygonOffsetFactor=a.polygonOffsetFactor);void 0!==a.polygonOffsetUnits&&(d.polygonOffsetUnits= +a.polygonOffsetUnits);void 0!==a.skinning&&(d.skinning=a.skinning);void 0!==a.morphTargets&&(d.morphTargets=a.morphTargets);void 0!==a.morphNormals&&(d.morphNormals=a.morphNormals);void 0!==a.dithering&&(d.dithering=a.dithering);void 0!==a.vertexTangents&&(d.vertexTangents=a.vertexTangents);void 0!==a.visible&&(d.visible=a.visible);void 0!==a.toneMapped&&(d.toneMapped=a.toneMapped);void 0!==a.userData&&(d.userData=a.userData);void 0!==a.vertexColors&&(d.vertexColors="number"===typeof a.vertexColors? +0Number.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y=== +g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=rb.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new Nb;h.curves=g.curves;b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var l=[],n=[],p=0;l[p]=void 0;n[p]=[];for(var u=0,r=f.length;ud&&this._mixBufferRegion(c,a,b*this._origIndex,1-d,b);0=b){var n=b++,p=a[n];c[p.uuid]=m;a[m]=p;c[l]=n;a[n]=h;h=0;for(l=e;h!==l;++h){p=d[h];var q=p[m];p[m]=p[n];p[n]=q}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var l= -arguments[g].uuid,m=d[l];if(void 0!==m)if(delete d[l],m=b){var n=b++,p=a[n];c[p.uuid]=l;a[l]=p;c[k]=n;a[n]=h;h=0;for(k=e;h!==k;++h){p=d[h];var u=p[l];p[l]=p[n];p[n]=u}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k= +arguments[g].uuid,l=d[k];if(void 0!==l)if(delete d[k],lb||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1=== -e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else{this.time=b;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=b;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished? -this.paused=!0:this.enabled=!1,this.time=b=0a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this.time=b,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}else this.time=b;if(f&&1===(e&1))return c-b}return b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd= -b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});Ng.prototype=Object.assign(Object.create(Fa.prototype),{constructor:Ng,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName, -l=h[g];void 0===l&&(l={},h[g]=l);for(h=0;h!==e;++h){var m=d[h],n=m.name,p=l[n];if(void 0===p){p=f[h];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,g,n));continue}p=new Mg(Ba.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),m.ValueTypeName,m.getValueSize());++p.referenceCount;this._addInactiveBinding(p,g,n)}f[h]=p;a[h].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid, -c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions= -[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}}, -_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&athis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new x);return b.set((a.x-this.min.x)/(this.max.x-this.min.x), -(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new x);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return dj.copy(a).clamp(this.min,this.max).sub(a).length()},intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min); -this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var ej=new n,Vf=new n;Object.assign(Rg.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"), -a=new n);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new n);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(a, -b){ej.subVectors(a,this.start);Vf.subVectors(this.end,this.start);a=Vf.dot(Vf);a=Vf.dot(ej)/a;b&&(a=O.clamp(a,0,1));return a},closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}}); -te.prototype=Object.create(D.prototype);te.prototype.constructor=te;te.prototype.isImmediateRenderObject=!0;var fj=new n;id.prototype=Object.create(D.prototype);id.prototype.constructor=id;id.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};id.prototype.update=function(){this.light.updateMatrixWorld();var a=this.light.distance?this.light.distance:1E3,b=a*Math.tan(this.light.angle);this.cone.scale.set(b,b,a);fj.setFromMatrixPosition(this.light.target.matrixWorld); -this.cone.lookAt(fj);void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Rb=new n,Wf=new P,th=new P;jd.prototype=Object.create(la.prototype);jd.prototype.constructor=jd;jd.prototype.updateMatrixWorld=function(a){var b=this.bones,c=this.geometry,d=c.getAttribute("position");th.getInverse(this.root.matrixWorld);for(var e=0,f=0;eMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);D.prototype.updateMatrixWorld.call(this,a)};var kj=new n,yf,Sg;yb.prototype=Object.create(D.prototype);yb.prototype.constructor=yb;yb.prototype.setDirection=function(a){.99999a.y?this.quaternion.set(1,0,0,0):(kj.set(a.z, -0,-a.x).normalize(),this.quaternion.setFromAxisAngle(kj,Math.acos(a.y)))};yb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(1E-4,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};yb.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};yb.prototype.copy=function(a){D.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone); -return this};yb.prototype.clone=function(){return(new this.constructor).copy(this)};xe.prototype=Object.create(la.prototype);xe.prototype.constructor=xe;var lb=Math.pow(2,8),lj=[.125,.215,.35,.446,.526,.582],vi=5+lj.length,mb={3E3:0,3001:1,3002:2,3004:3,3005:4,3006:5,3007:6},Vg=new gd,zf=function(a){var b=new Float32Array(a),c=new n(0,1,0);a=new vb({defines:{n:a},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:b},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}, -inputEncoding:{value:mb[3E3]},outputEncoding:{value:mb[3E3]}},vertexShader:Xg(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n"+Yg()+"\n\n#define ENVMAP_TYPE_CUBE_UV\n#include \n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfor (int dir = -1; dir < 2; dir += 2) {\n\t\t\tif (i == 0 && dir == 1)\n\t\t\t\tcontinue;\n\t\t\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\t\t\tif (all(equal(axis, vec3(0.0))))\n\t\t\t\taxis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection);\n\t\t\taxis = normalize(axis);\n\t\t\tfloat theta = dTheta * float(dir * i);\n\t\t\tfloat cosTheta = cos(theta);\n\t\t\t// Rodrigues' axis-angle rotation\n\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t\t\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\t\t\tgl_FragColor.rgb +=\n\t\t\t\t\tweights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt);\n\t\t}\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t", -blending:0,depthTest:!1,depthWrite:!1});a.type="SphericalGaussianBlur";return a}(20),Sb=null,Tb=null,uh=function(){for(var a=[],b=[],c=[],d=8,e=0;em;m++){var n=m%3*2/3-1,p=2p;p++)q=p%3,0==q?(c.up.set(0,d[p],0),c.lookAt(f[p],0,0)):1==q?(c.up.set(0,0,d[p]),c.lookAt(0,f[p],0)):(c.up.set(0,d[p],0),c.lookAt(0,0,f[p])),Wg(q*lb,2b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale= +b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else{this.time=b;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=b;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0=== +this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=b=0a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this.time=b,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}else this.time=b;if(f&&1===(e&1))return c-b}return b},_setEndings:function(a,b, +c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});Kg.prototype=Object.assign(Object.create(ua.prototype),{constructor:Kg,_bindAction:function(a, +b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],n=l.name,p=k[n];if(void 0===p){p=f[h];if(void 0!==p){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,g,n));continue}p=new Jg(ya.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName,l.getValueSize());++p.referenceCount;this._addInactiveBinding(p,g,n)}f[h]= +p;a[h].resultBuffer=p.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c= +0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length}, +get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&athis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a, +b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new v);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new v);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return Wi.copy(a).clamp(this.min, +this.max).sub(a).length()},intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var Xi=new n,Sf=new n;Object.assign(Pg.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start); +this.end.copy(a.end);return this},getCenter:function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new n);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new n);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){void 0=== +b&&(console.warn("THREE.Line3: .at() target is now required"),b=new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(a,b){Xi.subVectors(a,this.start);Sf.subVectors(this.end,this.start);a=Sf.dot(Sf);a=Sf.dot(Xi)/a;b&&(a=M.clamp(a,0,1));return a},closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)}, +applyMatrix4:function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});me.prototype=Object.create(E.prototype);me.prototype.constructor=me;me.prototype.isImmediateRenderObject=!0;var Yi=new n;gd.prototype=Object.create(E.prototype);gd.prototype.constructor=gd;gd.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};gd.prototype.update=function(){this.light.updateMatrixWorld(); +var a=this.light.distance?this.light.distance:1E3,b=a*Math.tan(this.light.angle);this.cone.scale.set(b,b,a);Yi.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(Yi);void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Tb=new n,Tf=new P,qh=new P;oc.prototype=Object.create(na.prototype);oc.prototype.constructor=oc;oc.prototype.isSkeletonHelper=!0;oc.prototype.updateMatrixWorld=function(a){var b=this.bones,c=this.geometry, +d=c.getAttribute("position");qh.getInverse(this.root.matrixWorld);for(var e=0,f=0;eMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);E.prototype.updateMatrixWorld.call(this,a)};var cj=new n,yf,Qg;wb.prototype=Object.create(E.prototype); +wb.prototype.constructor=wb;wb.prototype.setDirection=function(a){.99999a.y?this.quaternion.set(1,0,0,0):(cj.set(a.z,0,-a.x).normalize(),this.quaternion.setFromAxisAngle(cj,Math.acos(a.y)))};wb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(1E-4,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};wb.prototype.setColor=function(a){this.line.material.color.set(a); +this.cone.material.color.set(a)};wb.prototype.copy=function(a){E.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};wb.prototype.clone=function(){return(new this.constructor).copy(this)};qe.prototype=Object.create(na.prototype);qe.prototype.constructor=qe;var lb=Math.pow(2,8),dj=[.125,.215,.35,.446,.526,.582],ej=5+dj.length,kb={3E3:0,3001:1,3002:2,3004:3,3005:4,3006:5,3007:6},rh=new ed,sh=function(){for(var a=[],b=[],c=[],d=8,e=0;el;l++){var n=l%3*2/3-1,p=2p;p++)u=p%3,0==u?(b.up.set(0,c[p],0),b.lookAt(e[p],0,0)):1==u?(b.up.set(0,0,c[p]),b.lookAt(0,e[p],0)):(b.up.set(0,c[p],0),b.lookAt(0,0,e[p])),Ug(d,u*lb,2< +p?lb:0,lb,lb),f.setRenderTarget(d),f.render(a,b);f.toneMapping=h;f.toneMappingExposure=k;f.outputEncoding=g;f.setClearColor(l,n);a.scale.z*=-1},_textureToCubeUV:function(a,b){var c=new ob,d=this._renderer;a.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=ti()):null==this._equirectShader&&(this._equirectShader=si());var e=a.isCubeTexture?this._cubemapShader:this._equirectShader;c.add(new ja(Be[0],e));e=e.uniforms;e.envMap.value=a;a.isCubeTexture||e.texelSize.value.set(1/a.image.width, +1/a.image.height);e.inputEncoding.value=kb[a.encoding];e.outputEncoding.value=kb[b.texture.encoding];Ug(b,0,0,3*lb,2*lb);d.setRenderTarget(b);d.render(c,rh)},_applyPMREM:function(a){var b=this._renderer,c=b.autoClear;b.autoClear=!1;for(var d=1;dq;++q){var t=q/p;t=Math.exp(-t* +t/2);e.push(t);0==q?r+=t:q 0 ) { - return qm.copy( qa ).slerp( qb, t ); + console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); - }, + } - slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { +} - // fuzz-free, array-based Quaternion SLERP operation +Object.assign( Matrix3.prototype, { - var x0 = src0[ srcOffset0 + 0 ], - y0 = src0[ srcOffset0 + 1 ], - z0 = src0[ srcOffset0 + 2 ], - w0 = src0[ srcOffset0 + 3 ], + isMatrix3: true, - x1 = src1[ srcOffset1 + 0 ], - y1 = src1[ srcOffset1 + 1 ], - z1 = src1[ srcOffset1 + 2 ], - w1 = src1[ srcOffset1 + 3 ]; + set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { - if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { + var te = this.elements; - var s = 1 - t, + te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; + te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; + te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; - cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, + return this; - dir = ( cos >= 0 ? 1 : - 1 ), - sqrSin = 1 - cos * cos; + }, - // Skip the Slerp for tiny steps to avoid numeric problems: - if ( sqrSin > Number.EPSILON ) { + identity: function () { - var sin = Math.sqrt( sqrSin ), - len = Math.atan2( sin, cos * dir ); + this.set( - s = Math.sin( s * len ) / sin; - t = Math.sin( t * len ) / sin; + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 - } + ); - var tDir = t * dir; + return this; - x0 = x0 * s + x1 * tDir; - y0 = y0 * s + y1 * tDir; - z0 = z0 * s + z1 * tDir; - w0 = w0 * s + w1 * tDir; + }, - // Normalize in case we just did a lerp: - if ( s === 1 - t ) { + clone: function () { - var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); + return new this.constructor().fromArray( this.elements ); - x0 *= f; - y0 *= f; - z0 *= f; - w0 *= f; + }, - } + copy: function ( m ) { - } + var te = this.elements; + var me = m.elements; - dst[ dstOffset ] = x0; - dst[ dstOffset + 1 ] = y0; - dst[ dstOffset + 2 ] = z0; - dst[ dstOffset + 3 ] = w0; + te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; + te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; + te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; - } + return this; -} ); + }, -Object.defineProperties( Quaternion.prototype, { + extractBasis: function ( xAxis, yAxis, zAxis ) { - x: { + xAxis.setFromMatrix3Column( this, 0 ); + yAxis.setFromMatrix3Column( this, 1 ); + zAxis.setFromMatrix3Column( this, 2 ); - get: function () { + return this; - return this._x; + }, - }, + setFromMatrix4: function ( m ) { - set: function ( value ) { + var me = m.elements; - this._x = value; - this._onChangeCallback(); + this.set( - } + me[ 0 ], me[ 4 ], me[ 8 ], + me[ 1 ], me[ 5 ], me[ 9 ], + me[ 2 ], me[ 6 ], me[ 10 ] - }, + ); - y: { + return this; - get: function () { + }, - return this._y; + multiply: function ( m ) { - }, + return this.multiplyMatrices( this, m ); - set: function ( value ) { + }, - this._y = value; - this._onChangeCallback(); + premultiply: function ( m ) { - } + return this.multiplyMatrices( m, this ); }, - z: { + multiplyMatrices: function ( a, b ) { - get: function () { + var ae = a.elements; + var be = b.elements; + var te = this.elements; - return this._z; + var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; + var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; + var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; - }, + var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; + var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; + var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; - set: function ( value ) { + te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; + te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; + te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; - this._z = value; - this._onChangeCallback(); + te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; + te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; + te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; - } + te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; + te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; + te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + + return this; }, - w: { + multiplyScalar: function ( s ) { - get: function () { + var te = this.elements; - return this._w; + te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; + te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; + te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; - }, + return this; - set: function ( value ) { + }, - this._w = value; - this._onChangeCallback(); + determinant: function () { - } + var te = this.elements; - } + var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], + d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], + g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; -} ); + return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; -Object.assign( Quaternion.prototype, { + }, - isQuaternion: true, + getInverse: function ( matrix, throwOnDegenerate ) { - set: function ( x, y, z, w ) { + if ( throwOnDegenerate !== undefined ) { - this._x = x; - this._y = y; - this._z = z; - this._w = w; + console.warn( "THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate." ); - this._onChangeCallback(); + } - return this; + var me = matrix.elements, + te = this.elements, - }, + n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], + n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ], + n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ], - clone: function () { + t11 = n33 * n22 - n32 * n23, + t12 = n32 * n13 - n33 * n12, + t13 = n23 * n12 - n22 * n13, - return new this.constructor( this._x, this._y, this._z, this._w ); + det = n11 * t11 + n21 * t12 + n31 * t13; - }, + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 ); - copy: function ( quaternion ) { + var detInv = 1 / det; - this._x = quaternion.x; - this._y = quaternion.y; - this._z = quaternion.z; - this._w = quaternion.w; + te[ 0 ] = t11 * detInv; + te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; + te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; - this._onChangeCallback(); + te[ 3 ] = t12 * detInv; + te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; + te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + + te[ 6 ] = t13 * detInv; + te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; + te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; return this; }, - setFromEuler: function ( euler, update ) { - - if ( ! ( euler && euler.isEuler ) ) { - - throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); - - } + transpose: function () { - var x = euler._x, y = euler._y, z = euler._z, order = euler.order; + var tmp, m = this.elements; - // http://www.mathworks.com/matlabcentral/fileexchange/ - // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ - // content/SpinCalc.m + tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; + tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; + tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; - var cos = Math.cos; - var sin = Math.sin; + return this; - var c1 = cos( x / 2 ); - var c2 = cos( y / 2 ); - var c3 = cos( z / 2 ); + }, - var s1 = sin( x / 2 ); - var s2 = sin( y / 2 ); - var s3 = sin( z / 2 ); + getNormalMatrix: function ( matrix4 ) { - if ( order === 'XYZ' ) { + return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + }, - } else if ( order === 'YXZ' ) { + transposeIntoArray: function ( r ) { - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + var m = this.elements; - } else if ( order === 'ZXY' ) { + r[ 0 ] = m[ 0 ]; + r[ 1 ] = m[ 3 ]; + r[ 2 ] = m[ 6 ]; + r[ 3 ] = m[ 1 ]; + r[ 4 ] = m[ 4 ]; + r[ 5 ] = m[ 7 ]; + r[ 6 ] = m[ 2 ]; + r[ 7 ] = m[ 5 ]; + r[ 8 ] = m[ 8 ]; - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + return this; - } else if ( order === 'ZYX' ) { + }, - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) { - } else if ( order === 'YZX' ) { + var c = Math.cos( rotation ); + var s = Math.sin( rotation ); - this._x = s1 * c2 * c3 + c1 * s2 * s3; - this._y = c1 * s2 * c3 + s1 * c2 * s3; - this._z = c1 * c2 * s3 - s1 * s2 * c3; - this._w = c1 * c2 * c3 - s1 * s2 * s3; + this.set( + sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, + - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, + 0, 0, 1 + ); - } else if ( order === 'XZY' ) { + }, - this._x = s1 * c2 * c3 - c1 * s2 * s3; - this._y = c1 * s2 * c3 - s1 * c2 * s3; - this._z = c1 * c2 * s3 + s1 * s2 * c3; - this._w = c1 * c2 * c3 + s1 * s2 * s3; + scale: function ( sx, sy ) { - } + var te = this.elements; - if ( update !== false ) this._onChangeCallback(); + te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; + te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; return this; }, - setFromAxisAngle: function ( axis, angle ) { + rotate: function ( theta ) { - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm + var c = Math.cos( theta ); + var s = Math.sin( theta ); - // assumes axis is normalized + var te = this.elements; - var halfAngle = angle / 2, s = Math.sin( halfAngle ); + var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; + var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; - this._x = axis.x * s; - this._y = axis.y * s; - this._z = axis.z * s; - this._w = Math.cos( halfAngle ); + te[ 0 ] = c * a11 + s * a21; + te[ 3 ] = c * a12 + s * a22; + te[ 6 ] = c * a13 + s * a23; - this._onChangeCallback(); + te[ 1 ] = - s * a11 + c * a21; + te[ 4 ] = - s * a12 + c * a22; + te[ 7 ] = - s * a13 + c * a23; return this; }, - setFromRotationMatrix: function ( m ) { - - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - - // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + translate: function ( tx, ty ) { - var te = m.elements, + var te = this.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 ], + te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; + te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; - trace = m11 + m22 + m33, - s; + return this; - if ( trace > 0 ) { + }, - s = 0.5 / Math.sqrt( trace + 1.0 ); + equals: function ( matrix ) { - this._w = 0.25 / s; - this._x = ( m32 - m23 ) * s; - this._y = ( m13 - m31 ) * s; - this._z = ( m21 - m12 ) * s; + var te = this.elements; + var me = matrix.elements; - } else if ( m11 > m22 && m11 > m33 ) { + for ( var i = 0; i < 9; i ++ ) { - s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); + if ( te[ i ] !== me[ i ] ) return false; - this._w = ( m32 - m23 ) / s; - this._x = 0.25 * s; - this._y = ( m12 + m21 ) / s; - this._z = ( m13 + m31 ) / s; + } - } else if ( m22 > m33 ) { + return true; - s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); + }, - this._w = ( m13 - m31 ) / s; - this._x = ( m12 + m21 ) / s; - this._y = 0.25 * s; - this._z = ( m23 + m32 ) / s; + fromArray: function ( array, offset ) { - } else { + if ( offset === undefined ) offset = 0; - s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + for ( var i = 0; i < 9; i ++ ) { - this._w = ( m21 - m12 ) / s; - this._x = ( m13 + m31 ) / s; - this._y = ( m23 + m32 ) / s; - this._z = 0.25 * s; + this.elements[ i ] = array[ i + offset ]; } - this._onChangeCallback(); - return this; }, - setFromUnitVectors: function ( vFrom, vTo ) { + toArray: function ( array, offset ) { - // assumes direction vectors vFrom and vTo are normalized + if ( array === undefined ) array = []; + if ( offset === undefined ) offset = 0; - var EPS = 0.000001; + var te = this.elements; - var r = vFrom.dot( vTo ) + 1; + array[ offset ] = te[ 0 ]; + array[ offset + 1 ] = te[ 1 ]; + array[ offset + 2 ] = te[ 2 ]; - if ( r < EPS ) { + array[ offset + 3 ] = te[ 3 ]; + array[ offset + 4 ] = te[ 4 ]; + array[ offset + 5 ] = te[ 5 ]; - r = 0; + array[ offset + 6 ] = te[ 6 ]; + array[ offset + 7 ] = te[ 7 ]; + array[ offset + 8 ] = te[ 8 ]; - if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { + return array; - this._x = - vFrom.y; - this._y = vFrom.x; - this._z = 0; - this._w = r; + } - } else { +} ); - this._x = 0; - this._y = - vFrom.z; - this._z = vFrom.y; - this._w = r; +/** + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * @author szimek / https://github.com/szimek/ + */ - } +var _canvas; - } else { +var ImageUtils = { - // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 + getDataURL: function ( image ) { - this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; - this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; - this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; - this._w = r; + var canvas; - } + if ( typeof HTMLCanvasElement == 'undefined' ) { - return this.normalize(); + return image.src; - }, + } else if ( image instanceof HTMLCanvasElement ) { - angleTo: function ( q ) { + canvas = image; - return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) ); + } else { - }, + if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); - rotateTowards: function ( q, step ) { + _canvas.width = image.width; + _canvas.height = image.height; - var angle = this.angleTo( q ); + var context = _canvas.getContext( '2d' ); - if ( angle === 0 ) return this; + if ( image instanceof ImageData ) { - var t = Math.min( 1, step / angle ); + context.putImageData( image, 0, 0 ); - this.slerp( q, t ); + } else { - return this; + context.drawImage( image, 0, 0, image.width, image.height ); - }, + } - inverse: function () { + canvas = _canvas; - // quaternion is assumed to have unit length + } - return this.conjugate(); + if ( canvas.width > 2048 || canvas.height > 2048 ) { - }, + return canvas.toDataURL( 'image/jpeg', 0.6 ); - conjugate: function () { + } else { - this._x *= - 1; - this._y *= - 1; - this._z *= - 1; + return canvas.toDataURL( 'image/png' ); - this._onChangeCallback(); + } - return this; + } - }, +}; - dot: function ( v ) { +/** + * @author mrdoob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + * @author szimek / https://github.com/szimek/ + */ - return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; +var textureId = 0; - }, +function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - lengthSq: function () { + Object.defineProperty( this, 'id', { value: textureId ++ } ); - return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; + this.uuid = MathUtils.generateUUID(); - }, + this.name = ''; - length: function () { + this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; + this.mipmaps = []; - return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); + this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; - }, + this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; + this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; - normalize: function () { - - var l = this.length(); + this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; + this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; - if ( l === 0 ) { + this.anisotropy = anisotropy !== undefined ? anisotropy : 1; - this._x = 0; - this._y = 0; - this._z = 0; - this._w = 1; + this.format = format !== undefined ? format : RGBAFormat; + this.internalFormat = null; + this.type = type !== undefined ? type : UnsignedByteType; - } else { + this.offset = new Vector2( 0, 0 ); + this.repeat = new Vector2( 1, 1 ); + this.center = new Vector2( 0, 0 ); + this.rotation = 0; - l = 1 / l; + this.matrixAutoUpdate = true; + this.matrix = new Matrix3(); - this._x = this._x * l; - this._y = this._y * l; - this._z = this._z * l; - this._w = this._w * l; + 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._onChangeCallback(); + this.version = 0; + this.onUpdate = null; - return this; +} - }, +Texture.DEFAULT_IMAGE = undefined; +Texture.DEFAULT_MAPPING = UVMapping; - multiply: function ( q, p ) { +Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { - if ( p !== undefined ) { + constructor: Texture, - console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); - return this.multiplyQuaternions( q, p ); + isTexture: true, - } + updateMatrix: function () { - return this.multiplyQuaternions( this, q ); + this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); }, - premultiply: function ( q ) { + clone: function () { - return this.multiplyQuaternions( q, this ); + return new this.constructor().copy( this ); }, - multiplyQuaternions: function ( a, b ) { + copy: function ( source ) { - // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm + this.name = source.name; - var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; - var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; + this.image = source.image; + this.mipmaps = source.mipmaps.slice( 0 ); - this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; - this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; - this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; - this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + this.mapping = source.mapping; - this._onChangeCallback(); + 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.internalFormat = source.internalFormat; + this.type = source.type; + + this.offset.copy( source.offset ); + this.repeat.copy( source.repeat ); + this.center.copy( source.center ); + this.rotation = source.rotation; + + this.matrixAutoUpdate = source.matrixAutoUpdate; + this.matrix.copy( source.matrix ); + + this.generateMipmaps = source.generateMipmaps; + this.premultiplyAlpha = source.premultiplyAlpha; + this.flipY = source.flipY; + this.unpackAlignment = source.unpackAlignment; + this.encoding = source.encoding; return this; }, - slerp: function ( qb, t ) { + toJSON: function ( meta ) { - if ( t === 0 ) return this; - if ( t === 1 ) return this.copy( qb ); + var isRootObject = ( meta === undefined || typeof meta === 'string' ); - var x = this._x, y = this._y, z = this._z, w = this._w; + if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { - // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ + return meta.textures[ this.uuid ]; - var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; + } - if ( cosHalfTheta < 0 ) { + var output = { - this._w = - qb._w; - this._x = - qb._x; - this._y = - qb._y; - this._z = - qb._z; + metadata: { + version: 4.5, + type: 'Texture', + generator: 'Texture.toJSON' + }, - cosHalfTheta = - cosHalfTheta; + uuid: this.uuid, + name: this.name, - } else { + mapping: this.mapping, - this.copy( qb ); + repeat: [ this.repeat.x, this.repeat.y ], + offset: [ this.offset.x, this.offset.y ], + center: [ this.center.x, this.center.y ], + rotation: this.rotation, - } + wrap: [ this.wrapS, this.wrapT ], - if ( cosHalfTheta >= 1.0 ) { + format: this.format, + type: this.type, + encoding: this.encoding, - this._w = w; - this._x = x; - this._y = y; - this._z = z; + minFilter: this.minFilter, + magFilter: this.magFilter, + anisotropy: this.anisotropy, - return this; + flipY: this.flipY, - } + premultiplyAlpha: this.premultiplyAlpha, + unpackAlignment: this.unpackAlignment - var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; + }; - if ( sqrSinHalfTheta <= Number.EPSILON ) { + if ( this.image !== undefined ) { - var s = 1 - t; - this._w = s * w + t * this._w; - this._x = s * x + t * this._x; - this._y = s * y + t * this._y; - this._z = s * z + t * this._z; + // TODO: Move to THREE.Image - this.normalize(); - this._onChangeCallback(); + var image = this.image; - return this; + if ( image.uuid === undefined ) { + + image.uuid = MathUtils.generateUUID(); // UGH + + } + + if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + + var url; + + if ( Array.isArray( image ) ) { + + // process array of images e.g. CubeTexture + + url = []; + + for ( var i = 0, l = image.length; i < l; i ++ ) { + + url.push( ImageUtils.getDataURL( image[ i ] ) ); + + } + + } else { + + // process single image + + url = ImageUtils.getDataURL( image ); + + } + + meta.images[ image.uuid ] = { + uuid: image.uuid, + url: url + }; + + } + + output.image = image.uuid; } - var sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); - var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); - var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, - ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + if ( ! isRootObject ) { - this._w = ( w * ratioA + this._w * ratioB ); - this._x = ( x * ratioA + this._x * ratioB ); - this._y = ( y * ratioA + this._y * ratioB ); - this._z = ( z * ratioA + this._z * ratioB ); + meta.textures[ this.uuid ] = output; - this._onChangeCallback(); + } - return this; + return output; }, - equals: function ( quaternion ) { + dispose: function () { - return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); + this.dispatchEvent( { type: 'dispose' } ); }, - fromArray: function ( array, offset ) { + transformUv: function ( uv ) { - if ( offset === undefined ) offset = 0; + if ( this.mapping !== UVMapping ) return uv; - this._x = array[ offset ]; - this._y = array[ offset + 1 ]; - this._z = array[ offset + 2 ]; - this._w = array[ offset + 3 ]; + uv.applyMatrix3( this.matrix ); - this._onChangeCallback(); + if ( uv.x < 0 || uv.x > 1 ) { - return this; + switch ( this.wrapS ) { - }, + case RepeatWrapping: - toArray: function ( array, offset ) { + uv.x = uv.x - Math.floor( uv.x ); + break; - if ( array === undefined ) array = []; - if ( offset === undefined ) offset = 0; + case ClampToEdgeWrapping: - array[ offset ] = this._x; - array[ offset + 1 ] = this._y; - array[ offset + 2 ] = this._z; - array[ offset + 3 ] = this._w; + uv.x = uv.x < 0 ? 0 : 1; + break; - return array; + case MirroredRepeatWrapping: - }, + if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) { - _onChange: function ( callback ) { + uv.x = Math.ceil( uv.x ) - uv.x; - this._onChangeCallback = callback; + } else { - return this; + uv.x = uv.x - Math.floor( uv.x ); - }, + } - _onChangeCallback: function () {} + 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; + + } + + return uv; + + } + +} ); + +Object.defineProperty( Texture.prototype, "needsUpdate", { + + set: function ( value ) { + + if ( value === true ) this.version ++; + + } } ); /** - * @author mrdoob / http://mrdoob.com/ - * @author kile / http://kile.stravaganza.org/ + * @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 */ -var _vector = new Vector3(); -var _quaternion = new Quaternion(); - -function Vector3( x, y, z ) { +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( Vector3.prototype, { +Object.defineProperties( Vector4.prototype, { - isVector3: true, + "width": { - set: function ( x, y, z ) { + get: function () { + + return this.z; + + }, + + set: function ( value ) { + + this.z = value; + + } + + }, + + "height": { + + get: function () { + + return this.w; + + }, + + set: function ( value ) { + + this.w = value; + + } + + } + +} ); + +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; @@ -1668,6 +1882,7 @@ Object.assign( Vector3.prototype, { this.x = scalar; this.y = scalar; this.z = scalar; + this.w = scalar; return this; @@ -1697,6 +1912,14 @@ Object.assign( Vector3.prototype, { }, + setW: function ( w ) { + + this.w = w; + + return this; + + }, + setComponent: function ( index, value ) { switch ( index ) { @@ -1704,6 +1927,7 @@ Object.assign( Vector3.prototype, { 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 ); } @@ -1719,6 +1943,7 @@ Object.assign( Vector3.prototype, { 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 ); } @@ -1727,7 +1952,7 @@ Object.assign( Vector3.prototype, { clone: function () { - return new this.constructor( this.x, this.y, this.z ); + return new this.constructor( this.x, this.y, this.z, this.w ); }, @@ -1736,6 +1961,7 @@ Object.assign( Vector3.prototype, { this.x = v.x; this.y = v.y; this.z = v.z; + this.w = ( v.w !== undefined ) ? v.w : 1; return this; @@ -1745,7 +1971,7 @@ Object.assign( Vector3.prototype, { if ( w !== undefined ) { - console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } @@ -1753,6 +1979,7 @@ Object.assign( Vector3.prototype, { this.x += v.x; this.y += v.y; this.z += v.z; + this.w += v.w; return this; @@ -1763,6 +1990,7 @@ Object.assign( Vector3.prototype, { this.x += s; this.y += s; this.z += s; + this.w += s; return this; @@ -1773,6 +2001,7 @@ Object.assign( Vector3.prototype, { 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; @@ -1783,6 +2012,7 @@ Object.assign( Vector3.prototype, { this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; + this.w += v.w * s; return this; @@ -1792,7 +2022,7 @@ Object.assign( Vector3.prototype, { if ( w !== undefined ) { - console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } @@ -1800,6 +2030,7 @@ Object.assign( Vector3.prototype, { this.x -= v.x; this.y -= v.y; this.z -= v.z; + this.w -= v.w; return this; @@ -1810,6 +2041,7 @@ Object.assign( Vector3.prototype, { this.x -= s; this.y -= s; this.z -= s; + this.w -= s; return this; @@ -1820,23 +2052,7 @@ Object.assign( Vector3.prototype, { this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; - - return this; - - }, - - multiply: function ( v, w ) { - - if ( w !== undefined ) { - - console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); - return this.multiplyVectors( v, w ); - - } - - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; + this.w = a.w - b.w; return this; @@ -1847,136 +2063,187 @@ Object.assign( Vector3.prototype, { this.x *= scalar; this.y *= scalar; this.z *= scalar; + this.w *= scalar; return this; }, - multiplyVectors: function ( a, b ) { + applyMatrix4: function ( m ) { - this.x = a.x * b.x; - this.y = a.y * b.y; - this.z = a.z * b.z; + 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; }, - applyEuler: function ( euler ) { + divideScalar: function ( scalar ) { - if ( ! ( euler && euler.isEuler ) ) { + return this.multiplyScalar( 1 / scalar ); - console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); + }, - } + setAxisAngleFromQuaternion: function ( q ) { - return this.applyQuaternion( _quaternion.setFromEuler( euler ) ); + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm - }, + // q is assumed to be normalized - applyAxisAngle: function ( axis, angle ) { + this.w = 2 * Math.acos( q.w ); - return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); + var s = Math.sqrt( 1 - q.w * q.w ); - }, + if ( s < 0.0001 ) { - applyMatrix3: function ( m ) { + this.x = 1; + this.y = 0; + this.z = 0; - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + } else { - this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; - this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; - this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; + this.x = q.x / s; + this.y = q.y / s; + this.z = q.z / s; + + } return this; }, - applyNormalMatrix: function ( m ) { + setAxisAngleFromRotationMatrix: function ( m ) { - return this.applyMatrix3( m ).normalize(); + // 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) - applyMatrix4: function ( m ) { + 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 - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + te = m.elements, - var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); + 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 ]; - 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; + if ( ( Math.abs( m12 - m21 ) < epsilon ) && + ( Math.abs( m13 - m31 ) < epsilon ) && + ( Math.abs( m23 - m32 ) < epsilon ) ) { - return this; + // 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 ) ) { - applyQuaternion: function ( q ) { + // this singularity is identity matrix so angle = 0 - var x = this.x, y = this.y, z = this.z; - var qx = q.x, qy = q.y, qz = q.z, qw = q.w; + this.set( 1, 0, 0, 0 ); - // calculate quat * vector + return this; // zero angle, arbitrary axis - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = - qx * x - qy * y - qz * z; + } - // calculate result * inverse quat + // otherwise this singularity is angle = 180 - this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; - this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; - this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; + angle = Math.PI; - return this; + 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 ) ) { - project: function ( camera ) { + // m11 is the largest diagonal term - return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); + if ( xx < epsilon ) { - }, + x = 0; + y = 0.707106781; + z = 0.707106781; - unproject: function ( camera ) { + } else { - return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); + x = Math.sqrt( xx ); + y = xy / x; + z = xz / x; - }, + } - transformDirection: function ( m ) { + } else if ( yy > zz ) { - // input: THREE.Matrix4 affine matrix - // vector interpreted as a direction + // m22 is the largest diagonal term - var x = this.x, y = this.y, z = this.z; - var e = m.elements; + if ( yy < epsilon ) { - this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; - this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; - this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; + x = 0.707106781; + y = 0; + z = 0.707106781; - return this.normalize(); + } else { - }, + y = Math.sqrt( yy ); + x = xy / y; + z = yz / y; - divide: function ( v ) { + } - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; + } else { - return this; + // m33 is the largest diagonal term so base result on this - }, + if ( zz < epsilon ) { - divideScalar: function ( scalar ) { + x = 0.707106781; + y = 0.707106781; + z = 0; - return this.multiplyScalar( 1 / scalar ); + } 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; }, @@ -1985,6 +2252,7 @@ Object.assign( Vector3.prototype, { 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; @@ -1995,6 +2263,7 @@ Object.assign( Vector3.prototype, { 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; @@ -2007,6 +2276,7 @@ Object.assign( Vector3.prototype, { 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; @@ -2017,6 +2287,7 @@ Object.assign( Vector3.prototype, { this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); + this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); return this; @@ -2035,6 +2306,7 @@ Object.assign( Vector3.prototype, { 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; @@ -2045,6 +2317,7 @@ Object.assign( Vector3.prototype, { this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); this.z = Math.ceil( this.z ); + this.w = Math.ceil( this.w ); return this; @@ -2055,6 +2328,7 @@ Object.assign( Vector3.prototype, { this.x = Math.round( this.x ); this.y = Math.round( this.y ); this.z = Math.round( this.z ); + this.w = Math.round( this.w ); return this; @@ -2065,6 +2339,7 @@ Object.assign( Vector3.prototype, { 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 ); this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); + this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); return this; @@ -2075,6 +2350,7 @@ Object.assign( Vector3.prototype, { this.x = - this.x; this.y = - this.y; this.z = - this.z; + this.w = - this.w; return this; @@ -2082,27 +2358,25 @@ Object.assign( Vector3.prototype, { dot: function ( v ) { - return this.x * v.x + this.y * v.y + this.z * v.z; + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; }, - // TODO lengthSquared? - lengthSq: function () { - return this.x * this.x + this.y * this.y + this.z * this.z; + return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; }, length: function () { - return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); }, manhattanLength: function () { - return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); }, @@ -2123,6 +2397,7 @@ Object.assign( Vector3.prototype, { this.x += ( v.x - this.x ) * alpha; this.y += ( v.y - this.y ) * alpha; this.z += ( v.z - this.z ) * alpha; + this.w += ( v.w - this.w ) * alpha; return this; @@ -2134,201 +2409,187 @@ Object.assign( Vector3.prototype, { }, - cross: function ( v, w ) { - - if ( w !== undefined ) { - - console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); - return this.crossVectors( v, w ); - - } + equals: function ( v ) { - return this.crossVectors( this, v ); + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); }, - crossVectors: function ( a, b ) { + fromArray: function ( array, offset ) { - var ax = a.x, ay = a.y, az = a.z; - var bx = b.x, by = b.y, bz = b.z; + if ( offset === undefined ) offset = 0; - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + this.w = array[ offset + 3 ]; return this; }, - projectOnVector: function ( v ) { + toArray: function ( array, offset ) { - // v cannot be the zero v + if ( array === undefined ) array = []; + if ( offset === undefined ) offset = 0; - var scalar = v.dot( this ) / v.lengthSq(); + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + array[ offset + 3 ] = this.w; - return this.copy( v ).multiplyScalar( scalar ); + return array; }, - projectOnPlane: function ( planeNormal ) { - - _vector.copy( this ).projectOnVector( planeNormal ); + fromBufferAttribute: function ( attribute, index, offset ) { - return this.sub( _vector ); + if ( offset !== undefined ) { - }, + console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); - reflect: function ( normal ) { + } - // reflect incident vector off plane orthogonal to normal - // normal is assumed to have unit length + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + this.w = attribute.getW( index ); - return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); + return this; }, - angleTo: function ( v ) { - - var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); + random: function () { - if ( denominator === 0 ) console.error( 'THREE.Vector3: angleTo() can\'t handle zero length vectors.' ); + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); + this.w = Math.random(); - var theta = this.dot( v ) / denominator; + return this; - // clamp, to handle numerical problems + } - return Math.acos( _Math.clamp( theta, - 1, 1 ) ); +} ); - }, +/** + * @author szimek / https://github.com/szimek/ + * @author alteredq / http://alteredqualia.com/ + * @author Marius Kintel / https://github.com/kintel + */ - distanceTo: function ( v ) { +/* + In options, we can specify: + * Texture parameters for an auto-generated target texture + * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers +*/ +function WebGLRenderTarget( width, height, options ) { - return Math.sqrt( this.distanceToSquared( v ) ); + this.width = width; + this.height = height; - }, + this.scissor = new Vector4( 0, 0, width, height ); + this.scissorTest = false; - distanceToSquared: function ( v ) { + this.viewport = new Vector4( 0, 0, width, height ); - var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + options = options || {}; - return dx * dx + dy * dy + dz * dz; + this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); - }, + this.texture.image = {}; + this.texture.image.width = width; + this.texture.image.height = height; - manhattanDistanceTo: function ( v ) { + this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; + this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; - return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); + this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; + this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; + this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; - }, +} - setFromSpherical: function ( s ) { +WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { - return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); + constructor: WebGLRenderTarget, - }, + isWebGLRenderTarget: true, - setFromSphericalCoords: function ( radius, phi, theta ) { + setSize: function ( width, height ) { - var sinPhiRadius = Math.sin( phi ) * radius; + if ( this.width !== width || this.height !== height ) { - this.x = sinPhiRadius * Math.sin( theta ); - this.y = Math.cos( phi ) * radius; - this.z = sinPhiRadius * Math.cos( theta ); + this.width = width; + this.height = height; - return this; + this.texture.image.width = width; + this.texture.image.height = height; - }, + this.dispose(); - setFromCylindrical: function ( c ) { + } - return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); + this.viewport.set( 0, 0, width, height ); + this.scissor.set( 0, 0, width, height ); }, - setFromCylindricalCoords: function ( radius, theta, y ) { - - this.x = radius * Math.sin( theta ); - this.y = y; - this.z = radius * Math.cos( theta ); + clone: function () { - return this; + return new this.constructor().copy( this ); }, - setFromMatrixPosition: function ( m ) { - - var e = m.elements; - - this.x = e[ 12 ]; - this.y = e[ 13 ]; - this.z = e[ 14 ]; - - return this; + copy: function ( source ) { - }, + this.width = source.width; + this.height = source.height; - setFromMatrixScale: function ( m ) { + this.viewport.copy( source.viewport ); - var sx = this.setFromMatrixColumn( m, 0 ).length(); - var sy = this.setFromMatrixColumn( m, 1 ).length(); - var sz = this.setFromMatrixColumn( m, 2 ).length(); + this.texture = source.texture.clone(); - this.x = sx; - this.y = sy; - this.z = sz; + this.depthBuffer = source.depthBuffer; + this.stencilBuffer = source.stencilBuffer; + this.depthTexture = source.depthTexture; return this; }, - setFromMatrixColumn: function ( m, index ) { - - return this.fromArray( m.elements, index * 4 ); - - }, - - equals: function ( v ) { - - return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); - - }, - - fromArray: function ( array, offset ) { + dispose: function () { - if ( offset === undefined ) offset = 0; + this.dispatchEvent( { type: 'dispose' } ); - this.x = array[ offset ]; - this.y = array[ offset + 1 ]; - this.z = array[ offset + 2 ]; + } - return this; +} ); - }, +/** + * @author Mugen87 / https://github.com/Mugen87 + * @author Matt DesLauriers / @mattdesl + */ - toArray: function ( array, offset ) { +function WebGLMultisampleRenderTarget( width, height, options ) { - if ( array === undefined ) array = []; - if ( offset === undefined ) offset = 0; + WebGLRenderTarget.call( this, width, height, options ); - array[ offset ] = this.x; - array[ offset + 1 ] = this.y; - array[ offset + 2 ] = this.z; + this.samples = 4; - return array; +} - }, +WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { - fromBufferAttribute: function ( attribute, index, offset ) { + constructor: WebGLMultisampleRenderTarget, - if ( offset !== undefined ) { + isWebGLMultisampleRenderTarget: true, - console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + copy: function ( source ) { - } + WebGLRenderTarget.prototype.copy.call( this, source ); - this.x = attribute.getX( index ); - this.y = attribute.getY( index ); - this.z = attribute.getZ( index ); + this.samples = source.samples; return this; @@ -2337,822 +2598,703 @@ Object.assign( Vector3.prototype, { } ); /** + * @author mikael emtinger / http://gomo.se/ * @author alteredq / http://alteredqualia.com/ * @author WestLangley / http://github.com/WestLangley * @author bhouston / http://clara.io - * @author tschw */ -var _vector$1 = new Vector3(); +function Quaternion( x, y, z, w ) { -function Matrix3() { + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this._w = ( w !== undefined ) ? w : 1; - this.elements = [ +} - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 +Object.assign( Quaternion, { - ]; + slerp: function ( qa, qb, qm, t ) { - if ( arguments.length > 0 ) { + return qm.copy( qa ).slerp( qb, t ); - console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); + }, - } + slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { -} + // fuzz-free, array-based Quaternion SLERP operation -Object.assign( Matrix3.prototype, { + var x0 = src0[ srcOffset0 + 0 ], + y0 = src0[ srcOffset0 + 1 ], + z0 = src0[ srcOffset0 + 2 ], + w0 = src0[ srcOffset0 + 3 ], - isMatrix3: true, + x1 = src1[ srcOffset1 + 0 ], + y1 = src1[ srcOffset1 + 1 ], + z1 = src1[ srcOffset1 + 2 ], + w1 = src1[ srcOffset1 + 3 ]; - set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) { + if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) { - var te = this.elements; + var s = 1 - t, - te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31; - te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32; - te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33; + cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, - return this; + dir = ( cos >= 0 ? 1 : - 1 ), + sqrSin = 1 - cos * cos; - }, + // Skip the Slerp for tiny steps to avoid numeric problems: + if ( sqrSin > Number.EPSILON ) { - identity: function () { + var sin = Math.sqrt( sqrSin ), + len = Math.atan2( sin, cos * dir ); - this.set( + s = Math.sin( s * len ) / sin; + t = Math.sin( t * len ) / sin; - 1, 0, 0, - 0, 1, 0, - 0, 0, 1 + } - ); + var tDir = t * dir; - return this; + x0 = x0 * s + x1 * tDir; + y0 = y0 * s + y1 * tDir; + z0 = z0 * s + z1 * tDir; + w0 = w0 * s + w1 * tDir; - }, + // Normalize in case we just did a lerp: + if ( s === 1 - t ) { - clone: function () { + var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 ); - return new this.constructor().fromArray( this.elements ); + x0 *= f; + y0 *= f; + z0 *= f; + w0 *= f; - }, + } - copy: function ( m ) { + } - var te = this.elements; - var me = m.elements; + dst[ dstOffset ] = x0; + dst[ dstOffset + 1 ] = y0; + dst[ dstOffset + 2 ] = z0; + dst[ dstOffset + 3 ] = w0; - te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; - te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; - te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ]; + }, - return this; + multiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) { - }, + var x0 = src0[ srcOffset0 ]; + var y0 = src0[ srcOffset0 + 1 ]; + var z0 = src0[ srcOffset0 + 2 ]; + var w0 = src0[ srcOffset0 + 3 ]; - setFromMatrix4: function ( m ) { + var x1 = src1[ srcOffset1 ]; + var y1 = src1[ srcOffset1 + 1 ]; + var z1 = src1[ srcOffset1 + 2 ]; + var w1 = src1[ srcOffset1 + 3 ]; - var me = m.elements; + dst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1; + dst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1; + dst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1; + dst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1; - this.set( + return dst; - me[ 0 ], me[ 4 ], me[ 8 ], - me[ 1 ], me[ 5 ], me[ 9 ], - me[ 2 ], me[ 6 ], me[ 10 ] + } - ); +} ); - return this; +Object.defineProperties( Quaternion.prototype, { - }, + x: { - applyToBufferAttribute: function ( attribute ) { + get: function () { - for ( var i = 0, l = attribute.count; i < l; i ++ ) { + return this._x; - _vector$1.x = attribute.getX( i ); - _vector$1.y = attribute.getY( i ); - _vector$1.z = attribute.getZ( i ); + }, - _vector$1.applyMatrix3( this ); + set: function ( value ) { - attribute.setXYZ( i, _vector$1.x, _vector$1.y, _vector$1.z ); + this._x = value; + this._onChangeCallback(); } - return attribute; - }, - multiply: function ( m ) { + y: { - return this.multiplyMatrices( this, m ); + get: function () { - }, + return this._y; - premultiply: function ( m ) { + }, - return this.multiplyMatrices( m, this ); + set: function ( value ) { - }, + this._y = value; + this._onChangeCallback(); - multiplyMatrices: function ( a, b ) { + } - var ae = a.elements; - var be = b.elements; - var te = this.elements; + }, - var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ]; - var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ]; - var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ]; + z: { - var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ]; - var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ]; - var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ]; + get: function () { - te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31; - te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32; - te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33; + return this._z; - te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31; - te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32; - te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33; + }, - te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31; - te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32; - te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33; + set: function ( value ) { - return this; + this._z = value; + this._onChangeCallback(); + + } }, - multiplyScalar: function ( s ) { + w: { - var te = this.elements; + get: function () { - te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s; - te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s; - te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s; + return this._w; - return this; + }, - }, + set: function ( value ) { - determinant: function () { + this._w = value; + this._onChangeCallback(); - var te = this.elements; + } - var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ], - d = te[ 3 ], e = te[ 4 ], f = te[ 5 ], - g = te[ 6 ], h = te[ 7 ], i = te[ 8 ]; + } - return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g; +} ); - }, +Object.assign( Quaternion.prototype, { - getInverse: function ( matrix, throwOnDegenerate ) { + isQuaternion: true, - if ( matrix && matrix.isMatrix4 ) { + set: function ( x, y, z, w ) { - console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." ); + this._x = x; + this._y = y; + this._z = z; + this._w = w; - } + this._onChangeCallback(); - var me = matrix.elements, - te = this.elements, + return this; - n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], - n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ], - n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ], + }, - t11 = n33 * n22 - n32 * n23, - t12 = n32 * n13 - n33 * n12, - t13 = n23 * n12 - n22 * n13, - - det = n11 * t11 + n21 * t12 + n31 * t13; - - if ( det === 0 ) { - - var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0"; - - if ( throwOnDegenerate === true ) { - - throw new Error( msg ); - - } else { - - console.warn( msg ); - - } - - return this.identity(); + clone: function () { - } + return new this.constructor( this._x, this._y, this._z, this._w ); - var detInv = 1 / det; + }, - te[ 0 ] = t11 * detInv; - te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv; - te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv; + copy: function ( quaternion ) { - te[ 3 ] = t12 * detInv; - te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv; - te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv; + this._x = quaternion.x; + this._y = quaternion.y; + this._z = quaternion.z; + this._w = quaternion.w; - te[ 6 ] = t13 * detInv; - te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv; - te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv; + this._onChangeCallback(); return this; }, - transpose: function () { - - var tmp, m = this.elements; + setFromEuler: function ( euler, update ) { - tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp; - tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp; - tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp; + if ( ! ( euler && euler.isEuler ) ) { - return this; + throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' ); - }, + } - getNormalMatrix: function ( matrix4 ) { + var x = euler._x, y = euler._y, z = euler._z, order = euler.order; - return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); + // http://www.mathworks.com/matlabcentral/fileexchange/ + // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ + // content/SpinCalc.m - }, + var cos = Math.cos; + var sin = Math.sin; - transposeIntoArray: function ( r ) { + var c1 = cos( x / 2 ); + var c2 = cos( y / 2 ); + var c3 = cos( z / 2 ); - var m = this.elements; + var s1 = sin( x / 2 ); + var s2 = sin( y / 2 ); + var s3 = sin( z / 2 ); - r[ 0 ] = m[ 0 ]; - r[ 1 ] = m[ 3 ]; - r[ 2 ] = m[ 6 ]; - r[ 3 ] = m[ 1 ]; - r[ 4 ] = m[ 4 ]; - r[ 5 ] = m[ 7 ]; - r[ 6 ] = m[ 2 ]; - r[ 7 ] = m[ 5 ]; - r[ 8 ] = m[ 8 ]; + switch ( order ) { - return this; + case 'XYZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - }, + case 'YXZ': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) { + case 'ZXY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - var c = Math.cos( rotation ); - var s = Math.sin( rotation ); + case 'ZYX': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - this.set( - sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx, - - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty, - 0, 0, 1 - ); + case 'YZX': + this._x = s1 * c2 * c3 + c1 * s2 * s3; + this._y = c1 * s2 * c3 + s1 * c2 * s3; + this._z = c1 * c2 * s3 - s1 * s2 * c3; + this._w = c1 * c2 * c3 - s1 * s2 * s3; + break; - }, + case 'XZY': + this._x = s1 * c2 * c3 - c1 * s2 * s3; + this._y = c1 * s2 * c3 - s1 * c2 * s3; + this._z = c1 * c2 * s3 + s1 * s2 * c3; + this._w = c1 * c2 * c3 + s1 * s2 * s3; + break; - scale: function ( sx, sy ) { + default: + console.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order ); - var te = this.elements; + } - te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx; - te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy; + if ( update !== false ) this._onChangeCallback(); return this; }, - rotate: function ( theta ) { + setFromAxisAngle: function ( axis, angle ) { - var c = Math.cos( theta ); - var s = Math.sin( theta ); + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm - var te = this.elements; + // assumes axis is normalized - var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ]; - var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ]; + var halfAngle = angle / 2, s = Math.sin( halfAngle ); - te[ 0 ] = c * a11 + s * a21; - te[ 3 ] = c * a12 + s * a22; - te[ 6 ] = c * a13 + s * a23; + this._x = axis.x * s; + this._y = axis.y * s; + this._z = axis.z * s; + this._w = Math.cos( halfAngle ); - te[ 1 ] = - s * a11 + c * a21; - te[ 4 ] = - s * a12 + c * a22; - te[ 7 ] = - s * a13 + c * a23; + this._onChangeCallback(); return this; }, - translate: function ( tx, ty ) { + setFromRotationMatrix: function ( m ) { - var te = this.elements; + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm - te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ]; - te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ]; + // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) - return this; + var 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 ], - equals: function ( matrix ) { + trace = m11 + m22 + m33, + s; - var te = this.elements; - var me = matrix.elements; + if ( trace > 0 ) { - for ( var i = 0; i < 9; i ++ ) { + s = 0.5 / Math.sqrt( trace + 1.0 ); - if ( te[ i ] !== me[ i ] ) return false; + this._w = 0.25 / s; + this._x = ( m32 - m23 ) * s; + this._y = ( m13 - m31 ) * s; + this._z = ( m21 - m12 ) * s; - } + } else if ( m11 > m22 && m11 > m33 ) { - return true; + s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); - }, + this._w = ( m32 - m23 ) / s; + this._x = 0.25 * s; + this._y = ( m12 + m21 ) / s; + this._z = ( m13 + m31 ) / s; - fromArray: function ( array, offset ) { + } else if ( m22 > m33 ) { - if ( offset === undefined ) offset = 0; + s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); - for ( var i = 0; i < 9; i ++ ) { + this._w = ( m13 - m31 ) / s; + this._x = ( m12 + m21 ) / s; + this._y = 0.25 * s; + this._z = ( m23 + m32 ) / s; - this.elements[ i ] = array[ i + offset ]; + } else { + + s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); + + this._w = ( m21 - m12 ) / s; + this._x = ( m13 + m31 ) / s; + this._y = ( m23 + m32 ) / s; + this._z = 0.25 * s; } + this._onChangeCallback(); + return this; }, - toArray: function ( array, offset ) { + setFromUnitVectors: function ( vFrom, vTo ) { - if ( array === undefined ) array = []; - if ( offset === undefined ) offset = 0; + // assumes direction vectors vFrom and vTo are normalized - var te = this.elements; + var EPS = 0.000001; - array[ offset ] = te[ 0 ]; - array[ offset + 1 ] = te[ 1 ]; - array[ offset + 2 ] = te[ 2 ]; + var r = vFrom.dot( vTo ) + 1; - array[ offset + 3 ] = te[ 3 ]; - array[ offset + 4 ] = te[ 4 ]; - array[ offset + 5 ] = te[ 5 ]; + if ( r < EPS ) { - array[ offset + 6 ] = te[ 6 ]; - array[ offset + 7 ] = te[ 7 ]; - array[ offset + 8 ] = te[ 8 ]; + r = 0; - return array; + if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) { - } + this._x = - vFrom.y; + this._y = vFrom.x; + this._z = 0; + this._w = r; -} ); + } else { -/** - * @author mrdoob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * @author szimek / https://github.com/szimek/ - */ + this._x = 0; + this._y = - vFrom.z; + this._z = vFrom.y; + this._w = r; -var _canvas; + } -var ImageUtils = { + } else { - getDataURL: function ( image ) { + // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3 - var canvas; + this._x = vFrom.y * vTo.z - vFrom.z * vTo.y; + this._y = vFrom.z * vTo.x - vFrom.x * vTo.z; + this._z = vFrom.x * vTo.y - vFrom.y * vTo.x; + this._w = r; - if ( typeof HTMLCanvasElement == 'undefined' ) { + } - return image.src; + return this.normalize(); - } else if ( image instanceof HTMLCanvasElement ) { + }, - canvas = image; + angleTo: function ( q ) { - } else { + return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) ); - if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); + }, - _canvas.width = image.width; - _canvas.height = image.height; + rotateTowards: function ( q, step ) { - var context = _canvas.getContext( '2d' ); + var angle = this.angleTo( q ); - if ( image instanceof ImageData ) { + if ( angle === 0 ) return this; - context.putImageData( image, 0, 0 ); + var t = Math.min( 1, step / angle ); - } else { + this.slerp( q, t ); - context.drawImage( image, 0, 0, image.width, image.height ); + return this; - } + }, - canvas = _canvas; + inverse: function () { - } + // quaternion is assumed to have unit length - if ( canvas.width > 2048 || canvas.height > 2048 ) { + return this.conjugate(); - return canvas.toDataURL( 'image/jpeg', 0.6 ); + }, - } else { + conjugate: function () { - return canvas.toDataURL( 'image/png' ); + this._x *= - 1; + this._y *= - 1; + this._z *= - 1; - } + this._onChangeCallback(); - } + return this; -}; + }, -/** - * @author mrdoob / http://mrdoob.com/ - * @author alteredq / http://alteredqualia.com/ - * @author szimek / https://github.com/szimek/ - */ + dot: function ( v ) { -var textureId = 0; + return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; -function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { + }, - Object.defineProperty( this, 'id', { value: textureId ++ } ); + lengthSq: function () { - this.uuid = _Math.generateUUID(); + return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; - this.name = ''; + }, - this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; - this.mipmaps = []; + length: function () { - this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; + return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); - this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; - this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; + }, - this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; - this.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter; + normalize: function () { - this.anisotropy = anisotropy !== undefined ? anisotropy : 1; + var l = this.length(); - this.format = format !== undefined ? format : RGBAFormat; - this.internalFormat = null; - this.type = type !== undefined ? type : UnsignedByteType; + if ( l === 0 ) { - this.offset = new Vector2( 0, 0 ); - this.repeat = new Vector2( 1, 1 ); - this.center = new Vector2( 0, 0 ); - this.rotation = 0; + this._x = 0; + this._y = 0; + this._z = 0; + this._w = 1; - this.matrixAutoUpdate = true; - this.matrix = new Matrix3(); + } else { - 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) + l = 1 / l; - // 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._x = this._x * l; + this._y = this._y * l; + this._z = this._z * l; + this._w = this._w * l; - this.version = 0; - this.onUpdate = null; + } -} + this._onChangeCallback(); -Texture.DEFAULT_IMAGE = undefined; -Texture.DEFAULT_MAPPING = UVMapping; + return this; -Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { + }, - constructor: Texture, + multiply: function ( q, p ) { - isTexture: true, + if ( p !== undefined ) { - updateMatrix: function () { + console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); + return this.multiplyQuaternions( q, p ); - this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); + } + + return this.multiplyQuaternions( this, q ); }, - clone: function () { + premultiply: function ( q ) { - return new this.constructor().copy( this ); + return this.multiplyQuaternions( q, this ); }, - copy: function ( source ) { + multiplyQuaternions: function ( a, b ) { - this.name = source.name; + // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm - this.image = source.image; - this.mipmaps = source.mipmaps.slice( 0 ); + var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; + var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; - this.mapping = source.mapping; + this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; - this.wrapS = source.wrapS; - this.wrapT = source.wrapT; + this._onChangeCallback(); - this.magFilter = source.magFilter; - this.minFilter = source.minFilter; + return this; - this.anisotropy = source.anisotropy; + }, - this.format = source.format; - this.internalFormat = source.internalFormat; - this.type = source.type; + slerp: function ( qb, t ) { - this.offset.copy( source.offset ); - this.repeat.copy( source.repeat ); - this.center.copy( source.center ); - this.rotation = source.rotation; + if ( t === 0 ) return this; + if ( t === 1 ) return this.copy( qb ); - this.matrixAutoUpdate = source.matrixAutoUpdate; - this.matrix.copy( source.matrix ); + var x = this._x, y = this._y, z = this._z, w = this._w; - this.generateMipmaps = source.generateMipmaps; - this.premultiplyAlpha = source.premultiplyAlpha; - this.flipY = source.flipY; - this.unpackAlignment = source.unpackAlignment; - this.encoding = source.encoding; + // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ - return this; + var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; - }, + if ( cosHalfTheta < 0 ) { - toJSON: function ( meta ) { + this._w = - qb._w; + this._x = - qb._x; + this._y = - qb._y; + this._z = - qb._z; - var isRootObject = ( meta === undefined || typeof meta === 'string' ); + cosHalfTheta = - cosHalfTheta; - if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) { + } else { - return meta.textures[ this.uuid ]; + this.copy( qb ); } - var output = { - - metadata: { - version: 4.5, - type: 'Texture', - generator: 'Texture.toJSON' - }, + if ( cosHalfTheta >= 1.0 ) { - uuid: this.uuid, - name: this.name, + this._w = w; + this._x = x; + this._y = y; + this._z = z; - mapping: this.mapping, + return this; - repeat: [ this.repeat.x, this.repeat.y ], - offset: [ this.offset.x, this.offset.y ], - center: [ this.center.x, this.center.y ], - rotation: this.rotation, + } - wrap: [ this.wrapS, this.wrapT ], + var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta; - format: this.format, - type: this.type, - encoding: this.encoding, + if ( sqrSinHalfTheta <= Number.EPSILON ) { - minFilter: this.minFilter, - magFilter: this.magFilter, - anisotropy: this.anisotropy, + var s = 1 - t; + this._w = s * w + t * this._w; + this._x = s * x + t * this._x; + this._y = s * y + t * this._y; + this._z = s * z + t * this._z; - flipY: this.flipY, + this.normalize(); + this._onChangeCallback(); - premultiplyAlpha: this.premultiplyAlpha, - unpackAlignment: this.unpackAlignment + return this; - }; + } - if ( this.image !== undefined ) { + var sinHalfTheta = Math.sqrt( sqrSinHalfTheta ); + var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta ); + var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; - // TODO: Move to THREE.Image + this._w = ( w * ratioA + this._w * ratioB ); + this._x = ( x * ratioA + this._x * ratioB ); + this._y = ( y * ratioA + this._y * ratioB ); + this._z = ( z * ratioA + this._z * ratioB ); - var image = this.image; + this._onChangeCallback(); - if ( image.uuid === undefined ) { + return this; - image.uuid = _Math.generateUUID(); // UGH + }, - } + equals: function ( quaternion ) { - if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) { + return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); - var url; + }, - if ( Array.isArray( image ) ) { + fromArray: function ( array, offset ) { - // process array of images e.g. CubeTexture + if ( offset === undefined ) offset = 0; - url = []; + this._x = array[ offset ]; + this._y = array[ offset + 1 ]; + this._z = array[ offset + 2 ]; + this._w = array[ offset + 3 ]; - for ( var i = 0, l = image.length; i < l; i ++ ) { + this._onChangeCallback(); - url.push( ImageUtils.getDataURL( image[ i ] ) ); + return this; - } + }, - } else { + toArray: function ( array, offset ) { - // process single image + if ( array === undefined ) array = []; + if ( offset === undefined ) offset = 0; - url = ImageUtils.getDataURL( image ); + array[ offset ] = this._x; + array[ offset + 1 ] = this._y; + array[ offset + 2 ] = this._z; + array[ offset + 3 ] = this._w; - } + return array; - meta.images[ image.uuid ] = { - uuid: image.uuid, - url: url - }; + }, - } + fromBufferAttribute: function ( attribute, index ) { - output.image = image.uuid; + this._x = attribute.getX( index ); + this._y = attribute.getY( index ); + this._z = attribute.getZ( index ); + this._w = attribute.getW( index ); - } + return this; - if ( ! isRootObject ) { + }, - meta.textures[ this.uuid ] = output; + _onChange: function ( callback ) { - } + this._onChangeCallback = callback; - return output; + return this; }, - dispose: function () { - - this.dispatchEvent( { type: 'dispose' } ); - - }, - - transformUv: function ( uv ) { - - if ( this.mapping !== UVMapping ) return uv; - - uv.applyMatrix3( this.matrix ); - - 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; - - } - - return uv; - - } - -} ); - -Object.defineProperty( Texture.prototype, "needsUpdate", { - - set: function ( value ) { - - if ( value === true ) this.version ++; - - } + _onChangeCallback: function () {} } ); /** - * @author supereggbert / http://www.paulbrunt.co.uk/ + * @author mrdoob / http://mrdoob.com/ + * @author kile / http://kile.stravaganza.org/ * @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 ) { +var _vector = new Vector3(); +var _quaternion = new Quaternion(); + +function Vector3( x, y, z ) { this.x = x || 0; this.y = y || 0; this.z = z || 0; - this.w = ( w !== undefined ) ? w : 1; } -Object.defineProperties( Vector4.prototype, { - - "width": { - - get: function () { - - return this.z; - - }, - - set: function ( value ) { - - this.z = value; - - } - - }, - - "height": { - - get: function () { - - return this.w; - - }, - - set: function ( value ) { - - this.w = value; - - } - - } - -} ); - -Object.assign( Vector4.prototype, { +Object.assign( Vector3.prototype, { - isVector4: true, + isVector3: true, - set: function ( x, y, z, w ) { + set: function ( x, y, z ) { this.x = x; this.y = y; this.z = z; - this.w = w; return this; @@ -3163,7 +3305,6 @@ Object.assign( Vector4.prototype, { this.x = scalar; this.y = scalar; this.z = scalar; - this.w = scalar; return this; @@ -3193,14 +3334,6 @@ Object.assign( Vector4.prototype, { }, - setW: function ( w ) { - - this.w = w; - - return this; - - }, - setComponent: function ( index, value ) { switch ( index ) { @@ -3208,7 +3341,6 @@ Object.assign( Vector4.prototype, { 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 ); } @@ -3224,7 +3356,6 @@ Object.assign( Vector4.prototype, { 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 ); } @@ -3233,7 +3364,7 @@ Object.assign( Vector4.prototype, { clone: function () { - return new this.constructor( this.x, this.y, this.z, this.w ); + return new this.constructor( this.x, this.y, this.z ); }, @@ -3242,7 +3373,6 @@ Object.assign( Vector4.prototype, { this.x = v.x; this.y = v.y; this.z = v.z; - this.w = ( v.w !== undefined ) ? v.w : 1; return this; @@ -3252,7 +3382,7 @@ Object.assign( Vector4.prototype, { if ( w !== undefined ) { - console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } @@ -3260,7 +3390,6 @@ Object.assign( Vector4.prototype, { this.x += v.x; this.y += v.y; this.z += v.z; - this.w += v.w; return this; @@ -3271,7 +3400,6 @@ Object.assign( Vector4.prototype, { this.x += s; this.y += s; this.z += s; - this.w += s; return this; @@ -3282,7 +3410,6 @@ Object.assign( Vector4.prototype, { 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; @@ -3293,7 +3420,6 @@ Object.assign( Vector4.prototype, { this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; - this.w += v.w * s; return this; @@ -3303,7 +3429,7 @@ Object.assign( Vector4.prototype, { if ( w !== undefined ) { - console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); + console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } @@ -3311,7 +3437,6 @@ Object.assign( Vector4.prototype, { this.x -= v.x; this.y -= v.y; this.z -= v.z; - this.w -= v.w; return this; @@ -3322,7 +3447,6 @@ Object.assign( Vector4.prototype, { this.x -= s; this.y -= s; this.z -= s; - this.w -= s; return this; @@ -3333,198 +3457,163 @@ Object.assign( Vector4.prototype, { 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; + multiply: function ( v, w ) { - }, + if ( w !== undefined ) { - applyMatrix4: function ( m ) { + console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); + return this.multiplyVectors( v, w ); - 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; + this.x *= v.x; + this.y *= v.y; + this.z *= v.z; return this; }, - divideScalar: function ( scalar ) { - - return this.multiplyScalar( 1 / scalar ); + multiplyScalar: function ( scalar ) { - }, + this.x *= scalar; + this.y *= scalar; + this.z *= scalar; - setAxisAngleFromQuaternion: function ( q ) { + return this; - // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + }, - // q is assumed to be normalized + multiplyVectors: function ( a, b ) { - this.w = 2 * Math.acos( q.w ); + this.x = a.x * b.x; + this.y = a.y * b.y; + this.z = a.z * b.z; - var s = Math.sqrt( 1 - q.w * q.w ); + return this; - if ( s < 0.0001 ) { + }, - this.x = 1; - this.y = 0; - this.z = 0; + applyEuler: function ( euler ) { - } else { + if ( ! ( euler && euler.isEuler ) ) { - this.x = q.x / s; - this.y = q.y / s; - this.z = q.z / s; + console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); } - return this; + return this.applyQuaternion( _quaternion.setFromEuler( euler ) ); }, - 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, + applyAxisAngle: function ( axis, angle ) { - 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 ]; + return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); - 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 + applyMatrix3: function ( m ) { - if ( ( Math.abs( m12 + m21 ) < epsilon2 ) && - ( Math.abs( m13 + m31 ) < epsilon2 ) && - ( Math.abs( m23 + m32 ) < epsilon2 ) && - ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - // this singularity is identity matrix so angle = 0 + this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z; + this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z; + this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z; - this.set( 1, 0, 0, 0 ); + return this; - return this; // zero angle, arbitrary axis + }, - } + applyNormalMatrix: function ( m ) { - // otherwise this singularity is angle = 180 + return this.applyMatrix3( m ).normalize(); - 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; + applyMatrix4: function ( m ) { - if ( ( xx > yy ) && ( xx > zz ) ) { + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - // m11 is the largest diagonal term + var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] ); - if ( xx < epsilon ) { + 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; - x = 0; - y = 0.707106781; - z = 0.707106781; + return this; - } else { + }, - x = Math.sqrt( xx ); - y = xy / x; - z = xz / x; + applyQuaternion: function ( q ) { - } + var x = this.x, y = this.y, z = this.z; + var qx = q.x, qy = q.y, qz = q.z, qw = q.w; - } else if ( yy > zz ) { + // calculate quat * vector - // m22 is the largest diagonal term + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = - qx * x - qy * y - qz * z; - if ( yy < epsilon ) { + // calculate result * inverse quat - x = 0.707106781; - y = 0; - z = 0.707106781; + this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy; + this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz; + this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx; - } else { + return this; - y = Math.sqrt( yy ); - x = xy / y; - z = yz / y; + }, - } + project: function ( camera ) { - } else { + return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix ); - // m33 is the largest diagonal term so base result on this + }, - if ( zz < epsilon ) { + unproject: function ( camera ) { - x = 0.707106781; - y = 0.707106781; - z = 0; + return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld ); - } else { + }, - z = Math.sqrt( zz ); - x = xz / z; - y = yz / z; + transformDirection: function ( m ) { - } + // input: THREE.Matrix4 affine matrix + // vector interpreted as a direction - } + var x = this.x, y = this.y, z = this.z; + var e = m.elements; - this.set( x, y, z, angle ); + this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z; + this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z; + this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z; - return this; // return 180 deg rotation + return this.normalize(); - } + }, - // as we have reached here there are no singularities so we can handle normally + divide: function ( v ) { - var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) + - ( m13 - m31 ) * ( m13 - m31 ) + - ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize + this.x /= v.x; + this.y /= v.y; + this.z /= v.z; - if ( Math.abs( s ) < 0.001 ) s = 1; + return this; - // 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 ); + divideScalar: function ( scalar ) { - return this; + return this.multiplyScalar( 1 / scalar ); }, @@ -3533,7 +3622,6 @@ Object.assign( Vector4.prototype, { 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; @@ -3544,7 +3632,6 @@ Object.assign( Vector4.prototype, { 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; @@ -3557,7 +3644,6 @@ Object.assign( Vector4.prototype, { 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; @@ -3568,7 +3654,6 @@ Object.assign( Vector4.prototype, { this.x = Math.max( minVal, Math.min( maxVal, this.x ) ); this.y = Math.max( minVal, Math.min( maxVal, this.y ) ); this.z = Math.max( minVal, Math.min( maxVal, this.z ) ); - this.w = Math.max( minVal, Math.min( maxVal, this.w ) ); return this; @@ -3587,7 +3672,6 @@ Object.assign( Vector4.prototype, { 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; @@ -3598,7 +3682,6 @@ Object.assign( Vector4.prototype, { this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); this.z = Math.ceil( this.z ); - this.w = Math.ceil( this.w ); return this; @@ -3609,7 +3692,6 @@ Object.assign( Vector4.prototype, { this.x = Math.round( this.x ); this.y = Math.round( this.y ); this.z = Math.round( this.z ); - this.w = Math.round( this.w ); return this; @@ -3620,7 +3702,6 @@ Object.assign( Vector4.prototype, { 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 ); this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z ); - this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w ); return this; @@ -3631,7 +3712,6 @@ Object.assign( Vector4.prototype, { this.x = - this.x; this.y = - this.y; this.z = - this.z; - this.w = - this.w; return this; @@ -3639,25 +3719,27 @@ Object.assign( Vector4.prototype, { dot: function ( v ) { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + return this.x * v.x + this.y * v.y + this.z * v.z; }, + // TODO lengthSquared? + lengthSq: function () { - return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; + return this.x * this.x + this.y * this.y + this.z * this.z; }, length: function () { - return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w ); + return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); }, manhattanLength: function () { - return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w ); + return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ); }, @@ -3678,7 +3760,6 @@ Object.assign( Vector4.prototype, { this.x += ( v.x - this.x ) * alpha; this.y += ( v.y - this.y ) * alpha; this.z += ( v.z - this.z ) * alpha; - this.w += ( v.w - this.w ) * alpha; return this; @@ -3690,176 +3771,219 @@ Object.assign( Vector4.prototype, { }, - equals: function ( v ) { + cross: function ( v, w ) { - return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) ); + if ( w !== undefined ) { + + console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); + return this.crossVectors( v, w ); + + } + + return this.crossVectors( this, v ); }, - fromArray: function ( array, offset ) { + crossVectors: function ( a, b ) { - if ( offset === undefined ) offset = 0; + var ax = a.x, ay = a.y, az = a.z; + var bx = b.x, by = b.y, bz = b.z; - this.x = array[ offset ]; - this.y = array[ offset + 1 ]; - this.z = array[ offset + 2 ]; - this.w = array[ offset + 3 ]; + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; return this; }, - toArray: function ( array, offset ) { + projectOnVector: function ( v ) { - if ( array === undefined ) array = []; - if ( offset === undefined ) offset = 0; + var denominator = v.lengthSq(); - array[ offset ] = this.x; - array[ offset + 1 ] = this.y; - array[ offset + 2 ] = this.z; - array[ offset + 3 ] = this.w; + if ( denominator === 0 ) return this.set( 0, 0, 0 ); - return array; + var scalar = v.dot( this ) / denominator; + + return this.copy( v ).multiplyScalar( scalar ); }, - fromBufferAttribute: function ( attribute, index, offset ) { + projectOnPlane: function ( planeNormal ) { - if ( offset !== undefined ) { + _vector.copy( this ).projectOnVector( planeNormal ); - console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); + return this.sub( _vector ); - } + }, - this.x = attribute.getX( index ); - this.y = attribute.getY( index ); - this.z = attribute.getZ( index ); - this.w = attribute.getW( index ); + reflect: function ( normal ) { - return this; + // reflect incident vector off plane orthogonal to normal + // normal is assumed to have unit length - } + return this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) ); -} ); + }, -/** - * @author szimek / https://github.com/szimek/ - * @author alteredq / http://alteredqualia.com/ - * @author Marius Kintel / https://github.com/kintel - */ + angleTo: function ( v ) { -/* - In options, we can specify: - * Texture parameters for an auto-generated target texture - * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers -*/ -function WebGLRenderTarget( width, height, options ) { + var denominator = Math.sqrt( this.lengthSq() * v.lengthSq() ); - this.width = width; - this.height = height; + if ( denominator === 0 ) return Math.PI / 2; - this.scissor = new Vector4( 0, 0, width, height ); - this.scissorTest = false; + var theta = this.dot( v ) / denominator; - this.viewport = new Vector4( 0, 0, width, height ); + // clamp, to handle numerical problems - options = options || {}; + return Math.acos( MathUtils.clamp( theta, - 1, 1 ) ); - this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding ); + }, - this.texture.image = {}; - this.texture.image.width = width; - this.texture.image.height = height; + distanceTo: function ( v ) { - this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false; - this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter; + return Math.sqrt( this.distanceToSquared( v ) ); - this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; - this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true; - this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + }, -} + distanceToSquared: function ( v ) { -WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { + var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; - constructor: WebGLRenderTarget, + return dx * dx + dy * dy + dz * dz; - isWebGLRenderTarget: true, + }, - setSize: function ( width, height ) { + manhattanDistanceTo: function ( v ) { - if ( this.width !== width || this.height !== height ) { + return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z ); - this.width = width; - this.height = height; + }, - this.texture.image.width = width; - this.texture.image.height = height; + setFromSpherical: function ( s ) { - this.dispose(); + return this.setFromSphericalCoords( s.radius, s.phi, s.theta ); - } + }, - this.viewport.set( 0, 0, width, height ); - this.scissor.set( 0, 0, width, height ); + setFromSphericalCoords: function ( radius, phi, theta ) { - }, + var sinPhiRadius = Math.sin( phi ) * radius; - clone: function () { + this.x = sinPhiRadius * Math.sin( theta ); + this.y = Math.cos( phi ) * radius; + this.z = sinPhiRadius * Math.cos( theta ); - return new this.constructor().copy( this ); + return this; }, - copy: function ( source ) { + setFromCylindrical: function ( c ) { - this.width = source.width; - this.height = source.height; + return this.setFromCylindricalCoords( c.radius, c.theta, c.y ); - this.viewport.copy( source.viewport ); + }, - this.texture = source.texture.clone(); + setFromCylindricalCoords: function ( radius, theta, y ) { - this.depthBuffer = source.depthBuffer; - this.stencilBuffer = source.stencilBuffer; - this.depthTexture = source.depthTexture; + this.x = radius * Math.sin( theta ); + this.y = y; + this.z = radius * Math.cos( theta ); return this; }, - dispose: function () { + setFromMatrixPosition: function ( m ) { - this.dispatchEvent( { type: 'dispose' } ); + var e = m.elements; - } + this.x = e[ 12 ]; + this.y = e[ 13 ]; + this.z = e[ 14 ]; -} ); + return this; -/** - * @author Mugen87 / https://github.com/Mugen87 - * @author Matt DesLauriers / @mattdesl - */ + }, -function WebGLMultisampleRenderTarget( width, height, options ) { + setFromMatrixScale: function ( m ) { - WebGLRenderTarget.call( this, width, height, options ); + var sx = this.setFromMatrixColumn( m, 0 ).length(); + var sy = this.setFromMatrixColumn( m, 1 ).length(); + var sz = this.setFromMatrixColumn( m, 2 ).length(); - this.samples = 4; + this.x = sx; + this.y = sy; + this.z = sz; -} + return this; -WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { + }, - constructor: WebGLMultisampleRenderTarget, + setFromMatrixColumn: function ( m, index ) { - isWebGLMultisampleRenderTarget: true, + return this.fromArray( m.elements, index * 4 ); - copy: function ( source ) { + }, - WebGLRenderTarget.prototype.copy.call( this, source ); + setFromMatrix3Column: function ( m, index ) { - this.samples = source.samples; + return this.fromArray( m.elements, index * 3 ); + + }, + + equals: function ( v ) { + + return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) ); + + }, + + fromArray: function ( array, offset ) { + + if ( offset === undefined ) offset = 0; + + this.x = array[ offset ]; + this.y = array[ offset + 1 ]; + this.z = array[ offset + 2 ]; + + return this; + + }, + + toArray: function ( array, offset ) { + + if ( array === undefined ) array = []; + if ( offset === undefined ) offset = 0; + + array[ offset ] = this.x; + array[ offset + 1 ] = this.y; + array[ offset + 2 ] = this.z; + + return array; + + }, + + fromBufferAttribute: function ( attribute, index, offset ) { + + if ( offset !== undefined ) { + + console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); + + } + + this.x = attribute.getX( index ); + this.y = attribute.getY( index ); + this.z = attribute.getZ( index ); + + return this; + + }, + + random: function () { + + this.x = Math.random(); + this.y = Math.random(); + this.z = Math.random(); return this; @@ -4282,24 +4406,6 @@ Object.assign( Matrix4.prototype, { }, - applyToBufferAttribute: function ( attribute ) { - - for ( var i = 0, l = attribute.count; i < l; i ++ ) { - - _v1.x = attribute.getX( i ); - _v1.y = attribute.getY( i ); - _v1.z = attribute.getZ( i ); - - _v1.applyMatrix4( this ); - - attribute.setXYZ( i, _v1.x, _v1.y, _v1.z ); - - } - - return attribute; - - }, - determinant: function () { var te = this.elements; @@ -4391,6 +4497,12 @@ Object.assign( Matrix4.prototype, { getInverse: function ( m, throwOnDegenerate ) { + if ( throwOnDegenerate !== undefined ) { + + console.warn( "THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate." ); + + } + // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm var te = this.elements, me = m.elements, @@ -4407,23 +4519,7 @@ Object.assign( Matrix4.prototype, { var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14; - if ( det === 0 ) { - - var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0"; - - if ( throwOnDegenerate === true ) { - - throw new Error( msg ); - - } else { - - console.warn( msg ); - - } - - return this.identity(); - - } + if ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); var detInv = 1 / det; @@ -4917,7 +5013,7 @@ Object.assign( Euler.prototype, { setFromRotationMatrix: function ( m, order, update ) { - var clamp = _Math.clamp; + var clamp = MathUtils.clamp; // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) @@ -4928,105 +5024,119 @@ Object.assign( Euler.prototype, { order = order || this._order; - if ( order === 'XYZ' ) { + switch ( order ) { - this._y = Math.asin( clamp( m13, - 1, 1 ) ); + case 'XYZ': - if ( Math.abs( m13 ) < 0.9999999 ) { + this._y = Math.asin( clamp( m13, - 1, 1 ) ); - this._x = Math.atan2( - m23, m33 ); - this._z = Math.atan2( - m12, m11 ); + if ( Math.abs( m13 ) < 0.9999999 ) { - } else { + this._x = Math.atan2( - m23, m33 ); + this._z = Math.atan2( - m12, m11 ); - this._x = Math.atan2( m32, m22 ); - this._z = 0; + } else { - } + this._x = Math.atan2( m32, m22 ); + this._z = 0; - } else if ( order === 'YXZ' ) { + } - this._x = Math.asin( - clamp( m23, - 1, 1 ) ); + break; - if ( Math.abs( m23 ) < 0.9999999 ) { + case 'YXZ': - this._y = Math.atan2( m13, m33 ); - this._z = Math.atan2( m21, m22 ); + this._x = Math.asin( - clamp( m23, - 1, 1 ) ); - } else { + if ( Math.abs( m23 ) < 0.9999999 ) { - this._y = Math.atan2( - m31, m11 ); - this._z = 0; + this._y = Math.atan2( m13, m33 ); + this._z = Math.atan2( m21, m22 ); - } + } else { - } else if ( order === 'ZXY' ) { + this._y = Math.atan2( - m31, m11 ); + this._z = 0; - this._x = Math.asin( clamp( m32, - 1, 1 ) ); + } - if ( Math.abs( m32 ) < 0.9999999 ) { + break; - this._y = Math.atan2( - m31, m33 ); - this._z = Math.atan2( - m12, m22 ); + case 'ZXY': - } else { + this._x = Math.asin( clamp( m32, - 1, 1 ) ); - this._y = 0; - this._z = Math.atan2( m21, m11 ); + if ( Math.abs( m32 ) < 0.9999999 ) { - } + this._y = Math.atan2( - m31, m33 ); + this._z = Math.atan2( - m12, m22 ); - } else if ( order === 'ZYX' ) { + } else { - this._y = Math.asin( - clamp( m31, - 1, 1 ) ); + this._y = 0; + this._z = Math.atan2( m21, m11 ); - if ( Math.abs( m31 ) < 0.9999999 ) { + } - this._x = Math.atan2( m32, m33 ); - this._z = Math.atan2( m21, m11 ); + break; - } else { + case 'ZYX': - this._x = 0; - this._z = Math.atan2( - m12, m22 ); + this._y = Math.asin( - clamp( m31, - 1, 1 ) ); - } + if ( Math.abs( m31 ) < 0.9999999 ) { - } else if ( order === 'YZX' ) { + this._x = Math.atan2( m32, m33 ); + this._z = Math.atan2( m21, m11 ); + + } else { - this._z = Math.asin( clamp( m21, - 1, 1 ) ); + this._x = 0; + this._z = Math.atan2( - m12, m22 ); - if ( Math.abs( m21 ) < 0.9999999 ) { + } - this._x = Math.atan2( - m23, m22 ); - this._y = Math.atan2( - m31, m11 ); + break; - } else { + case 'YZX': - this._x = 0; - this._y = Math.atan2( m13, m33 ); + this._z = Math.asin( clamp( m21, - 1, 1 ) ); - } + if ( Math.abs( m21 ) < 0.9999999 ) { - } else if ( order === 'XZY' ) { + this._x = Math.atan2( - m23, m22 ); + this._y = Math.atan2( - m31, m11 ); - this._z = Math.asin( - clamp( m12, - 1, 1 ) ); + } else { - if ( Math.abs( m12 ) < 0.9999999 ) { + this._x = 0; + this._y = Math.atan2( m13, m33 ); - this._x = Math.atan2( m32, m22 ); - this._y = Math.atan2( m13, m11 ); + } - } else { + break; - this._x = Math.atan2( - m23, m33 ); - this._y = 0; + case 'XZY': - } + this._z = Math.asin( - clamp( m12, - 1, 1 ) ); - } else { + if ( Math.abs( m12 ) < 0.9999999 ) { + + this._x = Math.atan2( m32, m22 ); + this._y = Math.atan2( m13, m11 ); + + } else { + + this._x = Math.atan2( - m23, m33 ); + this._y = 0; + + } + + break; + + default: - console.warn( 'THREE.Euler: .setFromRotationMatrix() given unsupported order: ' + order ); + console.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order ); } @@ -5207,7 +5317,7 @@ function Object3D() { Object.defineProperty( this, 'id', { value: _object3DId ++ } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Object3D'; @@ -5297,7 +5407,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), onBeforeRender: function () {}, onAfterRender: function () {}, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { if ( this.matrixAutoUpdate ) this.updateMatrix(); @@ -5564,7 +5674,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), } - object.applyMatrix( _m1$1 ); + object.applyMatrix4( _m1$1 ); object.updateWorldMatrix( false, false ); @@ -5971,6 +6081,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), values.push( data ); } + return values; } @@ -6109,7 +6220,7 @@ var _points = [ new Vector3() ]; -var _vector$2 = new Vector3(); +var _vector$1 = new Vector3(); var _box = new Box3(); @@ -6238,7 +6349,7 @@ Object.assign( Box3.prototype, { setFromCenterAndSize: function ( center, size ) { - var halfSize = _vector$2.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$1.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -6360,8 +6471,7 @@ Object.assign( Box3.prototype, { _box.copy( geometry.boundingBox ); _box.applyMatrix4( object.matrixWorld ); - this.expandByPoint( _box.min ); - this.expandByPoint( _box.max ); + this.union( _box ); } @@ -6425,10 +6535,10 @@ Object.assign( Box3.prototype, { intersectsSphere: function ( sphere ) { // Find the point on the AABB closest to the sphere center. - this.clampPoint( sphere.center, _vector$2 ); + this.clampPoint( sphere.center, _vector$1 ); // If that point is inside the sphere, the AABB and sphere intersect. - return _vector$2.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + return _vector$1.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); }, @@ -6547,7 +6657,7 @@ Object.assign( Box3.prototype, { distanceToPoint: function ( point ) { - var clampedPoint = _vector$2.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$1.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); @@ -6564,7 +6674,7 @@ Object.assign( Box3.prototype, { this.getCenter( target.center ); - target.radius = this.getSize( _vector$2 ).length() * 0.5; + target.radius = this.getSize( _vector$1 ).length() * 0.5; return target; @@ -6667,7 +6777,7 @@ var _box$1 = new Box3(); function Sphere( center, radius ) { this.center = ( center !== undefined ) ? center : new Vector3(); - this.radius = ( radius !== undefined ) ? radius : 0; + this.radius = ( radius !== undefined ) ? radius : - 1; } @@ -6725,9 +6835,18 @@ Object.assign( Sphere.prototype, { }, - empty: function () { + isEmpty: function () { + + return ( this.radius < 0 ); + + }, + + makeEmpty: function () { + + this.center.set( 0, 0, 0 ); + this.radius = - 1; - return ( this.radius <= 0 ); + return this; }, @@ -6796,6 +6915,14 @@ Object.assign( Sphere.prototype, { } + if ( this.isEmpty() ) { + + // Empty sphere produces empty bounding box + target.makeEmpty(); + return target; + + } + target.set( this.center, this.center ); target.expandByScalar( this.radius ); @@ -6828,7 +6955,7 @@ Object.assign( Sphere.prototype, { } ); -var _vector$3 = new Vector3(); +var _vector$2 = new Vector3(); var _segCenter = new Vector3(); var _segDir = new Vector3(); var _diff = new Vector3(); @@ -6897,7 +7024,7 @@ Object.assign( Ray.prototype, { recast: function ( t ) { - this.origin.copy( this.at( t, _vector$3 ) ); + this.origin.copy( this.at( t, _vector$2 ) ); return this; @@ -6934,7 +7061,7 @@ Object.assign( Ray.prototype, { distanceSqToPoint: function ( point ) { - var directionDistance = _vector$3.subVectors( point, this.origin ).dot( this.direction ); + var directionDistance = _vector$2.subVectors( point, this.origin ).dot( this.direction ); // point behind the ray @@ -6944,9 +7071,9 @@ Object.assign( Ray.prototype, { } - _vector$3.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); + _vector$2.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin ); - return _vector$3.distanceToSquared( point ); + return _vector$2.distanceToSquared( point ); }, @@ -7071,9 +7198,9 @@ Object.assign( Ray.prototype, { intersectSphere: function ( sphere, target ) { - _vector$3.subVectors( sphere.center, this.origin ); - var tca = _vector$3.dot( this.direction ); - var d2 = _vector$3.dot( _vector$3 ) - tca * tca; + _vector$2.subVectors( sphere.center, this.origin ); + var tca = _vector$2.dot( this.direction ); + var d2 = _vector$2.dot( _vector$2 ) - tca * tca; var radius2 = sphere.radius * sphere.radius; if ( d2 > radius2 ) return null; @@ -7243,7 +7370,7 @@ Object.assign( Ray.prototype, { intersectsBox: function ( box ) { - return this.intersectBox( box, _vector$3 ) !== null; + return this.intersectBox( box, _vector$2 ) !== null; }, @@ -8024,9 +8151,9 @@ Object.assign( Color.prototype, { setHSL: function ( h, s, l ) { // h,s,l ranges are in 0.0 - 1.0 - h = _Math.euclideanModulo( h, 1 ); - s = _Math.clamp( s, 0, 1 ); - l = _Math.clamp( l, 0, 1 ); + h = MathUtils.euclideanModulo( h, 1 ); + s = MathUtils.clamp( s, 0, 1 ); + l = MathUtils.clamp( l, 0, 1 ); if ( s === 0 ) { @@ -8434,9 +8561,9 @@ Object.assign( Color.prototype, { this.getHSL( _hslA ); color.getHSL( _hslB ); - var h = _Math.lerp( _hslA.h, _hslB.h, alpha ); - var s = _Math.lerp( _hslA.s, _hslB.s, alpha ); - var l = _Math.lerp( _hslA.l, _hslB.l, alpha ); + var h = MathUtils.lerp( _hslA.h, _hslB.h, alpha ); + var s = MathUtils.lerp( _hslA.s, _hslB.s, alpha ); + var l = MathUtils.lerp( _hslA.l, _hslB.l, alpha ); this.setHSL( h, s, l ); @@ -8554,7 +8681,7 @@ function Material() { Object.defineProperty( this, 'id', { value: materialId ++ } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Material'; @@ -8564,8 +8691,7 @@ function Material() { this.blending = NormalBlending; this.side = FrontSide; this.flatShading = false; - this.vertexTangents = false; - this.vertexColors = NoColors; // THREE.NoColors, THREE.VertexColors, THREE.FaceColors + this.vertexColors = false; this.opacity = 1; this.transparent = false; @@ -8719,6 +8845,18 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat; if ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness; + if ( this.clearcoatMap && this.clearcoatMap.isTexture ) { + + data.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid; + + } + + if ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) { + + data.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid; + + } + if ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) { data.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid; @@ -8790,7 +8928,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( this.blending !== NormalBlending ) data.blending = this.blending; if ( this.flatShading === true ) data.flatShading = this.flatShading; if ( this.side !== FrontSide ) data.side = this.side; - if ( this.vertexColors !== NoColors ) data.vertexColors = this.vertexColors; + if ( this.vertexColors ) data.vertexColors = true; if ( this.opacity < 1 ) data.opacity = this.opacity; if ( this.transparent === true ) data.transparent = this.transparent; @@ -8887,7 +9025,6 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), this.blending = source.blending; this.side = source.side; this.flatShading = source.flatShading; - this.vertexTangents = source.vertexTangents; this.vertexColors = source.vertexColors; this.opacity = source.opacity; @@ -9089,7 +9226,7 @@ MeshBasicMaterial.prototype.copy = function ( source ) { * @author mrdoob / http://mrdoob.com/ */ -var _vector$4 = new Vector3(); +var _vector$3 = new Vector3(); function BufferAttribute( array, itemSize, normalized ) { @@ -9278,13 +9415,13 @@ Object.assign( BufferAttribute.prototype, { for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyMatrix3( m ); + _vector$3.applyMatrix3( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9296,13 +9433,13 @@ Object.assign( BufferAttribute.prototype, { for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyMatrix4( m ); + _vector$3.applyMatrix4( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9314,13 +9451,13 @@ Object.assign( BufferAttribute.prototype, { for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.applyNormalMatrix( m ); + _vector$3.applyNormalMatrix( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9332,13 +9469,13 @@ Object.assign( BufferAttribute.prototype, { for ( var i = 0, l = this.count; i < l; i ++ ) { - _vector$4.x = this.getX( i ); - _vector$4.y = this.getY( i ); - _vector$4.z = this.getZ( i ); + _vector$3.x = this.getX( i ); + _vector$3.y = this.getY( i ); + _vector$3.z = this.getZ( i ); - _vector$4.transformDirection( m ); + _vector$3.transformDirection( m ); - this.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); + this.setXYZ( i, _vector$3.x, _vector$3.y, _vector$3.z ); } @@ -9880,13 +10017,13 @@ var _obj = new Object3D(); var _offset = new Vector3(); var _box$2 = new Box3(); var _boxMorphTargets = new Box3(); -var _vector$5 = new Vector3(); +var _vector$4 = new Vector3(); function BufferGeometry() { Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'BufferGeometry'; @@ -9981,7 +10118,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy }, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { var position = this.attributes.position; @@ -10037,7 +10174,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _m1$2.makeRotationX( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10049,7 +10186,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _m1$2.makeRotationY( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10061,7 +10198,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _m1$2.makeRotationZ( angle ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10073,7 +10210,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _m1$2.makeTranslation( x, y, z ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10085,7 +10222,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _m1$2.makeScale( x, y, z ); - this.applyMatrix( _m1$2 ); + this.applyMatrix4( _m1$2 ); return this; @@ -10097,7 +10234,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy _obj.updateMatrix(); - this.applyMatrix( _obj.matrix ); + this.applyMatrix4( _obj.matrix ); return this; @@ -10434,11 +10571,11 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy if ( this.morphTargetsRelative ) { - _vector$5.addVectors( this.boundingBox.min, _box$2.min ); - this.boundingBox.expandByPoint( _vector$5 ); + _vector$4.addVectors( this.boundingBox.min, _box$2.min ); + this.boundingBox.expandByPoint( _vector$4 ); - _vector$5.addVectors( this.boundingBox.max, _box$2.max ); - this.boundingBox.expandByPoint( _vector$5 ); + _vector$4.addVectors( this.boundingBox.max, _box$2.max ); + this.boundingBox.expandByPoint( _vector$4 ); } else { @@ -10495,11 +10632,11 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy if ( this.morphTargetsRelative ) { - _vector$5.addVectors( _box$2.min, _boxMorphTargets.min ); - _box$2.expandByPoint( _vector$5 ); + _vector$4.addVectors( _box$2.min, _boxMorphTargets.min ); + _box$2.expandByPoint( _vector$4 ); - _vector$5.addVectors( _box$2.max, _boxMorphTargets.max ); - _box$2.expandByPoint( _vector$5 ); + _vector$4.addVectors( _box$2.max, _boxMorphTargets.max ); + _box$2.expandByPoint( _vector$4 ); } else { @@ -10521,9 +10658,9 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy for ( var i = 0, il = position.count; i < il; i ++ ) { - _vector$5.fromBufferAttribute( position, i ); + _vector$4.fromBufferAttribute( position, i ); - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$5 ) ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } @@ -10538,16 +10675,16 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { - _vector$5.fromBufferAttribute( morphAttribute, j ); + _vector$4.fromBufferAttribute( morphAttribute, j ); if ( morphTargetsRelative ) { _offset.fromBufferAttribute( position, j ); - _vector$5.add( _offset ); + _vector$4.add( _offset ); } - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$5 ) ); + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } @@ -10731,13 +10868,13 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy for ( var i = 0, il = normals.count; i < il; i ++ ) { - _vector$5.x = normals.getX( i ); - _vector$5.y = normals.getY( i ); - _vector$5.z = normals.getZ( i ); + _vector$4.x = normals.getX( i ); + _vector$4.y = normals.getY( i ); + _vector$4.z = normals.getZ( i ); - _vector$5.normalize(); + _vector$4.normalize(); - normals.setXYZ( i, _vector$5.x, _vector$5.y, _vector$5.z ); + normals.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); } @@ -11133,7 +11270,7 @@ function Mesh( geometry, material ) { this.type = 'Mesh'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new MeshBasicMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new MeshBasicMaterial(); this.updateMorphTargets(); @@ -11512,6 +11649,14 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi } + if ( object.isSkinnedMesh ) { + + object.boneTransform( a, _vA ); + object.boneTransform( b, _vB ); + object.boneTransform( c, _vC ); + + } + var intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint ); if ( intersection ) { @@ -11565,7 +11710,7 @@ function Geometry() { Object.defineProperty( this, 'id', { value: _geometryId += 2 } ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.name = ''; this.type = 'Geometry'; @@ -11604,7 +11749,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), isGeometry: true, - applyMatrix: function ( matrix ) { + applyMatrix4: function ( matrix ) { var normalMatrix = new Matrix3().getNormalMatrix( matrix ); @@ -11653,7 +11798,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _m1$3.makeRotationX( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11665,7 +11810,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _m1$3.makeRotationY( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11677,7 +11822,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _m1$3.makeRotationZ( angle ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11689,7 +11834,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _m1$3.makeTranslation( x, y, z ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11701,7 +11846,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _m1$3.makeScale( x, y, z ); - this.applyMatrix( _m1$3 ); + this.applyMatrix4( _m1$3 ); return this; @@ -11713,7 +11858,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), _obj$1.updateMatrix(); - this.applyMatrix( _obj$1.matrix ); + this.applyMatrix4( _obj$1.matrix ); return this; @@ -11888,7 +12033,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), 0, 0, 0, 1 ); - this.applyMatrix( matrix ); + this.applyMatrix4( matrix ); return this; @@ -13470,6 +13615,14 @@ Camera.prototype = Object.assign( Object.create( Object3D.prototype ), { }, + updateWorldMatrix: function ( updateParents, updateChildren ) { + + Object3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren ); + + this.matrixWorldInverse.getInverse( this.matrixWorld ); + + }, + clone: function () { return new this.constructor().copy( this ); @@ -13548,7 +13701,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), // see http://www.bobatkins.com/photography/technical/field_of_view.html var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength; - this.fov = _Math.RAD2DEG * 2 * Math.atan( vExtentSlope ); + this.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope ); this.updateProjectionMatrix(); }, @@ -13558,7 +13711,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), */ getFocalLength: function () { - var vExtentSlope = Math.tan( _Math.DEG2RAD * 0.5 * this.fov ); + var vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ); return 0.5 * this.getFilmHeight() / vExtentSlope; @@ -13566,8 +13719,8 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), getEffectiveFOV: function () { - return _Math.RAD2DEG * 2 * Math.atan( - Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom ); + return MathUtils.RAD2DEG * 2 * Math.atan( + Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom ); }, @@ -13665,7 +13818,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), updateProjectionMatrix: function () { var near = this.near, - top = near * Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom, + top = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom, height = 2 * top, width = this.aspect * height, left = - 0.5 * width, @@ -13763,7 +13916,7 @@ function CubeCamera( near, far, cubeResolution, options ) { options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter }; - this.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options ); + this.renderTarget = new WebGLCubeRenderTarget( cubeResolution, options ); this.renderTarget.texture.name = "CubeCamera"; this.update = function ( renderer, scene ) { @@ -13829,18 +13982,26 @@ CubeCamera.prototype.constructor = CubeCamera; * @author WestLangley / http://github.com/WestLangley */ -function WebGLRenderTargetCube( width, height, options ) { +function WebGLCubeRenderTarget( size, options, dummy ) { - WebGLRenderTarget.call( this, width, height, options ); + if ( Number.isInteger( options ) ) { + + console.warn( 'THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )' ); + + options = dummy; + + } + + WebGLRenderTarget.call( this, size, size, options ); } -WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype ); -WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube; +WebGLCubeRenderTarget.prototype = Object.create( WebGLRenderTarget.prototype ); +WebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget; -WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true; +WebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true; -WebGLRenderTargetCube.prototype.fromEquirectangularTexture = function ( renderer, texture ) { +WebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function ( renderer, texture ) { this.texture.type = texture.type; this.texture.format = texture.format; @@ -13966,7 +14127,7 @@ DataTexture.prototype.isDataTexture = true; */ var _sphere$1 = new Sphere(); -var _vector$6 = new Vector3(); +var _vector$5 = new Vector3(); function Frustum( p0, p1, p2, p3, p4, p5 ) { @@ -14020,7 +14181,7 @@ Object.assign( Frustum.prototype, { }, - setFromMatrix: function ( m ) { + setFromProjectionMatrix: function ( m ) { var planes = this.planes; var me = m.elements; @@ -14094,11 +14255,11 @@ Object.assign( Frustum.prototype, { // corner at max distance - _vector$6.x = plane.normal.x > 0 ? box.max.x : box.min.x; - _vector$6.y = plane.normal.y > 0 ? box.max.y : box.min.y; - _vector$6.z = plane.normal.z > 0 ? box.max.z : box.min.z; + _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z; - if ( plane.distanceToPoint( _vector$6 ) < 0 ) { + if ( plane.distanceToPoint( _vector$5 ) < 0 ) { return false; @@ -14130,1217 +14291,1233 @@ Object.assign( Frustum.prototype, { } ); -var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; +/** + * Uniforms library for shared webgl shaders + */ -var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; +var UniformsLib = { -var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif"; + common: { -var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, -var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; + map: { value: null }, + uvTransform: { value: new Matrix3() }, + uv2Transform: { value: new Matrix3() }, -var begin_vertex = "vec3 transformed = vec3( position );"; + alphaMap: { value: null }, -var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; + }, -var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif"; + specularmap: { -var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; + specularMap: { value: null }, -var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; + }, -var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; + envmap: { -var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif"; + envMap: { value: null }, + flipEnvMap: { value: - 1 }, + reflectivity: { value: 1.0 }, + refractionRatio: { value: 0.98 }, + maxMipLevel: { value: 0 } -var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif"; + }, -var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif"; + aomap: { -var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; + aoMap: { value: null }, + aoMapIntensity: { value: 1 } -var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; + }, -var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; + lightmap: { -var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}"; + lightMap: { value: null }, + lightMapIntensity: { value: 1 } -var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif"; + }, -var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; + emissivemap: { -var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; + emissiveMap: { value: null } -var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; + }, -var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; + bumpmap: { -var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; + bumpMap: { value: null }, + bumpScale: { value: 1 } -var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; + }, -var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; + normalmap: { -var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ), 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; + normalMap: { value: null }, + normalScale: { value: new Vector2( 1, 1 ) } -var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; + }, -var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; + displacementmap: { -var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; + displacementMap: { value: null }, + displacementScale: { value: 1 }, + displacementBias: { value: 0 } -var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; + }, -var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif"; + roughnessmap: { -var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; + roughnessMap: { value: null } -var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; + }, -var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; + metalnessmap: { -var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; + metalnessMap: { value: null } -var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif"; + }, -var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; + gradientmap: { -var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif"; + gradientMap: { value: null } -var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif"; + }, -var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif"; + fog: { -var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + fogDensity: { value: 0.00025 }, + fogNear: { value: 1 }, + fogFar: { value: 2000 }, + fogColor: { value: new Color( 0xffffff ) } -var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; + }, -var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; + lights: { -var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; + ambientLightColor: { value: [] }, -var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = max( clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif"; + lightProbe: { value: [] }, -var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; + directionalLights: { value: [], properties: { + direction: {}, + color: {} + } }, -var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; + directionalLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, -var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif"; + directionalShadowMap: { value: [] }, + directionalShadowMatrix: { value: [] }, -var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; + spotLights: { value: [], properties: { + color: {}, + position: {}, + direction: {}, + distance: {}, + coneCos: {}, + penumbraCos: {}, + decay: {} + } }, -var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; + spotLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {} + } }, -var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; + spotShadowMap: { value: [] }, + spotShadowMatrix: { value: [] }, -var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; + pointLights: { value: [], properties: { + color: {}, + position: {}, + decay: {}, + distance: {} + } }, -var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; + pointLightShadows: { value: [], properties: { + shadowBias: {}, + shadowRadius: {}, + shadowMapSize: {}, + shadowCameraNear: {}, + shadowCameraFar: {} + } }, -var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif"; + pointShadowMap: { value: [] }, + pointShadowMatrix: { value: [] }, -var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; + hemisphereLights: { value: [], properties: { + direction: {}, + skyColor: {}, + groundColor: {} + } }, -var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; + // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {} + } } -var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; + }, -var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; + points: { -var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, + size: { value: 1.0 }, + scale: { value: 1.0 }, + map: { value: null }, + alphaMap: { value: null }, + uvTransform: { value: new Matrix3() } -var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif"; + }, -var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif"; + sprite: { -var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif"; + diffuse: { value: new Color( 0xeeeeee ) }, + opacity: { value: 1.0 }, + center: { value: new Vector2( 0.5, 0.5 ) }, + rotation: { value: 0.0 }, + map: { value: null }, + alphaMap: { value: null }, + uvTransform: { value: new Matrix3() } -var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; + } -var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif"; +}; -var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; +/** + * @author mrdoob / http://mrdoob.com/ + */ -var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; +function WebGLAnimation() { -var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif"; + var context = null; + var isAnimating = false; + var animationLoop = null; -var clearcoat_normalmap_pars_fragment = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; + function onAnimationFrame( time, frame ) { -var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; + if ( isAnimating === false ) return; -var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; + animationLoop( time, frame ); -var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; + context.requestAnimationFrame( onAnimationFrame ); -var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; + } -var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; + return { -var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; + start: function () { -var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; + if ( isAnimating === true ) return; + if ( animationLoop === null ) return; -var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; + context.requestAnimationFrame( onAnimationFrame ); -var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; + isAnimating = true; -var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif"; + }, -var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}"; + stop: function () { -var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; + isAnimating = false; -var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; + }, -var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; + setAnimationLoop: function ( callback ) { -var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; + animationLoop = callback; -var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; + }, -var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; + setContext: function ( value ) { -var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; + context = value; -var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; + } -var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; + }; -var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; +} -var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; +/** + * @author mrdoob / http://mrdoob.com/ + */ -var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; +function WebGLAttributes( gl, capabilities ) { -var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; + var isWebGL2 = capabilities.isWebGL2; -var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; + var buffers = new WeakMap(); -var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; + function createBuffer( attribute, bufferType ) { -var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; + var array = attribute.array; + var usage = attribute.usage; -var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; + var buffer = gl.createBuffer(); -var cube_frag = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; + gl.bindBuffer( bufferType, buffer ); + gl.bufferData( bufferType, array, usage ); -var cube_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; + attribute.onUploadCallback(); -var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}"; + var type = 5126; -var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + if ( array instanceof Float32Array ) { -var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; + type = 5126; -var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; + } else if ( array instanceof Float64Array ) { -var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; + console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); -var equirect_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint16Array ) { -var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5123; -var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Int16Array ) { -var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5122; -var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint32Array ) { -var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5125; -var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Int32Array ) { -var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5124; -var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; + } else if ( array instanceof Int8Array ) { -var meshtoon_frag = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5120; -var meshtoon_vert = "#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + } else if ( array instanceof Uint8Array ) { -var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + type = 5121; -var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + } -var meshphysical_frag = "#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + return { + buffer: buffer, + type: type, + bytesPerElement: array.BYTES_PER_ELEMENT, + version: attribute.version + }; -var meshphysical_vert = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; + } -var normal_frag = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; + function updateBuffer( buffer, attribute, bufferType ) { -var normal_vert = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; + var array = attribute.array; + var updateRange = attribute.updateRange; -var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + gl.bindBuffer( bufferType, buffer ); -var points_vert = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; + if ( updateRange.count === - 1 ) { -var shadow_frag = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}"; + // Not using update ranges -var shadow_vert = "#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + gl.bufferSubData( bufferType, 0, array ); -var sprite_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}"; + } else { -var sprite_vert = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; + if ( isWebGL2 ) { -var ShaderChunk = { - alphamap_fragment: alphamap_fragment, - alphamap_pars_fragment: alphamap_pars_fragment, - alphatest_fragment: alphatest_fragment, - aomap_fragment: aomap_fragment, - aomap_pars_fragment: aomap_pars_fragment, - begin_vertex: begin_vertex, - beginnormal_vertex: beginnormal_vertex, - bsdfs: bsdfs, - bumpmap_pars_fragment: bumpmap_pars_fragment, - clipping_planes_fragment: clipping_planes_fragment, - clipping_planes_pars_fragment: clipping_planes_pars_fragment, - clipping_planes_pars_vertex: clipping_planes_pars_vertex, - clipping_planes_vertex: clipping_planes_vertex, - color_fragment: color_fragment, - color_pars_fragment: color_pars_fragment, - color_pars_vertex: color_pars_vertex, - color_vertex: color_vertex, - common: common, - cube_uv_reflection_fragment: cube_uv_reflection_fragment, - defaultnormal_vertex: defaultnormal_vertex, - displacementmap_pars_vertex: displacementmap_pars_vertex, - displacementmap_vertex: displacementmap_vertex, - emissivemap_fragment: emissivemap_fragment, - emissivemap_pars_fragment: emissivemap_pars_fragment, - encodings_fragment: encodings_fragment, - encodings_pars_fragment: encodings_pars_fragment, - envmap_fragment: envmap_fragment, - envmap_common_pars_fragment: envmap_common_pars_fragment, - envmap_pars_fragment: envmap_pars_fragment, - envmap_pars_vertex: envmap_pars_vertex, - envmap_physical_pars_fragment: envmap_physical_pars_fragment, - envmap_vertex: envmap_vertex, - fog_vertex: fog_vertex, - fog_pars_vertex: fog_pars_vertex, - fog_fragment: fog_fragment, - fog_pars_fragment: fog_pars_fragment, - gradientmap_pars_fragment: gradientmap_pars_fragment, - lightmap_fragment: lightmap_fragment, - lightmap_pars_fragment: lightmap_pars_fragment, - lights_lambert_vertex: lights_lambert_vertex, - lights_pars_begin: lights_pars_begin, - lights_toon_fragment: lights_toon_fragment, - lights_toon_pars_fragment: lights_toon_pars_fragment, - lights_phong_fragment: lights_phong_fragment, - lights_phong_pars_fragment: lights_phong_pars_fragment, - lights_physical_fragment: lights_physical_fragment, - lights_physical_pars_fragment: lights_physical_pars_fragment, - lights_fragment_begin: lights_fragment_begin, - lights_fragment_maps: lights_fragment_maps, - lights_fragment_end: lights_fragment_end, - logdepthbuf_fragment: logdepthbuf_fragment, - logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, - logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, - logdepthbuf_vertex: logdepthbuf_vertex, - map_fragment: map_fragment, - map_pars_fragment: map_pars_fragment, - map_particle_fragment: map_particle_fragment, - map_particle_pars_fragment: map_particle_pars_fragment, - metalnessmap_fragment: metalnessmap_fragment, - metalnessmap_pars_fragment: metalnessmap_pars_fragment, - morphnormal_vertex: morphnormal_vertex, - morphtarget_pars_vertex: morphtarget_pars_vertex, - morphtarget_vertex: morphtarget_vertex, - normal_fragment_begin: normal_fragment_begin, - normal_fragment_maps: normal_fragment_maps, - normalmap_pars_fragment: normalmap_pars_fragment, - clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, - clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, - clearcoat_normalmap_pars_fragment: clearcoat_normalmap_pars_fragment, - packing: packing, - premultiplied_alpha_fragment: premultiplied_alpha_fragment, - project_vertex: project_vertex, - dithering_fragment: dithering_fragment, - dithering_pars_fragment: dithering_pars_fragment, - roughnessmap_fragment: roughnessmap_fragment, - roughnessmap_pars_fragment: roughnessmap_pars_fragment, - shadowmap_pars_fragment: shadowmap_pars_fragment, - shadowmap_pars_vertex: shadowmap_pars_vertex, - shadowmap_vertex: shadowmap_vertex, - shadowmask_pars_fragment: shadowmask_pars_fragment, - skinbase_vertex: skinbase_vertex, - skinning_pars_vertex: skinning_pars_vertex, - skinning_vertex: skinning_vertex, - skinnormal_vertex: skinnormal_vertex, - specularmap_fragment: specularmap_fragment, - specularmap_pars_fragment: specularmap_pars_fragment, - tonemapping_fragment: tonemapping_fragment, - tonemapping_pars_fragment: tonemapping_pars_fragment, - uv_pars_fragment: uv_pars_fragment, - uv_pars_vertex: uv_pars_vertex, - uv_vertex: uv_vertex, - uv2_pars_fragment: uv2_pars_fragment, - uv2_pars_vertex: uv2_pars_vertex, - uv2_vertex: uv2_vertex, - worldpos_vertex: worldpos_vertex, + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array, updateRange.offset, updateRange.count ); - background_frag: background_frag, - background_vert: background_vert, - cube_frag: cube_frag, - cube_vert: cube_vert, - depth_frag: depth_frag, - depth_vert: depth_vert, - distanceRGBA_frag: distanceRGBA_frag, - distanceRGBA_vert: distanceRGBA_vert, - equirect_frag: equirect_frag, - equirect_vert: equirect_vert, - linedashed_frag: linedashed_frag, - linedashed_vert: linedashed_vert, - meshbasic_frag: meshbasic_frag, - meshbasic_vert: meshbasic_vert, - meshlambert_frag: meshlambert_frag, - meshlambert_vert: meshlambert_vert, - meshmatcap_frag: meshmatcap_frag, - meshmatcap_vert: meshmatcap_vert, - meshtoon_frag: meshtoon_frag, - meshtoon_vert: meshtoon_vert, - meshphong_frag: meshphong_frag, - meshphong_vert: meshphong_vert, - meshphysical_frag: meshphysical_frag, - meshphysical_vert: meshphysical_vert, - normal_frag: normal_frag, - normal_vert: normal_vert, - points_frag: points_frag, - points_vert: points_vert, - shadow_frag: shadow_frag, - shadow_vert: shadow_vert, - sprite_frag: sprite_frag, - sprite_vert: sprite_vert -}; + } else { -/** - * Uniforms library for shared webgl shaders - */ + gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, + array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); -var UniformsLib = { + } - common: { + updateRange.count = - 1; // reset range - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, + } - map: { value: null }, - uvTransform: { value: new Matrix3() }, - uv2Transform: { value: new Matrix3() }, + } - alphaMap: { value: null }, + // - }, + function get( attribute ) { - specularmap: { + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; - specularMap: { value: null }, + return buffers.get( attribute ); - }, + } - envmap: { + function remove( attribute ) { - envMap: { value: null }, - flipEnvMap: { value: - 1 }, - reflectivity: { value: 1.0 }, - refractionRatio: { value: 0.98 }, - maxMipLevel: { value: 0 } + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; - }, + var data = buffers.get( attribute ); - aomap: { + if ( data ) { - aoMap: { value: null }, - aoMapIntensity: { value: 1 } + gl.deleteBuffer( data.buffer ); - }, + buffers.delete( attribute ); - lightmap: { + } - lightMap: { value: null }, - lightMapIntensity: { value: 1 } + } - }, + function update( attribute, bufferType ) { - emissivemap: { + if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; - emissiveMap: { value: null } + var data = buffers.get( attribute ); - }, + if ( data === undefined ) { - bumpmap: { + buffers.set( attribute, createBuffer( attribute, bufferType ) ); - bumpMap: { value: null }, - bumpScale: { value: 1 } + } else if ( data.version < attribute.version ) { - }, + updateBuffer( data.buffer, attribute, bufferType ); - normalmap: { + data.version = attribute.version; - normalMap: { value: null }, - normalScale: { value: new Vector2( 1, 1 ) } + } - }, + } - displacementmap: { + return { - displacementMap: { value: null }, - displacementScale: { value: 1 }, - displacementBias: { value: 0 } + get: get, + remove: remove, + update: update - }, + }; - roughnessmap: { +} - roughnessMap: { value: null } +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / https://github.com/Mugen87 + */ - }, +// PlaneGeometry - metalnessmap: { +function PlaneGeometry( width, height, widthSegments, heightSegments ) { - metalnessMap: { value: null } + Geometry.call( this ); - }, + this.type = 'PlaneGeometry'; - gradientmap: { + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; - gradientMap: { value: null } + this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); + this.mergeVertices(); - }, +} - fog: { +PlaneGeometry.prototype = Object.create( Geometry.prototype ); +PlaneGeometry.prototype.constructor = PlaneGeometry; - fogDensity: { value: 0.00025 }, - fogNear: { value: 1 }, - fogFar: { value: 2000 }, - fogColor: { value: new Color( 0xffffff ) } +// PlaneBufferGeometry - }, +function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) { - lights: { + BufferGeometry.call( this ); - ambientLightColor: { value: [] }, + this.type = 'PlaneBufferGeometry'; - lightProbe: { value: [] }, + this.parameters = { + width: width, + height: height, + widthSegments: widthSegments, + heightSegments: heightSegments + }; - directionalLights: { value: [], properties: { - direction: {}, - color: {}, + width = width || 1; + height = height || 1; - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } }, + var width_half = width / 2; + var height_half = height / 2; - directionalShadowMap: { value: [] }, - directionalShadowMatrix: { value: [] }, + var gridX = Math.floor( widthSegments ) || 1; + var gridY = Math.floor( heightSegments ) || 1; - spotLights: { value: [], properties: { - color: {}, - position: {}, - direction: {}, - distance: {}, - coneCos: {}, - penumbraCos: {}, - decay: {}, + var gridX1 = gridX + 1; + var gridY1 = gridY + 1; - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {} - } }, + var segment_width = width / gridX; + var segment_height = height / gridY; - spotShadowMap: { value: [] }, - spotShadowMatrix: { value: [] }, + var ix, iy; - pointLights: { value: [], properties: { - color: {}, - position: {}, - decay: {}, - distance: {}, + // buffers - shadow: {}, - shadowBias: {}, - shadowRadius: {}, - shadowMapSize: {}, - shadowCameraNear: {}, - shadowCameraFar: {} - } }, + var indices = []; + var vertices = []; + var normals = []; + var uvs = []; - pointShadowMap: { value: [] }, - pointShadowMatrix: { value: [] }, + // generate vertices, normals and uvs - hemisphereLights: { value: [], properties: { - direction: {}, - skyColor: {}, - groundColor: {} - } }, + for ( iy = 0; iy < gridY1; iy ++ ) { - // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src - rectAreaLights: { value: [], properties: { - color: {}, - position: {}, - width: {}, - height: {} - } } + var y = iy * segment_height - height_half; - }, + for ( ix = 0; ix < gridX1; ix ++ ) { - points: { + var x = ix * segment_width - width_half; - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, - size: { value: 1.0 }, - scale: { value: 1.0 }, - map: { value: null }, - alphaMap: { value: null }, - uvTransform: { value: new Matrix3() } + vertices.push( x, - y, 0 ); - }, + normals.push( 0, 0, 1 ); - sprite: { + uvs.push( ix / gridX ); + uvs.push( 1 - ( iy / gridY ) ); - diffuse: { value: new Color( 0xeeeeee ) }, - opacity: { value: 1.0 }, - center: { value: new Vector2( 0.5, 0.5 ) }, - rotation: { value: 0.0 }, - map: { value: null }, - alphaMap: { value: null }, - uvTransform: { value: new Matrix3() } + } } -}; + // indices -/** - * @author alteredq / http://alteredqualia.com/ - * @author mrdoob / http://mrdoob.com/ - * @author mikael emtinger / http://gomo.se/ - */ + for ( iy = 0; iy < gridY; iy ++ ) { -var ShaderLib = { + for ( ix = 0; ix < gridX; ix ++ ) { - basic: { + var a = ix + gridX1 * iy; + var b = ix + gridX1 * ( iy + 1 ); + var c = ( ix + 1 ) + gridX1 * ( iy + 1 ); + var d = ( ix + 1 ) + gridX1 * iy; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.fog - ] ), + // faces - vertexShader: ShaderChunk.meshbasic_vert, - fragmentShader: ShaderChunk.meshbasic_frag + indices.push( a, b, d ); + indices.push( b, c, d ); - }, + } - lambert: { + } - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) } - } - ] ), + // build geometry - vertexShader: ShaderChunk.meshlambert_vert, - fragmentShader: ShaderChunk.meshlambert_frag + this.setIndex( indices ); + this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); - }, +} - phong: { +PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); +PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - specular: { value: new Color( 0x111111 ) }, - shininess: { value: 30 } - } - ] ), +var alphamap_fragment = "#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif"; - vertexShader: ShaderChunk.meshphong_vert, - fragmentShader: ShaderChunk.meshphong_frag +var alphamap_pars_fragment = "#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; - }, +var alphatest_fragment = "#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif"; - standard: { +var aomap_fragment = "#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.envmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.roughnessmap, - UniformsLib.metalnessmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - roughness: { value: 0.5 }, - metalness: { value: 0.5 }, - envMapIntensity: { value: 1 } // temporary - } - ] ), +var aomap_pars_fragment = "#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif"; - vertexShader: ShaderChunk.meshphysical_vert, - fragmentShader: ShaderChunk.meshphysical_frag +var begin_vertex = "vec3 transformed = vec3( position );"; - }, +var beginnormal_vertex = "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif"; - toon: { +var bsdfs = "vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.specularmap, - UniformsLib.aomap, - UniformsLib.lightmap, - UniformsLib.emissivemap, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.gradientmap, - UniformsLib.fog, - UniformsLib.lights, - { - emissive: { value: new Color( 0x000000 ) }, - specular: { value: new Color( 0x111111 ) }, - shininess: { value: 30 } - } - ] ), +var bumpmap_pars_fragment = "#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif"; - vertexShader: ShaderChunk.meshtoon_vert, - fragmentShader: ShaderChunk.meshtoon_frag +var clipping_planes_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif"; - }, +var clipping_planes_pars_fragment = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif"; - matcap: { +var clipping_planes_pars_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - UniformsLib.fog, - { - matcap: { value: null } - } - ] ), +var clipping_planes_vertex = "#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif"; - vertexShader: ShaderChunk.meshmatcap_vert, - fragmentShader: ShaderChunk.meshmatcap_frag +var color_fragment = "#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif"; - }, +var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; - points: { +var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.points, - UniformsLib.fog - ] ), +var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; - vertexShader: ShaderChunk.points_vert, - fragmentShader: ShaderChunk.points_frag +var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}"; - }, +var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x);\n } else if (face == 1.0) {\n uv = vec2(direction.x, -direction.z) / abs(direction.y);\n } else if (face == 2.0) {\n uv = direction.xy / abs(direction.z);\n } else if (face == 3.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x);\n } else if (face == 4.0) {\n uv = direction.xz / abs(direction.y);\n } else {\n uv = vec2(-direction.x, direction.y) / abs(direction.z);\n }\n return 0.5 * (uv + 1.0);\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness); }\n return mip;\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif"; - dashed: { +var defaultnormal_vertex = "vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.fog, - { - scale: { value: 1 }, - dashSize: { value: 1 }, - totalSize: { value: 2 } - } - ] ), +var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif"; - vertexShader: ShaderChunk.linedashed_vert, - fragmentShader: ShaderChunk.linedashed_frag +var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif"; - }, +var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif"; - depth: { +var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.displacementmap - ] ), +var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; - vertexShader: ShaderChunk.depth_vert, - fragmentShader: ShaderChunk.depth_frag +var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; - }, +var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; - normal: { +var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.bumpmap, - UniformsLib.normalmap, - UniformsLib.displacementmap, - { - opacity: { value: 1.0 } - } - ] ), +var envmap_pars_fragment = "#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif"; - vertexShader: ShaderChunk.normal_vert, - fragmentShader: ShaderChunk.normal_frag +var envmap_pars_vertex = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif"; - }, +var envmap_vertex = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif"; - sprite: { +var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.sprite, - UniformsLib.fog - ] ), +var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; - vertexShader: ShaderChunk.sprite_vert, - fragmentShader: ShaderChunk.sprite_frag +var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; - }, +var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; - background: { +var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}"; - uniforms: { - uvTransform: { value: new Matrix3() }, - t2D: { value: null }, - }, +var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif"; - vertexShader: ShaderChunk.background_vert, - fragmentShader: ShaderChunk.background_frag +var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; - }, - /* ------------------------------------------------------------------------- - // Cube map shader - ------------------------------------------------------------------------- */ +var lights_lambert_vertex = "vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif"; - cube: { +var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.envmap, - { - opacity: { value: 1.0 } - } - ] ), +var envmap_physical_pars_fragment = "#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif"; - vertexShader: ShaderChunk.cube_vert, - fragmentShader: ShaderChunk.cube_frag +var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; - }, +var lights_toon_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)"; - equirect: { +var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;"; - uniforms: { - tEquirect: { value: null }, - }, +var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)"; - vertexShader: ShaderChunk.equirect_vert, - fragmentShader: ShaderChunk.equirect_frag +var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif"; - }, +var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; - distanceRGBA: { +var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.common, - UniformsLib.displacementmap, - { - referencePosition: { value: new Vector3() }, - nearDistance: { value: 1 }, - farDistance: { value: 1000 } - } - ] ), +var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif"; - vertexShader: ShaderChunk.distanceRGBA_vert, - fragmentShader: ShaderChunk.distanceRGBA_frag +var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif"; - }, +var logdepthbuf_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif"; - shadow: { +var logdepthbuf_pars_fragment = "#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif"; - uniforms: mergeUniforms( [ - UniformsLib.lights, - UniformsLib.fog, - { - color: { value: new Color( 0x00000 ) }, - opacity: { value: 1.0 } - }, - ] ), +var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif"; - vertexShader: ShaderChunk.shadow_vert, - fragmentShader: ShaderChunk.shadow_frag +var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif"; - } +var map_fragment = "#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif"; -}; +var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif"; -ShaderLib.physical = { +var map_particle_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif"; - uniforms: mergeUniforms( [ - ShaderLib.standard.uniforms, - { - transparency: { value: 0 }, - clearcoat: { value: 0 }, - clearcoatRoughness: { value: 0 }, - sheen: { value: new Color( 0x000000 ) }, - clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, - clearcoatNormalMap: { value: null }, - } - ] ), +var map_particle_pars_fragment = "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif"; - vertexShader: ShaderChunk.meshphysical_vert, - fragmentShader: ShaderChunk.meshphysical_frag +var metalnessmap_fragment = "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif"; -}; +var metalnessmap_pars_fragment = "#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif"; -/** - * @author mrdoob / http://mrdoob.com/ - */ +var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif"; -function WebGLAnimation() { +var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif"; - var context = null; - var isAnimating = false; - var animationLoop = null; +var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif"; - function onAnimationFrame( time, frame ) { +var normal_fragment_begin = "#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;"; - if ( isAnimating === false ) return; +var normal_fragment_maps = "#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif"; - animationLoop( time, frame ); +var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tmat3 tsn = mat3( S, T, N );\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; - context.requestAnimationFrame( onAnimationFrame ); +var clearcoat_normal_fragment_begin = "#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif"; - } +var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\t#endif\n#endif"; - return { +var clearcoat_pars_fragment = "#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif"; - start: function () { +var packing = "vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}"; - if ( isAnimating === true ) return; - if ( animationLoop === null ) return; +var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif"; - context.requestAnimationFrame( onAnimationFrame ); +var project_vertex = "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;"; - isAnimating = true; +var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; - }, +var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; - stop: function () { +var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; - isAnimating = false; +var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; - }, +var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; - setAnimationLoop: function ( callback ) { +var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; - animationLoop = callback; +var shadowmap_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif"; - }, +var shadowmask_pars_fragment = "float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}"; - setContext: function ( value ) { +var skinbase_vertex = "#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif"; - context = value; +var skinning_pars_vertex = "#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif"; - } +var skinning_vertex = "#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif"; - }; +var skinnormal_vertex = "#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif"; -} +var specularmap_fragment = "float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif"; -/** - * @author mrdoob / http://mrdoob.com/ - */ +var specularmap_pars_fragment = "#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif"; -function WebGLAttributes( gl ) { +var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif"; - var buffers = new WeakMap(); +var tonemapping_pars_fragment = "#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; - function createBuffer( attribute, bufferType ) { +var uv_pars_fragment = "#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif"; - var array = attribute.array; - var usage = attribute.usage; +var uv_pars_vertex = "#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif"; - var buffer = gl.createBuffer(); +var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; - gl.bindBuffer( bufferType, buffer ); - gl.bufferData( bufferType, array, usage ); +var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; - attribute.onUploadCallback(); +var uv2_pars_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif"; - var type = 5126; +var uv2_vertex = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif"; - if ( array instanceof Float32Array ) { +var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif"; - type = 5126; +var background_frag = "uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; - } else if ( array instanceof Float64Array ) { +var background_vert = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}"; - console.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' ); +var cube_frag = "#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}"; - } else if ( array instanceof Uint16Array ) { +var cube_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}"; - type = 5123; +var depth_frag = "#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}"; - } else if ( array instanceof Int16Array ) { +var depth_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}"; - type = 5122; +var distanceRGBA_frag = "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}"; - } else if ( array instanceof Uint32Array ) { +var distanceRGBA_vert = "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}"; - type = 5125; +var equirect_frag = "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}"; - } else if ( array instanceof Int32Array ) { +var equirect_vert = "varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}"; - type = 5124; +var linedashed_frag = "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } else if ( array instanceof Int8Array ) { +var linedashed_vert = "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - type = 5120; +var meshbasic_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } else if ( array instanceof Uint8Array ) { +var meshbasic_vert = "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - type = 5121; +var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } +var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - return { - buffer: buffer, - type: type, - bytesPerElement: array.BYTES_PER_ELEMENT, - version: attribute.version - }; +var meshmatcap_frag = "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } +var meshmatcap_vert = "#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}"; - function updateBuffer( buffer, attribute, bufferType ) { +var meshtoon_frag = "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - var array = attribute.array; - var updateRange = attribute.updateRange; +var meshtoon_vert = "#define TOON\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; - gl.bindBuffer( bufferType, buffer ); +var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - if ( updateRange.count === - 1 ) { +var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - // Not using update ranges +var meshphysical_frag = "#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - gl.bufferSubData( bufferType, 0, array ); +var meshphysical_vert = "#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; - } else { +var normal_frag = "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}"; - gl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, - array.subarray( updateRange.offset, updateRange.offset + updateRange.count ) ); +var normal_vert = "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}"; - updateRange.count = - 1; // reset range +var points_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } +var points_vert = "uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - } +var shadow_frag = "uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}"; - // +var shadow_vert = "#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; - function get( attribute ) { +var sprite_frag = "uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}"; - if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; +var sprite_vert = "uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"; - return buffers.get( attribute ); +var ShaderChunk = { + alphamap_fragment: alphamap_fragment, + alphamap_pars_fragment: alphamap_pars_fragment, + alphatest_fragment: alphatest_fragment, + aomap_fragment: aomap_fragment, + aomap_pars_fragment: aomap_pars_fragment, + begin_vertex: begin_vertex, + beginnormal_vertex: beginnormal_vertex, + bsdfs: bsdfs, + bumpmap_pars_fragment: bumpmap_pars_fragment, + clipping_planes_fragment: clipping_planes_fragment, + clipping_planes_pars_fragment: clipping_planes_pars_fragment, + clipping_planes_pars_vertex: clipping_planes_pars_vertex, + clipping_planes_vertex: clipping_planes_vertex, + color_fragment: color_fragment, + color_pars_fragment: color_pars_fragment, + color_pars_vertex: color_pars_vertex, + color_vertex: color_vertex, + common: common, + cube_uv_reflection_fragment: cube_uv_reflection_fragment, + defaultnormal_vertex: defaultnormal_vertex, + displacementmap_pars_vertex: displacementmap_pars_vertex, + displacementmap_vertex: displacementmap_vertex, + emissivemap_fragment: emissivemap_fragment, + emissivemap_pars_fragment: emissivemap_pars_fragment, + encodings_fragment: encodings_fragment, + encodings_pars_fragment: encodings_pars_fragment, + envmap_fragment: envmap_fragment, + envmap_common_pars_fragment: envmap_common_pars_fragment, + envmap_pars_fragment: envmap_pars_fragment, + envmap_pars_vertex: envmap_pars_vertex, + envmap_physical_pars_fragment: envmap_physical_pars_fragment, + envmap_vertex: envmap_vertex, + fog_vertex: fog_vertex, + fog_pars_vertex: fog_pars_vertex, + fog_fragment: fog_fragment, + fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, + lightmap_fragment: lightmap_fragment, + lightmap_pars_fragment: lightmap_pars_fragment, + lights_lambert_vertex: lights_lambert_vertex, + lights_pars_begin: lights_pars_begin, + lights_toon_fragment: lights_toon_fragment, + lights_toon_pars_fragment: lights_toon_pars_fragment, + lights_phong_fragment: lights_phong_fragment, + lights_phong_pars_fragment: lights_phong_pars_fragment, + lights_physical_fragment: lights_physical_fragment, + lights_physical_pars_fragment: lights_physical_pars_fragment, + lights_fragment_begin: lights_fragment_begin, + lights_fragment_maps: lights_fragment_maps, + lights_fragment_end: lights_fragment_end, + logdepthbuf_fragment: logdepthbuf_fragment, + logdepthbuf_pars_fragment: logdepthbuf_pars_fragment, + logdepthbuf_pars_vertex: logdepthbuf_pars_vertex, + logdepthbuf_vertex: logdepthbuf_vertex, + map_fragment: map_fragment, + map_pars_fragment: map_pars_fragment, + map_particle_fragment: map_particle_fragment, + map_particle_pars_fragment: map_particle_pars_fragment, + metalnessmap_fragment: metalnessmap_fragment, + metalnessmap_pars_fragment: metalnessmap_pars_fragment, + morphnormal_vertex: morphnormal_vertex, + morphtarget_pars_vertex: morphtarget_pars_vertex, + morphtarget_vertex: morphtarget_vertex, + normal_fragment_begin: normal_fragment_begin, + normal_fragment_maps: normal_fragment_maps, + normalmap_pars_fragment: normalmap_pars_fragment, + clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin, + clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps, + clearcoat_pars_fragment: clearcoat_pars_fragment, + packing: packing, + premultiplied_alpha_fragment: premultiplied_alpha_fragment, + project_vertex: project_vertex, + dithering_fragment: dithering_fragment, + dithering_pars_fragment: dithering_pars_fragment, + roughnessmap_fragment: roughnessmap_fragment, + roughnessmap_pars_fragment: roughnessmap_pars_fragment, + shadowmap_pars_fragment: shadowmap_pars_fragment, + shadowmap_pars_vertex: shadowmap_pars_vertex, + shadowmap_vertex: shadowmap_vertex, + shadowmask_pars_fragment: shadowmask_pars_fragment, + skinbase_vertex: skinbase_vertex, + skinning_pars_vertex: skinning_pars_vertex, + skinning_vertex: skinning_vertex, + skinnormal_vertex: skinnormal_vertex, + specularmap_fragment: specularmap_fragment, + specularmap_pars_fragment: specularmap_pars_fragment, + tonemapping_fragment: tonemapping_fragment, + tonemapping_pars_fragment: tonemapping_pars_fragment, + uv_pars_fragment: uv_pars_fragment, + uv_pars_vertex: uv_pars_vertex, + uv_vertex: uv_vertex, + uv2_pars_fragment: uv2_pars_fragment, + uv2_pars_vertex: uv2_pars_vertex, + uv2_vertex: uv2_vertex, + worldpos_vertex: worldpos_vertex, - } + background_frag: background_frag, + background_vert: background_vert, + cube_frag: cube_frag, + cube_vert: cube_vert, + depth_frag: depth_frag, + depth_vert: depth_vert, + distanceRGBA_frag: distanceRGBA_frag, + distanceRGBA_vert: distanceRGBA_vert, + equirect_frag: equirect_frag, + equirect_vert: equirect_vert, + linedashed_frag: linedashed_frag, + linedashed_vert: linedashed_vert, + meshbasic_frag: meshbasic_frag, + meshbasic_vert: meshbasic_vert, + meshlambert_frag: meshlambert_frag, + meshlambert_vert: meshlambert_vert, + meshmatcap_frag: meshmatcap_frag, + meshmatcap_vert: meshmatcap_vert, + meshtoon_frag: meshtoon_frag, + meshtoon_vert: meshtoon_vert, + meshphong_frag: meshphong_frag, + meshphong_vert: meshphong_vert, + meshphysical_frag: meshphysical_frag, + meshphysical_vert: meshphysical_vert, + normal_frag: normal_frag, + normal_vert: normal_vert, + points_frag: points_frag, + points_vert: points_vert, + shadow_frag: shadow_frag, + shadow_vert: shadow_vert, + sprite_frag: sprite_frag, + sprite_vert: sprite_vert +}; - function remove( attribute ) { +/** + * @author alteredq / http://alteredqualia.com/ + * @author mrdoob / http://mrdoob.com/ + * @author mikael emtinger / http://gomo.se/ + */ - if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; +var ShaderLib = { - var data = buffers.get( attribute ); + basic: { - if ( data ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.fog + ] ), - gl.deleteBuffer( data.buffer ); + vertexShader: ShaderChunk.meshbasic_vert, + fragmentShader: ShaderChunk.meshbasic_frag + + }, + + lambert: { + + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) } + } + ] ), + + vertexShader: ShaderChunk.meshlambert_vert, + fragmentShader: ShaderChunk.meshlambert_frag - buffers.delete( attribute ); + }, - } + phong: { - } + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + specular: { value: new Color( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), - function update( attribute, bufferType ) { + vertexShader: ShaderChunk.meshphong_vert, + fragmentShader: ShaderChunk.meshphong_frag - if ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data; + }, - var data = buffers.get( attribute ); + standard: { - if ( data === undefined ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.envmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.roughnessmap, + UniformsLib.metalnessmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + roughness: { value: 1.0 }, + metalness: { value: 0.0 }, + envMapIntensity: { value: 1 } // temporary + } + ] ), - buffers.set( attribute, createBuffer( attribute, bufferType ) ); + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag - } else if ( data.version < attribute.version ) { + }, - updateBuffer( data.buffer, attribute, bufferType ); + toon: { - data.version = attribute.version; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.specularmap, + UniformsLib.aomap, + UniformsLib.lightmap, + UniformsLib.emissivemap, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.gradientmap, + UniformsLib.fog, + UniformsLib.lights, + { + emissive: { value: new Color( 0x000000 ) }, + specular: { value: new Color( 0x111111 ) }, + shininess: { value: 30 } + } + ] ), - } + vertexShader: ShaderChunk.meshtoon_vert, + fragmentShader: ShaderChunk.meshtoon_frag - } + }, - return { + matcap: { - get: get, - remove: remove, - update: update + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + UniformsLib.fog, + { + matcap: { value: null } + } + ] ), - }; + vertexShader: ShaderChunk.meshmatcap_vert, + fragmentShader: ShaderChunk.meshmatcap_frag -} + }, -/** - * @author mrdoob / http://mrdoob.com/ - * @author Mugen87 / https://github.com/Mugen87 - */ + points: { -// PlaneGeometry + uniforms: mergeUniforms( [ + UniformsLib.points, + UniformsLib.fog + ] ), -function PlaneGeometry( width, height, widthSegments, heightSegments ) { + vertexShader: ShaderChunk.points_vert, + fragmentShader: ShaderChunk.points_frag - Geometry.call( this ); + }, - this.type = 'PlaneGeometry'; + dashed: { - this.parameters = { - width: width, - height: height, - widthSegments: widthSegments, - heightSegments: heightSegments - }; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.fog, + { + scale: { value: 1 }, + dashSize: { value: 1 }, + totalSize: { value: 2 } + } + ] ), - this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); - this.mergeVertices(); + vertexShader: ShaderChunk.linedashed_vert, + fragmentShader: ShaderChunk.linedashed_frag -} + }, -PlaneGeometry.prototype = Object.create( Geometry.prototype ); -PlaneGeometry.prototype.constructor = PlaneGeometry; + depth: { -// PlaneBufferGeometry + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap + ] ), -function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) { + vertexShader: ShaderChunk.depth_vert, + fragmentShader: ShaderChunk.depth_frag - BufferGeometry.call( this ); + }, - this.type = 'PlaneBufferGeometry'; + normal: { - this.parameters = { - width: width, - height: height, - widthSegments: widthSegments, - heightSegments: heightSegments - }; + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.bumpmap, + UniformsLib.normalmap, + UniformsLib.displacementmap, + { + opacity: { value: 1.0 } + } + ] ), - width = width || 1; - height = height || 1; + vertexShader: ShaderChunk.normal_vert, + fragmentShader: ShaderChunk.normal_frag - var width_half = width / 2; - var height_half = height / 2; + }, - var gridX = Math.floor( widthSegments ) || 1; - var gridY = Math.floor( heightSegments ) || 1; + sprite: { - var gridX1 = gridX + 1; - var gridY1 = gridY + 1; + uniforms: mergeUniforms( [ + UniformsLib.sprite, + UniformsLib.fog + ] ), - var segment_width = width / gridX; - var segment_height = height / gridY; + vertexShader: ShaderChunk.sprite_vert, + fragmentShader: ShaderChunk.sprite_frag - var ix, iy; + }, - // buffers + background: { - var indices = []; - var vertices = []; - var normals = []; - var uvs = []; + uniforms: { + uvTransform: { value: new Matrix3() }, + t2D: { value: null }, + }, - // generate vertices, normals and uvs + vertexShader: ShaderChunk.background_vert, + fragmentShader: ShaderChunk.background_frag - for ( iy = 0; iy < gridY1; iy ++ ) { + }, + /* ------------------------------------------------------------------------- + // Cube map shader + ------------------------------------------------------------------------- */ - var y = iy * segment_height - height_half; + cube: { - for ( ix = 0; ix < gridX1; ix ++ ) { + uniforms: mergeUniforms( [ + UniformsLib.envmap, + { + opacity: { value: 1.0 } + } + ] ), - var x = ix * segment_width - width_half; + vertexShader: ShaderChunk.cube_vert, + fragmentShader: ShaderChunk.cube_frag - vertices.push( x, - y, 0 ); + }, - normals.push( 0, 0, 1 ); + equirect: { - uvs.push( ix / gridX ); - uvs.push( 1 - ( iy / gridY ) ); + uniforms: { + tEquirect: { value: null }, + }, - } + vertexShader: ShaderChunk.equirect_vert, + fragmentShader: ShaderChunk.equirect_frag - } + }, - // indices + distanceRGBA: { - for ( iy = 0; iy < gridY; iy ++ ) { + uniforms: mergeUniforms( [ + UniformsLib.common, + UniformsLib.displacementmap, + { + referencePosition: { value: new Vector3() }, + nearDistance: { value: 1 }, + farDistance: { value: 1000 } + } + ] ), - for ( ix = 0; ix < gridX; ix ++ ) { + vertexShader: ShaderChunk.distanceRGBA_vert, + fragmentShader: ShaderChunk.distanceRGBA_frag - var a = ix + gridX1 * iy; - var b = ix + gridX1 * ( iy + 1 ); - var c = ( ix + 1 ) + gridX1 * ( iy + 1 ); - var d = ( ix + 1 ) + gridX1 * iy; + }, - // faces + shadow: { - indices.push( a, b, d ); - indices.push( b, c, d ); + uniforms: mergeUniforms( [ + UniformsLib.lights, + UniformsLib.fog, + { + color: { value: new Color( 0x00000 ) }, + opacity: { value: 1.0 } + }, + ] ), - } + vertexShader: ShaderChunk.shadow_vert, + fragmentShader: ShaderChunk.shadow_frag } - // build geometry +}; - this.setIndex( indices ); - this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); - this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); - this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) ); +ShaderLib.physical = { -} + uniforms: mergeUniforms( [ + ShaderLib.standard.uniforms, + { + clearcoat: { value: 0 }, + clearcoatMap: { value: null }, + clearcoatRoughness: { value: 0 }, + clearcoatRoughnessMap: { value: null }, + clearcoatNormalScale: { value: new Vector2( 1, 1 ) }, + clearcoatNormalMap: { value: null }, + sheen: { value: new Color( 0x000000 ) }, + transparency: { value: 0 }, + } + ] ), -PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); -PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry; + vertexShader: ShaderChunk.meshphysical_vert, + fragmentShader: ShaderChunk.meshphysical_frag + +}; /** * @author mrdoob / http://mrdoob.com/ @@ -15353,10 +15530,10 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) { var planeMesh; var boxMesh; - // Store the current background texture and its `version` - // so we can recompile the material accordingly. + var currentBackground = null; var currentBackgroundVersion = 0; + var currentTonemapping = null; function render( renderList, scene, camera, forceClear ) { @@ -15377,15 +15554,11 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) { if ( background === null ) { setClear( clearColor, clearAlpha ); - currentBackground = null; - currentBackgroundVersion = 0; } else if ( background && background.isColor ) { setClear( background, 1 ); forceClear = true; - currentBackground = null; - currentBackgroundVersion = 0; } @@ -15395,7 +15568,7 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) { } - if ( background && ( background.isCubeTexture || background.isWebGLRenderTargetCube || background.mapping === CubeUVReflectionMapping ) ) { + if ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) { if ( boxMesh === undefined ) { @@ -15437,18 +15610,20 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) { } - var texture = background.isWebGLRenderTargetCube ? background.texture : background; + var texture = background.isWebGLCubeRenderTarget ? background.texture : background; boxMesh.material.uniforms.envMap.value = texture; boxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1; if ( currentBackground !== background || - currentBackgroundVersion !== texture.version ) { + currentBackgroundVersion !== texture.version || + currentTonemapping !== renderer.toneMapping ) { boxMesh.material.needsUpdate = true; currentBackground = background; currentBackgroundVersion = texture.version; + currentTonemapping = renderer.toneMapping; } @@ -15501,12 +15676,14 @@ function WebGLBackground( renderer, state, objects, premultipliedAlpha ) { planeMesh.material.uniforms.uvTransform.value.copy( background.matrix ); if ( currentBackground !== background || - currentBackgroundVersion !== background.version ) { + currentBackgroundVersion !== background.version || + currentTonemapping !== renderer.toneMapping ) { planeMesh.material.needsUpdate = true; currentBackground = background; currentBackgroundVersion = background.version; + currentTonemapping = renderer.toneMapping; } @@ -15891,6 +16068,7 @@ function WebGLClipping() { } scope.numPlanes = nPlanes; + scope.numIntersection = 0; return dstArray; @@ -16443,7 +16621,7 @@ function WebGLMorphtargets( gl ) { function WebGLObjects( gl, geometries, attributes, info ) { - var updateList = {}; + var updateMap = new WeakMap(); function update( object ) { @@ -16454,7 +16632,7 @@ function WebGLObjects( gl, geometries, attributes, info ) { // Update once per frame - if ( updateList[ buffergeometry.id ] !== frame ) { + if ( updateMap.get( buffergeometry ) !== frame ) { if ( geometry.isGeometry ) { @@ -16464,7 +16642,7 @@ function WebGLObjects( gl, geometries, attributes, info ) { geometries.update( buffergeometry ); - updateList[ buffergeometry.id ] = frame; + updateMap.set( buffergeometry, frame ); } @@ -16480,7 +16658,7 @@ function WebGLObjects( gl, geometries, attributes, info ) { function dispose() { - updateList = {}; + updateMap = new WeakMap(); } @@ -17053,6 +17231,20 @@ function setValueV4i( gl, v ) { } +// uint + +function setValueV1ui( gl, v ) { + + var cache = this.cache; + + if ( cache[ 0 ] === v ) return; + + gl.uniform1ui( this.addr, v ); + + cache[ 0 ] = v; + +} + // Helper to pick the right setter for the singular case function getSingularSetter( type ) { @@ -17068,16 +17260,37 @@ function getSingularSetter( type ) { case 0x8b5b: return setValueM3; // _MAT3 case 0x8b5c: return setValueM4; // _MAT4 - case 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES - case 0x8b5f: return setValueT3D1; // SAMPLER_3D - case 0x8b60: return setValueT6; // SAMPLER_CUBE - case 0x8DC1: return setValueT2DArray1; // SAMPLER_2D_ARRAY - case 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL case 0x8b53: case 0x8b57: return setValueV2i; // _VEC2 case 0x8b54: case 0x8b58: return setValueV3i; // _VEC3 case 0x8b55: case 0x8b59: return setValueV4i; // _VEC4 + case 0x1405: return setValueV1ui; // UINT + + case 0x8b5e: // SAMPLER_2D + case 0x8d66: // SAMPLER_EXTERNAL_OES + case 0x8dca: // INT_SAMPLER_2D + case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW + return setValueT1; + + case 0x8b5f: // SAMPLER_3D + case 0x8dcb: // INT_SAMPLER_3D + case 0x8dd3: // UNSIGNED_INT_SAMPLER_3D + return setValueT3D1; + + case 0x8b60: // SAMPLER_CUBE + case 0x8dcc: // INT_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW + return setValueT6; + + case 0x8dc1: // SAMPLER_2D_ARRAY + case 0x8dcf: // INT_SAMPLER_2D_ARRAY + case 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY + case 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW + return setValueT2DArray1; + } } @@ -17216,22 +17429,24 @@ function getPureArraySetter( type ) { case 0x8b5b: return setValueM3Array; // _MAT3 case 0x8b5c: return setValueM4Array; // _MAT4 + case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL + case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 + case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 + case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 + case 0x8b5e: // SAMPLER_2D case 0x8d66: // SAMPLER_EXTERNAL_OES case 0x8dca: // INT_SAMPLER_2D case 0x8dd2: // UNSIGNED_INT_SAMPLER_2D + case 0x8b62: // SAMPLER_2D_SHADOW return setValueT1Array; case 0x8b60: // SAMPLER_CUBE case 0x8dcc: // INT_SAMPLER_CUBE - case 0x8dd4: // UNSIGNED_SAMPLER_CUBE + case 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE + case 0x8dc5: // SAMPLER_CUBE_SHADOW return setValueT6Array; - case 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL - case 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2 - case 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3 - case 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4 - } } @@ -17568,15 +17783,13 @@ function getToneMappingFunction( functionName, toneMapping ) { } -function generateExtensions( extensions, parameters, rendererExtensions ) { - - extensions = extensions || {}; +function generateExtensions( parameters ) { var chunks = [ - ( extensions.derivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', - ( extensions.fragDepth || parameters.logarithmicDepthBuffer ) && rendererExtensions.get( 'EXT_frag_depth' ) ? '#extension GL_EXT_frag_depth : enable' : '', - ( extensions.drawBuffers ) && rendererExtensions.get( 'WEBGL_draw_buffers' ) ? '#extension GL_EXT_draw_buffers : require' : '', - ( extensions.shaderTextureLOD || parameters.envMap ) && rendererExtensions.get( 'EXT_shader_texture_lod' ) ? '#extension GL_EXT_shader_texture_lod : enable' : '' + ( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '', + ( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', + ( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '', + ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : '' ]; return chunks.filter( filterEmptyLine ).join( '\n' ); @@ -17676,11 +17889,21 @@ function includeReplacer( match, include ) { // Unroll Loops -var loopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; +var deprecatedUnrollLoopPattern = /#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g; +var unrollLoopPattern = /#pragma unroll_loop_start[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}[\s]+?#pragma unroll_loop_end/g; function unrollLoops( string ) { - return string.replace( loopPattern, loopReplacer ); + return string + .replace( unrollLoopPattern, loopReplacer ) + .replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer ); + +} + +function deprecatedLoopReplacer( match, start, end, snippet ) { + + console.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' ); + return loopReplacer( match, start, end, snippet ); } @@ -17830,14 +18053,14 @@ function generateEnvMapBlendingDefine( parameters ) { } -function WebGLProgram( renderer, extensions, cacheKey, material, shader, parameters ) { +function WebGLProgram( renderer, cacheKey, parameters ) { var gl = renderer.getContext(); - var defines = material.defines; + var defines = parameters.defines; - var vertexShader = shader.vertexShader; - var fragmentShader = shader.fragmentShader; + var vertexShader = parameters.vertexShader; + var fragmentShader = parameters.fragmentShader; var shadowMapTypeDefine = generateShadowMapTypeDefine( parameters ); var envMapTypeDefine = generateEnvMapTypeDefine( parameters ); var envMapModeDefine = generateEnvMapModeDefine( parameters ); @@ -17846,7 +18069,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet var gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0; - var customExtensions = parameters.isWebGL2 ? '' : generateExtensions( material.extensions, parameters, extensions ); + var customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters ); var customDefines = generateDefines( defines ); @@ -17854,9 +18077,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet var prefixVertex, prefixFragment; - var numMultiviewViews = parameters.numMultiviewViews; - - if ( material.isRawShaderMaterial ) { + if ( parameters.isRawShaderMaterial ) { prefixVertex = [ @@ -17889,7 +18110,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet generatePrecision( parameters ), - '#define SHADER_NAME ' + shader.name, + '#define SHADER_NAME ' + parameters.shaderName, customDefines, @@ -17913,6 +18134,8 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', @@ -17941,7 +18164,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', @@ -18015,7 +18238,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet generatePrecision( parameters ), - '#define SHADER_NAME ' + shader.name, + '#define SHADER_NAME ' + parameters.shaderName, customDefines, @@ -18039,6 +18262,8 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet parameters.normalMap ? '#define USE_NORMALMAP' : '', ( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '', ( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '', + parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', + parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', @@ -18067,9 +18292,9 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', - parameters.logarithmicDepthBuffer && ( parameters.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', + ( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '', - ( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( parameters.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', + ( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', @@ -18090,7 +18315,7 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet parameters.lightMapEncoding ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '', parameters.outputEncoding ? getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ) : '', - parameters.depthPacking ? '#define DEPTH_PACKING ' + material.depthPacking : '', + parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\n' @@ -18109,13 +18334,13 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet vertexShader = unrollLoops( vertexShader ); fragmentShader = unrollLoops( fragmentShader ); - if ( parameters.isWebGL2 && ! material.isRawShaderMaterial ) { + if ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) { var isGLSL3ShaderMaterial = false; var versionRegex = /^\s*#version\s+300\s+es\s*\n/; - if ( material.isShaderMaterial && + if ( parameters.isShaderMaterial && vertexShader.match( versionRegex ) !== null && fragmentShader.match( versionRegex ) !== null ) { @@ -18152,59 +18377,6 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet '#define textureCubeGradEXT textureGrad' ].join( '\n' ) + '\n' + prefixFragment; - // Multiview - - if ( numMultiviewViews > 0 ) { - - prefixVertex = prefixVertex.replace( - '#version 300 es\n', - [ - '#version 300 es\n', - '#extension GL_OVR_multiview2 : require', - 'layout(num_views = ' + numMultiviewViews + ') in;', - '#define VIEW_ID gl_ViewID_OVR' - ].join( '\n' ) - ); - - prefixVertex = prefixVertex.replace( - [ - 'uniform mat4 modelViewMatrix;', - 'uniform mat4 projectionMatrix;', - 'uniform mat4 viewMatrix;', - 'uniform mat3 normalMatrix;' - ].join( '\n' ), - [ - 'uniform mat4 modelViewMatrices[' + numMultiviewViews + '];', - 'uniform mat4 projectionMatrices[' + numMultiviewViews + '];', - 'uniform mat4 viewMatrices[' + numMultiviewViews + '];', - 'uniform mat3 normalMatrices[' + numMultiviewViews + '];', - - '#define modelViewMatrix modelViewMatrices[VIEW_ID]', - '#define projectionMatrix projectionMatrices[VIEW_ID]', - '#define viewMatrix viewMatrices[VIEW_ID]', - '#define normalMatrix normalMatrices[VIEW_ID]' - ].join( '\n' ) - ); - - prefixFragment = prefixFragment.replace( - '#version 300 es\n', - [ - '#version 300 es\n', - '#extension GL_OVR_multiview2 : require', - '#define VIEW_ID gl_ViewID_OVR' - ].join( '\n' ) - ); - - prefixFragment = prefixFragment.replace( - 'uniform mat4 viewMatrix;', - [ - 'uniform mat4 viewMatrices[' + numMultiviewViews + '];', - '#define viewMatrix viewMatrices[VIEW_ID]' - ].join( '\n' ) - ); - - } - } var vertexGlsl = prefixVertex + vertexShader; @@ -18221,9 +18393,9 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet // Force a particular attribute to index 0. - if ( material.index0AttributeName !== undefined ) { + if ( parameters.index0AttributeName !== undefined ) { - gl.bindAttribLocation( program, 0, material.index0AttributeName ); + gl.bindAttribLocation( program, 0, parameters.index0AttributeName ); } else if ( parameters.morphTargets === true ) { @@ -18268,7 +18440,6 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet this.diagnostics = { runnable: runnable, - material: material, programLog: programLog, @@ -18292,7 +18463,11 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet } - // clean up + // Clean up + + // Crashes in iOS9 and iOS10. #18402 + // gl.detachShader( program, glVertexShader ); + // gl.detachShader( program, glFragmentShader ); gl.deleteShader( glVertexShader ); gl.deleteShader( glFragmentShader ); @@ -18340,14 +18515,13 @@ function WebGLProgram( renderer, extensions, cacheKey, material, shader, paramet // - this.name = shader.name; + this.name = parameters.shaderName; this.id = programIdCount ++; this.cacheKey = cacheKey; this.usedTimes = 1; this.program = program; this.vertexShader = glVertexShader; this.fragmentShader = glFragmentShader; - this.numMultiviewViews = numMultiviewViews; return this; @@ -18387,9 +18561,9 @@ function WebGLPrograms( renderer, extensions, capabilities ) { }; var parameterNames = [ - "precision", "isWebGL2", "supportsVertexTextures", "outputEncoding", "instancing", "numMultiviewViews", + "precision", "isWebGL2", "supportsVertexTextures", "outputEncoding", "instancing", "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "envMapCubeUV", - "lightMap", "lightMapEncoding", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "tangentSpaceNormalMap", "clearcoatNormalMap", "displacementMap", "specularMap", + "lightMap", "lightMapEncoding", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "tangentSpaceNormalMap", "clearcoatMap", "clearcoatRoughnessMap", "clearcoatNormalMap", "displacementMap", "specularMap", "roughnessMap", "metalnessMap", "gradientMap", "alphaMap", "combine", "vertexColors", "vertexTangents", "vertexUvs", "uvsVertexOnly", "fog", "useFog", "fogExp2", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", @@ -18402,6 +18576,35 @@ function WebGLPrograms( renderer, extensions, capabilities ) { "sheen" ]; + function getShaderObject( material, shaderID ) { + + var shaderobject; + + if ( shaderID ) { + + var shader = ShaderLib[ shaderID ]; + + shaderobject = { + name: material.type, + uniforms: UniformsUtils.clone( shader.uniforms ), + vertexShader: shader.vertexShader, + fragmentShader: shader.fragmentShader + }; + + } else { + + shaderobject = { + name: material.type, + uniforms: material.uniforms, + vertexShader: material.vertexShader, + fragmentShader: material.fragmentShader + }; + + } + + return shaderobject; + + } function allocateBones( object ) { @@ -18488,21 +18691,31 @@ function WebGLPrograms( renderer, extensions, capabilities ) { } + var shaderobject = getShaderObject( material, shaderID ); + material.onBeforeCompile( shaderobject, renderer ); + var currentRenderTarget = renderer.getRenderTarget(); - var numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0; var parameters = { isWebGL2: isWebGL2, shaderID: shaderID, + shaderName: shaderobject.name, + + uniforms: shaderobject.uniforms, + vertexShader: shaderobject.vertexShader, + fragmentShader: shaderobject.fragmentShader, + defines: material.defines, + + isRawShaderMaterial: material.isRawShaderMaterial, + isShaderMaterial: material.isShaderMaterial, precision: precision, instancing: object.isInstancedMesh === true, supportsVertexTextures: vertexTextures, - numMultiviewViews: numMultiviewViews, outputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding, map: !! material.map, mapEncoding: getTextureEncodingFromMap( material.map ), @@ -18521,6 +18734,8 @@ function WebGLPrograms( renderer, extensions, capabilities ) { normalMap: !! material.normalMap, objectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap, tangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap, + clearcoatMap: !! material.clearcoatMap, + clearcoatRoughnessMap: !! material.clearcoatRoughnessMap, clearcoatNormalMap: !! material.clearcoatNormalMap, displacementMap: !! material.displacementMap, roughnessMap: !! material.roughnessMap, @@ -18536,7 +18751,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) { vertexTangents: ( material.normalMap && material.vertexTangents ), vertexColors: material.vertexColors, - vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap || !! material.displacementMap, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap, uvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap, fog: !! fog, @@ -18584,7 +18799,20 @@ function WebGLPrograms( renderer, extensions, capabilities ) { doubleSided: material.side === DoubleSide, flipSided: material.side === BackSide, - depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false + depthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false, + + index0AttributeName: material.index0AttributeName, + + extensionDerivatives: material.extensions && material.extensions.derivatives, + extensionFragDepth: material.extensions && material.extensions.fragDepth, + extensionDrawBuffers: material.extensions && material.extensions.drawBuffers, + extensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD, + + rendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null, + rendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null, + rendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null, + + onBeforeCompile: material.onBeforeCompile }; @@ -18592,7 +18820,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) { }; - this.getProgramCacheKey = function ( material, parameters ) { + this.getProgramCacheKey = function ( parameters ) { var array = []; @@ -18602,23 +18830,23 @@ function WebGLPrograms( renderer, extensions, capabilities ) { } else { - array.push( material.fragmentShader ); - array.push( material.vertexShader ); + array.push( parameters.fragmentShader ); + array.push( parameters.vertexShader ); } - if ( material.defines !== undefined ) { + if ( parameters.defines !== undefined ) { - for ( var name in material.defines ) { + for ( var name in parameters.defines ) { array.push( name ); - array.push( material.defines[ name ] ); + array.push( parameters.defines[ name ] ); } } - if ( material.isRawShaderMaterial === undefined ) { + if ( parameters.isRawShaderMaterial === undefined ) { for ( var i = 0; i < parameterNames.length; i ++ ) { @@ -18631,13 +18859,13 @@ function WebGLPrograms( renderer, extensions, capabilities ) { } - array.push( material.onBeforeCompile.toString() ); + array.push( parameters.onBeforeCompile.toString() ); return array.join(); }; - this.acquireProgram = function ( material, shader, parameters, cacheKey ) { + this.acquireProgram = function ( parameters, cacheKey ) { var program; @@ -18659,7 +18887,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) { if ( program === undefined ) { - program = new WebGLProgram( renderer, extensions, cacheKey, material, shader, parameters ); + program = new WebGLProgram( renderer, cacheKey, parameters ); programs.push( program ); } @@ -18878,6 +19106,27 @@ function WebGLRenderList() { } + function finish() { + + // Clear references from inactive renderItems in the list + + for ( var i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) { + + var renderItem = renderItems[ i ]; + + if ( renderItem.id === null ) break; + + renderItem.id = null; + renderItem.object = null; + renderItem.geometry = null; + renderItem.material = null; + renderItem.program = null; + renderItem.group = null; + + } + + } + return { opaque: opaque, transparent: transparent, @@ -18885,6 +19134,7 @@ function WebGLRenderList() { init: init, push: push, unshift: unshift, + finish: finish, sort: sort }; @@ -18971,12 +19221,7 @@ function UniformsCache() { case 'DirectionalLight': uniforms = { direction: new Vector3(), - color: new Color(), - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2() + color: new Color() }; break; @@ -18988,12 +19233,7 @@ function UniformsCache() { distance: 0, coneCos: 0, penumbraCos: 0, - decay: 0, - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2() + decay: 0 }; break; @@ -19002,14 +19242,7 @@ function UniformsCache() { position: new Vector3(), color: new Color(), distance: 0, - decay: 0, - - shadow: false, - shadowBias: 0, - shadowRadius: 1, - shadowMapSize: new Vector2(), - shadowCameraNear: 1, - shadowCameraFar: 1000 + decay: 0 }; break; @@ -19027,7 +19260,6 @@ function UniformsCache() { position: new Vector3(), halfWidth: new Vector3(), halfHeight: new Vector3() - // TODO (abelnation): set RectAreaLight shadow uniforms }; break; @@ -19043,6 +19275,66 @@ function UniformsCache() { } +function ShadowUniformsCache() { + + var lights = {}; + + return { + + get: function ( light ) { + + if ( lights[ light.id ] !== undefined ) { + + return lights[ light.id ]; + + } + + var uniforms; + + switch ( light.type ) { + + case 'DirectionalLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'SpotLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2() + }; + break; + + case 'PointLight': + uniforms = { + shadowBias: 0, + shadowRadius: 1, + shadowMapSize: new Vector2(), + shadowCameraNear: 1, + shadowCameraFar: 1000 + }; + break; + + // TODO (abelnation): set RectAreaLight shadow uniforms + + } + + lights[ light.id ] = uniforms; + + return uniforms; + + } + + }; + +} + + + var nextVersion = 0; function shadowCastingLightsFirst( lightA, lightB ) { @@ -19055,6 +19347,8 @@ function WebGLLights() { var cache = new UniformsCache(); + var shadowCache = ShadowUniformsCache(); + var state = { version: 0, @@ -19068,26 +19362,25 @@ function WebGLLights() { numDirectionalShadows: - 1, numPointShadows: - 1, - numSpotShadows: - 1, + numSpotShadows: - 1 }, ambient: [ 0, 0, 0 ], probe: [], directional: [], + directionalShadow: [], directionalShadowMap: [], directionalShadowMatrix: [], spot: [], + spotShadow: [], spotShadowMap: [], spotShadowMatrix: [], rectArea: [], point: [], + pointShadow: [], pointShadowMap: [], pointShadowMatrix: [], - hemi: [], - - numDirectionalShadows: - 1, - numPointShadows: - 1, - numSpotShadows: - 1 + hemi: [] }; @@ -19151,16 +19444,17 @@ function WebGLLights() { uniforms.direction.sub( vector3 ); uniforms.direction.transformDirection( viewMatrix ); - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + state.directionalShadow[ directionalLength ] = shadowUniforms; state.directionalShadowMap[ directionalLength ] = shadowMap; state.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix; @@ -19191,16 +19485,17 @@ function WebGLLights() { uniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) ); uniforms.decay = light.decay; - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + state.spotShadow[ spotLength ] = shadowUniforms; state.spotShadowMap[ spotLength ] = shadowMap; state.spotShadowMatrix[ spotLength ] = light.shadow.matrix; @@ -19255,18 +19550,19 @@ function WebGLLights() { uniforms.distance = light.distance; uniforms.decay = light.decay; - uniforms.shadow = light.castShadow; - if ( light.castShadow ) { var shadow = light.shadow; - uniforms.shadowBias = shadow.bias; - uniforms.shadowRadius = shadow.radius; - uniforms.shadowMapSize = shadow.mapSize; - uniforms.shadowCameraNear = shadow.camera.near; - uniforms.shadowCameraFar = shadow.camera.far; + var shadowUniforms = shadowCache.get( light ); + + shadowUniforms.shadowBias = shadow.bias; + shadowUniforms.shadowRadius = shadow.radius; + shadowUniforms.shadowMapSize = shadow.mapSize; + shadowUniforms.shadowCameraNear = shadow.camera.near; + shadowUniforms.shadowCameraFar = shadow.camera.far; + state.pointShadow[ pointLength ] = shadowUniforms; state.pointShadowMap[ pointLength ] = shadowMap; state.pointShadowMatrix[ pointLength ] = light.shadow.matrix; @@ -19318,8 +19614,11 @@ function WebGLLights() { state.point.length = pointLength; state.hemi.length = hemiLength; + state.directionalShadow.length = numDirectionalShadows; state.directionalShadowMap.length = numDirectionalShadows; + state.pointShadow.length = numPointShadows; state.pointShadowMap.length = numPointShadows; + state.spotShadow.length = numSpotShadows; state.spotShadowMap.length = numSpotShadows; state.directionalShadowMatrix.length = numDirectionalShadows; state.pointShadowMatrix.length = numPointShadows; @@ -19728,8 +20027,6 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) { - console.warn( 'THREE.WebGLShadowMap:', light, 'has shadow exceeding max texture size, reducing' ); - if ( _shadowMapSize.x > maxTextureSize ) { _viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x ); @@ -19886,9 +20183,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { } - function getDepthMaterial( object, material, light, shadowCameraNear, shadowCameraFar, type ) { - - var geometry = object.geometry; + function getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) { var result = null; @@ -19908,15 +20203,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( material.morphTargets === true ) { - if ( geometry.isBufferGeometry === true ) { - - useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0; - - } else if ( geometry.isGeometry === true ) { - - useMorphing = geometry.morphTargets && geometry.morphTargets.length > 0; - - } + useMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0; } @@ -20035,7 +20322,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( groupMaterial && groupMaterial.visible ) { - var depthMaterial = getDepthMaterial( object, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); + var depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group ); @@ -20045,7 +20332,7 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { } else if ( material.visible ) { - var depthMaterial = getDepthMaterial( object, material, light, shadowCamera.near, shadowCamera.far, type ); + var depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type ); _renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null ); @@ -20528,6 +20815,20 @@ function WebGLState( gl, extensions, capabilities ) { } + function vertexAttribPointer( index, size, type, normalized, stride, offset ) { + + if ( isWebGL2 === true && ( type === 5124 || type === 5125 ) ) { + + gl.vertexAttribIPointer( index, size, type, normalized, stride, offset ); + + } else { + + gl.vertexAttribPointer( index, size, type, normalized, stride, offset ); + + } + + } + function enable( id ) { if ( enabledCapabilities[ id ] !== true ) { @@ -21046,6 +21347,7 @@ function WebGLState( gl, extensions, capabilities ) { enableAttribute: enableAttribute, enableAttributeAndDivisor: enableAttributeAndDivisor, disableUnusedAttributes: disableUnusedAttributes, + vertexAttribPointer: vertexAttribPointer, enable: enable, disable: disable, @@ -21142,7 +21444,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { - var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor; + var floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor; var width = floor( scale * image.width ); var height = floor( scale * image.height ); @@ -21183,7 +21485,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function isPowerOfTwo( image ) { - return _Math.isPowerOfTwo( image.width ) && _Math.isPowerOfTwo( image.height ); + return MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height ); } @@ -21257,10 +21559,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, extensions.get( 'EXT_color_buffer_float' ); - } else if ( internalFormat === 34843 || internalFormat === 34837 ) { - - console.warn( 'THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.' ); - } return internalFormat; @@ -21346,7 +21644,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - if ( renderTarget.isWebGLRenderTargetCube ) { + if ( renderTarget.isWebGLCubeRenderTarget ) { for ( var i = 0; i < 6; i ++ ) { @@ -21359,21 +21657,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer ); if ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer ); - - } - - if ( renderTarget.isWebGLMultiviewRenderTarget ) { - - _gl.deleteTexture( renderTargetProperties.__webglColorTexture ); - _gl.deleteTexture( renderTargetProperties.__webglDepthStencilTexture ); - - info.memory.textures -= 2; - - for ( var i = 0, il = renderTargetProperties.__webglViewFramebuffers.length; i < il; i ++ ) { - - _gl.deleteFramebuffer( renderTargetProperties.__webglViewFramebuffers[ i ] ); - - } + if ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer ); + if ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer ); + if ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer ); } @@ -21489,7 +21775,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.pixelStorei( 37440, texture.flipY ); - var isCompressed = ( texture && texture.isCompressedTexture ); + var isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) ); var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); var cubeImage = []; @@ -21746,18 +22032,38 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, glInternalFormat = 6402; - if ( texture.type === FloatType ) { + if ( isWebGL2 ) { + + if ( texture.type === FloatType ) { + + glInternalFormat = 36012; - if ( isWebGL2 === false ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' ); - glInternalFormat = 36012; + } else if ( texture.type === UnsignedIntType ) { - } else if ( isWebGL2 ) { + glInternalFormat = 33190; - // WebGL 2.0 requires signed internalformat for glTexImage2D - glInternalFormat = 33189; + } else if ( texture.type === UnsignedInt248Type ) { + + glInternalFormat = 35056; + + } else { + + glInternalFormat = 33189; // WebGL2 requires sized internalformat for glTexImage2D + + } + + } else { + + if ( texture.type === FloatType ) { + + console.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' ); + + } } + // validation checks for WebGL 1 + if ( texture.format === DepthFormat && glInternalFormat === 6402 ) { // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are @@ -21774,10 +22080,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - // Depth stencil textures need the DEPTH_STENCIL internal format - // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) - if ( texture.format === DepthStencilFormat ) { + if ( texture.format === DepthStencilFormat && glInternalFormat === 6402 ) { + // Depth stencil textures need the DEPTH_STENCIL internal format + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) glInternalFormat = 34041; // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are @@ -21794,6 +22100,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } + // + state.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null ); } else if ( texture.isDataTexture ) { @@ -21922,15 +22230,33 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) { + var glInternalFormat = 33189; + if ( isMultisample ) { + var depthTexture = renderTarget.depthTexture; + + if ( depthTexture && depthTexture.isDepthTexture ) { + + if ( depthTexture.type === FloatType ) { + + glInternalFormat = 36012; + + } else if ( depthTexture.type === UnsignedIntType ) { + + glInternalFormat = 33190; + + } + + } + var samples = getRenderTargetSamples( renderTarget ); - _gl.renderbufferStorageMultisample( 36161, samples, 33189, renderTarget.width, renderTarget.height ); + _gl.renderbufferStorageMultisample( 36161, samples, glInternalFormat, renderTarget.width, renderTarget.height ); } else { - _gl.renderbufferStorage( 36161, 33189, renderTarget.width, renderTarget.height ); + _gl.renderbufferStorage( 36161, glInternalFormat, renderTarget.width, renderTarget.height ); } @@ -21980,7 +22306,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, // Setup resources for a Depth Texture for a FBO (needs an extension) function setupDepthTexture( framebuffer, renderTarget ) { - var isCube = ( renderTarget && renderTarget.isWebGLRenderTargetCube ); + var isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget ); if ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' ); _gl.bindFramebuffer( 36160, framebuffer ); @@ -22027,7 +22353,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, var renderTargetProperties = properties.get( renderTarget ); - var isCube = ( renderTarget.isWebGLRenderTargetCube === true ); + var isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); if ( renderTarget.depthTexture ) { @@ -22045,7 +22371,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer[ i ] ); renderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget ); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false ); } @@ -22053,7 +22379,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget ); + setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false ); } @@ -22075,11 +22401,20 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info.memory.textures ++; - var isCube = ( renderTarget.isWebGLRenderTargetCube === true ); + var isCube = ( renderTarget.isWebGLCubeRenderTarget === true ); var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true ); - var isMultiview = ( renderTarget.isWebGLMultiviewRenderTarget === true ); var supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2; + // Handles WebGL2 RGBFormat fallback - #18858 + + if ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) { + + renderTarget.texture.format = RGBAFormat; + + console.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' ); + + } + // Setup framebuffer if ( isCube ) { @@ -22131,48 +22466,6 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - } else if ( isMultiview ) { - - var width = renderTarget.width; - var height = renderTarget.height; - var numViews = renderTarget.numViews; - - _gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer ); - - var ext = extensions.get( 'OVR_multiview2' ); - - info.memory.textures += 2; - - var colorTexture = _gl.createTexture(); - _gl.bindTexture( 35866, colorTexture ); - _gl.texParameteri( 35866, 10240, 9728 ); - _gl.texParameteri( 35866, 10241, 9728 ); - _gl.texImage3D( 35866, 0, 32856, width, height, numViews, 0, 6408, 5121, null ); - ext.framebufferTextureMultiviewOVR( 36160, 36064, colorTexture, 0, 0, numViews ); - - var depthStencilTexture = _gl.createTexture(); - _gl.bindTexture( 35866, depthStencilTexture ); - _gl.texParameteri( 35866, 10240, 9728 ); - _gl.texParameteri( 35866, 10241, 9728 ); - _gl.texImage3D( 35866, 0, 35056, width, height, numViews, 0, 34041, 34042, null ); - ext.framebufferTextureMultiviewOVR( 36160, 33306, depthStencilTexture, 0, 0, numViews ); - - var viewFramebuffers = new Array( numViews ); - for ( var i = 0; i < numViews; ++ i ) { - - viewFramebuffers[ i ] = _gl.createFramebuffer(); - _gl.bindFramebuffer( 36160, viewFramebuffers[ i ] ); - _gl.framebufferTextureLayer( 36160, 36064, colorTexture, 0, i ); - - } - - renderTargetProperties.__webglColorTexture = colorTexture; - renderTargetProperties.__webglDepthStencilTexture = depthStencilTexture; - renderTargetProperties.__webglViewFramebuffers = viewFramebuffers; - - _gl.bindFramebuffer( 36160, null ); - _gl.bindTexture( 35866, null ); - } } @@ -22198,7 +22491,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, state.bindTexture( 34067, null ); - } else if ( ! isMultiview ) { + } else { state.bindTexture( 3553, textureProperties.__webglTexture ); setTextureParameters( 3553, renderTarget.texture, supportsMips ); @@ -22231,7 +22524,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - var target = renderTarget.isWebGLRenderTargetCube ? 34067 : 3553; + var target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553; var webglTexture = properties.get( texture ).__webglTexture; state.bindTexture( target, webglTexture ); @@ -22262,6 +22555,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, 9728 ); + _gl.bindFramebuffer( 36160, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905 + } else { console.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' ); @@ -22320,7 +22615,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function safeSetTextureCube( texture, slot ) { - if ( texture && texture.isWebGLRenderTargetCube ) { + if ( texture && texture.isWebGLCubeRenderTarget ) { if ( warnedTextureCube === false ) { @@ -22333,7 +22628,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - // currently relying on the fact that WebGLRenderTargetCube.texture is a Texture and NOT a CubeTexture + // currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture // TODO: unify these code paths if ( ( texture && texture.isCubeTexture ) || ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) { @@ -22345,7 +22640,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } else { - // assumed: texture property of THREE.WebGLRenderTargetCube + // assumed: texture property of THREE.WebGLCubeRenderTarget setTextureCubeDynamic( texture, slot ); } @@ -22486,11 +22781,29 @@ function WebGLUtils( gl, extensions, capabilities ) { } + if ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) { + + extension = extensions.get( 'WEBGL_compressed_texture_etc' ); + + if ( extension !== null ) { + + if ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2; + if ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC; + + } + + } + if ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || - p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) { + p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format || + p === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format || + p === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format || + p === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format || + p === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format || + p === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) { extension = extensions.get( 'WEBGL_compressed_texture_astc' ); @@ -22508,6 +22821,24 @@ function WebGLUtils( gl, extensions, capabilities ) { } + if ( p === RGBA_BPTC_Format ) { + + extension = extensions.get( 'EXT_texture_compression_bptc' ); + + if ( extension !== null ) { + + // TODO Complete? + + return p; + + } else { + + return null; + + } + + } + if ( p === UnsignedInt248Type ) { if ( isWebGL2 ) return 34042; @@ -22533,307 +22864,179 @@ function WebGLUtils( gl, extensions, capabilities ) { } /** - * @author fernandojsg / http://fernandojsg.com - * @author Takahiro https://github.com/takahirox + * @author mrdoob / http://mrdoob.com/ */ -function WebGLMultiviewRenderTarget( width, height, numViews, options ) { - - WebGLRenderTarget.call( this, width, height, options ); +function ArrayCamera( array ) { - this.depthBuffer = false; - this.stencilBuffer = false; + PerspectiveCamera.call( this ); - this.numViews = numViews; + this.cameras = array || []; } -WebGLMultiviewRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { - - constructor: WebGLMultiviewRenderTarget, - - isWebGLMultiviewRenderTarget: true, - - copy: function ( source ) { - - WebGLRenderTarget.prototype.copy.call( this, source ); - - this.numViews = source.numViews; - - return this; - - }, - - setNumViews: function ( numViews ) { - - if ( this.numViews !== numViews ) { - - this.numViews = numViews; - this.dispose(); - - } +ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), { - return this; + constructor: ArrayCamera, - } + isArrayCamera: true } ); /** - * @author fernandojsg / http://fernandojsg.com - * @author Takahiro https://github.com/takahirox + * @author mrdoob / http://mrdoob.com/ */ -function WebGLMultiview( renderer, gl ) { +function Group() { - var DEFAULT_NUMVIEWS = 2; + Object3D.call( this ); - var extensions = renderer.extensions; - var properties = renderer.properties; + this.type = 'Group'; - var renderTarget, currentRenderTarget; - var mat3, mat4, cameraArray, renderSize; +} - var available; - var maxNumViews = 0; +Group.prototype = Object.assign( Object.create( Object3D.prototype ), { - // + constructor: Group, - function isAvailable() { + isGroup: true - if ( available === undefined ) { +} ); - var extension = extensions.get( 'OVR_multiview2' ); +/** + * @author Mugen87 / https://github.com/Mugen87 + */ - available = extension !== null && gl.getContextAttributes().antialias === false; +function WebXRController() { - if ( available ) { + this._targetRay = null; + this._grip = null; - maxNumViews = gl.getParameter( extension.MAX_VIEWS_OVR ); - renderTarget = new WebGLMultiviewRenderTarget( 0, 0, DEFAULT_NUMVIEWS ); +} - renderSize = new Vector2(); - mat4 = []; - mat3 = []; - cameraArray = []; +Object.assign( WebXRController.prototype, { - for ( var i = 0; i < maxNumViews; i ++ ) { + constructor: WebXRController, - mat4[ i ] = new Matrix4(); - mat3[ i ] = new Matrix3(); + getTargetRaySpace: function () { - } + if ( this._targetRay === null ) { - } + this._targetRay = new Group(); + this._targetRay.matrixAutoUpdate = false; + this._targetRay.visible = false; } - return available; - - } - - function getCameraArray( camera ) { + return this._targetRay; - if ( camera.isArrayCamera ) return camera.cameras; - - cameraArray[ 0 ] = camera; - - return cameraArray; - - } - - function updateCameraProjectionMatricesUniform( camera, uniforms ) { + }, - var cameras = getCameraArray( camera ); + getGripSpace: function () { - for ( var i = 0; i < cameras.length; i ++ ) { + if ( this._grip === null ) { - mat4[ i ].copy( cameras[ i ].projectionMatrix ); + this._grip = new Group(); + this._grip.matrixAutoUpdate = false; + this._grip.visible = false; } - uniforms.setValue( gl, 'projectionMatrices', mat4 ); + return this._grip; - } - - function updateCameraViewMatricesUniform( camera, uniforms ) { + }, - var cameras = getCameraArray( camera ); + dispatchEvent: function ( event ) { - for ( var i = 0; i < cameras.length; i ++ ) { + if ( this._targetRay !== null ) { - mat4[ i ].copy( cameras[ i ].matrixWorldInverse ); + this._targetRay.dispatchEvent( event ); } - uniforms.setValue( gl, 'viewMatrices', mat4 ); - - } - - function updateObjectMatricesUniforms( object, camera, uniforms ) { - - var cameras = getCameraArray( camera ); + if ( this._grip !== null ) { - for ( var i = 0; i < cameras.length; i ++ ) { - - mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld ); - mat3[ i ].getNormalMatrix( mat4[ i ] ); + this._grip.dispatchEvent( event ); } - uniforms.setValue( gl, 'modelViewMatrices', mat4 ); - uniforms.setValue( gl, 'normalMatrices', mat3 ); - - } - - function isMultiviewCompatible( camera ) { - - if ( camera.isArrayCamera === undefined ) return true; - - var cameras = camera.cameras; - - if ( cameras.length > maxNumViews ) return false; - - for ( var i = 1, il = cameras.length; i < il; i ++ ) { - - if ( cameras[ 0 ].viewport.z !== cameras[ i ].viewport.z || - cameras[ 0 ].viewport.w !== cameras[ i ].viewport.w ) return false; - - } - - return true; - - } + return this; - function resizeRenderTarget( camera ) { + }, - if ( currentRenderTarget ) { + disconnect: function ( inputSource ) { - renderSize.set( currentRenderTarget.width, currentRenderTarget.height ); + this.dispatchEvent( { type: 'disconnected', data: inputSource } ); - } else { + if ( this._targetRay !== null ) { - renderer.getDrawingBufferSize( renderSize ); + this._targetRay.visible = false; } - if ( camera.isArrayCamera ) { - - var viewport = camera.cameras[ 0 ].viewport; - - renderTarget.setSize( viewport.z, viewport.w ); - renderTarget.setNumViews( camera.cameras.length ); + if ( this._grip !== null ) { - } else { - - renderTarget.setSize( renderSize.x, renderSize.y ); - renderTarget.setNumViews( DEFAULT_NUMVIEWS ); + this._grip.visible = false; } - } - - function attachCamera( camera ) { + return this; - if ( isMultiviewCompatible( camera ) === false ) return; + }, - currentRenderTarget = renderer.getRenderTarget(); - resizeRenderTarget( camera ); - renderer.setRenderTarget( renderTarget ); + update: function ( inputSource, frame, referenceSpace ) { - } + var inputPose = null; + var gripPose = null; - function detachCamera( camera ) { + var targetRay = this._targetRay; + var grip = this._grip; - if ( renderTarget !== renderer.getRenderTarget() ) return; + if ( inputSource ) { - renderer.setRenderTarget( currentRenderTarget ); + if ( targetRay !== null ) { - flush( camera ); + inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); - } - - function flush( camera ) { + if ( inputPose !== null ) { - var srcRenderTarget = renderTarget; - var numViews = srcRenderTarget.numViews; + targetRay.matrix.fromArray( inputPose.transform.matrix ); + targetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale ); - var srcFramebuffers = properties.get( srcRenderTarget ).__webglViewFramebuffers; + } - var viewWidth = srcRenderTarget.width; - var viewHeight = srcRenderTarget.height; + } - if ( camera.isArrayCamera ) { + if ( grip !== null && inputSource.gripSpace ) { - for ( var i = 0; i < numViews; i ++ ) { + gripPose = frame.getPose( inputSource.gripSpace, referenceSpace ); - var viewport = camera.cameras[ i ].viewport; + if ( gripPose !== null ) { - var x1 = viewport.x; - var y1 = viewport.y; - var x2 = x1 + viewport.z; - var y2 = y1 + viewport.w; + grip.matrix.fromArray( gripPose.transform.matrix ); + grip.matrix.decompose( grip.position, grip.rotation, grip.scale ); - gl.bindFramebuffer( 36008, srcFramebuffers[ i ] ); - gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, x1, y1, x2, y2, 16384, 9728 ); + } } - } else { - - gl.bindFramebuffer( 36008, srcFramebuffers[ 0 ] ); - gl.blitFramebuffer( 0, 0, viewWidth, viewHeight, 0, 0, renderSize.x, renderSize.y, 16384, 9728 ); - } - } - - this.isAvailable = isAvailable; - this.attachCamera = attachCamera; - this.detachCamera = detachCamera; - this.updateCameraProjectionMatricesUniform = updateCameraProjectionMatricesUniform; - this.updateCameraViewMatricesUniform = updateCameraViewMatricesUniform; - this.updateObjectMatricesUniforms = updateObjectMatricesUniforms; + if ( targetRay !== null ) { -} + targetRay.visible = ( inputPose !== null ); -/** - * @author mrdoob / http://mrdoob.com/ - */ - -function ArrayCamera( array ) { - - PerspectiveCamera.call( this ); - - this.cameras = array || []; - -} - -ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), { - - constructor: ArrayCamera, - - isArrayCamera: true - -} ); - -/** - * @author mrdoob / http://mrdoob.com/ - */ - -function Group() { - - Object3D.call( this ); + } - this.type = 'Group'; + if ( grip !== null ) { -} + grip.visible = ( gripPose !== null ); -Group.prototype = Object.assign( Object.create( Object3D.prototype ), { + } - constructor: Group, + return this; - isGroup: true + } } ); @@ -22847,7 +23050,7 @@ function WebXRManager( renderer, gl ) { var session = null; - // var framebufferScaleFactor = 1.0; + var framebufferScaleFactor = 1.0; var referenceSpace = null; var referenceSpaceType = 'local-floor'; @@ -22867,31 +23070,48 @@ function WebXRManager( renderer, gl ) { cameraR.layers.enable( 2 ); cameraR.viewport = new Vector4(); - var cameraVR = new ArrayCamera( [ cameraL, cameraR ] ); + var cameras = [ cameraL, cameraR ]; + + var cameraVR = new ArrayCamera(); cameraVR.layers.enable( 1 ); cameraVR.layers.enable( 2 ); + var _currentDepthNear = null; + var _currentDepthFar = null; + // this.enabled = false; this.isPresenting = false; - this.getController = function ( id ) { + this.getController = function ( index ) { - var controller = controllers[ id ]; + var controller = controllers[ index ]; if ( controller === undefined ) { - controller = new Group(); - controller.matrixAutoUpdate = false; - controller.visible = false; + controller = new WebXRController(); + controllers[ index ] = controller; + + } + + return controller.getTargetRaySpace(); + + }; - controllers[ id ] = controller; + this.getControllerGrip = function ( index ) { + + var controller = controllers[ index ]; + + if ( controller === undefined ) { + + controller = new WebXRController(); + controllers[ index ] = controller; } - return controller; + return controller.getGripSpace(); }; @@ -22913,8 +23133,7 @@ function WebXRManager( renderer, gl ) { inputSourcesMap.forEach( function ( controller, inputSource ) { - controller.dispatchEvent( { type: 'disconnected', data: inputSource } ); - controller.visible = false; + controller.disconnect( inputSource ); } ); @@ -22926,10 +23145,10 @@ function WebXRManager( renderer, gl ) { renderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830 animation.stop(); - scope.dispatchEvent( { type: 'sessionend' } ); - scope.isPresenting = false; + scope.dispatchEvent( { type: 'sessionend' } ); + } function onRequestReferenceSpace( value ) { @@ -22939,15 +23158,21 @@ function WebXRManager( renderer, gl ) { animation.setContext( session ); animation.start(); - scope.dispatchEvent( { type: 'sessionstart' } ); - scope.isPresenting = true; + scope.dispatchEvent( { type: 'sessionstart' } ); + } - this.setFramebufferScaleFactor = function ( /* value */ ) { + this.setFramebufferScaleFactor = function ( value ) { + + framebufferScaleFactor = value; - // framebufferScaleFactor = value; + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' ); + + } }; @@ -22955,6 +23180,12 @@ function WebXRManager( renderer, gl ) { referenceSpaceType = value; + if ( scope.isPresenting === true ) { + + console.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' ); + + } + }; this.getReferenceSpace = function () { @@ -22989,7 +23220,8 @@ function WebXRManager( renderer, gl ) { antialias: attributes.antialias, alpha: attributes.alpha, depth: attributes.depth, - stencil: attributes.stencil + stencil: attributes.stencil, + framebufferScaleFactor: framebufferScaleFactor }; // eslint-disable-next-line no-undef @@ -23132,6 +23364,23 @@ function WebXRManager( renderer, gl ) { this.getCamera = function ( camera ) { + cameraVR.near = cameraR.near = cameraL.near = camera.near; + cameraVR.far = cameraR.far = cameraL.far = camera.far; + + if ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) { + + // Note that the new renderState won't apply until the next frame. See #18320 + + session.updateRenderState( { + depthNear: cameraVR.near, + depthFar: cameraVR.far + } ); + + _currentDepthNear = cameraVR.near; + _currentDepthFar = cameraVR.far; + + } + var parent = camera.parent; var cameras = cameraVR.cameras; @@ -23155,7 +23404,19 @@ function WebXRManager( renderer, gl ) { } - setProjectionFromUnion( cameraVR, cameraL, cameraR ); + // update projection matrix for proper view frustum culling + + if ( cameras.length === 2 ) { + + setProjectionFromUnion( cameraVR, cameraL, cameraR ); + + } else { + + // assume single camera setup (AR) + + cameraVR.projectionMatrix.copy( cameraL.projectionMatrix ); + + } return cameraVR; @@ -23176,14 +23437,24 @@ function WebXRManager( renderer, gl ) { renderer.setFramebuffer( baseLayer.framebuffer ); + var cameraVRNeedsUpdate = false; + + // check if it's necessary to rebuild cameraVR's camera list + + if ( views.length !== cameraVR.cameras.length ) { + + cameraVR.cameras.length = 0; + cameraVRNeedsUpdate = true; + + } + for ( var i = 0; i < views.length; i ++ ) { var view = views[ i ]; var viewport = baseLayer.getViewport( view ); - var viewMatrix = view.transform.inverse.matrix; - var camera = cameraVR.cameras[ i ]; - camera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix ); + var camera = cameras[ i ]; + camera.matrix.fromArray( view.transform.matrix ); camera.projectionMatrix.fromArray( view.projectionMatrix ); camera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height ); @@ -23193,6 +23464,12 @@ function WebXRManager( renderer, gl ) { } + if ( cameraVRNeedsUpdate === true ) { + + cameraVR.cameras.push( camera ); + + } + } } @@ -23204,26 +23481,9 @@ function WebXRManager( renderer, gl ) { for ( var i = 0; i < controllers.length; i ++ ) { var controller = controllers[ i ]; - var inputSource = inputSources[ i ]; - if ( inputSource ) { - - var inputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace ); - - if ( inputPose !== null ) { - - controller.matrix.fromArray( inputPose.transform.matrix ); - controller.matrix.decompose( controller.position, controller.rotation, controller.scale ); - controller.visible = true; - - continue; - - } - - } - - controller.visible = false; + controller.update( inputSource, frame, referenceSpace ); } @@ -23314,7 +23574,7 @@ function WebGLRenderer( parameters ) { // tone mapping - this.toneMapping = LinearToneMapping; + this.toneMapping = NoToneMapping; this.toneMappingExposure = 1.0; this.toneMappingWhitePoint = 1.0; @@ -23484,7 +23744,7 @@ function WebGLRenderer( parameters ) { info = new WebGLInfo( _gl ); properties = new WebGLProperties(); textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ); - attributes = new WebGLAttributes( _gl ); + attributes = new WebGLAttributes( _gl, capabilities ); geometries = new WebGLGeometries( _gl, attributes, info ); objects = new WebGLObjects( _gl, geometries, attributes, info ); morphtargets = new WebGLMorphtargets( _gl ); @@ -23516,10 +23776,6 @@ function WebGLRenderer( parameters ) { this.xr = xr; - // Multiview - - var multiview = new WebGLMultiview( _this, _gl ); - // shadow map var shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize ); @@ -23957,6 +24213,12 @@ function WebGLRenderer( parameters ) { } + if ( object.isInstancedMesh === true ) { + + updateBuffers = true; + + } + // var index = geometry.index; @@ -24151,7 +24413,7 @@ function WebGLRenderer( parameters ) { } _gl.bindBuffer( 34962, buffer ); - _gl.vertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement ); + state.vertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement ); } else { @@ -24172,7 +24434,7 @@ function WebGLRenderer( parameters ) { } _gl.bindBuffer( 34962, buffer ); - _gl.vertexAttribPointer( programAttribute, size, type, normalized, 0, 0 ); + state.vertexAttribPointer( programAttribute, size, type, normalized, 0, 0 ); } @@ -24261,6 +24523,8 @@ function WebGLRenderer( parameters ) { currentRenderState.setupLights( camera ); + var compiled = {}; + scene.traverse( function ( object ) { if ( object.material ) { @@ -24269,13 +24533,19 @@ function WebGLRenderer( parameters ) { for ( var i = 0; i < object.material.length; i ++ ) { - initMaterial( object.material[ i ], scene, object ); + if ( object.material[ i ].uuid in compiled === false ) { + + initMaterial( object.material[ i ], scene, object ); + compiled[ object.material[ i ].uuid ] = true; + + } } - } else { + } else if ( object.material.uuid in compiled === false ) { initMaterial( object.material, scene, object ); + compiled[ object.material.uuid ] = true; } @@ -24362,14 +24632,13 @@ function WebGLRenderer( parameters ) { } // + scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget ); currentRenderState = renderStates.get( scene, camera ); currentRenderState.init(); - scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget ); - _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); - _frustum.setFromMatrix( _projScreenMatrix ); + _frustum.setFromProjectionMatrix( _projScreenMatrix ); _localClippingEnabled = this.localClippingEnabled; _clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera ); @@ -24379,6 +24648,8 @@ function WebGLRenderer( parameters ) { projectObject( scene, camera, 0, _this.sortObjects ); + currentRenderList.finish(); + if ( _this.sortObjects === true ) { currentRenderList.sort( _opaqueSort, _transparentSort ); @@ -24407,12 +24678,6 @@ function WebGLRenderer( parameters ) { } - if ( xr.enabled && multiview.isAvailable() ) { - - multiview.attachCamera( camera ); - - } - // background.render( currentRenderList, scene, camera, forceClear ); @@ -24467,16 +24732,6 @@ function WebGLRenderer( parameters ) { state.setPolygonOffset( false ); - if ( xr.enabled ) { - - if ( multiview.isAvailable() ) { - - multiview.detachCamera( camera ); - - } - - } - // _gl.finish(); currentRenderList = null; @@ -24624,27 +24879,19 @@ function WebGLRenderer( parameters ) { _currentArrayCamera = camera; - if ( xr.enabled && multiview.isAvailable() ) { - - renderObject( object, scene, camera, geometry, material, group ); - - } else { - - var cameras = camera.cameras; + var cameras = camera.cameras; - for ( var j = 0, jl = cameras.length; j < jl; j ++ ) { + for ( var j = 0, jl = cameras.length; j < jl; j ++ ) { - var camera2 = cameras[ j ]; + var camera2 = cameras[ j ]; - if ( object.layers.test( camera2.layers ) ) { + if ( object.layers.test( camera2.layers ) ) { - state.viewport( _currentViewport.copy( camera2.viewport ) ); + state.viewport( _currentViewport.copy( camera2.viewport ) ); - currentRenderState.setupLights( camera2 ); + currentRenderState.setupLights( camera2 ); - renderObject( object, scene, camera2, geometry, material, group ); - - } + renderObject( object, scene, camera2, geometry, material, group ); } @@ -24702,10 +24949,8 @@ function WebGLRenderer( parameters ) { var lightsStateVersion = lights.state.version; - var parameters = programCache.getParameters( - material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object ); - - var programCacheKey = programCache.getProgramCacheKey( material, parameters ); + var parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object ); + var programCacheKey = programCache.getProgramCacheKey( parameters ); var program = materialProperties.program; var programChange = true; @@ -24740,38 +24985,11 @@ function WebGLRenderer( parameters ) { if ( programChange ) { - if ( parameters.shaderID ) { - - var shader = ShaderLib[ parameters.shaderID ]; - - materialProperties.shader = { - name: material.type, - uniforms: cloneUniforms( shader.uniforms ), - vertexShader: shader.vertexShader, - fragmentShader: shader.fragmentShader - }; - - } else { - - materialProperties.shader = { - name: material.type, - uniforms: material.uniforms, - vertexShader: material.vertexShader, - fragmentShader: material.fragmentShader - }; - - } - - material.onBeforeCompile( materialProperties.shader, _this ); - - // Computing cache key again as onBeforeCompile may have changed the shaders - programCacheKey = programCache.getProgramCacheKey( material, parameters ); - - program = programCache.acquireProgram( material, materialProperties.shader, parameters, programCacheKey ); + program = programCache.acquireProgram( parameters, programCacheKey ); materialProperties.program = program; - materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; - materialProperties.outputEncoding = _this.outputEncoding; + materialProperties.uniforms = parameters.uniforms; + materialProperties.outputEncoding = parameters.outputEncoding; material.program = program; } @@ -24810,7 +25028,7 @@ function WebGLRenderer( parameters ) { } - var uniforms = materialProperties.shader.uniforms; + var uniforms = materialProperties.uniforms; if ( ! material.isShaderMaterial && ! material.isRawShaderMaterial || @@ -24822,6 +25040,7 @@ function WebGLRenderer( parameters ) { } + materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null; materialProperties.fog = scene.fog; // store the light setup it was created for @@ -24836,9 +25055,12 @@ function WebGLRenderer( parameters ) { uniforms.ambientLightColor.value = lights.state.ambient; uniforms.lightProbe.value = lights.state.probe; uniforms.directionalLights.value = lights.state.directional; + uniforms.directionalLightShadows.value = lights.state.directionalShadow; uniforms.spotLights.value = lights.state.spot; + uniforms.spotLightShadows.value = lights.state.spotShadow; uniforms.rectAreaLights.value = lights.state.rectArea; uniforms.pointLights.value = lights.state.point; + uniforms.pointLightShadows.value = lights.state.pointShadow; uniforms.hemisphereLights.value = lights.state.hemi; uniforms.directionalShadowMap.value = lights.state.directionalShadowMap; @@ -24865,6 +25087,7 @@ function WebGLRenderer( parameters ) { var fog = scene.fog; var environment = material.isMeshStandardMaterial ? scene.environment : null; + var encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding; var materialProperties = properties.get( material ); var lights = currentRenderState.state.lights; @@ -24892,35 +25115,33 @@ function WebGLRenderer( parameters ) { if ( materialProperties.program === undefined ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( material.fog && materialProperties.fog !== fog ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.environment !== environment ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } else if ( materialProperties.numClippingPlanes !== undefined && ( materialProperties.numClippingPlanes !== _clipping.numPlanes || materialProperties.numIntersection !== _clipping.numIntersection ) ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); - } else if ( materialProperties.outputEncoding !== _this.outputEncoding ) { + } else if ( materialProperties.outputEncoding !== encoding ) { - material.needsUpdate = true; + initMaterial( material, scene, object ); } - } - - if ( material.version !== materialProperties.__version ) { + } else { initMaterial( material, scene, object ); materialProperties.__version = material.version; @@ -24933,7 +25154,7 @@ function WebGLRenderer( parameters ) { var program = materialProperties.program, p_uniforms = program.getUniforms(), - m_uniforms = materialProperties.shader.uniforms; + m_uniforms = materialProperties.uniforms; if ( state.useProgram( program.program ) ) { @@ -24953,15 +25174,7 @@ function WebGLRenderer( parameters ) { if ( refreshProgram || _currentCamera !== camera ) { - if ( program.numMultiviewViews > 0 ) { - - multiview.updateCameraProjectionMatricesUniform( camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); - - } + p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix ); if ( capabilities.logarithmicDepthBuffer ) { @@ -25022,15 +25235,7 @@ function WebGLRenderer( parameters ) { material.isShaderMaterial || material.skinning ) { - if ( program.numMultiviewViews > 0 ) { - - multiview.updateCameraViewMatricesUniform( camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); - - } + p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse ); } @@ -25038,7 +25243,7 @@ function WebGLRenderer( parameters ) { // skinning uniforms must be set even if material didn't change // auto-setting of texture unit for bone texture must go before other textures - // not sure why, but otherwise weird things happen + // otherwise textures used for skinning can take over texture units reserved for other material textures if ( material.skinning ) { @@ -25064,7 +25269,7 @@ function WebGLRenderer( parameters ) { var size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix - size = _Math.ceilPowerOfTwo( size ); + size = MathUtils.ceilPowerOfTwo( size ); size = Math.max( size, 4 ); var boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel @@ -25235,17 +25440,8 @@ function WebGLRenderer( parameters ) { // common matrices - if ( program.numMultiviewViews > 0 ) { - - multiview.updateObjectMatricesUniforms( object, camera, p_uniforms ); - - } else { - - p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); - p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); - - } - + p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix ); + p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix ); p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); return program; @@ -25294,10 +25490,6 @@ function WebGLRenderer( parameters ) { uniforms.envMap.value = envMap; - // don't flip CubeTexture envMaps, flip everything else: - // WebGLRenderTargetCube will be flipped for backwards compatibility - // WebGLRenderTargetCube.texture will be flipped because it's a Texture and NOT a CubeTexture - // this check must be handled differently, or removed entirely, if WebGLRenderTargetCube uses a CubeTexture in the future uniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1; uniforms.reflectivity.value = material.reflectivity; @@ -25710,6 +25902,18 @@ function WebGLRenderer( parameters ) { uniforms.clearcoatRoughness.value = material.clearcoatRoughness; if ( material.sheen ) uniforms.sheen.value.copy( material.sheen ); + if ( material.clearcoatMap ) { + + uniforms.clearcoatMap.value = material.clearcoatMap; + + } + + if ( material.clearcoatRoughnessMap ) { + + uniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap; + + } + if ( material.clearcoatNormalMap ) { uniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale ); @@ -25825,8 +26029,11 @@ function WebGLRenderer( parameters ) { uniforms.lightProbe.needsUpdate = value; uniforms.directionalLights.needsUpdate = value; + uniforms.directionalLightShadows.needsUpdate = value; uniforms.pointLights.needsUpdate = value; + uniforms.pointLightShadows.needsUpdate = value; uniforms.spotLights.needsUpdate = value; + uniforms.spotLightShadows.needsUpdate = value; uniforms.rectAreaLights.needsUpdate = value; uniforms.hemisphereLights.needsUpdate = value; @@ -25886,7 +26093,7 @@ function WebGLRenderer( parameters ) { var __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer; - if ( renderTarget.isWebGLRenderTargetCube ) { + if ( renderTarget.isWebGLCubeRenderTarget ) { framebuffer = __webglFramebuffer[ activeCubeFace || 0 ]; isCube = true; @@ -25944,7 +26151,7 @@ function WebGLRenderer( parameters ) { var framebuffer = properties.get( renderTarget ).__webglFramebuffer; - if ( renderTarget.isWebGLRenderTargetCube && activeCubeFaceIndex !== undefined ) { + if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) { framebuffer = framebuffer[ activeCubeFaceIndex ]; @@ -26033,6 +26240,8 @@ function WebGLRenderer( parameters ) { this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) { + if ( level === undefined ) level = 0; + var width = srcTexture.image.width; var height = srcTexture.image.height; var glFormat = utils.convert( dstTexture.format ); @@ -26042,14 +26251,25 @@ function WebGLRenderer( parameters ) { if ( srcTexture.isDataTexture ) { - _gl.texSubImage2D( 3553, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); + _gl.texSubImage2D( 3553, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data ); } else { - _gl.texSubImage2D( 3553, level || 0, position.x, position.y, glFormat, glType, srcTexture.image ); + if ( srcTexture.isCompressedTexture ) { + + _gl.compressedTexSubImage2D( 3553, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data ); + + } else { + + _gl.texSubImage2D( 3553, level, position.x, position.y, glFormat, glType, srcTexture.image ); + + } } + // Generate mipmaps only when copying level 0 + if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( 3553 ); + state.unbindTexture(); }; @@ -26242,7 +26462,7 @@ Object.assign( InterleavedBuffer.prototype, { * @author benaadams / https://twitter.com/ben_a_adams */ -var _vector$7 = new Vector3(); +var _vector$6 = new Vector3(); function InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normalized ) { @@ -26286,13 +26506,13 @@ Object.assign( InterleavedBufferAttribute.prototype, { for ( var i = 0, l = this.data.count; i < l; i ++ ) { - _vector$7.x = this.getX( i ); - _vector$7.y = this.getY( i ); - _vector$7.z = this.getZ( i ); + _vector$6.x = this.getX( i ); + _vector$6.y = this.getY( i ); + _vector$6.z = this.getZ( i ); - _vector$7.applyMatrix4( m ); + _vector$6.applyMatrix4( m ); - this.setXYZ( i, _vector$7.x, _vector$7.y, _vector$7.z ); + this.setXYZ( i, _vector$6.x, _vector$6.y, _vector$6.z ); } @@ -26644,6 +26864,8 @@ function LOD() { Object3D.call( this ); + this._currentLevel = 0; + this.type = 'LOD'; Object.defineProperties( this, { @@ -26709,6 +26931,12 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { }, + getCurrentLevel: function () { + + return this._currentLevel; + + }, + getObjectForDistance: function ( distance ) { var levels = this.levels; @@ -26758,7 +26986,7 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { _v1$4.setFromMatrixPosition( camera.matrixWorld ); _v2$2.setFromMatrixPosition( this.matrixWorld ); - var distance = _v1$4.distanceTo( _v2$2 ); + var distance = _v1$4.distanceTo( _v2$2 ) / camera.zoom; levels[ 0 ].object.visible = true; @@ -26777,6 +27005,8 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { } + this._currentLevel = i - 1; + for ( ; i < l; i ++ ) { levels[ i ].object.visible = false; @@ -26924,7 +27154,51 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { return new this.constructor( this.geometry, this.material ).copy( this ); - } + }, + + boneTransform: ( function () { + + var basePosition = new Vector3(); + + var skinIndex = new Vector4(); + var skinWeight = new Vector4(); + + var vector = new Vector3(); + var matrix = new Matrix4(); + + return function ( index, target ) { + + var skeleton = this.skeleton; + var geometry = this.geometry; + + skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index ); + skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index ); + + basePosition.fromBufferAttribute( geometry.attributes.position, index ).applyMatrix4( this.bindMatrix ); + + target.set( 0, 0, 0 ); + + for ( var i = 0; i < 4; i ++ ) { + + var weight = skinWeight.getComponent( i ); + + if ( weight !== 0 ) { + + var boneIndex = skinIndex.getComponent( i ); + + matrix.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] ); + + target.addScaledVector( vector.copy( basePosition ).applyMatrix4( matrix ), weight ); + + } + + } + + return target.applyMatrix4( this.bindMatrixInverse ); + + }; + + }() ) } ); @@ -27096,6 +27370,18 @@ Object.assign( Skeleton.prototype, { return undefined; + }, + + dispose: function ( ) { + + if ( this.boneTexture ) { + + this.boneTexture.dispose(); + + this.boneTexture = undefined; + + } + } } ); @@ -27141,6 +27427,8 @@ function InstancedMesh( geometry, material, count ) { this.count = count; + this.frustumCulled = false; + } InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { @@ -27181,17 +27469,17 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { // process the result of raycast - if ( _instanceIntersects.length > 0 ) { - - _instanceIntersects[ 0 ].instanceId = instanceId; - _instanceIntersects[ 0 ].object = this; - - intersects.push( _instanceIntersects[ 0 ] ); + for ( var i = 0, l = _instanceIntersects.length; i < l; i ++ ) { - _instanceIntersects.length = 0; + var intersect = _instanceIntersects[ i ]; + intersect.instanceId = instanceId; + intersect.object = this; + intersects.push( intersect ); } + _instanceIntersects.length = 0; + } }, @@ -27280,7 +27568,7 @@ function Line( geometry, material, mode ) { this.type = 'Line'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new LineBasicMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new LineBasicMaterial(); } @@ -27343,10 +27631,9 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - var precision = raycaster.linePrecision; - var geometry = this.geometry; var matrixWorld = this.matrixWorld; + var threshold = raycaster.params.Line.threshold; // Checking boundingSphere distance to ray @@ -27354,7 +27641,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { _sphere$2.copy( geometry.boundingSphere ); _sphere$2.applyMatrix4( matrixWorld ); - _sphere$2.radius += precision; + _sphere$2.radius += threshold; if ( raycaster.ray.intersectsSphere( _sphere$2 ) === false ) return; @@ -27363,8 +27650,8 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { _inverseMatrix$1.getInverse( matrixWorld ); _ray$1.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$1 ); - var localPrecision = precision / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); - var localPrecisionSq = localPrecision * localPrecision; + var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); + var localThresholdSq = localThreshold * localThreshold; var vStart = new Vector3(); var vEnd = new Vector3(); @@ -27392,7 +27679,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); - if ( distSq > localPrecisionSq ) continue; + if ( distSq > localThresholdSq ) continue; interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27424,7 +27711,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { var distSq = _ray$1.distanceSqToSegment( vStart, vEnd, interRay, interSegment ); - if ( distSq > localPrecisionSq ) continue; + if ( distSq > localThresholdSq ) continue; interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27458,7 +27745,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { var distSq = _ray$1.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment ); - if ( distSq > localPrecisionSq ) continue; + if ( distSq > localThresholdSq ) continue; interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation @@ -27666,7 +27953,7 @@ function Points( geometry, material ) { this.type = 'Points'; this.geometry = geometry !== undefined ? geometry : new BufferGeometry(); - this.material = material !== undefined ? material : new PointsMaterial( { color: Math.random() * 0xffffff } ); + this.material = material !== undefined ? material : new PointsMaterial(); this.updateMorphTargets(); @@ -28125,7 +28412,7 @@ WireframeGeometry.prototype.constructor = WireframeGeometry; * @author Mugen87 / https://github.com/Mugen87 * * Parametric Surfaces Geometry - * based on the brilliant article by @prideout http://prideout.net/blog/?p=44 + * based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html */ // ParametricGeometry @@ -29407,7 +29694,7 @@ TorusBufferGeometry.prototype.constructor = TorusBufferGeometry; /** * @author Mugen87 / https://github.com/Mugen87 - * Port from https://github.com/mapbox/earcut (v2.1.5) + * Port from https://github.com/mapbox/earcut (v2.2.2) */ var Earcut = { @@ -29563,7 +29850,7 @@ function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) { } else if ( pass === 1 ) { - ear = cureLocalIntersections( ear, triangles, dim ); + ear = cureLocalIntersections( filterPoints( ear ), triangles, dim ); earcutLinked( ear, triangles, dim, minX, minY, invSize, 2 ); // as a last resort, try splitting the remaining polygon into two @@ -29693,7 +29980,7 @@ function cureLocalIntersections( start, triangles, dim ) { } while ( p !== start ); - return p; + return filterPoints( p ); } @@ -29776,6 +30063,9 @@ function eliminateHole( hole, outerNode ) { if ( outerNode ) { var b = splitPolygon( outerNode, hole ); + + // filter collinear points around the cuts + filterPoints( outerNode, outerNode.next ); filterPoints( b, b.next ); } @@ -29820,7 +30110,7 @@ function findHoleBridge( hole, outerNode ) { if ( ! m ) return null; - if ( hx === qx ) return m.prev; // hole touches outer segment; pick lower endpoint + if ( hx === qx ) return m; // hole touches outer segment; pick leftmost endpoint // look for points inside the triangle of hole point, segment intersection and endpoint; // if there are no points found, we have a valid connection; @@ -29832,16 +30122,16 @@ function findHoleBridge( hole, outerNode ) { tanMin = Infinity, tan; - p = m.next; + p = m; - while ( p !== stop ) { + do { if ( hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) { tan = Math.abs( hy - p.y ) / ( hx - p.x ); // tangential - if ( ( tan < tanMin || ( tan === tanMin && p.x > m.x ) ) && locallyInside( p, hole ) ) { + if ( locallyInside( p, hole ) && ( tan < tanMin || ( tan === tanMin && ( p.x > m.x || ( p.x === m.x && sectorContainsSector( m, p ) ) ) ) ) ) { m = p; tanMin = tan; @@ -29852,12 +30142,19 @@ function findHoleBridge( hole, outerNode ) { p = p.next; - } + } while ( p !== stop ); return m; } +// whether sector in vertex m contains sector in vertex p in the same coordinates +function sectorContainsSector( m, p ) { + + return area( m.prev, m, p.prev ) < 0 && area( p.next, m, m.next ) < 0; + +} + // interlink polygon nodes in z-order function indexCurve( start, minX, minY, invSize ) { @@ -29985,16 +30282,18 @@ function getLeftmost( start ) { function pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) { return ( cx - px ) * ( ay - py ) - ( ax - px ) * ( cy - py ) >= 0 && - ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 && - ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0; + ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 && + ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0; } // check if a diagonal between two polygon nodes is valid (lies in polygon interior) function isValidDiagonal( a, b ) { - return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && - locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ); + return a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) && // dones't intersect other edges + ( locallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b ) && // locally visible + ( area( a.prev, a, b.prev ) || area( a, b.prev, b ) ) || // does not create opposite-facing sectors + equals( a, b ) && area( a.prev, a, a.next ) > 0 && area( b.prev, b, b.next ) > 0 ); // special zero-length case } @@ -30015,10 +30314,32 @@ function equals( p1, p2 ) { // check if two segments intersect function intersects( p1, q1, p2, q2 ) { - if ( ( equals( p1, p2 ) && equals( q1, q2 ) ) || - ( equals( p1, q2 ) && equals( p2, q1 ) ) ) return true; - return area( p1, q1, p2 ) > 0 !== area( p1, q1, q2 ) > 0 && - area( p2, q2, p1 ) > 0 !== area( p2, q2, q1 ) > 0; + var o1 = sign( area( p1, q1, p2 ) ); + var o2 = sign( area( p1, q1, q2 ) ); + var o3 = sign( area( p2, q2, p1 ) ); + var o4 = sign( area( p2, q2, q1 ) ); + + if ( o1 !== o2 && o3 !== o4 ) return true; // general case + + if ( o1 === 0 && onSegment( p1, p2, q1 ) ) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1 + if ( o2 === 0 && onSegment( p1, q2, q1 ) ) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1 + if ( o3 === 0 && onSegment( p2, p1, q2 ) ) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2 + if ( o4 === 0 && onSegment( p2, q1, q2 ) ) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2 + + return false; + +} + +// for collinear points p, q, r, check if point q lies on segment pr +function onSegment( p, q, r ) { + + return q.x <= Math.max( p.x, r.x ) && q.x >= Math.min( p.x, r.x ) && q.y <= Math.max( p.y, r.y ) && q.y >= Math.min( p.y, r.y ); + +} + +function sign( num ) { + + return num > 0 ? 1 : num < 0 ? - 1 : 0; } @@ -31513,7 +31834,7 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) { // clamp phiLength so it's in range of [ 0, 2PI ] - phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 ); + phiLength = MathUtils.clamp( phiLength, 0, Math.PI * 2 ); // buffers @@ -31876,7 +32197,7 @@ function EdgesGeometry( geometry, thresholdAngle ) { // helper variables - var thresholdDot = Math.cos( _Math.DEG2RAD * thresholdAngle ); + var thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle ); var edge = [ 0, 0 ], edges = {}, edge1, edge2; var key, keys = [ 'a', 'b', 'c' ]; @@ -32430,8 +32751,6 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) { CircleBufferGeometry.prototype = Object.create( BufferGeometry.prototype ); CircleBufferGeometry.prototype.constructor = CircleBufferGeometry; - - var Geometries = /*#__PURE__*/Object.freeze({ __proto__: null, WireframeGeometry: WireframeGeometry, @@ -32638,6 +32957,8 @@ function MeshStandardMaterial( parameters ) { this.morphTargets = false; this.morphNormals = false; + this.vertexTangents = false; + this.setValues( parameters ); } @@ -32700,6 +33021,8 @@ MeshStandardMaterial.prototype.copy = function ( source ) { this.morphTargets = source.morphTargets; this.morphNormals = source.morphNormals; + this.vertexTangents = source.vertexTangents; + return this; }; @@ -32708,14 +33031,18 @@ MeshStandardMaterial.prototype.copy = function ( source ) { * @author WestLangley / http://github.com/WestLangley * * parameters = { - * reflectivity: - * clearcoat: - * clearcoatRoughness: - * - * sheen: - * + * clearcoat: , + * clearcoatMap: new THREE.Texture( ), + * clearcoatRoughness: , + * clearcoatRoughnessMap: new THREE.Texture( ), * clearcoatNormalScale: , * clearcoatNormalMap: new THREE.Texture( ), + * + * reflectivity: , + * + * sheen: , + * + * transparency: * } */ @@ -32732,16 +33059,17 @@ function MeshPhysicalMaterial( parameters ) { this.type = 'MeshPhysicalMaterial'; - this.reflectivity = 0.5; // maps to F0 = 0.04 - this.clearcoat = 0.0; + this.clearcoatMap = null; this.clearcoatRoughness = 0.0; - - this.sheen = null; // null will disable sheen bsdf - + this.clearcoatRoughnessMap = null; this.clearcoatNormalScale = new Vector2( 1, 1 ); this.clearcoatNormalMap = null; + this.reflectivity = 0.5; // maps to F0 = 0.04 + + this.sheen = null; // null will disable sheen bsdf + this.transparency = 0.0; this.setValues( parameters ); @@ -32764,17 +33092,25 @@ MeshPhysicalMaterial.prototype.copy = function ( source ) { }; - this.reflectivity = source.reflectivity; - this.clearcoat = source.clearcoat; + this.clearcoatMap = source.clearcoatMap; this.clearcoatRoughness = source.clearcoatRoughness; - - if ( source.sheen ) this.sheen = ( this.sheen || new Color() ).copy( source.sheen ); - else this.sheen = null; - + this.clearcoatRoughnessMap = source.clearcoatRoughnessMap; this.clearcoatNormalMap = source.clearcoatNormalMap; this.clearcoatNormalScale.copy( source.clearcoatNormalScale ); + this.reflectivity = source.reflectivity; + + if ( source.sheen ) { + + this.sheen = ( this.sheen || new Color() ).copy( source.sheen ); + + } else { + + this.sheen = null; + + } + this.transparency = source.transparency; return this; @@ -33459,8 +33795,6 @@ LineDashedMaterial.prototype.copy = function ( source ) { }; - - var Materials = /*#__PURE__*/Object.freeze({ __proto__: null, ShadowMaterial: ShadowMaterial, @@ -33716,6 +34050,112 @@ var AnimationUtils = { return clip; + }, + + makeClipAdditive: function ( targetClip, referenceFrame, referenceClip, fps ) { + + if ( referenceFrame === undefined ) referenceFrame = 0; + if ( referenceClip === undefined ) referenceClip = targetClip; + if ( fps === undefined || fps <= 0 ) fps = 30; + + var numTracks = targetClip.tracks.length; + var referenceTime = referenceFrame / fps; + + // Make each track's values relative to the values at the reference frame + for ( var i = 0; i < numTracks; ++ i ) { + + var referenceTrack = referenceClip.tracks[ i ]; + var referenceTrackType = referenceTrack.ValueTypeName; + + // Skip this track if it's non-numeric + if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) continue; + + // Find the track in the target clip whose name and type matches the reference track + var targetTrack = targetClip.tracks.find( function ( track ) { + + return track.name === referenceTrack.name + && track.ValueTypeName === referenceTrackType; + + } ); + + if ( targetTrack === undefined ) continue; + + var valueSize = referenceTrack.getValueSize(); + var lastIndex = referenceTrack.times.length - 1; + var referenceValue; + + // Find the value to subtract out of the track + if ( referenceTime <= referenceTrack.times[ 0 ] ) { + + // Reference frame is earlier than the first keyframe, so just use the first keyframe + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, 0, referenceTrack.valueSize ); + + } else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { + + // Reference frame is after the last keyframe, so just use the last keyframe + var startIndex = lastIndex * valueSize; + referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex ); + + } else { + + // Interpolate to the reference value + var interpolant = referenceTrack.createInterpolant(); + interpolant.evaluate( referenceTime ); + referenceValue = interpolant.resultBuffer; + + } + + // Conjugate the quaternion + if ( referenceTrackType === 'quaternion' ) { + + var referenceQuat = new Quaternion( + referenceValue[ 0 ], + referenceValue[ 1 ], + referenceValue[ 2 ], + referenceValue[ 3 ] + ).normalize().conjugate(); + referenceQuat.toArray( referenceValue ); + + } + + // Subtract the reference value from all of the track values + + var numTimes = targetTrack.times.length; + for ( var j = 0; j < numTimes; ++ j ) { + + var valueStart = j * valueSize; + + if ( referenceTrackType === 'quaternion' ) { + + // Multiply the conjugate for quaternion track types + Quaternion.multiplyQuaternionsFlat( + targetTrack.values, + valueStart, + referenceValue, + 0, + targetTrack.values, + valueStart + ); + + } else { + + // Subtract each value for all other numeric track types + for ( var k = 0; k < valueSize; ++ k ) { + + targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; + + } + + } + + } + + } + + targetClip.blendMode = AdditiveAnimationBlendMode; + + return targetClip; + } }; @@ -33966,7 +34406,7 @@ Object.assign( Interpolant.prototype, { } ); -//!\ DECLARE ALIAS AFTER assign prototype ! +// DECLARE ALIAS AFTER assign prototype Object.assign( Interpolant.prototype, { //( 0, t, t0 ), returns this.resultBuffer @@ -34439,7 +34879,12 @@ Object.assign( KeyframeTrack.prototype, { if ( from !== 0 || to !== nKeys ) { // empty tracks are forbidden, so keep at least one keyframe - if ( from >= to ) to = Math.max( to, 1 ), from = to - 1; + if ( from >= to ) { + + to = Math.max( to, 1 ); + from = to - 1; + + } var stride = this.getValueSize(); this.times = AnimationUtils.arraySlice( times, from, to ); @@ -34532,8 +34977,9 @@ Object.assign( KeyframeTrack.prototype, { // (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0) optimize: function () { - var times = this.times, - values = this.values, + // times or values may be shared with other tracks, so overwriting is unsafe + var times = AnimationUtils.arraySlice( this.times ), + values = AnimationUtils.arraySlice( this.values ), stride = this.getValueSize(), smoothInterpolation = this.getInterpolation() === InterpolateSmooth, @@ -34628,6 +35074,11 @@ Object.assign( KeyframeTrack.prototype, { this.times = AnimationUtils.arraySlice( times, 0, writeIndex ); this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride ); + } else { + + this.times = times; + this.values = values; + } return this; @@ -34883,13 +35334,14 @@ VectorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prot * @author David Sarno / http://lighthaus.us/ */ -function AnimationClip( name, duration, tracks ) { +function AnimationClip( name, duration, tracks, blendMode ) { this.name = name; this.tracks = tracks; this.duration = ( duration !== undefined ) ? duration : - 1; + this.blendMode = ( blendMode !== undefined ) ? blendMode : NormalAnimationBlendMode; - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); // this means it should figure out its duration by scanning the tracks if ( this.duration < 0 ) { @@ -34991,7 +35443,7 @@ Object.assign( AnimationClip, { } - return new AnimationClip( json.name, json.duration, tracks ); + return new AnimationClip( json.name, json.duration, tracks, json.blendMode ); }, @@ -35005,7 +35457,8 @@ Object.assign( AnimationClip, { 'name': clip.name, 'duration': clip.duration, 'tracks': tracks, - 'uuid': clip.uuid + 'uuid': clip.uuid, + 'blendMode': clip.blendMode }; @@ -35167,6 +35620,7 @@ Object.assign( AnimationClip, { // automatic length determination in AnimationClip. var duration = animation.length || - 1; var fps = animation.fps || 30; + var blendMode = animation.blendMode; var hierarchyTracks = animation.hierarchy || []; @@ -35248,7 +35702,7 @@ Object.assign( AnimationClip, { } - var clip = new AnimationClip( clipName, duration, tracks ); + var clip = new AnimationClip( clipName, duration, tracks, blendMode ); return clip; @@ -35324,7 +35778,7 @@ Object.assign( AnimationClip.prototype, { } - return new AnimationClip( this.name, this.duration, tracks ); + return new AnimationClip( this.name, this.duration, tracks, this.blendMode ); } @@ -35533,6 +35987,18 @@ Object.assign( Loader.prototype, { load: function ( /* url, onLoad, onProgress, onError */ ) {}, + loadAsync: function ( url, onProgress ) { + + var scope = this; + + return new Promise( function ( resolve, reject ) { + + scope.load( url, resolve, onProgress, reject ); + + } ); + + }, + parse: function ( /* data */ ) {}, setCrossOrigin: function ( crossOrigin ) { @@ -36101,6 +36567,7 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), texture.format = texData.format; } + if ( texData.type !== undefined ) { texture.type = texData.type; @@ -36327,8 +36794,8 @@ TextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), { * Extensible curve object * * Some common of curve methods: - * .getPoint( t, optionalTarget ), .getTangent( t ) - * .getPointAt( u, optionalTarget ), .getTangentAt( u ) + * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget ) + * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget ) * .getPoints(), .getSpacedPoints() * .getLength() * .updateArcLengths() @@ -36557,7 +37024,7 @@ Object.assign( Curve.prototype, { // 2 points a small delta apart will be used to find its gradient // which seems to give a reasonable approximation - getTangent: function ( t ) { + getTangent: function ( t, optionalTarget ) { var delta = 0.0001; var t1 = t - delta; @@ -36571,15 +37038,18 @@ Object.assign( Curve.prototype, { var pt1 = this.getPoint( t1 ); var pt2 = this.getPoint( t2 ); - var vec = pt2.clone().sub( pt1 ); - return vec.normalize(); + var tangent = optionalTarget || ( ( pt1.isVector2 ) ? new Vector2() : new Vector3() ); + + tangent.copy( pt2 ).sub( pt1 ).normalize(); + + return tangent; }, - getTangentAt: function ( u ) { + getTangentAt: function ( u, optionalTarget ) { var t = this.getUtoTmapping( u ); - return this.getTangent( t ); + return this.getTangent( t, optionalTarget ); }, @@ -36604,7 +37074,7 @@ Object.assign( Curve.prototype, { u = i / segments; - tangents[ i ] = this.getTangentAt( u ); + tangents[ i ] = this.getTangentAt( u, new Vector3() ); tangents[ i ].normalize(); } @@ -36659,7 +37129,7 @@ Object.assign( Curve.prototype, { vec.normalize(); - theta = Math.acos( _Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors + theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) ); @@ -36673,7 +37143,7 @@ Object.assign( Curve.prototype, { if ( closed === true ) { - theta = Math.acos( _Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) ); + theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) ); theta /= segments; if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) { @@ -37424,11 +37894,13 @@ LineCurve.prototype.getPointAt = function ( u, optionalTarget ) { }; -LineCurve.prototype.getTangent = function ( /* t */ ) { +LineCurve.prototype.getTangent = function ( t, optionalTarget ) { + + var tangent = optionalTarget || new Vector2(); - var tangent = this.v2.clone().sub( this.v1 ); + var tangent = tangent.copy( this.v2 ).sub( this.v1 ).normalize(); - return tangent.normalize(); + return tangent; }; @@ -37769,8 +38241,6 @@ SplineCurve.prototype.fromJSON = function ( json ) { }; - - var Curves = /*#__PURE__*/Object.freeze({ __proto__: null, ArcCurve: ArcCurve, @@ -38249,7 +38719,7 @@ function Shape( points ) { Path.call( this, points ); - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); this.type = 'Shape'; @@ -38504,7 +38974,7 @@ Object.assign( LightShadow.prototype, { shadowCamera.updateMatrixWorld(); projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse ); - this._frustum.setFromMatrix( projScreenMatrix ); + this._frustum.setFromProjectionMatrix( projScreenMatrix ); shadowMatrix.set( 0.5, 0.0, 0.0, 0.5, @@ -38586,7 +39056,7 @@ SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype var camera = this.camera; - var fov = _Math.RAD2DEG * 2 * light.angle; + var fov = MathUtils.RAD2DEG * 2 * light.angle; var aspect = this.mapSize.width / this.mapSize.height; var far = light.distance || camera.far; @@ -38747,7 +39217,7 @@ PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype shadowMatrix.makeTranslation( - lightPositionWorld.x, - lightPositionWorld.y, - lightPositionWorld.z ); projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); - this._frustum.setFromMatrix( projScreenMatrix ); + this._frustum.setFromProjectionMatrix( projScreenMatrix ); } @@ -38913,15 +39383,13 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), if ( this.view !== null && this.view.enabled ) { - var zoomW = this.zoom / ( this.view.width / this.view.fullWidth ); - var zoomH = this.zoom / ( this.view.height / this.view.fullHeight ); - var scaleW = ( this.right - this.left ) / this.view.width; - var scaleH = ( this.top - this.bottom ) / this.view.height; + var scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom; + var scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom; - left += scaleW * ( this.view.offsetX / zoomW ); - right = left + scaleW * ( this.view.width / zoomW ); - top -= scaleH * ( this.view.offsetY / zoomH ); - bottom = top - scaleH * ( this.view.height / zoomH ); + left += scaleW * this.view.offsetX; + right = left + scaleW * this.view.width; + top -= scaleH * this.view.offsetY; + bottom = top - scaleH * this.view.height; } @@ -39082,6 +39550,311 @@ RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), { } ); +/** + * @author bhouston / http://clara.io + * @author WestLangley / http://github.com/WestLangley + * + * Primary reference: + * https://graphics.stanford.edu/papers/envmap/envmap.pdf + * + * Secondary reference: + * https://www.ppsloan.org/publications/StupidSH36.pdf + */ + +// 3-band SH defined by 9 coefficients + +function SphericalHarmonics3() { + + this.coefficients = []; + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients.push( new Vector3() ); + + } + +} + +Object.assign( SphericalHarmonics3.prototype, { + + isSphericalHarmonics3: true, + + set: function ( coefficients ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].copy( coefficients[ i ] ); + + } + + return this; + + }, + + zero: function () { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].set( 0, 0, 0 ); + + } + + return this; + + }, + + // get the radiance in the direction of the normal + // target is a Vector3 + getAt: function ( normal, target ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + var coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.282095 ); + + // band 1 + target.addScaledVector( coeff[ 1 ], 0.488603 * y ); + target.addScaledVector( coeff[ 2 ], 0.488603 * z ); + target.addScaledVector( coeff[ 3 ], 0.488603 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 1.092548 * ( x * y ) ); + target.addScaledVector( coeff[ 5 ], 1.092548 * ( y * z ) ); + target.addScaledVector( coeff[ 6 ], 0.315392 * ( 3.0 * z * z - 1.0 ) ); + target.addScaledVector( coeff[ 7 ], 1.092548 * ( x * z ) ); + target.addScaledVector( coeff[ 8 ], 0.546274 * ( x * x - y * y ) ); + + return target; + + }, + + // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal + // target is a Vector3 + // https://graphics.stanford.edu/papers/envmap/envmap.pdf + getIrradianceAt: function ( normal, target ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + var coeff = this.coefficients; + + // band 0 + target.copy( coeff[ 0 ] ).multiplyScalar( 0.886227 ); // π * 0.282095 + + // band 1 + target.addScaledVector( coeff[ 1 ], 2.0 * 0.511664 * y ); // ( 2 * π / 3 ) * 0.488603 + target.addScaledVector( coeff[ 2 ], 2.0 * 0.511664 * z ); + target.addScaledVector( coeff[ 3 ], 2.0 * 0.511664 * x ); + + // band 2 + target.addScaledVector( coeff[ 4 ], 2.0 * 0.429043 * x * y ); // ( π / 4 ) * 1.092548 + target.addScaledVector( coeff[ 5 ], 2.0 * 0.429043 * y * z ); + target.addScaledVector( coeff[ 6 ], 0.743125 * z * z - 0.247708 ); // ( π / 4 ) * 0.315392 * 3 + target.addScaledVector( coeff[ 7 ], 2.0 * 0.429043 * x * z ); + target.addScaledVector( coeff[ 8 ], 0.429043 * ( x * x - y * y ) ); // ( π / 4 ) * 0.546274 + + return target; + + }, + + add: function ( sh ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].add( sh.coefficients[ i ] ); + + } + + return this; + + }, + + addScaledSH: function ( sh, s ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].addScaledVector( sh.coefficients[ i ], s ); + + } + + return this; + + }, + + scale: function ( s ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].multiplyScalar( s ); + + } + + return this; + + }, + + lerp: function ( sh, alpha ) { + + for ( var i = 0; i < 9; i ++ ) { + + this.coefficients[ i ].lerp( sh.coefficients[ i ], alpha ); + + } + + return this; + + }, + + equals: function ( sh ) { + + for ( var i = 0; i < 9; i ++ ) { + + if ( ! this.coefficients[ i ].equals( sh.coefficients[ i ] ) ) { + + return false; + + } + + } + + return true; + + }, + + copy: function ( sh ) { + + return this.set( sh.coefficients ); + + }, + + clone: function () { + + return new this.constructor().copy( this ); + + }, + + fromArray: function ( array, offset ) { + + if ( offset === undefined ) offset = 0; + + var coefficients = this.coefficients; + + for ( var i = 0; i < 9; i ++ ) { + + coefficients[ i ].fromArray( array, offset + ( i * 3 ) ); + + } + + return this; + + }, + + toArray: function ( array, offset ) { + + if ( array === undefined ) array = []; + if ( offset === undefined ) offset = 0; + + var coefficients = this.coefficients; + + for ( var i = 0; i < 9; i ++ ) { + + coefficients[ i ].toArray( array, offset + ( i * 3 ) ); + + } + + return array; + + } + +} ); + +Object.assign( SphericalHarmonics3, { + + // evaluate the basis functions + // shBasis is an Array[ 9 ] + getBasisAt: function ( normal, shBasis ) { + + // normal is assumed to be unit length + + var x = normal.x, y = normal.y, z = normal.z; + + // band 0 + shBasis[ 0 ] = 0.282095; + + // band 1 + shBasis[ 1 ] = 0.488603 * y; + shBasis[ 2 ] = 0.488603 * z; + shBasis[ 3 ] = 0.488603 * x; + + // band 2 + shBasis[ 4 ] = 1.092548 * x * y; + shBasis[ 5 ] = 1.092548 * y * z; + shBasis[ 6 ] = 0.315392 * ( 3 * z * z - 1 ); + shBasis[ 7 ] = 1.092548 * x * z; + shBasis[ 8 ] = 0.546274 * ( x * x - y * y ); + + } + +} ); + +/** + * @author WestLangley / http://github.com/WestLangley + * + * A LightProbe is a source of indirect-diffuse light + */ + +function LightProbe( sh, intensity ) { + + Light.call( this, undefined, intensity ); + + this.type = 'LightProbe'; + + this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3(); + +} + +LightProbe.prototype = Object.assign( Object.create( Light.prototype ), { + + constructor: LightProbe, + + isLightProbe: true, + + copy: function ( source ) { + + Light.prototype.copy.call( this, source ); + + this.sh.copy( source.sh ); + + return this; + + }, + + fromJSON: function ( json ) { + + this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); + this.sh.fromArray( json.sh ); + + return this; + + }, + + toJSON: function ( meta ) { + + var data = Light.prototype.toJSON.call( this, meta ); + + data.object.sh = this.sh.toArray(); + + return data; + + } + +} ); + /** * @author mrdoob / http://mrdoob.com/ */ @@ -39141,7 +39914,6 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { if ( json.shininess !== undefined ) material.shininess = json.shininess; if ( json.clearcoat !== undefined ) material.clearcoat = json.clearcoat; if ( json.clearcoatRoughness !== undefined ) material.clearcoatRoughness = json.clearcoatRoughness; - if ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors; if ( json.fog !== undefined ) material.fog = json.fog; if ( json.flatShading !== undefined ) material.flatShading = json.flatShading; if ( json.blending !== undefined ) material.blending = json.blending; @@ -39184,12 +39956,28 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { if ( json.morphNormals !== undefined ) material.morphNormals = json.morphNormals; if ( json.dithering !== undefined ) material.dithering = json.dithering; + if ( json.vertexTangents !== undefined ) material.vertexTangents = json.vertexTangents; + if ( json.visible !== undefined ) material.visible = json.visible; if ( json.toneMapped !== undefined ) material.toneMapped = json.toneMapped; if ( json.userData !== undefined ) material.userData = json.userData; + if ( json.vertexColors !== undefined ) { + + if ( typeof json.vertexColors === 'number' ) { + + material.vertexColors = ( json.vertexColors > 0 ) ? true : false; + + } else { + + material.vertexColors = json.vertexColors; + + } + + } + // Shader Material if ( json.uniforms !== undefined ) { @@ -39266,12 +40054,7 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { if ( json.map !== undefined ) material.map = getTexture( json.map ); if ( json.matcap !== undefined ) material.matcap = getTexture( json.matcap ); - if ( json.alphaMap !== undefined ) { - - material.alphaMap = getTexture( json.alphaMap ); - material.transparent = true; - - } + if ( json.alphaMap !== undefined ) material.alphaMap = getTexture( json.alphaMap ); if ( json.bumpMap !== undefined ) material.bumpMap = getTexture( json.bumpMap ); if ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale; @@ -39320,6 +40103,8 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), { if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + if ( json.clearcoatMap !== undefined ) material.clearcoatMap = getTexture( json.clearcoatMap ); + if ( json.clearcoatRoughnessMap !== undefined ) material.clearcoatRoughnessMap = getTexture( json.clearcoatRoughnessMap ); if ( json.clearcoatNormalMap !== undefined ) material.clearcoatNormalMap = getTexture( json.clearcoatNormalMap ); if ( json.clearcoatNormalScale !== undefined ) material.clearcoatNormalScale = new Vector2().fromArray( json.clearcoatNormalScale ); @@ -39992,17 +40777,7 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), { case 'Geometry': - if ( 'THREE' in window && 'LegacyJSONLoader' in THREE ) { - - var geometryLoader = new THREE.LegacyJSONLoader(); - geometry = geometryLoader.parse( data, this.resourcePath ).geometry; - - - } else { - - console.error( 'THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".' ); - - } + console.error( 'THREE.ObjectLoader: Loading "Geometry" is not supported anymore.' ); break; @@ -40401,6 +41176,12 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), { break; + case 'LightProbe': + + object = new LightProbe().fromJSON( data ); + + break; + case 'SkinnedMesh': console.warn( 'THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.' ); @@ -40410,15 +41191,7 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), { var geometry = getGeometry( data.geometry ); var material = getMaterial( data.material ); - if ( geometry.bones && geometry.bones.length > 0 ) { - - object = new SkinnedMesh( geometry, material ); - - } else { - - object = new Mesh( geometry, material ); - - } + object = new Mesh( geometry, material ); break; @@ -40798,6 +41571,7 @@ Object.assign( ShapePath.prototype, { edgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy; } + if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue; if ( inPt.y === edgeLowPt.y ) { @@ -40937,6 +41711,7 @@ Object.assign( ShapePath.prototype, { } } + if ( hole_unassigned ) { betterShapeHoles[ sIdx ].push( ho ); @@ -40947,6 +41722,7 @@ Object.assign( ShapePath.prototype, { } // console.log("ambiguous: ", ambiguous); + if ( toChange.length > 0 ) { // console.log("to change: ", toChange); @@ -41019,7 +41795,7 @@ Object.assign( Font.prototype, { function createPaths( text, size, data ) { - var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988 + var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // workaround for IE11, see #13988 var scale = size / data.resolution; var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale; @@ -41245,290 +42021,6 @@ AudioLoader.prototype = Object.assign( Object.create( Loader.prototype ), { } ); -/** - * @author bhouston / http://clara.io - * @author WestLangley / http://github.com/WestLangley - * - * Primary reference: - * https://graphics.stanford.edu/papers/envmap/envmap.pdf - * - * Secondary reference: - * https://www.ppsloan.org/publications/StupidSH36.pdf - */ - -// 3-band SH defined by 9 coefficients - -function SphericalHarmonics3() { - - this.coefficients = []; - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients.push( new Vector3() ); - - } - -} - -Object.assign( SphericalHarmonics3.prototype, { - - isSphericalHarmonics3: true, - - set: function ( coefficients ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].copy( coefficients[ i ] ); - - } - - return this; - - }, - - zero: function () { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].set( 0, 0, 0 ); - - } - - return this; - - }, - - // get the radiance in the direction of the normal - // target is a Vector3 - getAt: function ( normal, target ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - var coeff = this.coefficients; - - // band 0 - target.copy( coeff[ 0 ] ).multiplyScalar( 0.282095 ); - - // band 1 - target.addScale( coeff[ 1 ], 0.488603 * y ); - target.addScale( coeff[ 2 ], 0.488603 * z ); - target.addScale( coeff[ 3 ], 0.488603 * x ); - - // band 2 - target.addScale( coeff[ 4 ], 1.092548 * ( x * y ) ); - target.addScale( coeff[ 5 ], 1.092548 * ( y * z ) ); - target.addScale( coeff[ 6 ], 0.315392 * ( 3.0 * z * z - 1.0 ) ); - target.addScale( coeff[ 7 ], 1.092548 * ( x * z ) ); - target.addScale( coeff[ 8 ], 0.546274 * ( x * x - y * y ) ); - - return target; - - }, - - // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal - // target is a Vector3 - // https://graphics.stanford.edu/papers/envmap/envmap.pdf - getIrradianceAt: function ( normal, target ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - var coeff = this.coefficients; - - // band 0 - target.copy( coeff[ 0 ] ).multiplyScalar( 0.886227 ); // π * 0.282095 - - // band 1 - target.addScale( coeff[ 1 ], 2.0 * 0.511664 * y ); // ( 2 * π / 3 ) * 0.488603 - target.addScale( coeff[ 2 ], 2.0 * 0.511664 * z ); - target.addScale( coeff[ 3 ], 2.0 * 0.511664 * x ); - - // band 2 - target.addScale( coeff[ 4 ], 2.0 * 0.429043 * x * y ); // ( π / 4 ) * 1.092548 - target.addScale( coeff[ 5 ], 2.0 * 0.429043 * y * z ); - target.addScale( coeff[ 6 ], 0.743125 * z * z - 0.247708 ); // ( π / 4 ) * 0.315392 * 3 - target.addScale( coeff[ 7 ], 2.0 * 0.429043 * x * z ); - target.addScale( coeff[ 8 ], 0.429043 * ( x * x - y * y ) ); // ( π / 4 ) * 0.546274 - - return target; - - }, - - add: function ( sh ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].add( sh.coefficients[ i ] ); - - } - - return this; - - }, - - - scale: function ( s ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].multiplyScalar( s ); - - } - - return this; - - }, - - lerp: function ( sh, alpha ) { - - for ( var i = 0; i < 9; i ++ ) { - - this.coefficients[ i ].lerp( sh.coefficients[ i ], alpha ); - - } - - return this; - - }, - - equals: function ( sh ) { - - for ( var i = 0; i < 9; i ++ ) { - - if ( ! this.coefficients[ i ].equals( sh.coefficients[ i ] ) ) { - - return false; - - } - - } - - return true; - - }, - - copy: function ( sh ) { - - return this.set( sh.coefficients ); - - }, - - clone: function () { - - return new this.constructor().copy( this ); - - }, - - fromArray: function ( array, offset ) { - - if ( offset === undefined ) offset = 0; - - var coefficients = this.coefficients; - - for ( var i = 0; i < 9; i ++ ) { - - coefficients[ i ].fromArray( array, offset + ( i * 3 ) ); - - } - - return this; - - }, - - toArray: function ( array, offset ) { - - if ( array === undefined ) array = []; - if ( offset === undefined ) offset = 0; - - var coefficients = this.coefficients; - - for ( var i = 0; i < 9; i ++ ) { - - coefficients[ i ].toArray( array, offset + ( i * 3 ) ); - - } - - return array; - - } - -} ); - -Object.assign( SphericalHarmonics3, { - - // evaluate the basis functions - // shBasis is an Array[ 9 ] - getBasisAt: function ( normal, shBasis ) { - - // normal is assumed to be unit length - - var x = normal.x, y = normal.y, z = normal.z; - - // band 0 - shBasis[ 0 ] = 0.282095; - - // band 1 - shBasis[ 1 ] = 0.488603 * y; - shBasis[ 2 ] = 0.488603 * z; - shBasis[ 3 ] = 0.488603 * x; - - // band 2 - shBasis[ 4 ] = 1.092548 * x * y; - shBasis[ 5 ] = 1.092548 * y * z; - shBasis[ 6 ] = 0.315392 * ( 3 * z * z - 1 ); - shBasis[ 7 ] = 1.092548 * x * z; - shBasis[ 8 ] = 0.546274 * ( x * x - y * y ); - - } - -} ); - -/** - * @author WestLangley / http://github.com/WestLangley - * - * A LightProbe is a source of indirect-diffuse light - */ - -function LightProbe( sh, intensity ) { - - Light.call( this, undefined, intensity ); - - this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3(); - -} - -LightProbe.prototype = Object.assign( Object.create( Light.prototype ), { - - constructor: LightProbe, - - isLightProbe: true, - - copy: function ( source ) { - - Light.prototype.copy.call( this, source ); - - this.sh.copy( source.sh ); - this.intensity = source.intensity; - - return this; - - }, - - toJSON: function ( meta ) { - - var data = Light.prototype.toJSON.call( this, meta ); - - // data.sh = this.sh.toArray(); // todo - - return data; - - } - -} ); - /** * @author WestLangley / http://github.com/WestLangley */ @@ -41680,7 +42172,7 @@ Object.assign( StereoCamera.prototype, { var projectionMatrix = camera.projectionMatrix.clone(); var eyeSepHalf = cache.eyeSep / 2; var eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus; - var ymax = ( cache.near * Math.tan( _Math.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom; + var ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom; var xmin, xmax; // translate xOffset @@ -41956,7 +42448,7 @@ function Audio( listener ) { this.sourceType = 'empty'; this._startedAt = 0; - this._pausedAt = 0; + this._progress = 0; this.filters = []; @@ -42042,7 +42534,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { source.loopStart = this.loopStart; source.loopEnd = this.loopEnd; source.onended = this.onEnded.bind( this ); - source.start( this._startedAt, this._pausedAt + this.offset, this.duration ); + source.start( this._startedAt, this._progress + this.offset, this.duration ); this.isPlaying = true; @@ -42066,7 +42558,17 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( this.isPlaying === true ) { - this._pausedAt = ( this.context.currentTime - this._startedAt ) * this.playbackRate; + // update current progress + + this._progress += Math.max( this.context.currentTime - this._startedAt, 0 ) * this.playbackRate; + + if ( this.loop === true ) { + + // ensure _progress does not exceed duration with looped audios + + this._progress = this._progress % ( this.duration || this.buffer.duration ); + + } this.source.stop(); this.source.onended = null; @@ -42088,7 +42590,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { } - this._pausedAt = 0; + this._progress = 0; this.source.stop(); this.source.onended = null; @@ -42492,41 +42994,67 @@ function PropertyMixer( binding, typeName, valueSize ) { this.binding = binding; this.valueSize = valueSize; - var bufferType = Float64Array, - mixFunction; + var mixFunction, + mixFunctionAdditive, + setIdentity; + + // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ] + // + // interpolators can use .buffer as their .result + // the data then goes to 'incoming' + // + // 'accu0' and 'accu1' are used frame-interleaved for + // the cumulative result and are compared to detect + // changes + // + // 'orig' stores the original state of the property + // + // 'add' is used for additive cumulative results + // + // 'work' is optional and is only present for quaternion types. It is used + // to store intermediate quaternion multiplication results switch ( typeName ) { case 'quaternion': mixFunction = this._slerp; + mixFunctionAdditive = this._slerpAdditive; + setIdentity = this._setAdditiveIdentityQuaternion; + + this.buffer = new Float64Array( valueSize * 6 ); + this._workIndex = 5; break; case 'string': case 'bool': - bufferType = Array; mixFunction = this._select; + + // Use the regular mix function and for additive on these types, + // additive is not relevant for non-numeric types + mixFunctionAdditive = this._select; + + setIdentity = this._setAdditiveIdentityOther; + + this.buffer = new Array( valueSize * 5 ); break; default: mixFunction = this._lerp; + mixFunctionAdditive = this._lerpAdditive; + setIdentity = this._setAdditiveIdentityNumeric; - } + this.buffer = new Float64Array( valueSize * 5 ); - this.buffer = new bufferType( valueSize * 4 ); - // layout: [ incoming | accu0 | accu1 | orig ] - // - // interpolators can use .buffer as their .result - // the data then goes to 'incoming' - // - // 'accu0' and 'accu1' are used frame-interleaved for - // the cumulative result and are compared to detect - // changes - // - // 'orig' stores the original state of the property + } this._mixBufferRegion = mixFunction; + this._mixBufferRegionAdditive = mixFunctionAdditive; + this._setIdentity = setIdentity; + this._origIndex = 3; + this._addIndex = 4; this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; this.useCount = 0; this.referenceCount = 0; @@ -42573,6 +43101,28 @@ Object.assign( PropertyMixer.prototype, { }, + // accumulate data in the 'incoming' region into 'add' + accumulateAdditive: function ( weight ) { + + var buffer = this.buffer, + stride = this.valueSize, + offset = stride * this._addIndex; + + if ( this.cumulativeWeightAdditive === 0 ) { + + // add = identity + + this._setIdentity(); + + } + + // add := add + incoming * weight + + this._mixBufferRegionAdditive( buffer, offset, 0, weight, stride ); + this.cumulativeWeightAdditive += weight; + + }, + // apply the state of 'accu' to the binding when accus differ apply: function ( accuIndex ) { @@ -42581,22 +43131,32 @@ Object.assign( PropertyMixer.prototype, { offset = accuIndex * stride + stride, weight = this.cumulativeWeight, + weightAdditive = this.cumulativeWeightAdditive, binding = this.binding; this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; if ( weight < 1 ) { // accuN := accuN + original * ( 1 - cumulativeWeight ) - var originalValueOffset = stride * 3; + var originalValueOffset = stride * this._origIndex; this._mixBufferRegion( buffer, offset, originalValueOffset, 1 - weight, stride ); } + if ( weightAdditive > 0 ) { + + // accuN := accuN + additive accuN + + this._mixBufferRegionAdditive( buffer, offset, this._addIndex * stride, 1, stride ); + + } + for ( var i = stride, e = stride + stride; i !== e; ++ i ) { if ( buffer[ i ] !== buffer[ i + stride ] ) { @@ -42620,7 +43180,7 @@ Object.assign( PropertyMixer.prototype, { var buffer = this.buffer, stride = this.valueSize, - originalValueOffset = stride * 3; + originalValueOffset = stride * this._origIndex; binding.getValue( buffer, originalValueOffset ); @@ -42631,7 +43191,11 @@ Object.assign( PropertyMixer.prototype, { } + // Add to identity for additive + this._setIdentity(); + this.cumulativeWeight = 0; + this.cumulativeWeightAdditive = 0; }, @@ -42643,6 +43207,30 @@ Object.assign( PropertyMixer.prototype, { }, + _setAdditiveIdentityNumeric: function () { + + var startIndex = this._addIndex * this.valueSize; + + this.buffer.fill( 0, startIndex, startIndex + this.valueSize ); + + }, + + _setAdditiveIdentityQuaternion: function () { + + this._setAdditiveIdentityNumeric(); + this.buffer[ this._addIndex * 4 + 3 ] = 1; + + }, + + _setAdditiveIdentityOther: function () { + + var startIndex = this._origIndex * this.valueSize; + var targetIndex = this._addIndex * this.valueSize; + + this.buffer.copyWithin( targetIndex, startIndex, this.valueSize ); + + }, + // mix functions @@ -42666,6 +43254,18 @@ Object.assign( PropertyMixer.prototype, { }, + _slerpAdditive: function ( buffer, dstOffset, srcOffset, t, stride ) { + + var workOffset = this._workIndex * stride; + + // Store result in intermediate buffer offset + Quaternion.multiplyQuaternionsFlat( buffer, workOffset, buffer, dstOffset, buffer, srcOffset ); + + // Slerp to the intermediate result + Quaternion.slerpFlat( buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t ); + + }, + _lerp: function ( buffer, dstOffset, srcOffset, t, stride ) { var s = 1 - t; @@ -42678,6 +43278,18 @@ Object.assign( PropertyMixer.prototype, { } + }, + + _lerpAdditive: function ( buffer, dstOffset, srcOffset, t, stride ) { + + for ( var i = 0; i !== stride; ++ i ) { + + var j = dstOffset + i; + + buffer[ j ] = buffer[ j ] + buffer[ srcOffset + i ] * t; + + } + } } ); @@ -42882,7 +43494,7 @@ Object.assign( PropertyBinding, { findNode: function ( root, nodeName ) { - if ( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { + if ( ! nodeName || nodeName === "" || nodeName === "." || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) { return root; @@ -43386,7 +43998,7 @@ Object.assign( PropertyBinding.prototype, { // prototype, continued } ); -//!\ DECLARE ALIAS AFTER assign prototype ! +// DECLARE ALIAS AFTER assign prototype Object.assign( PropertyBinding.prototype, { // initial state of these methods that calls 'bind' @@ -43428,7 +44040,7 @@ Object.assign( PropertyBinding.prototype, { function AnimationObjectGroup() { - this.uuid = _Math.generateUUID(); + this.uuid = MathUtils.generateUUID(); // cached objects followed by the active ones this._objects = Array.prototype.slice.call( arguments ); @@ -43782,11 +44394,12 @@ Object.assign( AnimationObjectGroup.prototype, { * */ -function AnimationAction( mixer, clip, localRoot ) { +function AnimationAction( mixer, clip, localRoot, blendMode ) { this._mixer = mixer; this._clip = clip; this._localRoot = localRoot || null; + this.blendMode = blendMode || clip.blendMode; var tracks = clip.tracks, nTracks = tracks.length, @@ -44145,10 +44758,28 @@ Object.assign( AnimationAction.prototype, { var interpolants = this._interpolants; var propertyMixers = this._propertyBindings; - for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + switch ( this.blendMode ) { + + case AdditiveAnimationBlendMode: - interpolants[ j ].evaluate( clipTime ); - propertyMixers[ j ].accumulate( accuIndex, weight ); + for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulateAdditive( weight ); + + } + + break; + + case NormalAnimationBlendMode: + default: + + for ( var j = 0, m = interpolants.length; j !== m; ++ j ) { + + interpolants[ j ].evaluate( clipTime ); + propertyMixers[ j ].accumulate( accuIndex, weight ); + + } } @@ -44966,7 +45597,7 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy // return an action for a clip optionally using a custom root target // object (this method allocates a lot of dynamic memory in case a // previously unknown clip/root combination is specified) - clipAction: function ( clip, optionalRoot ) { + clipAction: function ( clip, optionalRoot, blendMode ) { var root = optionalRoot || this._root, rootUuid = root.uuid, @@ -44979,12 +45610,26 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy actionsForClip = this._actionsByClip[ clipUuid ], prototypeAction = null; + if ( blendMode === undefined ) { + + if ( clipObject !== null ) { + + blendMode = clipObject.blendMode; + + } else { + + blendMode = NormalAnimationBlendMode; + + } + + } + if ( actionsForClip !== undefined ) { var existingAction = actionsForClip.actionByRoot[ rootUuid ]; - if ( existingAction !== undefined ) { + if ( existingAction !== undefined && existingAction.blendMode === blendMode ) { return existingAction; @@ -45004,7 +45649,7 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy if ( clipObject === null ) return null; // allocate all resources required to run it - var newAction = new AnimationAction( this, clipObject, optionalRoot ); + var newAction = new AnimationAction( this, clipObject, optionalRoot, blendMode ); this._bindAction( newAction, prototypeAction ); @@ -45286,10 +45931,11 @@ function Raycaster( origin, direction, near, far ) { this.near = near || 0; this.far = far || Infinity; this.camera = null; + this.layers = new Layers(); this.params = { Mesh: {}, - Line: {}, + Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} @@ -45316,9 +45962,11 @@ function ascSort( a, b ) { function intersectObject( object, raycaster, intersects, recursive ) { - if ( object.visible === false ) return; + if ( object.layers.test( raycaster.layers ) ) { - object.raycast( raycaster, intersects ); + object.raycast( raycaster, intersects ); + + } if ( recursive === true ) { @@ -45336,8 +45984,6 @@ function intersectObject( object, raycaster, intersects, recursive ) { Object.assign( Raycaster.prototype, { - linePrecision: 1, - set: function ( origin, direction ) { // direction is assumed to be normalized (for accurate distance calculations) @@ -45481,7 +46127,7 @@ Object.assign( Spherical.prototype, { } else { this.theta = Math.atan2( x, z ); - this.phi = Math.acos( _Math.clamp( y / this.radius, - 1, 1 ) ); + this.phi = Math.acos( MathUtils.clamp( y / this.radius, - 1, 1 ) ); } @@ -45558,7 +46204,7 @@ Object.assign( Cylindrical.prototype, { * @author bhouston / http://clara.io */ -var _vector$8 = new Vector2(); +var _vector$7 = new Vector2(); function Box2( min, max ) { @@ -45594,7 +46240,7 @@ Object.assign( Box2.prototype, { setFromCenterAndSize: function ( center, size ) { - var halfSize = _vector$8.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$7.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -45744,7 +46390,7 @@ Object.assign( Box2.prototype, { distanceToPoint: function ( point ) { - var clampedPoint = _vector$8.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$7.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); }, @@ -45887,7 +46533,7 @@ Object.assign( Line3.prototype, { if ( clampToLine ) { - t = _Math.clamp( t, 0, 1 ); + t = MathUtils.clamp( t, 0, 1 ); } @@ -45951,7 +46597,7 @@ ImmediateRenderObject.prototype.isImmediateRenderObject = true; * @author WestLangley / http://github.com/WestLangley */ -var _vector$9 = new Vector3(); +var _vector$8 = new Vector3(); function SpotLightHelper( light, color ) { @@ -45989,7 +46635,7 @@ function SpotLightHelper( light, color ) { geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); - var material = new LineBasicMaterial( { fog: false } ); + var material = new LineBasicMaterial( { fog: false, toneMapped: false } ); this.cone = new LineSegments( geometry, material ); this.add( this.cone ); @@ -46017,9 +46663,9 @@ SpotLightHelper.prototype.update = function () { this.cone.scale.set( coneWidth, coneWidth, coneLength ); - _vector$9.setFromMatrixPosition( this.light.target.matrixWorld ); + _vector$8.setFromMatrixPosition( this.light.target.matrixWorld ); - this.cone.lookAt( _vector$9 ); + this.cone.lookAt( _vector$8 ); if ( this.color !== undefined ) { @@ -46041,7 +46687,7 @@ SpotLightHelper.prototype.update = function () { * @author Mugen87 / https://github.com/Mugen87 */ -var _vector$a = new Vector3(); +var _vector$9 = new Vector3(); var _boneMatrix = new Matrix4(); var _matrixWorldInv = new Matrix4(); @@ -46095,10 +46741,12 @@ function SkeletonHelper( object ) { geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } ); + var material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } ); LineSegments.call( this, geometry, material ); + this.type = 'SkeletonHelper'; + this.root = object; this.bones = bones; @@ -46110,6 +46758,8 @@ function SkeletonHelper( object ) { SkeletonHelper.prototype = Object.create( LineSegments.prototype ); SkeletonHelper.prototype.constructor = SkeletonHelper; +SkeletonHelper.prototype.isSkeletonHelper = true; + SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { var bones = this.bones; @@ -46126,12 +46776,12 @@ SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { if ( bone.parent && bone.parent.isBone ) { _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld ); - _vector$a.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j, _vector$a.x, _vector$a.y, _vector$a.z ); + _vector$9.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j, _vector$9.x, _vector$9.y, _vector$9.z ); _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld ); - _vector$a.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j + 1, _vector$a.x, _vector$a.y, _vector$a.z ); + _vector$9.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j + 1, _vector$9.x, _vector$9.y, _vector$9.z ); j += 2; @@ -46158,10 +46808,12 @@ function PointLightHelper( light, sphereSize, color ) { this.color = color; var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); - var material = new MeshBasicMaterial( { wireframe: true, fog: false } ); + var material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); Mesh.call( this, geometry, material ); + this.type = 'PointLightHelper'; + this.matrix = this.light.matrixWorld; this.matrixAutoUpdate = false; @@ -46237,7 +46889,7 @@ PointLightHelper.prototype.update = function () { * @author Mugen87 / https://github.com/Mugen87 */ -var _vector$b = new Vector3(); +var _vector$a = new Vector3(); var _color1 = new Color(); var _color2 = new Color(); @@ -46256,8 +46908,8 @@ function HemisphereLightHelper( light, size, color ) { var geometry = new OctahedronBufferGeometry( size ); geometry.rotateY( Math.PI * 0.5 ); - this.material = new MeshBasicMaterial( { wireframe: true, fog: false } ); - if ( this.color === undefined ) this.material.vertexColors = VertexColors; + this.material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } ); + if ( this.color === undefined ) this.material.vertexColors = true; var position = geometry.getAttribute( 'position' ); var colors = new Float32Array( position.count * 3 ); @@ -46307,7 +46959,7 @@ HemisphereLightHelper.prototype.update = function () { } - mesh.lookAt( _vector$b.setFromMatrixPosition( this.light.matrixWorld ).negate() ); + mesh.lookAt( _vector$a.setFromMatrixPosition( this.light.matrixWorld ).negate() ); }; @@ -46346,10 +46998,12 @@ function GridHelper( size, divisions, color1, color2 ) { geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'GridHelper'; + } GridHelper.prototype = Object.assign( Object.create( LineSegments.prototype ), { @@ -46453,10 +47107,12 @@ function PolarGridHelper( radius, radials, circles, divisions, color1, color2 ) geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'PolarGridHelper'; + } PolarGridHelper.prototype = Object.create( LineSegments.prototype ); @@ -46495,7 +47151,7 @@ function DirectionalLightHelper( light, size, color ) { - size, size, 0 ], 3 ) ); - var material = new LineBasicMaterial( { fog: false } ); + var material = new LineBasicMaterial( { fog: false, toneMapped: false } ); this.lightPlane = new Line( geometry, material ); this.add( this.lightPlane ); @@ -46557,13 +47213,13 @@ DirectionalLightHelper.prototype.update = function () { * http://evanw.github.com/lightgl.js/tests/shadowmap.html */ -var _vector$c = new Vector3(); +var _vector$b = new Vector3(); var _camera = new Camera(); function CameraHelper( camera ) { var geometry = new BufferGeometry(); - var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } ); + var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } ); var vertices = []; var colors = []; @@ -46652,6 +47308,8 @@ function CameraHelper( camera ) { LineSegments.call( this, geometry, material ); + this.type = 'CameraHelper'; + this.camera = camera; if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); @@ -46722,7 +47380,7 @@ CameraHelper.prototype.update = function () { function setPoint( point, pointMap, geometry, camera, x, y, z ) { - _vector$c.set( x, y, z ).unproject( camera ); + _vector$b.set( x, y, z ).unproject( camera ); var points = pointMap[ point ]; @@ -46732,7 +47390,7 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) { for ( var i = 0, l = points.length; i < l; i ++ ) { - position.setXYZ( points[ i ], _vector$c.x, _vector$c.y, _vector$c.z ); + position.setXYZ( points[ i ], _vector$b.x, _vector$b.y, _vector$b.z ); } @@ -46760,7 +47418,9 @@ function BoxHelper( object, color ) { geometry.setIndex( new BufferAttribute( indices, 1 ) ); geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) ); - LineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + LineSegments.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'BoxHelper'; this.matrixAutoUpdate = false; @@ -46872,7 +47532,9 @@ function Box3Helper( box, color ) { geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); - LineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + LineSegments.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'Box3Helper'; this.geometry.computeBoundingSphere(); @@ -46903,8 +47565,6 @@ Box3Helper.prototype.updateMatrixWorld = function ( force ) { function PlaneHelper( plane, size, hex ) { - this.type = 'PlaneHelper'; - this.plane = plane; this.size = ( size === undefined ) ? 1 : size; @@ -46917,7 +47577,9 @@ function PlaneHelper( plane, size, hex ) { geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); geometry.computeBoundingSphere(); - Line.call( this, geometry, new LineBasicMaterial( { color: color } ) ); + Line.call( this, geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); + + this.type = 'PlaneHelper'; // @@ -46927,7 +47589,7 @@ function PlaneHelper( plane, size, hex ) { geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); geometry2.computeBoundingSphere(); - this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false } ) ) ); + this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false } ) ) ); } @@ -46975,6 +47637,8 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { Object3D.call( this ); + this.type = 'ArrowHelper'; + if ( dir === undefined ) dir = new Vector3( 0, 0, 1 ); if ( origin === undefined ) origin = new Vector3( 0, 0, 0 ); if ( length === undefined ) length = 1; @@ -46994,11 +47658,11 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { this.position.copy( origin ); - this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color } ) ); + this.line = new Line( _lineGeometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); this.line.matrixAutoUpdate = false; this.add( this.line ); - this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color } ) ); + this.cone = new Mesh( _coneGeometry, new MeshBasicMaterial( { color: color, toneMapped: false } ) ); this.cone.matrixAutoUpdate = false; this.add( this.cone ); @@ -47097,10 +47761,12 @@ function AxesHelper( size ) { geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); - var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); LineSegments.call( this, geometry, material ); + this.type = 'AxesHelper'; + } AxesHelper.prototype = Object.create( LineSegments.prototype ); @@ -47123,15 +47789,19 @@ AxesHelper.prototype.constructor = AxesHelper; var LOD_MIN = 4; var LOD_MAX = 8; var SIZE_MAX = Math.pow( 2, LOD_MAX ); + // The standard deviations (radians) associated with the extra mips. These are // chosen to approximate a Trowbridge-Reitz distribution function times the // geometric shadowing function. These sigma values squared must match the // variance #defines in cube_uv_reflection_fragment.glsl.js. var EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ]; + var TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; + // The maximum length of the blur for loop. Smaller sigmas will use fewer // samples and exit early, but not recompile the shader. var MAX_SAMPLES = 20; + var ENCODINGS = { [ LinearEncoding ]: 0, [ sRGBEncoding ]: 1, @@ -47143,17 +47813,13 @@ var ENCODINGS = { }; var _flatCamera = new OrthographicCamera(); -var _blurMaterial = _getBlurShader( MAX_SAMPLES ); -var _equirectShader = null; -var _cubemapShader = null; - var { _lodPlanes, _sizeLods, _sigmas } = _createPlanes(); -var _pingPongRenderTarget = null; -var _renderer = null; +var _oldTarget = null; // Golden Ratio var PHI = ( 1 + Math.sqrt( 5 ) ) / 2; var INV_PHI = 1 / PHI; + // Vertices of a dodecahedron (except the opposites, which represent the // same axis), used as axis directions evenly spread on a sphere. var _axisDirections = [ @@ -47170,8 +47836,14 @@ var _axisDirections = [ function PMREMGenerator( renderer ) { - _renderer = renderer; - _compileMaterial( _blurMaterial ); + this._renderer = renderer; + this._pingPongRenderTarget = null; + + this._blurMaterial = _getBlurShader( MAX_SAMPLES ); + this._equirectShader = null; + this._cubemapShader = null; + + this._compileMaterial( this._blurMaterial ); } @@ -47188,16 +47860,18 @@ PMREMGenerator.prototype = { */ fromScene: function ( scene, sigma = 0, near = 0.1, far = 100 ) { - var cubeUVRenderTarget = _allocateTargets(); - _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); + _oldTarget = this._renderer.getRenderTarget(); + var cubeUVRenderTarget = this._allocateTargets(); + + this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget ); if ( sigma > 0 ) { - _blur( cubeUVRenderTarget, 0, 0, sigma ); + this._blur( cubeUVRenderTarget, 0, 0, sigma ); } - _applyPMREM( cubeUVRenderTarget ); - _cleanup(); - cubeUVRenderTarget.scissorTest = false; + + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); return cubeUVRenderTarget; @@ -47225,11 +47899,11 @@ PMREMGenerator.prototype = { */ fromCubemap: function ( cubemap ) { - var cubeUVRenderTarget = _allocateTargets( cubemap ); - _textureToCubeUV( cubemap, cubeUVRenderTarget ); - _applyPMREM( cubeUVRenderTarget ); - _cleanup(); - cubeUVRenderTarget.scissorTest = false; + _oldTarget = this._renderer.getRenderTarget(); + var cubeUVRenderTarget = this._allocateTargets( cubemap ); + this._textureToCubeUV( cubemap, cubeUVRenderTarget ); + this._applyPMREM( cubeUVRenderTarget ); + this._cleanup( cubeUVRenderTarget ); return cubeUVRenderTarget; @@ -47241,10 +47915,10 @@ PMREMGenerator.prototype = { */ compileCubemapShader: function () { - if ( _cubemapShader == null ) { + if ( this._cubemapShader === null ) { - _cubemapShader = _getCubemapShader(); - _compileMaterial( _cubemapShader ); + this._cubemapShader = _getCubemapShader(); + this._compileMaterial( this._cubemapShader ); } @@ -47256,10 +47930,10 @@ PMREMGenerator.prototype = { */ compileEquirectangularShader: function () { - if ( _equirectShader == null ) { + if ( this._equirectShader === null ) { - _equirectShader = _getEquirectShader(); - _compileMaterial( _equirectShader ); + this._equirectShader = _getEquirectShader(); + this._compileMaterial( this._equirectShader ); } @@ -47272,10 +47946,10 @@ PMREMGenerator.prototype = { */ dispose: function () { - _blurMaterial.dispose(); + this._blurMaterial.dispose(); - if ( _cubemapShader != null ) _cubemapShader.dispose(); - if ( _equirectShader != null ) _equirectShader.dispose(); + if ( this._cubemapShader !== null ) this._cubemapShader.dispose(); + if ( this._equirectShader !== null ) this._equirectShader.dispose(); for ( var i = 0; i < _lodPlanes.length; i ++ ) { @@ -47285,373 +47959,399 @@ PMREMGenerator.prototype = { }, -}; + // private interface -function _createPlanes() { + _cleanup: function ( outputTarget ) { - var _lodPlanes = []; - var _sizeLods = []; - var _sigmas = []; + this._pingPongRenderTarget.dispose(); + this._renderer.setRenderTarget( _oldTarget ); + outputTarget.scissorTest = false; + // reset viewport and scissor + outputTarget.setSize( outputTarget.width, outputTarget.height ); - var lod = LOD_MAX; - for ( var i = 0; i < TOTAL_LODS; i ++ ) { + }, - var sizeLod = Math.pow( 2, lod ); - _sizeLods.push( sizeLod ); - var sigma = 1.0 / sizeLod; - if ( i > LOD_MAX - LOD_MIN ) { + _allocateTargets: function ( equirectangular ) { - sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; + var params = { + magFilter: NearestFilter, + minFilter: NearestFilter, + generateMipmaps: false, + type: UnsignedByteType, + format: RGBEFormat, + encoding: _isLDR( equirectangular ) ? equirectangular.encoding : RGBEEncoding, + depthBuffer: false, + stencilBuffer: false + }; - } else if ( i == 0 ) { + var cubeUVRenderTarget = _createRenderTarget( params ); + cubeUVRenderTarget.depthBuffer = equirectangular ? false : true; + this._pingPongRenderTarget = _createRenderTarget( params ); + return cubeUVRenderTarget; - sigma = 0; + }, - } - _sigmas.push( sigma ); + _compileMaterial: function ( material ) { - var texelSize = 1.0 / ( sizeLod - 1 ); - var min = - texelSize / 2; - var max = 1 + texelSize / 2; - var uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; + var tmpScene = new Scene(); + tmpScene.add( new Mesh( _lodPlanes[ 0 ], material ) ); + this._renderer.compile( tmpScene, _flatCamera ); - var cubeFaces = 6; - var vertices = 6; - var positionSize = 3; - var uvSize = 2; - var faceIndexSize = 1; + }, - var position = new Float32Array( positionSize * vertices * cubeFaces ); - var uv = new Float32Array( uvSize * vertices * cubeFaces ); - var faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); + _sceneToCubeUV: function ( scene, near, far, cubeUVRenderTarget ) { - for ( var face = 0; face < cubeFaces; face ++ ) { + var fov = 90; + var aspect = 1; + var cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); + var upSign = [ 1, 1, 1, 1, - 1, 1 ]; + var forwardSign = [ 1, 1, - 1, - 1, - 1, 1 ]; + var renderer = this._renderer; - var x = ( face % 3 ) * 2 / 3 - 1; - var y = face > 2 ? 0 : - 1; - var coordinates = [ - x, y, 0, - x + 2 / 3, y, 0, - x + 2 / 3, y + 1, 0, - x, y, 0, - x + 2 / 3, y + 1, 0, - x, y + 1, 0 - ]; - position.set( coordinates, positionSize * vertices * face ); - uv.set( uv1, uvSize * vertices * face ); - var fill = [ face, face, face, face, face, face ]; - faceIndex.set( fill, faceIndexSize * vertices * face ); + var outputEncoding = renderer.outputEncoding; + var toneMapping = renderer.toneMapping; + var toneMappingExposure = renderer.toneMappingExposure; + var clearColor = renderer.getClearColor(); + var clearAlpha = renderer.getClearAlpha(); + + renderer.toneMapping = LinearToneMapping; + renderer.toneMappingExposure = 1.0; + renderer.outputEncoding = LinearEncoding; + scene.scale.z *= - 1; + + var background = scene.background; + if ( background && background.isColor ) { + + background.convertSRGBToLinear(); + // Convert linear to RGBE + var maxComponent = Math.max( background.r, background.g, background.b ); + var fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 ); + background = background.multiplyScalar( Math.pow( 2.0, - fExp ) ); + var alpha = ( fExp + 128.0 ) / 255.0; + renderer.setClearColor( background, alpha ); + scene.background = null; } - var planes = new BufferGeometry(); - planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); - planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); - planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); - _lodPlanes.push( planes ); - if ( lod > LOD_MIN ) { + for ( var i = 0; i < 6; i ++ ) { - lod --; + var col = i % 3; + if ( col == 0 ) { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + + } else if ( col == 1 ) { + + cubeCamera.up.set( 0, 0, upSign[ i ] ); + cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + + } else { + + cubeCamera.up.set( 0, upSign[ i ], 0 ); + cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + + } + + _setViewport( cubeUVRenderTarget, + col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( scene, cubeCamera ); } - } - return { _lodPlanes, _sizeLods, _sigmas }; + renderer.toneMapping = toneMapping; + renderer.toneMappingExposure = toneMappingExposure; + renderer.outputEncoding = outputEncoding; + renderer.setClearColor( clearColor, clearAlpha ); + scene.scale.z *= - 1; -} + }, -function _allocateTargets( equirectangular ) { + _textureToCubeUV: function ( texture, cubeUVRenderTarget ) { - var params = { - magFilter: NearestFilter, - minFilter: NearestFilter, - generateMipmaps: false, - type: equirectangular ? equirectangular.type : UnsignedByteType, - format: equirectangular ? equirectangular.format : RGBEFormat, - encoding: equirectangular ? equirectangular.encoding : RGBEEncoding, - depthBuffer: false, - stencilBuffer: false - }; - var cubeUVRenderTarget = _createRenderTarget( params ); - cubeUVRenderTarget.depthBuffer = equirectangular ? false : true; - _pingPongRenderTarget = _createRenderTarget( params ); - return cubeUVRenderTarget; + var scene = new Scene(); + var renderer = this._renderer; -} + if ( texture.isCubeTexture ) { -function _cleanup() { + if ( this._cubemapShader == null ) { - _pingPongRenderTarget.dispose(); - _renderer.setRenderTarget( null ); - var size = _renderer.getSize( new Vector2() ); - _renderer.setViewport( 0, 0, size.x, size.y ); + this._cubemapShader = _getCubemapShader(); -} + } -function _sceneToCubeUV( scene, near, far, cubeUVRenderTarget ) { + } else { - var fov = 90; - var aspect = 1; - var cubeCamera = new PerspectiveCamera( fov, aspect, near, far ); - var upSign = [ 1, 1, 1, 1, - 1, 1 ]; - var forwardSign = [ 1, 1, - 1, - 1, - 1, 1 ]; + if ( this._equirectShader == null ) { - var outputEncoding = _renderer.outputEncoding; - var toneMapping = _renderer.toneMapping; - var toneMappingExposure = _renderer.toneMappingExposure; - var clearColor = _renderer.getClearColor(); - var clearAlpha = _renderer.getClearAlpha(); + this._equirectShader = _getEquirectShader(); - _renderer.toneMapping = LinearToneMapping; - _renderer.toneMappingExposure = 1.0; - _renderer.outputEncoding = LinearEncoding; - scene.scale.z *= - 1; + } - var background = scene.background; - if ( background && background.isColor ) { + } - background.convertSRGBToLinear(); - // Convert linear to RGBE - var maxComponent = Math.max( background.r, background.g, background.b ); - var fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 ); - background = background.multiplyScalar( Math.pow( 2.0, - fExp ) ); - var alpha = ( fExp + 128.0 ) / 255.0; - _renderer.setClearColor( background, alpha ); - scene.background = null; + var material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader; + scene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - } + var uniforms = material.uniforms; - _renderer.setRenderTarget( cubeUVRenderTarget ); - for ( var i = 0; i < 6; i ++ ) { + uniforms[ 'envMap' ].value = texture; - var col = i % 3; - if ( col == 0 ) { + if ( ! texture.isCubeTexture ) { - cubeCamera.up.set( 0, upSign[ i ], 0 ); - cubeCamera.lookAt( forwardSign[ i ], 0, 0 ); + uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); - } else if ( col == 1 ) { + } - cubeCamera.up.set( 0, 0, upSign[ i ] ); - cubeCamera.lookAt( 0, forwardSign[ i ], 0 ); + uniforms[ 'inputEncoding' ].value = ENCODINGS[ texture.encoding ]; + uniforms[ 'outputEncoding' ].value = ENCODINGS[ cubeUVRenderTarget.texture.encoding ]; - } else { + _setViewport( cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); + + renderer.setRenderTarget( cubeUVRenderTarget ); + renderer.render( scene, _flatCamera ); + + }, + + _applyPMREM: function ( cubeUVRenderTarget ) { + + var renderer = this._renderer; + var autoClear = renderer.autoClear; + renderer.autoClear = false; + + for ( var i = 1; i < TOTAL_LODS; i ++ ) { + + var sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); - cubeCamera.up.set( 0, upSign[ i ], 0 ); - cubeCamera.lookAt( 0, 0, forwardSign[ i ] ); + var poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ]; + + this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); } - _setViewport( - col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX ); - _renderer.render( scene, cubeCamera ); - } + renderer.autoClear = autoClear; - _renderer.toneMapping = toneMapping; - _renderer.toneMappingExposure = toneMappingExposure; - _renderer.outputEncoding = outputEncoding; - _renderer.setClearColor( clearColor, clearAlpha ); - scene.scale.z *= - 1; + }, -} + /** + * This is a two-pass Gaussian blur for a cubemap. Normally this is done + * vertically and horizontally, but this breaks down on a cube. Here we apply + * the blur latitudinally (around the poles), and then longitudinally (towards + * the poles) to approximate the orthogonally-separable blur. It is least + * accurate at the poles, but still does a decent job. + */ + _blur: function ( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { -function _textureToCubeUV( texture, cubeUVRenderTarget ) { + var pingPongRenderTarget = this._pingPongRenderTarget; - var scene = new Scene(); - if ( texture.isCubeTexture ) { + this._halfBlur( + cubeUVRenderTarget, + pingPongRenderTarget, + lodIn, + lodOut, + sigma, + 'latitudinal', + poleAxis ); - if ( _cubemapShader == null ) { + this._halfBlur( + pingPongRenderTarget, + cubeUVRenderTarget, + lodOut, + lodOut, + sigma, + 'longitudinal', + poleAxis ); - _cubemapShader = _getCubemapShader(); + }, + + _halfBlur: function ( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { + + var renderer = this._renderer; + var blurMaterial = this._blurMaterial; + + if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { + + console.error( + 'blur direction must be either latitudinal or longitudinal!' ); } - } else { + // Number of standard deviations at which to cut off the discrete approximation. + var STANDARD_DEVIATIONS = 3; + + var blurScene = new Scene(); + blurScene.add( new Mesh( _lodPlanes[ lodOut ], blurMaterial ) ); + var blurUniforms = blurMaterial.uniforms; - if ( _equirectShader == null ) { + var pixels = _sizeLods[ lodIn ] - 1; + var radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); + var sigmaPixels = sigmaRadians / radiansPerPixel; + var samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; - _equirectShader = _getEquirectShader(); + if ( samples > MAX_SAMPLES ) { + + console.warn( `sigmaRadians, ${ + sigmaRadians}, is too large and will clip, as it requested ${ + samples} samples when the maximum is set to ${MAX_SAMPLES}` ); } - } - var material = texture.isCubeTexture ? _cubemapShader : _equirectShader; - scene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - var uniforms = material.uniforms; + var weights = []; + var sum = 0; - uniforms[ 'envMap' ].value = texture; - if ( ! texture.isCubeTexture ) { + for ( var i = 0; i < MAX_SAMPLES; ++ i ) { - uniforms[ 'texelSize' ].value.set( 1.0 / texture.image.width, 1.0 / texture.image.height ); + var x = i / sigmaPixels; + var weight = Math.exp( - x * x / 2 ); + weights.push( weight ); - } - uniforms[ 'inputEncoding' ].value = ENCODINGS[ texture.encoding ]; - uniforms[ 'outputEncoding' ].value = ENCODINGS[ texture.encoding ]; + if ( i == 0 ) { - _renderer.setRenderTarget( cubeUVRenderTarget ); - _setViewport( 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX ); - _renderer.render( scene, _flatCamera ); + sum += weight; -} + } else if ( i < samples ) { -function _compileMaterial( material ) { + sum += 2 * weight; - var tmpScene = new Scene(); - tmpScene.add( new Mesh( _lodPlanes[ 0 ], material ) ); - _renderer.compile( tmpScene, _flatCamera ); + } -} + } -function _createRenderTarget( params ) { + for ( var i = 0; i < weights.length; i ++ ) { - var cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); - cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; - cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; - cubeUVRenderTarget.scissorTest = true; - return cubeUVRenderTarget; + weights[ i ] = weights[ i ] / sum; -} + } -function _setViewport( x, y, width, height ) { + blurUniforms[ 'envMap' ].value = targetIn.texture; + blurUniforms[ 'samples' ].value = samples; + blurUniforms[ 'weights' ].value = weights; + blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; - var invDpr = 1.0 / _renderer.getPixelRatio(); - x *= invDpr; - y *= invDpr; - width *= invDpr; - height *= invDpr; - _renderer.setViewport( x, y, width, height ); - _renderer.setScissor( x, y, width, height ); + if ( poleAxis ) { -} + blurUniforms[ 'poleAxis' ].value = poleAxis; -function _applyPMREM( cubeUVRenderTarget ) { + } - var autoClear = _renderer.autoClear; - _renderer.autoClear = false; + blurUniforms[ 'dTheta' ].value = radiansPerPixel; + blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; + blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; + blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; - for ( var i = 1; i < TOTAL_LODS; i ++ ) { + var outputSize = _sizeLods[ lodOut ]; + var x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); + var y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); - var sigma = Math.sqrt( - _sigmas[ i ] * _sigmas[ i ] - - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] ); - var poleAxis = - _axisDirections[ ( i - 1 ) % _axisDirections.length ]; - _blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis ); + _setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize ); + renderer.setRenderTarget( targetOut ); + renderer.render( blurScene, _flatCamera ); } - _renderer.autoClear = autoClear; - -} +}; -/** - * This is a two-pass Gaussian blur for a cubemap. Normally this is done - * vertically and horizontally, but this breaks down on a cube. Here we apply - * the blur latitudinally (around the poles), and then longitudinally (towards - * the poles) to approximate the orthogonally-separable blur. It is least - * accurate at the poles, but still does a decent job. - */ -function _blur( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) { +function _isLDR( texture ) { - _halfBlur( - cubeUVRenderTarget, - _pingPongRenderTarget, - lodIn, - lodOut, - sigma, - 'latitudinal', - poleAxis ); + if ( texture === undefined || texture.type !== UnsignedByteType ) return false; - _halfBlur( - _pingPongRenderTarget, - cubeUVRenderTarget, - lodOut, - lodOut, - sigma, - 'longitudinal', - poleAxis ); + return texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding; } -function _halfBlur( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) { - - if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) { +function _createPlanes() { - console.error( - 'blur direction must be either latitudinal or longitudinal!' ); + var _lodPlanes = []; + var _sizeLods = []; + var _sigmas = []; - } + var lod = LOD_MAX; - // Number of standard deviations at which to cut off the discrete approximation. - var STANDARD_DEVIATIONS = 3; + for ( var i = 0; i < TOTAL_LODS; i ++ ) { - var blurScene = new Scene(); - blurScene.add( new Mesh( _lodPlanes[ lodOut ], _blurMaterial ) ); - var blurUniforms = _blurMaterial.uniforms; + var sizeLod = Math.pow( 2, lod ); + _sizeLods.push( sizeLod ); + var sigma = 1.0 / sizeLod; - var pixels = _sizeLods[ lodIn ] - 1; - var radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 ); - var sigmaPixels = sigmaRadians / radiansPerPixel; - var samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES; + if ( i > LOD_MAX - LOD_MIN ) { - if ( samples > MAX_SAMPLES ) { + sigma = EXTRA_LOD_SIGMA[ i - LOD_MAX + LOD_MIN - 1 ]; - console.warn( `sigmaRadians, ${ - sigmaRadians}, is too large and will clip, as it requested ${ - samples} samples when the maximum is set to ${MAX_SAMPLES}` ); + } else if ( i == 0 ) { - } + sigma = 0; - var weights = []; - var sum = 0; + } - for ( var i = 0; i < MAX_SAMPLES; ++ i ) { + _sigmas.push( sigma ); - var x = i / sigmaPixels; - var weight = Math.exp( - x * x / 2 ); - weights.push( weight ); + var texelSize = 1.0 / ( sizeLod - 1 ); + var min = - texelSize / 2; + var max = 1 + texelSize / 2; + var uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ]; - if ( i == 0 ) { + var cubeFaces = 6; + var vertices = 6; + var positionSize = 3; + var uvSize = 2; + var faceIndexSize = 1; - sum += weight; + var position = new Float32Array( positionSize * vertices * cubeFaces ); + var uv = new Float32Array( uvSize * vertices * cubeFaces ); + var faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces ); - } else if ( i < samples ) { + for ( var face = 0; face < cubeFaces; face ++ ) { - sum += 2 * weight; + var x = ( face % 3 ) * 2 / 3 - 1; + var y = face > 2 ? 0 : - 1; + var coordinates = [ + x, y, 0, + x + 2 / 3, y, 0, + x + 2 / 3, y + 1, 0, + x, y, 0, + x + 2 / 3, y + 1, 0, + x, y + 1, 0 + ]; + position.set( coordinates, positionSize * vertices * face ); + uv.set( uv1, uvSize * vertices * face ); + var fill = [ face, face, face, face, face, face ]; + faceIndex.set( fill, faceIndexSize * vertices * face ); } - } + var planes = new BufferGeometry(); + planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) ); + planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) ); + planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) ); + _lodPlanes.push( planes ); - for ( var i = 0; i < weights.length; i ++ ) { + if ( lod > LOD_MIN ) { - weights[ i ] = weights[ i ] / sum; + lod --; + + } } - blurUniforms[ 'envMap' ].value = targetIn.texture; - blurUniforms[ 'samples' ].value = samples; - blurUniforms[ 'weights' ].value = weights; - blurUniforms[ 'latitudinal' ].value = direction === 'latitudinal'; - if ( poleAxis ) { + return { _lodPlanes, _sizeLods, _sigmas }; + +} - blurUniforms[ 'poleAxis' ].value = poleAxis; +function _createRenderTarget( params ) { - } - blurUniforms[ 'dTheta' ].value = radiansPerPixel; - blurUniforms[ 'mipInt' ].value = LOD_MAX - lodIn; - blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; - blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ]; + var cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params ); + cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping; + cubeUVRenderTarget.texture.name = 'PMREM.cubeUv'; + cubeUVRenderTarget.scissorTest = true; + return cubeUVRenderTarget; - var outputSize = _sizeLods[ lodOut ]; - var x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize ); - var y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + - 2 * outputSize * - ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 ); +} + +function _setViewport( target, x, y, width, height ) { - _renderer.setRenderTarget( targetOut ); - _setViewport( x, y, 3 * outputSize, 2 * outputSize ); - _renderer.render( blurScene, _flatCamera ); + target.viewport.set( x, y, width, height ); + target.scissor.set( x, y, width, height ); } @@ -47694,27 +48394,28 @@ ${_getEncodings()} #define ENVMAP_TYPE_CUBE_UV #include +vec3 getSample(float theta, vec3 axis) { + float cosTheta = cos(theta); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross(axis, vOutputDirection) * sin(theta) + + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta); + return bilinearCubeUV(envMap, sampleDirection, mipInt); +} + void main() { + vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection); + if (all(equal(axis, vec3(0.0)))) + axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x); + axis = normalize(axis); gl_FragColor = vec4(0.0); - for (int i = 0; i < n; i++) { + gl_FragColor.rgb += weights[0] * getSample(0.0, axis); + for (int i = 1; i < n; i++) { if (i >= samples) break; - for (int dir = -1; dir < 2; dir += 2) { - if (i == 0 && dir == 1) - continue; - vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection); - if (all(equal(axis, vec3(0.0)))) - axis = cross(vec3(0.0, 1.0, 0.0), vOutputDirection); - axis = normalize(axis); - float theta = dTheta * float(dir * i); - float cosTheta = cos(theta); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross(axis, vOutputDirection) * sin(theta) - + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta); - gl_FragColor.rgb += - weights[i] * bilinearCubeUV(envMap, sampleDirection, mipInt); - } + float theta = dTheta * float(i); + gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis); + gl_FragColor.rgb += weights[i] * getSample(theta, axis); } gl_FragColor = linearToOutputTexel(gl_FragColor); } @@ -47931,8 +48632,10 @@ function Face4( a, b, c, d, normal, color, materialIndex ) { } var LineStrip = 0; - var LinePieces = 1; +var NoColors = 0; +var FaceColors = 1; +var VertexColors = 2; function MeshFaceMaterial( materials ) { @@ -47953,6 +48656,7 @@ function MultiMaterial( materials ) { return materials.slice(); }; + return materials; } @@ -48010,8 +48714,8 @@ function Vertex( x, y, z ) { function DynamicBufferAttribute( array, itemSize ) { - console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' ); - return new BufferAttribute( array, itemSize ).setDynamic( true ); + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.' ); + return new BufferAttribute( array, itemSize ).setUsage( DynamicDrawUsage ); } @@ -48370,6 +49074,24 @@ Object.assign( Box3.prototype, { } } ); +Object.assign( Sphere.prototype, { + + empty: function () { + + console.warn( 'THREE.Sphere: .empty() has been renamed to .isEmpty().' ); + return this.isEmpty(); + + }, + +} ); + +Frustum.prototype.setFromMatrix = function ( m ) { + + console.warn( 'THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().' ); + return this.setFromProjectionMatrix( m ); + +}; + Line3.prototype.center = function ( optionalTarget ) { console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); @@ -48377,7 +49099,7 @@ Line3.prototype.center = function ( optionalTarget ) { }; -Object.assign( _Math, { +Object.assign( MathUtils, { random16: function () { @@ -48389,14 +49111,14 @@ Object.assign( _Math, { nearestPowerOfTwo: function ( value ) { console.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' ); - return _Math.floorPowerOfTwo( value ); + return MathUtils.floorPowerOfTwo( value ); }, nextPowerOfTwo: function ( value ) { console.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' ); - return _Math.ceilPowerOfTwo( value ); + return MathUtils.ceilPowerOfTwo( value ); } @@ -48421,10 +49143,10 @@ Object.assign( Matrix3.prototype, { console.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' ); }, - applyToBuffer: function ( buffer /*, offset, length */ ) { + applyToBufferAttribute: function ( attribute ) { - console.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); - return this.applyToBufferAttribute( buffer ); + console.warn( 'THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.' ); + return attribute.applyMatrix3( this ); }, applyToVector3Array: function ( /* array, offset, length */ ) { @@ -48520,10 +49242,10 @@ Object.assign( Matrix4.prototype, { console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); }, - applyToBuffer: function ( buffer /*, offset, length */ ) { + applyToBufferAttribute: function ( attribute ) { - console.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' ); - return this.applyToBufferAttribute( buffer ); + console.warn( 'THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.' ); + return attribute.applyMatrix4( this ); }, applyToVector3Array: function ( /* array, offset, length */ ) { @@ -48762,6 +49484,12 @@ Object.assign( Geometry.prototype, { console.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } } ); @@ -48789,6 +49517,12 @@ Object.assign( Object3D.prototype, { console.error( 'THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.' ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } } ); @@ -49109,6 +49843,7 @@ Object.assign( BufferGeometry.prototype, { console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); } + console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); this.addGroup( start, count ); @@ -49135,7 +49870,14 @@ Object.assign( BufferGeometry.prototype, { return this.deleteAttribute( name ); + }, + applyMatrix: function ( matrix ) { + + console.warn( 'THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4().' ); + return this.applyMatrix4( matrix ); + } + } ); Object.defineProperties( BufferGeometry.prototype, { @@ -49159,6 +49901,25 @@ Object.defineProperties( BufferGeometry.prototype, { } ); +Object.defineProperties( Raycaster.prototype, { + + linePrecision: { + get: function () { + + console.warn( 'THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.' ); + return this.params.Line.threshold; + + }, + set: function ( value ) { + + console.warn( 'THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.' ); + this.params.Line.threshold = value; + + } + } + +} ); + Object.defineProperties( InterleavedBuffer.prototype, { dynamic: { @@ -49626,26 +50387,12 @@ Object.defineProperties( WebGLShadowMap.prototype, { } ); -// - -Object.defineProperties( WebGLRenderTargetCube.prototype, { - - activeCubeFace: { - set: function ( /* value */ ) { - - console.warn( 'THREE.WebGLRenderTargetCube: .activeCubeFace has been removed. It is now the second parameter of WebGLRenderer.setRenderTarget().' ); - - } - }, - activeMipMapLevel: { - set: function ( /* value */ ) { - - console.warn( 'THREE.WebGLRenderTargetCube: .activeMipMapLevel has been removed. It is now the third parameter of WebGLRenderer.setRenderTarget().' ); +function WebGLRenderTargetCube( width, height, options ) { - } - } + console.warn( 'THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).' ); + return new WebGLCubeRenderTarget( width, options ); -} ); +} // @@ -49936,19 +50683,19 @@ var SceneUtils = { createMultiMaterialObject: function ( /* geometry, materials */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); }, detach: function ( /* child, parent, scene */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); }, attach: function ( /* child, scene, parent */ ) { - console.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' ); + console.error( 'THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js' ); } @@ -49958,7 +50705,7 @@ var SceneUtils = { function LensFlare() { - console.error( 'THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js' ); + console.error( 'THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js' ); } @@ -49972,4 +50719,4 @@ if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { } -export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, ClosedSplineCurve3, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeBufferGeometry, ConeGeometry, CubeCamera, BoxGeometry as CubeGeometry, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DirectionalLightShadow, DiscreteInterpolant, DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeBufferGeometry, ExtrudeGeometry, Face3, Face4, FaceColors, FileLoader, FlatShading, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FrontFaceDirectionCCW, FrontFaceDirectionCW, FrontSide, Frustum, GammaEncoding, Geometry, GeometryUtils, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, LightShadow, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LogLuvEncoding, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, _Math as Math, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricBufferGeometry, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDEncoding, RGBEEncoding, RGBEFormat, RGBFormat, RGBIntegerFormat, RGBM16Encoding, RGBM7Encoding, RGB_ETC1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingBufferGeometry, RingGeometry, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SphericalReflectionMapping, Spline, SplineCurve, SplineCurve3, SpotLight, SpotLightHelper, SpotLightShadow, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronBufferGeometry, TetrahedronGeometry, TextBufferGeometry, TextGeometry, Texture, TextureLoader, TorusBufferGeometry, TorusGeometry, TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uncharted2ToneMapping, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, sRGBEncoding }; +export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AlphaFormat, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightProbe, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, AxisHelper, BackSide, BasicDepthPacking, BasicShadowMap, BinaryTextureLoader, Bone, BooleanKeyframeTrack, BoundingBoxHelper, Box2, Box3, Box3Helper, BoxBufferGeometry, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasRenderer, CanvasTexture, CatmullRomCurve3, CineonToneMapping, CircleBufferGeometry, CircleGeometry, ClampToEdgeWrapping, Clock, ClosedSplineCurve3, Color, ColorKeyframeTrack, CompressedTexture, CompressedTextureLoader, ConeBufferGeometry, ConeGeometry, CubeCamera, BoxGeometry as CubeGeometry, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubeUVRefractionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CylinderBufferGeometry, CylinderGeometry, Cylindrical, DataTexture, DataTexture2DArray, DataTexture3D, DataTextureLoader, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DirectionalLight, DirectionalLightHelper, DirectionalLightShadow, DiscreteInterpolant, DodecahedronBufferGeometry, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicBufferAttribute, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EdgesHelper, EllipseCurve, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeBufferGeometry, ExtrudeGeometry, Face3, Face4, FaceColors, FileLoader, FlatShading, Float32Attribute, Float32BufferAttribute, Float64Attribute, Float64BufferAttribute, FloatType, Fog, FogExp2, Font, FontLoader, FrontFaceDirectionCCW, FrontFaceDirectionCW, FrontSide, Frustum, GammaEncoding, Geometry, GeometryUtils, GreaterDepth, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightProbe, IcosahedronBufferGeometry, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, ImmediateRenderObject, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16Attribute, Int16BufferAttribute, Int32Attribute, Int32BufferAttribute, Int8Attribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, JSONLoader, KeepStencilOp, KeyframeTrack, LOD, LatheBufferGeometry, LatheGeometry, Layers, LensFlare, LessDepth, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, LightShadow, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LinePieces, LineSegments, LineStrip, LinearEncoding, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearToneMapping, Loader, LoaderUtils, LoadingManager, LogLuvEncoding, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils as Math, MathUtils, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshFaceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiMaterial, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeverDepth, NeverStencilFunc, NoBlending, NoColors, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronBufferGeometry, OctahedronGeometry, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, ParametricBufferGeometry, ParametricGeometry, Particle, ParticleBasicMaterial, ParticleSystem, ParticleSystemMaterial, Path, PerspectiveCamera, Plane, PlaneBufferGeometry, PlaneGeometry, PlaneHelper, PointCloud, PointCloudMaterial, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronBufferGeometry, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDEncoding, RGBEEncoding, RGBEFormat, RGBFormat, RGBIntegerFormat, RGBM16Encoding, RGBM7Encoding, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingBufferGeometry, RingGeometry, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, Scene, SceneUtils, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeBufferGeometry, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SmoothShading, Sphere, SphereBufferGeometry, SphereGeometry, Spherical, SphericalHarmonics3, SphericalReflectionMapping, Spline, SplineCurve, SplineCurve3, SpotLight, SpotLightHelper, SpotLightShadow, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronBufferGeometry, TetrahedronGeometry, TextBufferGeometry, TextGeometry, Texture, TextureLoader, TorusBufferGeometry, TorusGeometry, TorusKnotBufferGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeBufferGeometry, TubeGeometry, UVMapping, Uint16Attribute, Uint16BufferAttribute, Uint32Attribute, Uint32BufferAttribute, Uint8Attribute, Uint8BufferAttribute, Uint8ClampedAttribute, Uint8ClampedBufferAttribute, Uncharted2ToneMapping, Uniform, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, Vertex, VertexColors, VideoTexture, WebGLCubeRenderTarget, WebGLMultisampleRenderTarget, WebGLRenderTarget, WebGLRenderTargetCube, WebGLRenderer, WebGLUtils, WireframeGeometry, WireframeHelper, WrapAroundEnding, XHRLoader, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, sRGBEncoding }; diff --git a/docs/api/en/animation/AnimationObjectGroup.html b/docs/api/en/animation/AnimationObjectGroup.html index 59db3ecfefc02d..6a2124e41db3e2 100644 --- a/docs/api/en/animation/AnimationObjectGroup.html +++ b/docs/api/en/animation/AnimationObjectGroup.html @@ -37,10 +37,10 @@

Limitations

Constructor

-

[name]( [param:object obj1], [param:object obj2], [param:object obj3], ... )

- [page:object obj] - an abitrary number of meshes that share the same animation state.
- +

+ [page:object obj] - an abitrary number of meshes that share the same animation state. +

Properties

diff --git a/docs/api/en/animation/KeyframeTrack.html b/docs/api/en/animation/KeyframeTrack.html index 389707cb45c2df..35a31b995a19c6 100644 --- a/docs/api/en/animation/KeyframeTrack.html +++ b/docs/api/en/animation/KeyframeTrack.html @@ -58,7 +58,7 @@

[name]

Some examples of how to manually create [page:AnimationClip AnimationClips] with different sorts - of KeyframeTracks can be found in the [link:https://threejs.org/examples/js/animation/AnimationClipCreator.js AnimationClipCreator] + of KeyframeTracks can be found in the [link:https://threejs.org/examples/jsm/animation/AnimationClipCreator.js AnimationClipCreator] file.

diff --git a/docs/api/en/audio/Audio.html b/docs/api/en/audio/Audio.html index 9b93b7511ce7bb..115d66f3c27c0f 100644 --- a/docs/api/en/audio/Audio.html +++ b/docs/api/en/audio/Audio.html @@ -18,13 +18,7 @@

[name]

This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

- -

Example

- -

- [example:webaudio_sandbox webaudio / sandbox ]
- [example:webaudio_visualizer webaudio / visualizer ] -

+

Code Example

// create an AudioListener and add it to the camera @@ -44,6 +38,12 @@

Example

});
+

Examples

+ +

+ [example:webaudio_sandbox webaudio / sandbox ]
+ [example:webaudio_visualizer webaudio / visualizer ] +

Constructor

diff --git a/docs/api/en/audio/AudioAnalyser.html b/docs/api/en/audio/AudioAnalyser.html index aca9f4b7b8ba31..70a8a6a83c76db 100644 --- a/docs/api/en/audio/AudioAnalyser.html +++ b/docs/api/en/audio/AudioAnalyser.html @@ -18,13 +18,7 @@

[name]

- -

Example

- -

- [example:webaudio_sandbox webaudio / sandbox ]
- [example:webaudio_visualizer webaudio / visualizer ] -

+

Code Example

// create an AudioListener and add it to the camera @@ -50,6 +44,12 @@

Example

var data = analyser.getAverageFrequency();
+

Examples

+ +

+ [example:webaudio_sandbox webaudio / sandbox ]
+ [example:webaudio_visualizer webaudio / visualizer ] +

Constructor

diff --git a/docs/api/en/audio/AudioContext.html b/docs/api/en/audio/AudioContext.html index 913db1bf3dd33f..159af362065cf2 100644 --- a/docs/api/en/audio/AudioContext.html +++ b/docs/api/en/audio/AudioContext.html @@ -29,7 +29,7 @@

[method:AudioContext getContext]()

otherwise set it to a new [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].

-

[method:AudioContext setContext]( [param:AudioConetxt value] )

+

[method:AudioContext setContext]( [param:AudioContext value] )

Set the variable *context* in the outer scope to *value*.

diff --git a/docs/api/en/audio/AudioListener.html b/docs/api/en/audio/AudioListener.html index 2bbacecbcbc764..bf5ab6b9ce0308 100644 --- a/docs/api/en/audio/AudioListener.html +++ b/docs/api/en/audio/AudioListener.html @@ -18,14 +18,7 @@

[name]

In most cases, the listener object is a child of the camera. So the 3D transformation of the camera represents the 3D transformation of the listener.

- -

Example

- -

- [example:webaudio_sandbox webaudio / sandbox ]
- [example:webaudio_timing webaudio / timing ]
- [example:webaudio_visualizer webaudio / visualizer ] -

+

Code Example

// create an AudioListener and add it to the camera @@ -45,6 +38,13 @@

Example

});
+

Examples

+ +

+ [example:webaudio_sandbox webaudio / sandbox ]
+ [example:webaudio_timing webaudio / timing ]
+ [example:webaudio_visualizer webaudio / visualizer ] +

Constructor

diff --git a/docs/api/en/audio/PositionalAudio.html b/docs/api/en/audio/PositionalAudio.html index 65b2701ba318ee..5b244da2dc7b79 100644 --- a/docs/api/en/audio/PositionalAudio.html +++ b/docs/api/en/audio/PositionalAudio.html @@ -18,14 +18,7 @@

[name]

This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

- -

Example

- -

- [example:webaudio_orientation webaudio / orientation ]
- [example:webaudio_sandbox webaudio / sandbox ]
- [example:webaudio_timing webaudio / timing ] -

+

Code Example

// create an AudioListener and add it to the camera @@ -44,7 +37,7 @@

Example

}); // create an object for the sound to play from - var sphere = new THREE.SphereGeometry( 20, 32, 16 ); + var sphere = new THREE.SphereBufferGeometry( 20, 32, 16 ); var material = new THREE.MeshPhongMaterial( { color: 0xff2200 } ); var mesh = new THREE.Mesh( sphere, material ); scene.add( mesh ); @@ -53,6 +46,13 @@

Example

mesh.add( sound );
+

Examples

+ +

+ [example:webaudio_orientation webaudio / orientation ]
+ [example:webaudio_sandbox webaudio / sandbox ]
+ [example:webaudio_timing webaudio / timing ] +

Constructor

diff --git a/docs/api/en/cameras/ArrayCamera.html b/docs/api/en/cameras/ArrayCamera.html index a5ca04697e3e67..bb6fab9839d238 100644 --- a/docs/api/en/cameras/ArrayCamera.html +++ b/docs/api/en/cameras/ArrayCamera.html @@ -17,7 +17,7 @@

[name]

An instance of [name] always has an array of sub cameras. It's mandatory to define for each sub camera the *viewport* property which determines the part of the viewport that is rendered with this camera.

-

Example

+

Examples

[example:webgl_camera_array camera / array ]

diff --git a/docs/api/en/cameras/CubeCamera.html b/docs/api/en/cameras/CubeCamera.html index 17919627110e52..1c64ea2da9b9ac 100644 --- a/docs/api/en/cameras/CubeCamera.html +++ b/docs/api/en/cameras/CubeCamera.html @@ -12,12 +12,9 @@

[name]

-

Creates 6 cameras that render to a [page:WebGLRenderTargetCube].

+

Creates 6 cameras that render to a [page:WebGLCubeRenderTarget].

-

Examples

- -

[example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]

-

[example:webgl_shading_physical shading / physical ]

+

Code Example

// Create cube camera var cubeCamera = new THREE.CubeCamera( 1, 100000, 128 ); @@ -38,6 +35,12 @@

Examples

renderer.render( scene, camera );
+

Examples

+ +

+ [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
+ [example:webgl_shading_physical shading / physical ] +

Constructor

@@ -47,7 +50,7 @@

[name]( [param:Number near], [param:Number far], [param:Number cubeResolutio near -- The near clipping distance.
far -- The far clipping distance
cubeResolution -- Sets the length of the cube's edges.
- options - (optional) object that holds texture parameters passed to the auto-generated WebGLRenderTargetCube. + options - (optional) object that holds texture parameters passed to the auto-generated WebGLCubeRenderTarget. If not specified, the options default to: { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter } @@ -56,14 +59,14 @@

[name]( [param:Number near], [param:Number far], [param:Number cubeResolutio

Constructs a CubeCamera that contains 6 [page:PerspectiveCamera PerspectiveCameras] that - render to a [page:WebGLRenderTargetCube]. + render to a [page:WebGLCubeRenderTarget].

Properties

See the base [page:Object3D] class for common properties.

-

[property:WebGLRenderTargetCube renderTarget]

+

[property:WebGLCubeRenderTarget renderTarget]

The cube texture that gets generated.

diff --git a/docs/api/en/cameras/OrthographicCamera.html b/docs/api/en/cameras/OrthographicCamera.html index 92d2fad5af5971..7fce781236a1c4 100644 --- a/docs/api/en/cameras/OrthographicCamera.html +++ b/docs/api/en/cameras/OrthographicCamera.html @@ -21,22 +21,26 @@

[name]

This can be useful for rendering 2D scenes and UI elements, amongst other things.

+

Code Example

-

Example

+ + var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + scene.add( camera ); + -

[example:webgl_camera camera ]

-

[example:webgl_interactive_cubes_ortho interactive / cubes / ortho ]

-

[example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]

-

[example:webgl_postprocessing_advanced postprocessing / advanced ]

-

[example:webgl_postprocessing_dof2 postprocessing / dof2 ]

-

[example:webgl_postprocessing_godrays postprocessing / godrays ]

-

[example:webgl_rtt rtt ]

-

[example:webgl_shaders_tonemapping shaders / tonemapping ]

-

[example:webgl_shadowmap shadowmap ]

- - var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); -scene.add( camera ); +

Examples

+

+ [example:webgl_camera camera ]
+ [example:webgl_interactive_cubes_ortho interactive / cubes / ortho ]
+ [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
+ [example:webgl_postprocessing_advanced postprocessing / advanced ]
+ [example:webgl_postprocessing_dof2 postprocessing / dof2 ]
+ [example:webgl_postprocessing_godrays postprocessing / godrays ]
+ [example:webgl_rtt rtt ]
+ [example:webgl_shaders_tonemapping shaders / tonemapping ]
+ [example:webgl_shadowmap shadowmap ] +

Constructor

diff --git a/docs/api/en/cameras/PerspectiveCamera.html b/docs/api/en/cameras/PerspectiveCamera.html index f20c4629b0271f..85c656d4b00a3c 100644 --- a/docs/api/en/cameras/PerspectiveCamera.html +++ b/docs/api/en/cameras/PerspectiveCamera.html @@ -19,18 +19,22 @@

[name]

common projection mode used for rendering a 3D scene.

+

Code Example

-

Example

+ + var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); + scene.add( camera ); + -

[example:webgl_animation_skinning_blending animation / skinning / blending ]

-

[example:webgl_animation_skinning_morph animation / skinning / blending ]

-

[example:webgl_effects_stereo effects / stereo ]

-

[example:webgl_interactive_cubes interactive / cubes ]

-

[example:webgl_loader_collada_skinning loader / collada / skinning ]

- - var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); -scene.add( camera ); +

Examples

+

+ [example:webgl_animation_skinning_blending animation / skinning / blending ]
+ [example:webgl_animation_skinning_morph animation / skinning / blending ]
+ [example:webgl_effects_stereo effects / stereo ]
+ [example:webgl_interactive_cubes interactive / cubes ]
+ [example:webgl_loader_collada_skinning loader / collada / skinning ] +

Constructor

diff --git a/docs/api/en/cameras/StereoCamera.html b/docs/api/en/cameras/StereoCamera.html index 4e37b28af54f1f..ddb7c6d94f5970 100644 --- a/docs/api/en/cameras/StereoCamera.html +++ b/docs/api/en/cameras/StereoCamera.html @@ -16,22 +16,14 @@

[name]

[link:https://en.wikipedia.org/wiki/Anaglyph_3D 3D Anaglyph] or [link:https://en.wikipedia.org/wiki/parallax_barrier Parallax Barrier].

- -

Example

- -

[example:webgl_effects_anaglyph effects / anaglyph ]

-

[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]

-

[example:webgl_effects_stereo effects / stereo ]

+

Examples

- This class is used internally in the files

- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/AnaglyphEffect.js examples/js/effects/AnaglyphEffect.js]

- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/ParallaxBarrierEffect.js examples/js/effects/ParallaxBarrierEffect.js]

- [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/StereoEffect.js examples/js/effects/StereoEffect.js]

- used in the above examples. + [example:webgl_effects_anaglyph effects / anaglyph ]
+ [example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]
+ [example:webgl_effects_stereo effects / stereo ]

-

Constructor

[name]( )

diff --git a/docs/api/en/constants/CustomBlendingEquations.html b/docs/api/en/constants/CustomBlendingEquations.html index 9c15432b1fac4f..4f6abdc60f920c 100644 --- a/docs/api/en/constants/CustomBlendingEquations.html +++ b/docs/api/en/constants/CustomBlendingEquations.html @@ -10,15 +10,12 @@

Custom Blending Equation Constants

- -

Example

-

[example:webgl_materials_blending_custom materials / blending / custom ]

- -

Usage

These work with all material types. First set the material's blending mode to THREE.CustomBlending, then set the desired Blending Equation, Source Factor and Destination Factor.

+

Code Example

+ var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); material.blending = THREE.CustomBlending; @@ -27,6 +24,9 @@

Usage

material.blendDst = THREE.OneMinusSrcAlphaFactor; //default
+

Examples

+

[example:webgl_materials_blending_custom materials / blending / custom ]

+

Blending Equations

THREE.AddEquation diff --git a/docs/api/en/constants/Materials.html b/docs/api/en/constants/Materials.html index 4d92eaf241f388..5ab138f32f9971 100644 --- a/docs/api/en/constants/Materials.html +++ b/docs/api/en/constants/Materials.html @@ -27,20 +27,6 @@

Side

Default is [page:Constant FrontSide].

- -

Colors

- - THREE.NoColors - THREE.FaceColors - THREE.VertexColors - -

- [page:Constant NoColors] is the default and applies the material's color to all faces.
- [page:Constant FaceColors] colors faces according to each [page:Face3 Face3] [page:Color Color] value.
- [page:Constant VertexColors] colors faces according to each [page:Face3 Face3] vertexColors value. This is an array of three [page:Color Color]s, one for each vertex in the face.
- See the [example:webgl_geometry_colors geometry / colors] example. -

-

Blending Mode

THREE.NoBlending diff --git a/docs/api/en/constants/Renderer.html b/docs/api/en/constants/Renderer.html index dd454c5af92e55..a7597895aefa44 100644 --- a/docs/api/en/constants/Renderer.html +++ b/docs/api/en/constants/Renderer.html @@ -46,7 +46,7 @@

Shadow Types

[page:constant BasicShadowMap] gives unfiltered shadow maps - fastest, but lowest quality.
[page:constant PCFShadowMap] filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm (default).
- [page:constant PCFSoftShadowMap] filters shadow maps using the Percentage-Closer Soft Shadows (PCSS) algorithm.
+ [page:constant PCFSoftShadowMap] filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm with better soft shadows especially when using low-resolution shadow maps.
[page:constant VSMShadowMap] filters shadow maps using the Variance Shadow Map (VSM) algorithm. When using VSMShadowMap all shadow receivers will also cast shadows.

@@ -64,9 +64,6 @@

Tone Mapping

This is used to approximate the appearance of high dynamic range (HDR) on the low dynamic range medium of a standard computer monitor or mobile device's screen.

- [page:constant NoToneMapping] disables tone mapping.
- [page:constant LinearToneMapping] is the default.

- See the [example:webgl_tonemapping WebGL / tonemapping] example.

diff --git a/docs/api/en/constants/Textures.html b/docs/api/en/constants/Textures.html index ecea9bcee7934d..b9908bf42891eb 100644 --- a/docs/api/en/constants/Textures.html +++ b/docs/api/en/constants/Textures.html @@ -262,11 +262,50 @@

PVRTC Compressed Texture Formats

ETC Compressed Texture Format

THREE.RGB_ETC1_Format + THREE.RGB_ETC2_Format + THREE.RGBA_ETC2_EAC_Format

For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property, these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/ WEBGL_compressed_texture_etc1] - extension.

+ (ETC1) or [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc/ WEBGL_compressed_texture_etc] + (ETC2) extensions.

+

+ +

ASTC Compressed Texture Format

+ + THREE.RGBA_ASTC_4x4_Format + THREE.RGBA_ASTC_5x4_Format + THREE.RGBA_ASTC_5x5_Format + THREE.RGBA_ASTC_6x5_Format + THREE.RGBA_ASTC_6x6_Format + THREE.RGBA_ASTC_8x5_Format + THREE.RGBA_ASTC_8x6_Format + THREE.RGBA_ASTC_8x8_Format + THREE.RGBA_ASTC_10x5_Format + THREE.RGBA_ASTC_10x6_Format + THREE.RGBA_ASTC_10x8_Format + THREE.RGBA_ASTC_10x10_Format + THREE.RGBA_ASTC_12x10_Format + THREE.RGBA_ASTC_12x12_Format + THREE.SRGB8_ALPHA8_ASTC_4x4_Format + THREE.SRGB8_ALPHA8_ASTC_5x4_Format + THREE.SRGB8_ALPHA8_ASTC_5x5_Format + THREE.SRGB8_ALPHA8_ASTC_6x5_Format + THREE.SRGB8_ALPHA8_ASTC_6x6_Format + THREE.SRGB8_ALPHA8_ASTC_8x5_Format + THREE.SRGB8_ALPHA8_ASTC_8x6_Format + THREE.SRGB8_ALPHA8_ASTC_8x8_Format + THREE.SRGB8_ALPHA8_ASTC_10x5_Format + THREE.SRGB8_ALPHA8_ASTC_10x6_Format + THREE.SRGB8_ALPHA8_ASTC_10x8_Format + THREE.SRGB8_ALPHA8_ASTC_10x10_Format + THREE.SRGB8_ALPHA8_ASTC_12x10_Format + THREE.SRGB8_ALPHA8_ASTC_12x12_Format + +

+ For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property, + these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/ WEBGL_compressed_texture_astc] extension.

Internal Formats

diff --git a/docs/api/en/core/BufferGeometry.html b/docs/api/en/core/BufferGeometry.html index 9cbd5db001e559..da402461ce1450 100644 --- a/docs/api/en/core/BufferGeometry.html +++ b/docs/api/en/core/BufferGeometry.html @@ -22,7 +22,7 @@

[name]

For a less efficient but easier-to-use representation of geometry, see [page:Geometry].

-

Example

+

Code Example

var geometry = new THREE.BufferGeometry(); // create a simple square shape. We duplicate the top left and bottom right @@ -42,6 +42,8 @@

Example

var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); var mesh = new THREE.Mesh( geometry, material );
+ +

Examples

[example:webgl_buffergeometry Mesh with non-indexed faces]
[example:webgl_buffergeometry_indexed Mesh with indexed faces]
@@ -179,7 +181,7 @@

[method:null addGroup]( [param:Integer start], [param:Integer count], [param

-

[method:null applyMatrix]( [param:Matrix4 matrix] )

+

[method:null applyMatrix4]( [param:Matrix4 matrix] )

Bakes matrix transform directly into vertex coordinates.

[method:BufferGeometry center] ()

diff --git a/docs/api/en/core/EventDispatcher.html b/docs/api/en/core/EventDispatcher.html index 954f12e5fb1b58..57e52bfbc1a562 100644 --- a/docs/api/en/core/EventDispatcher.html +++ b/docs/api/en/core/EventDispatcher.html @@ -15,36 +15,36 @@

[name]

[link:https://github.com/mrdoob/eventdispatcher.js Eventdispatcher on GitHub]

-

Example

+

Code Example

-// Adding events to a custom object + // Adding events to a custom object -var Car = function () { + var Car = function () { - this.start = function () { + this.start = function () { - this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); + this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); - }; + }; -}; + }; -// Mixing the EventDispatcher.prototype with the custom object prototype + // Mixing the EventDispatcher.prototype with the custom object prototype -Object.assign( Car.prototype, EventDispatcher.prototype ); + Object.assign( Car.prototype, EventDispatcher.prototype ); -// Using events with the custom object + // Using events with the custom object -var car = new Car(); + var car = new Car(); -car.addEventListener( 'start', function ( event ) { + car.addEventListener( 'start', function ( event ) { - alert( event.message ); + alert( event.message ); -} ); + } ); -car.start(); + car.start();

Constructor

diff --git a/docs/api/en/core/Face3.html b/docs/api/en/core/Face3.html index 4428f23835e532..a4c6a7388ac989 100644 --- a/docs/api/en/core/Face3.html +++ b/docs/api/en/core/Face3.html @@ -16,39 +16,40 @@

[name]

create them manually.

- -

Examples

- -

[example:svg_sandbox svg / sandbox ]

-

[example:misc_exporter_obj exporter / obj ]

-

[example:webgl_shaders_vector WebGL / shaders / vector ]

- +

Code Example

-var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } ); -//create a triangular geometry -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 ) ); + //create a triangular geometry + 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 ) ); -//create a new face using vertices 0, 1, 2 -var normal = new THREE.Vector3( 0, 1, 0 ); //optional -var color = new THREE.Color( 0xffaa00 ); //optional -var materialIndex = 0; //optional -var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex ); + //create a new face using vertices 0, 1, 2 + var normal = new THREE.Vector3( 0, 0, 1 ); //optional + var color = new THREE.Color( 0xffaa00 ); //optional + var materialIndex = 0; //optional + var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex ); -//add the face to the geometry's faces array -geometry.faces.push( face ); + //add the face to the geometry's faces array + geometry.faces.push( face ); -//the face normals and vertex normals can be calculated automatically if not supplied above -geometry.computeFaceNormals(); -geometry.computeVertexNormals(); + //the face normals and vertex normals can be calculated automatically if not supplied above + geometry.computeFaceNormals(); + geometry.computeVertexNormals(); -scene.add( new THREE.Mesh( geometry, material ) ); + scene.add( new THREE.Mesh( geometry, material ) ); +

Examples

+ +

+ [example:svg_sandbox svg / sandbox ]
+ [example:misc_exporter_obj exporter / obj ]
+ [example:webgl_shaders_vector WebGL / shaders / vector ] +

Constructor

@@ -97,7 +98,7 @@

[property:Vector3 normal]

[property:Color color]

Face color - for this to be used a material's [page:Material.vertexColors vertexColors] property - must be set to [page:Materials THREE.FaceColors]. + must be set to *true*.

[property:Array vertexNormals]

@@ -108,7 +109,7 @@

[property:Array vertexNormals]

[property:Array vertexColors]

Array of 3 vertex colors - for these to be used a material's [page:Material.vertexColors vertexColors] property - must be set to [page:Materials THREE.VertexColors]. + must be set to *true*.

diff --git a/docs/api/en/core/Geometry.html b/docs/api/en/core/Geometry.html index 3527ebd81aaa2e..809e1b384ed85b 100644 --- a/docs/api/en/core/Geometry.html +++ b/docs/api/en/core/Geometry.html @@ -21,20 +21,10 @@

[name]

+

Code Example

-

Example

- -
[example:webgl_geometry_minecraft WebGL / geometry / minecraft ]
-
[example:webgl_geometry_minecraft_ao WebGL / geometry / minecraft / ao ]
-
[example:webgl_geometry_nurbs WebGL / geometry / nurbs ]
-
[example:webgl_geometry_spline_editor WebGL / geometry / spline / editor ]
-
[example:webgl_interactive_cubes_gpu WebGL / interactive / cubes / gpu ]
-
[example:webgl_interactive_lines WebGL / interactive / lines ]
-
[example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points ]
-
[example:webgl_interactive_voxelpainter WebGL / interactive / voxelpainter ]
- - - var geometry = new THREE.Geometry(); + + var geometry = new THREE.Geometry(); geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ), @@ -47,6 +37,20 @@

Example

geometry.computeBoundingSphere();
+ +

Examples

+ +

+ [example:webgl_geometry_minecraft WebGL / geometry / minecraft ]
+ [example:webgl_geometry_minecraft_ao WebGL / geometry / minecraft / ao ]
+ [example:webgl_geometry_nurbs WebGL / geometry / nurbs ]
+ [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor ]
+ [example:webgl_interactive_cubes_gpu WebGL / interactive / cubes / gpu ]
+ [example:webgl_interactive_lines WebGL / interactive / lines ]
+ [example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points ]
+ [example:webgl_interactive_voxelpainter WebGL / interactive / voxelpainter ] +

+

Constructor

@@ -203,7 +207,7 @@

Methods

[page:EventDispatcher EventDispatcher] methods are available on this class.

-

[method:null applyMatrix]( [param:Matrix4 matrix] )

+

[method:null applyMatrix4]( [param:Matrix4 matrix] )

Bakes matrix transform directly into vertex coordinates.

[method:Geometry center] ()

diff --git a/docs/api/en/core/InstancedBufferAttribute.html b/docs/api/en/core/InstancedBufferAttribute.html index 4b5cb475905574..ed97d7bee9c911 100644 --- a/docs/api/en/core/InstancedBufferAttribute.html +++ b/docs/api/en/core/InstancedBufferAttribute.html @@ -22,7 +22,7 @@

[name]( [param:TypedArray array], [param:Integer itemSize], [param:Boolean n

Properties

- See [page:BufferAttribute] for inherited properties. +

See [page:BufferAttribute] for inherited properties.

[property:Number meshPerAttribute]

diff --git a/docs/api/en/core/InstancedBufferGeometry.html b/docs/api/en/core/InstancedBufferGeometry.html index 18181f9dc14ff0..19f63eddfeaced 100644 --- a/docs/api/en/core/InstancedBufferGeometry.html +++ b/docs/api/en/core/InstancedBufferGeometry.html @@ -22,7 +22,7 @@

[name]( )

Properties

- See [page:BufferGeometry] for inherited properties. +

See [page:BufferGeometry] for inherited properties.

[property:Number maxInstancedCount]

@@ -30,13 +30,7 @@

[property:Number maxInstancedCount]

Methods

-

See [page:BufferAttribute] for inherited methods.

- -

[property:Number addGroup]( start, count, materialIndex )

-

- -

- +

See [page:BufferGeometry] for inherited methods.

Source

diff --git a/docs/api/en/core/InterleavedBuffer.html b/docs/api/en/core/InterleavedBuffer.html index de462be7daee6d..7e9fb4aaabfbfa 100644 --- a/docs/api/en/core/InterleavedBuffer.html +++ b/docs/api/en/core/InterleavedBuffer.html @@ -16,7 +16,7 @@

[name]

An introduction into interleaved arrays can be found here: [link:https://blog.tojicode.com/2011/05/interleaved-array-basics.html Interleaved array basics]

-

Example

+

Examples

[example:webgl_buffergeometry_points_interleaved webgl / buffergeometry / points / interleaved]

diff --git a/docs/api/en/core/Object3D.html b/docs/api/en/core/Object3D.html index 0c713fc77659cd..9f31fce8eb3e8c 100644 --- a/docs/api/en/core/Object3D.html +++ b/docs/api/en/core/Object3D.html @@ -61,7 +61,8 @@

[property:Integer id]

[property:Layers layers]

The layer membership of the object. The object is only visible if it has at least one - layer in common with the [page:Camera] in use. + layer in common with the [page:Camera] in use. This property can also be used to filter out + unwanted objects in ray-intersection tests when using [page:Raycaster].

[property:Matrix4 matrix]

@@ -204,7 +205,7 @@

[method:this add]( [param:Object3D object], ... )

See [page:Group] for info on manually grouping objects.

-

[method:null applyMatrix]( [param:Matrix4 matrix] )

+

[method:null applyMatrix4]( [param:Matrix4 matrix] )

Applies the matrix transform to the object and updates the object's position, rotation and scale.

[method:this applyQuaternion]( [param:Quaternion quaternion] )

diff --git a/docs/api/en/core/Raycaster.html b/docs/api/en/core/Raycaster.html index 3ba8d30a755fcd..2ca591a703af29 100644 --- a/docs/api/en/core/Raycaster.html +++ b/docs/api/en/core/Raycaster.html @@ -16,7 +16,7 @@

[name]

other things.

-

Example

+

Code Example

var raycaster = new THREE.Raycaster(); var mouse = new THREE.Vector2(); @@ -54,8 +54,11 @@

Example

window.requestAnimationFrame(render);
-
- Examples: [example:webgl_interactive_cubes Raycasting to a Mesh]
+ +

Examples

+ +

+ [example:webgl_interactive_cubes Raycasting to a Mesh]
[example:webgl_interactive_cubes_ortho Raycasting to a Mesh in using an OrthographicCamera]
[example:webgl_interactive_buffergeometry Raycasting to a Mesh with BufferGeometry]
[example:webgl_instancing_raycast Raycasting to a InstancedMesh]
@@ -64,13 +67,8 @@

Example

[example:webgl_geometry_terrain_raycast Terrain raycasting]
[example:webgl_interactive_voxelpainter Raycasting to paint voxels]
[example:webgl_raycast_texture Raycast to a Texture] -
- - -

-

Constructor

[name]( [param:Vector3 origin], [param:Vector3 direction], [param:Float near], [param:Float far] ) {

@@ -93,11 +91,6 @@

[property:float far]

This value shouldn't be negative and should be larger than the near property.

-

[property:float linePrecision]

-

- The precision factor of the raycaster when intersecting [page:Line] objects. -

-

[property:float near]

The near factor of the raycaster. This value indicates which objects can be discarded based on the distance. @@ -112,6 +105,18 @@

[property:Camera camera]

Defaults to null.

+

[property:Layers layers]

+

+ Used by [name] to selectively ignore 3D objects when performing intersection tests. The following code example ensures that + only 3D objects on layer *1* will be honored by the instance of [name]. + + + raycaster.layers.set( 1 ); + object.layers.enable( 1 ); + + +

+

[property:Object params]

An object with the following properties: @@ -119,13 +124,14 @@

[property:Object params]

{ Mesh: {}, - Line: {}, + Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} } + Where threshold is the precision of the raycaster when intersecting objects, in world units.

[property:Ray ray]

diff --git a/docs/api/en/core/Uniform.html b/docs/api/en/core/Uniform.html index 7fe057ff857241..252e518149f3bc 100644 --- a/docs/api/en/core/Uniform.html +++ b/docs/api/en/core/Uniform.html @@ -13,18 +13,18 @@

[name]

Uniforms are global [link:https://www.opengl.org/documentation/glsl/ GLSL] variables. They are passed to shader programs.

-

Example

+

Code Example

When declaring a uniform of a [page:ShaderMaterial], it is declared by value or by object.

uniforms: { time: { value: 1.0 }, - resolution: new THREE.Uniform(new THREE.Vector2()) - } + resolution: new Uniform( new Vector2() ) + }; -

Uniform types

+

Uniform types

Each uniform must have a *value* property. The type of the value must correspond to the @@ -50,6 +50,10 @@

Uniform types

int [page:Number] + + uint (WebGL 2) + [page:Number] + float [page:Number] @@ -182,6 +186,63 @@

Uniform types

(*) Same for an (innermost) array (dimension) of the same GLSL type, containing the components of all vectors or matrices in the array.

+

Structured Uniforms

+ +

+ Sometimes you want to organize uniforms as *structs* in your shader code. The following style must be used so *three.js* is able + to process structured uniform data. +

+ + uniforms = { + data: { + value: { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + } + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data; + + +

Structured Uniforms with Arrays

+ +

+ It's also possible to manage *structs* in arrays. The syntax for this use case looks like so: +

+ + var entry1 = { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + }; + var entry2 = { + position: new Vector3( 1, 1, 1 ), + direction: new Vector3( 0, 1, 0 ) + }; + + uniforms = { + data: { + value: [ entry1, entry2 ] + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data[ 2 ]; + +

Constructor

[name]( [param:Object value] )

@@ -202,8 +263,7 @@

[method:Uniform clone]()

Returns a clone of this uniform.
If the uniform's value property is an [page:Object] with a clone() method, this is used, otherwise the value is copied by assignment. - Array values are shared between cloned [page:Uniform]s.

- See [example:webgldeferred_animation WebGL deferred animation] for an example of this method in use. + Array values are shared between cloned [page:Uniform]s.

Source

diff --git a/docs/api/en/core/bufferAttributeTypes/BufferAttributeTypes.html b/docs/api/en/core/bufferAttributeTypes/BufferAttributeTypes.html index de3addae7d08cf..6559473e9c0133 100644 --- a/docs/api/en/core/bufferAttributeTypes/BufferAttributeTypes.html +++ b/docs/api/en/core/bufferAttributeTypes/BufferAttributeTypes.html @@ -46,14 +46,20 @@

TypedBufferAttribute( [param:Array_or_Integer array], [param:Integer itemSiz

Properties

- See the [page:BufferAttribute] page for inherited properties. +

+ See the [page:BufferAttribute] page for inherited properties. +

Methods

- See the [page:BufferAttribute] page for inherited methods. +

+ See the [page:BufferAttribute] page for inherited methods. +

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js src/core/BufferAttribute.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js src/core/BufferAttribute.js] +

diff --git a/docs/api/en/deprecated/DeprecatedList.html b/docs/api/en/deprecated/DeprecatedList.html deleted file mode 100644 index 7f18731ef6949e..00000000000000 --- a/docs/api/en/deprecated/DeprecatedList.html +++ /dev/null @@ -1,609 +0,0 @@ - - - - - - - - - - -

Deprecated API List

- -

- As three.js has a rapidly evolving interface, you may come across examples that - suggest the use of API elements that are no longer part of the core.

- - Below is a list of such elements, along with info regarding their replacements. -

- - - - - - - - - - -

Audio

- -

[page:Audio]

-

Audio.load has been deprecated. Use [page:AudioLoader] instead.

- -

[page:AudioAnalyser]

-

AudioAnalyser.getData() has been renamed to [page:AudioAnalyser.getFrequencyData]().

- -

[page:BinaryTextureLoader]

-

BinaryTextureLoader has been renamed to [page:DataTextureLoader].

- - - - - - - - - - - -

Buffers

- -

[page:BufferAttribute]

-

BufferAttribute.length has been renamed to [page:BufferAttribute.count].

-

BufferAttribute.copyIndicesArray() has been removed.

- - -

[page:DynamicBufferAttribute]

-

DynamicBufferAttribute has been removed. Use [page:BufferAttribute.setDynamic]( true ) instead.

- -

[page:Int8Attribute]

-

Int8Attribute has been removed. Use [page:BufferAttributeTypes Int8BufferAttribute] instead.

- -

[page:Uint8Attribute]

-

Uint8Attribute has been removed. Use [page:BufferAttributeTypes Uint8BufferAttribute] instead.

- -

[page:Uint8ClampedAttribute]

-

Uint8ClampedAttribute has been removed. Use [page:BufferAttributeTypes Uint8ClampedBufferAttribute] instead.

- -

[page:Int16Attribute]

-

Int16Attribute has been removed. Use [page:BufferAttributeTypes Int16BufferAttribute] instead.

- -

[page:Uint16Attribute]

-

Uint16Attribute has been removed. Use [page:BufferAttributeTypes Uint16BufferAttribute] instead.

- -

[page:Int32Attribute]

-

Int32Attribute has been removed. Use [page:BufferAttributeTypes Int32BufferAttribute] instead.

- -

[page:Uint32Attribute]

-

Uint32Attribute has been removed. Use [page:BufferAttributeTypes Uint32BufferAttribute] instead.

- -

[page:Float32Attribute]

-

Float32Attribute has been removed. Use [page:BufferAttributeTypes Float32BufferAttribute] instead.

- -

[page:Float64Attribute]

-

Float64Attribute has been removed. Use [page:BufferAttributeTypes Float64BufferAttribute] instead.

- - - - - - - -

Cameras

- -

[page:PerspectiveCamera]

-

- PerspectiveCamera.setLens() is deprecated. Use [page:PerspectiveCamera.setFocalLength]() - and [page:PerspectiveCamera.filmGauge]() for a photographic setup. -

- - - - - - - -

Constants

- -

[page:LineStrip]

- -

[page:LinePieces]

-

- LinePieces mode is no longer supported for [page:Line]s. Create a [page:LineSegments] instead. -

- - - - - -

Core

- -

[page:EventDispatcher]

-

EventDispatcher.apply has been removed. Inherit or Object.assign the prototype to mix-in instead.

- -

[page:Raycaster]

-

Raycaster.params.PointCloud has been renamed to [page:Raycaster.params.Points].

- - -

[page:Uniform]

-

- Uniform.dynamic has been removed. Use object.onBeforeRender() instead.

- - Uniform.onUpdate has been removed. Use object.onBeforeRender() instead. -

- - - - - - -

Extras

- -

[page:ClosedSplineCurve3]

-

ClosedSplineCurve3 has been deprecated. Use [page:CatmullRomCurve3] instead.

- -

[page:SplineCurve3]

-

SplineCurve3 has been deprecated. Use [page:CatmullRomCurve3] instead.

- - - - - - - -

Geometry

- -

- Geometry.computeTangents() has been removed.

- - Geometry.computeLineDistances() has been removed. Use [page:Line.computeLineDistances] instead.

-

- -

[page:BufferGeometry]

-

- BufferGeometry.addIndex has been renamed to [page:BufferGeometry.setIndex].

- - BufferGeometry.addDrawCall is now [page:BufferGeometry.addGroup].

- - BufferGeometry.clearDrawCalls is now [page:BufferGeometry.clearGroups].

- - BufferGeometry.computeTangents has been removed.

- - BufferGeometry.computeOffsets has been removed.

- - BufferGeometry.drawcalls has been renamed to [page:BufferGeometry.groups].

- - BufferGeometry.offsets has been renamed to [page:BufferGeometry.groups].

- -

- -

[page:CubeGeometry]

-

CubeGeometry has been renamed to [page:BoxGeometry].

- -

[page:Geometry]

-

Geometry.computeTangents() has been removed.

- -

[page:GeometryUtils]

-

- GeometryUtils.merge has been moved to [page:Geometry]. Use [page:Geometry.merge]( geometry2, matrix, materialIndexOffset ) instead.

- - GeometryUtils.center has been moved to [page:Geometry]. Use [page:Geometry.center]( ) instead. -

- -

[page:Plane]

-

- Plane.isIntersectionLine() has been renamed to [page:Plane.intersectsLine](). -

- - - - - - - - -

Helpers

- -

[page:BoundingBoxHelper]

-

BoundingBoxHelper has been deprecated. Use [page:BoxHelper] instead.

- -

[page:EdgesHelper]

-

EdgesHelper has been removed. Use [page:EdgesGeometry] instead.

- -

[page:GridHelper]

-

GridHelper.setColors() has been deprecated, pass them in the constructor instead.

- -

[page:WireframeHelper WireframeHelper]

-

WireframeHelper has been removed. Use [page:WireframeGeometry] instead.

- - - - -

Lights

- -

[page:Light]

-

- Light.onlyShadow has been removed.

- - Light.shadowCameraLeft is now [page:Light.shadow.camera.left].

- - Light.shadowCameraRight is now [page:Light.shadow.camera.right].

- - Light.shadowCameraTop is now [page:Light.shadow.camera.top].

- - Light.shadowCameraBottom is now [page:Light.shadow.camera.bottom].

- - Light.shadowCameraNear is now [page:Light.shadow.camera.near].

- - Light.shadowCameraFar is now [page:Light.shadow.camera.far].

- - Light.shadowCameraVisible has been removed. Use [page:CameraHelper] ( light.shadow.camera ) instead.

- - Light.shadowMapWidth is now [page:Light.shadow.mapSize.width].

- - Light.shadowMapHeight is now [page:Light.shadow.mapSize.height]. -

- -

Loaders

- -

[page:XHRLoader]

-

XHRLoader has been renamed to [page:FileLoader].

- -

[page:JSONLoader]

-

JSONLoader has been removed from core.

- -

Maths

- -

[page:Box2]

-

- Box2.center has been renamed to [page:Box2.getCenter]().

- - Box2.empty has been renamed to [page:Box2.isEmpty]().

- - Box2.isIntersectionBox has been renamed to [page:Box2.intersectsBox]().

- - Box2.size has been renamed to [page:Box2.getSize](). - -

- -

[page:Box3]

-

- Box3.center has been renamed to [page:Box3.getCenter]().

- - Box3.empty has been renamed to [page:Box3.isEmpty]().

- - Box3.isIntersectionBox has been renamed to [page:Box3.intersectsBox]().

- - Box3.isIntersectionSphere has been renamed to [page:Box3.intersectsSphere]().

- - Box3.size has been renamed to [page:Box3.getSize](). -

- -

[page:Face4]

-

Face4 has been removed. Use [page:Face3] instead.

- -

[page:Line3]

-

Line3.center has been renamed to [page:Line3.getCenter]().

- -

[page:Math]

-

- Math.random16() has been deprecated. Use Math.random() instead. -

- -

[page:Matrix3]

-

- Matrix3.flattenToArrayOffset is deprecated. Use [page:Matrix3.toArray]() instead.

- - Matrix3.multiplyVector3 has been removed. Use vector.applyMatrix3( matrix ) instead.

- - Matrix3.multiplyVector3Array has been renamed to [page:Matrix3.applyToVector3Array]( array ).

- - Matrix3.applyToBuffer has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.

- - Matrix3.applyToVector3Array has been removed. -

- -

[page:Matrix4]

-

- Matrix4.flattenToArrayOffset() is deprecated. Use [page:Matrix4.toArray]() instead.

- - Matrix4.extractPosition() has been renamed to [page:Matrix4.copyPosition]( matrix ).

- - Matrix4.getPosition() has been removed. Use [page:Vector3.setFromMatrixPosition]( matrix ) instead.

- - Matrix4.setRotationFromQuaternion() has been renamed to [page:Matrix4.makeRotationFromQuaternion]( quaternion ).

- - Matrix4.multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.

- - Matrix4.multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.

- - Matrix4.multiplyVector3Array() has been renamed to [page:Matrix4.applyToVector3Array] ( array ).

- - Matrix4.rotateAxis() has been removed. Use [page:Matrix4.transformDirection]( matrix ) instead.

- - Matrix4.crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.

- - Matrix4.rotateX() has been removed.

- - Matrix4.rotateY() has been removed.

- - Matrix4.rotateZ() has been removed.

- - Matrix4.rotateByAxis() has been removed.

- - Matrix4.applyToBuffer() has been removed. Use matrix.applyToBufferAttribute() instead.

- - Matrix4.applyToVector3Array() has been removed.

- - Matrix4.makeFrustum() has been removed. Use [page:Matrix4.makePerspective]( left, right, top, bottom, near, far ) instead. -

- - -

[page:Quaternion.multiplyVector3]

-

Quaternion.multiplyVector3() has been removed. Use vector.applyQuaternion( quaternion ) instead.

- -

[page:Ray]

-

- Ray.isIntersectionBox() has been renamed to [page:Ray.intersectsBox]().

- - Ray.isIntersectionPlane has been renamed to [page:Ray.intersectsPlane].

- - Ray.isIntersectionSphere has been renamed to [page:Ray.intersectsSphere]. -

- -

[page:Triangle]

-

- Triangle.area() has been renamed to [page:Triangle.getArea]().

- Triangle.barycoordFromPoint() has been renamed to [page:Triangle.getBarycoord]().

- Triangle.midpoint() has been renamed to [page:Triangle.getMidpoint]().

- Triangle.normal() has been renamed to [page:Triangle.getNormal]().

- Triangle.plane() has been renamed to [page:Triangle.getPlane](). -

- -

[page:Vector2]

-

- Vector2.fromAttribute() has been renamed to [page:Vector2.fromBufferAttribute](). -

- -

[page:Vector3]

-

- Vector3.setEulerFromRotationMatrix() has been removed. Use [page:Euler.setFromRotationMatrix]() instead.

- - Vector3.setEulerFromQuaternion() has been removed. Use [page:Euler.setFromQuaternion]() instead.

- - Vector3.getPositionFromMatrix() has been renamed to [page:Vector3.setFromMatrixPosition]().

- - Vector3.getScaleFromMatrix() has been renamed to [page:Vector3.setFromMatrixScale]().

- - Vector3.getColumnFromMatrix() has been renamed to [page:Vector3.setFromMatrixColumn]().

- - Vector3.applyProjection() has been removed. Use [page:Vector3.applyMatrix4]() instead.

- - Vector3.fromAttribute() has been renamed to [page:Vector3.fromBufferAttribute](). -

- -

[page:Vector4]

-

- Vector4.fromAttribute() has been renamed to [page:Vector4.fromBufferAttribute](). -

- -

[page:Vertex]

-

Vertex has been removed. Use [page:Vector3] instead.

- -

[page:Spline]

-

Spline has been removed. Use [page:CatmullRomCurve3] instead.

- - - - - - - - - - - - -

Materials

- -

[page:Material]

-

- Material.wrapAround has been removed.

- - Material.wrapRGB has been removed. - -

- -

[page:MeshFaceMaterial]

-

MeshFaceMaterial has been removed. Use an array of materials instead.

- -

[page:MultiMaterial]

-

MultiMaterial has been removed. Use an array of materials instead.

- -

[page:MeshPhongMaterial]

-

MeshPhongMaterial.metal has been removed. Use [page:MeshStandardMaterial] instead.

- -

[page:ParticleBasicMaterial]

-

ParticleBasicMaterial has been renamed to [page:PointsMaterial].

- -

[page:ParticleSystemMaterial]

-

ParticleBasicMaterial has been renamed to [page:PointsMaterial].

- -

[page:PointCloudMaterial]

-

PointCloudMaterial has been renamed to [page:PointsMaterial].

- -

[page:ShaderMaterial.derivatives]

-

ShaderMaterial.derivatives has been moved to [page:ShaderMaterial.extensions.derivatives].

- - - - - - - - -

Objects

- -

[page:LOD.objects]

-

LOD.objects has been renamed to [page:LOD.levels].

- -

[page:Object3D]

-

- Object3D.eulerOrder is now [page:Object3D.rotation.order].

- - Object3D.getChildByName() has been renamed to [page:Object3D.getObjectByName]().

- - Object3D.renderDepth has been removed. Use [page:Object3D.renderOrder] instead.

- - Object3D.translate() has been removed. Use [page:Object3D.translateOnAxis]( axis, distance ) instead.

- - Object3D.useQuaternion has been removed. The library now uses quaternions by default. -

- -

[page:LensFlare]

-

- LensFlare has been moved to [link:https://github.com/mrdoob/three.js/blob/master/examples/js/objects/Lensflare.js /examples/js/objects/Lensflare.js]. -

- - -

[page:Particle]

-

Particle has been renamed to [page:Sprite].

- -

[page:ParticleSystem]

-

ParticleSystem has been renamed to [page:Points].

- -

[page:PointCloud]

-

PointCloud has been renamed to [page:Points].

- -

[page:Shape]

-

- Shape.extrude has been removed. Use [page:ExtrudeGeometry] instead.

- - Shape.makeGeometry has been removed. Use [page:ShapeGeometry] instead. -

- -

[page:SkinnedMesh]

-

- SkinnedMesh.initBones() has been removed. -

- - -

Renderers

- -

[page:CanvasRenderer]

-

- CanvasRenderer has been removed. -

- -

[page:Projector]

-

- Projector has been moved to - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/Projector.js /examples/js/renderers/Projector.js].

- - Projector.projectVector() is now [page:Vector.project]().

- - Projector.unprojectVector() is now [page:Vector.unproject]().

- - Projector:.pickingRay() is now [page:Raycaster.setFromCamera](). -

- -

[page:WebGLProgram]

-

- WebGLProgram.uniforms is now [page:WebGLProgram.getUniforms]().

- - WebGLProgram.attributes is now [page:WebGLProgram.getAttributes](). -

- -

[page:WebGLRenderer]

-

- WebGLRenderer.supportsFloatTextures() is now [page:WebGLRenderer.extensions.get]( 'OES_texture_float' ).

- - WebGLRenderer.supportsHalfFloatTextures() is now [page:WebGLRenderer.extensions.get]( 'OES_texture_half_float' ).

- - WebGLRenderer.supportsStandardDerivatives() is now [page:WebGLRenderer.extensions.get]( 'OES_standard_derivatives' ).

- - WebGLRenderer.supportsCompressedTextureS3TC() is now [page:WebGLRenderer.extensions.get]( 'WEBGL_compressed_texture_s3tc' ).

- - WebGLRenderer.supportsCompressedTexturePVRTC() is now [page:WebGLRenderer.extensions.get]( 'WEBGL_compressed_texture_pvrtc' ).

- - WebGLRenderer.supportsBlendMinMax() is now [page:WebGLRenderer.extensions.get]( 'EXT_blend_minmax' ).

- - WebGLRenderer.supportsVertexTextures() is now [page:WebGLRenderer.capabilities.vertexTextures].

- - WebGLRenderer.supportsInstancedArrays() is now [page:WebGLRenderer.extensions.get]( 'ANGLE_instanced_arrays' ).

- - WebGLRenderer.enableScissorTest() is now [page:WebGLRenderer.setScissorTest]().

- - WebGLRenderer.initMaterial() has been removed.

- - WebGLRenderer.addPrePlugin() has been removed.

- - WebGLRenderer.addPostPlugin() has been removed.

- - WebGLRenderer.updateShadowMap() has been removed.

- - WebGLRenderer.setFaceCulling() has been removed.

- - WebGLRenderer.setTexture is deprecated, use [page:WebGLRenderer.setTexture2D]() instead.

- - WebGLRenderer.shadowMapEnabled is now [page:WebGLRenderer.shadowMap.enabled].

- - WebGLRenderer.shadowMapType is now [page:WebGLRenderer.shadowMap.type].

- - WebGLRenderer.shadowMapCullFace has been removed. Set [page:Material.shadowSide] instead.

- - WebGLRenderer.shadowMap.cullFace has been removed. Set [page:Material.shadowSide] instead.

- - WebGLRenderer.shadowMap.renderReverseSided has been removed. Set [page:Material.shadowSide] instead.

- - WebGLRenderer.shadowMap.renderSingleSided has been removed. Set [page:Material.shadowSide] instead. - -

- -

[page:WebGLRenderTarget]

-

- WebGLRenderTarget.wrapS is now [page:WebGLRenderTarget.texture.wrapS].

- - WebGLRenderTarget.wrapT is now [page:WebGLRenderTarget.texture.wrapT].

- - WebGLRenderTarget.magFilter is now [page:WebGLRenderTarget.texture.magFilter].

- - WebGLRenderTarget.minFilter is now [page:WebGLRenderTarget.texture.minFilter].

- - WebGLRenderTarget.anisotropy is now [page:WebGLRenderTarget.texture.anisotropy].

- - WebGLRenderTarget.offset is now [page:WebGLRenderTarget.texture.offset].

- - WebGLRenderTarget.repeat is now [page:WebGLRenderTarget.texture.repeat].

- - WebGLRenderTarget.format is now [page:WebGLRenderTarget.texture.format].

- - WebGLRenderTarget.type is now [page:WebGLRenderTarget.texture.type].

- - WebGLRenderTarget.generateMipmaps is now [page:WebGLRenderTarget.texture.generateMipmaps]. -

- - -

Textures

- -

[page:ImageUtils]

-

- ImageUtils.loadTexture has been deprecated. Use [page:TextureLoader] instead.

- - ImageUtils.loadTextureCube has been deprecated. Use [page:CubeTextureLoader] instead.

- - ImageUtils.loadCompressedTexture has been removed. Use [page:DDSLoader] instead.

- - ImageUtils.loadCompressedTextureCube has been removed. Use [page:DDSLoader] instead. -

- - -

Source

- -

- [link:https://github.com/mrdoob/three.js/blob/master/src/Three.Legacy.js src/Three.Legacy.js] -

- - - diff --git a/docs/api/en/extras/Earcut.html b/docs/api/en/extras/Earcut.html index 52bf8e7651a379..077172f9b2bb44 100644 --- a/docs/api/en/extras/Earcut.html +++ b/docs/api/en/extras/Earcut.html @@ -18,10 +18,11 @@

Methods

[method:Array triangulate]( data, holeIndices, dim )

- data -- A flat array of vertice coordinates.

- holeIndices -- An array of hole indices if any.

- dim -- The number of coordinates per vertice in the input array.

+ data -- A flat array of vertex coordinates.
+ holeIndices -- An array of hole indices if any.
+ dim -- The number of coordinates per vertex in the input array.

+ Triangulates the given shape definition by returning an array of triangles. A triangle is defined by three consecutive integers representing vertex indices.

Source

diff --git a/docs/api/en/extras/ImageUtils.html b/docs/api/en/extras/ImageUtils.html new file mode 100644 index 00000000000000..1f850372034bee --- /dev/null +++ b/docs/api/en/extras/ImageUtils.html @@ -0,0 +1,32 @@ + + + + + + + + + + +

[name]

+ +

+ A class containing utility functions for images. +

+ +

Methods

+ +

[method:String getDataURL]( [param:HTMLCanvasElement image] | [param:HTMLImageElement image] | [param:ImageBitmap image] )

+

+ image -- The image object.

+ + Returns a data URI containing a representation of the given image. +

+ +

Source

+ +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

+ + diff --git a/docs/api/en/extras/PMREMGenerator.html b/docs/api/en/extras/PMREMGenerator.html new file mode 100644 index 00000000000000..e5fa7605922cdc --- /dev/null +++ b/docs/api/en/extras/PMREMGenerator.html @@ -0,0 +1,80 @@ + + + + + + + + + + +

[name]

+ +

+ This class generates a Prefiltered, Mipmapped Radiance Environment Map (PMREM) from a cubeMap environment texture. + This allows different levels of blur to be quickly accessed based on material roughness. It is packed into a special + CubeUV format that allows us to perform custom interpolation so that we can support nonlinear formats such as RGBE. + Unlike a traditional mipmap chain, it only goes down to the LOD_MIN level (above), and then creates extra even more + filtered 'mips' at the same LOD_MIN resolution, associated with higher roughness levels. In this way we maintain + resolution to smoothly interpolate diffuse lighting while limiting sampling computation. +

+ +

Constructor

+ +

[name]( [param:WebGLRenderer renderer] )

+

+ This constructor creates a new [name]. +

+ +

Methods

+ +

[method:WebGLRenderTarget fromScene]( [param:Scene scene], [param:Number sigma], [param:Number near], [param:Number far] )

+

+ [page:Scene scene] - The given scene.
+ [page:Number sigma] - (optional) Specifies a blur radius in radians to be applied to the scene before PMREM generation. Default is *0*.
+ [page:Number near] - (optional) The near plane value. Default is *0.1*.
+ [page:Number far] - (optional) The far plane value. Default is *100*.

+ + Generates a PMREM from a supplied Scene, which can be faster than using an image if networking bandwidth is low. + Optional near and far planes ensure the scene is rendered in its entirety (the cubeCamera is placed at the origin). +

+ +

[method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangular] )

+

+ [page:Texture equirectangular] - The equirectangular texture.

+ + Generates a PMREM from an equirectangular texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat). + The ideal input image size is 1k (1024 x 512), as this matches best with the 256 x 256 cubemap output. +

+ +

[method:WebGLRenderTarget fromCubemap]( [param:CubeTexture cubemap] )

+

+ [page:CubeTexture cubemap] - The cubemap texture.

+ + Generates a PMREM from an cubemap texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat). + The ideal input cube size is 256 x 256, as this matches best with the 256 x 256 cubemap output. +

+ +

[method:void compileCubemapShader]()

+

+ Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency. +

+ +

[method:void compileEquirectangularShader]()

+

+ Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency. +

+ +

[method:void dispose]()

+

+ Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, so you should not need more than one + PMREMGenerator object. If you do, calling dispose() on one of them will cause any others to also become unusable. +

+ +

Source

+ +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

+ + diff --git a/docs/api/en/extras/ShapeUtils.html b/docs/api/en/extras/ShapeUtils.html index 4919b52ecbe4be..9576fa6d05a3b4 100644 --- a/docs/api/en/extras/ShapeUtils.html +++ b/docs/api/en/extras/ShapeUtils.html @@ -24,11 +24,10 @@

[method:Number area]( contour )

contour -- 2D polygon. An array of THREE.Vector2()

- Calculate area of a ( 2D ) contour polygon.

- + Calculate area of a ( 2D ) contour polygon.

-

[method:Boolean isClockwise]( pts )

+

[method:Boolean isClockWise]( pts )

pts -- points defining a 2D polygon

diff --git a/docs/api/en/extras/core/Curve.html b/docs/api/en/extras/core/Curve.html index 9abd7140ab6e51..f7a8e5be89fd37 100644 --- a/docs/api/en/extras/core/Curve.html +++ b/docs/api/en/extras/core/Curve.html @@ -79,22 +79,30 @@

[method:Float getUtoTmapping]( [param:Float u], [param:Float distance] )

-

[method:Vector getTangent]( [param:Float t] )

+

[method:Vector getTangent]( [param:Float t, [param:Vector optionalTarget] ] )

+ [page:Float t] - A position on the curve. Must be in the range [ 0, 1 ].
+ [page:Vector optionalTarget] — (optional) If specified, the result will be copied into this Vector, + otherwise a new Vector will be created.

+ Returns a unit vector tangent at t. If the derived curve does not implement its tangent derivation, two points a small delta apart will be used to find its gradient which seems to give a reasonable approximation.

-

[method:Vector getTangentAt]( [param:Float u] )

+

[method:Vector getTangentAt]( [param:Float u, [param:Vector optionalTarget] ] )

+ [page:Float u] - A position on the curve according to the arc length. Must be in the range [ 0, 1 ].
+ [page:Vector optionalTarget] — (optional) If specified, the result will be copied into this Vector, + otherwise a new Vector will be created.

+ Returns tangent at a point which is equidistant to the ends of the curve from the point given in [page:.getTangent].

[method:Object computeFrenetFrames]( [param:Integer segments], [param:Boolean closed] )

- Generates the Frenet Frames. Used in geometries like [page:TubeGeometry] or [page:ExtrudeGeometry]. + Generates the Frenet Frames. Requires a curve definition in 3D space. Used in geometries like [page:TubeGeometry] or [page:ExtrudeGeometry].

[method:Curve clone]()

diff --git a/docs/api/en/extras/core/CurvePath.html b/docs/api/en/extras/core/CurvePath.html index cbc808ce405da7..02103ab639d316 100644 --- a/docs/api/en/extras/core/CurvePath.html +++ b/docs/api/en/extras/core/CurvePath.html @@ -52,6 +52,26 @@

[method:null closePath]()

[method:Float getCurveLengths]()

Adds together the lengths of the curves in the [page:.curves] array.

+

[method:Vector getPoint]( [param:Float t] )

+

+ [page:Float t] - A position on the curve. Must be in the range [ 0, 1 ].

+ + Returns a vector for a given position on the curve path. +

+ +

[method:Array getPoints]( [param:Integer divisions] )

+

+ divisions -- number of pieces to divide the curve into. Default is *12*.

+ + Returns a set of divisions + 1 points using getPoint( t ). +

+ +

[method:Array getSpacedPoints]( [param:Integer divisions] )

+

+ divisions -- number of pieces to divide the curve into. Default is *40*.

+ + Returns a set of divisions + 1 equi-spaced points using getPointAt( u ). +

Source

diff --git a/docs/api/en/extras/core/Interpolations.html b/docs/api/en/extras/core/Interpolations.html index 52feff3bee1e63..5423e3bdc3ba26 100644 --- a/docs/api/en/extras/core/Interpolations.html +++ b/docs/api/en/extras/core/Interpolations.html @@ -11,7 +11,7 @@

[name]

- TODO + [name] contains spline and Bézier functions internally used by concrete curve classes.

Methods

diff --git a/docs/api/en/extras/core/Path.html b/docs/api/en/extras/core/Path.html index f43d9b01e4e306..9ce6d6fa23b6f2 100644 --- a/docs/api/en/extras/core/Path.html +++ b/docs/api/en/extras/core/Path.html @@ -16,22 +16,22 @@

[name]

A 2D path representation. The class provides methods for creating paths and contours of 2D shapes similar to the 2D Canvas API.

-

Example

+

Code Example

- var path = new THREE.Path(); + var path = new THREE.Path(); - path.lineTo( 0, 0.8 ); - path.quadraticCurveTo( 0, 1, 0.2, 1 ); - path.lineTo( 1, 1 ); + path.lineTo( 0, 0.8 ); + path.quadraticCurveTo( 0, 1, 0.2, 1 ); + path.lineTo( 1, 1 ); - var points = path.getPoints(); + var points = path.getPoints(); - var geometry = new THREE.BufferGeometry().setFromPoints( points ); - var material = new THREE.LineBasicMaterial( { color: 0xffffff } ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var material = new THREE.LineBasicMaterial( { color: 0xffffff } ); - var line = new THREE.Line( geometry, material ); - scene.add( line ); + var line = new THREE.Line( geometry, material ); + scene.add( line ); diff --git a/docs/api/en/extras/core/Shape.html b/docs/api/en/extras/core/Shape.html index 0f0b719c2febe2..2c5e6156b3a9a4 100644 --- a/docs/api/en/extras/core/Shape.html +++ b/docs/api/en/extras/core/Shape.html @@ -17,6 +17,8 @@

[name]

[page:ShapeGeometry], to get points, or to get triangulated faces.

+

Code Example

+ var heartShape = new THREE.Shape(); @@ -30,7 +32,7 @@

[name]

var extrudeSettings = { amount: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 }; - var geometry = new THREE.ExtrudeGeometry( heartShape, extrudeSettings ); + var geometry = new THREE.ExtrudeBufferGeometry( heartShape, extrudeSettings ); var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
diff --git a/docs/api/en/extras/core/ShapePath.html b/docs/api/en/extras/core/ShapePath.html index 2fabd87e9aa082..62e58fd1db8d3f 100644 --- a/docs/api/en/extras/core/ShapePath.html +++ b/docs/api/en/extras/core/ShapePath.html @@ -8,8 +8,6 @@ - [page:Curve] → [page:CurvePath] → -

[name]

@@ -18,9 +16,10 @@

[name]

series of paths.

-

Example

- - [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2] +

Examples

+

+ [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2] +

Constructor

@@ -89,6 +88,8 @@

[method:Array toShapes]( [param:Boolean isCCW], [param:Boolean noHoles] )Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/extras/core/ShapePath.js src/extras/core/ShapePath.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/extras/core/ShapePath.js src/extras/core/ShapePath.js] +

diff --git a/docs/api/en/extras/curves/ArcCurve.html b/docs/api/en/extras/curves/ArcCurve.html index 5201b4447c4d34..3d4fe504ffd41f 100644 --- a/docs/api/en/extras/curves/ArcCurve.html +++ b/docs/api/en/extras/curves/ArcCurve.html @@ -12,7 +12,7 @@

[name]

-

Alias for [page:EllipseCurve]

+

Alias for [page:EllipseCurve].

Properties

See the [page:EllipseCurve] class for common properties.

diff --git a/docs/api/en/extras/curves/CatmullRomCurve3.html b/docs/api/en/extras/curves/CatmullRomCurve3.html index 598dde4f056387..788fe0e1e66fd5 100644 --- a/docs/api/en/extras/curves/CatmullRomCurve3.html +++ b/docs/api/en/extras/curves/CatmullRomCurve3.html @@ -15,29 +15,32 @@

[name]

Create a smooth 3d spline curve from a series of points using the [link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom] algorithm.

-

Example

+

Code Example

- -//Create a closed wavey loop -var curve = new THREE.CatmullRomCurve3( [ - new THREE.Vector3( -10, 0, 10 ), - new THREE.Vector3( -5, 5, 5 ), - new THREE.Vector3( 0, 0, 0 ), - new THREE.Vector3( 5, -5, 5 ), - new THREE.Vector3( 10, 0, 10 ) -] ); + + //Create a closed wavey loop + var curve = new THREE.CatmullRomCurve3( [ + new THREE.Vector3( -10, 0, 10 ), + new THREE.Vector3( -5, 5, 5 ), + new THREE.Vector3( 0, 0, 0 ), + new THREE.Vector3( 5, -5, 5 ), + new THREE.Vector3( 10, 0, 10 ) + ] ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); + -

[example:webgl_geometry_extrude_splines geometry / extrude / splines]

+

Examples

+

+ [example:webgl_geometry_extrude_splines WebGL / geometry / extrude / splines] +

Constructor

diff --git a/docs/api/en/extras/curves/CubicBezierCurve.html b/docs/api/en/extras/curves/CubicBezierCurve.html index 3798503652bb89..4fa7e032610ead 100644 --- a/docs/api/en/extras/curves/CubicBezierCurve.html +++ b/docs/api/en/extras/curves/CubicBezierCurve.html @@ -18,24 +18,24 @@

[name]

defined by a start point, endpoint and two control points.

-

Example

+

Code Example

- -var curve = new THREE.CubicBezierCurve( - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( -5, 15 ), - new THREE.Vector2( 20, 15 ), - new THREE.Vector2( 10, 0 ) -); + + var curve = new THREE.CubicBezierCurve( + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( -5, 15 ), + new THREE.Vector2( 20, 15 ), + new THREE.Vector2( 10, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

Constructor

diff --git a/docs/api/en/extras/curves/CubicBezierCurve3.html b/docs/api/en/extras/curves/CubicBezierCurve3.html index 2279f4439da6a4..cc53e242b56d33 100644 --- a/docs/api/en/extras/curves/CubicBezierCurve3.html +++ b/docs/api/en/extras/curves/CubicBezierCurve3.html @@ -18,25 +18,25 @@

[name]

defined by a start point, endpoint and two control points.

-

Example

+

Code Example

- -var curve = new THREE.CubicBezierCurve3( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( -5, 15, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) -); + + var curve = new THREE.CubicBezierCurve3( + new THREE.Vector3( -10, 0, 0 ), + new THREE.Vector3( -5, 15, 0 ), + new THREE.Vector3( 20, 15, 0 ), + new THREE.Vector3( 10, 0, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); - +

Constructor

diff --git a/docs/api/en/extras/curves/EllipseCurve.html b/docs/api/en/extras/curves/EllipseCurve.html index a2fb5841a34bb8..261ad2b238d073 100644 --- a/docs/api/en/extras/curves/EllipseCurve.html +++ b/docs/api/en/extras/curves/EllipseCurve.html @@ -17,25 +17,25 @@

[name]

[page:Number xRadius] equal to the [page:Number yRadius] will result in a circle.

-

Example

+

Code Example

- -var curve = new THREE.EllipseCurve( - 0, 0, // ax, aY - 10, 10, // xRadius, yRadius - 0, 2 * Math.PI, // aStartAngle, aEndAngle - false, // aClockwise - 0 // aRotation -); + + var curve = new THREE.EllipseCurve( + 0, 0, // ax, aY + 10, 10, // xRadius, yRadius + 0, 2 * Math.PI, // aStartAngle, aEndAngle + false, // aClockwise + 0 // aRotation + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var ellipse = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var ellipse = new THREE.Line( geometry, material ); +

Constructor

diff --git a/docs/api/en/extras/curves/QuadraticBezierCurve.html b/docs/api/en/extras/curves/QuadraticBezierCurve.html index 39e5c6efd4d466..411d24ffd71610 100644 --- a/docs/api/en/extras/curves/QuadraticBezierCurve.html +++ b/docs/api/en/extras/curves/QuadraticBezierCurve.html @@ -18,23 +18,23 @@

[name]

defined by a startpoint, endpoint and a single control point.

-

Example

+

Code Example

- -var curve = new THREE.QuadraticBezierCurve( - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( 20, 15 ), - new THREE.Vector2( 10, 0 ) -); + + var curve = new THREE.QuadraticBezierCurve( + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( 20, 15 ), + new THREE.Vector2( 10, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -//Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + //Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

Constructor

diff --git a/docs/api/en/extras/curves/QuadraticBezierCurve3.html b/docs/api/en/extras/curves/QuadraticBezierCurve3.html index 0222b20eb30f87..50bd3af004f221 100644 --- a/docs/api/en/extras/curves/QuadraticBezierCurve3.html +++ b/docs/api/en/extras/curves/QuadraticBezierCurve3.html @@ -18,23 +18,23 @@

[name]

defined by a startpoint, endpoint and a single control point.

-

Example

+

Code Example

- -var curve = new THREE.QuadraticBezierCurve3( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) -); + + var curve = new THREE.QuadraticBezierCurve3( + new THREE.Vector3( -10, 0, 0 ), + new THREE.Vector3( 20, 15, 0 ), + new THREE.Vector3( 10, 0, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

Constructor

diff --git a/docs/api/en/extras/curves/SplineCurve.html b/docs/api/en/extras/curves/SplineCurve.html index 201aaf9d83a4d1..308db8da61c30b 100644 --- a/docs/api/en/extras/curves/SplineCurve.html +++ b/docs/api/en/extras/curves/SplineCurve.html @@ -17,26 +17,26 @@

[name]

[page:Interpolations.CatmullRom] to create the curve.

-

Example

- - -// Create a sine-like wave -var curve = new THREE.SplineCurve( [ - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( -5, 5 ), - new THREE.Vector2( 0, 0 ), - new THREE.Vector2( 5, -5 ), - new THREE.Vector2( 10, 0 ) -] ); - -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); - -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); - -// Create the final object to add to the scene -var splineObject = new THREE.Line( geometry, material ); - +

Code Example

+ + + // Create a sine-like wave + var curve = new THREE.SplineCurve( [ + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( -5, 5 ), + new THREE.Vector2( 0, 0 ), + new THREE.Vector2( 5, -5 ), + new THREE.Vector2( 10, 0 ) + ] ); + + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); + + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + + // Create the final object to add to the scene + var splineObject = new THREE.Line( geometry, material ); +

Constructor

diff --git a/docs/api/en/geometries/BoxBufferGeometry.html b/docs/api/en/geometries/BoxBufferGeometry.html index d933e81c051720..568d8472f358a3 100644 --- a/docs/api/en/geometries/BoxBufferGeometry.html +++ b/docs/api/en/geometries/BoxBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); @@ -74,6 +74,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/BoxGeometry.js src/geometries/BoxGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/BoxGeometry.js src/geometries/BoxGeometry.js] +

diff --git a/docs/api/en/geometries/BoxGeometry.html b/docs/api/en/geometries/BoxGeometry.html index e13dc4791748ad..6772368c705781 100644 --- a/docs/api/en/geometries/BoxGeometry.html +++ b/docs/api/en/geometries/BoxGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); diff --git a/docs/api/en/geometries/CircleBufferGeometry.html b/docs/api/en/geometries/CircleBufferGeometry.html index 67f624aab0f29b..d5ba5fdd6eac4b 100644 --- a/docs/api/en/geometries/CircleBufferGeometry.html +++ b/docs/api/en/geometries/CircleBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.CircleBufferGeometry( 5, 32 ); @@ -64,6 +64,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CircleGeometry.js src/geometries/CircleGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CircleGeometry.js src/geometries/CircleGeometry.js] +

diff --git a/docs/api/en/geometries/CircleGeometry.html b/docs/api/en/geometries/CircleGeometry.html index 0db549cd323a91..4d6c3558add4e2 100644 --- a/docs/api/en/geometries/CircleGeometry.html +++ b/docs/api/en/geometries/CircleGeometry.html @@ -33,7 +33,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.CircleGeometry( 5, 32 ); diff --git a/docs/api/en/geometries/ConeBufferGeometry.html b/docs/api/en/geometries/ConeBufferGeometry.html index 2a35e74bbea26a..b1d0aa210539af 100644 --- a/docs/api/en/geometries/ConeBufferGeometry.html +++ b/docs/api/en/geometries/ConeBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.ConeBufferGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -66,6 +66,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ConeGeometry.js src/geometries/ConeGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ConeGeometry.js src/geometries/ConeGeometry.js] +

diff --git a/docs/api/en/geometries/ConeGeometry.html b/docs/api/en/geometries/ConeGeometry.html index 64d6607e026547..dc2a414a9c840a 100644 --- a/docs/api/en/geometries/ConeGeometry.html +++ b/docs/api/en/geometries/ConeGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.ConeGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/en/geometries/CylinderBufferGeometry.html b/docs/api/en/geometries/CylinderBufferGeometry.html index 4c4f888714f02c..bf95d81ca6dbf4 100644 --- a/docs/api/en/geometries/CylinderBufferGeometry.html +++ b/docs/api/en/geometries/CylinderBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.CylinderBufferGeometry( 5, 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -67,6 +67,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CylinderGeometry.js src/geometries/CylinderGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CylinderGeometry.js src/geometries/CylinderGeometry.js] +

diff --git a/docs/api/en/geometries/CylinderGeometry.html b/docs/api/en/geometries/CylinderGeometry.html index 45ec297cdcecdb..74aa5bd6326bf4 100644 --- a/docs/api/en/geometries/CylinderGeometry.html +++ b/docs/api/en/geometries/CylinderGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.CylinderGeometry( 5, 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/en/geometries/DodecahedronBufferGeometry.html b/docs/api/en/geometries/DodecahedronBufferGeometry.html index e285f1953f91e2..f9f3e934426b40 100644 --- a/docs/api/en/geometries/DodecahedronBufferGeometry.html +++ b/docs/api/en/geometries/DodecahedronBufferGeometry.html @@ -53,6 +53,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/DodecahedronGeometry.js src/geometries/DodecahedronGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/DodecahedronGeometry.js src/geometries/DodecahedronGeometry.js] +

diff --git a/docs/api/en/geometries/EdgesGeometry.html b/docs/api/en/geometries/EdgesGeometry.html index 7f115f9c53a258..fc16949c05a229 100644 --- a/docs/api/en/geometries/EdgesGeometry.html +++ b/docs/api/en/geometries/EdgesGeometry.html @@ -14,9 +14,7 @@

[name]

This can be used as a helper object to view the edges of a [page:Geometry Geometry] object.

-

Example

- - [example:webgl_helpers helpers] +

Code Example

var geometry = new THREE.BoxBufferGeometry( 100, 100, 100 ); @@ -25,6 +23,11 @@

Example

scene.add( line );
+

Examples

+

+ [example:webgl_helpers helpers] +

+

Constructor

[name]( [param:Geometry geometry], [param:Integer thresholdAngle] )

diff --git a/docs/api/en/geometries/ExtrudeBufferGeometry.html b/docs/api/en/geometries/ExtrudeBufferGeometry.html index 5cf5b8f812480d..afca0d6fd02e26 100644 --- a/docs/api/en/geometries/ExtrudeBufferGeometry.html +++ b/docs/api/en/geometries/ExtrudeBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

@@ -107,6 +107,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ExtrudeGeometry.js src/geometries/ExtrudeGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ExtrudeGeometry.js src/geometries/ExtrudeGeometry.js] +

diff --git a/docs/api/en/geometries/ExtrudeGeometry.html b/docs/api/en/geometries/ExtrudeGeometry.html index 9373afd58a427a..f63062e08c8f9b 100644 --- a/docs/api/en/geometries/ExtrudeGeometry.html +++ b/docs/api/en/geometries/ExtrudeGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

diff --git a/docs/api/en/geometries/IcosahedronBufferGeometry.html b/docs/api/en/geometries/IcosahedronBufferGeometry.html index 2b8a081ea18bc6..8b5723cb767ec7 100644 --- a/docs/api/en/geometries/IcosahedronBufferGeometry.html +++ b/docs/api/en/geometries/IcosahedronBufferGeometry.html @@ -52,6 +52,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/IcosahedronGeometry.js src/geometries/IcosahedronGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/IcosahedronGeometry.js src/geometries/IcosahedronGeometry.js] +

diff --git a/docs/api/en/geometries/LatheBufferGeometry.html b/docs/api/en/geometries/LatheBufferGeometry.html index b0bac164437d31..e7fc809e500b47 100644 --- a/docs/api/en/geometries/LatheBufferGeometry.html +++ b/docs/api/en/geometries/LatheBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var points = []; @@ -71,6 +71,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/LatheGeometry.js src/geometries/LatheGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/LatheGeometry.js src/geometries/LatheGeometry.js] +

diff --git a/docs/api/en/geometries/LatheGeometry.html b/docs/api/en/geometries/LatheGeometry.html index bda2bb055300ad..4461140f3b2100 100644 --- a/docs/api/en/geometries/LatheGeometry.html +++ b/docs/api/en/geometries/LatheGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var points = []; diff --git a/docs/api/en/geometries/OctahedronBufferGeometry.html b/docs/api/en/geometries/OctahedronBufferGeometry.html index fc03ad3d782afd..bbf3b2c5528e44 100644 --- a/docs/api/en/geometries/OctahedronBufferGeometry.html +++ b/docs/api/en/geometries/OctahedronBufferGeometry.html @@ -52,6 +52,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/OctahedronGeometry.js src/geometries/OctahedronGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/OctahedronGeometry.js src/geometries/OctahedronGeometry.js] +

diff --git a/docs/api/en/geometries/ParametricBufferGeometry.html b/docs/api/en/geometries/ParametricBufferGeometry.html index a7d32b007b93f5..e979b9a9bb63a0 100644 --- a/docs/api/en/geometries/ParametricBufferGeometry.html +++ b/docs/api/en/geometries/ParametricBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.ParametricBufferGeometry( THREE.ParametricGeometries.klein, 25, 25 ); @@ -65,6 +65,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ParametricGeometry.js src/geometries/ParametricGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ParametricGeometry.js src/geometries/ParametricGeometry.js] +

diff --git a/docs/api/en/geometries/ParametricGeometry.html b/docs/api/en/geometries/ParametricGeometry.html index 41686a089c5ce0..b7b1b32d16ad94 100644 --- a/docs/api/en/geometries/ParametricGeometry.html +++ b/docs/api/en/geometries/ParametricGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.ParametricGeometry( THREE.ParametricGeometries.klein, 25, 25 ); diff --git a/docs/api/en/geometries/PlaneBufferGeometry.html b/docs/api/en/geometries/PlaneBufferGeometry.html index 424071d2485a67..26b84eaef2cb6b 100644 --- a/docs/api/en/geometries/PlaneBufferGeometry.html +++ b/docs/api/en/geometries/PlaneBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.PlaneBufferGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} ); @@ -63,6 +63,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PlaneGeometry.js src/geometries/PlaneGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PlaneGeometry.js src/geometries/PlaneGeometry.js] +

diff --git a/docs/api/en/geometries/PlaneGeometry.html b/docs/api/en/geometries/PlaneGeometry.html index f15499d0d1462b..8135e35524d87c 100644 --- a/docs/api/en/geometries/PlaneGeometry.html +++ b/docs/api/en/geometries/PlaneGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.PlaneGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} ); diff --git a/docs/api/en/geometries/PolyhedronBufferGeometry.html b/docs/api/en/geometries/PolyhedronBufferGeometry.html index 5a29c31ff1deeb..39bcb566d182c9 100644 --- a/docs/api/en/geometries/PolyhedronBufferGeometry.html +++ b/docs/api/en/geometries/PolyhedronBufferGeometry.html @@ -19,7 +19,7 @@

[name]

and [page:TetrahedronBufferGeometry] to generate their respective geometries.

-

Example

+

Code Example

var verticesOfCube = [ -1,-1,-1, 1,-1,-1, 1, 1,-1, -1, 1,-1, @@ -62,6 +62,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PolyhedronGeometry.js src/geometries/PolyhedronGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PolyhedronGeometry.js src/geometries/PolyhedronGeometry.js] +

diff --git a/docs/api/en/geometries/PolyhedronGeometry.html b/docs/api/en/geometries/PolyhedronGeometry.html index dd8a461a89e547..d05ea4b72e2d28 100644 --- a/docs/api/en/geometries/PolyhedronGeometry.html +++ b/docs/api/en/geometries/PolyhedronGeometry.html @@ -17,7 +17,7 @@

[name]

project them onto a sphere, and then divide them up to the desired level of detail.

-

Example

+

Code Example

var verticesOfCube = [ -1,-1,-1, 1,-1,-1, 1, 1,-1, -1, 1,-1, diff --git a/docs/api/en/geometries/RingBufferGeometry.html b/docs/api/en/geometries/RingBufferGeometry.html index 6f2048c6e39d5b..0ff12b940507fd 100644 --- a/docs/api/en/geometries/RingBufferGeometry.html +++ b/docs/api/en/geometries/RingBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.RingBufferGeometry( 1, 5, 32 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00, side: THREE.DoubleSide } ); @@ -66,6 +66,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/RingGeometry.js src/geometries/RingGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/RingGeometry.js src/geometries/RingGeometry.js] +

diff --git a/docs/api/en/geometries/RingGeometry.html b/docs/api/en/geometries/RingGeometry.html index a4b4f7069c2bb5..e63aab46fd9609 100644 --- a/docs/api/en/geometries/RingGeometry.html +++ b/docs/api/en/geometries/RingGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.RingGeometry( 1, 5, 32 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00, side: THREE.DoubleSide } ); diff --git a/docs/api/en/geometries/ShapeBufferGeometry.html b/docs/api/en/geometries/ShapeBufferGeometry.html index 860e1c05612453..3dd694d63e7f20 100644 --- a/docs/api/en/geometries/ShapeBufferGeometry.html +++ b/docs/api/en/geometries/ShapeBufferGeometry.html @@ -33,7 +33,7 @@

[name]

-

Example

+

Code Example

@@ -77,6 +77,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ShapeGeometry.js src/geometries/ShapeGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ShapeGeometry.js src/geometries/ShapeGeometry.js] +

diff --git a/docs/api/en/geometries/ShapeGeometry.html b/docs/api/en/geometries/ShapeGeometry.html index aea1063e5479f7..3abaafd12bdeb9 100644 --- a/docs/api/en/geometries/ShapeGeometry.html +++ b/docs/api/en/geometries/ShapeGeometry.html @@ -33,7 +33,7 @@

[name]

-

Example

+

Code Example

diff --git a/docs/api/en/geometries/SphereBufferGeometry.html b/docs/api/en/geometries/SphereBufferGeometry.html index 4d6b25db806fa2..99ff2b9514994c 100644 --- a/docs/api/en/geometries/SphereBufferGeometry.html +++ b/docs/api/en/geometries/SphereBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -71,6 +71,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/SphereGeometry.js src/geometries/SphereGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/SphereGeometry.js src/geometries/SphereGeometry.js] +

diff --git a/docs/api/en/geometries/SphereGeometry.html b/docs/api/en/geometries/SphereGeometry.html index 1b882b246d79aa..08ed82d137d2fc 100644 --- a/docs/api/en/geometries/SphereGeometry.html +++ b/docs/api/en/geometries/SphereGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.SphereGeometry( 5, 32, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/en/geometries/TetrahedronBufferGeometry.html b/docs/api/en/geometries/TetrahedronBufferGeometry.html index 2bab1dcbe53f9a..d0b91263695c21 100644 --- a/docs/api/en/geometries/TetrahedronBufferGeometry.html +++ b/docs/api/en/geometries/TetrahedronBufferGeometry.html @@ -53,6 +53,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TetrahedronGeometry.js src/geometries/TetrahedronGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TetrahedronGeometry.js src/geometries/TetrahedronGeometry.js] +

diff --git a/docs/api/en/geometries/TextBufferGeometry.html b/docs/api/en/geometries/TextBufferGeometry.html index 33416c64d78402..0adcdb2378a390 100644 --- a/docs/api/en/geometries/TextBufferGeometry.html +++ b/docs/api/en/geometries/TextBufferGeometry.html @@ -36,11 +36,7 @@

[name]

-

Examples

- -

- [example:webgl_geometry_text geometry / text ] -

+

Code Example

var loader = new THREE.FontLoader(); @@ -61,6 +57,12 @@

Examples

} );
+

Examples

+ +

+ [example:webgl_geometry_text geometry / text ] +

+

Constructor

[name]([param:String text], [param:Object parameters])

@@ -168,6 +170,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TextGeometry.js src/geometries/TextGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TextGeometry.js src/geometries/TextGeometry.js] +

diff --git a/docs/api/en/geometries/TextGeometry.html b/docs/api/en/geometries/TextGeometry.html index e292919ff7fd69..cbc59530e44515 100644 --- a/docs/api/en/geometries/TextGeometry.html +++ b/docs/api/en/geometries/TextGeometry.html @@ -15,7 +15,7 @@

[name]

A class for generating text as a single geometry. It is constructed by providing a string of text, and a hash of parameters consisting of a loaded [page:Font] and settings for the geometry's parent [page:ExtrudeGeometry]. - See the [page:Font], [page:FontLoader] and [page:Creating_Text] pages for additional details. + See the [page:Font], [page:FontLoader] and [page:Creating-Text] pages for additional details.

@@ -36,11 +36,7 @@

[name]

-

Examples

- -

- [example:webgl_geometry_text geometry / text ] -

+

Code Example

var loader = new THREE.FontLoader(); @@ -61,6 +57,12 @@

Examples

} );
+

Examples

+ +

+ [example:webgl_geometry_text geometry / text ] +

+

Constructor

[name]([param:String text], [param:Object parameters])

diff --git a/docs/api/en/geometries/TorusBufferGeometry.html b/docs/api/en/geometries/TorusBufferGeometry.html index 51b59baeea16ea..42af60e94a4b8a 100644 --- a/docs/api/en/geometries/TorusBufferGeometry.html +++ b/docs/api/en/geometries/TorusBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.TorusBufferGeometry( 10, 3, 16, 100 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); @@ -64,6 +64,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusGeometry.js src/geometries/TorusGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusGeometry.js src/geometries/TorusGeometry.js] +

diff --git a/docs/api/en/geometries/TorusGeometry.html b/docs/api/en/geometries/TorusGeometry.html index 579e25f3da838b..5648ddaa8e93e9 100644 --- a/docs/api/en/geometries/TorusGeometry.html +++ b/docs/api/en/geometries/TorusGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.TorusGeometry( 10, 3, 16, 100 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); diff --git a/docs/api/en/geometries/TorusKnotBufferGeometry.html b/docs/api/en/geometries/TorusKnotBufferGeometry.html index ca6c229bc3546c..5d6e6986862e16 100644 --- a/docs/api/en/geometries/TorusKnotBufferGeometry.html +++ b/docs/api/en/geometries/TorusKnotBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.TorusKnotBufferGeometry( 10, 3, 100, 16 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); @@ -67,6 +67,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusKnotGeometry.js src/geometries/TorusKnotGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusKnotGeometry.js src/geometries/TorusKnotGeometry.js] +

diff --git a/docs/api/en/geometries/TorusKnotGeometry.html b/docs/api/en/geometries/TorusKnotGeometry.html index 89cbc0b974bc8d..8b0e9b451f9677 100644 --- a/docs/api/en/geometries/TorusKnotGeometry.html +++ b/docs/api/en/geometries/TorusKnotGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

var geometry = new THREE.TorusKnotGeometry( 10, 3, 100, 16 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); diff --git a/docs/api/en/geometries/TubeBufferGeometry.html b/docs/api/en/geometries/TubeBufferGeometry.html index 28f50b20206f0f..01f0d9fcd41324 100644 --- a/docs/api/en/geometries/TubeBufferGeometry.html +++ b/docs/api/en/geometries/TubeBufferGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

function CustomSinCurve( scale ) { @@ -68,7 +68,7 @@

Constructor

[name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])

- path — [page:Curve] - A path that inherits from the [page:Curve] base class
+ path — [page:Curve] - A 3D path that inherits from the [page:Curve] base class
tubularSegments — [page:Integer] - The number of segments that make up the tube, default is 64
radius — [page:Float] - The radius of the tube, default is 1
radialSegments — [page:Integer] - The number of segments that make up the cross-section, default is 8
@@ -104,6 +104,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js src/geometries/TubeGeometry.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js src/geometries/TubeGeometry.js] +

diff --git a/docs/api/en/geometries/TubeGeometry.html b/docs/api/en/geometries/TubeGeometry.html index 3c04357510b588..3169c726f74fa7 100644 --- a/docs/api/en/geometries/TubeGeometry.html +++ b/docs/api/en/geometries/TubeGeometry.html @@ -32,7 +32,7 @@

[name]

-

Example

+

Code Example

function CustomSinCurve( scale ) { @@ -68,7 +68,7 @@

Constructor

[name]([param:Curve path], [param:Integer tubularSegments], [param:Float radius], [param:Integer radialSegments], [param:Boolean closed])

- path — [page:Curve] - A path that inherits from the [page:Curve] base class
+ path — [page:Curve] - A 3D path that inherits from the [page:Curve] base class
tubularSegments — [page:Integer] - The number of segments that make up the tube, default is 64
radius — [page:Float] - The radius of the tube, default is 1
radialSegments — [page:Integer] - The number of segments that make up the cross-section, default is 8
diff --git a/docs/api/en/geometries/WireframeGeometry.html b/docs/api/en/geometries/WireframeGeometry.html index e24e9c1eab4568..6c440a69c13103 100644 --- a/docs/api/en/geometries/WireframeGeometry.html +++ b/docs/api/en/geometries/WireframeGeometry.html @@ -14,41 +14,27 @@

[name]

This can be used as a helper object to view a [page:Geometry Geometry] object as a wireframe.

- - -

Example

- - [example:webgl_helpers helpers] +

Code Example

-var geometry = new THREE.SphereBufferGeometry( 100, 100, 100 ); + var geometry = new THREE.SphereBufferGeometry( 100, 100, 100 ); -var wireframe = new THREE.WireframeGeometry( geometry ); + var wireframe = new THREE.WireframeGeometry( geometry ); -var line = new THREE.LineSegments( wireframe ); -line.material.depthTest = false; -line.material.opacity = 0.25; -line.material.transparent = true; + var line = new THREE.LineSegments( wireframe ); + line.material.depthTest = false; + line.material.opacity = 0.25; + line.material.transparent = true; -scene.add( line ); + scene.add( line ); +

Examples

+ +

+ [example:webgl_helpers helpers] +

+

Constructor

[name]( [param:Geometry geometry] )

diff --git a/docs/api/en/helpers/ArrowHelper.html b/docs/api/en/helpers/ArrowHelper.html index 56269be004121d..434624c5509467 100644 --- a/docs/api/en/helpers/ArrowHelper.html +++ b/docs/api/en/helpers/ArrowHelper.html @@ -14,12 +14,7 @@

[name]

An 3D arrow object for visualizing directions.

- -

Example

- -
[example:webgl_geometries WebGL / geometries]
-
[example:webgl_geometry_normals WebGL / geometry / normals]
-
[example:webgl_shadowmesh WebGL / shadowmesh]
+

Code Example

var dir = new THREE.Vector3( 1, 2, 0 ); @@ -35,11 +30,16 @@

Example

scene.add( arrowHelper );
+

Examples

+

+ [example:webgl_geometries WebGL / geometries]
+ [example:webgl_geometry_normals WebGL / geometry / normals]
+ [example:webgl_shadowmesh WebGL / shadowmesh] +

Constructor

-

[name]([param:Vector3 dir], [param:Vector3 origin], [param:Number length], [param:Number hex], [param:Number headLength], [param:Number headWidth] )

[page:Vector3 dir] -- direction from origin. Must be a unit vector.
@@ -53,21 +53,15 @@

[name]([param:Vector3 dir], [param:Vector3 origin], [param:Number length], [

Properties

See the base [page:Object3D] class for common properties.

-

[property:Line line]

Contains the line part of the arrowHelper.

[property:Mesh cone]

Contains the cone part of the arrowHelper.

- - -

Methods

See the base [page:Object3D] class for common methods.

- -

[method:null setColor]([param:Color color])

color -- The desired color.

diff --git a/docs/api/en/helpers/AxesHelper.html b/docs/api/en/helpers/AxesHelper.html index 1068f8e091d77b..7999d820f5ae12 100644 --- a/docs/api/en/helpers/AxesHelper.html +++ b/docs/api/en/helpers/AxesHelper.html @@ -13,21 +13,23 @@

[name]

An axis object to visualize the 3 axes in a simple way.
- The X axis is red. The Y axis is green. The Z axis is blue.

- - -

Example

- -
[example:webgl_geometries WebGL / geometries]
-
[example:webgl_geometry_convex WebGL / geometry / convex]
-
[example:webgl_geometry_spline_editor WebGL / geometry / spline / editor]
- + The X axis is red. The Y axis is green. The Z axis is blue. +

+

Code Example

var axesHelper = new THREE.AxesHelper( 5 ); scene.add( axesHelper ); - +
+ +

Examples

+ +

+ [example:webgl_geometries WebGL / geometries]
+ [example:webgl_geometry_convex WebGL / geometry / convex]
+ [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor] +

Constructor

diff --git a/docs/api/en/helpers/Box3Helper.html b/docs/api/en/helpers/Box3Helper.html index d74632121fbe1c..67cde3c3a31792 100644 --- a/docs/api/en/helpers/Box3Helper.html +++ b/docs/api/en/helpers/Box3Helper.html @@ -17,7 +17,7 @@

[name]

-

Example

+

Code Example

var box = new THREE.Box3(); diff --git a/docs/api/en/helpers/BoxHelper.html b/docs/api/en/helpers/BoxHelper.html index d8577b0e6af672..f3caba4810996a 100644 --- a/docs/api/en/helpers/BoxHelper.html +++ b/docs/api/en/helpers/BoxHelper.html @@ -19,21 +19,22 @@

[name]

so it won't work with [page:Sprite Sprites].

- -

Example

- -
[example:webgl_helpers WebGL / helpers]
-
[example:webgl_loader_nrrd WebGL / loader / nrrd]
-
[example:webgl_buffergeometry_drawcalls advanced / buffergeometry / drawcalls]
- +

Code Example

- var sphere = new THREE.SphereGeometry(); - var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); - var box = new THREE.BoxHelper( object, 0xffff00 ); - scene.add( box ); + var sphere = new THREE.SphereBufferGeometry(); + var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); + var box = new THREE.BoxHelper( object, 0xffff00 ); + scene.add( box ); +

Examples

+ +

+ [example:webgl_helpers WebGL / helpers]
+ [example:webgl_loader_nrrd WebGL / loader / nrrd]
+ [example:webgl_buffergeometry_drawrange WebGL / buffergeometry / drawrange] +

Constructor

diff --git a/docs/api/en/helpers/CameraHelper.html b/docs/api/en/helpers/CameraHelper.html index fed058e7f3570e..a445155d071088 100644 --- a/docs/api/en/helpers/CameraHelper.html +++ b/docs/api/en/helpers/CameraHelper.html @@ -17,17 +17,18 @@

[name]

It visualizes the frustum of a camera using a [page:LineSegments].

-

Example

- -
[example:webgl_camera WebGL / camera]
-
[example:webgl_geometry_extrude_splines WebGL / extrude / splines]
- +

Code Example

var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var helper = new THREE.CameraHelper( camera ); scene.add( helper ); +

Examples

+

+ [example:webgl_camera WebGL / camera]
+ [example:webgl_geometry_extrude_splines WebGL / extrude / splines] +

Constructor

diff --git a/docs/api/en/helpers/DirectionalLightHelper.html b/docs/api/en/helpers/DirectionalLightHelper.html index efb2718f28d2bb..d1a5d9d9d6a23a 100644 --- a/docs/api/en/helpers/DirectionalLightHelper.html +++ b/docs/api/en/helpers/DirectionalLightHelper.html @@ -18,17 +18,14 @@

[name]

This consists of plane and a line representing the light's position and direction.

-

Example

+

Code Example

var light = new THREE.DirectionalLight( 0xFFFFFF ); - var helper = new THREE.DirectionalLightHelper( light, 5 ); - scene.add( helper ); -

Constructor

diff --git a/docs/api/en/helpers/GridHelper.html b/docs/api/en/helpers/GridHelper.html index 904d4c78080ca1..c463284b37d043 100644 --- a/docs/api/en/helpers/GridHelper.html +++ b/docs/api/en/helpers/GridHelper.html @@ -9,13 +9,12 @@ [page:Object3D] → [page:Line] → - +

[name]

The GridHelper is an object to define grids. Grids are two-dimensional arrays of lines.

- -

Example

+

Code Example

var size = 10; var divisions = 10; @@ -23,8 +22,12 @@

Example

var gridHelper = new THREE.GridHelper( size, divisions ); scene.add( gridHelper );
- [example:webgl_helpers Example using various helpers] +

Examples

+ +

+ [example:webgl_helpers WebGL / helpers] +

Constructor

diff --git a/docs/api/en/helpers/HemisphereLightHelper.html b/docs/api/en/helpers/HemisphereLightHelper.html index ed87263c1f9caa..8ff48966610268 100644 --- a/docs/api/en/helpers/HemisphereLightHelper.html +++ b/docs/api/en/helpers/HemisphereLightHelper.html @@ -16,14 +16,12 @@

[name]

Creates a visual aid consisting of a spherical [page:Mesh] for a [page:HemisphereLight HemisphereLight].

-

Example

+

Code Example

-var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); - -var helper = new THREE.HemisphereLightHelper( light, 5 ); - -scene.add( helper ); + var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + var helper = new THREE.HemisphereLightHelper( light, 5 ); + scene.add( helper ); diff --git a/docs/api/en/helpers/PlaneHelper.html b/docs/api/en/helpers/PlaneHelper.html index 39431e2e946598..7f27010c73c65c 100644 --- a/docs/api/en/helpers/PlaneHelper.html +++ b/docs/api/en/helpers/PlaneHelper.html @@ -17,7 +17,7 @@

[name]

-

Example

+

Code Example

var plane = new THREE.Plane( new THREE.Vector3( 1, 1, 0.2 ), 3 ); diff --git a/docs/api/en/helpers/PointLightHelper.html b/docs/api/en/helpers/PointLightHelper.html index 9761e0d7c1ba0f..3c45767343745a 100644 --- a/docs/api/en/helpers/PointLightHelper.html +++ b/docs/api/en/helpers/PointLightHelper.html @@ -17,10 +17,7 @@

[name]

a [page:PointLight].

- -

Example

- - [example:webgl_helpers WebGL / helpers] +

Code Example

var pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); @@ -32,8 +29,11 @@

Example

scene.add( pointLightHelper );
+

Examples

- +

+ [example:webgl_helpers WebGL / helpers] +

Constructor

diff --git a/docs/api/en/helpers/PolarGridHelper.html b/docs/api/en/helpers/PolarGridHelper.html index a356622ab73a47..730165c63638e2 100644 --- a/docs/api/en/helpers/PolarGridHelper.html +++ b/docs/api/en/helpers/PolarGridHelper.html @@ -14,10 +14,10 @@

[name]

The PolarGridHelper is an object to define polar grids. Grids are two-dimensional arrays of lines.

+

Code Example

-

Example

- - var radius = 10; + + var radius = 10; var radials = 16; var circles = 8; var divisions = 64; @@ -25,8 +25,12 @@

Example

var helper = new THREE.PolarGridHelper( radius, radials, circles, divisions ); scene.add( helper );
- [example:webgl_helpers Example using various helpers] +

Examples

+ +

+ [example:webgl_helpers WebGL / helpers] +

Constructor

diff --git a/docs/api/en/helpers/SkeletonHelper.html b/docs/api/en/helpers/SkeletonHelper.html index 6a33ed017bfd78..bd3a926df4372a 100644 --- a/docs/api/en/helpers/SkeletonHelper.html +++ b/docs/api/en/helpers/SkeletonHelper.html @@ -17,21 +17,20 @@

[name]

The helper is renderered using a [page:LineBasicMaterial LineBasicMaterial].

- -

Example

- -

- [example:webgl_animation_skinning_blending animation / skinning / blending]
- [example:webgl_animation_skinning_morph animation / skinning / morph]
- [example:webgl_loader_bvh loader / bvh ] -

+

Code Example

-var helper = new THREE.SkeletonHelper( skinnedMesh ); -scene.add( helper ); + var helper = new THREE.SkeletonHelper( skinnedMesh ); + scene.add( helper ); +

Examples

+

+ [example:webgl_animation_skinning_blending WebGL / animation / skinning / blending]
+ [example:webgl_animation_skinning_morph WebGL / animation / skinning / morph]
+ [example:webgl_loader_bvh WebGL / loader / bvh ] +

Constructor

diff --git a/docs/api/en/helpers/SpotLightHelper.html b/docs/api/en/helpers/SpotLightHelper.html index 05fb85c4be89c1..329dfc34c6f136 100644 --- a/docs/api/en/helpers/SpotLightHelper.html +++ b/docs/api/en/helpers/SpotLightHelper.html @@ -14,13 +14,6 @@

[name]

This displays a cone shaped helper object for a [page:SpotLight].

-

Example

- - View in Examples
-

Other Examples

- -
[example:webgl_lights_spotlights lights / spotlights ]
-

Code Example

var spotLight = new THREE.SpotLight( 0xffffff ); @@ -31,10 +24,13 @@

Code Example

scene.add( spotLightHelper );
+

Examples

+

+ [example:webgl_lights_spotlights WebGL/ lights / spotlights ] +

Constructor

-

[name]( [param:SpotLight light], [param:Hex color] )

[page:SpotLight light] -- The [page:SpotLight] to be visualized.

@@ -63,8 +59,8 @@

[property:object matrixAutoUpdate]

[property:hex color]

- The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update - the next time [page:.update update] is called. + The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update + the next time [page:.update update] is called.

Methods

diff --git a/docs/api/en/lights/AmbientLight.html b/docs/api/en/lights/AmbientLight.html index 694ca8e1f65f80..3699321811fd5e 100644 --- a/docs/api/en/lights/AmbientLight.html +++ b/docs/api/en/lights/AmbientLight.html @@ -18,16 +18,19 @@

[name]

This light cannot be used to cast shadows as it does not have a direction.

+

Code Example

-

Example

+ + var light = new THREE.AmbientLight( 0x404040 ); // soft white light + scene.add( light ); + + +

Examples

- [example:webgl_animation_cloth animation / cloth ]
- [example:webgl_animation_skinning_blending animation / skinning / blending ] + [example:webgl_animation_cloth animation / cloth ]
+ [example:webgl_animation_skinning_blending animation / skinning / blending ]

-var light = new THREE.AmbientLight( 0x404040 ); // soft white light -scene.add( light ); -

Constructor

[name]( [param:Integer color], [param:Float intensity] )

diff --git a/docs/api/en/lights/DirectionalLight.html b/docs/api/en/lights/DirectionalLight.html index b267c77ce90bfb..38f975aa4e3f0a 100644 --- a/docs/api/en/lights/DirectionalLight.html +++ b/docs/api/en/lights/DirectionalLight.html @@ -37,8 +37,15 @@

A Note about Position, Target and rotation

See the [page:.target target] property below for details on updating the target.

+

Code Example

-

Example

+ + // White directional light at half intensity shining from the top. + var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + scene.add( directionalLight ); + + +

Examples

[example:misc_controls_fly controls / fly ]
[example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]
@@ -48,13 +55,6 @@

Example

[example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection ]

- - // White directional light at half intensity shining from the top. - var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); - scene.add( directionalLight ); - - -

Constructor

[name]( [param:Integer color], [param:Float intensity] )

@@ -67,7 +67,7 @@

[name]( [param:Integer color], [param:Float intensity] )

Properties

- See the base [page:Light Light] class for common properties. +

See the base [page:Light Light] class for common properties.

[property:Boolean castShadow]

@@ -117,7 +117,7 @@

[property:Object3D target]

Methods

- See the base [page:Light Light] class for common methods. +

See the base [page:Light Light] class for common methods.

[method:DirectionalLight copy]( [param:DirectionalLight source] )

diff --git a/docs/api/en/lights/HemisphereLight.html b/docs/api/en/lights/HemisphereLight.html index f7a4375dcbc3d9..1cee0bafbfb178 100644 --- a/docs/api/en/lights/HemisphereLight.html +++ b/docs/api/en/lights/HemisphereLight.html @@ -19,21 +19,23 @@

[name]

This light cannot be used to cast shadows.

-

Example

+

Code Example

-
+ + var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + scene.add( light ); + + +

Examples

+ +

[example:webgl_lights_hemisphere lights / hemisphere ]
- [example:misc_controls_pointerlock controls / pointerlock ]
- [example:webgl_decals decals ]
- [example:webgl_loader_collada_kinematics loader / collada / kinematics ]
- [example:webgl_materials_lightmap materials / lightmap ]
- [example:webgl_shaders_ocean shaders / ocean ] -

- - -var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); -scene.add( light ); - + [example:misc_controls_pointerlock controls / pointerlock ]
+ [example:webgl_decals decals ]
+ [example:webgl_loader_collada_kinematics loader / collada / kinematics ]
+ [example:webgl_materials_lightmap materials / lightmap ]
+ [example:webgl_shaders_ocean shaders / ocean ] +

Constructor

[name]( [param:Integer skyColor], [param:Integer groundColor], [param:Float intensity] )

@@ -77,7 +79,7 @@

[property:Vector3 position]

Methods

- See the base [page:Light Light] class for common methods. +

See the base [page:Light Light] class for common methods.

[method:HemisphereLight copy]( [param:HemisphereLight source] )

diff --git a/docs/api/en/lights/PointLight.html b/docs/api/en/lights/PointLight.html index 5fad479442b892..b6d99a41ed0675 100644 --- a/docs/api/en/lights/PointLight.html +++ b/docs/api/en/lights/PointLight.html @@ -16,28 +16,27 @@

[name]

A light that gets emitted from a single point in all directions. A common use case for this is to replicate the light emitted from a bare lightbulb.

- This light can cast shadows - see [page:LightShadow] page for details. + This light can cast shadows - see [page:PointLightShadow] page for details.

+

Code Example

-

Example

+ +var light = new THREE.PointLight( 0xff0000, 1, 100 ); +light.position.set( 50, 50, 50 ); +scene.add( light ); + + +

Examples

[example:webgl_lights_pointlights lights / pointlights ]
[example:webgl_lights_pointlights2 lights / pointlights2 ]
- [example:webgldeferred_animation animation ]
[example:webgl_effects_anaglyph effects / anaglyph ]
[example:webgl_geometry_text geometry / text ]
[example:webgl_lensflares lensflares ]

- -var light = new THREE.PointLight( 0xff0000, 1, 100 ); -light.position.set( 50, 50, 50 ); -scene.add( light ); - - -

Constructor

[name]( [param:Integer color], [param:Float intensity], [param:Number distance], [param:Float decay] )

@@ -93,9 +92,9 @@

[property:Float power]

and changing this will also change the intensity.

-

[property:LightShadow shadow]

+

[property:PointLightShadow shadow]

- A [page:LightShadow] used to calculate shadows for this light.

+ A [page:PointLightShadow] used to calculate shadows for this light.

The lightShadow's [page:LightShadow.camera camera] is set to a [page:PerspectiveCamera] with [page:PerspectiveCamera.fov fov] of 90, diff --git a/docs/api/en/lights/RectAreaLight.html b/docs/api/en/lights/RectAreaLight.html index 15197bf2bcbcfe..ad767e1ae3c11d 100644 --- a/docs/api/en/lights/RectAreaLight.html +++ b/docs/api/en/lights/RectAreaLight.html @@ -20,18 +20,13 @@

[name]

  • There is no shadow support.
  • Only [page:MeshStandardMaterial MeshStandardMaterial] and [page:MeshPhysicalMaterial MeshPhysicalMaterial] are supported.
  • -
  • You have to include [link:https://threejs.org/examples/js/lights/RectAreaLightUniformsLib.js RectAreaLightUniformsLib] into your scene and call *init()*.
  • +
  • You have to include [link:https://threejs.org/examples/jsm/lights/RectAreaLightUniformsLib.js RectAreaLightUniformsLib] into your scene and call *init()*.

+

Code Example

- -

Examples

- -

- [example:webgl_lights_rectarealight WebGL / rectarealight ] - - + var width = 10; var height = 10; var intensity = 1; @@ -43,9 +38,13 @@

Examples

rectLightHelper = new THREE.RectAreaLightHelper( rectLight ); rectLight.add( rectLightHelper ); - -

+
+ +

Examples

+

+ [example:webgl_lights_rectarealight WebGL / rectarealight ] +

Constructor

diff --git a/docs/api/en/lights/SpotLight.html b/docs/api/en/lights/SpotLight.html index 198574461826a1..515325a7c40cfa 100644 --- a/docs/api/en/lights/SpotLight.html +++ b/docs/api/en/lights/SpotLight.html @@ -19,32 +19,6 @@

[name]

This light can cast shadows - see the [page:SpotLightShadow] page for details.

- - - -

Example

- - -

- [example:webgl_lights_spotlight View in Examples ] -

- -

Other Examples

- -

- [example:webgl_interactive_cubes_gpu interactive / cubes / gpu ]
- [example:webgl_interactive_draggablecubes interactive / draggablecubes ]
- [example:webgl_materials_bumpmap_skin materials / bumpmap / skin ]
- [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
- [example:webgl_loader_md2 loader / md2 ]
- [example:webgl_shading_physical shading / physical ]
- [example:webgl_materials_bumpmap materials / bumpmap]
- [example:webgl_shading_physical shading / physical]
- [example:webgl_shadowmap shadowmap]
- [example:webgl_shadowmap_performance shadowmap / performance]
- [example:webgl_shadowmap_viewer shadowmap / viewer] -

-

Code Example

// white spotlight shining from the side, casting a shadow @@ -64,6 +38,13 @@

Code Example

scene.add( spotLight );
+

Examples

+ +

+ [example:webgl_lights_spotlight lights / spotlight ]
+ [example:webgl_lights_spotlights lights / spotlights ] +

+

Constructor

@@ -83,7 +64,7 @@

[name]( [param:Integer color], [param:Float intensity], [param:Float distanc

Properties

- See the base [page:Light Light] class for common properties. +

See the base [page:Light Light] class for common properties.

[property:Float angle]

@@ -181,7 +162,7 @@

[property:Object3D target]

Methods

- See the base [page:Light Light] class for common methods. +

See the base [page:Light Light] class for common methods.

[method:SpotLight copy]( [param:SpotLight source] )

diff --git a/docs/api/en/lights/shadows/DirectionalLightShadow.html b/docs/api/en/lights/shadows/DirectionalLightShadow.html index b41d80ef225da0..e7f1dc95e0fd33 100644 --- a/docs/api/en/lights/shadows/DirectionalLightShadow.html +++ b/docs/api/en/lights/shadows/DirectionalLightShadow.html @@ -20,46 +20,45 @@

[name]

are parallel.

-

Example

-

- -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a DirectionalLight and turn on shadows for the light -var light = new THREE.DirectionalLight( 0xffffff, 1, 100 ); -light.position.set( 0, 1, 0 ); //default; light shining from top -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500; // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

+

Code Example

+ + + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a DirectionalLight and turn on shadows for the light + var light = new THREE.DirectionalLight( 0xffffff, 1, 100 ); + light.position.set( 0, 1, 0 ); //default; light shining from top + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500; // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

Constructor

[name]( )

diff --git a/docs/api/en/lights/shadows/LightShadow.html b/docs/api/en/lights/shadows/LightShadow.html index 7cc536c7eb468d..fa8aaca7c7cd84 100644 --- a/docs/api/en/lights/shadows/LightShadow.html +++ b/docs/api/en/lights/shadows/LightShadow.html @@ -22,7 +22,7 @@

[name]( [param:Camera camera] )

[page:Camera camera] - the light's view of the world.

- Create a new [name]. This is not intended to be called directly - it is used as a base class by + Create a new [name]. This is not intended to be called directly - it is used as a base class by other light shadows.

@@ -48,7 +48,7 @@

[property:WebGLRenderTarget map]

[property:WebGLRenderTarget mapPass]

- The distribution map generated using the internal camera; an occlusion is calculated based + The distribution map generated using the internal camera; an occlusion is calculated based on the distribution of depths. Computed internally during rendering.

@@ -74,8 +74,8 @@

[property:Float radius]

High values will cause unwanted banding effects in the shadows - a greater [page:.mapSize mapSize] will allow for a higher value to be used here before these effects become visible.
- If [page:WebGLRenderer.shadowMap.type] is set to [page:Renderer PCFSoftShadowMap], it is recommended to - leave radius at 1 and increase softness by decreasing [page:.mapSize mapSize] instead.

+ If [page:WebGLRenderer.shadowMap.type] is set to [page:Renderer PCFSoftShadowMap], radius has + no effect and it is recommended to increase softness by decreasing [page:.mapSize mapSize] instead.

Note that this has no effect if the [page:WebGLRenderer.shadowMap.type] is set to [page:Renderer BasicShadowMap].

@@ -123,6 +123,8 @@

[method:Object toJSON]()

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

diff --git a/docs/api/en/lights/shadows/PointLightShadow.html b/docs/api/en/lights/shadows/PointLightShadow.html index 0a4b1ccaabfe79..9ebdaacce0a22f 100644 --- a/docs/api/en/lights/shadows/PointLightShadow.html +++ b/docs/api/en/lights/shadows/PointLightShadow.html @@ -12,50 +12,48 @@

[name]

- This is used internally by [page:PointLight PointLights] for calculating shadows + This is used internally by [page:PointLight PointLights] for calculating shadows.

-

Example

-

- -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a PointLight and turn on shadows for the light -var light = new THREE.PointLight( 0xffffff, 1, 100 ); -light.position.set( 0, 10, 0 ); -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500 // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

+

Code Example

+ + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a PointLight and turn on shadows for the light + var light = new THREE.PointLight( 0xffffff, 1, 100 ); + light.position.set( 0, 10, 0 ); + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500 // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

Constructor

[name]( )

@@ -70,7 +68,11 @@

Properties

Methods

- + +

+ See the base [page:LightShadow LightShadow] class for common methods. +

+

[method:null updateMatrices]( [param:Light light], [param:number viewportIndex])

Update the matrices for the camera and shadow, used internally by the renderer.

@@ -79,10 +81,6 @@

[method:null updateMatrices]( [param:Light light], [param:number viewportInd viewportIndex -- calculates the matrix for this viewport

-

- See the base [page:LightShadow LightShadow] class for common methods. -

-

Source

diff --git a/docs/api/en/lights/shadows/SpotLightShadow.html b/docs/api/en/lights/shadows/SpotLightShadow.html index d2bb006ea5e31e..a0c39bc70814a1 100644 --- a/docs/api/en/lights/shadows/SpotLightShadow.html +++ b/docs/api/en/lights/shadows/SpotLightShadow.html @@ -16,53 +16,50 @@

[name]

This is used internally by [page:SpotLight SpotLights] for calculating shadows.

-

Example

-

- -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a SpotLight and turn on shadows for the light -var light = new THREE.SpotLight( 0xffffff ); -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500 // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

- +

Code Example

+ + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a SpotLight and turn on shadows for the light + var light = new THREE.SpotLight( 0xffffff ); + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500 // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

Constructor

- The constructor creates a [param:PerspectiveCamera PerspectiveCamera] to manage the shadow's view of the world. +

The constructor creates a [param:PerspectiveCamera PerspectiveCamera] to manage the shadow's view of the world.

Properties

- See the base [page:LightShadow LightShadow] class for common properties. +

See the base [page:LightShadow LightShadow] class for common properties.

[property:Camera camera]

@@ -80,7 +77,7 @@

[property:Camera camera]

Methods

- See the base [page:LightShadow LightShadow] class for common methods. +

See the base [page:LightShadow LightShadow] class for common methods.

[method:SpotLightShadow update]( [param:SpotLight light] )

diff --git a/docs/api/en/loaders/AnimationLoader.html b/docs/api/en/loaders/AnimationLoader.html index d62c0410b16ade..f95ce00d1a5516 100644 --- a/docs/api/en/loaders/AnimationLoader.html +++ b/docs/api/en/loaders/AnimationLoader.html @@ -17,7 +17,7 @@

[name]

This uses the [page:FileLoader] internally for loading files.

-

Example

+

Code Example

// instantiate a loader diff --git a/docs/api/en/loaders/AudioLoader.html b/docs/api/en/loaders/AudioLoader.html index bb2a04e2a185d6..e05e5d2ab86a71 100644 --- a/docs/api/en/loaders/AudioLoader.html +++ b/docs/api/en/loaders/AudioLoader.html @@ -18,7 +18,7 @@

[name]

This uses the [page:FileLoader] internally for loading files.

-

Example

+

Code Example

// instantiate a listener diff --git a/docs/api/en/loaders/BufferGeometryLoader.html b/docs/api/en/loaders/BufferGeometryLoader.html index d2d9154f9230ca..1cb29c76f19a00 100644 --- a/docs/api/en/loaders/BufferGeometryLoader.html +++ b/docs/api/en/loaders/BufferGeometryLoader.html @@ -17,9 +17,7 @@

[name]

This uses the [page:FileLoader] internally for loading files.

-

Example

- - [example:webgl_geometry_colors_lookuptable WebGL / geometry / colors / lookuptable] +

Code Example

// instantiate a loader @@ -49,6 +47,12 @@

Example

);
+

Examples

+ +

+ [example:webgl_performance WebGL / performance] +

+

Constructor

[name]( [param:LoadingManager manager] )

diff --git a/docs/api/en/loaders/Cache.html b/docs/api/en/loaders/Cache.html index c053f9dda84c9e..2a0b3fe4c4940d 100644 --- a/docs/api/en/loaders/Cache.html +++ b/docs/api/en/loaders/Cache.html @@ -14,6 +14,14 @@

[name]

A simple caching system, used internally by [page:FileLoader].

+

Code Example

+ +

To enable caching across all loaders that use [page:FileLoader], set

+ + THREE.Cache.enabled = true. + + +

Examples

@@ -22,14 +30,6 @@

Examples

[example:webgl_loader_ttf WebGL / loader / ttf]

-

Usage

- -

To enable caching across all loaders that use [page:FileLoader], set

- -THREE.Cache.enabled = true. - - -

Properties

[property:Boolean enabled]

diff --git a/docs/api/en/loaders/CompressedTextureLoader.html b/docs/api/en/loaders/CompressedTextureLoader.html index a03c5ba03f8ecf..293830ae1963c2 100644 --- a/docs/api/en/loaders/CompressedTextureLoader.html +++ b/docs/api/en/loaders/CompressedTextureLoader.html @@ -20,8 +20,8 @@

[name]

Examples

- See the [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DDSLoader.js DDSLoader] - and [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PVRLoader.js PVRLoader] + See the [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/DDSLoader.js DDSLoader] + and [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PVRLoader.js PVRLoader] for examples of derived classes.

diff --git a/docs/api/en/loaders/CubeTextureLoader.html b/docs/api/en/loaders/CubeTextureLoader.html index 27ba39dbc0ad23..0065713dcd8c8b 100644 --- a/docs/api/en/loaders/CubeTextureLoader.html +++ b/docs/api/en/loaders/CubeTextureLoader.html @@ -17,15 +17,7 @@

[name]

This uses the [page:ImageLoader] internally for loading files.

-

Example

- -

- [example:webgl_materials_cubemap materials / cubemap]
- [example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection]
- [example:webgl_materials_cubemap_balls_refraction materials / cubemap / balls / refraction]
- [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic]
- [example:webgl_materials_cubemap_refraction materials / cubemap / refraction] -

+

Code Example

var scene = new THREE.Scene(); @@ -41,6 +33,16 @@

Example

] );
+

Examples

+ +

+ [example:webgl_materials_cubemap materials / cubemap]
+ [example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection]
+ [example:webgl_materials_cubemap_balls_refraction materials / cubemap / balls / refraction]
+ [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic]
+ [example:webgl_materials_cubemap_refraction materials / cubemap / refraction] +

+

Constructor

[name]( [param:LoadingManager manager] )

diff --git a/docs/api/en/loaders/DataTextureLoader.html b/docs/api/en/loaders/DataTextureLoader.html index 372b085f00f40c..7bcaaed1d0cf7a 100644 --- a/docs/api/en/loaders/DataTextureLoader.html +++ b/docs/api/en/loaders/DataTextureLoader.html @@ -21,7 +21,7 @@

[name]

Examples

- See the [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/RGBELoader.js RGBELoader] + See the [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/RGBELoader.js RGBELoader] for an example of a derived class.

diff --git a/docs/api/en/loaders/FileLoader.html b/docs/api/en/loaders/FileLoader.html index 5559fd6c869564..ab81a82539ece2 100644 --- a/docs/api/en/loaders/FileLoader.html +++ b/docs/api/en/loaders/FileLoader.html @@ -17,7 +17,7 @@

[name]

It can also be used directly to load any file type that does not have a loader.

-

Example

+

Code Example

var loader = new THREE.FileLoader(); diff --git a/docs/api/en/loaders/FontLoader.html b/docs/api/en/loaders/FontLoader.html index bc7ee10bac9c0c..fe8ee4387eabd4 100644 --- a/docs/api/en/loaders/FontLoader.html +++ b/docs/api/en/loaders/FontLoader.html @@ -14,18 +14,13 @@

[name]

Class for loading a font in JSON format. Returns a [page:Font Font], which is an - array of [page:Shape Shape]s representing the font. + array of [page:Shape Shapes] representing the font. This uses the [page:FileLoader] internally for loading files.

You can convert fonts online using [link:https://gero3.github.io/facetype.js/ facetype.js]

-

Examples

- -

- [example:webgl_geometry_text_shapes geometry / text / shapes ]
- [example:webgl_geometry_text geometry / text ] -

+

Code Example

var loader = new THREE.FontLoader(); @@ -51,6 +46,13 @@

Examples

);
+

Examples

+ +

+ [example:webgl_geometry_text_shapes geometry / text / shapes ]
+ [example:webgl_geometry_text geometry / text ] +

+

Constructor

[name]( [param:LoadingManager manager] )

diff --git a/docs/api/en/loaders/ImageBitmapLoader.html b/docs/api/en/loaders/ImageBitmapLoader.html index ed0cd4f585dfe6..6f4fa666df6f4d 100644 --- a/docs/api/en/loaders/ImageBitmapLoader.html +++ b/docs/api/en/loaders/ImageBitmapLoader.html @@ -25,11 +25,7 @@

[name]

instead. Refer to [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.10 WebGL specification] for the detail.

-

Example

- -

- [example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap] -

+

Code Example

// instantiate a loader @@ -59,6 +55,11 @@

Example

);
+

Examples

+ +

+ [example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap] +

Constructor

diff --git a/docs/api/en/loaders/ImageLoader.html b/docs/api/en/loaders/ImageLoader.html index f158ec34fcb7d0..32a258c89beea8 100644 --- a/docs/api/en/loaders/ImageLoader.html +++ b/docs/api/en/loaders/ImageLoader.html @@ -18,12 +18,7 @@

[name]

[page:CubeTextureLoader], [page:ObjectLoader] and [page:TextureLoader].

-

Example

- -

- [example:webgl_loader_obj WebGL / loader / obj]
- [example:webgl_shaders_ocean WebGL / shaders / ocean] -

+

Code Example

// instantiate a loader @@ -57,6 +52,13 @@

Example

that supports progress events, see [link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-275785639 this thread].

+

Examples

+ +

+ [example:webgl_loader_obj WebGL / loader / obj]
+ [example:webgl_shaders_ocean WebGL / shaders / ocean] +

+

Constructor

[name]( [param:LoadingManager manager] )

diff --git a/docs/api/en/loaders/Loader.html b/docs/api/en/loaders/Loader.html index c070231c5bfd93..be58a16d6a731e 100644 --- a/docs/api/en/loaders/Loader.html +++ b/docs/api/en/loaders/Loader.html @@ -57,6 +57,18 @@

[method:void load]()

This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.

+

[method:Promise loadAsync]( [param:String url], [param:Function onProgress] )

+

+ [page:String url] — A string containing the path/URL of the file to be loaded.
+ [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.
+

+

+ This method is equivalent to [page:.load], but returns a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promise]. +

+

+ [page:Function onLoad] is handled by [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve Promise.resolve] and [page:Function onError] is handled by [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject Promise.reject]. +

+

[method:void parse]()

This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset into three.js entities. diff --git a/docs/api/en/loaders/MaterialLoader.html b/docs/api/en/loaders/MaterialLoader.html index 561aa634c1d2b8..08664632b6a931 100644 --- a/docs/api/en/loaders/MaterialLoader.html +++ b/docs/api/en/loaders/MaterialLoader.html @@ -17,8 +17,7 @@

[name]

This uses the [page:FileLoader] internally for loading files.

-

Example

- +

Code Example

// instantiate a loader diff --git a/docs/api/en/loaders/ObjectLoader.html b/docs/api/en/loaders/ObjectLoader.html index 3483a9d566e342..0d4c3e1289b15a 100644 --- a/docs/api/en/loaders/ObjectLoader.html +++ b/docs/api/en/loaders/ObjectLoader.html @@ -18,12 +18,7 @@

[name]

This uses the [page:FileLoader] internally for loading files.

-

Example

- -

- [example:webgl_loader_json_claraio WebGL / loader / json / claraio]
- [example:webgl_materials_lightmap WebGL / materials / lightmap] -

+

Code Example

var loader = new THREE.ObjectLoader(); @@ -57,7 +52,12 @@

Example

scene.add( object );
+

Examples

+

+ [example:webgl_loader_json_claraio WebGL / loader / json / claraio]
+ [example:webgl_materials_lightmap WebGL / materials / lightmap] +

Constructor

diff --git a/docs/api/en/loaders/TextureLoader.html b/docs/api/en/loaders/TextureLoader.html index 66d1af939ebd51..1461c5990db4e0 100644 --- a/docs/api/en/loaders/TextureLoader.html +++ b/docs/api/en/loaders/TextureLoader.html @@ -17,7 +17,7 @@

[name]

This uses the [page:ImageLoader] internally for loading files.

-

Example

+

Code Example

var texture = new THREE.TextureLoader().load( 'textures/land_ocean_ice_cloud_2048.jpg' ); @@ -26,9 +26,7 @@

Example

var material = new THREE.MeshBasicMaterial( { map: texture } );
- [example:webgl_geometry_cube geometry / cube] - -

Example with Callbacks

+

Code Example with Callbacks

// instantiate a loader @@ -57,7 +55,15 @@

Example with Callbacks

);
- Please note three.js r84 dropped support for TextureLoader progress events. For a TextureLoader that supports progress events, see [link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-293260145 this thread]. +

+ Please note three.js r84 dropped support for TextureLoader progress events. For a TextureLoader that supports progress events, see [link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-293260145 this thread]. +

+ +

Examples

+ +

+ [example:webgl_geometry_cube geometry / cube] +

Constructor

diff --git a/docs/api/en/loaders/managers/DefaultLoadingManager.html b/docs/api/en/loaders/managers/DefaultLoadingManager.html index f608c7e1ec04b2..ade7913d6429d4 100644 --- a/docs/api/en/loaders/managers/DefaultLoadingManager.html +++ b/docs/api/en/loaders/managers/DefaultLoadingManager.html @@ -17,7 +17,7 @@

[name]

for say, textures and models.

-

Example

+

Code Example

You can optionally set the [page:LoadingManager.onStart onStart], [page:LoadingManager.onLoad onLoad], @@ -66,6 +66,8 @@

Methods

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

diff --git a/docs/api/en/loaders/managers/LoadingManager.html b/docs/api/en/loaders/managers/LoadingManager.html index 6e2df042d4f8f3..5b2686dcd9509b 100644 --- a/docs/api/en/loaders/managers/LoadingManager.html +++ b/docs/api/en/loaders/managers/LoadingManager.html @@ -19,15 +19,7 @@

[name]

- -

Example

- -

- [example:webgl_loader_fbx WebGL / loader / fbx]
- [example:webgl_loader_obj WebGL / loader / obj]
- [example:webgl_materials_reflectivity WebGL / materials / reflectivity]
- [example:webgl_postprocessing_outline WebGL / postprocesing / outline] -

+

Code Example

This example shows how to use LoadingManager to track the progress of @@ -105,6 +97,15 @@

Example

});
+

Examples

+ +

+ [example:webgl_loader_fbx WebGL / loader / fbx]
+ [example:webgl_loader_obj WebGL / loader / obj]
+ [example:webgl_materials_physical_reflectivity WebGL / materials / physical / reflectivity]
+ [example:webgl_postprocessing_outline WebGL / postprocesing / outline] +

+

Constructor

[name]( [param:Function onLoad], [param:Function onProgress], [param:Function onError] )

@@ -203,7 +204,8 @@

[method:null setURLModifier]( [param:Function callback] )

behavior can be used to load assets from .ZIP files, drag-and-drop APIs, and Data URIs.

-

+
+

Note: The following methods are designed to be called internally by loaders. You shouldn't call them directly. @@ -232,6 +234,8 @@

[method:null itemError]( [param:String url] )

Source

- [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

+ [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

diff --git a/docs/api/en/materials/LineBasicMaterial.html b/docs/api/en/materials/LineBasicMaterial.html index 8a2d95f42f4d4e..6378a7e6d7a7c6 100644 --- a/docs/api/en/materials/LineBasicMaterial.html +++ b/docs/api/en/materials/LineBasicMaterial.html @@ -14,6 +14,17 @@

[name]

A material for drawing wireframe-style geometries.

+

Code Example

+ + + var material = new THREE.LineBasicMaterial( { + color: 0xffffff, + linewidth: 1, + linecap: 'round', //ignored by WebGLRenderer + linejoin: 'round' //ignored by WebGLRenderer + } ); + +

Examples

@@ -30,18 +41,9 @@

Examples

[example:webgl_lines_dashed WebGL / lines / dashed]
[example:webgl_lines_sphere WebGL / lines / sphere]
[example:webgl_materials WebGL / materials]
- [example:webgl_physics_rope WebGL / phyics / rope] + [example:physics_ammo_rope physics / ammo / rope]

- -var material = new THREE.LineBasicMaterial( { - color: 0xffffff, - linewidth: 1, - linecap: 'round', //ignored by WebGLRenderer - linejoin: 'round' //ignored by WebGLRenderer -} ); - -

Constructor

[name]( [param:Object parameters] )

diff --git a/docs/api/en/materials/LineDashedMaterial.html b/docs/api/en/materials/LineDashedMaterial.html index e5508d25717c62..c8c79cbf5a825a 100644 --- a/docs/api/en/materials/LineDashedMaterial.html +++ b/docs/api/en/materials/LineDashedMaterial.html @@ -8,46 +8,42 @@ - [page:Material] → + [page:Material] → [page:LineBasicMaterial] →

[name]

A material for drawing wireframe-style geometries with dashed lines.

+

Code Example

+ + + var material = new THREE.LineDashedMaterial( { + color: 0xffffff, + linewidth: 1, + scale: 1, + dashSize: 3, + gapSize: 1, + } ); + +

Examples

[example:webgl_lines_dashed WebGL / lines / dashed]

- -var material = new THREE.LineDashedMaterial( { - color: 0xffffff, - linewidth: 1, - scale: 1, - dashSize: 3, - gapSize: 1, -} ); - -

Constructor

[name]( [param:Object parameters] )

[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance. - Any property of the material (including any property inherited from [page:Material]) can be passed in here.

- - The exception is the property [page:Hexadecimal color], which can be passed i as a hexadecimal - string and is *0xffffff* (white) by default. [page:Color.set]( color ) is called internally. + Any property of the material (including any property inherited from [page:LineBasicMaterial]) can be passed in here.

Properties

-

See the base [page:Material] class for common properties.

- -

[property:Color color]

-

[page:Color] of the material, by default set to white (0xffffff).

+

See the base [page:LineBasicMaterial] class for common properties.

[property:number dashSize]

The size of the dash. This is both the gap with the stroke. Default is *3*.

@@ -55,22 +51,12 @@

[property:number dashSize]

[property:number gapSize]

The size of the gap. Default is *1*.

-

[property:Float linewidth]

-

- Controls line thickness. Default is *1*.

- - Due to limitations of the [link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile] - with the [page:WebGLRenderer WebGL] renderer on most platforms linewidth will - always be 1 regardless of the set value. -

[property:number scale]

The scale of the dashed part of a line. Default is *1*.

Methods

-

See the base [page:Material] class for common methods.

- - +

See the base [page:LineBasicMaterial] class for common methods.

Source

diff --git a/docs/api/en/materials/Material.html b/docs/api/en/materials/Material.html index 09db0f2131416e..be34234301dbed 100644 --- a/docs/api/en/materials/Material.html +++ b/docs/api/en/materials/Material.html @@ -293,18 +293,9 @@

[property:Integer version]

This starts at *0* and counts how many times [property:Boolean needsUpdate] is set to *true*.

-

[property:Integer vertexColors]

+

[property:Boolean vertexColors]

- Defines whether vertex coloring is used. - Default is [page:Materials THREE.NoColors]. - Other options are [page:Materials THREE.VertexColors] and [page:Materials THREE.FaceColors]. -

- -

[property:Boolean vertexTangents]

-

- Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute, - are used. When disabled, tangents are derived automatically. Using precomputed tangents will give - more accurate normal map details in some cases, such as with mirrored UVs. Default is false. + Defines whether vertex coloring is used. Default is *false*.

[property:Boolean visible]

diff --git a/docs/api/en/materials/MeshDistanceMaterial.html b/docs/api/en/materials/MeshDistanceMaterial.html index bfea4e376e74b9..cede800a03e40c 100644 --- a/docs/api/en/materials/MeshDistanceMaterial.html +++ b/docs/api/en/materials/MeshDistanceMaterial.html @@ -19,9 +19,11 @@

[name]

The following examples demonstrates this approach in order to ensure transparent parts of objects do no cast shadows.

-

Example

+

Examples

- [example:webgl_shadowmap_pointlight WebGL / shadowmap / pointlight] +

+ [example:webgl_shadowmap_pointlight WebGL / shadowmap / pointlight] +

Examples

- [example:webgl_materials_variations_physical materials / variations / physical]
- [example:webgl_materials_reflectivity materials / reflectivity] +

+ [example:webgl_materials_variations_physical materials / variations / physical]
+ [example:webgl_materials_physical_clearcoat materials / physical / clearcoat]
+ [example:webgl_materials_physical_reflectivity materials / physical / reflectivity]
+ [example:webgl_materials_physical_transparency materials / physical / transparency] +

Constructor

@@ -57,11 +82,30 @@

Properties

[property:Float clearcoat]

- Clearcoat level, from *0.0* to *1.0*. Default is *0.0*. + Represents the thickness of the clear coat layer, from *0.0* to *1.0*. Use clear coat related properties to enable multilayer + materials that have a thin translucent layer over the base layer. Default is *0.0*.

+

[property:Texture clearcoatMap]

+

+ The red channel of this texture is multiplied against [page:.clearcoat], for per-pixel control + over a coating's thickness. Default is *null*. +

+ +

[property:Texture clearcoatNormalMap]

+

Can be used to enable independent normals for the clear coat layer. Default is *null*.

+ +

[property:Vector2 clearcoatNormalScale]

+

How much [page:.clearcoatNormalMap] affects the clear coat layer, from *(0,0)* to *(1,1)*. Default is *(1,1)*.

+

[property:Float clearcoatRoughness]

-

How rough the clearcoat appears, from *0.0* to *1.0*. Default is *0.0*.

+

Roughness of the clear coat layer, from *0.0* to *1.0*. Default is *0.0*.

+ +

[property:Texture clearcoatRoughnessMap]

+

+ The green channel of this texture is multiplied against [page:.clearcoatRoughness], for per-pixel control + over a coating's roughness. Default is *null*. +

[property:Object defines]

An object of the form: @@ -70,7 +114,7 @@

[property:Object defines]

'STANDARD': '' 'PHYSICAL': '', - + };
@@ -84,6 +128,17 @@

[property:Float reflectivity]

This models the reflectivity of non-metallic materials. It has no effect when [page:MeshStandardMaterial.metalness metalness] is *1.0*

+

[property:Float transparency]

+

+ Degree of transparency, from *0.0* to *1.0*. Default is *0.0*.
+ + Thin, transparent or semitransparent, plastic or glass materials remain largely reflective even if they are mostly transparent. + + The transparency property can be used to model these materials.
+ + When transparency is non-zero, [page:Material.opacity opacity] should be set to *1*. +

+

Methods

See the base [page:Material] and [page:MeshStandardMaterial] classes for common methods.

diff --git a/docs/api/en/materials/MeshStandardMaterial.html b/docs/api/en/materials/MeshStandardMaterial.html index 8e38df2a3784f9..e84d6d4ceac3b2 100644 --- a/docs/api/en/materials/MeshStandardMaterial.html +++ b/docs/api/en/materials/MeshStandardMaterial.html @@ -174,7 +174,7 @@

[property:TextureCube envMap]

Note: only [link:https://threejs.org/docs/#api/textures/CubeTexture cube environment maps] are supported for MeshStandardMaterial. If you want to use an equirectangular map you will need to use - [page:WebGLRenderTargetCube.fromEquirectangularTexture WebGLRenderTargetCube.fromEquirectangularTexture](). + [page:WebGLCubeRenderTarget.fromEquirectangularTexture WebGLCubeRenderTarget.fromEquirectangularTexture](). See this [link:https://threejs.org/examples/webgl_materials_envmaps_exr.html example] for details.

@@ -214,6 +214,8 @@

[property:Texture normalMap]

The texture to create a normal map. The RGB values affect the surface normal for each pixel fragment and change the way the color is lit. Normal maps do not change the actual shape of the surface, only the lighting. + In case the material has a normal map authored using the left handed convention, the y component of normalScale + should be negated to compensate for the different handedness.

[property:Integer normalMapType]

@@ -248,6 +250,13 @@

[property:Texture roughnessMap]

[property:Boolean skinning]

Define whether the material uses skinning. Default is false.

+

[property:Boolean vertexTangents]

+

+ Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute, + are used. When disabled, tangents are derived automatically. Using precomputed tangents will give + more accurate normal map details in some cases, such as with mirrored UVs. Default is false. +

+

[property:Boolean wireframe]

Render geometry as wireframe. Default is *false* (i.e. render as flat polygons).

diff --git a/docs/api/en/materials/MeshToonMaterial.html b/docs/api/en/materials/MeshToonMaterial.html index 62481c865de3d6..0b3826ea26bb89 100644 --- a/docs/api/en/materials/MeshToonMaterial.html +++ b/docs/api/en/materials/MeshToonMaterial.html @@ -147,6 +147,8 @@

[property:Texture normalMap]

The texture to create a normal map. The RGB values affect the surface normal for each pixel fragment and change the way the color is lit. Normal maps do not change the actual shape of the surface, only the lighting. + In case the material has a normal map authored using the left handed convention, the y component of normalScale + should be negated to compensate for the different handedness.

[property:Integer normalMapType]

diff --git a/docs/api/en/materials/PointsMaterial.html b/docs/api/en/materials/PointsMaterial.html index 8ac9d5dab17550..583cd78acc3de1 100644 --- a/docs/api/en/materials/PointsMaterial.html +++ b/docs/api/en/materials/PointsMaterial.html @@ -14,6 +14,30 @@

[name]

The default material used by [page:Points].

+

Code Example

+ + var vertices = []; + + for ( var i = 0; i < 10000; i ++ ) { + + var x = THREE.MathUtils.randFloatSpread( 2000 ); + var y = THREE.MathUtils.randFloatSpread( 2000 ); + var z = THREE.MathUtils.randFloatSpread( 2000 ); + + vertices.push( x, y, z ); + + } + + var geometry = new THREE.BufferGeometry(); + geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + + var material = new THREE.PointsMaterial( { color: 0x888888 } ); + + var points = new THREE.Points( geometry, material ); + + scene.add( points ); + +

Examples

[example:misc_controls_fly misc / controls / fly]
@@ -31,29 +55,7 @@

Examples

[example:webgl_trails WebGL / trails]

- -//This will add a starfield to the background of a scene -var starsGeometry = new THREE.Geometry(); - -for ( var i = 0; i < 10000; i ++ ) { - - var star = new THREE.Vector3(); - star.x = THREE.Math.randFloatSpread( 2000 ); - star.y = THREE.Math.randFloatSpread( 2000 ); - star.z = THREE.Math.randFloatSpread( 2000 ); - - starsGeometry.vertices.push( star ); - -} - -var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } ); - -var starField = new THREE.Points( starsGeometry, starsMaterial ); - -scene.add( starField ); - - -

[name]( [param:Object parameters] )

+

[name]( [param:Object parameters] )

[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance. Any property of the material (including any property inherited from [page:Material]) can be passed in here.

diff --git a/docs/api/en/materials/RawShaderMaterial.html b/docs/api/en/materials/RawShaderMaterial.html index d44a19bd0430c3..2216d2ba5e93aa 100644 --- a/docs/api/en/materials/RawShaderMaterial.html +++ b/docs/api/en/materials/RawShaderMaterial.html @@ -17,6 +17,19 @@

[name]

built-in uniforms and attributes are not automatically prepended to the GLSL shader code.

+

Code Example

+ + var material = new THREE.RawShaderMaterial( { + + uniforms: { + time: { value: 1.0 } + }, + vertexShader: document.getElementById( 'vertexShader' ).textContent, + fragmentShader: document.getElementById( 'fragmentShader' ).textContent, + + } ); + +

Examples

[example:webgl_buffergeometry_rawshader WebGL / buffergeometry / rawshader]
@@ -28,18 +41,6 @@

Examples

[example:webgl_raymarching_reflect WebGL / raymarching / reflect]

- -var material = new THREE.RawShaderMaterial( { - - uniforms: { - time: { value: 1.0 } - }, - vertexShader: document.getElementById( 'vertexShader' ).textContent, - fragmentShader: document.getElementById( 'fragmentShader' ).textContent, - -} ); - -

Constructor

[name]( [param:Object parameters] )

diff --git a/docs/api/en/materials/ShaderMaterial.html b/docs/api/en/materials/ShaderMaterial.html index 860dd9822a9c80..ece5ed7c7ce235 100644 --- a/docs/api/en/materials/ShaderMaterial.html +++ b/docs/api/en/materials/ShaderMaterial.html @@ -35,7 +35,7 @@

[name]

using [page:BufferAttribute] instances to define custom attributes.
  • - As of THREE r77, [page:WebGLRenderTarget] or [page:WebGLRenderTargetCube] instances + As of THREE r77, [page:WebGLRenderTarget] or [page:WebGLCubeRenderTarget] instances are no longer supposed to be used as uniforms. Their [page:Texture texture] property must be used instead.
  • @@ -45,7 +45,7 @@

    [name]

    [page:RawShaderMaterial] instead of this class.
  • - You can use the directive #pragma unroll_loop in order to unroll a *for* loop in GLSL by the shader preprocessor. + You can use the directive #pragma unroll_loop_start and #pragma unroll_loop_end in order to unroll a *for* loop in GLSL by the shader preprocessor. The directive has to be placed right above the loop. The loop formatting has to correspond to a defined standard.
    • @@ -59,17 +59,37 @@

      [name]

    - #pragma unroll_loop + #pragma unroll_loop_start for ( int i = 0; i < 10; i ++ ) { // ... } + #pragma unroll_loop_end
  • +

    Code Example

    + + + var material = new THREE.ShaderMaterial( { + + uniforms: { + + time: { value: 1.0 }, + resolution: { value: new THREE.Vector2() } + + }, + + vertexShader: document.getElementById( 'vertexShader' ).textContent, + + fragmentShader: document.getElementById( 'fragmentShader' ).textContent + + } ); + +

    Examples

    @@ -101,26 +121,8 @@

    Examples

    [example:webgl_nearestneighbour webgl / nearestneighbour]
    [example:webgl_postprocessing_dof2 webgl / postprocessing / dof2]
    [example:webgl_postprocessing_godrays webgl / postprocessing / godrays] -

    - - var material = new THREE.ShaderMaterial( { - - uniforms: { - - time: { value: 1.0 }, - resolution: { value: new THREE.Vector2() } - - }, - - vertexShader: document.getElementById( 'vertexShader' ).textContent, - - fragmentShader: document.getElementById( 'fragmentShader' ).textContent - - } ); - -

    Vertex shaders and fragment shaders

    @@ -260,8 +262,8 @@

    Custom attributes and uniforms

    You're recommended to update custom [page:Uniform] values depending on [page:Object3D object] and [page:Camera camera] in [page:Object3D.onBeforeRender] because [page:Material] can be shared among [page:Mesh meshes], [page:Matrix4 matrixWorld] - of [page:Scene] and [page:Camera] are updated in [page:WebGLRenderer.render], and some effects(ex:VREffect) render a [page:Scene scene] - with private their own [page:Camera cameras]. + of [page:Scene] and [page:Camera] are updated in [page:WebGLRenderer.render], and some effects render a [page:Scene scene] + with their own private [page:Camera cameras].

    @@ -409,12 +411,14 @@

    [property:Object uniforms]

    so updating the value of the uniform will immediately update the value available to the GLSL code.

    +

    [property:Boolean uniformsNeedUpdate]

    +

    + Can be used to force a uniform update while changing uniforms in [page:Object3D.onBeforeRender](). Default is *false*. +

    -

    [property:Number vertexColors]

    +

    [property:Boolean vertexColors]

    - Define how the vertices are colored, by defining how the *colors* attribute gets populated. - Possible values are [page:Materials THREE.NoColors], [page:Materials THREE.FaceColors] and - [page:Materials THREE.VertexColors]. Default is THREE.NoColors. + Defines whether vertex coloring is used. Default is *false*.

    [property:String vertexShader]

    diff --git a/docs/api/en/materials/ShadowMaterial.html b/docs/api/en/materials/ShadowMaterial.html index b85845d3940d4c..562a2340b4fa7c 100644 --- a/docs/api/en/materials/ShadowMaterial.html +++ b/docs/api/en/materials/ShadowMaterial.html @@ -8,7 +8,7 @@ - [page:Material] → [page:ShaderMaterial] → + [page:Material] →

    [name]

    @@ -16,39 +16,44 @@

    [name]

    This material can receive shadows, but otherwise is completely transparent.

    -

    Example

    - [example:webgl_geometry_spline_editor geometry / spline / editor] +

    Code Example

    -var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 ); -planeGeometry.rotateX( - Math.PI / 2 ); + var planeGeometry = new THREE.PlaneBufferGeometry( 2000, 2000 ); + planeGeometry.rotateX( - Math.PI / 2 ); -var planeMaterial = new THREE.ShadowMaterial(); -planeMaterial.opacity = 0.2; + var planeMaterial = new THREE.ShadowMaterial(); + planeMaterial.opacity = 0.2; -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.position.y = -200; -plane.receiveShadow = true; -scene.add( plane ); + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.position.y = -200; + plane.receiveShadow = true; + scene.add( plane ); +

    Examples

    + +

    + [example:webgl_geometry_spline_editor geometry / spline / editor] +

    +

    Constructor

    [name]( [param:Object parameters] )

    [page:Object parameters] - (optional) an object with one or more properties defining the material's appearance. - Any property of the material (including any property inherited from [page:Material] and [page:ShaderMaterial]) can be passed in here.

    + Any property of the material (including any property inherited from [page:Material]) can be passed in here.

    Properties

    -

    See the base [page:Material] and [page:ShaderMaterial] classes for common properties.

    +

    See the base [page:Material] classes for common properties.

    [property:Boolean transparent]

    Defines whether this material is transparent. Default is *true*.

    Methods

    -

    See the base [page:Material] and [page:ShaderMaterial] classes for common methods.

    +

    See the base [page:Material] classes for common methods.

    Source

    diff --git a/docs/api/en/materials/SpriteMaterial.html b/docs/api/en/materials/SpriteMaterial.html index b2c17afc9c4d0c..d5cb2991511277 100644 --- a/docs/api/en/materials/SpriteMaterial.html +++ b/docs/api/en/materials/SpriteMaterial.html @@ -14,26 +14,28 @@

    [name]

    A material for a use with a [page:Sprite].

    -

    Examples

    -
    - [example:webgl_sprites WebGL / sprites]
    - [example:software_sandbox software / sandbox]
    - [example:svg_sandbox svg / sandbox]
    - [example:webgl_materials_cubemap_dynamic webgl / materials / cubemap / dynamic] -
    +

    Code Example

    -var spriteMap = new THREE.TextureLoader().load( 'textures/sprite.png' ); - -var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); + var spriteMap = new THREE.TextureLoader().load( 'textures/sprite.png' ); -var sprite = new THREE.Sprite( spriteMaterial ); -sprite.scale.set(200, 200, 1) + var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); -scene.add( sprite ); + var sprite = new THREE.Sprite( spriteMaterial ); + sprite.scale.set(200, 200, 1) + scene.add( sprite ); +

    Examples

    +

    + [example:webgl_sprites webGL / sprites]
    + [example:software_sandbox software / sandbox]
    + [example:svg_sandbox svg / sandbox]
    + [example:webgl_materials_cubemap_dynamic webgl / materials / cubemap / dynamic] +

    + +

    Constructor

    [name]( [param:Object parameters] )

    diff --git a/docs/api/en/math/Box2.html b/docs/api/en/math/Box2.html index 85dff58180d75f..8c3101b5c62f20 100644 --- a/docs/api/en/math/Box2.html +++ b/docs/api/en/math/Box2.html @@ -11,7 +11,7 @@

    [name]

    - Represents a box in 2D space. + Represents an axis-aligned bounding box (AABB) in 2D space.

    diff --git a/docs/api/en/math/Box3.html b/docs/api/en/math/Box3.html index 29d7485ea91661..bd35df8ca2b5bc 100644 --- a/docs/api/en/math/Box3.html +++ b/docs/api/en/math/Box3.html @@ -11,32 +11,29 @@

    [name]

    - Represents a box or cube in 3D space. The main purpose of this is to represent - the world-axis-aligned bounding boxes for objects. + Represents an axis-aligned bounding box (AABB) in 3D space.

    - -

    Example

    +

    Code Example

    - // Creating the object whose bounding box we want to compute - var sphereObject = new THREE.Mesh( - new THREE.SphereGeometry(), - new THREE.MeshBasicMaterial( 0xff0000 ) + var box = new THREE.Box3(); + + var mesh = new THREE.Mesh( + new THREE.SphereBufferGeometry(), + new THREE.MeshBasicMaterial() ); - // Creating the actual bounding box with Box3 - sphereObject.geometry.computeBoundingBox(); - var box = sphereObject.geometry.boundingBox.clone(); + + // ensure the bounding box is computed for its geometry + // this should be done only once (assuming static geometries) + mesh.geometry.computeBoundingBox(); // ... - - // In the animation loop, to keep the bounding box updated after move/rotate/scale operations - sphereObject.updateMatrixWorld( true ); - box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld ); - + // in the animation loop, compute the current bounding box with the world matrix + box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld ); +
    -

    Constructor

    diff --git a/docs/api/en/math/Color.html b/docs/api/en/math/Color.html index 0d86b1ce16a52b..baebef469a3e51 100644 --- a/docs/api/en/math/Color.html +++ b/docs/api/en/math/Color.html @@ -14,9 +14,11 @@

    [name]

    Class representing a color.

    +

    Code Examples

    -

    Examples

    - A Color can be initialised in any of the following ways: +

    + A Color can be initialised in any of the following ways: +

    //empty constructor - will default white var color = new THREE.Color(); @@ -39,8 +41,6 @@

    Examples

    var color = new THREE.Color( 1, 0, 0 );
    - -

    Constructor

    diff --git a/docs/api/en/math/Euler.html b/docs/api/en/math/Euler.html index db5833945797db..16b22c85059190 100644 --- a/docs/api/en/math/Euler.html +++ b/docs/api/en/math/Euler.html @@ -17,7 +17,7 @@

    [name]

    axes in specified amounts per axis, and a specified axis order.

    -

    Example

    +

    Code Example

    var a = new THREE.Euler( 0, 1, 1.57, 'XYZ' ); var b = new THREE.Vector3( 1, 0, 1 ); diff --git a/docs/api/en/math/Frustum.html b/docs/api/en/math/Frustum.html index 6e4c60afc351e9..fd2392afb6fcbb 100644 --- a/docs/api/en/math/Frustum.html +++ b/docs/api/en/math/Frustum.html @@ -89,32 +89,19 @@

    [method:Boolean intersectsSprite]( [param:Sprite sprite] )

    Checks whether the [page:Sprite sprite] is intersecting the Frustum.

    -

    [method:Frustum set]( [param:Plane p0], [param:Plane p1], [param:Plane p2], [param:Plane p3], [param:Plane p4], [param:Plane p5] )

    +

    [method:this set]( [param:Plane p0], [param:Plane p1], [param:Plane p2], [param:Plane p3], [param:Plane p4], [param:Plane p5] )

    - Sets the current frustum from the passed planes. No plane order is implicitely implied.
    - Please note that this method only copies the values from the given objects. + Sets the frustum from the passed planes. No plane order is implied.
    + Note that this method only copies the values from the given objects.

    -

    [method:Frustum setFromMatrix]( [param:Matrix4 matrix] )

    +

    [method:this setFromProjectionMatrix]( [param:Matrix4 matrix] )

    - [page:Matrix4 matrix] - [page:Matrix4] used to set the [page:.planes planes]

    - - This is used by the [page:WebGLRenderer] to set up the Frustum from a [page:Camera Camera]'s - [page:Camera.projectionMatrix projectionMatrix] and [page:Camera.matrixWorldInverse matrixWorldInverse]. + [page:Matrix4 matrix] - Projection [page:Matrix4] used to set the [page:.planes planes]

    + Sets the frustum planes from the projection matrix.

    - - - - - - - - - - -

    Source

    diff --git a/docs/api/en/math/Line3.html b/docs/api/en/math/Line3.html index 59cde37e8ffc36..5c27924abf16e8 100644 --- a/docs/api/en/math/Line3.html +++ b/docs/api/en/math/Line3.html @@ -98,7 +98,7 @@

    [method:Boolean equals]( [param:Line3 line] )

    [page:Line3 line] - [page:Line3] to compare with this one.

    - Returns true if both line's [page:.start start] and [page:.end en] points are equal. + Returns true if both line's [page:.start start] and [page:.end end] points are equal.

    [method:Vector3 getCenter]( [param:Vector3 target] )

    diff --git a/docs/api/en/math/Math.html b/docs/api/en/math/MathUtils.html similarity index 81% rename from docs/api/en/math/Math.html rename to docs/api/en/math/MathUtils.html index bb84bd1a92aa48..d881b4f6497bab 100644 --- a/docs/api/en/math/Math.html +++ b/docs/api/en/math/MathUtils.html @@ -105,6 +105,19 @@

    [method:Float smootherstep]( [param:Float x], [param:Float min], [param:Floa that has zero 1st and 2nd order derivatives at x=0 and x=1.

    +

    [method:null setQuaternionFromProperEuler]( [param:Quaternion q], [param:Float a], [param:Float b], [param:Float c], [param:String order] )

    +

    + [page:Quaternion q] - the quaternion to be set
    + [page:Float a] - the rotation applied to the first axis, in radians
    + [page:Float b] - the rotation applied to the second axis, in radians
    + [page:Float c] - the rotation applied to the third axis, in radians
    + [page:String order] - a string specifying the axes order: 'XYX', 'XZX', 'YXY', 'YZY', 'ZXZ', or 'ZYZ'

    + + Sets quaternion [page:Quaternion q] from the [link:http://en.wikipedia.org/wiki/Euler_angles intrinsic Proper Euler Angles] defined by angles [page:Float a], [page:Float b], and [page:Float c], and order [page:String order].
    + + Rotations are applied to the axes in the order specified by [page:String order]: rotation by angle [page:Float a] is applied first, then by angle [page:Float b], then by angle [page:Float c]. Angles are in radians. +

    +

    Source

    diff --git a/docs/api/en/math/Matrix3.html b/docs/api/en/math/Matrix3.html index 4911fe002aa3d9..fd19b76a8a3647 100644 --- a/docs/api/en/math/Matrix3.html +++ b/docs/api/en/math/Matrix3.html @@ -14,7 +14,7 @@

    [name]

    A class representing a 3x3 [link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].

    -

    Example

    +

    Code Example

    var m = new Matrix3(); @@ -65,14 +65,6 @@

    [property:Array elements]

    Methods

    -

    [method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )

    -

    - [page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.

    - - Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute]. -

    - -

    [method:Matrix3 clone]()

    Creates a new Matrix3 and with identical elements to this one.

    @@ -88,6 +80,23 @@

    [method:Float determinant]()

    [method:Boolean equals]( [param:Matrix3 m] )

    Return true if this matrix and [page:Matrix3 m] are equal.

    +

    [method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )

    +

    + Extracts the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis] of this + matrix into the three axis vectors provided. If this matrix is: + +a, b, c, +d, e, f, +g, h, i + + then the [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] will be set to: + +xAxis = (a, d, g) +yAxis = (b, e, h) +zAxis = (c, f, i) + +

    +

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    [page:Array array] - the array to read the elements from.
    @@ -97,15 +106,14 @@

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.

    -

    [method:this getInverse]( [param:Matrix3 m], [param:Boolean throwOnDegenerate] )

    +

    [method:this getInverse]( [param:Matrix3 m] )

    - [page:Matrix3 m] - the matrix to take the inverse of.
    - [page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).

    + [page:Matrix3 m] - the matrix to take the inverse of.

    Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m], using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method]. - If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 3x3 identity matrix. + You can not invert a matrix with a determinant of zero. If you attempt this, the method returns a zero matrix instead.

    [method:this getNormalMatrix]( [param:Matrix4 m] )

    diff --git a/docs/api/en/math/Matrix4.html b/docs/api/en/math/Matrix4.html index 24211ca60709a0..4cd3467c14fea4 100644 --- a/docs/api/en/math/Matrix4.html +++ b/docs/api/en/math/Matrix4.html @@ -77,6 +77,24 @@

    A Note on Row-Major and Column-Major Ordering

    code, you'll have to take the [link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices outlined here to make sense of the calculations.

    +

    Extracting position, rotation and scale

    +

    + There are several options available for extracting position, rotation and scale from a Matrix4. +

      +
    • + [page:Vector3.setFromMatrixPosition]: can be used to extract the translation component. +
    • +
    • + [page:Vector3.setFromMatrixScale]: can be used to extract the scale component. +
    • +
    • + [page:Quaternion.setFromRotationMatrix], [page:Euler.setFromRotationMatrix] or [page:.extractRotation extractRotation] can be used to extract the rotation component. +
    • +
    • + [page:.decompose decompose] can be used to extract position, rotation and scale all at once. +
    • +
    +

    Constructor

    @@ -101,14 +119,6 @@

    [property:Array elements]

    Methods

    -

    [method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )

    -

    - [page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.

    - - Multiplies (applies) this matrix to every 3D vector in the [page:BufferAttribute attribute]. -

    - -

    [method:Matrix4 clone]()

    Creates a new Matrix4 with identical [page:.elements elements] to this one.

    @@ -180,15 +190,14 @@

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.

    -

    [method:this getInverse]( [param:Matrix4 m], [param:Boolean throwOnDegenerate] )

    +

    [method:this getInverse]( [param:Matrix4 m] )

    - [page:Matrix4 m] - the matrix to take the inverse of.
    - [page:Boolean throwOnDegenerate] - (optional) If true, throw an error if the matrix is degenerate (not invertible).

    + [page:Matrix4 m] - the matrix to take the inverse of.

    Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix4 m], using the method outlined [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm here]. - If [page:Boolean throwOnDegenerate] is not set and the matrix is not invertible, set this to the 4x4 identity matrix. + You can not invert a matrix with a determinant of zero. If you attempt this, the method returns a zero matrix instead.

    diff --git a/docs/api/en/math/Quaternion.html b/docs/api/en/math/Quaternion.html index 50aa96f37f816a..0f91e0add7a52e 100644 --- a/docs/api/en/math/Quaternion.html +++ b/docs/api/en/math/Quaternion.html @@ -11,15 +11,11 @@

    [name]

    - Implementation of a [link:http://en.wikipedia.org/wiki/Quaternion quaternion]. - This is used for [link:https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation rotating things] - without encountering the dreaded - [link:http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock] issue, amongst other - advantages. + Implementation of a [link:http://en.wikipedia.org/wiki/Quaternion quaternion].
    + Quaternions are used in three.js to represent [link:https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation rotations].

    - -

    Example

    +

    Code Example

    var quaternion = new THREE.Quaternion(); @@ -113,7 +109,7 @@

    [method:Float length]()

    [method:Float lengthSq]()

    - Computes the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] + Computes the squared [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] (straight-line length) of this quaternion, considered as a 4 dimensional vector. This can be useful if you are comparing the lengths of two quaternions, as this is a slightly more efficient calculation than [page:.length length](). @@ -199,6 +195,14 @@

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    Returns the numerical elements of this quaternion in an array of format [x, y, z, w].

    +

    [method:this fromBufferAttribute]( [param:BufferAttribute attribute], [param:Integer index] )

    +

    + [page:BufferAttribute attribute] - the source attribute.
    + [page:Integer index] - index in the attribute.

    + + Sets [page:.x x], [page:.y y], [page:.z z], [page:.w w] properties of this quaternion from the [page:BufferAttribute attribute]. +

    +

    Static Methods

    diff --git a/docs/api/en/math/Sphere.html b/docs/api/en/math/Sphere.html index 0816a839e7322b..32034b754319ff 100644 --- a/docs/api/en/math/Sphere.html +++ b/docs/api/en/math/Sphere.html @@ -16,7 +16,7 @@

    Constructor

    [name]( [param:Vector3 center], [param:Float radius] )

    [page:Vector3 center] - center of the sphere. Default is a [page:Vector3] at (0, 0, 0).
    - [page:Float radius] - radius of the sphere. Default is 0.

    + [page:Float radius] - radius of the sphere. Default is -1.

    Creates a new [name]. @@ -46,8 +46,8 @@

    [method:Vector3 clampPoint]( [param:Vector3 point], [param:Vector3 target] ) [page:Vector3 point] - [page:Vector3] The point to clamp.
    [page:Vector3 target] — the result will be copied into this Vector3.

    - Clamps a point within the sphere. If the point is is outside the sphere, it will clamp it to the - closets point on the edge of the sphere. Points already inside the sphere will not be affected. + Clamps a point within the sphere. If the point is outside the sphere, it will clamp it to the + closest point on the edge of the sphere. Points already inside the sphere will not be affected.

    [method:Sphere clone]()

    @@ -73,8 +73,14 @@

    [method:Float distanceToPoint]( [param:Vector3 point] )

    the distance will be negative.

    -

    [method:Boolean empty]()

    -

    Checks to see if the sphere is empty (the radius set to 0).

    +

    [method:Boolean isEmpty]()

    +

    + Checks to see if the sphere is empty (the radius set to a negative number).
    + Spheres with a radius of 0 contain only their center point and are not considered to be empty. +

    + +

    [method:Sphere makeEmpty]()

    +

    Makes the sphere empty by setting [page:.center center] to (0, 0, 0) and [page:.radius radius] to -1.

    [method:Boolean equals]( [param:Sphere sphere] )

    diff --git a/docs/api/en/math/Vector2.html b/docs/api/en/math/Vector2.html index 1342fe3154ee2c..2de674a29c265f 100644 --- a/docs/api/en/math/Vector2.html +++ b/docs/api/en/math/Vector2.html @@ -37,7 +37,7 @@

    [name]

    vectors, complex numbers and so on, however these are the most common uses in three.js.

    -

    Example

    +

    Code Example

    var a = new THREE.Vector2( 0, 1 ); @@ -53,8 +53,8 @@

    Constructor

    [name]( [param:Float x], [param:Float y] )

    - [page:Float x] - the x value of the vector. Default is *0*.
    - [page:Float y] - the y value of the vector. Default is *0*.

    + [page:Float x] - the x value of this vector. Default is *0*.
    + [page:Float y] - the y value of this vector. Default is *0*.

    Creates a new [name].

    @@ -99,7 +99,7 @@

    [method:this applyMatrix3]( [param:Matrix3 m] )

    [method:this ceil]()

    - The [page:.x x] and [page:.y y] components of the vector are rounded up to the nearest integer value. + The [page:.x x] and [page:.y y] components of this vector are rounded up to the nearest integer value.

    [method:this clamp]( [param:Vector2 min], [param:Vector2 max] )

    @@ -169,7 +169,7 @@

    [method:Float dot]( [param:Vector2 v] )

    Calculates the [link:https://en.wikipedia.org/wiki/Dot_product dot product] of this vector and [page:Vector2 v].

    - +

    [method:Float cross]( [param:Vector2 v] )

    Calculates the [link:https://en.wikipedia.org/wiki/Cross_product cross product] of this @@ -180,7 +180,7 @@

    [method:Boolean equals]( [param:Vector2 v] )

    Checks for strict equality of this vector and [page:Vector2 v].

    [method:this floor]()

    -

    The components of the vector are rounded down to the nearest integer value.

    +

    The components of this vector are rounded down to the nearest integer value.

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    @@ -247,7 +247,7 @@

    [method:this negate]()

    [method:this normalize]()

    - Converts this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction + Converts this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to a vector with the same direction as this one, but [page:.length length] 1.

    @@ -275,15 +275,15 @@

    [method:this rotateAround]( [param:Vector2 center], [param:float angle] ) [page:float angle] - the angle to rotate, in radians.

    - Rotates the vector around [page:Vector2 center] by [page:float angle] radians. + Rotates this vector around [page:Vector2 center] by [page:float angle] radians.

    [method:this round]()

    -

    The components of the vector are rounded to the nearest integer value.

    +

    The components of this vector are rounded to the nearest integer value.

    [method:this roundToZero]()

    - The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value. + The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.

    [method:this set]( [param:Float x], [param:Float y] )

    @@ -300,7 +300,7 @@

    [method:null setComponent]( [param:Integer index], [param:Float value] )

    [method:this setLength]( [param:Float l] )

    - Sets this vector to the vector with the same direction as this one, but [page:.length length] + Sets this vector to a vector with the same direction as this one, but [page:.length length] [page:Float l].

    @@ -326,12 +326,17 @@

    [method:this subVectors]( [param:Vector2 a], [param:Vector2 b] )

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    - [page:Array array] - (optional) array to store the vector to. If this is not provided, a new array will be created.
    + [page:Array array] - (optional) array to store this vector to. If this is not provided, a new array will be created.
    [page:Integer offset] - (optional) optional offset into the array.

    Returns an array [x, y], or copies x and y into the provided [page:Array array].

    +

    [method:this random]()

    +

    + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

    +

    Source

    diff --git a/docs/api/en/math/Vector3.html b/docs/api/en/math/Vector3.html index 8f7be658855173..c803a4dfc9c61d 100644 --- a/docs/api/en/math/Vector3.html +++ b/docs/api/en/math/Vector3.html @@ -37,15 +37,15 @@

    [name]

    -

    Example

    +

    Code Example

    -var a = new THREE.Vector3( 0, 1, 0 ); + var a = new THREE.Vector3( 0, 1, 0 ); -//no arguments; will be initialised to (0, 0, 0) -var b = new THREE.Vector3( ); + //no arguments; will be initialised to (0, 0, 0) + var b = new THREE.Vector3( ); -var d = a.distanceTo( b ); + var d = a.distanceTo( b ); @@ -53,9 +53,9 @@

    Constructor

    [name]( [param:Float x], [param:Float y], [param:Float z] )

    - [page:Float x] - the x value of the vector. Default is *0*.
    - [page:Float y] - the y value of the vector. Default is *0*.
    - [page:Float z] - the z value of the vector. Default is *0*.

    + [page:Float x] - the x value of this vector. Default is *0*.
    + [page:Float y] - the y value of this vector. Default is *0*.
    + [page:Float z] - the z value of this vector. Default is *0*.

    Creates a new [name].

    @@ -117,12 +117,12 @@

    [method:this applyQuaternion]( [param:Quaternion quaternion] )

    [method:Float angleTo]( [param:Vector3 v] )

    - Returns the angle between this vector and vector [page:Vector3 v] in radians. Neither this vector nor [page:Vector3 v] can be the zero vector. + Returns the angle between this vector and vector [page:Vector3 v] in radians.

    [method:this ceil]()

    - The [page:.x x], [page:.y y] and [page:.z z] components of the vector are rounded up to the nearest integer value. + The [page:.x x], [page:.y y] and [page:.z z] components of this vector are rounded up to the nearest integer value.

    [method:this clamp]( [param:Vector3 min], [param:Vector3 max] )

    @@ -207,7 +207,7 @@

    [method:Boolean equals]( [param:Vector3 v] )

    Checks for strict equality of this vector and [page:Vector3 v].

    [method:this floor]()

    -

    The components of the vector are rounded down to the nearest integer value.

    +

    The components of this vector are rounded down to the nearest integer value.

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    @@ -297,7 +297,7 @@

    [method:this negate]()

    [method:this normalize]()

    - Convert this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction + Convert this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to a vector with the same direction as this one, but [page:.length length] 1.

    @@ -305,7 +305,7 @@

    [method:this project]( [param:Camera camera] )

    [page:Camera camera] — camera to use in the projection.

    - [link:https://en.wikipedia.org/wiki/Vector_projection Projects] the vector with the camera. + Projects this vector from world space into the camera's normalized device coordinate (NDC) space.

    [method:this projectOnPlane]( [param:Vector3 planeNormal] )

    @@ -317,22 +317,22 @@

    [method:this projectOnPlane]( [param:Vector3 planeNormal] )

    [method:this projectOnVector]( [param:Vector3 v] )

    -

    [link:https://en.wikipedia.org/wiki/Vector_projection Projects] this vector onto [page:Vector3 v]. [page:Vector3 v] cannot be the zero vector.

    +

    [link:https://en.wikipedia.org/wiki/Vector_projection Projects] this vector onto [page:Vector3 v].

    [method:this reflect]( [param:Vector3 normal] )

    [page:Vector3 normal] - the normal to the reflecting plane

    - Reflect the vector off of plane orthogonal to [page:Vector3 normal]. Normal is assumed to + Reflect this vector off of plane orthogonal to [page:Vector3 normal]. Normal is assumed to have unit length.

    [method:this round]()

    -

    The components of the vector are rounded to the nearest integer value.

    +

    The components of this vector are rounded to the nearest integer value.

    [method:this roundToZero]()

    - The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value. + The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.

    [method:this set]( [param:Float x], [param:Float y], [param:Float z] )

    @@ -358,8 +358,12 @@

    [method:this setFromCylindricalCoords]( [param:Float radius], [param:Float t

    [method:this setFromMatrixColumn]( [param:Matrix4 matrix], [param:Integer index] )

    - Sets this vector's [page:.x x], [page:.y y] and [page:.z z] equal to the column of - the [page:Matrix4 matrix] specified by the [page:Integer index]. + Sets this vector's [page:.x x], [page:.y y] and [page:.z z] components from [page:Integer index] column of [page:Matrix4 matrix]. +

    + +

    [method:this setFromMatrix3Column]( [param:Matrix3 matrix], [param:Integer index] )

    +

    + Sets this vector's [page:.x x], [page:.y y] and [page:.z z] components from [page:Integer index] column of [page:Matrix3 matrix].

    [method:this setFromMatrixPosition]( [param:Matrix4 m] )

    @@ -384,7 +388,7 @@

    [method:this setFromSphericalCoords]( [param:Float radius], [param:Float phi

    [method:this setLength]( [param:Float l] )

    - Set this vector to the vector with the same direction as this one, but [page:.length length] + Set this vector to a vector with the same direction as this one, but [page:.length length] [page:Float l].

    @@ -413,7 +417,7 @@

    [method:this subVectors]( [param:Vector3 a], [param:Vector3 b] )

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    - [page:Array array] - (optional) array to store the vector to. If this is not provided + [page:Array array] - (optional) array to store this vector to. If this is not provided a new array will be created.
    [page:Integer offset] - (optional) optional offset into the array.

    @@ -430,10 +434,13 @@

    [method:this unproject]( [param:Camera camera] )

    [page:Camera camera] — camera to use in the projection.

    - [link:https://en.wikipedia.org/wiki/Vector_projection Unprojects] the vector with the - camera's projection matrix. + Projects this vector from the camera's normalized device coordinate (NDC) space into world space.

    +

    [method:this random]()

    +

    + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

    Source

    diff --git a/docs/api/en/math/Vector4.html b/docs/api/en/math/Vector4.html index 963c54ae5d8b15..2329e20af4e437 100644 --- a/docs/api/en/math/Vector4.html +++ b/docs/api/en/math/Vector4.html @@ -36,15 +36,15 @@

    [name]

    -

    Example

    +

    Code Example

    -var a = new THREE.Vector4( 0, 1, 0, 0 ); + var a = new THREE.Vector4( 0, 1, 0, 0 ); -//no arguments; will be initialised to (0, 0, 0, 1) -var b = new THREE.Vector4( ); + //no arguments; will be initialised to (0, 0, 0, 1) + var b = new THREE.Vector4( ); -var d = a.dot( b ); + var d = a.dot( b ); @@ -52,10 +52,10 @@

    Constructor

    [name]( [param:Float x], [param:Float y], [param:Float z], [param:Float w] )

    - [page:Float x] - the x value of the vector. Default is *0*.
    - [page:Float y] - the y value of the vector. Default is *0*.
    - [page:Float z] - the z value of the vector. Default is *0*.
    - [page:Float w] - the w value of the vector. Default is *1*.

    + [page:Float x] - the x value of this vector. Default is *0*.
    + [page:Float y] - the y value of this vector. Default is *0*.
    + [page:Float z] - the z value of this vector. Default is *0*.
    + [page:Float w] - the w value of this vector. Default is *1*.

    Creates a new [name].

    @@ -99,7 +99,7 @@

    [method:this applyMatrix4]( [param:Matrix4 m] )

    [method:this ceil]()

    - The [page:.x x], [page:.y y], [page:.z z] and [page:.w w] components of the vector are rounded up to the nearest integer value. + The [page:.x x], [page:.y y], [page:.z z] and [page:.w w] components of this vector are rounded up to the nearest integer value.

    [method:this clamp]( [param:Vector4 min], [param:Vector4 max] )

    @@ -156,7 +156,7 @@

    [method:Boolean equals]( [param:Vector4 v] )

    Checks for strict equality of this vector and [page:Vector4 v].

    [method:this floor]()

    -

    The components of the vector are rounded down to the nearest integer value.

    +

    The components of this vector are rounded down to the nearest integer value.

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    @@ -226,7 +226,7 @@

    [method:this negate]()

    [method:this normalize]()

    - Converts this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to the vector with the same direction + Converts this vector to a [link:https://en.wikipedia.org/wiki/Unit_vector unit vector] - that is, sets it equal to a vector with the same direction as this one, but [page:.length length] 1.

    @@ -246,11 +246,11 @@

    [method:this multiplyScalar]( [param:Float s] )

    Multiplies this vector by scalar [page:Float s].

    [method:this round]()

    -

    The components of the vector are rounded to the nearest integer value.

    +

    The components of this vector are rounded to the nearest integer value.

    [method:this roundToZero]()

    - The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value. + The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.

    [method:this set]( [param:Float x], [param:Float y], [param:Float z], [param:Float w] )

    @@ -285,7 +285,7 @@

    [method:null setComponent]( [param:Integer index], [param:Float value] )

    [method:this setLength]( [param:Float l] )

    - Sets this vector to the vector with the same direction as this one, but [page:.length length] + Sets this vector to a vector with the same direction as this one, but [page:.length length] [page:Float l].

    @@ -317,12 +317,17 @@

    [method:this subVectors]( [param:Vector4 a], [param:Vector4 b] )

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    - [page:Array array] - (optional) array to store the vector to. If this is not provided, a new array will be created.
    + [page:Array array] - (optional) array to store this vector to. If this is not provided, a new array will be created.
    [page:Integer offset] - (optional) optional offset into the array.

    Returns an array [x, y, z, w], or copies x, y, z and w into the provided [page:Array array].

    +

    [method:this random]()

    +

    + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

    +

    Source

    diff --git a/docs/api/en/math/interpolants/CubicInterpolant.html b/docs/api/en/math/interpolants/CubicInterpolant.html index 6d88b412602117..0cc29820369f7d 100644 --- a/docs/api/en/math/interpolants/CubicInterpolant.html +++ b/docs/api/en/math/interpolants/CubicInterpolant.html @@ -16,7 +16,7 @@

    [name]

    -

    Example

    +

    Code Example

    var interpolant = new THREE.[name]( diff --git a/docs/api/en/math/interpolants/DiscreteInterpolant.html b/docs/api/en/math/interpolants/DiscreteInterpolant.html index 6d88b412602117..0cc29820369f7d 100644 --- a/docs/api/en/math/interpolants/DiscreteInterpolant.html +++ b/docs/api/en/math/interpolants/DiscreteInterpolant.html @@ -16,7 +16,7 @@

    [name]

    -

    Example

    +

    Code Example

    var interpolant = new THREE.[name]( diff --git a/docs/api/en/math/interpolants/LinearInterpolant.html b/docs/api/en/math/interpolants/LinearInterpolant.html index 6d88b412602117..0cc29820369f7d 100644 --- a/docs/api/en/math/interpolants/LinearInterpolant.html +++ b/docs/api/en/math/interpolants/LinearInterpolant.html @@ -16,7 +16,7 @@

    [name]

    -

    Example

    +

    Code Example

    var interpolant = new THREE.[name]( diff --git a/docs/api/en/math/interpolants/QuaternionLinearInterpolant.html b/docs/api/en/math/interpolants/QuaternionLinearInterpolant.html index 6d88b412602117..0cc29820369f7d 100644 --- a/docs/api/en/math/interpolants/QuaternionLinearInterpolant.html +++ b/docs/api/en/math/interpolants/QuaternionLinearInterpolant.html @@ -16,7 +16,7 @@

    [name]

    -

    Example

    +

    Code Example

    var interpolant = new THREE.[name]( diff --git a/docs/api/en/objects/Bone.html b/docs/api/en/objects/Bone.html index c31d346c2f9f58..3c0c9548ed70ae 100644 --- a/docs/api/en/objects/Bone.html +++ b/docs/api/en/objects/Bone.html @@ -17,7 +17,7 @@

    [name]

    Bones are almost identical to a blank [page:Object3D].

    -

    Example

    +

    Code Example

    var root = new THREE.Bone(); diff --git a/docs/api/en/objects/Group.html b/docs/api/en/objects/Group.html index 7a6ee283787b5c..953072baa5bd56 100644 --- a/docs/api/en/objects/Group.html +++ b/docs/api/en/objects/Group.html @@ -17,8 +17,7 @@

    [name]

    with groups of objects syntactically clearer.

    - -

    Example

    +

    Code Example

    var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); diff --git a/docs/api/en/objects/InstancedMesh.html b/docs/api/en/objects/InstancedMesh.html index a58354fe1ad810..ad1656038a84f2 100644 --- a/docs/api/en/objects/InstancedMesh.html +++ b/docs/api/en/objects/InstancedMesh.html @@ -17,11 +17,18 @@

    [name]

    objects with the same geometry and material but with different world transformations. The usage of [name] will help you to reduce the number of draw calls and thus improve the overall rendering performance in your application.

    +

    + The current implementation requires that materials are not shared between [name] and other 3D objects. +

    -

    Example

    +

    Examples

    - [example:webgl_instancing_suzanne WebGL / instancing / suzanne]
    + [example:webgl_instancing_dynamic WebGL / instancing / dynamic]
    + [example:webgl_instancing_modified WebGL / instancing / modified]
    + [example:webgl_instancing_performance WebGL / instancing / performance]
    + [example:webgl_instancing_scatter WebGL / instancing / scatter]
    + [example:webgl_instancing_raycast WebGL / instancing / raycast]

    Constructor

    @@ -47,7 +54,8 @@

    [property:Integer count]

    [property:BufferAttribute instanceMatrix]

    - Represents the local transformation of all instances. For internal use only. + Represents the local transformation of all instances. + You have to set its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify instanced data via [page:.setMatrixAt]().

    Methods

    diff --git a/docs/api/en/objects/LOD.html b/docs/api/en/objects/LOD.html index 6edab812d62706..3f8417f632320a 100644 --- a/docs/api/en/objects/LOD.html +++ b/docs/api/en/objects/LOD.html @@ -20,29 +20,31 @@

    [name]

    and one for close up (high detail).

    -

    Example

    - -

    - [example:webgl_lod webgl / lod ] -

    +

    Code Example

    -var lod = new THREE.LOD(); + var lod = new THREE.LOD(); -//Create spheres with 3 levels of detail and create new LOD levels for them -for( var i = 0; i < 3; i++ ) { + //Create spheres with 3 levels of detail and create new LOD levels for them + for( var i = 0; i < 3; i++ ) { - var geometry = new THREE.IcosahedronBufferGeometry( 10, 3 - i ) + var geometry = new THREE.IcosahedronBufferGeometry( 10, 3 - i ) - var mesh = new THREE.Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, material ); - lod.addLevel( mesh, i * 75 ); + lod.addLevel( mesh, i * 75 ); -} + } -scene.add( lod ); + scene.add( lod ); +

    Examples

    + +

    + [example:webgl_lod webgl / lod ] +

    +

    Constructor

    [name]( )

    @@ -87,6 +89,13 @@

    [method:LOD clone]()

    +

    [method:integer getCurrentLevel]()

    +

    + Get the currently active LOD level. As index of the levels array. +

    + + +

    [method:Object3D getObjectForDistance]( [param:Float distance] )

    Get a reference to the first [page:Object3D] (mesh) that is greater than [page:Float distance]. @@ -108,7 +117,7 @@

    [method:Object toJSON]( meta )

    [method:null update]( [param:Camera camera] )

    Set the visibility of each [page:levels level]'s [page:Object3D object] based on - distance from the [page:Camera camera]. + distance from the [page:Camera camera].

    Source

    diff --git a/docs/api/en/objects/Line.html b/docs/api/en/objects/Line.html index cd6f2cff0fb8f9..4e30e0b83e21fc 100644 --- a/docs/api/en/objects/Line.html +++ b/docs/api/en/objects/Line.html @@ -22,19 +22,19 @@

    [name]

    +

    Code Example

    -

    Example

    - - var material = new THREE.LineBasicMaterial({ + + var material = new THREE.LineBasicMaterial({ color: 0x0000ff }); - var geometry = new THREE.Geometry(); - geometry.vertices.push( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( 0, 10, 0 ), - new THREE.Vector3( 10, 0, 0 ) - ); + var points = []; + points.push( new THREE.Vector3( - 10, 0, 0 ) ); + points.push( new THREE.Vector3( 0, 10, 0 ) ); + points.push( new THREE.Vector3( 10, 0, 0 ) ); + + var geometry = new THREE.BufferGeometry().setFromPoints( points ); var line = new THREE.Line( geometry, material ); scene.add( line ); @@ -47,12 +47,9 @@

    [name]( [param:Geometry geometry], [param:Material material] )

    [page:Geometry geometry] — vertices representing the line segment(s). Default is a new [page:BufferGeometry].
    - [page:Material material] — material for the line. Default is a new [page:LineBasicMaterial] with random color.
    + [page:Material material] — material for the line. Default is a new [page:LineBasicMaterial].

    -

    If no material is supplied, a randomized line material will be created and assigned to the object.

    - -

    Properties

    See the base [page:Object3D] class for common properties.

    diff --git a/docs/api/en/objects/LineLoop.html b/docs/api/en/objects/LineLoop.html index 386be78a3dcce3..646966459c09ef 100644 --- a/docs/api/en/objects/LineLoop.html +++ b/docs/api/en/objects/LineLoop.html @@ -31,9 +31,6 @@

    [name]( [param:Geometry geometry], [param:Material material] )

    [page:Material material] — Material for the line. Default is [page:LineBasicMaterial LineBasicMaterial].

    -

    If no material is supplied, a randomized line material will be created and assigned to the object.

    - -

    Properties

    See the base [page:Line] class for common properties.

    diff --git a/docs/api/en/objects/LineSegments.html b/docs/api/en/objects/LineSegments.html index fe1b67b2b134e5..81a31b9d7463f7 100644 --- a/docs/api/en/objects/LineSegments.html +++ b/docs/api/en/objects/LineSegments.html @@ -30,9 +30,6 @@

    [name]( [param:Geometry geometry], [param:Material material] )

    [page:Material material] — Material for the line. Default is [page:LineBasicMaterial LineBasicMaterial].

    -

    If no material is supplied, a randomized line material will be created and assigned to the object.

    - -

    Properties

    See the base [page:Line] class for common properties.

    diff --git a/docs/api/en/objects/Mesh.html b/docs/api/en/objects/Mesh.html index c0ca6ccb558c0e..24f1fa9fcd81a8 100644 --- a/docs/api/en/objects/Mesh.html +++ b/docs/api/en/objects/Mesh.html @@ -17,8 +17,7 @@

    [name]

    Also serves as a base for other classes such as [page:SkinnedMesh].

    - -

    Example

    +

    Code Example

    var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); @@ -27,7 +26,6 @@

    Example

    scene.add( mesh );
    -

    Constructor

    [name]( [param:Geometry geometry], [param:Material material] )

    @@ -52,7 +50,7 @@

    [property:Geometry geometry]

    [property:Material material]

    An instance of material derived from the [page:Material] base class or an array of materials, defining the - object's appearance. Default is a [page:MeshBasicMaterial] with a random color. + object's appearance. Default is a [page:MeshBasicMaterial].

    [property:Array morphTargetInfluences]

    diff --git a/docs/api/en/objects/Points.html b/docs/api/en/objects/Points.html index efe24b616b174a..ac1e17a31203ab 100644 --- a/docs/api/en/objects/Points.html +++ b/docs/api/en/objects/Points.html @@ -25,8 +25,7 @@

    [name]( [param:Geometry geometry], [param:Material material] )

    [page:Geometry geometry] — (optional) an instance of [page:Geometry] or [page:BufferGeometry]. Default is a new [page:BufferGeometry].
    - [page:Material material] — (optional) a [page:Material]. Default is a new [page:PointsMaterial] - with a random color. + [page:Material material] — (optional) a [page:Material]. Default is a new [page:PointsMaterial].

    @@ -44,7 +43,7 @@

    [property:Geometry geometry]

    [property:Material material]

    An instance of [page:Material], defining the object's appearance. - Default is a [page:PointsMaterial] with a random color. + Default is a [page:PointsMaterial].

    [property:Array morphTargetInfluences]

    diff --git a/docs/api/en/objects/Skeleton.html b/docs/api/en/objects/Skeleton.html index 7c3a71cc4e30c7..ea620126164aa2 100644 --- a/docs/api/en/objects/Skeleton.html +++ b/docs/api/en/objects/Skeleton.html @@ -16,29 +16,30 @@

    [name]

    [page:SkinnedMesh].

    -

    Example

    - -// Create a simple "arm" +

    Code Example

    + + // Create a simple "arm" -var bones = []; + var bones = []; -var shoulder = new THREE.Bone(); -var elbow = new THREE.Bone(); -var hand = new THREE.Bone(); + var shoulder = new THREE.Bone(); + var elbow = new THREE.Bone(); + var hand = new THREE.Bone(); -shoulder.add( elbow ); -elbow.add( hand ); + shoulder.add( elbow ); + elbow.add( hand ); -bones.push( shoulder ); -bones.push( elbow ); -bones.push( hand ); + bones.push( shoulder ); + bones.push( elbow ); + bones.push( hand ); -shoulder.position.y = -5; -elbow.position.y = 0; -hand.position.y = 5; + shoulder.position.y = -5; + elbow.position.y = 0; + hand.position.y = 5; + + var armSkeleton = new THREE.Skeleton( bones ); + -var armSkeleton = new THREE.Skeleton( bones ); -

    See the [page:SkinnedMesh] page for an example of usage with standard [page:BufferGeometry].

    @@ -109,6 +110,11 @@

    [method:Bone getBoneByName]( [param:String name] )

    Searches through the skeleton's bone array and returns the first with a matching name.

    +

    [method:null dispose]()

    +

    + Can be used if an instance of [name] becomes obsolete in an application. The method will free internal resources. +

    +

    Source

    diff --git a/docs/api/en/objects/SkinnedMesh.html b/docs/api/en/objects/SkinnedMesh.html index 72b2c593aad162..e314768b1576af 100644 --- a/docs/api/en/objects/SkinnedMesh.html +++ b/docs/api/en/objects/SkinnedMesh.html @@ -35,7 +35,7 @@

    [name]

    -

    Example

    +

    Code Example

    var geometry = new THREE.CylinderBufferGeometry( 5, 5, 5, 5, 15, 5, 30 ); diff --git a/docs/api/en/objects/Sprite.html b/docs/api/en/objects/Sprite.html index 2dbf052c5989db..44d775e357ff04 100644 --- a/docs/api/en/objects/Sprite.html +++ b/docs/api/en/objects/Sprite.html @@ -19,16 +19,15 @@

    [name]

    Sprites do not cast shadows, setting castShadow = true will have no effect.

    -

    Example

    +

    Code Example

    -var spriteMap = new THREE.TextureLoader().load( "sprite.png" ); -var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); -var sprite = new THREE.Sprite( spriteMaterial ); -scene.add( sprite ); + var spriteMap = new THREE.TextureLoader().load( "sprite.png" ); + var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap } ); + var sprite = new THREE.Sprite( spriteMaterial ); + scene.add( sprite ); -

    Constructor

    [name]( [param:Material material] )

    diff --git a/docs/api/en/renderers/WebGLRenderTargetCube.html b/docs/api/en/renderers/WebGLCubeRenderTarget.html similarity index 88% rename from docs/api/en/renderers/WebGLRenderTargetCube.html rename to docs/api/en/renderers/WebGLCubeRenderTarget.html index fe8346a40c5554..e8d5c33b8837ef 100644 --- a/docs/api/en/renderers/WebGLRenderTargetCube.html +++ b/docs/api/en/renderers/WebGLCubeRenderTarget.html @@ -24,10 +24,9 @@

    Examples

    Constructor

    -

    [name]([param:Number width], [param:Number height], [param:Object options])

    +

    [name]([param:Number size], [param:Object options])

    - [page:Float width] - The width of the renderTarget.
    - [page:Float height] - The height of the renderTarget.
    + [page:Float size] - the size, in pixels.
    options - (optional) object that holds texture parameters for an auto-generated target texture and depthBuffer/stencilBuffer booleans. @@ -57,7 +56,7 @@

    Methods

    See [page:WebGLRenderTarget] for inherited methods

    -

    [method:WebGLRenderTargetCube fromEquirectangularTexture]( [param:WebGLRenderer renderer], [param:Texture texture] )

    +

    [method:WebGLCubeRenderTarget fromEquirectangularTexture]( [param:WebGLRenderer renderer], [param:Texture texture] )

    [page:WebGLRenderer renderer] — the renderer.
    [page:Texture texture] — the equirectangular texture. diff --git a/docs/api/en/renderers/WebGLRenderTarget.html b/docs/api/en/renderers/WebGLRenderTarget.html index 887f70c45b9709..4372319dcabc89 100644 --- a/docs/api/en/renderers/WebGLRenderTarget.html +++ b/docs/api/en/renderers/WebGLRenderTarget.html @@ -38,7 +38,7 @@

    [name]([param:Number width], [param:Number height], [param:Object options])< [page:Constant minFilter] - default is [page:Textures LinearFilter].
    [page:Constant format] - default is [page:Textures RGBAFormat].
    [page:Constant type] - default is [page:Textures UnsignedByteType].
    - [page:Number anisotropy] - default is *1*. See [page:Texture.anistropy]
    + [page:Number anisotropy] - default is *1*. See [page:Texture.anisotropy]
    [page:Constant encoding] - default is [page:Textures LinearEncoding].
    [page:Boolean depthBuffer] - default is *true*. Set this to false if you don't need it.
    [page:Boolean stencilBuffer] - default is *true*. Set this to false if you don't need it.

    diff --git a/docs/api/en/renderers/WebGLRenderer.html b/docs/api/en/renderers/WebGLRenderer.html index dea83f412ee010..118202d400ce06 100644 --- a/docs/api/en/renderers/WebGLRenderer.html +++ b/docs/api/en/renderers/WebGLRenderer.html @@ -166,6 +166,7 @@

    [property:Float gammaFactor]

    [property:number outputEncoding]

    Defines the output encoding of the renderer. Default is [page:Textures THREE.LinearEncoding].

    +

    If a render target has been set using [page:WebGLRenderer.setRenderTarget .setRenderTarget] then renderTarget.texture.encoding will be used instead.

    See the [page:Textures texture constants] page for details of other formats.

    [property:Object info]

    @@ -266,7 +267,7 @@

    [property:Object state]

    [property:Constant toneMapping]

    - Default is [page:Renderer LinearToneMapping]. See the [page:Renderer Renderer constants] for other choices. + Default is [page:Renderer NoToneMapping]. See the [page:Renderer Renderer constants] for other choices.

    [property:Number toneMappingExposure]

    @@ -279,14 +280,9 @@

    [property:Number toneMappingWhitePoint]

    Tone mapping white point. Default is *1*.

    -

    [property:Object xr]

    +

    [property:WebXRManager xr]

    - Provides access to the WebXR related interface of the renderer. -

    - -

    [property:Boolean xr.enabled]

    -

    - Whether the renderer should enable XR rendering or not. Default is *false*. + Provides access to the WebXR related [page:WebXRManager interface] of the renderer.

    Methods

    @@ -410,7 +406,7 @@

    [method:null readRenderTargetPixels]( [param:WebGLRenderTarget renderTarget]

    buffer - Uint8Array is the only destination type supported in all cases, other types are renderTarget and platform dependent. See [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 WebGL spec] for details.

    Reads the pixel data from the renderTarget into the buffer you pass in. This is a wrapper around [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels WebGLRenderingContext.readPixels]().

    See the [example:webgl_interactive_cubes_gpu interactive / cubes / gpu] example.

    -

    For reading out a [page:WebGLRenderTargetCube WebGLRenderTargetCube] use the optional parameter activeCubeFaceIndex to determine which face should be read.

    +

    For reading out a [page:WebGLCubeRenderTarget WebGLCubeRenderTarget] use the optional parameter activeCubeFaceIndex to determine which face should be read.

    [method:null render]( [param:Scene scene], [param:Camera camera] )

    @@ -427,12 +423,11 @@

    [method:null render]( [param:Scene scene], [param:Camera camera] )

    [method:null renderBufferDirect]( [param:Camera camera], [param:Fog fog], [param:Geometry geometry], [param:Material material], [param:Object3D object], [param:Object group] )

    Render a buffer geometry group using the camera and with the specified material.

    -

    [method:null renderBufferImmediate]( [param:Object3D object], [param:shaderprogram program], [param:Material shading] )

    +

    [method:null renderBufferImmediate]( [param:Object3D object], [param:WebGLProgram program] )

    object - an instance of [page:Object3D]
    - program - an instance of shaderProgram
    - shading - an instance of Material

    + program - an instance of [page:WebGLProgram]
    - Render an immediate buffer. Gets called by renderImmediateObject. + Renders an instance of [page:ImmediateRenderObject]. Gets called by renderObjectImmediate().

    [method:null setAnimationLoop]( [param:Function callback] )

    @@ -445,13 +440,16 @@

    [method:null setClearAlpha]( [param:Float alpha] )

    [method:null setClearColor]( [param:Color color], [param:Float alpha] )

    Sets the clear color and opacity.

    +

    [method:null setFramebuffer]( [param:WebGLFramebuffer value] )

    +

    Sets the given WebGLFramebuffer. This method can only be used if no render target is set via [page:WebGLRenderer.setRenderTarget .setRenderTarget]().

    +

    [method:null setPixelRatio]( [param:number value] )

    Sets device pixel ratio. This is usually used for HiDPI device to prevent bluring output canvas.

    [method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipmapLevel] )

    renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be activated. When *null* is given, the canvas is set as the active render target instead.
    - activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLRenderTargetCube] (optional).
    + activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLCubeRenderTarget] (optional).
    activeMipmapLevel -- Specifies the active mipmap level (optional).

    This method sets the active rendertarget.

    diff --git a/docs/api/en/renderers/shaders/UniformsUtils.html b/docs/api/en/renderers/shaders/UniformsUtils.html index 6731259ef05f75..7ac9813b333160 100644 --- a/docs/api/en/renderers/shaders/UniformsUtils.html +++ b/docs/api/en/renderers/shaders/UniformsUtils.html @@ -10,15 +10,28 @@

    [name]

    -

    Uniform Utilities. Support merging and cloning of uniform variables

    - -

    Properties

    +

    + Provides utility functions for managing uniforms. +

    +

    Methods

    +

    [method:Object clone]( [param:Object src] )

    +

    + src -- An object representing uniform definitions.

    -

    Methods

    + Clones the given uniform definitions by performing a deep-copy. That means if + the [page:Uniform.value value] of a uniform refers to an object like a [page:Vector3] + or [page:Texture], the cloned uniform will refer to a new object reference. +

    +

    [method:Object merge]( [param:Array uniforms] )

    +

    + uniforms -- An array of objects containing uniform definitions.

    + Merges the given uniform definitions into a single object. Since the method + internally uses [page:.clone](), it performs a deep-copy when producing the + merged uniform definitions.

    Source

    diff --git a/docs/api/en/renderers/webgl/WebGLProgram.html b/docs/api/en/renderers/webgl/WebGLProgram.html index f8c66501318880..7969d8cc033fcf 100644 --- a/docs/api/en/renderers/webgl/WebGLProgram.html +++ b/docs/api/en/renderers/webgl/WebGLProgram.html @@ -105,28 +105,31 @@

    Fragment shader:

    Constructor

    -

    [name]( [param:WebGLRenderer renderer], [param:Object code], [param:Material material], [param:Object parameters] )

    -

    For parameters see [page:WebGLRenderer WebGLRenderer]

    +

    [name]( [param:WebGLRenderer renderer], [param:String cacheKey], [param:Object parameters] )

    +

    For parameters see [page:WebGLRenderer WebGLRenderer].

    Properties

    +

    [property:String name]

    +

    The name of the respective shader program.

    +

    [property:String id]

    -

    +

    The identifier of this instance.

    -

    [property:String code]

    -

    +

    [property:String cacheKey]

    +

    This key enables the reusability of a single [name] for different materials.

    [property:Integer usedTimes]

    -

    +

    How many times this instance is used for rendering render items.

    [property:Object program]

    -

    +

    The actual shader program.

    [property:WebGLShader vertexShader]

    -

    +

    An instance of [page:WebGLShader] representing the vertex shader.

    [property:WebGLShader fragmentShader]

    -

    +

    An instance of [page:WebGLShader] representing the frament shader.

    Methods

    @@ -140,6 +143,11 @@

    [method:Object getAttributes]()

    Returns a name-value mapping of all active vertex attribute locations.

    +

    [method:null destroy]()

    +

    + Destroys an instance of [name]. +

    +

    Source

    diff --git a/docs/api/en/renderers/webgl/WebGLShader.html b/docs/api/en/renderers/webgl/WebGLShader.html index 95f75de07c0538..5382ab96752d1d 100644 --- a/docs/api/en/renderers/webgl/WebGLShader.html +++ b/docs/api/en/renderers/webgl/WebGLShader.html @@ -12,7 +12,7 @@

    [name]

    A lower level function to compile either a vertex or fragment shader.

    -

    Example

    +

    Code Example

    var gl = renderer.getContext(); diff --git a/docs/api/en/renderers/webxr/WebXRManager.html b/docs/api/en/renderers/webxr/WebXRManager.html new file mode 100644 index 00000000000000..f9cbdb25c5fae3 --- /dev/null +++ b/docs/api/en/renderers/webxr/WebXRManager.html @@ -0,0 +1,90 @@ + + + + + + + + + + + +

    [name]

    + +

    + + This class represents an abstraction of the WebXR Device API and is internally used by [page:WebGLRenderer]. + [name] also provides a public interface that allows users to enable/disable XR and perform XR related tasks like + for instance retrieving controllers. +

    + +

    Properties

    + +

    [property:Boolean enabled]

    +

    + This flag notifies the renderer to be ready for XR rendering. Default is *false*. Set it to *true* if you are going + to use XR in your app. +

    + +

    [property:Boolean isPresenting]

    +

    + Whether XR presentation is active or not. Default is *false*. This flag is read-only and automatically set by [name]. +

    + +

    Methods

    + +

    [method:Group getController]( [param:Integer index] )

    +

    + [page:Integer index] — The index of the controller.

    + + Returns a [page:Group] representing the so called *target ray* space of the controller. + Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction. +

    + +

    [method:Group getControllerGrip]( [param:Integer index] )

    +

    + [page:Integer index] — The index of the controller.

    + + Returns a [page:Group] representing the so called *grip* space of the controller. + Use this space if the user is going to hold other 3D objects like a lightsaber. +

    + +

    + Note: If you want to show something in the user's hand AND offer a pointing ray at the same time, you'll want to attached the handheld object to the + group returned by [page:.getControllerGrip]() and the ray to the group returned by [page:.getController](). The idea is to have two different groups + in two different coordinate spaces for the same WebXR controller. +

    + +

    [method:void setFramebufferScaleFactor]( [param:Float framebufferScaleFactor] )

    +

    + [page:Float framebufferScaleFactor] — The framebuffer scale factor to set.

    + + Specifies the scaling factor to use when determining the size of the framebuffer when rendering to a XR device. + The value is relative to the default XR device display resolution. Default is *1*. A value of *0.5* would specify + a framebuffer with 50% of the display's native resolution. +

    + +

    + Note: It is not possible to change the framebuffer scale factor while presenting XR content. +

    + +

    [method:void setReferenceSpaceType]( [param:String referenceSpaceType] )

    +

    + [page:String referenceSpaceType] — The reference space type to set.

    + + Can be used to configure a spatial relationship with the user's physical environment. Depending on how the user moves in 3D space, setting an + appropriate reference space can improve tracking. Default is *local-floor*. + Please check out the [link:https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType MDN] for possible values and their use cases. +

    + +

    + Note: It is not possible to change the reference space type while presenting XR content. +

    + +

    Source

    + +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

    + + diff --git a/docs/api/en/scenes/Scene.html b/docs/api/en/scenes/Scene.html index 5a8aaf61aeeec4..b2512d0d16d32b 100644 --- a/docs/api/en/scenes/Scene.html +++ b/docs/api/en/scenes/Scene.html @@ -33,7 +33,7 @@

    [property:boolean autoUpdate]

    [property:Object background]

    - If not null, sets the background used when rendering the scene, and is always rendered first. Can be set to a [page:Color] which sets the clear color, a [page:Texture] covering the canvas, or a cubemap as a [page:CubeTexture] or [page:WebGLRenderTargetCube]. Default is null. + If not null, sets the background used when rendering the scene, and is always rendered first. Can be set to a [page:Color] which sets the clear color, a [page:Texture] covering the canvas, or a cubemap as a [page:CubeTexture] or [page:WebGLCubeRenderTarget]. Default is null.

    [property:Texture environment]

    diff --git a/docs/api/en/textures/CubeTexture.html b/docs/api/en/textures/CubeTexture.html index 70e8f179b91cf4..922da9a2cbb110 100644 --- a/docs/api/en/textures/CubeTexture.html +++ b/docs/api/en/textures/CubeTexture.html @@ -9,17 +9,17 @@ [page:Texture] → - +

    [name]

    Creates a cube texture made up of six images.

    -

    Example

    +

    Code Example

    var loader = new THREE.CubeTextureLoader(); loader.setPath( 'textures/cube/pisa/' ); - + var textureCube = loader.load( [ 'px.png', 'nx.png', 'py.png', 'ny.png', @@ -33,7 +33,7 @@

    Constructor

    [name]( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )

    - +

    CubeTexture is almost equivalent in functionality and usage to [page:Texture]. The only differences are that the images are an array of 6 images as opposed to a single image, and the mapping options are @@ -43,13 +43,16 @@

    [name]( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, a

    Properties

    -

    See [page:Texture]

    +

    + See the base [page:Texture Texture] class for common properties. +

    Methods

    - -

    See [page:Texture]

    - +

    + See the base [page:Texture Texture] class for common methods. +

    +

    Source

    diff --git a/docs/api/en/textures/DataTexture.html b/docs/api/en/textures/DataTexture.html index bb948abba58ef8..4cd16520ae10aa 100644 --- a/docs/api/en/textures/DataTexture.html +++ b/docs/api/en/textures/DataTexture.html @@ -32,7 +32,7 @@

    [name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, In order to use the types THREE.FloatType and THREE.HalfFloatType, the WebGL implementation must support the respective extensions OES_texture_float and OES_texture_half_float. In order to use THREE.LinearFilter for component-wise, bilinear interpolation of the texels based on these types, the WebGL extensions OES_texture_float_linear or OES_texture_half_float_linear must also be present.

    -

    Example

    +

    Code Example

    // create a buffer with color data @@ -61,6 +61,10 @@

    Example

    Properties

    +

    + See the base [page:Texture Texture] class for common properties. +

    +

    [property:Image image]

    Overridden with a record type holding data, width and height. @@ -68,6 +72,9 @@

    [property:Image image]

    Methods

    +

    + See the base [page:Texture Texture] class for common methods. +

    Source

    diff --git a/docs/api/en/textures/DataTexture3D.html b/docs/api/en/textures/DataTexture3D.html index de4283be525914..8c90c946a5c87d 100644 --- a/docs/api/en/textures/DataTexture3D.html +++ b/docs/api/en/textures/DataTexture3D.html @@ -27,10 +27,12 @@

    [name]( [param:TypedArray data], [param:Number width], [param:Number height] [page:Number depth] -- depth of the texture.

    -

    Example

    +

    Examples

    -
    [example:webgl2_materials_texture3d WebGL2 / materials / texture3d]
    -
    [example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]
    +

    + [example:webgl2_materials_texture3d WebGL2 / materials / texture3d]
    + [example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray] +

    Properties

    diff --git a/docs/api/en/textures/DepthTexture.html b/docs/api/en/textures/DepthTexture.html index 9c518d02c9b90c..c59636cc547c13 100644 --- a/docs/api/en/textures/DepthTexture.html +++ b/docs/api/en/textures/DepthTexture.html @@ -17,9 +17,11 @@

    [name]

    [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/ WEBGL_depth_texture] extension.

    -

    Example

    +

    Examples

    - [example:webgl_depth_texture depth / texture] +

    + [example:webgl_depth_texture depth / texture] +

    Constructor

    [name]( [param:Number width], [param:Number height], [param:Constant type], [param:Constant wrapS], [param:Constant wrapT], [param:Constant magFilter], [param:Constant minFilter], [param:Number anisotropy], [param:Constant format] )

    diff --git a/docs/api/en/textures/Texture.html b/docs/api/en/textures/Texture.html index d1968416c8c99a..3d4361eeec579d 100644 --- a/docs/api/en/textures/Texture.html +++ b/docs/api/en/textures/Texture.html @@ -12,12 +12,7 @@

    [name]

    Create a texture to apply to a surface or as a reflection or refraction map.

    - -

    Constructor

    - -

    [name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding )

    - -

    Example

    +

    Code Example

    // load a texture, set wrap mode to repeat @@ -27,6 +22,10 @@

    Example

    texture.repeat.set( 4, 4 );
    +

    Constructor

    + +

    [name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding )

    +

    Properties

    [property:Integer id]

    @@ -191,7 +190,7 @@

    [property:boolean generateMipmaps]

    [property:boolean premultiplyAlpha]

    - If set to *true*, the alpha channel, if present, is multiplied into the color channels when the texture is uploaded to the GPU. Defaut is *false*.

    + If set to *true*, the alpha channel, if present, is multiplied into the color channels when the texture is uploaded to the GPU. Default is *false*.

    Note that this property has no effect for [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap]. You need to configure on bitmap creation instead. See [page:ImageBitmapLoader]. diff --git a/docs/api/en/textures/VideoTexture.html b/docs/api/en/textures/VideoTexture.html index 47edfc25f17240..caabb3252556bf 100644 --- a/docs/api/en/textures/VideoTexture.html +++ b/docs/api/en/textures/VideoTexture.html @@ -18,27 +18,28 @@

    [name]

    This is almost the same as the base [page:Texture Texture] class, except that it continuosly sets [page:Texture.needsUpdate needsUpdate] to *true* so that the texture is updated as the video plays. Automatic creation of [page:Texture.mipmaps mipmaps] is also disabled.

    -

    Example

    - -

    [example:webgl_materials_video materials / video ]

    +

    Code Example

    -//assuming you have created a HTML video element with id="video" -var video = document.getElementById( 'video' ); + //assuming you have created a HTML video element with id="video" + var video = document.getElementById( 'video' ); -var texture = new THREE.VideoTexture( video ); -texture.minFilter = THREE.LinearFilter; -texture.magFilter = THREE.LinearFilter; -texture.format = THREE.RGBFormat; - + var texture = new THREE.VideoTexture( video ); + texture.minFilter = THREE.LinearFilter; + texture.magFilter = THREE.LinearFilter; + texture.format = THREE.RGBFormat; +
    +

    Examples

    + +

    [example:webgl_materials_video materials / video ]

    Constructor

    [name]( [param:Video video], [param:Constant mapping], [param:Constant wrapS], [param:Constant wrapT], [param:Constant magFilter], [param:Constant minFilter], [param:Constant format], [param:Constant type], [param:Number anisotropy] )

    [page:Video video] -- The video element to use as the texture.
    - [page:Constant mapping] -- How the image is applied to the object. An object type of [page:Textures THREE.UVMapping]. + [page:Constant mapping] -- How the image is applied to the object. An object type of [page:Textures THREE.UVMapping]. See [page:Textures mapping constants] for other choices.
    [page:Constant wrapS] -- The default is [page:Textures THREE.ClampToEdgeWrapping]. @@ -51,13 +52,13 @@

    [name]( [param:Video video], [param:Constant mapping], [param:Constant wrapS The default is [page:Textures THREE.LinearFilter]. See [page:Textures magnification filter constants] for other choices.
    [page:Constant minFilter] -- How the texture is sampled when a texel covers less than one pixel. - The default is [page:Textures THREE.LinearMipmapLinearFilter]. See [page:Textures minification filter constants] for other choices.
    + The default is [page:Textures THREE.LinearMipmapLinearFilter]. See [page:Textures minification filter constants] for other choices.
    - [page:Constant format] -- The format used in the texture. - See [page:Textures format constants] for other choices.
    + [page:Constant format] -- The format used in the texture. + See [page:Textures format constants] for other choices.
    - [page:Constant type] -- Default is [page:Textures THREE.UnsignedByteType]. - See [page:Textures type constants] for other choices.
    + [page:Constant type] -- Default is [page:Textures THREE.UnsignedByteType]. + See [page:Textures type constants] for other choices.
    [page:Number anisotropy] -- The number of samples taken along the axis through the pixel that has the highest density of texels. By default, this value is 1. A higher value gives a less blurry result than a basic mipmap, at the cost of more texture samples being used. @@ -68,8 +69,8 @@

    [name]( [param:Video video], [param:Constant mapping], [param:Constant wrapS

    Properties

    - See the base [page:Texture Texture] class for common properties. -

    + See the base [page:Texture Texture] class for common properties. +

    [property:boolean needsUpdate]

    @@ -78,14 +79,14 @@

    [property:boolean needsUpdate]

    Methods

    -

    - See the base [page:Texture Texture] class for common methods. -

    +

    + See the base [page:Texture Texture] class for common methods. +

    -

    [method:null update]()

    +

    [method:null update]()

    This is called automatically and sets [property:boolean needsUpdate] to *true* every time - a new frame is available. + a new frame is available.

    diff --git a/docs/api/zh/Template.html b/docs/api/zh/Template.html index d0dbbe16ffe67d..42a906344b23f7 100644 --- a/docs/api/zh/Template.html +++ b/docs/api/zh/Template.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/AnimationAction.html b/docs/api/zh/animation/AnimationAction.html index a8c3cebf3e9017..3a2de280b07f73 100644 --- a/docs/api/zh/animation/AnimationAction.html +++ b/docs/api/zh/animation/AnimationAction.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/AnimationClip.html b/docs/api/zh/animation/AnimationClip.html index 22ddc1d24f8faa..58e7f4ffccacdc 100644 --- a/docs/api/zh/animation/AnimationClip.html +++ b/docs/api/zh/animation/AnimationClip.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/AnimationMixer.html b/docs/api/zh/animation/AnimationMixer.html index 151cf78b2b3453..637365d4176756 100644 --- a/docs/api/zh/animation/AnimationMixer.html +++ b/docs/api/zh/animation/AnimationMixer.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/AnimationObjectGroup.html b/docs/api/zh/animation/AnimationObjectGroup.html index 4ee9710cd934ac..b75259294bb75b 100644 --- a/docs/api/zh/animation/AnimationObjectGroup.html +++ b/docs/api/zh/animation/AnimationObjectGroup.html @@ -1,5 +1,5 @@ - + @@ -35,10 +35,10 @@

    限制

    构造器

    -

    [name]( [param:object obj1], [param:object obj2], [param:object obj3], ... )

    - [page:object obj] - 共享同一动画状态的任意数量的网格
    - +

    + [page:object obj] - 共享同一动画状态的任意数量的网格 +

    属性

    diff --git a/docs/api/zh/animation/AnimationUtils.html b/docs/api/zh/animation/AnimationUtils.html index 4506306a63b776..442907bce1b639 100644 --- a/docs/api/zh/animation/AnimationUtils.html +++ b/docs/api/zh/animation/AnimationUtils.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/KeyframeTrack.html b/docs/api/zh/animation/KeyframeTrack.html index f78a1275b7b782..4d3ad69e0b20e4 100644 --- a/docs/api/zh/animation/KeyframeTrack.html +++ b/docs/api/zh/animation/KeyframeTrack.html @@ -1,5 +1,5 @@ - + @@ -49,7 +49,7 @@

    [name]

    - 可以在[link:https://threejs.org/examples/js/animation/AnimationClipCreator.js AnimationClipCreator]文件中找到用不同类型的关键帧轨道创建动画剪辑([page:AnimationClip AnimationClips])的示例。 + 可以在[link:https://threejs.org/examples/jsm/animation/AnimationClipCreator.js AnimationClipCreator]文件中找到用不同类型的关键帧轨道创建动画剪辑([page:AnimationClip AnimationClips])的示例。

    diff --git a/docs/api/zh/animation/PropertyBinding.html b/docs/api/zh/animation/PropertyBinding.html index 61d019a4a165c2..31aef3070cbc7a 100644 --- a/docs/api/zh/animation/PropertyBinding.html +++ b/docs/api/zh/animation/PropertyBinding.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/PropertyMixer.html b/docs/api/zh/animation/PropertyMixer.html index f4d9d5df866209..ac6f64b68efa3c 100644 --- a/docs/api/zh/animation/PropertyMixer.html +++ b/docs/api/zh/animation/PropertyMixer.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/BooleanKeyframeTrack.html b/docs/api/zh/animation/tracks/BooleanKeyframeTrack.html index bfc34d4e7cc23e..32122f5fc24d93 100644 --- a/docs/api/zh/animation/tracks/BooleanKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/BooleanKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/ColorKeyframeTrack.html b/docs/api/zh/animation/tracks/ColorKeyframeTrack.html index e31893fc31332f..fc9a5f2bfad847 100644 --- a/docs/api/zh/animation/tracks/ColorKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/ColorKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/NumberKeyframeTrack.html b/docs/api/zh/animation/tracks/NumberKeyframeTrack.html index 21c07bc86f020f..3c9ad70eedf06d 100644 --- a/docs/api/zh/animation/tracks/NumberKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/NumberKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/QuaternionKeyframeTrack.html b/docs/api/zh/animation/tracks/QuaternionKeyframeTrack.html index 565a9cfd0c914e..d15fb432d70b9a 100644 --- a/docs/api/zh/animation/tracks/QuaternionKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/QuaternionKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/StringKeyframeTrack.html b/docs/api/zh/animation/tracks/StringKeyframeTrack.html index 19aca3bf961cc6..6c72a5b4bcdc46 100644 --- a/docs/api/zh/animation/tracks/StringKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/StringKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/animation/tracks/VectorKeyframeTrack.html b/docs/api/zh/animation/tracks/VectorKeyframeTrack.html index e73b820d6756dd..7b2b6cd92e5ae6 100644 --- a/docs/api/zh/animation/tracks/VectorKeyframeTrack.html +++ b/docs/api/zh/animation/tracks/VectorKeyframeTrack.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/audio/Audio.html b/docs/api/zh/audio/Audio.html index 73f803f8bbecd5..8bb1f0ee9c708d 100644 --- a/docs/api/zh/audio/Audio.html +++ b/docs/api/zh/audio/Audio.html @@ -1,5 +1,5 @@ - + @@ -18,13 +18,7 @@

    [name]

    使用 [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

    - -

    例子

    - -

    - [example:webaudio_sandbox webaudio / sandbox ]
    - [example:webaudio_visualizer webaudio / visualizer ] -

    +

    代码示例

    // create an AudioListener and add it to the camera @@ -44,6 +38,12 @@

    例子

    });
    +

    例子

    + +

    + [example:webaudio_sandbox webaudio / sandbox ]
    + [example:webaudio_visualizer webaudio / visualizer ] +

    构造函数

    diff --git a/docs/api/zh/audio/AudioAnalyser.html b/docs/api/zh/audio/AudioAnalyser.html index 73dd880324d3fa..a17c3e39278c14 100644 --- a/docs/api/zh/audio/AudioAnalyser.html +++ b/docs/api/zh/audio/AudioAnalyser.html @@ -1,5 +1,5 @@ - + @@ -18,13 +18,7 @@

    [name]

    - -

    示例

    - -

    - [example:webaudio_sandbox webaudio / sandbox ]
    - [example:webaudio_visualizer webaudio / visualizer ] -

    +

    代码示例

    // create an AudioListener and add it to the camera @@ -50,6 +44,12 @@

    示例

    var data = analyser.getAverageFrequency();
    +

    例子

    + +

    + [example:webaudio_sandbox webaudio / sandbox ]
    + [example:webaudio_visualizer webaudio / visualizer ] +

    构造函数

    diff --git a/docs/api/zh/audio/AudioContext.html b/docs/api/zh/audio/AudioContext.html index 3cfae44e350a71..a655cd133f13ff 100644 --- a/docs/api/zh/audio/AudioContext.html +++ b/docs/api/zh/audio/AudioContext.html @@ -1,5 +1,5 @@ - + @@ -29,7 +29,7 @@

    [method:AudioContext getContext]()

    否则创建一个新的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].

    -

    [method:AudioContext setContext]( [param:AudioConetxt value] )

    +

    [method:AudioContext setContext]( [param:AudioContext value] )

    外部用来设置 *context* 的值.

    diff --git a/docs/api/zh/audio/AudioListener.html b/docs/api/zh/audio/AudioListener.html index a68a899f0be070..9394d61e2c2184 100644 --- a/docs/api/zh/audio/AudioListener.html +++ b/docs/api/zh/audio/AudioListener.html @@ -1,5 +1,5 @@ - + @@ -18,14 +18,7 @@

    [name]

    大多数情况下, listener对象是camera的子对象. Camera的3D变换表示了listener的3D变换.

    - -

    示例

    - -

    - [example:webaudio_sandbox webaudio / sandbox ]
    - [example:webaudio_timing webaudio / timing ]
    - [example:webaudio_visualizer webaudio / visualizer ] -

    +

    代码示例

    // create an AudioListener and add it to the camera @@ -45,6 +38,13 @@

    示例

    });
    +

    例子

    + +

    + [example:webaudio_sandbox webaudio / sandbox ]
    + [example:webaudio_timing webaudio / timing ]
    + [example:webaudio_visualizer webaudio / visualizer ] +

    构造函数

    diff --git a/docs/api/zh/audio/PositionalAudio.html b/docs/api/zh/audio/PositionalAudio.html index 755affb7e29306..7fb034fc738f48 100644 --- a/docs/api/zh/audio/PositionalAudio.html +++ b/docs/api/zh/audio/PositionalAudio.html @@ -1,5 +1,5 @@ - + @@ -18,14 +18,7 @@

    [name]

    使用了[link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

    - -

    示例

    - -

    - [example:webaudio_orientation webaudio / orientation ]
    - [example:webaudio_sandbox webaudio / sandbox ]
    - [example:webaudio_timing webaudio / timing ] -

    +

    代码示例

    // create an AudioListener and add it to the camera @@ -44,7 +37,7 @@

    示例

    }); // create an object for the sound to play from - var sphere = new THREE.SphereGeometry( 20, 32, 16 ); + var sphere = new THREE.SphereBufferGeometry( 20, 32, 16 ); var material = new THREE.MeshPhongMaterial( { color: 0xff2200 } ); var mesh = new THREE.Mesh( sphere, material ); scene.add( mesh ); @@ -53,6 +46,13 @@

    示例

    mesh.add( sound );
    +

    例子

    + +

    + [example:webaudio_orientation webaudio / orientation ]
    + [example:webaudio_sandbox webaudio / sandbox ]
    + [example:webaudio_timing webaudio / timing ] +

    构造函数

    diff --git a/docs/api/zh/cameras/ArrayCamera.html b/docs/api/zh/cameras/ArrayCamera.html index 813d14f6268b55..0c35f7ff0314b2 100644 --- a/docs/api/zh/cameras/ArrayCamera.html +++ b/docs/api/zh/cameras/ArrayCamera.html @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@

    摄像机阵列([name])

    一个 [name] 的实例中总是包含着一组子摄像机,应当为每一个子摄像机定义*viewport*(视口)这个属性,这一属性决定了由该子摄像机所渲染的视口区域的大小。

    -

    示例

    +

    例子

    [example:webgl_camera_array camera / array ]

    diff --git a/docs/api/zh/cameras/Camera.html b/docs/api/zh/cameras/Camera.html index 1898cfd99fd4df..b3a045e98faec1 100644 --- a/docs/api/zh/cameras/Camera.html +++ b/docs/api/zh/cameras/Camera.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/cameras/CubeCamera.html b/docs/api/zh/cameras/CubeCamera.html index 5f4a4bef818e71..684ab48398ed58 100644 --- a/docs/api/zh/cameras/CubeCamera.html +++ b/docs/api/zh/cameras/CubeCamera.html @@ -1,5 +1,5 @@ - + @@ -13,13 +13,9 @@

    立方相机([name])

    -

    创建6个摄像机,并将它们所拍摄的场景渲染到[page:WebGLRenderTargetCube]上。

    +

    创建6个摄像机,并将它们所拍摄的场景渲染到[page:WebGLCubeRenderTarget]上。

    -

    示例

    - -

    [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]

    -

    [example:webgl_materials_cubemap_dynamic2 materials / cubemap / dynamic2 ]

    -

    [example:webgl_shading_physical shading / physical ]

    +

    代码示例

    // Create cube camera var cubeCamera = new THREE.CubeCamera( 1, 100000, 128 ); @@ -40,7 +36,13 @@

    示例

    renderer.render( scene, camera );
    +

    例子

    +

    + [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
    + [example:webgl_materials_cubemap_dynamic2 materials / cubemap / dynamic2 ]
    + [example:webgl_shading_physical shading / physical ] +

    构造器

    @@ -54,7 +56,7 @@

    [name]( [param:Number near], [param:Number far], [param:Number cubeResolutio cubeResolution -- 设置立方体边缘的长度

    - 构造一个包含6个[page:PerspectiveCamera PerspectiveCameras](透视摄像机)的立方摄像机,并将其拍摄的场景渲染到一个[page:WebGLRenderTargetCube]上。 + 构造一个包含6个[page:PerspectiveCamera PerspectiveCameras](透视摄像机)的立方摄像机,并将其拍摄的场景渲染到一个[page:WebGLCubeRenderTarget]上。

    @@ -62,7 +64,7 @@

    [name]( [param:Number near], [param:Number far], [param:Number cubeResolutio

    属性

    共有属性请参见其基类[page:Object3D]。

    -

    [property:WebGLRenderTargetCube renderTarget]

    +

    [property:WebGLCubeRenderTarget renderTarget]

    生成的立方体纹理
    (译注:生成的立方体纹理保存在其中的.texture对象中,可作为贴图赋值给其他材质) diff --git a/docs/api/zh/cameras/OrthographicCamera.html b/docs/api/zh/cameras/OrthographicCamera.html index 66036299e9df8d..2f88f6c5cc7644 100644 --- a/docs/api/zh/cameras/OrthographicCamera.html +++ b/docs/api/zh/cameras/OrthographicCamera.html @@ -1,5 +1,5 @@ - + @@ -22,24 +22,26 @@

    正交相机([name])

    这对于渲染2D场景或者UI元素是非常有用的。

    +

    代码示例

    -

    示例

    - -

    [example:webgl_camera camera ]

    -

    [example:webgl_interactive_cubes_ortho interactive / cubes / ortho ]

    -

    [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]

    -

    [example:webgl_postprocessing_advanced postprocessing / advanced ]

    -

    [example:webgl_postprocessing_dof2 postprocessing / dof2 ]

    -

    [example:webgl_postprocessing_godrays postprocessing / godrays ]

    -

    [example:webgl_rtt rtt ]

    -

    [example:webgl_shaders_tonemapping shaders / tonemapping ]

    -

    [example:webgl_shadowmap shadowmap ]

    -

    [example:webgl_terrain_dynamic terrain / dynamic ]

    - - var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); -scene.add( camera ); + + var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + scene.add( camera ); + +

    例子

    +

    + [example:webgl_camera camera ]
    + [example:webgl_interactive_cubes_ortho interactive / cubes / ortho ]
    + [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
    + [example:webgl_postprocessing_advanced postprocessing / advanced ]
    + [example:webgl_postprocessing_dof2 postprocessing / dof2 ]
    + [example:webgl_postprocessing_godrays postprocessing / godrays ]
    + [example:webgl_rtt rtt ]
    + [example:webgl_shaders_tonemapping shaders / tonemapping ]
    + [example:webgl_shadowmap shadowmap ] +

    构造器

    diff --git a/docs/api/zh/cameras/PerspectiveCamera.html b/docs/api/zh/cameras/PerspectiveCamera.html index 02fc0870d20c91..1cfcf54f117644 100644 --- a/docs/api/zh/cameras/PerspectiveCamera.html +++ b/docs/api/zh/cameras/PerspectiveCamera.html @@ -1,5 +1,5 @@ - + @@ -19,18 +19,22 @@

    透视相机([name])

    +

    代码示例

    -

    示例

    + + var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); + scene.add( camera ); + -

    [example:webgl_animation_skinning_blending animation / skinning / blending ]

    -

    [example:webgl_animation_skinning_morph animation / skinning / blending ]

    -

    [example:webgl_effects_stereo effects / stereo ]

    -

    [example:webgl_interactive_cubes interactive / cubes ]

    -

    [example:webgl_loader_collada_skinning loader / collada / skinning ]

    - - var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); -scene.add( camera ); +

    例子

    +

    + [example:webgl_animation_skinning_blending animation / skinning / blending ]
    + [example:webgl_animation_skinning_morph animation / skinning / blending ]
    + [example:webgl_effects_stereo effects / stereo ]
    + [example:webgl_interactive_cubes interactive / cubes ]
    + [example:webgl_loader_collada_skinning loader / collada / skinning ] +

    构造器

    diff --git a/docs/api/zh/cameras/StereoCamera.html b/docs/api/zh/cameras/StereoCamera.html index 965dc866869375..126c8efffd72b9 100644 --- a/docs/api/zh/cameras/StereoCamera.html +++ b/docs/api/zh/cameras/StereoCamera.html @@ -1,5 +1,5 @@ - + @@ -16,21 +16,14 @@

    立体相机([name])

    - -

    示例

    - -

    [example:webgl_effects_anaglyph effects / anaglyph ]

    -

    [example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]

    -

    [example:webgl_effects_stereo effects / stereo ]

    +

    例子

    - 这些类在以上示例中的文件内部使用:

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/AnaglyphEffect.js examples/js/effects/AnaglyphEffect.js]

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/ParallaxBarrierEffect.js examples/js/effects/ParallaxBarrierEffect.js]

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/effects/StereoEffect.js examples/js/effects/StereoEffect.js]

    + [example:webgl_effects_anaglyph effects / anaglyph ]
    + [example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]
    + [example:webgl_effects_stereo effects / stereo ]

    -

    构造器

    [name]( )

    diff --git a/docs/api/zh/constants/Animation.html b/docs/api/zh/constants/Animation.html index 58f45a17fc3cbd..d820e9a1313e40 100644 --- a/docs/api/zh/constants/Animation.html +++ b/docs/api/zh/constants/Animation.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/constants/Core.html b/docs/api/zh/constants/Core.html index 8718d33c78ced2..8fa47bc99e57a5 100644 --- a/docs/api/zh/constants/Core.html +++ b/docs/api/zh/constants/Core.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/constants/CustomBlendingEquations.html b/docs/api/zh/constants/CustomBlendingEquations.html index 49cee21759c292..d5908c09eefce3 100644 --- a/docs/api/zh/constants/CustomBlendingEquations.html +++ b/docs/api/zh/constants/CustomBlendingEquations.html @@ -1,5 +1,5 @@ - + @@ -10,15 +10,12 @@

    自定义混合方程常量(Custom Blending Equation Constants)

    - -

    示例

    -

    [example:webgl_materials_blending_custom materials / blending / custom ]

    - -

    用法

    这个常量可以用于所有的材质类型。首先将材质的混合模式设置为THREE.CustomBlending,然后设置所需要的混合方程、源因子和目标因子。

    +

    代码示例

    + var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); material.blending = THREE.CustomBlending; @@ -27,6 +24,9 @@

    用法

    material.blendDst = THREE.OneMinusSrcAlphaFactor; //default
    +

    例子

    +

    [example:webgl_materials_blending_custom materials / blending / custom ]

    +

    混合方程

    THREE.AddEquation diff --git a/docs/api/zh/constants/Materials.html b/docs/api/zh/constants/Materials.html index 075fce98ea23d8..8b3744745edac5 100644 --- a/docs/api/zh/constants/Materials.html +++ b/docs/api/zh/constants/Materials.html @@ -1,5 +1,5 @@ - + @@ -27,20 +27,6 @@

    默认值是[page:Constant FrontSide](只渲染正面)。

    - -

    颜色

    - - THREE.NoColors - THREE.FaceColors - THREE.VertexColors - -

    - [page:Constant NoColors] 是默认值,且会将材质的颜色应用到所有面。
    - [page:Constant FaceColors] 根据每个[page:Face3 Face3]的[page:Color Color]值来对面进行着色。
    - [page:Constant VertexColors] 根据每个 [page:Face3 Face3]的vertexColors(顶点颜色)值来对面进行着色。 这是一个包含有三个[page:Color Color]的数组,数组中每一项都对应着面中的每一个顶点。
    - 请查看示例:[example:webgl_geometry_colors geometry / colors]。 -

    -

    混合模式

    THREE.NoBlending diff --git a/docs/api/zh/constants/Renderer.html b/docs/api/zh/constants/Renderer.html index e49599349458dc..91956897ed8b05 100644 --- a/docs/api/zh/constants/Renderer.html +++ b/docs/api/zh/constants/Renderer.html @@ -1,5 +1,5 @@ - + @@ -46,7 +46,7 @@

    阴影类型

    [page:constant BasicShadowMap] 能够给出没有经过过滤的阴影映射 —— 速度最快,但质量最差。
    [page:constant PCFShadowMap] 为默认值,使用Percentage-Closer Filtering (PCF)算法来过滤阴影映射。
    - [page:constant PCFSoftShadowMap] 使用Percentage-Closer Soft Shadows (PCSS)算法来过滤阴影映射。
    + [page:constant PCFSoftShadowMap] filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm with better soft shadows especially when using low-resolution shadow maps.
    [page:constant VSMShadowMap] 使用Variance Shadow Map (VSM)算法来过滤阴影映射。当使用VSMShadowMap时,所有阴影接收者也将会投射阴影。

    @@ -63,9 +63,6 @@

    色调映射

    这个属性用于在普通计算机显示器或者移动设备屏幕等低动态范围介质上,模拟、逼近高动态范围(HDR)效果。

    - [page:constant NoToneMapping] 禁用色调映射。
    - [page:constant LinearToneMapping] 为默认值,线性色调映射。

    - 请查看示例:[example:webgl_tonemapping WebGL / tonemapping]。

    diff --git a/docs/api/zh/constants/Textures.html b/docs/api/zh/constants/Textures.html index fa648783064b25..ebce7f0e535e56 100644 --- a/docs/api/zh/constants/Textures.html +++ b/docs/api/zh/constants/Textures.html @@ -1,5 +1,5 @@ - + @@ -221,11 +221,50 @@

    PVRTC 压缩纹理格式(PVRTC Compressed Texture Formats)

    ETC 压缩纹理格式

    THREE.RGB_ETC1_Format + THREE.RGB_ETC2_Format + THREE.RGBA_ETC2_EAC_Format +

    + For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property, + these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/ WEBGL_compressed_texture_etc1] + (ETC1) or [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc/ WEBGL_compressed_texture_etc] + (ETC2) extensions.

    +

    + +

    ASTC Compressed Texture Format

    + + THREE.RGBA_ASTC_4x4_Format + THREE.RGBA_ASTC_5x4_Format + THREE.RGBA_ASTC_5x5_Format + THREE.RGBA_ASTC_6x5_Format + THREE.RGBA_ASTC_6x6_Format + THREE.RGBA_ASTC_8x5_Format + THREE.RGBA_ASTC_8x6_Format + THREE.RGBA_ASTC_8x8_Format + THREE.RGBA_ASTC_10x5_Format + THREE.RGBA_ASTC_10x6_Format + THREE.RGBA_ASTC_10x8_Format + THREE.RGBA_ASTC_10x10_Format + THREE.RGBA_ASTC_12x10_Format + THREE.RGBA_ASTC_12x12_Format + THREE.SRGB8_ALPHA8_ASTC_4x4_Format + THREE.SRGB8_ALPHA8_ASTC_5x4_Format + THREE.SRGB8_ALPHA8_ASTC_5x5_Format + THREE.SRGB8_ALPHA8_ASTC_6x5_Format + THREE.SRGB8_ALPHA8_ASTC_6x6_Format + THREE.SRGB8_ALPHA8_ASTC_8x5_Format + THREE.SRGB8_ALPHA8_ASTC_8x6_Format + THREE.SRGB8_ALPHA8_ASTC_8x8_Format + THREE.SRGB8_ALPHA8_ASTC_10x5_Format + THREE.SRGB8_ALPHA8_ASTC_10x6_Format + THREE.SRGB8_ALPHA8_ASTC_10x8_Format + THREE.SRGB8_ALPHA8_ASTC_10x10_Format + THREE.SRGB8_ALPHA8_ASTC_12x10_Format + THREE.SRGB8_ALPHA8_ASTC_12x12_Format +

    - 要使用[page:CompressedTexture CompressedTexture]中的[page:Texture.format format]属性,需要获得 - [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_etc1/ WEBGL_compressed_texture_etc1] - 扩展的支持。

    + For use with a [page:CompressedTexture CompressedTexture]'s [page:Texture.format format] property, + these require support for the [link:https://www.khronos.org/registry/webgl/extensions/WEBGL_compressed_texture_astc/ WEBGL_compressed_texture_astc] extension.

    编码

    diff --git a/docs/api/zh/core/BufferAttribute.html b/docs/api/zh/core/BufferAttribute.html index 1819b50287eea4..88a48a23e2ec17 100644 --- a/docs/api/zh/core/BufferAttribute.html +++ b/docs/api/zh/core/BufferAttribute.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/BufferGeometry.html b/docs/api/zh/core/BufferGeometry.html index 416c8f94d6c5d2..45fbe60f5c5e27 100644 --- a/docs/api/zh/core/BufferGeometry.html +++ b/docs/api/zh/core/BufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -21,7 +21,7 @@

    [name]

    几何体的更多使用示例,详见 [page:Geometry]。

    -

    示例

    +

    代码示例

    var geometry = new THREE.BufferGeometry(); // 创建一个简单的矩形. 在这里我们左上和右下顶点被复制了两次。 @@ -41,6 +41,8 @@

    示例

    var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); var mesh = new THREE.Mesh( geometry, material );
    + +

    例子

    [example:webgl_buffergeometry Mesh with non-indexed faces]
    [example:webgl_buffergeometry_indexed Mesh with indexed faces]
    @@ -162,7 +164,7 @@

    [method:null addGroup]( [param:Integer start], [param:Integer count], [param

    -

    [method:null applyMatrix]( [param:Matrix4 matrix] )

    +

    [method:null applyMatrix4]( [param:Matrix4 matrix] )

    用给定矩阵转换几何体的顶点坐标。

    [method:BufferGeometry center] ()

    diff --git a/docs/api/zh/core/Clock.html b/docs/api/zh/core/Clock.html index 230d3bb117c6a6..65d4b544acb8e7 100644 --- a/docs/api/zh/core/Clock.html +++ b/docs/api/zh/core/Clock.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/DirectGeometry.html b/docs/api/zh/core/DirectGeometry.html index 45317a017c49df..336328e67c9070 100644 --- a/docs/api/zh/core/DirectGeometry.html +++ b/docs/api/zh/core/DirectGeometry.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/EventDispatcher.html b/docs/api/zh/core/EventDispatcher.html index 18f22a74fea573..7b10512a0e7102 100644 --- a/docs/api/zh/core/EventDispatcher.html +++ b/docs/api/zh/core/EventDispatcher.html @@ -1,5 +1,5 @@ - + @@ -15,36 +15,36 @@

    [name]

    [link:https://github.com/mrdoob/eventdispatcher.js Eventdispatcher on GitHub]

    -

    示例

    +

    代码示例

    -// 为自定义对象添加事件 + // 为自定义对象添加事件 -var Car = function () { + var Car = function () { - this.start = function () { + this.start = function () { - this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); + this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); - }; + }; -}; + }; -// 将 EventDispatcher.prototype 与自定义对象 prototype 进行混合 + // 将 EventDispatcher.prototype 与自定义对象 prototype 进行混合 -Object.assign( Car.prototype, EventDispatcher.prototype ); + Object.assign( Car.prototype, EventDispatcher.prototype ); -// 使用自定义对象的事件 + // 使用自定义对象的事件 -var car = new Car(); + var car = new Car(); -car.addEventListener( 'start', function ( event ) { + car.addEventListener( 'start', function ( event ) { - alert( event.message ); + alert( event.message ); -} ); + } ); -car.start(); + car.start();

    构造函数

    diff --git a/docs/api/zh/core/Face3.html b/docs/api/zh/core/Face3.html index 6540b20ba72785..06cfe87e0bf0b6 100644 --- a/docs/api/zh/core/Face3.html +++ b/docs/api/zh/core/Face3.html @@ -1,5 +1,5 @@ - + @@ -15,39 +15,40 @@

    [name]

    然而,如果你正在构建一个自定义几何体,你需要手动创建这些三角形面。

    - -

    示例

    - -

    [example:svg_sandbox svg / sandbox ]

    -

    [example:misc_exporter_obj exporter / obj ]

    -

    [example:webgl_shaders_vector WebGL / shaders / vector ]

    - +

    代码示例

    -var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } ); + var material = new THREE.MeshStandardMaterial( { 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 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 ) ); -// 利用顶点 0, 1, 2 创建一个面 -var normal = new THREE.Vector3( 0, 1, 0 ); //optional -var color = new THREE.Color( 0xffaa00 ); //optional -var materialIndex = 0; //optional -var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex ); + // 利用顶点 0, 1, 2 创建一个面 + var normal = new THREE.Vector3( 0, 0, 1 ); //optional + var color = new THREE.Color( 0xffaa00 ); //optional + var materialIndex = 0; //optional + var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex ); -// 将创建的面添加到几何体的面的队列 -geometry.faces.push( face ); + // 将创建的面添加到几何体的面的队列 + geometry.faces.push( face ); -// 如果没有特别指明,面和顶点的法向量可以通过如下代码自动计算 -geometry.computeFaceNormals(); -geometry.computeVertexNormals(); + // 如果没有特别指明,面和顶点的法向量可以通过如下代码自动计算 + geometry.computeFaceNormals(); + geometry.computeVertexNormals(); -scene.add( new THREE.Mesh( geometry, material ) ); + scene.add( new THREE.Mesh( geometry, material ) ); +

    例子

    + +

    + [example:svg_sandbox svg / sandbox ]
    + [example:misc_exporter_obj exporter / obj ]
    + [example:webgl_shaders_vector WebGL / shaders / vector ] +

    构造函数

    @@ -94,7 +95,7 @@

    [property:Vector3 normal]

    [property:Color color]

    面的颜色值 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为 - [page:Materials THREE.FaceColors]。 + *true*。

    [property:Array vertexNormals]

    @@ -105,7 +106,7 @@

    [property:Array vertexNormals]

    [property:Array vertexColors]

    包含 3 个顶点颜色值的队列 - 在被用于指定材质的 [page:Material.vertexColors vertexColors] 属性时,该值必须被设置为 - [page:Materials THREE.VertexColors]。 + *true*。

    [property:Integer materialIndex]

    diff --git a/docs/api/zh/core/Geometry.html b/docs/api/zh/core/Geometry.html index 1409bed79277fb..a818fbc5b6a95a 100644 --- a/docs/api/zh/core/Geometry.html +++ b/docs/api/zh/core/Geometry.html @@ -1,5 +1,5 @@ - + @@ -21,20 +21,10 @@

    [name]

    -

    示例

    +

    代码示例

    -
    [example:webgl_geometry_minecraft WebGL / geometry / minecraft ]
    -
    [example:webgl_geometry_minecraft_ao WebGL / geometry / minecraft / ao ]
    -
    [example:webgl_geometry_nurbs WebGL / geometry / nurbs ]
    -
    [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor ]
    -
    [example:webgl_interactive_cubes_gpu WebGL / interactive / cubes / gpu ]
    -
    [example:webgl_interactive_lines WebGL / interactive / lines ]
    -
    [example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points ]
    -
    [example:webgl_interactive_voxelpainter WebGL / interactive / voxelpainter ]
    -
    [example:webgl_morphnormals WebGL / morphNormals ]
    - - - var geometry = new THREE.Geometry(); + + var geometry = new THREE.Geometry(); geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ), @@ -47,6 +37,19 @@

    示例

    geometry.computeBoundingSphere();
    +

    例子

    + +

    + [example:webgl_geometry_minecraft WebGL / geometry / minecraft ]
    + [example:webgl_geometry_minecraft_ao WebGL / geometry / minecraft / ao ]
    + [example:webgl_geometry_nurbs WebGL / geometry / nurbs ]
    + [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor ]
    + [example:webgl_interactive_cubes_gpu WebGL / interactive / cubes / gpu ]
    + [example:webgl_interactive_lines WebGL / interactive / lines ]
    + [example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points ]
    + [example:webgl_interactive_voxelpainter WebGL / interactive / voxelpainter ] +

    +

    构造函数

    @@ -198,7 +201,7 @@

    方法

    [page:EventDispatcher EventDispatcher] 该类中可用的函数。

    -

    [method:null applyMatrix]( [param:Matrix4 matrix] )

    +

    [method:null applyMatrix4]( [param:Matrix4 matrix] )

    将矩阵信息直接应用于几何体顶点坐标。

    [method:Geometry center] ()

    diff --git a/docs/api/zh/core/InstancedBufferAttribute.html b/docs/api/zh/core/InstancedBufferAttribute.html index c8526bf4c78b9c..d264c38a3432f4 100644 --- a/docs/api/zh/core/InstancedBufferAttribute.html +++ b/docs/api/zh/core/InstancedBufferAttribute.html @@ -1,5 +1,5 @@ - + @@ -22,7 +22,7 @@

    [name]( [param:TypedArray array], [param:Integer itemSize], [param:Number me

    属性

    - 继承属性详见 [page:BufferAttribute]。 +

    继承属性详见 [page:BufferAttribute]。

    [property:Number meshPerAttribute]

    diff --git a/docs/api/zh/core/InstancedBufferGeometry.html b/docs/api/zh/core/InstancedBufferGeometry.html index 18cce08eef6d0c..a7e3a9fa1b0f5b 100644 --- a/docs/api/zh/core/InstancedBufferGeometry.html +++ b/docs/api/zh/core/InstancedBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -22,7 +22,7 @@

    [name]( )

    属性

    - 继承属性详见 [page:BufferGeometry]。 +

    继承属性详见 [page:BufferGeometry]。

    [property:Number maxInstancedCount]

    @@ -30,13 +30,7 @@

    [property:Number maxInstancedCount]

    方法

    -

    继承方法详见 [page:BufferAttribute]。

    - -

    [property:Number addGroup]( start, count, materialIndex )

    -

    - -

    - +

    继承方法详见 [page:BufferGeometry]。

    源代码

    diff --git a/docs/api/zh/core/InstancedInterleavedBuffer.html b/docs/api/zh/core/InstancedInterleavedBuffer.html index b4628e34b31f77..64a358fc283917 100644 --- a/docs/api/zh/core/InstancedInterleavedBuffer.html +++ b/docs/api/zh/core/InstancedInterleavedBuffer.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/InterleavedBuffer.html b/docs/api/zh/core/InterleavedBuffer.html index 16a16904f4deaf..35e81bb8196d93 100644 --- a/docs/api/zh/core/InterleavedBuffer.html +++ b/docs/api/zh/core/InterleavedBuffer.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

    [name]

    如下链接有对交叉存储更详细的介绍: [link:https://blog.tojicode.com/2011/05/interleaved-array-basics.html Interleaved array basics]

    -

    示例

    +

    例子

    [example:webgl_buffergeometry_points_interleaved webgl / buffergeometry / points / interleaved]

    diff --git a/docs/api/zh/core/InterleavedBufferAttribute.html b/docs/api/zh/core/InterleavedBufferAttribute.html index 221f059e2c9655..6358968869860d 100644 --- a/docs/api/zh/core/InterleavedBufferAttribute.html +++ b/docs/api/zh/core/InterleavedBufferAttribute.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/Layers.html b/docs/api/zh/core/Layers.html index 5a95835bc4f1df..e2ccc201636a1d 100644 --- a/docs/api/zh/core/Layers.html +++ b/docs/api/zh/core/Layers.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/core/Object3D.html b/docs/api/zh/core/Object3D.html index 039ad48eb296b3..071f2873acb865 100644 --- a/docs/api/zh/core/Object3D.html +++ b/docs/api/zh/core/Object3D.html @@ -1,5 +1,5 @@ - + @@ -59,7 +59,8 @@

    [property:Integer id]

    [property:Layers layers]

    物体的层级关系。 - 物体只有和一个正在使用的[page:Camera]至少在同一个层时才可见。 + 物体只有和一个正在使用的[page:Camera]至少在同一个层时才可见。This property can also be used to filter out + unwanted objects in ray-intersection tests when using [page:Raycaster].

    [property:Matrix4 matrix]

    @@ -193,13 +194,13 @@

    [method:null add]( [param:Object3D object], ... )

    请参阅[page:Group]来查看手动编组对象的相关信息。

    -

    [method:null applyMatrix]( [param:Matrix4 matrix] )

    +

    [method:null applyMatrix4]( [param:Matrix4 matrix] )

    对当前物体应用这个变换矩阵,并更新物体的位置、旋转和缩放。

    [method:Object3D applyQuaternion]( [param:Quaternion quaternion] )

    对当前物体应用由四元数所表示的变换。

    - +

    [method:this attach]( [param:Object3D object] )

    将*object*作为子级来添加到该对象中,同时保持该object的世界变换。

    diff --git a/docs/api/zh/core/Raycaster.html b/docs/api/zh/core/Raycaster.html index de0a8223ef857e..2e3607784aa223 100644 --- a/docs/api/zh/core/Raycaster.html +++ b/docs/api/zh/core/Raycaster.html @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@

    光线投射[name]

    光线投射用于进行鼠标拾取(在三维空间中计算出鼠标移过了什么物体)。

    -

    示例

    +

    代码示例

    var raycaster = new THREE.Raycaster(); var mouse = new THREE.Vector2(); @@ -52,8 +52,10 @@

    示例

    window.requestAnimationFrame(render);
    -
    - 其它示例:
    [example:webgl_interactive_cubes Raycasting to a Mesh]
    + +

    例子

    +

    + [example:webgl_interactive_cubes Raycasting to a Mesh]
    [example:webgl_interactive_cubes_ortho Raycasting to a Mesh in using an OrthographicCamera]
    [example:webgl_interactive_buffergeometry Raycasting to a Mesh with BufferGeometry]
    [example:webgl_instancing_raycast Raycasting to a InstancedMesh]
    @@ -62,7 +64,7 @@

    示例

    [example:webgl_geometry_terrain_raycast Terrain raycasting]
    [example:webgl_interactive_voxelpainter Raycasting to paint voxels]
    [example:webgl_raycast_texture Raycast to a Texture] -
    +

    @@ -91,17 +93,10 @@

    [property:float far]

    这个值不应当为负,并且应当比near属性大。

    -

    [property:float linePrecision]

    -

    - - raycaster与[page:Line](线)物体相交时的精度因数。 - -

    -

    [property:float near]

    raycaster的近距离因数(投射近点)。这个值表明哪些对象可以基于该距离而被raycaster所丢弃。 - 这个值不应当为负,并且应当比near属性小。 + 这个值不应当为负,并且应当比far属性小。

    [property:Camera camera]

    @@ -112,18 +107,31 @@

    [property:Camera camera]

    Defaults to null.

    +

    [property:Layers layers]

    +

    + Used by [name] to selectively ignore 3D objects when performing intersection tests. The following code example ensures that + only 3D objects on layer *1* will be honored by the instance of [name]. + + + raycaster.layers.set( 1 ); + object.layers.enable( 1 ); + + +

    +

    [property:Object params]

    具有以下属性的对象: { Mesh: {}, - Line: {}, + Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} } + Where threshold is the precision of the raycaster when intersecting objects, in world units.

    [property:Ray ray]

    diff --git a/docs/api/zh/core/Uniform.html b/docs/api/zh/core/Uniform.html index 7cf6695de9f2f2..6a2a58721927ef 100644 --- a/docs/api/zh/core/Uniform.html +++ b/docs/api/zh/core/Uniform.html @@ -1,5 +1,5 @@ - + @@ -13,19 +13,18 @@

    [name]

    Uniforms 是 [link:https://www.opengl.org/documentation/glsl/ GLSL] 着色器中的全局变量。

    -

    示例

    +

    代码示例

    - 在声明一个 [page:ShaderMaterial] 的 Uniform 变量时,该变量被值或对象声明。 - When declaring a uniform of a [page:ShaderMaterial], it is declared by value or by object. + When declaring a uniform of a [page:ShaderMaterial], it is declared by value or by object.

    uniforms: { time: { value: 1.0 }, - resolution: new THREE.Uniform(new THREE.Vector2()) - } + resolution: new Uniform( new Vector2() ) + }; -

    Uniform 种类

    +

    Uniform 种类

    每个 Uniform 必须包括一个 *value* 属性。value 的类型必须和下表中 GLSL 的基本类型相对应。同样,Uniform 的结构体和队列 @@ -48,6 +47,10 @@

    Uniform 种类

    int [page:Number] + + uint (WebGL 2) + [page:Number] + float [page:Number] @@ -177,10 +180,66 @@

    Uniform 种类

    - (*) 与最内层队列中 GSLS 的类型保持一致。包含队列中所有矢量的元素或矩阵中的元素。

    +

    Structured Uniforms

    + +

    + Sometimes you want to organize uniforms as *structs* in your shader code. The following style must be used so *three.js* is able + to process structured uniform data. +

    + + uniforms = { + data: { + value: { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + } + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data; + + +

    Structured Uniforms with Arrays

    + +

    + It's also possible to manage *structs* in arrays. The syntax for this use case looks like so: +

    + + var entry1 = { + position: new Vector3(), + direction: new Vector3( 0, 0, 1 ) + }; + var entry2 = { + position: new Vector3( 1, 1, 1 ), + direction: new Vector3( 0, 1, 0 ) + }; + + uniforms = { + data: { + value: [ entry1, entry2 ] + } + }; + + This definition can be mapped on the following GLSL code: + + struct Data { + vec3 position; + vec3 direction; + }; + + uniform Data data[ 2 ]; + +

    构造函数

    [name]( [param:Object value] )

    @@ -201,9 +260,7 @@

    [method:Uniform clone]()

    返回该 Uniform 的克隆。
    如果 Uniform 的 value 属性是一个带 clone() 方法的 [page:Object],则克隆该对象时,value 的 clone() 方法也会被调用,否则克隆时只会使用赋值语句。 - 队列中的值会在该 Uniform 和 被克隆对象间共享。

    - - 该方法的使用示例详见 [example:webgldeferred_animation WebGL deferred animation]。 + 队列中的值会在该 Uniform 和 被克隆对象间共享。

    源代码

    diff --git a/docs/api/zh/core/bufferAttributeTypes/BufferAttributeTypes.html b/docs/api/zh/core/bufferAttributeTypes/BufferAttributeTypes.html index 26ad4035f7eb3c..09350e4bcced53 100644 --- a/docs/api/zh/core/bufferAttributeTypes/BufferAttributeTypes.html +++ b/docs/api/zh/core/bufferAttributeTypes/BufferAttributeTypes.html @@ -1,5 +1,5 @@ - + @@ -45,14 +45,20 @@

    TypedBufferAttribute( [param:Array array], [param:Integer itemSize], [param:

    属性

    - 继承属性详见 [page:BufferAttribute]。 +

    + 继承属性详见 [page:BufferAttribute]。 +

    方法

    - 继承方法详见 [page:BufferAttribute]。 +

    + 继承方法详见 [page:BufferAttribute]。 +

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js src/core/BufferAttribute.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js src/core/BufferAttribute.js] +

    diff --git a/docs/api/zh/deprecated/DeprecatedList.html b/docs/api/zh/deprecated/DeprecatedList.html deleted file mode 100644 index 4ba71c45437d02..00000000000000 --- a/docs/api/zh/deprecated/DeprecatedList.html +++ /dev/null @@ -1,589 +0,0 @@ - - - - - - - - - - -

    已被弃用API列表(Deprecated API List)

    - -

    - 由于three.js具有一个快速发展的接口,你可能会遇上类似“提示你当前所调用的API元素不再是Three.js核心的一部分”的提示。

    - 下面就列举出了这些API元素,以及一些关于他们的替代信息。 -

    - -

    音频(Audio)

    - -

    [page:Audio]

    -

    Audio.load 已被弃用。 请使用 [page:AudioLoader]。

    - -

    [page:AudioAnalyser]

    -

    AudioAnalyser.getData() 已被重命名为 [page:AudioAnalyser.getFrequencyData]()。

    - -

    [page:BinaryTextureLoader]

    -

    BinaryTextureLoader 已被重命名为 [page:DataTextureLoader]。

    - - -

    缓冲器(Buffers)

    - -

    [page:BufferAttribute]

    -

    BufferAttribute.length 已被重命名为 [page:BufferAttribute.count]。

    -

    BufferAttribute.copyIndicesArray() 已被删除。

    - - -

    [page:DynamicBufferAttribute]

    -

    DynamicBufferAttribute 已被删除。 请使用[page:BufferAttribute.setDynamic]( true )。

    - -

    [page:Int8Attribute]

    -

    Int8Attribute 已被删除。 请使用[page:BufferAttributeTypes Int8BufferAttribute]。

    - -

    [page:Uint8Attribute]

    -

    Uint8Attribute 已被删除。 请使用[page:BufferAttributeTypes Uint8BufferAttribute]。

    - -

    [page:Uint8ClampedAttribute]

    -

    Uint8ClampedAttribute 已被删除。 请使用[page:BufferAttributeTypes Uint8ClampedBufferAttribute]。

    - -

    [page:Int16Attribute]

    -

    Int16Attribute 已被删除。 请使用[page:BufferAttributeTypes Int16BufferAttribute]。

    - -

    [page:Uint16Attribute]

    -

    Uint16Attribute 已被删除。 请使用[page:BufferAttributeTypes Uint16BufferAttribute]。

    - -

    [page:Int32Attribute]

    -

    Int32Attribute 已被删除。 请使用[page:BufferAttributeTypes Int32BufferAttribute]。

    - -

    [page:Uint32Attribute]

    -

    Uint32Attribute 已被删除。 请使用[page:BufferAttributeTypes Uint32BufferAttribute]。

    - -

    [page:Float32Attribute]

    -

    Float32Attribute 已被删除。 请使用[page:BufferAttributeTypes Float32BufferAttribute]。

    - -

    [page:Float64Attribute]

    -

    Float64Attribute 已被删除。 请使用[page:BufferAttributeTypes Float64BufferAttribute]。

    - - - - - - - -

    摄像机(Cameras)

    - -

    [page:PerspectiveCamera]

    -

    - PerspectiveCamera.setLens() 已被弃用。 请使用[page:PerspectiveCamera.setFocalLength]() - 和 [page:PerspectiveCamera.filmGauge]() 来对摄像机拍摄进行设置。 -

    - - - - - - - -

    常量(Constants)

    - -

    [page:LineStrip]

    - -

    [page:LinePieces]

    -

    - LinePieces mode 已经不再对 [page:Line]s 进行支持。 请创建一个 [page:LineSegments] 。 -

    - - - - - -

    核心(Core)

    - -

    [page:EventDispatcher]

    -

    EventDispatcher.apply 已被删除。 请继承或者Object.assign其原型来“混合”。Inherit or Object.assign the prototype to mix-in。

    - -

    [page:Raycaster]

    -

    Raycaster.params.PointCloud 已被重命名为 [page:Raycaster.params.Points]。

    - - -

    [page:Uniform]

    -

    - Uniform.dynamic 已被删除。 请使用object.onBeforeRender()。

    - - Uniform.onUpdate 已被删除。 请使用object.onBeforeRender() 。 -

    - - - - - - -

    附件(Extras)

    - -

    [page:ClosedSplineCurve3]

    -

    ClosedSplineCurve3 已被弃用。 请使用[page:CatmullRomCurve3]。

    - -

    [page:SplineCurve3]

    -

    SplineCurve3 已被弃用。 请使用[page:CatmullRomCurve3]。

    - - - - - - - -

    几何体(Geometry)

    - -

    - Geometry.computeTangents() 已被删除。

    - - Geometry.computeLineDistances() 已被删除。 请使用[page:Line.computeLineDistances]。

    -

    - -

    [page:BufferGeometry]

    -

    - BufferGeometry.addIndex 已被重命名为 [page:BufferGeometry.setIndex]。

    - - BufferGeometry.addDrawCall 现在是 [page:BufferGeometry.addGroup]。

    - - BufferGeometry.clearDrawCalls 现在是 [page:BufferGeometry.clearGroups]。

    - - BufferGeometry.computeTangents 已被删除。

    - - BufferGeometry.computeOffsets 已被删除。

    - - BufferGeometry.drawcalls 已被重命名为 [page:BufferGeometry.groups]。

    - - BufferGeometry.offsets 已被重命名为 [page:BufferGeometry.groups]。

    - -

    - -

    [page:CubeGeometry]

    -

    CubeGeometry 已被重命名为 [page:BoxGeometry]。

    - -

    [page:Geometry]

    -

    Geometry.computeTangents() 已被删除。

    - -

    [page:GeometryUtils]

    -

    - GeometryUtils.merge 已被移动到了 [page:Geometry],请使用[page:Geometry.merge]( geometry2, matrix, materialIndexOffset )。

    - - GeometryUtils.center 已被移动到了 [page:Geometry],请使用[page:Geometry.center]( ) 。 -

    - -

    [page:Plane]

    -

    - Plane.isIntersectionLine() 已被重命名为 [page:Plane.intersectsLine]()。 -

    - - - - - - - - -

    辅助工具(Helpers)

    - -

    [page:BoundingBoxHelper]

    -

    BoundingBoxHelper 已被弃用。 请使用[page:BoxHelper]。

    - -

    [page:EdgesHelper]

    -

    EdgesHelper 已被删除。 请使用[page:EdgesGeometry]。

    - -

    [page:GridHelper]

    -

    GridHelper.setColors() 已被弃用,请在构造器中传递它们。

    - -

    [page:WireframeHelper WireframeHelper]

    -

    WireframeHelper 已被删除。 请使用[page:WireframeGeometry]。

    - - - - -

    灯光(Lights)

    - -

    [page:Light]

    -

    - Light.onlyShadow 已被删除。

    - - Light.shadowCameraLeft 现在是 [page:Light.shadow.camera.left]。

    - - Light.shadowCameraRight 现在是 [page:Light.shadow.camera.right]。

    - - Light.shadowCameraTop 现在是 [page:Light.shadow.camera.top]。

    - - Light.shadowCameraBottom 现在是 [page:Light.shadow.camera.bottom]。

    - - Light.shadowCameraNear 现在是 [page:Light.shadow.camera.near]。

    - - Light.shadowCameraFar 现在是 [page:Light.shadow.camera.far]。

    - - Light.shadowCameraVisible 已被删除。 请使用[page:CameraHelper] ( light.shadow.camera )。

    - - Light.shadowMapWidth 现在是 [page:Light.shadow.mapSize.width]。

    - - Light.shadowMapHeight 现在是 [page:Light.shadow.mapSize.height]。 -

    - -

    加载器(Loaders)

    - -

    [page:XHRLoader]

    -

    XHRLoader 已被重命名为 [page:FileLoader]。

    - -

    [page:JSONLoader]

    -

    JSONLoader has been removed from core.

    - -

    数学(Maths)

    - -

    [page:Box2]

    -

    - Box2.center 已被重命名为 [page:Box2.getCenter]()。

    - - Box2.empty 已被重命名为 [page:Box2.isEmpty]()。

    - - Box2.isIntersectionBox 已被重命名为 [page:Box2.intersectsBox]()。

    - - Box2.size 已被重命名为 [page:Box2.getSize]()。 - -

    - -

    [page:Box3]

    -

    - Box3.center 已被重命名为 [page:Box3.getCenter]()。

    - - Box3.empty 已被重命名为 [page:Box3.isEmpty]()。

    - - Box3.isIntersectionBox 已被重命名为 [page:Box3.intersectsBox]()。

    - - Box3.isIntersectionSphere 已被重命名为 [page:Box3.intersectsSphere]()。

    - - Box3.size 已被重命名为 [page:Box3.getSize]()。 -

    - -

    [page:Face4]

    -

    Face4 已被删除。 请使用[page:Face3]。

    - -

    [page:Line3]

    -

    Line3.center 已被重命名为 [page:Line3.getCenter]()。

    - -

    [page:Math]

    -

    - Math.random16() 已被弃用。 请使用Math.random() 。 -

    - -

    [page:Matrix3]

    -

    - Matrix3.flattenToArrayOffset 已被弃用。请使用[page:Matrix3.toArray]()。

    - - Matrix3.multiplyVector3 已被删除。 请使用vector.applyMatrix3( matrix )。

    - - Matrix3.multiplyVector3Array 已被重命名为 [page:Matrix3.applyToVector3Array]( array )。

    - - Matrix3.applyToBuffer 已被删除。 请使用matrix.applyToBufferAttribute( attribute )。

    - - Matrix3.applyToVector3Array 已被删除。 -

    - -

    [page:Matrix4]

    -

    - Matrix4.flattenToArrayOffset() 已被弃用。请使用[page:Matrix4.toArray]()。

    - - Matrix4.extractPosition() 已被重命名为 [page:Matrix4.copyPosition]( matrix )。

    - - Matrix4.getPosition() 已被删除。 请使用[page:Vector3.setFromMatrixPosition]( matrix )。

    - - Matrix4.setRotationFromQuaternion() 已被重命名为 [page:Matrix4.makeRotationFromQuaternion]( quaternion )。

    - - Matrix4.multiplyVector3() 已被删除。 请使用vector.applyMatrix4( matrix )。

    - - Matrix4.multiplyVector4() 已被删除。 请使用vector.applyMatrix4( matrix )。

    - - Matrix4.multiplyVector3Array() 已被重命名为 [page:Matrix4.applyToVector3Array] ( array )。

    - - Matrix4.rotateAxis() 已被删除。 请使用[page:Matrix4.transformDirection]( matrix )。

    - - Matrix4.crossVector() 已被删除。 请使用vector.applyMatrix4( matrix )。

    - - Matrix4.rotateX() 已被删除。

    - - Matrix4.rotateY() 已被删除。

    - - Matrix4.rotateZ() 已被删除。

    - - Matrix4.rotateByAxis() 已被删除。

    - - Matrix4.applyToBuffer() 已被删除。 请使用matrix.applyToBufferAttribute()。

    - - Matrix4.applyToVector3Array() 已被删除。

    - - Matrix4.makeFrustum() 已被删除。 请使用[page:Matrix4.makePerspective]( left, right, top, bottom, near, far ) 。 -

    - - -

    [page:Quaternion.multiplyVector3]

    -

    Quaternion.multiplyVector3() 已被删除。 请使用vector.applyQuaternion( quaternion )。

    - -

    [page:Ray]

    -

    - Ray.isIntersectionBox() 已被重命名为 [page:Ray.intersectsBox]()。

    - - Ray.isIntersectionPlane 已被重命名为 [page:Ray.intersectsPlane]。

    - - Ray.isIntersectionSphere 已被重命名为 [page:Ray.intersectsSphere]。 -

    - -

    [page:Triangle]

    -

    - Triangle.area() 已被重命名为 [page:Triangle.getArea]()。

    - Triangle.barycoordFromPoint() 已被重命名为 [page:Triangle.getBarycoord]()。

    - Triangle.midpoint() 已被重命名为 [page:Triangle.getMidpoint]()。

    - Triangle.normal() 已被重命名为 [page:Triangle.getNormal]()。

    - Triangle.plane() 已被重命名为 [page:Triangle.getPlane]()。 -

    - -

    [page:Vector2]

    -

    - Vector2.fromAttribute() 已被重命名为 [page:Vector2.fromBufferAttribute]()。 -

    - -

    [page:Vector3]

    -

    - Vector3.setEulerFromRotationMatrix() 已被删除。 请使用[page:Euler.setFromRotationMatrix]()。

    - - Vector3.setEulerFromQuaternion() 已被删除。 请使用[page:Euler.setFromQuaternion]()。

    - - Vector3.getPositionFromMatrix() 已被重命名为 [page:Vector3.setFromMatrixPosition]()。

    - - Vector3.getScaleFromMatrix() 已被重命名为 [page:Vector3.setFromMatrixScale]()。

    - - Vector3.getColumnFromMatrix() 已被重命名为 [page:Vector3.setFromMatrixColumn]()。

    - - Vector3.applyProjection() 已被删除。 请使用[page:Vector3.applyMatrix4]()。

    - - Vector3.fromAttribute() 已被重命名为 [page:Vector3.fromBufferAttribute]()。 -

    - -

    [page:Vector4]

    -

    - Vector4.fromAttribute() 已被重命名为 [page:Vector4.fromBufferAttribute](). -

    - -

    [page:Vertex]

    -

    Vertex 已被删除。 请使用[page:Vector3]。

    - -

    [page:Spline]

    -

    Spline 已被删除。 请使用[page:CatmullRomCurve3]。

    - - - - - - - - - - - - -

    材质(Materials)

    - -

    [page:Material]

    -

    - Material.wrapAround 已被删除。

    - - Material.wrapRGB 已被删除。 - -

    - -

    [page:MeshFaceMaterial]

    -

    MeshFaceMaterial 已被删除。 请使用一个材质数组。

    - -

    [page:MultiMaterial]

    -

    MultiMaterial 已被删除。 请使用一个材质数组。

    - -

    [page:MeshPhongMaterial]

    -

    MeshPhongMaterial.metal 已被删除。 请使用[page:MeshStandardMaterial]。

    - -

    [page:ParticleBasicMaterial]

    -

    ParticleBasicMaterial 已被重命名为 [page:PointsMaterial]。

    - -

    [page:ParticleSystemMaterial]

    -

    ParticleBasicMaterial 已被重命名为 [page:PointsMaterial]。

    - -

    [page:PointCloudMaterial]

    -

    PointCloudMaterial 已被重命名为 [page:PointsMaterial]。

    - -

    [page:ShaderMaterial.derivatives]

    -

    ShaderMaterial.derivatives 已被移动到了 [page:ShaderMaterial.extensions.derivatives]。

    - - - - - - - - -

    物体(Objects)

    - -

    [page:LOD.objects]

    -

    LOD.objects 已被重命名为 [page:LOD.levels]。

    - -

    [page:Object3D]

    -

    - Object3D.eulerOrder 现在是 [page:Object3D.rotation.order]。

    - - Object3D.getChildByName() 已被重命名为 [page:Object3D.getObjectByName]()。

    - - Object3D.renderDepth 已被删除。 请使用[page:Object3D.renderOrder]。

    - - Object3D.translate() 已被删除。 请使用[page:Object3D.translateOnAxis]( axis, distance )。

    - - Object3D.useQuaternion 已被删除。 默认情况下,Three.js库是使用quaternions(四元数)的。 -

    - -

    [page:LensFlare]

    -

    - LensFlare 已被移动到了 [link:https://github.com/mrdoob/three.js/blob/master/examples/js/objects/Lensflare.js /examples/js/objects/Lensflare.js]. -

    - - -

    [page:Particle]

    -

    Particle 已被重命名为 [page:Sprite]。

    - -

    [page:ParticleSystem]

    -

    ParticleSystem 已被重命名为 [page:Points]。

    - -

    [page:PointCloud]

    -

    PointCloud 已被重命名为 [page:Points]。

    - -

    [page:Shape]

    -

    - Shape.extrude 已被删除。 请使用[page:ExtrudeGeometry]。

    - - Shape.makeGeometry 已被删除。 请使用[page:ShapeGeometry] 。 -

    - -

    [page:SkinnedMesh]

    -

    - SkinnedMesh.initBones() has been removed. -

    - - -

    渲染器(Renderer)

    - -

    [page:Projector]

    -

    - CanvasRenderer 已被移动到了 [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CanvasRenderer.js /examples/js/renderers/CanvasRenderer.js]. -

    - -

    [page:Projector]

    -

    - Projector 已被移动到了 - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/Projector.js /examples/js/renderers/Projector.js]。

    - - Projector.projectVector() 现在是 [page:Vector.project]()。

    - - Projector.unprojectVector() 现在是 [page:Vector.unproject]()。

    - - Projector:.pickingRay() 现在是 [page:Raycaster.setFromCamera]()。 -

    - -

    [page:WebGLProgram]

    -

    - WebGLProgram.uniforms 现在是 [page:WebGLProgram.getUniforms]()。

    - - WebGLProgram.attributes 现在是 [page:WebGLProgram.getAttributes]()。 -

    - -

    [page:WebGLRenderer]

    -

    - WebGLRenderer.supportsFloatTextures() 现在是 [page:WebGLRenderer.extensions.get]( 'OES_texture_float' )。

    - - WebGLRenderer.supportsHalfFloatTextures() 现在是 [page:WebGLRenderer.extensions.get]( 'OES_texture_half_float' )。

    - - WebGLRenderer.supportsStandardDerivatives() 现在是 [page:WebGLRenderer.extensions.get]( 'OES_standard_derivatives' )。

    - - WebGLRenderer.supportsCompressedTextureS3TC() 现在是 [page:WebGLRenderer.extensions.get]( 'WEBGL_compressed_texture_s3tc' )。

    - - WebGLRenderer.supportsCompressedTexturePVRTC() 现在是 [page:WebGLRenderer.extensions.get]( 'WEBGL_compressed_texture_pvrtc' )。

    - - WebGLRenderer.supportsBlendMinMax() 现在是 [page:WebGLRenderer.extensions.get]( 'EXT_blend_minmax' )。

    - - WebGLRenderer.supportsVertexTextures() 现在是 [page:WebGLRenderer.capabilities.vertexTextures]。

    - - WebGLRenderer.supportsInstancedArrays() 现在是 [page:WebGLRenderer.extensions.get]( 'ANGLE_instanced_arrays' )。

    - - WebGLRenderer.enableScissorTest() 现在是 [page:WebGLRenderer.setScissorTest]()。

    - - WebGLRenderer.initMaterial() 已被删除。

    - - WebGLRenderer.addPrePlugin() 已被删除。

    - - WebGLRenderer.addPostPlugin() 已被删除。

    - - WebGLRenderer.updateShadowMap() 已被删除。

    - - WebGLRenderer.setFaceCulling() 已被删除。

    - - WebGLRenderer.setTexture is deprecated, 请使用[page:WebGLRenderer.setTexture2D]()。

    - - WebGLRenderer.shadowMapEnabled 现在是 [page:WebGLRenderer.shadowMap.enabled]。

    - - WebGLRenderer.shadowMapType 现在是 [page:WebGLRenderer.shadowMap.type]。

    - - WebGLRenderer.shadowMapCullFace 已被删除。请设置[page:Material.shadowSide]。

    - - WebGLRenderer.shadowMap.cullFace 已被删除。请设置[page:Material.shadowSide]。

    - - WebGLRenderer.shadowMap.renderReverseSided 已被删除。请设置[page:Material.shadowSide]。

    - - WebGLRenderer.shadowMap.renderSingleSided 已被删除。请设置[page:Material.shadowSide]。 - -

    - -

    [page:WebGLRenderTarget]

    -

    - WebGLRenderTarget.wrapS 现在是 [page:WebGLRenderTarget.texture.wrapS]。

    - - WebGLRenderTarget.wrapT 现在是 [page:WebGLRenderTarget.texture.wrapT]。

    - - WebGLRenderTarget.magFilter 现在是 [page:WebGLRenderTarget.texture.magFilter]。

    - - WebGLRenderTarget.minFilter 现在是 [page:WebGLRenderTarget.texture.minFilter]。

    - - WebGLRenderTarget.anisotropy 现在是 [page:WebGLRenderTarget.texture.anisotropy]。

    - - WebGLRenderTarget.offset 现在是 [page:WebGLRenderTarget.texture.offset]。

    - - WebGLRenderTarget.repeat 现在是 [page:WebGLRenderTarget.texture.repeat]。

    - - WebGLRenderTarget.format 现在是 [page:WebGLRenderTarget.texture.format]。

    - - WebGLRenderTarget.type 现在是 [page:WebGLRenderTarget.texture.type]。

    - - WebGLRenderTarget.generateMipmaps 现在是 [page:WebGLRenderTarget.texture.generateMipmaps]. -

    - - -

    纹理(Textures)

    - -

    [page:ImageUtils]

    -

    - ImageUtils.loadTexture 已被弃用。 请使用[page:TextureLoader]。

    - - ImageUtils.loadTextureCube 已被弃用。 请使用[page:CubeTextureLoader]。

    - - ImageUtils.loadCompressedTexture 已被删除。 请使用[page:DDSLoader]。

    - - ImageUtils.loadCompressedTextureCube 已被删除。 请使用[page:DDSLoader] 。 -

    - - -

    源代码

    - -

    - [link:https://github.com/mrdoob/three.js/blob/master/src/Three.Legacy.js src/Three.Legacy.js] -

    - - - diff --git a/docs/api/zh/extras/Earcut.html b/docs/api/zh/extras/Earcut.html index 614c88a3a500f8..96bd463f10f8e2 100644 --- a/docs/api/zh/extras/Earcut.html +++ b/docs/api/zh/extras/Earcut.html @@ -1,5 +1,5 @@ - + @@ -18,10 +18,11 @@

    方法

    [method:Array triangulate]( data, holeIndices, dim )

    - data -- 一个顶点坐标的平面数组。

    - holeIndices -- 空洞索引的数组(如果有的话)。

    + data -- 一个顶点坐标的平面数组。
    + holeIndices -- 空洞索引的数组(如果有的话)。
    dim -- 输入数组中每个顶点的坐标数。

    + Triangulates the given shape definition by returning an array of triangles. A triangle is defined by three consecutive integers representing vertex indices.

    源代码

    diff --git a/docs/api/zh/extras/ImageUtils.html b/docs/api/zh/extras/ImageUtils.html new file mode 100644 index 00000000000000..a8ccaf816b3588 --- /dev/null +++ b/docs/api/zh/extras/ImageUtils.html @@ -0,0 +1,32 @@ + + + + + + + + + + +

    [name]

    + +

    + A class containing utility functions for images. +

    + +

    Methods

    + +

    [method:String getDataURL]( [param:HTMLCanvasElement image] | [param:HTMLImageElement image] | [param:ImageBitmap image] )

    +

    + image -- The image object.

    + + Returns a data URI containing a representation of the given image. +

    + +

    Source

    + +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

    + + diff --git a/docs/api/zh/extras/PMREMGenerator.html b/docs/api/zh/extras/PMREMGenerator.html new file mode 100644 index 00000000000000..3d30fa7314f137 --- /dev/null +++ b/docs/api/zh/extras/PMREMGenerator.html @@ -0,0 +1,80 @@ + + + + + + + + + + +

    [name]

    + +

    + This class generates a Prefiltered, Mipmapped Radiance Environment Map (PMREM) from a cubeMap environment texture. + This allows different levels of blur to be quickly accessed based on material roughness. It is packed into a special + CubeUV format that allows us to perform custom interpolation so that we can support nonlinear formats such as RGBE. + Unlike a traditional mipmap chain, it only goes down to the LOD_MIN level (above), and then creates extra even more + filtered 'mips' at the same LOD_MIN resolution, associated with higher roughness levels. In this way we maintain + resolution to smoothly interpolate diffuse lighting while limiting sampling computation. +

    + +

    Constructor

    + +

    [name]( [param:WebGLRenderer renderer] )

    +

    + This constructor creates a new [name]. +

    + +

    Methods

    + +

    [method:WebGLRenderTarget fromScene]( [param:Scene scene], [param:Number sigma], [param:Number near], [param:Number far] )

    +

    + [page:Scene scene] - The given scene.
    + [page:Number sigma] - (optional) Specifies a blur radius in radians to be applied to the scene before PMREM generation. Default is *0*.
    + [page:Number near] - (optional) The near plane value. Default is *0.1*.
    + [page:Number far] - (optional) The far plane value. Default is *100*.

    + + Generates a PMREM from a supplied Scene, which can be faster than using an image if networking bandwidth is low. + Optional near and far planes ensure the scene is rendered in its entirety (the cubeCamera is placed at the origin). +

    + +

    [method:WebGLRenderTarget fromEquirectangular]( [param:Texture equirectangular] )

    +

    + [page:Texture equirectangular] - The equirectangular texture.

    + + Generates a PMREM from an equirectangular texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat). + The ideal input image size is 1k (1024 x 512), as this matches best with the 256 x 256 cubemap output. +

    + +

    [method:WebGLRenderTarget fromCubemap]( [param:CubeTexture cubemap] )

    +

    + [page:CubeTexture cubemap] - The cubemap texture.

    + + Generates a PMREM from an cubemap texture, which can be either LDR (RGBFormat) or HDR (RGBEFormat). + The ideal input cube size is 256 x 256, as this matches best with the 256 x 256 cubemap output. +

    + +

    [method:void compileCubemapShader]()

    +

    + Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency. +

    + +

    [method:void compileEquirectangularShader]()

    +

    + Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during your texture's network fetch for increased concurrency. +

    + +

    [method:void dispose]()

    +

    + Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class, so you should not need more than one + PMREMGenerator object. If you do, calling dispose() on one of them will cause any others to also become unusable. +

    + +

    Source

    + +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

    + + diff --git a/docs/api/zh/extras/ShapeUtils.html b/docs/api/zh/extras/ShapeUtils.html index 246d5dfe9e2d16..ed30bc422f5b16 100644 --- a/docs/api/zh/extras/ShapeUtils.html +++ b/docs/api/zh/extras/ShapeUtils.html @@ -1,5 +1,5 @@ - + @@ -23,11 +23,10 @@

    [method:Number area]( contour )

    contour -- 2D多边形,一个THREE.Vector2()数组。

    - 计算(2D)轮廓多边形的面积。

    - + 计算(2D)轮廓多边形的面积。

    -

    [method:Boolean isClockwise]( pts )

    +

    [method:Boolean isClockWise]( pts )

    pts -- 定义2D多边形的点

    diff --git a/docs/api/zh/extras/core/Curve.html b/docs/api/zh/extras/core/Curve.html index 9abd7140ab6e51..503f98b25fa85e 100644 --- a/docs/api/zh/extras/core/Curve.html +++ b/docs/api/zh/extras/core/Curve.html @@ -1,5 +1,5 @@ - + @@ -77,17 +77,25 @@

    [method:Float getUtoTmapping]( [param:Float u], [param:Float distance] )

    +

    -

    [method:Vector getTangent]( [param:Float t] )

    +

    [method:Vector getTangent]( [param:Float t, [param:Vector optionalTarget] ] )

    + [page:Float t] - A position on the curve. Must be in the range [ 0, 1 ].
    + [page:Vector optionalTarget] — (optional) If specified, the result will be copied into this Vector, + otherwise a new Vector will be created.

    + Returns a unit vector tangent at t. If the derived curve does not implement its tangent derivation, two points a small delta apart will be used to find its gradient which seems to give a reasonable approximation.

    -

    [method:Vector getTangentAt]( [param:Float u] )

    +

    [method:Vector getTangentAt]( [param:Float u, [param:Vector optionalTarget] ] )

    + [page:Float u] - A position on the curve according to the arc length. Must be in the range [ 0, 1 ].
    + [page:Vector optionalTarget] — (optional) If specified, the result will be copied into this Vector, + otherwise a new Vector will be created.

    + Returns tangent at a point which is equidistant to the ends of the curve from the point given in [page:.getTangent].

    diff --git a/docs/api/zh/extras/core/CurvePath.html b/docs/api/zh/extras/core/CurvePath.html index 915c398de12c86..45d469a57d2968 100644 --- a/docs/api/zh/extras/core/CurvePath.html +++ b/docs/api/zh/extras/core/CurvePath.html @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@

    曲线路径([name])

    - + 一个扩展了[page:Curve]的抽象基类。CurvePath仅仅是一个已连接的曲线的数组,但保留了曲线的API。

    @@ -52,6 +52,26 @@

    [method:null closePath]()

    [method:Float getCurveLengths]()

    将[page:.curves]数组中曲线的长度相加。

    +

    [method:Vector getPoint]( [param:Float t] )

    +

    + [page:Float t] - A position on the curve. Must be in the range [ 0, 1 ].

    + + Returns a vector for a given position on the curve path. +

    + +

    [method:Array getPoints]( [param:Integer divisions] )

    +

    + divisions -- 曲线分段数量。默认值为*12*。

    + + 返回一组使用getPoint( t )获得的divisions + 1个点。 +

    + +

    [method:Array getSpacedPoints]( [param:Integer divisions] )

    +

    + divisions -- 曲线分段数量。默认值为*40*。

    + + 返回一组使用getPointAt( u )获得的divisions + 1个均分点。 +

    源代码

    diff --git a/docs/api/zh/extras/core/Font.html b/docs/api/zh/extras/core/Font.html index 131a2d81841576..4bf94db778be01 100644 --- a/docs/api/zh/extras/core/Font.html +++ b/docs/api/zh/extras/core/Font.html @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@

    字体([name])

    该类在内部由[page:FontLoader]所使用。

    -

    示例

    +

    例子

    [example:webgl_geometry_text_shapes geometry / text / shapes ]
    diff --git a/docs/api/zh/extras/core/Interpolations.html b/docs/api/zh/extras/core/Interpolations.html index e42d8c13593f38..1857d9ce4a21df 100644 --- a/docs/api/zh/extras/core/Interpolations.html +++ b/docs/api/zh/extras/core/Interpolations.html @@ -1,5 +1,5 @@ - + @@ -11,7 +11,7 @@

    插值([name])

    - TODO + [name] contains spline and Bézier functions internally used by concrete curve classes.

    方法

    diff --git a/docs/api/zh/extras/core/Path.html b/docs/api/zh/extras/core/Path.html index 11b9d8ea0955b1..2beabfc1f5cd1c 100644 --- a/docs/api/zh/extras/core/Path.html +++ b/docs/api/zh/extras/core/Path.html @@ -1,5 +1,5 @@ - + @@ -16,22 +16,22 @@

    路径([name])

    该类定义了二维路径,提供了一些类似2D Canvas API的方法来创建或者构造二维路径。

    -

    示例

    +

    代码示例

    - var path = new THREE.Path(); + var path = new THREE.Path(); - path.lineTo( 0, 0.8 ); - path.quadraticCurveTo( 0, 1, 0.2, 1 ); - path.lineTo( 1, 1 ); + path.lineTo( 0, 0.8 ); + path.quadraticCurveTo( 0, 1, 0.2, 1 ); + path.lineTo( 1, 1 ); - var points = path.getPoints(); + var points = path.getPoints(); - var geometry = new THREE.BufferGeometry().setFromPoints( points ); - var material = new THREE.LineBasicMaterial( { color: 0xffffff } ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var material = new THREE.LineBasicMaterial( { color: 0xffffff } ); - var line = new THREE.Line( geometry, material ); - scene.add( line ); + var line = new THREE.Line( geometry, material ); + scene.add( line ); diff --git a/docs/api/zh/extras/core/Shape.html b/docs/api/zh/extras/core/Shape.html index 8d5b62f4d5805e..0a2cb9741c1af3 100644 --- a/docs/api/zh/extras/core/Shape.html +++ b/docs/api/zh/extras/core/Shape.html @@ -1,5 +1,5 @@ - + @@ -17,6 +17,8 @@

    形状([name])

    它可以和[page:ExtrudeGeometry]、[page:ShapeGeometry]一起使用,获取点,或者获取三角面。

    +

    代码示例

    + var heartShape = new THREE.Shape(); @@ -30,20 +32,19 @@

    形状([name])

    var extrudeSettings = { amount: 8, bevelEnabled: true, bevelSegments: 2, steps: 2, bevelSize: 1, bevelThickness: 1 }; - var geometry = new THREE.ExtrudeGeometry( heartShape, extrudeSettings ); + var geometry = new THREE.ExtrudeBufferGeometry( heartShape, extrudeSettings ); var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
    -

    示例

    +

    例子

    [example:webgl_geometry_shapes geometry / shapes ]
    [example:webgl_geometry_extrude_shapes geometry / extrude / shapes ]
    - [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2 ]
    + [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2 ]

    -

    构造函数

    diff --git a/docs/api/zh/extras/core/ShapePath.html b/docs/api/zh/extras/core/ShapePath.html index 2994c8e6c8088f..e5f220e66abea1 100644 --- a/docs/api/zh/extras/core/ShapePath.html +++ b/docs/api/zh/extras/core/ShapePath.html @@ -1,5 +1,5 @@ - + @@ -8,8 +8,6 @@ - [page:Curve] → [page:CurvePath] → -

    形状路径([name])

    @@ -17,9 +15,10 @@

    形状路径([name])

    在内部它由[page:Font]所使用,用于将JSON字体转换为一系列路径。

    -

    示例

    - - [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2] +

    例子

    +

    + [example:webgl_geometry_extrude_shapes2 geometry / extrude / shapes2] +

    构造函数

    @@ -84,7 +83,8 @@

    [method:Array toShapes]( [param:Boolean isCCW], [param:Boolean noHoles] )源代码

    - - [link:https://github.com/mrdoob/three.js/blob/master/src/extras/core/Path.js src/extras/core/Path.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/extras/core/Path.js src/extras/core/Path.js] +

    diff --git a/docs/api/zh/extras/curves/ArcCurve.html b/docs/api/zh/extras/curves/ArcCurve.html index fd26fad768d334..45cf03eeccf152 100644 --- a/docs/api/zh/extras/curves/ArcCurve.html +++ b/docs/api/zh/extras/curves/ArcCurve.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/extras/curves/CatmullRomCurve3.html b/docs/api/zh/extras/curves/CatmullRomCurve3.html index 7094b5019cec7e..86e317ca103fb7 100644 --- a/docs/api/zh/extras/curves/CatmullRomCurve3.html +++ b/docs/api/zh/extras/curves/CatmullRomCurve3.html @@ -1,5 +1,5 @@ - + @@ -16,29 +16,32 @@

    [name]

    使用[link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom]算法, 从一系列的点创建一条平滑的三维样条曲线。

    -

    示例

    +

    代码示例

    - -//Create a closed wavey loop -var curve = new THREE.CatmullRomCurve3( [ - new THREE.Vector3( -10, 0, 10 ), - new THREE.Vector3( -5, 5, 5 ), - new THREE.Vector3( 0, 0, 0 ), - new THREE.Vector3( 5, -5, 5 ), - new THREE.Vector3( 10, 0, 10 ) -] ); + + //Create a closed wavey loop + var curve = new THREE.CatmullRomCurve3( [ + new THREE.Vector3( -10, 0, 10 ), + new THREE.Vector3( -5, 5, 5 ), + new THREE.Vector3( 0, 0, 0 ), + new THREE.Vector3( 5, -5, 5 ), + new THREE.Vector3( 10, 0, 10 ) + ] ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); + -

    [example:webgl_geometry_extrude_splines geometry / extrude / splines]

    +

    例子

    +

    + [example:webgl_geometry_extrude_splines WebGL / geometry / extrude / splines] +

    构造函数

    diff --git a/docs/api/zh/extras/curves/CubicBezierCurve.html b/docs/api/zh/extras/curves/CubicBezierCurve.html index cb5c69791a01bc..8f16be4b77c8e3 100644 --- a/docs/api/zh/extras/curves/CubicBezierCurve.html +++ b/docs/api/zh/extras/curves/CubicBezierCurve.html @@ -1,5 +1,5 @@ - + @@ -18,24 +18,24 @@

    二维三次贝塞尔曲线([name])

    由起点、终点和两个控制点所定义。

    -

    示例

    +

    代码示例

    - -var curve = new THREE.CubicBezierCurve( - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( -5, 15 ), - new THREE.Vector2( 20, 15 ), - new THREE.Vector2( 10, 0 ) -); + + var curve = new THREE.CubicBezierCurve( + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( -5, 15 ), + new THREE.Vector2( 20, 15 ), + new THREE.Vector2( 10, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

    构造函数

    diff --git a/docs/api/zh/extras/curves/CubicBezierCurve3.html b/docs/api/zh/extras/curves/CubicBezierCurve3.html index 3ac670932b49fb..ba2a43848a783b 100644 --- a/docs/api/zh/extras/curves/CubicBezierCurve3.html +++ b/docs/api/zh/extras/curves/CubicBezierCurve3.html @@ -1,5 +1,5 @@ - + @@ -18,25 +18,25 @@

    三维三次贝塞尔曲线([name])

    由起点、终点和两个控制点所定义。

    -

    示例

    +

    代码示例

    - -var curve = new THREE.CubicBezierCurve3( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( -5, 15, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) -); + + var curve = new THREE.CubicBezierCurve3( + new THREE.Vector3( -10, 0, 0 ), + new THREE.Vector3( -5, 15, 0 ), + new THREE.Vector3( 20, 15, 0 ), + new THREE.Vector3( 10, 0, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); - +

    构造函数

    diff --git a/docs/api/zh/extras/curves/EllipseCurve.html b/docs/api/zh/extras/curves/EllipseCurve.html index 99f57f7524c7cb..158972496cf985 100644 --- a/docs/api/zh/extras/curves/EllipseCurve.html +++ b/docs/api/zh/extras/curves/EllipseCurve.html @@ -1,5 +1,5 @@ - + @@ -17,25 +17,25 @@

    椭圆曲线([name])

    将[page:Number xRadius]与[page:Number yRadius]设为相等的值它将会成为一个圆。

    -

    示例

    +

    代码示例

    - -var curve = new THREE.EllipseCurve( - 0, 0, // ax, aY - 10, 10, // xRadius, yRadius - 0, 2 * Math.PI, // aStartAngle, aEndAngle - false, // aClockwise - 0 // aRotation -); + + var curve = new THREE.EllipseCurve( + 0, 0, // ax, aY + 10, 10, // xRadius, yRadius + 0, 2 * Math.PI, // aStartAngle, aEndAngle + false, // aClockwise + 0 // aRotation + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var ellipse = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var ellipse = new THREE.Line( geometry, material ); +

    构造函数

    diff --git a/docs/api/zh/extras/curves/LineCurve.html b/docs/api/zh/extras/curves/LineCurve.html index 8624aa9e5795ab..dc96d70b9dd7cb 100644 --- a/docs/api/zh/extras/curves/LineCurve.html +++ b/docs/api/zh/extras/curves/LineCurve.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/extras/curves/LineCurve3.html b/docs/api/zh/extras/curves/LineCurve3.html index 7143306bee5f9b..df957a7c638a18 100644 --- a/docs/api/zh/extras/curves/LineCurve3.html +++ b/docs/api/zh/extras/curves/LineCurve3.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/extras/curves/QuadraticBezierCurve.html b/docs/api/zh/extras/curves/QuadraticBezierCurve.html index 6354334911b56c..deb0a931fe9bbe 100644 --- a/docs/api/zh/extras/curves/QuadraticBezierCurve.html +++ b/docs/api/zh/extras/curves/QuadraticBezierCurve.html @@ -1,5 +1,5 @@ - + @@ -18,23 +18,23 @@

    二维二次贝塞尔曲线([name])

    由起点、终点和一个控制点所定义。

    -

    示例

    +

    代码示例

    - -var curve = new THREE.QuadraticBezierCurve( - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( 20, 15 ), - new THREE.Vector2( 10, 0 ) -); + + var curve = new THREE.QuadraticBezierCurve( + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( 20, 15 ), + new THREE.Vector2( 10, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -//Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + //Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

    构造函数

    diff --git a/docs/api/zh/extras/curves/QuadraticBezierCurve3.html b/docs/api/zh/extras/curves/QuadraticBezierCurve3.html index 79eba9371149a6..4d46602d62b583 100644 --- a/docs/api/zh/extras/curves/QuadraticBezierCurve3.html +++ b/docs/api/zh/extras/curves/QuadraticBezierCurve3.html @@ -1,5 +1,5 @@ - + @@ -18,23 +18,23 @@

    三维二次贝塞尔曲线([name])

    由起点、终点和一个控制点所定义。

    -

    示例

    +

    代码示例

    - -var curve = new THREE.QuadraticBezierCurve3( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) -); + + var curve = new THREE.QuadraticBezierCurve3( + new THREE.Vector3( -10, 0, 0 ), + new THREE.Vector3( 20, 15, 0 ), + new THREE.Vector3( 10, 0, 0 ) + ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var curveObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var curveObject = new THREE.Line( geometry, material ); +

    构造函数

    diff --git a/docs/api/zh/extras/curves/SplineCurve.html b/docs/api/zh/extras/curves/SplineCurve.html index 48f0fa6a3a9fb5..df9b3aecd0bb4e 100644 --- a/docs/api/zh/extras/curves/SplineCurve.html +++ b/docs/api/zh/extras/curves/SplineCurve.html @@ -1,5 +1,5 @@ - + @@ -16,26 +16,26 @@

    样条曲线([name])

    从一系列的点中,创建一个平滑的二维样条曲线。内部使用[page:Interpolations.CatmullRom]来创建曲线。

    -

    示例

    +

    代码示例

    - -// Create a sine-like wave -var curve = new THREE.SplineCurve( [ - new THREE.Vector2( -10, 0 ), - new THREE.Vector2( -5, 5 ), - new THREE.Vector2( 0, 0 ), - new THREE.Vector2( 5, -5 ), - new THREE.Vector2( 10, 0 ) -] ); + + // Create a sine-like wave + var curve = new THREE.SplineCurve( [ + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( -5, 5 ), + new THREE.Vector2( 0, 0 ), + new THREE.Vector2( 5, -5 ), + new THREE.Vector2( 10, 0 ) + ] ); -var points = curve.getPoints( 50 ); -var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var points = curve.getPoints( 50 ); + var geometry = new THREE.BufferGeometry().setFromPoints( points ); -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final object to add to the scene -var splineObject = new THREE.Line( geometry, material ); - + // Create the final object to add to the scene + var splineObject = new THREE.Line( geometry, material ); +

    构造函数

    diff --git a/docs/api/zh/extras/objects/ImmediateRenderObject.html b/docs/api/zh/extras/objects/ImmediateRenderObject.html index 4e67346cb8d851..5cfd8558a064b3 100644 --- a/docs/api/zh/extras/objects/ImmediateRenderObject.html +++ b/docs/api/zh/extras/objects/ImmediateRenderObject.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/geometries/BoxBufferGeometry.html b/docs/api/zh/geometries/BoxBufferGeometry.html index 5cdf7030041f04..7cc173b3d264ab 100644 --- a/docs/api/zh/geometries/BoxBufferGeometry.html +++ b/docs/api/zh/geometries/BoxBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -33,7 +33,7 @@

    立方缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); @@ -75,6 +75,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/BoxGeometry.js src/geometries/BoxGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/BoxGeometry.js src/geometries/BoxGeometry.js] +

    diff --git a/docs/api/zh/geometries/BoxGeometry.html b/docs/api/zh/geometries/BoxGeometry.html index ba83e87e04dd91..c771e3562ad997 100644 --- a/docs/api/zh/geometries/BoxGeometry.html +++ b/docs/api/zh/geometries/BoxGeometry.html @@ -1,5 +1,5 @@ - + @@ -33,7 +33,7 @@

    立方几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); diff --git a/docs/api/zh/geometries/CircleBufferGeometry.html b/docs/api/zh/geometries/CircleBufferGeometry.html index 7f33a4e5aa90d8..1c1365f04e2a9e 100644 --- a/docs/api/zh/geometries/CircleBufferGeometry.html +++ b/docs/api/zh/geometries/CircleBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆形缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.CircleBufferGeometry( 5, 32 ); @@ -64,6 +64,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CircleGeometry.js src/geometries/CircleGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CircleGeometry.js src/geometries/CircleGeometry.js] +

    diff --git a/docs/api/zh/geometries/CircleGeometry.html b/docs/api/zh/geometries/CircleGeometry.html index c3ce43f7fb7474..745437fcfc3231 100644 --- a/docs/api/zh/geometries/CircleGeometry.html +++ b/docs/api/zh/geometries/CircleGeometry.html @@ -1,5 +1,5 @@ - + @@ -34,7 +34,7 @@

    圆形几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.CircleGeometry( 5, 32 ); diff --git a/docs/api/zh/geometries/ConeBufferGeometry.html b/docs/api/zh/geometries/ConeBufferGeometry.html index eda8d8f7c93e57..ceacd39473b1e3 100644 --- a/docs/api/zh/geometries/ConeBufferGeometry.html +++ b/docs/api/zh/geometries/ConeBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆锥缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.ConeBufferGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -66,6 +66,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ConeGeometry.js src/geometries/ConeGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ConeGeometry.js src/geometries/ConeGeometry.js] +

    diff --git a/docs/api/zh/geometries/ConeGeometry.html b/docs/api/zh/geometries/ConeGeometry.html index 240c740d9a1d85..6f5a9a681b9a58 100644 --- a/docs/api/zh/geometries/ConeGeometry.html +++ b/docs/api/zh/geometries/ConeGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆锥几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.ConeGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/zh/geometries/CylinderBufferGeometry.html b/docs/api/zh/geometries/CylinderBufferGeometry.html index ad9ee853c6792a..54ebb1e1591ff4 100644 --- a/docs/api/zh/geometries/CylinderBufferGeometry.html +++ b/docs/api/zh/geometries/CylinderBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆柱缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.CylinderBufferGeometry( 5, 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -67,6 +67,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CylinderGeometry.js src/geometries/CylinderGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/CylinderGeometry.js src/geometries/CylinderGeometry.js] +

    diff --git a/docs/api/zh/geometries/CylinderGeometry.html b/docs/api/zh/geometries/CylinderGeometry.html index 8f48c7aa5ec132..252da006bab25e 100644 --- a/docs/api/zh/geometries/CylinderGeometry.html +++ b/docs/api/zh/geometries/CylinderGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆柱几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.CylinderGeometry( 5, 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/zh/geometries/DodecahedronBufferGeometry.html b/docs/api/zh/geometries/DodecahedronBufferGeometry.html index 5ca37d94d58f5c..680314b2a1f799 100644 --- a/docs/api/zh/geometries/DodecahedronBufferGeometry.html +++ b/docs/api/zh/geometries/DodecahedronBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -53,6 +53,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/DodecahedronGeometry.js src/geometries/DodecahedronGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/DodecahedronGeometry.js src/geometries/DodecahedronGeometry.js] +

    diff --git a/docs/api/zh/geometries/DodecahedronGeometry.html b/docs/api/zh/geometries/DodecahedronGeometry.html index 47c1aa9851fc6f..37526f2b756b14 100644 --- a/docs/api/zh/geometries/DodecahedronGeometry.html +++ b/docs/api/zh/geometries/DodecahedronGeometry.html @@ -1,5 +1,5 @@ - + @@ -22,13 +22,13 @@

    十二面几何体([name])

    // iOS iframe auto-resize workaround - if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent)) { + if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) { - var scene = document.getElementById('scene'); + var scene = document.getElementById( 'scene' ); - scene.style.width = getComputedStyle(scene).width; - scene.style.height = getComputedStyle(scene).height; - scene.setAttribute('scrolling', 'no'); + scene.style.width = getComputedStyle( scene ).width; + scene.style.height = getComputedStyle( scene ).height; + scene.setAttribute( 'scrolling', 'no' ); } diff --git a/docs/api/zh/geometries/EdgesGeometry.html b/docs/api/zh/geometries/EdgesGeometry.html index fff1ad1fa601b4..4772064f9448dc 100644 --- a/docs/api/zh/geometries/EdgesGeometry.html +++ b/docs/api/zh/geometries/EdgesGeometry.html @@ -1,5 +1,5 @@ - + @@ -14,17 +14,19 @@

    边缘几何体([name])

    这可以作为一个辅助对象来查看[page:Geometry Geometry]的边缘。

    -

    示例

    - - [example:webgl_helpers helpers] - +

    代码示例

    -var geometry = new THREE.BoxBufferGeometry( 100, 100, 100 ); -var edges = new THREE.EdgesGeometry( geometry ); -var line = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0xffffff } ) ); -scene.add( line ); + var geometry = new THREE.BoxBufferGeometry( 100, 100, 100 ); + var edges = new THREE.EdgesGeometry( geometry ); + var line = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0xffffff } ) ); + scene.add( line ); +

    例子

    +

    + [example:webgl_helpers helpers] +

    +

    构造器

    [name]( [param:Geometry geometry], [param:Integer thresholdAngle] )

    diff --git a/docs/api/zh/geometries/ExtrudeBufferGeometry.html b/docs/api/zh/geometries/ExtrudeBufferGeometry.html index cee937f412f1e5..5805a4454d0621 100644 --- a/docs/api/zh/geometries/ExtrudeBufferGeometry.html +++ b/docs/api/zh/geometries/ExtrudeBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    挤压缓冲几何体([name])

    -

    示例

    +

    代码示例

    @@ -106,6 +106,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ExtrudeGeometry.js src/geometries/ExtrudeGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ExtrudeGeometry.js src/geometries/ExtrudeGeometry.js] +

    diff --git a/docs/api/zh/geometries/ExtrudeGeometry.html b/docs/api/zh/geometries/ExtrudeGeometry.html index 5a32e482137442..207214fe52c820 100644 --- a/docs/api/zh/geometries/ExtrudeGeometry.html +++ b/docs/api/zh/geometries/ExtrudeGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    挤压几何体([name])

    -

    示例

    +

    代码示例

    diff --git a/docs/api/zh/geometries/IcosahedronBufferGeometry.html b/docs/api/zh/geometries/IcosahedronBufferGeometry.html index 5e4610c621a0af..7e2cf76f9118a5 100644 --- a/docs/api/zh/geometries/IcosahedronBufferGeometry.html +++ b/docs/api/zh/geometries/IcosahedronBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -52,6 +52,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/IcosahedronGeometry.js src/geometries/IcosahedronGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/IcosahedronGeometry.js src/geometries/IcosahedronGeometry.js] +

    diff --git a/docs/api/zh/geometries/IcosahedronGeometry.html b/docs/api/zh/geometries/IcosahedronGeometry.html index 83858d5f632b9b..db13ec80ad26ca 100644 --- a/docs/api/zh/geometries/IcosahedronGeometry.html +++ b/docs/api/zh/geometries/IcosahedronGeometry.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/geometries/LatheBufferGeometry.html b/docs/api/zh/geometries/LatheBufferGeometry.html index ff15a02ed6e337..2d431491ea293e 100644 --- a/docs/api/zh/geometries/LatheBufferGeometry.html +++ b/docs/api/zh/geometries/LatheBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    车削缓冲几何体([name])

    -

    示例

    +

    代码示例

    var points = []; @@ -71,6 +71,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/LatheGeometry.js src/geometries/LatheGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/LatheGeometry.js src/geometries/LatheGeometry.js] +

    diff --git a/docs/api/zh/geometries/LatheGeometry.html b/docs/api/zh/geometries/LatheGeometry.html index b74d43f100b733..ce527f0a2ec37d 100644 --- a/docs/api/zh/geometries/LatheGeometry.html +++ b/docs/api/zh/geometries/LatheGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    车削几何体([name])

    -

    示例

    +

    代码示例

    var points = []; diff --git a/docs/api/zh/geometries/OctahedronBufferGeometry.html b/docs/api/zh/geometries/OctahedronBufferGeometry.html index 7fb23279023ccf..09cb89ab3eab21 100644 --- a/docs/api/zh/geometries/OctahedronBufferGeometry.html +++ b/docs/api/zh/geometries/OctahedronBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -53,6 +53,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/OctahedronGeometry.js src/geometries/OctahedronGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/OctahedronGeometry.js src/geometries/OctahedronGeometry.js] +

    diff --git a/docs/api/zh/geometries/OctahedronGeometry.html b/docs/api/zh/geometries/OctahedronGeometry.html index fc48d164365a0a..062e09cafb9930 100644 --- a/docs/api/zh/geometries/OctahedronGeometry.html +++ b/docs/api/zh/geometries/OctahedronGeometry.html @@ -1,5 +1,5 @@ - + @@ -22,13 +22,13 @@

    八面几何体([name])

    // iOS iframe auto-resize workaround - if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent)) { + if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) { - var scene = document.getElementById('scene'); + var scene = document.getElementById( 'scene' ); - scene.style.width = getComputedStyle(scene).width; - scene.style.height = getComputedStyle(scene).height; - scene.setAttribute('scrolling', 'no'); + scene.style.width = getComputedStyle( scene ).width; + scene.style.height = getComputedStyle( scene ).height; + scene.setAttribute( 'scrolling', 'no' ); } diff --git a/docs/api/zh/geometries/ParametricBufferGeometry.html b/docs/api/zh/geometries/ParametricBufferGeometry.html index d9c16b7b17fab4..6c1d8bd8de46d4 100644 --- a/docs/api/zh/geometries/ParametricBufferGeometry.html +++ b/docs/api/zh/geometries/ParametricBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    参数化缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.ParametricBufferGeometry( THREE.ParametricGeometries.klein, 25, 25 ); @@ -65,6 +65,8 @@

    方法(Methods)

    方法

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ParametricGeometry.js src/geometries/ParametricGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ParametricGeometry.js src/geometries/ParametricGeometry.js] +

    diff --git a/docs/api/zh/geometries/ParametricGeometry.html b/docs/api/zh/geometries/ParametricGeometry.html index 62c1294e8ed6ab..6c76b446592c4b 100644 --- a/docs/api/zh/geometries/ParametricGeometry.html +++ b/docs/api/zh/geometries/ParametricGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    参数化几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.ParametricGeometry( THREE.ParametricGeometries.klein, 25, 25 ); diff --git a/docs/api/zh/geometries/PlaneBufferGeometry.html b/docs/api/zh/geometries/PlaneBufferGeometry.html index 47a41c8b2b3dcb..3e1476c3b8313f 100644 --- a/docs/api/zh/geometries/PlaneBufferGeometry.html +++ b/docs/api/zh/geometries/PlaneBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    平面缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.PlaneBufferGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} ); @@ -63,6 +63,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PlaneGeometry.js src/geometries/PlaneGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PlaneGeometry.js src/geometries/PlaneGeometry.js] +

    diff --git a/docs/api/zh/geometries/PlaneGeometry.html b/docs/api/zh/geometries/PlaneGeometry.html index 854be583616edb..00010eee3a831a 100644 --- a/docs/api/zh/geometries/PlaneGeometry.html +++ b/docs/api/zh/geometries/PlaneGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    平面几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.PlaneGeometry( 5, 20, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00, side: THREE.DoubleSide} ); diff --git a/docs/api/zh/geometries/PolyhedronBufferGeometry.html b/docs/api/zh/geometries/PolyhedronBufferGeometry.html index 5f5f0e434e7afb..60bfc71ede9746 100644 --- a/docs/api/zh/geometries/PolyhedronBufferGeometry.html +++ b/docs/api/zh/geometries/PolyhedronBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@

    多面缓冲几何体([name])

    所使用,以生成它们各自的几何结构。

    -

    示例

    +

    代码示例

    var verticesOfCube = [ -1,-1,-1, 1,-1,-1, 1, 1,-1, -1, 1,-1, @@ -62,7 +62,7 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/PolyhedronGeometry.js src/geometries/PolyhedronGeometry.js]

    diff --git a/docs/api/zh/geometries/PolyhedronGeometry.html b/docs/api/zh/geometries/PolyhedronGeometry.html index 12b84a7ff509ab..e5a44f3ba44dc9 100644 --- a/docs/api/zh/geometries/PolyhedronGeometry.html +++ b/docs/api/zh/geometries/PolyhedronGeometry.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

    多面几何体([name])

    多面体是在三维空间中具有一些平面的立体图形。这个类将一个顶点数组投射到一个球面上,之后将它们细分为所需的细节级别。

    -

    示例

    +

    代码示例

    var verticesOfCube = [ -1,-1,-1, 1,-1,-1, 1, 1,-1, -1, 1,-1, diff --git a/docs/api/zh/geometries/RingBufferGeometry.html b/docs/api/zh/geometries/RingBufferGeometry.html index a59e4b7ab737b8..90c023a423d228 100644 --- a/docs/api/zh/geometries/RingBufferGeometry.html +++ b/docs/api/zh/geometries/RingBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆环缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.RingBufferGeometry( 1, 5, 32 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00, side: THREE.DoubleSide } ); @@ -66,6 +66,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/RingGeometry.js src/geometries/RingGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/RingGeometry.js src/geometries/RingGeometry.js] +

    diff --git a/docs/api/zh/geometries/RingGeometry.html b/docs/api/zh/geometries/RingGeometry.html index 0c11f7430ce8d0..887d24d0bc3493 100644 --- a/docs/api/zh/geometries/RingGeometry.html +++ b/docs/api/zh/geometries/RingGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆环几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.RingGeometry( 1, 5, 32 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00, side: THREE.DoubleSide } ); diff --git a/docs/api/zh/geometries/ShapeBufferGeometry.html b/docs/api/zh/geometries/ShapeBufferGeometry.html index d541dd016a9030..a87380a5df4966 100644 --- a/docs/api/zh/geometries/ShapeBufferGeometry.html +++ b/docs/api/zh/geometries/ShapeBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -33,7 +33,7 @@

    形状缓冲几何体([name])

    -

    示例

    +

    代码示例

    @@ -77,6 +77,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ShapeGeometry.js src/geometries/ShapeGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/ShapeGeometry.js src/geometries/ShapeGeometry.js] +

    diff --git a/docs/api/zh/geometries/ShapeGeometry.html b/docs/api/zh/geometries/ShapeGeometry.html index 686990d2e89963..644ef801be0f70 100644 --- a/docs/api/zh/geometries/ShapeGeometry.html +++ b/docs/api/zh/geometries/ShapeGeometry.html @@ -1,5 +1,5 @@ - + @@ -33,7 +33,7 @@

    形状几何体([name])

    -

    示例

    +

    代码示例

    diff --git a/docs/api/zh/geometries/SphereBufferGeometry.html b/docs/api/zh/geometries/SphereBufferGeometry.html index 5cc0066d9e1c21..23d8da40fbd1ac 100644 --- a/docs/api/zh/geometries/SphereBufferGeometry.html +++ b/docs/api/zh/geometries/SphereBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    球缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); @@ -73,6 +73,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/SphereGeometry.js src/geometries/SphereGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/SphereGeometry.js src/geometries/SphereGeometry.js] +

    diff --git a/docs/api/zh/geometries/SphereGeometry.html b/docs/api/zh/geometries/SphereGeometry.html index 6403c94148aff2..0d53ebfbb84689 100644 --- a/docs/api/zh/geometries/SphereGeometry.html +++ b/docs/api/zh/geometries/SphereGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    球几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.SphereGeometry( 5, 32, 32 ); var material = new THREE.MeshBasicMaterial( {color: 0xffff00} ); diff --git a/docs/api/zh/geometries/TetrahedronBufferGeometry.html b/docs/api/zh/geometries/TetrahedronBufferGeometry.html index 010ecf369ecc9f..556767cae77405 100644 --- a/docs/api/zh/geometries/TetrahedronBufferGeometry.html +++ b/docs/api/zh/geometries/TetrahedronBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -53,6 +53,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TetrahedronGeometry.js src/geometries/TetrahedronGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TetrahedronGeometry.js src/geometries/TetrahedronGeometry.js] +

    diff --git a/docs/api/zh/geometries/TetrahedronGeometry.html b/docs/api/zh/geometries/TetrahedronGeometry.html index 8537875fe4a6be..2089d01930377f 100644 --- a/docs/api/zh/geometries/TetrahedronGeometry.html +++ b/docs/api/zh/geometries/TetrahedronGeometry.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/geometries/TextBufferGeometry.html b/docs/api/zh/geometries/TextBufferGeometry.html index ac7b8bc7d30f9e..d7c793495fb852 100644 --- a/docs/api/zh/geometries/TextBufferGeometry.html +++ b/docs/api/zh/geometries/TextBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -36,11 +36,7 @@

    文本缓冲几何体([name])

    -

    示例

    - -

    - [example:webgl_geometry_text geometry / text ] -

    +

    代码示例

    var loader = new THREE.FontLoader(); @@ -60,6 +56,12 @@

    示例

    } );
    +

    例子

    + +

    + [example:webgl_geometry_text geometry / text ] +

    +

    构造器

    [name]([param:String text], [param:Object parameters])

    @@ -167,7 +169,7 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TextGeometry.js src/geometries/TextGeometry.js]

    diff --git a/docs/api/zh/geometries/TextGeometry.html b/docs/api/zh/geometries/TextGeometry.html index 86492efdeda978..b5156e82b6842c 100644 --- a/docs/api/zh/geometries/TextGeometry.html +++ b/docs/api/zh/geometries/TextGeometry.html @@ -1,5 +1,5 @@ - + @@ -36,11 +36,7 @@

    文本几何体([name])

    -

    示例

    - -

    - [example:webgl_geometry_text geometry / text ] -

    +

    代码示例

    var loader = new THREE.FontLoader(); @@ -60,6 +56,12 @@

    示例

    } );
    +

    例子

    + +

    + [example:webgl_geometry_text geometry / text ] +

    +

    构造器

    [name]([param:String text], [param:Object parameters])

    diff --git a/docs/api/zh/geometries/TorusBufferGeometry.html b/docs/api/zh/geometries/TorusBufferGeometry.html index 38367939c07b30..f83519655a7959 100644 --- a/docs/api/zh/geometries/TorusBufferGeometry.html +++ b/docs/api/zh/geometries/TorusBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆环缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.TorusBufferGeometry( 10, 3, 16, 100 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); @@ -64,6 +64,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusGeometry.js src/geometries/TorusGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusGeometry.js src/geometries/TorusGeometry.js] +

    diff --git a/docs/api/zh/geometries/TorusGeometry.html b/docs/api/zh/geometries/TorusGeometry.html index 9c0cbf1e47469c..e7ecc0e2c212d7 100644 --- a/docs/api/zh/geometries/TorusGeometry.html +++ b/docs/api/zh/geometries/TorusGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    圆环几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.TorusGeometry( 10, 3, 16, 100 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); diff --git a/docs/api/zh/geometries/TorusKnotBufferGeometry.html b/docs/api/zh/geometries/TorusKnotBufferGeometry.html index 62fba193247635..23b8e700d8292e 100644 --- a/docs/api/zh/geometries/TorusKnotBufferGeometry.html +++ b/docs/api/zh/geometries/TorusKnotBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ [page:BufferGeometry] → -

    圆环缓冲几何体([name])

    +

    圆环缓冲扭结几何体([name])

    This is the [page:BufferGeometry] port of [page:TorusKnotGeometry].

    @@ -32,7 +32,7 @@

    圆环缓冲几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.TorusKnotBufferGeometry( 10, 3, 100, 16 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); @@ -67,6 +67,8 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusKnotGeometry.js src/geometries/TorusKnotGeometry.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TorusKnotGeometry.js src/geometries/TorusKnotGeometry.js] +

    diff --git a/docs/api/zh/geometries/TorusKnotGeometry.html b/docs/api/zh/geometries/TorusKnotGeometry.html index f3ba5d9d5f7fbf..5e660748d7afed 100644 --- a/docs/api/zh/geometries/TorusKnotGeometry.html +++ b/docs/api/zh/geometries/TorusKnotGeometry.html @@ -1,5 +1,5 @@ - + @@ -33,7 +33,7 @@

    圆环扭结几何体([name])

    -

    示例

    +

    代码示例

    var geometry = new THREE.TorusKnotGeometry( 10, 3, 100, 16 ); var material = new THREE.MeshBasicMaterial( { color: 0xffff00 } ); diff --git a/docs/api/zh/geometries/TubeBufferGeometry.html b/docs/api/zh/geometries/TubeBufferGeometry.html index 39041b03e01c16..974bba2bdbef5f 100644 --- a/docs/api/zh/geometries/TubeBufferGeometry.html +++ b/docs/api/zh/geometries/TubeBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    管道缓冲几何体([name])

    -

    示例

    +

    代码示例

    function CustomSinCurve( scale ) { @@ -105,7 +105,7 @@

    方法(Methods)

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/src/geometries/TubeGeometry.js src/geometries/TubeGeometry.js]

    diff --git a/docs/api/zh/geometries/TubeGeometry.html b/docs/api/zh/geometries/TubeGeometry.html index 79c83f9fd32378..9366919a0febeb 100644 --- a/docs/api/zh/geometries/TubeGeometry.html +++ b/docs/api/zh/geometries/TubeGeometry.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    管道几何体([name])

    -

    示例

    +

    代码示例

    function CustomSinCurve( scale ) { diff --git a/docs/api/zh/geometries/WireframeGeometry.html b/docs/api/zh/geometries/WireframeGeometry.html index 5a128007396dff..341b0c63252b29 100644 --- a/docs/api/zh/geometries/WireframeGeometry.html +++ b/docs/api/zh/geometries/WireframeGeometry.html @@ -1,5 +1,5 @@ - + @@ -14,41 +14,26 @@

    网格几何体([name])

    这个类可以被用作一个辅助物体,来对一个[page:Geometry Geometry]以线框的形式进行查看。

    - - -

    示例

    - - [example:webgl_helpers helpers] +

    代码示例

    -var geometry = new THREE.SphereBufferGeometry( 100, 100, 100 ); + var geometry = new THREE.SphereBufferGeometry( 100, 100, 100 ); -var wireframe = new THREE.WireframeGeometry( geometry ); + var wireframe = new THREE.WireframeGeometry( geometry ); -var line = new THREE.LineSegments( wireframe ); -line.material.depthTest = false; -line.material.opacity = 0.25; -line.material.transparent = true; + var line = new THREE.LineSegments( wireframe ); + line.material.depthTest = false; + line.material.opacity = 0.25; + line.material.transparent = true; -scene.add( line ); + scene.add( line ); +

    例子

    +

    + [example:webgl_helpers helpers] +

    +

    构造器

    [name]( [param:Geometry geometry] )

    diff --git a/docs/api/zh/helpers/ArrowHelper.html b/docs/api/zh/helpers/ArrowHelper.html index 1927bb6910e6ed..da6982d7e9cdfc 100644 --- a/docs/api/zh/helpers/ArrowHelper.html +++ b/docs/api/zh/helpers/ArrowHelper.html @@ -14,12 +14,7 @@

    [name]

    用于模拟方向的3维箭头对象.

    - -

    例子

    - -
    [example:webgl_geometries WebGL / geometries]
    -
    [example:webgl_geometry_normals WebGL / geometry / normals]
    -
    [example:webgl_shadowmesh WebGL / shadowmesh]
    +

    代码示例

    var dir = new THREE.Vector3( 1, 2, 0 ); @@ -35,7 +30,13 @@

    例子

    scene.add( arrowHelper );
    +

    例子

    +

    + [example:webgl_geometries WebGL / geometries]
    + [example:webgl_geometry_normals WebGL / geometry / normals]
    + [example:webgl_shadowmesh WebGL / shadowmesh] +

    构造函数

    @@ -60,13 +61,9 @@

    [property:Line line]

    [property:Mesh cone]

    包含箭头辅助对象的锥体部分.

    - - -

    方法

    请到基类 [page:Object3D] 页面查看公共方法.

    -

    [method:null setColor]([param:Color color])

    color -- 所需的颜色。

    diff --git a/docs/api/zh/helpers/AxesHelper.html b/docs/api/zh/helpers/AxesHelper.html index 68e80978a9c5bd..06cceda7e8685f 100644 --- a/docs/api/zh/helpers/AxesHelper.html +++ b/docs/api/zh/helpers/AxesHelper.html @@ -15,21 +15,21 @@

    [name]

    用于简单模拟3个坐标轴的对象.
    红色代表 X 轴. 绿色代表 Y 轴. 蓝色代表 Z 轴.

    - -

    例子

    - -
    [example:webgl_geometries WebGL / geometries]
    -
    [example:webgl_geometries2 WebGL / geometries2]
    -
    [example:webgl_geometry_convex WebGL / geometry / convex]
    -
    [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor]
    - - +

    代码示例

    -var axesHelper = new THREE.AxesHelper( 5 ); -scene.add( axesHelper ); + var axesHelper = new THREE.AxesHelper( 5 ); + scene.add( axesHelper ); +

    例子

    + +

    + [example:webgl_geometries WebGL / geometries]
    + [example:webgl_geometry_convex WebGL / geometry / convex]
    + [example:webgl_geometry_spline_editor WebGL / geometry / spline / editor] +

    +

    构造函数

    diff --git a/docs/api/zh/helpers/Box3Helper.html b/docs/api/zh/helpers/Box3Helper.html index 752b0bc8ad5217..59f03048aff33d 100644 --- a/docs/api/zh/helpers/Box3Helper.html +++ b/docs/api/zh/helpers/Box3Helper.html @@ -16,8 +16,7 @@

    [name]

    模拟3维包围盒 [page:Box3] 的辅助对象.

    - -

    例子

    +

    代码示例

    var box = new THREE.Box3(); @@ -27,7 +26,6 @@

    例子

    scene.add( helper );
    -

    构造函数

    diff --git a/docs/api/zh/helpers/BoxHelper.html b/docs/api/zh/helpers/BoxHelper.html index 9b32a4aeaf27df..0ef92dd74c5209 100644 --- a/docs/api/zh/helpers/BoxHelper.html +++ b/docs/api/zh/helpers/BoxHelper.html @@ -20,21 +20,22 @@

    [name]

    所以当目标对象是精灵 [page:Sprite Sprites] 时将不能正常运行.

    - -

    例子

    - -
    [example:webgl_helpers WebGL / helpers]
    -
    [example:webgl_loader_nrrd WebGL / loader / nrrd]
    -
    [example:webgl_buffergeometry_drawcalls advanced / buffergeometry / drawcalls]
    - +

    代码示例

    - var sphere = new THREE.SphereGeometry(); - var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); - var box = new THREE.BoxHelper( object, 0xffff00 ); - scene.add( box ); + var sphere = new THREE.SphereBufferGeometry(); + var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); + var box = new THREE.BoxHelper( object, 0xffff00 ); + scene.add( box ); +

    例子

    + +

    + [example:webgl_helpers WebGL / helpers]
    + [example:webgl_loader_nrrd WebGL / loader / nrrd]
    + [example:webgl_buffergeometry_drawrange WebGL / buffergeometry / drawrange] +

    构造函数

    diff --git a/docs/api/zh/helpers/CameraHelper.html b/docs/api/zh/helpers/CameraHelper.html index e6213ea5cbbd4b..1fa0fb7a56e5a1 100644 --- a/docs/api/zh/helpers/CameraHelper.html +++ b/docs/api/zh/helpers/CameraHelper.html @@ -17,17 +17,19 @@

    [name]

    它使用 [page:LineSegments] 来模拟相机视锥体.

    -

    例子

    - -
    [example:webgl_camera WebGL / camera]
    -
    [example:webgl_geometry_extrude_splines WebGL / extrude / splines]
    +

    代码示例

    -var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); -var helper = new THREE.CameraHelper( camera ); -scene.add( helper ); + var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); + var helper = new THREE.CameraHelper( camera ); + scene.add( helper ); +

    例子

    +

    + [example:webgl_camera WebGL / camera]
    + [example:webgl_geometry_extrude_splines WebGL / extrude / splines] +

    构造函数

    diff --git a/docs/api/zh/helpers/DirectionalLightHelper.html b/docs/api/zh/helpers/DirectionalLightHelper.html index 1185dc661242ff..da2bd21a193ab1 100644 --- a/docs/api/zh/helpers/DirectionalLightHelper.html +++ b/docs/api/zh/helpers/DirectionalLightHelper.html @@ -18,17 +18,14 @@

    [name]

    其中包含了表示光位置的平面和表示光方向的线段.

    -

    例子

    +

    代码示例

    var light = new THREE.DirectionalLight( 0xFFFFFF ); - var helper = new THREE.DirectionalLightHelper( light, 5 ); - scene.add( helper ); -

    构造函数

    diff --git a/docs/api/zh/helpers/GridHelper.html b/docs/api/zh/helpers/GridHelper.html index 3b87656aca0b85..3f0fb94930ea72 100644 --- a/docs/api/zh/helpers/GridHelper.html +++ b/docs/api/zh/helpers/GridHelper.html @@ -14,17 +14,21 @@

    [name]

    坐标格辅助对象. 坐标格实际上是2维线数组.

    +

    代码示例

    -

    例子

    - - var size = 10; + + var size = 10; var divisions = 10; var gridHelper = new THREE.GridHelper( size, divisions ); scene.add( gridHelper ); - [example:webgl_helpers Example using various helpers] +

    例子

    + +

    + [example:webgl_helpers WebGL / helpers] +

    构造函数

    diff --git a/docs/api/zh/helpers/HemisphereLightHelper.html b/docs/api/zh/helpers/HemisphereLightHelper.html index d5e0798c502bc3..78ebb48f7eb6eb 100644 --- a/docs/api/zh/helpers/HemisphereLightHelper.html +++ b/docs/api/zh/helpers/HemisphereLightHelper.html @@ -17,14 +17,12 @@

    [name]

    半球形光源 [page:HemisphereLight HemisphereLight].

    -

    例子

    +

    代码示例

    -var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); - -var helper = new THREE.HemisphereLightHelper( light, 5 ); - -scene.add( helper ); + var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + var helper = new THREE.HemisphereLightHelper( light, 5 ); + scene.add( helper ); diff --git a/docs/api/zh/helpers/PlaneHelper.html b/docs/api/zh/helpers/PlaneHelper.html index 7436eb17c5a8e7..ab67045c4f49af 100644 --- a/docs/api/zh/helpers/PlaneHelper.html +++ b/docs/api/zh/helpers/PlaneHelper.html @@ -16,8 +16,7 @@

    [name]

    用于模拟平面 [page:Plane] 的辅助对象.

    - -

    例子

    +

    代码示例

    var plane = new THREE.Plane( new THREE.Vector3( 1, 1, 0.2 ), 3 ); diff --git a/docs/api/zh/helpers/PointLightHelper.html b/docs/api/zh/helpers/PointLightHelper.html index 6999999a9231fa..b5356611357b95 100644 --- a/docs/api/zh/helpers/PointLightHelper.html +++ b/docs/api/zh/helpers/PointLightHelper.html @@ -17,10 +17,7 @@

    [name]

    点光源 [page:PointLight].

    - -

    例子

    - - [example:webgl_helpers WebGL / helpers] +

    代码示例

    var pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); @@ -32,8 +29,11 @@

    例子

    scene.add( pointLightHelper );
    +

    例子

    - +

    + [example:webgl_helpers WebGL / helpers] +

    构造函数

    diff --git a/docs/api/zh/helpers/PolarGridHelper.html b/docs/api/zh/helpers/PolarGridHelper.html index 605c366932f4dd..c7e8fbc5ae4627 100644 --- a/docs/api/zh/helpers/PolarGridHelper.html +++ b/docs/api/zh/helpers/PolarGridHelper.html @@ -14,10 +14,10 @@

    [name]

    极坐标格辅助对象. 坐标格实际上是2维线数组.

    +

    代码示例

    -

    例子

    - - var radius = 10; + + var radius = 10; var radials = 16; var circles = 8; var divisions = 64; @@ -25,8 +25,12 @@

    例子

    var helper = new THREE.PolarGridHelper( radius, radials, circles, divisions ); scene.add( helper );
    - [example:webgl_helpers Example using various helpers] +

    例子

    + +

    + [example:webgl_helpers WebGL / helpers] +

    构造函数

    diff --git a/docs/api/zh/helpers/SkeletonHelper.html b/docs/api/zh/helpers/SkeletonHelper.html index 68356e227017dd..d71e0a1c98ba52 100644 --- a/docs/api/zh/helpers/SkeletonHelper.html +++ b/docs/api/zh/helpers/SkeletonHelper.html @@ -17,21 +17,20 @@

    [name]

    该辅助对象使用 [page:LineBasicMaterial LineBasicMaterial] 材质.

    - -

    例子

    - -

    - [example:webgl_animation_skinning_blending animation / skinning / blending]
    - [example:webgl_animation_skinning_morph animation / skinning / morph]
    - [example:webgl_loader_bvh loader / bvh ] -

    +

    代码示例

    -var helper = new THREE.SkeletonHelper( skinnedMesh ); -scene.add( helper ); + var helper = new THREE.SkeletonHelper( skinnedMesh ); + scene.add( helper ); +

    例子

    +

    + [example:webgl_animation_skinning_blending WebGL / animation / skinning / blending]
    + [example:webgl_animation_skinning_morph WebGL / animation / skinning / morph]
    + [example:webgl_loader_bvh WebGL / loader / bvh ] +

    构造函数

    diff --git a/docs/api/zh/helpers/SpotLightHelper.html b/docs/api/zh/helpers/SpotLightHelper.html index 2f5e0cbd516a69..ebc07345c6b3cd 100644 --- a/docs/api/zh/helpers/SpotLightHelper.html +++ b/docs/api/zh/helpers/SpotLightHelper.html @@ -14,13 +14,6 @@

    [name]

    用于模拟聚光灯 [page:SpotLight] 的锥形辅助对象.

    -

    例子

    - - View in Examples
    -

    其他例子

    - -
    [example:webgl_lights_spotlights lights / spotlights ]
    -

    代码示例

    var spotLight = new THREE.SpotLight( 0xffffff ); @@ -31,6 +24,8 @@

    代码示例

    scene.add( spotLightHelper );
    +

    例子

    +

    [example:webgl_lights_spotlights WebGL / lights / spotlights ]

    构造函数

    diff --git a/docs/api/zh/lights/AmbientLight.html b/docs/api/zh/lights/AmbientLight.html index e60ba719c0b68e..da08e9c645112b 100644 --- a/docs/api/zh/lights/AmbientLight.html +++ b/docs/api/zh/lights/AmbientLight.html @@ -18,16 +18,19 @@

    [name]

    环境光不能用来投射阴影,因为它没有方向。

    +

    代码示例

    -

    示例

    + + var light = new THREE.AmbientLight( 0x404040 ); // soft white light + scene.add( light ); + + +

    例子

    - [example:webgl_animation_cloth animation / cloth ]
    - [example:webgl_animation_skinning_blending animation / skinning / blending ] + [example:webgl_animation_cloth animation / cloth ]
    + [example:webgl_animation_skinning_blending animation / skinning / blending ]

    -var light = new THREE.AmbientLight( 0x404040 ); // soft white light -scene.add( light ); -

    构造函数

    [name]( [param:Integer color], [param:Float intensity] )

    diff --git a/docs/api/zh/lights/DirectionalLight.html b/docs/api/zh/lights/DirectionalLight.html index e03e2e269b1f5e..193365c56814bf 100644 --- a/docs/api/zh/lights/DirectionalLight.html +++ b/docs/api/zh/lights/DirectionalLight.html @@ -33,8 +33,15 @@

    关于位置、目标和旋转说明

    有关更新目标的详细信息,请参阅 [page:.target target] 下面的目标属性。

    +

    代码示例

    -

    示例

    + + // White directional light at half intensity shining from the top. + var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + scene.add( directionalLight ); + + +

    例子

    [example:misc_controls_fly controls / fly ]
    [example:webgl_effects_parallaxbarrier effects / parallaxbarrier ]
    @@ -44,13 +51,6 @@

    示例

    [example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection ]

    - - // White directional light at half intensity shining from the top. - var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); - scene.add( directionalLight ); - - -

    构造器

    [name]( [param:Integer color], [param:Float intensity] )

    @@ -63,7 +63,7 @@

    [name]( [param:Integer color], [param:Float intensity] )

    属性

    - 公共属性请查看基类 [page:Light Light]。 +

    公共属性请查看基类 [page:Light Light]。

    [property:Boolean castShadow]

    @@ -110,7 +110,7 @@

    [property:Object3D target]

    方法

    - 公共方法请查看基类 [page:Light Light]。 +

    公共方法请查看基类 [page:Light Light]。

    [method:DirectionalLight copy]( [param:DirectionalLight source] )

    diff --git a/docs/api/zh/lights/HemisphereLight.html b/docs/api/zh/lights/HemisphereLight.html index 57ea346f3de4f7..e45f3e05130a3f 100644 --- a/docs/api/zh/lights/HemisphereLight.html +++ b/docs/api/zh/lights/HemisphereLight.html @@ -1,5 +1,5 @@ - + @@ -19,21 +19,23 @@

    半球光([name])

    半球光不能投射阴影。

    -

    示例

    +

    代码示例

    -
    + + var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + scene.add( light ); + + +

    例子

    + +

    [example:webgl_lights_hemisphere lights / hemisphere ]
    - [example:misc_controls_pointerlock controls / pointerlock ]
    - [example:webgl_decals decals ]
    - [example:webgl_loader_collada_kinematics loader / collada / kinematics ]
    - [example:webgl_materials_lightmap materials / lightmap ]
    - [example:webgl_shaders_ocean shaders / ocean ] -

    - - -var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); -scene.add( light ); - + [example:misc_controls_pointerlock controls / pointerlock ]
    + [example:webgl_decals decals ]
    + [example:webgl_loader_collada_kinematics loader / collada / kinematics ]
    + [example:webgl_materials_lightmap materials / lightmap ]
    + [example:webgl_shaders_ocean shaders / ocean ] +

    构造器(Constructor)

    [name]( [param:Integer skyColor], [param:Integer groundColor], [param:Float intensity] )

    @@ -77,7 +79,7 @@

    [property:Vector3 position]

    方法(Methods)

    - 公共方法请查看基类 [page:Light Light]。 +

    公共方法请查看基类 [page:Light Light]。

    [method:HemisphereLight copy]( [param:HemisphereLight source] )

    diff --git a/docs/api/zh/lights/Light.html b/docs/api/zh/lights/Light.html index ff1e4c310551b2..2a47f06bf9cf15 100644 --- a/docs/api/zh/lights/Light.html +++ b/docs/api/zh/lights/Light.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/lights/PointLight.html b/docs/api/zh/lights/PointLight.html index f3251a6cba652f..6aac8205c4da65 100644 --- a/docs/api/zh/lights/PointLight.html +++ b/docs/api/zh/lights/PointLight.html @@ -1,5 +1,5 @@ - + @@ -15,28 +15,27 @@

    点光源([name])

    从一个点向各个方向发射的光源。一个常见的例子是模拟一个灯泡发出的光。

    - 该光源可以投射阴影 - 跳转至 [page:LightShadow] 查看更多细节。 + 该光源可以投射阴影 - 跳转至 [page:PointLightShadow] 查看更多细节。

    +

    代码示例

    -

    示例

    + + var light = new THREE.PointLight( 0xff0000, 1, 100 ); + light.position.set( 50, 50, 50 ); + scene.add( light ); + + +

    例子

    [example:webgl_lights_pointlights lights / pointlights ]
    [example:webgl_lights_pointlights2 lights / pointlights2 ]
    - [example:webgldeferred_animation animation ]
    [example:webgl_effects_anaglyph effects / anaglyph ]
    [example:webgl_geometry_text geometry / text ]
    [example:webgl_lensflares lensflares ]

    - -var light = new THREE.PointLight( 0xff0000, 1, 100 ); -light.position.set( 50, 50, 50 ); -scene.add( light ); - - -

    构造器(Constructor)

    [name]( [param:Integer color], [param:Float intensity], [param:Number distance], [param:Float decay] )

    @@ -46,7 +45,7 @@

    [name]( [param:Integer color], [param:Float intensity], [param:Number distan [page:Number distance] - 这个距离表示从光源到光照强度为0的位置。 当设置为0时,光永远不会消失(距离无穷大)。缺省值 0.
    [page:Float decay] - 沿着光照距离的衰退量。缺省值 1。 - + 在 [page:WebGLRenderer.physicallyCorrectLights physically correct] 模式中,decay = 2。

    创建一个新的点光源(PointLight)。 @@ -75,7 +74,7 @@

    [property:Float power]

    光功率
    在 [page:WebGLRenderer.physicallyCorrectLights physically correct] 模式中, 表示以"流明(光通量单位)"为单位的光功率。 缺省值 - *4Math.PI*。

    - + 该值与 [page:.intensity intensity] 直接关联 power = intensity * 4π @@ -83,12 +82,12 @@

    [property:Float power]

    修改该值也会导致光强度的改变。

    -

    [property:LightShadow shadow]

    +

    [property:PointLightShadow shadow]

    - [page:LightShadow]用与计算此光照的阴影。

    - + [page:PointLightShadow]用与计算此光照的阴影。

    + 此对象的摄像机被设置为 [page:PerspectiveCamera.fov fov] 为90度,[page:PerspectiveCamera.aspect aspect]为1 - ,近裁剪面 [page:PerspectiveCamera.near near] 为0,远裁剪面[page:PerspectiveCamera.far far] + ,近裁剪面 [page:PerspectiveCamera.near near] 为0,远裁剪面[page:PerspectiveCamera.far far] 为500的透视摄像机 [page:PerspectiveCamera]。

    diff --git a/docs/api/zh/lights/RectAreaLight.html b/docs/api/zh/lights/RectAreaLight.html index fd59c127636127..cc449726c03c5c 100644 --- a/docs/api/zh/lights/RectAreaLight.html +++ b/docs/api/zh/lights/RectAreaLight.html @@ -1,5 +1,5 @@ - + @@ -19,33 +19,31 @@

    平面光光源([name])

    • 不支持阴影。
    • 只支持 [page:MeshStandardMaterial MeshStandardMaterial] 和 [page:MeshPhysicalMaterial MeshPhysicalMaterial] 两种材质。
    • -
    • 你必须在你的场景中加入 [link:https://threejs.org/examples/js/lights/RectAreaLightUniformsLib.js RectAreaLightUniformsLib] ,并调用*init()*。
    • +
    • 你必须在你的场景中加入 [link:https://threejs.org/examples/jsm/lights/RectAreaLightUniformsLib.js RectAreaLightUniformsLib] ,并调用*init()*。

    +

    代码示例

    + + var width = 10; + var height = 10; + var intensity = 1; + var rectLight = new THREE.RectAreaLight( 0xffffff, intensity, width, height ); + rectLight.position.set( 5, 5, 0 ); + rectLight.lookAt( 0, 0, 0 ); + scene.add( rectLight ) -

    示例

    + rectLightHelper = new THREE.RectAreaLightHelper( rectLight ); + scene.add( rectLightHelper ); +
    + +

    例子

    [example:webgl_lights_rectarealight WebGL / rectarealight ] - - -var width = 10; -var height = 10; -var intensity = 1; -var rectLight = new THREE.RectAreaLight( 0xffffff, intensity, width, height ); -rectLight.position.set( 5, 5, 0 ); -rectLight.lookAt( 0, 0, 0 ); -scene.add( rectLight ) - -rectLightHelper = new THREE.RectAreaLightHelper( rectLight ); -scene.add( rectLightHelper ); - -

    -

    构造器(Constructor)

    diff --git a/docs/api/zh/lights/SpotLight.html b/docs/api/zh/lights/SpotLight.html index 07a44d5f5c7bad..25a1203455de55 100644 --- a/docs/api/zh/lights/SpotLight.html +++ b/docs/api/zh/lights/SpotLight.html @@ -1,5 +1,5 @@ - + @@ -18,32 +18,6 @@

    聚光灯([name])

    该光源可以投射阴影 - 跳转至 [page:SpotLightShadow] 查看更多细节。

    - - - -

    示例

    - - -

    - [example:webgl_lights_spotlight View in Examples ] -

    - -

    其他例子

    - -

    - [example:webgl_interactive_cubes_gpu interactive / cubes / gpu ]
    - [example:webgl_interactive_draggablecubes interactive / draggablecubes ]
    - [example:webgl_materials_bumpmap_skin materials / bumpmap / skin ]
    - [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]
    - [example:webgl_loader_md2 loader / md2 ]
    - [example:webgl_shading_physical shading / physical ]
    - [example:webgl_materials_bumpmap materials / bumpmap]
    - [example:webgl_shading_physical shading / physical]
    - [example:webgl_shadowmap shadowmap]
    - [example:webgl_shadowmap_performance shadowmap / performance]
    - [example:webgl_shadowmap_viewer shadowmap / viewer] -

    -

    代码示例

    // white spotlight shining from the side, casting a shadow @@ -63,6 +37,13 @@

    代码示例

    scene.add( spotLight );
    +

    例子

    + +

    + [example:webgl_lights_spotlight lights / spotlight ]
    + [example:webgl_lights_spotlights lights / spotlights ] +

    +

    构造器(Constructor)

    @@ -80,7 +61,7 @@

    [name]( [param:Integer color], [param:Float intensity], [param:Float distanc

    属性(Properties)

    - 公共属性请查看基类[page:Light Light]。 +

    公共属性请查看基类[page:Light Light]。

    [property:Float angle]

    @@ -124,7 +105,7 @@

    [property:Float power]

    光功率
    在 [page:WebGLRenderer.physicallyCorrectLights physically correct] 模式中, 表示以"流明(光通量单位)"为单位的光功率。 缺省值 - *4Math.PI*。

    - + 该值与 [page:.intensity intensity] 直接关联 power = intensity * 4π @@ -162,7 +143,7 @@

    [property:Object3D target]

    方法(Methods)

    - 公共方法请查看基类 [page:Light Light]。 +

    公共方法请查看基类 [page:Light Light]。

    [method:SpotLight copy]( [param:SpotLight source] )

    diff --git a/docs/api/zh/lights/shadows/DirectionalLightShadow.html b/docs/api/zh/lights/shadows/DirectionalLightShadow.html index 6992201b9daa6f..45a905abbd5255 100644 --- a/docs/api/zh/lights/shadows/DirectionalLightShadow.html +++ b/docs/api/zh/lights/shadows/DirectionalLightShadow.html @@ -1,5 +1,5 @@ - + @@ -18,46 +18,44 @@

    [name]

    与其他阴影类不同,它是使用OrthographicCamera来计算阴影,而不是PerspectiveCamera。这是因为来自DirectionalLight的光线是平行的。

    -

    例子

    -

    - -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a DirectionalLight and turn on shadows for the light -var light = new THREE.DirectionalLight( 0xffffff, 1, 100 ); -light.position.set( 0, 1, 0 ); //default; light shining from top -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500; // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

    +

    代码示例

    + + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a DirectionalLight and turn on shadows for the light + var light = new THREE.DirectionalLight( 0xffffff, 1, 100 ); + light.position.set( 0, 1, 0 ); //default; light shining from top + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500; // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

    构造函数

    [name]( )

    @@ -76,14 +74,15 @@

    [property:Camera camera]

    在光的世界里。这用于生成场景的深度图;从光的角度来看,其他物体背后的物体将处于阴影中。

    -

    方法

    - 有关常用方法,请参阅基础[page:LightShadow LightShadow]类。 + 有关常用方法,请参阅基础[page:LightShadow LightShadow]类。

    源码

    - [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

    diff --git a/docs/api/zh/lights/shadows/LightShadow.html b/docs/api/zh/lights/shadows/LightShadow.html index b7c7c258d9dbcc..a6864542885776 100644 --- a/docs/api/zh/lights/shadows/LightShadow.html +++ b/docs/api/zh/lights/shadows/LightShadow.html @@ -1,5 +1,5 @@ - + @@ -69,8 +69,8 @@

    [property:Float radius]

    将此值设置为大于1的值将模糊阴影的边缘。
    较高的值会在阴影中产生不必要的条带效果 - 更大的[page:.mapSize mapSize]将允许在这些效果变得可见之前使用更高的值。
    - If [page:WebGLRenderer.shadowMap.type] is set to [page:Renderer PCFSoftShadowMap], it is recommended to - leave radius at 1 and increase softness by decreasing [page:.mapSize mapSize] instead.

    + If [page:WebGLRenderer.shadowMap.type] is set to [page:Renderer PCFSoftShadowMap], radius has + no effect and it is recommended to increase softness by decreasing [page:.mapSize mapSize] instead.

    请注意,如果[page:WebGLRenderer.shadowMap.type]设置为[page:Renderer BasicShadowMap],将会无效。

    diff --git a/docs/api/zh/lights/shadows/PointLightShadow.html b/docs/api/zh/lights/shadows/PointLightShadow.html index 04204785829fa7..0bfeae7c3416cb 100644 --- a/docs/api/zh/lights/shadows/PointLightShadow.html +++ b/docs/api/zh/lights/shadows/PointLightShadow.html @@ -1,5 +1,5 @@ - + @@ -16,46 +16,45 @@

    [name]

    -

    示例

    -

    - -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a PointLight and turn on shadows for the light -var light = new THREE.PointLight( 0xffffff, 1, 100 ); -light.position.set( 0, 10, 0 ); -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500 // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

    +

    代码示例

    + + + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a PointLight and turn on shadows for the light + var light = new THREE.PointLight( 0xffffff, 1, 100 ); + light.position.set( 0, 10, 0 ); + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500 // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

    构造函数

    [name]( )

    @@ -70,6 +69,10 @@

    属性

    方法

    +

    + 共有方法请参见其基类[page:LightShadow LightShadow]。 +

    +

    [method:null updateMatrices]( [param:Light light], [param:number viewportIndex])

    Update the matrices for the camera and shadow, used internally by the renderer.

    @@ -77,10 +80,6 @@

    [method:null updateMatrices]( [param:Light light], [param:number viewportInd light -- the light for which the shadow is being rendered.
    viewportIndex -- calculates the matrix for this viewport

    - -

    - 共有方法请参见其基类[page:LightShadow LightShadow]。 -

    源代码

    diff --git a/docs/api/zh/lights/shadows/SpotLightShadow.html b/docs/api/zh/lights/shadows/SpotLightShadow.html index 9cd884bfed1ce4..01baedc99ad5ce 100644 --- a/docs/api/zh/lights/shadows/SpotLightShadow.html +++ b/docs/api/zh/lights/shadows/SpotLightShadow.html @@ -1,5 +1,5 @@ - + @@ -16,61 +16,61 @@

    [name]

    这在SpotLights内部用于计算阴影。

    -

    例子

    -

    - -//Create a WebGLRenderer and turn on shadows in the renderer -var renderer = new THREE.WebGLRenderer(); -renderer.shadowMap.enabled = true; -renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap - -//Create a SpotLight and turn on shadows for the light -var light = new THREE.SpotLight( 0xffffff ); -light.castShadow = true; // default false -scene.add( light ); - -//Set up shadow properties for the light -light.shadow.mapSize.width = 512; // default -light.shadow.mapSize.height = 512; // default -light.shadow.camera.near = 0.5; // default -light.shadow.camera.far = 500 // default - -//Create a sphere that cast shadows (but does not receive them) -var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); -var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); -var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); -sphere.castShadow = true; //default is false -sphere.receiveShadow = false; //default -scene.add( sphere ); - -//Create a plane that receives shadows (but does not cast them) -var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); -var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.receiveShadow = true; -scene.add( plane ); - -//Create a helper for the shadow camera (optional) -var helper = new THREE.CameraHelper( light.shadow.camera ); -scene.add( helper ); - -

    +

    代码示例

    + + + //Create a WebGLRenderer and turn on shadows in the renderer + var renderer = new THREE.WebGLRenderer(); + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFSoftShadowMap; // default THREE.PCFShadowMap + + //Create a SpotLight and turn on shadows for the light + var light = new THREE.SpotLight( 0xffffff ); + light.castShadow = true; // default false + scene.add( light ); + + //Set up shadow properties for the light + light.shadow.mapSize.width = 512; // default + light.shadow.mapSize.height = 512; // default + light.shadow.camera.near = 0.5; // default + light.shadow.camera.far = 500 // default + + //Create a sphere that cast shadows (but does not receive them) + var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); + var sphereMaterial = new THREE.MeshStandardMaterial( { color: 0xff0000 } ); + var sphere = new THREE.Mesh( sphereGeometry, sphereMaterial ); + sphere.castShadow = true; //default is false + sphere.receiveShadow = false; //default + scene.add( sphere ); + + //Create a plane that receives shadows (but does not cast them) + var planeGeometry = new THREE.PlaneBufferGeometry( 20, 20, 32, 32 ); + var planeMaterial = new THREE.MeshStandardMaterial( { color: 0x00ff00 } ) + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.receiveShadow = true; + scene.add( plane ); + //Create a helper for the shadow camera (optional) + var helper = new THREE.CameraHelper( light.shadow.camera ); + scene.add( helper ); +

    构造函数

    - 构造函数创建一个 [param:PerspectiveCamera PerspectiveCamera] 来管理阴影的世界视图 +

    构造函数创建一个 [param:PerspectiveCamera PerspectiveCamera] 来管理阴影的世界视图

    +

    属性

    - 有关常用属性,请参阅基础LightShadow类。 +

    有关常用属性,请参阅基础LightShadow类。

    +

    [property:Camera camera]

    在光的世界里。这用于生成场景的深度图;从光的角度来看,其他物体背后的物体将处于阴影中。

    默认值为PerspectiveCamera,近剪裁平面为0.5。 fov将通过更新方法跟踪拥有SpotLight的角度属性。同样,aspect属性将跟踪mapSize的方面。如果设置了灯光的距离属性,则远剪裁平面将跟踪该值,否则默认为500。 -

    方法

    - 有关常用方法,请参阅基础LightShadow类。 +

    有关常用方法,请参阅基础LightShadow类。

    +

    [method:SpotLightShadow update]( [param:SpotLight light] )

    根据传入的[page:SpotLight light]更新内部透视[page:.camera camera]。 @@ -78,6 +78,8 @@

    [method:SpotLightShadow update]( [param:SpotLight light] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/lights/[name].js src/lights/[name].js] +

    diff --git a/docs/api/zh/loaders/AnimationLoader.html b/docs/api/zh/loaders/AnimationLoader.html index f16e007674214e..96bd77f5794ec8 100644 --- a/docs/api/zh/loaders/AnimationLoader.html +++ b/docs/api/zh/loaders/AnimationLoader.html @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@

    [name]

    内部使用 [page:FileLoader] 来加载文件。

    -

    例子

    +

    代码示例

    // 初始化一个加载器 diff --git a/docs/api/zh/loaders/AudioLoader.html b/docs/api/zh/loaders/AudioLoader.html index e0b9ca676eb306..6950181c3f3d12 100644 --- a/docs/api/zh/loaders/AudioLoader.html +++ b/docs/api/zh/loaders/AudioLoader.html @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@

    [name]

    内部默认使用[page:FileLoader]来加载文件。

    -

    例子

    +

    代码示例

    // 初始化一个监听 diff --git a/docs/api/zh/loaders/BufferGeometryLoader.html b/docs/api/zh/loaders/BufferGeometryLoader.html index 71d97ff360d7ba..e873daa47ea088 100644 --- a/docs/api/zh/loaders/BufferGeometryLoader.html +++ b/docs/api/zh/loaders/BufferGeometryLoader.html @@ -1,5 +1,5 @@ - + @@ -17,9 +17,7 @@

    [name]

    内部使用[page:FileLoader]来加载文件。

    -

    例子

    - - [example:webgl_geometry_colors_lookuptable WebGL / geometry / colors / lookuptable] +

    代码示例

    // 初始化一个加载器 @@ -49,6 +47,12 @@

    例子

    );
    +

    例子

    + +

    + [example:webgl_performance WebGL / performance] +

    +

    构造函数

    [name]( [param:LoadingManager manager] )

    diff --git a/docs/api/zh/loaders/Cache.html b/docs/api/zh/loaders/Cache.html index 33056850a0a4f1..f0772ec7a7e88a 100644 --- a/docs/api/zh/loaders/Cache.html +++ b/docs/api/zh/loaders/Cache.html @@ -1,5 +1,5 @@ - + @@ -14,15 +14,7 @@

    [name]

    一个简单的缓存系统,内部使用[page:FileLoader]。

    -

    例子

    - -

    - [example:webgl_geometry_text WebGL / geometry / text ]
    - [example:webgl_interactive_instances_gpu WebGL / interactive / instances / gpu]
    - [example:webgl_loader_ttf WebGL / loader / ttf] -

    - -

    Usage

    +

    代码示例

    要在所有使用[page:FileLoader]的加载器上启用缓存, 需设置

    @@ -30,6 +22,13 @@

    Usage

    THREE.Cache.enabled = true.
    +

    例子

    + +

    + [example:webgl_geometry_text WebGL / geometry / text ]
    + [example:webgl_interactive_instances_gpu WebGL / interactive / instances / gpu]
    + [example:webgl_loader_ttf WebGL / loader / ttf] +

    属性

    diff --git a/docs/api/zh/loaders/CompressedTextureLoader.html b/docs/api/zh/loaders/CompressedTextureLoader.html index 5fca540fea7f87..5048eecac7ac11 100644 --- a/docs/api/zh/loaders/CompressedTextureLoader.html +++ b/docs/api/zh/loaders/CompressedTextureLoader.html @@ -1,5 +1,5 @@ - + @@ -20,8 +20,8 @@

    [name]

    例子

    - 请参考[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DDSLoader.js DDSLoader] - 和[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PVRLoader.js PVRLoader] + 请参考[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/DDSLoader.js DDSLoader] + 和[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PVRLoader.js PVRLoader] 子类的例子

    diff --git a/docs/api/zh/loaders/CubeTextureLoader.html b/docs/api/zh/loaders/CubeTextureLoader.html index 42fe5f0b6d8932..f0e95ab7aead22 100644 --- a/docs/api/zh/loaders/CubeTextureLoader.html +++ b/docs/api/zh/loaders/CubeTextureLoader.html @@ -1,5 +1,5 @@ - + @@ -17,16 +17,7 @@

    [name]

    内部使用[page:ImageLoader]来加载文件。

    -

    例子

    - -

    - [example:webgl_materials_cubemap materials / cubemap]
    - [example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection]
    - [example:webgl_materials_cubemap_balls_refraction materials / cubemap / balls / refraction]
    - [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic]
    - [example:webgl_materials_cubemap_dynamic2 materials / cubemap / dynamic2]
    - [example:webgl_materials_cubemap_refraction materials / cubemap / refraction] -

    +

    代码示例

    var scene = new THREE.Scene(); @@ -42,6 +33,17 @@

    例子

    ] );
    +

    例子

    + +

    + [example:webgl_materials_cubemap materials / cubemap]
    + [example:webgl_materials_cubemap_balls_reflection materials / cubemap / balls / reflection]
    + [example:webgl_materials_cubemap_balls_refraction materials / cubemap / balls / refraction]
    + [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic]
    + [example:webgl_materials_cubemap_dynamic2 materials / cubemap / dynamic2]
    + [example:webgl_materials_cubemap_refraction materials / cubemap / refraction] +

    +

    构造函数

    [name]( [param:LoadingManager manager] )

    diff --git a/docs/api/zh/loaders/DataTextureLoader.html b/docs/api/zh/loaders/DataTextureLoader.html index 16200f8edb4ca7..62165a3a8011da 100644 --- a/docs/api/zh/loaders/DataTextureLoader.html +++ b/docs/api/zh/loaders/DataTextureLoader.html @@ -1,5 +1,5 @@ - + @@ -21,7 +21,7 @@

    [name]

    例子

    - 请参考[link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/RGBELoader.js RGBELoader] + 请参考[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/RGBELoader.js RGBELoader] 这个子类的例子。

    diff --git a/docs/api/zh/loaders/FileLoader.html b/docs/api/zh/loaders/FileLoader.html index 775824138284af..5f4371158a6453 100644 --- a/docs/api/zh/loaders/FileLoader.html +++ b/docs/api/zh/loaders/FileLoader.html @@ -1,5 +1,5 @@ - + @@ -17,11 +17,7 @@

    [name]

    它也可以直接用于加载任何没有对应加载器的文件类型。

    -

    例子

    -

    - [example:webgl_loader_msgpack WebGL / loader / msgpack]
    - [example:webgl_morphtargets_human WebGL / morphtargets / human]
    -

    +

    代码示例

    var loader = new THREE.FileLoader(); @@ -56,7 +52,6 @@

    例子

    [page:Cache Cache] 是​​一个缓存模块,用于保存通过此加载器发出的每个请求的响应,因此每个文件都会被请求一次。

    -

    构造函数

    [name] ( [param:LoadingManager manager] )

    diff --git a/docs/api/zh/loaders/FontLoader.html b/docs/api/zh/loaders/FontLoader.html index 2ef248d2ebc27c..9638422110e13e 100644 --- a/docs/api/zh/loaders/FontLoader.html +++ b/docs/api/zh/loaders/FontLoader.html @@ -1,5 +1,5 @@ - + @@ -19,12 +19,7 @@

    [name]

    你可以使用[link:https://gero3.github.io/facetype.js/ facetype.js]在线转换字体。

    -

    例子

    - -

    - [example:webgl_geometry_text_shapes geometry / text / shapes ]
    - [example:webgl_geometry_text geometry / text ] -

    +

    代码示例

    var loader = new THREE.FontLoader(); @@ -50,6 +45,13 @@

    例子

    );
    +

    例子

    + +

    + [example:webgl_geometry_text_shapes geometry / text / shapes ]
    + [example:webgl_geometry_text geometry / text ] +

    +

    构造函数

    [name]( [param:LoadingManager manager] )

    diff --git a/docs/api/zh/loaders/ImageBitmapLoader.html b/docs/api/zh/loaders/ImageBitmapLoader.html index 0300f1edd98e30..8885b766fff4e4 100644 --- a/docs/api/zh/loaders/ImageBitmapLoader.html +++ b/docs/api/zh/loaders/ImageBitmapLoader.html @@ -1,5 +1,5 @@ - + @@ -25,11 +25,7 @@

    [name]

    instead. Refer to [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.10 WebGL specification] for the detail.

    -

    例子

    - -

    - [example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap] -

    +

    代码示例

    // 初始化一个加载器 @@ -59,6 +55,11 @@

    例子

    );
    +

    例子

    + +

    + [example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap] +

    构造函数

    diff --git a/docs/api/zh/loaders/ImageLoader.html b/docs/api/zh/loaders/ImageLoader.html index f65c34611243e4..919e7b7f463feb 100644 --- a/docs/api/zh/loaders/ImageLoader.html +++ b/docs/api/zh/loaders/ImageLoader.html @@ -1,5 +1,5 @@ - + @@ -18,12 +18,7 @@

    [name]

    [page:CubeTextureLoader]、[page:ObjectLoader]、[page:TextureLoader]所使用。

    -

    例子

    - -

    - [example:webgl_loader_obj WebGL / loader / obj]
    - [example:webgl_shaders_ocean WebGL / shaders / ocean] -

    +

    代码示例

    // 初始化一个加载器 @@ -57,6 +52,13 @@

    例子

    请参考[link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-275785639 this thread].

    +

    例子

    + +

    + [example:webgl_loader_obj WebGL / loader / obj]
    + [example:webgl_shaders_ocean WebGL / shaders / ocean] +

    +

    构造方法

    [name]( [param:LoadingManager manager] )

    diff --git a/docs/api/zh/loaders/Loader.html b/docs/api/zh/loaders/Loader.html index 1ebb3fe4825a77..c61d62a10ea221 100644 --- a/docs/api/zh/loaders/Loader.html +++ b/docs/api/zh/loaders/Loader.html @@ -1,5 +1,5 @@ - + @@ -57,6 +57,18 @@

    [method:void load]()

    This method needs to be implement by all concrete loaders. It holds the logic for loading the asset from the backend.

    +

    [method:Promise loadAsync]( [param:String url], [param:Function onProgress] )

    +

    + [page:String url] — A string containing the path/URL of the file to be loaded.
    + [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.
    +

    +

    + This method is equivalent to [page:.load], but returns a [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Promise]. +

    +

    + [page:Function onLoad] is handled by [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve Promise.resolve] and [page:Function onError] is handled by [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject Promise.reject]. +

    +

    [method:void parse]()

    This method needs to be implement by all concrete loaders. It holds the logic for parsing the asset into three.js entities. diff --git a/docs/api/zh/loaders/LoaderUtils.html b/docs/api/zh/loaders/LoaderUtils.html index 9fe8cdda0a7578..78fc0da4f696a8 100644 --- a/docs/api/zh/loaders/LoaderUtils.html +++ b/docs/api/zh/loaders/LoaderUtils.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/loaders/MaterialLoader.html b/docs/api/zh/loaders/MaterialLoader.html index 79a3077868f170..6ac947dc5cd911 100644 --- a/docs/api/zh/loaders/MaterialLoader.html +++ b/docs/api/zh/loaders/MaterialLoader.html @@ -1,5 +1,5 @@ - + @@ -17,8 +17,7 @@

    [name]

    默认使用[page:FileLoader]进行加载文件。

    -

    例子

    - +

    代码示例

    // 初始化一个加载器 diff --git a/docs/api/zh/loaders/ObjectLoader.html b/docs/api/zh/loaders/ObjectLoader.html index 6a8e4e700d66c9..9639696397f0bb 100644 --- a/docs/api/zh/loaders/ObjectLoader.html +++ b/docs/api/zh/loaders/ObjectLoader.html @@ -1,5 +1,5 @@ - + @@ -18,12 +18,7 @@

    [name]

    此加载器内部使用[page:FileLoader]进行加载文件。

    -

    例子

    - -

    - [example:webgl_loader_json_claraio WebGL / loader / json / claraio]
    - [example:webgl_materials_lightmap WebGL / materials / lightmap] -

    +

    代码示例

    var loader = new THREE.ObjectLoader(); @@ -57,7 +52,12 @@

    例子

    scene.add( object );
    +

    例子

    +

    + [example:webgl_loader_json_claraio WebGL / loader / json / claraio]
    + [example:webgl_materials_lightmap WebGL / materials / lightmap] +

    构造函数

    diff --git a/docs/api/zh/loaders/TextureLoader.html b/docs/api/zh/loaders/TextureLoader.html index 8cd7af5df33115..b5a330fe332651 100644 --- a/docs/api/zh/loaders/TextureLoader.html +++ b/docs/api/zh/loaders/TextureLoader.html @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@

    [name]

    内部使用[page:ImageLoader]来加载文件。

    -

    例子

    +

    代码示例

    var texture = new THREE.TextureLoader().load( 'textures/land_ocean_ice_cloud_2048.jpg' ); @@ -26,9 +26,7 @@

    例子

    var material = new THREE.MeshBasicMaterial( { map: texture } );
    - [example:webgl_geometry_cube geometry / cube] - -

    Example with Callbacks

    +

    Code Example with Callbacks

    // 初始化一个加载器 @@ -56,8 +54,16 @@

    Example with Callbacks

    } );
    - 请注意three.js r84遗弃了TextureLoader进度事件。对于支持进度事件的TextureLoader , - 请参考[link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-293260145 this thread]。 +

    + 请注意three.js r84遗弃了TextureLoader进度事件。对于支持进度事件的TextureLoader , + 请参考[link:https://github.com/mrdoob/three.js/issues/10439#issuecomment-293260145 this thread]。 +

    + +

    例子

    + +

    + [example:webgl_geometry_cube geometry / cube] +

    构造函数

    diff --git a/docs/api/zh/loaders/managers/DefaultLoadingManager.html b/docs/api/zh/loaders/managers/DefaultLoadingManager.html index 20ccb49b8d3841..22e7c52098f00e 100644 --- a/docs/api/zh/loaders/managers/DefaultLoadingManager.html +++ b/docs/api/zh/loaders/managers/DefaultLoadingManager.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

    [name]

    LoadingManager对于大多数加载器来说已经足够了,但有时您可能需要单独设置加载管理器,例如纹理、模型加载器。

    -

    例子

    +

    代码示例

    你可以选择性的为你的管理器设置 [page:LoadingManager.onStart onStart], [page:LoadingManager.onLoad onLoad], @@ -26,30 +26,30 @@

    例子

    请注意,个人的加载器的不应具有类似上面类似的命名函数,以避免混淆。因为这些函数时用于显示有关加载总体状态的信息,而不是处理已加载的数据。

    -THREE.DefaultLoadingManager.onStart = function ( url, itemsLoaded, itemsTotal ) { + THREE.DefaultLoadingManager.onStart = function ( url, itemsLoaded, itemsTotal ) { - console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' ); + console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' ); -}; + }; -THREE.DefaultLoadingManager.onLoad = function ( ) { + THREE.DefaultLoadingManager.onLoad = function ( ) { - console.log( 'Loading Complete!'); + console.log( 'Loading Complete!'); -}; + }; -THREE.DefaultLoadingManager.onProgress = function ( url, itemsLoaded, itemsTotal ) { + THREE.DefaultLoadingManager.onProgress = function ( url, itemsLoaded, itemsTotal ) { - console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' ); + console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' ); -}; + }; -THREE.DefaultLoadingManager.onError = function ( url ) { + THREE.DefaultLoadingManager.onError = function ( url ) { - console.log( 'There was an error loading ' + url ); + console.log( 'There was an error loading ' + url ); -}; + }; @@ -62,7 +62,8 @@

    方法

    有关LoadingManager方法的详细信息,请查看[page:LoadingManager LoadingManager] 页面。

    - - [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

    diff --git a/docs/api/zh/loaders/managers/LoadingManager.html b/docs/api/zh/loaders/managers/LoadingManager.html index b3e9a780b510b1..5cb8fe9b509427 100644 --- a/docs/api/zh/loaders/managers/LoadingManager.html +++ b/docs/api/zh/loaders/managers/LoadingManager.html @@ -1,5 +1,5 @@ - + @@ -19,16 +19,7 @@

    [name]

    - -

    例子

    - -

    - [example:webgl_loader_fbx WebGL / loader / fbx]
    - [example:webgl_loader_obj WebGL / loader / obj]
    - [example:webgl_materials_reflectivity WebGL / materials / reflectivity]
    - [example:webgl_postprocessing_outline WebGL / postprocesing / outline]
    - [example:webgl_terrain_dynamic WebGL / terrain / dynamic] -

    +

    代码示例

    下面的例子将介绍,如何使用加载管理器来跟踪 [page:OBJLoader] 的加载进度流程。 @@ -104,6 +95,15 @@

    例子

    });
    +

    例子

    + +

    + [example:webgl_loader_fbx WebGL / loader / fbx]
    + [example:webgl_loader_obj WebGL / loader / obj]
    + [example:webgl_materials_physical_reflectivity WebGL / materials / physical / reflectivity]
    + [example:webgl_postprocessing_outline WebGL / postprocesing / outline] +

    +

    构造方法

    [name]( [param:Function onLoad], [param:Function onProgress], [param:Function onError] )

    @@ -200,7 +200,7 @@

    [method:null setURLModifier]( [param:Function callback] )

    -

    +

    Note: The following methods are designed to be called internally by loaders. You shouldn't call them directly. @@ -228,7 +228,8 @@

    [method:null itemError]( [param:String url] )

    - - [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

    + [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js] +

    diff --git a/docs/api/zh/materials/LineBasicMaterial.html b/docs/api/zh/materials/LineBasicMaterial.html index de3fade0d6ea98..2b5a332bc68c45 100644 --- a/docs/api/zh/materials/LineBasicMaterial.html +++ b/docs/api/zh/materials/LineBasicMaterial.html @@ -1,5 +1,5 @@ - + @@ -12,9 +12,20 @@

    基础线条材质([name])

    -

    一种用于绘制线框样式几何体的材质。

    +

    一种用于绘制线框样式几何体的材质。

    -

    例子(Examples)

    +

    代码示例

    + + + var material = new THREE.LineBasicMaterial( { + color: 0xffffff, + linewidth: 1, + linecap: 'round', //ignored by WebGLRenderer + linejoin: 'round' //ignored by WebGLRenderer + } ); + + +

    例子

    [example:webgl_buffergeometry_drawcalls WebGL / buffergeometry / drawcalls]
    @@ -29,20 +40,10 @@

    例子(Examples)

    [example:webgl_lines_colors WebGL / lines / colors]
    [example:webgl_lines_dashed WebGL / lines / dashed]
    [example:webgl_lines_sphere WebGL / lines / sphere]
    - [example:webgl_lines_splines WebGL / lines / splines]
    [example:webgl_materials WebGL / materials]
    - [example:webgl_physics_rope WebGL / phyics / rope] + [example:physics_ammo_rope physics / ammo / rope]

    - -var material = new THREE.LineBasicMaterial( { - color: 0xffffff, - linewidth: 1, - linecap: 'round', //ignored by WebGLRenderer - linejoin: 'round' //ignored by WebGLRenderer -} ); - -

    构造函数(Constructor)

    [name]( [param:Object parameters] )

    diff --git a/docs/api/zh/materials/LineDashedMaterial.html b/docs/api/zh/materials/LineDashedMaterial.html index fb16f71bb0523d..5204b5352cb673 100644 --- a/docs/api/zh/materials/LineDashedMaterial.html +++ b/docs/api/zh/materials/LineDashedMaterial.html @@ -1,5 +1,5 @@ - + @@ -8,43 +8,40 @@ - [page:Material] → + [page:Material] → [page:LineBasicMaterial] →

    虚线材质([name])

    一种用于绘制虚线样式几何体的材质。

    -

    例子(Examples)

    +

    代码示例

    + + + var material = new THREE.LineDashedMaterial( { + color: 0xffffff, + linewidth: 1, + scale: 1, + dashSize: 3, + gapSize: 1, + } ); + + +

    例子

    [example:webgl_lines_dashed WebGL / lines / dashed]

    - -var material = new THREE.LineDashedMaterial( { - color: 0xffffff, - linewidth: 1, - scale: 1, - dashSize: 3, - gapSize: 1, -} ); - -

    构造函数(Constructor)

    [name]( [param:Object parameters] )

    - [page:Object parameters] - (可选)用于定义材质外观的对象,具有一个或多个属性。材质的任何属性都可以从此处传入(包括从[page:Material]继承的任何属性)。

    - 属性[page:Hexadecimal color]例外,其可以作为十六进制字符串传递,默认情况下为 *0xffffff*(白色),内部调用[page:Color.set](color)。 + [page:Object parameters] - (可选)用于定义材质外观的对象,具有一个或多个属性。材质的任何属性都可以从此处传入(包括从[page:LineBasicMaterial]继承的任何属性)。

    -

    属性(Properties)

    -

    共有属性请参见其基类[page:Material]。

    - -

    [property:Color color]

    -

    材质的颜色([page:Color]),默认值为白色 (0xffffff)。

    +

    共有属性请参见其基类[page:LineBasicMaterial]。

    [property:number dashSize]

    虚线的大小,是指破折号和间隙之和。默认值为 *3*。

    @@ -52,21 +49,11 @@

    [property:number dashSize]

    [property:number gapSize]

    间隙的大小,默认值为 *1*。

    -

    [property:Float linewidth]

    -

    - 控制线宽。默认值为 *1*。

    - - 由于[link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile]与 - 大多数平台上[page:WebGLRenderer WebGL]渲染器的限制,无论如何设置该值,线宽始终为1。 -

    -

    [property:number scale]

    线条中虚线部分的占比。默认值为 *1*。

    方法(Methods)

    -

    共有方法请参见其基类[page:Material]。

    - - +

    共有方法请参见其基类[page:LineBasicMaterial]。

    源码(Source)

    diff --git a/docs/api/zh/materials/Material.html b/docs/api/zh/materials/Material.html index a2c723b87fca27..57027497af9475 100644 --- a/docs/api/zh/materials/Material.html +++ b/docs/api/zh/materials/Material.html @@ -1,5 +1,5 @@ - + @@ -253,15 +253,9 @@

    [property:Integer version]

    This starts at *0* and counts how many times [property:Boolean needsUpdate] is set to *true*.

    -

    [property:Integer vertexColors]

    -

    是否使用顶点着色。默认值为[page:Materials THREE.NoColors]。 - 其他选项有[page:Materials THREE.VertexColors] 和 [page:Materials THREE.FaceColors]。 -

    - -

    [property:Boolean vertexTangents]

    -

    Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute, - are used. When disabled, tangents are derived automatically. Using precomputed tangents will give - more accurate normal map details in some cases, such as with mirrored UVs. Default is false. +

    [property:Boolean vertexColors]

    +

    +Defines whether vertex coloring is used. Default is *false*.

    [property:Boolean visible]

    diff --git a/docs/api/zh/materials/MeshBasicMaterial.html b/docs/api/zh/materials/MeshBasicMaterial.html index b1e2c82840c757..1f84d6e59f0e9b 100644 --- a/docs/api/zh/materials/MeshBasicMaterial.html +++ b/docs/api/zh/materials/MeshBasicMaterial.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/materials/MeshDepthMaterial.html b/docs/api/zh/materials/MeshDepthMaterial.html index 6c2bfedf9d6b7c..aa13063eb5b707 100644 --- a/docs/api/zh/materials/MeshDepthMaterial.html +++ b/docs/api/zh/materials/MeshDepthMaterial.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/materials/MeshDistanceMaterial.html b/docs/api/zh/materials/MeshDistanceMaterial.html index 3b470a8bc31a0a..c57b994f8878e5 100644 --- a/docs/api/zh/materials/MeshDistanceMaterial.html +++ b/docs/api/zh/materials/MeshDistanceMaterial.html @@ -1,5 +1,5 @@ - + @@ -19,9 +19,11 @@

    [name]

    下列示例演示了这一方法,以确保物体的透明部分不投射阴影。

    -

    示例

    +

    例子

    - [example:webgl_shadowmap_pointlight WebGL / shadowmap / pointlight] +

    + [example:webgl_shadowmap_pointlight WebGL / shadowmap / pointlight] +

    -

    例子(Examples)

    - [example:webgl_materials_variations_physical materials / variations / physical]
    - [example:webgl_materials_reflectivity materials / reflectivity] +

    例子

    + +

    + [example:webgl_materials_variations_physical materials / variations / physical]
    + [example:webgl_materials_physical_clearcoat materials / physical / clearcoat]
    + [example:webgl_materials_physical_reflectivity materials / physical / reflectivity]
    + [example:webgl_materials_physical_transparency materials / physical / transparency] +

    构造函数(Constructor)

    @@ -52,11 +80,30 @@

    属性(Properties)

    [property:Float clearcoat]

    - Clearcoat级别,从*0.0*到*1.0*。默认值为*0.0*。 + Represents the thickness of the clear coat layer, from *0.0* to *1.0*. Use clear coat related properties to enable multilayer + materials that have a thin translucent layer over the base layer. Default is *0.0*.

    +

    [property:Texture clearcoatMap]

    +

    + The red channel of this texture is multiplied against [page:.clearcoat], for per-pixel control + over a coating's thickness. Default is *null*. +

    + +

    [property:Texture clearcoatNormalMap]

    +

    Can be used to enable independent normals for the clear coat layer. Default is *null*.

    + +

    [property:Vector2 clearcoatNormalScale]

    +

    How much [page:.clearcoatNormalMap] affects the clear coat layer, from *(0,0)* to *(1,1)*. Default is *(1,1)*.

    +

    [property:Float clearcoatRoughness]

    -

    clearcoat看起来的粗糙程度,从*0.0*到*1.0*。默认值为*0.0*。

    +

    Roughness of the clear coat layer, from *0.0* to *1.0*. Default is *0.0*.

    + +

    [property:Texture clearcoatRoughnessMap]

    +

    + The green channel of this texture is multiplied against [page:.clearcoatRoughness], for per-pixel control + over a coating's roughness. Default is *null*. +

    [property:Object defines]

    如下形式的对象: @@ -65,7 +112,7 @@

    [property:Object defines]

    'STANDARD': '' 'PHYSICAL': '', - + };
    [page:WebGLRenderer]使用它来选择shaders。 @@ -76,6 +123,17 @@

    [property:Float reflectivity]

    这模拟了非金属材质的反射率。当[page:MeshStandardMaterial]为*1.0*时,此属性无效。

    +

    [property:Float transparency]

    +

    + Degree of transparency, from *0.0* to *1.0*. Default is *0.0*.
    + + Thin, transparent or semitransparent, plastic or glass materials remain largely reflective even if they are mostly transparent. + + The transparency property can be used to model these materials.
    + + When transparency is non-zero, [page:Material.opacity opacity] should be set to *1*. +

    +

    方法(Methods)

    共有方法请参见其基类[page:Material] 和[page:MeshStandardMaterial]。

    diff --git a/docs/api/zh/materials/MeshStandardMaterial.html b/docs/api/zh/materials/MeshStandardMaterial.html index f6beab0aa1ad59..a559ac95c1c5ce 100644 --- a/docs/api/zh/materials/MeshStandardMaterial.html +++ b/docs/api/zh/materials/MeshStandardMaterial.html @@ -1,5 +1,5 @@ - + @@ -140,7 +140,7 @@

    [property:TextureCube envMap]

    请确保将minFilter设置为其中一个MipMap选项,并且未强制禁用mip贴图。

    注意:MeshStandardMaterial 仅支持[link:https://threejs.org/docs/#api/textures/CubeTexture cube environment maps]。 - 如果要使用equirectangular贴图,则需要使用 [page:WebGLRenderTargetCube.fromEquirectangularTexture WebGLRenderTargetCube.fromEquirectangularTexture]().。 + 如果要使用equirectangular贴图,则需要使用 [page:WebGLCubeRenderTarget.fromEquirectangularTexture WebGLCubeRenderTarget.fromEquirectangularTexture]().。 详细信息请参阅此示例[link:https://threejs.org/examples/webgl_materials_envmaps_exr.html example]。

    @@ -201,6 +201,12 @@

    [property:Texture roughnessMap]

    [property:Boolean skinning]

    材质是否使用蒙皮。默认值为false。

    +

    [property:Boolean vertexTangents]

    +

    Defines whether precomputed vertex tangents, which must be provided in a vec4 "tangent" attribute, + are used. When disabled, tangents are derived automatically. Using precomputed tangents will give + more accurate normal map details in some cases, such as with mirrored UVs. Default is false. +

    +

    [property:Boolean wireframe]

    将几何体渲染为线框。默认值为*false*(即渲染为平面多边形)。

    diff --git a/docs/api/zh/materials/MeshToonMaterial.html b/docs/api/zh/materials/MeshToonMaterial.html index e90053f1ef62d2..06251f5b5c0ad7 100644 --- a/docs/api/zh/materials/MeshToonMaterial.html +++ b/docs/api/zh/materials/MeshToonMaterial.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

    [name]

    -

    Examples

    +

    例子

    [example:webgl_materials_variations_toon materials / variations / toon]

    diff --git a/docs/api/zh/materials/PointsMaterial.html b/docs/api/zh/materials/PointsMaterial.html index 276fab7d02ef7b..613097a3e2a184 100644 --- a/docs/api/zh/materials/PointsMaterial.html +++ b/docs/api/zh/materials/PointsMaterial.html @@ -1,5 +1,5 @@ - + @@ -14,7 +14,32 @@

    点材质([name])

    [page:Points]使用的默认材质。

    -

    例子(Examples)

    +

    代码示例

    + + + var vertices = []; + + for ( var i = 0; i < 10000; i ++ ) { + + var x = THREE.MathUtils.randFloatSpread( 2000 ); + var y = THREE.MathUtils.randFloatSpread( 2000 ); + var z = THREE.MathUtils.randFloatSpread( 2000 ); + + vertices.push( x, y, z ); + + } + + var geometry = new THREE.BufferGeometry(); + geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + + var material = new THREE.PointsMaterial( { color: 0x888888 } ); + + var points = new THREE.Points( geometry, material ); + + scene.add( points ); + + +

    例子

    [example:misc_controls_fly misc / controls / fly]
    [example:webgl_buffergeometry_drawcalls WebGL / BufferGeometry / drawcalls]
    @@ -26,36 +51,12 @@

    例子(Examples)

    [example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points]
    [example:webgl_multiple_elements_text WebGL / multiple / elements / text]
    [example:webgl_points_billboards WebGL / points / billboards]
    - [example:webgl_points_billboards_colors WebGL / points / billboards / colors]
    [example:webgl_points_dynamic WebGL / points / dynamic]
    - [example:webgl_points_random WebGL / points / random]
    [example:webgl_points_sprites WebGL / points / sprites]
    [example:webgl_trails WebGL / trails]

    - -//This will add a starfield to the background of a scene -var starsGeometry = new THREE.Geometry(); - -for ( var i = 0; i < 10000; i ++ ) { - - var star = new THREE.Vector3(); - star.x = THREE.Math.randFloatSpread( 2000 ); - star.y = THREE.Math.randFloatSpread( 2000 ); - star.z = THREE.Math.randFloatSpread( 2000 ); - - starsGeometry.vertices.push( star ); - -} - -var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } ); - -var starField = new THREE.Points( starsGeometry, starsMaterial ); - -scene.add( starField ); - - -

    [name]( [param:Object parameters] )

    +

    [name]( [param:Object parameters] )

    [page:Object parameters] - (可选)用于定义材质外观的对象,具有一个或多个属性。 材质的任何属性都可以从此处传入(包括从[page:Material]继承的任何属性)。

    diff --git a/docs/api/zh/materials/RawShaderMaterial.html b/docs/api/zh/materials/RawShaderMaterial.html index e1458112a1c44b..97dcd175fe8985 100644 --- a/docs/api/zh/materials/RawShaderMaterial.html +++ b/docs/api/zh/materials/RawShaderMaterial.html @@ -1,5 +1,5 @@ - + @@ -15,7 +15,21 @@

    原始着色器材质([name])

    此类的工作方式与[page:ShaderMaterial]类似,不同之处在于内置的uniforms和attributes的定义不会自动添加到GLSL shader代码中。

    -

    例子(Examples)

    +

    代码示例

    + + + var material = new THREE.RawShaderMaterial( { + + uniforms: { + time: { value: 1.0 } + }, + vertexShader: document.getElementById( 'vertexShader' ).textContent, + fragmentShader: document.getElementById( 'fragmentShader' ).textContent, + + } ); + + +

    例子

    [example:webgl_buffergeometry_rawshader WebGL / buffergeometry / rawshader]
    [example:webgl_buffergeometry_instancing_billboards WebGL / buffergeometry / instancing / billboards]
    @@ -26,18 +40,6 @@

    例子(Examples)

    [example:webgl_raymarching_reflect WebGL / raymarching / reflect]

    - -var material = new THREE.RawShaderMaterial( { - - uniforms: { - time: { value: 1.0 } - }, - vertexShader: document.getElementById( 'vertexShader' ).textContent, - fragmentShader: document.getElementById( 'fragmentShader' ).textContent, - -} ); - -

    构造函数(Constructor)

    [name]( [param:Object parameters] )

    diff --git a/docs/api/zh/materials/ShaderMaterial.html b/docs/api/zh/materials/ShaderMaterial.html index 6f20eae06b9692..9eb463efba5a5a 100644 --- a/docs/api/zh/materials/ShaderMaterial.html +++ b/docs/api/zh/materials/ShaderMaterial.html @@ -1,5 +1,5 @@ - + @@ -29,13 +29,13 @@

    着色器材质([name])

  • 从 THREE r72开始,不再支持在ShaderMaterial中直接分配属性。 必须使用 [page:BufferGeometry]实例 (而不是 [page:Geometry] 实例),使用[page:BufferAttribute]实例来定义自定义属性。
  • -
  • 从 THREE r77开始,[page:WebGLRenderTarget] 或 [page:WebGLRenderTargetCube] 实例不再被用作uniforms。 +
  • 从 THREE r77开始,[page:WebGLRenderTarget] 或 [page:WebGLCubeRenderTarget] 实例不再被用作uniforms。 必须使用它们的[page:Texture texture] 属性。
  • 内置attributes和uniforms与代码一起传递到shaders。 如果您不希望[page:WebGLProgram]向shader代码添加任何内容,则可以使用[page:RawShaderMaterial]而不是此类。
  • -
  • 您可以使用指令#pragma unroll_loop,以便通过shader预处理器在GLSL中展开for循环。 +
  • 您可以使用指令#pragma unroll_loop_start,#pragma unroll_loop_end 以便通过shader预处理器在GLSL中展开for循环。 该指令必须放在循环的正上方。循环格式必须与定义的标准相对应。
    • 循环必须标准化[link:https://en.wikipedia.org/wiki/Normalized_loop normalized]。 @@ -48,18 +48,38 @@

      着色器材质([name])

    - #pragma unroll_loop + #pragma unroll_loop_start for ( int i = 0; i < 10; i ++ ) { // ... } + #pragma unroll_loop_end
  • -

    例子(Examples)

    +

    代码示例

    + + + var material = new THREE.ShaderMaterial( { + + uniforms: { + + time: { value: 1.0 }, + resolution: { value: new THREE.Vector2() } + + }, + + vertexShader: document.getElementById( 'vertexShader' ).textContent, + + fragmentShader: document.getElementById( 'fragmentShader' ).textContent + + } ); + + +

    例子

    [example:webgl_animation_cloth webgl / animation / cloth ]
    @@ -91,26 +111,8 @@

    例子(Examples)

    [example:webgl_nearestneighbour webgl / nearestneighbour]
    [example:webgl_postprocessing_dof2 webgl / postprocessing / dof2]
    [example:webgl_postprocessing_godrays webgl / postprocessing / godrays] -

    - - var material = new THREE.ShaderMaterial( { - - uniforms: { - - time: { value: 1.0 }, - resolution: { value: new THREE.Vector2() } - - }, - - vertexShader: document.getElementById( 'vertexShader' ).textContent, - - fragmentShader: document.getElementById( 'fragmentShader' ).textContent - - } ); - -

    顶点着色器和片元着色器(Vertex shaders and fragment shaders)

    @@ -357,11 +359,14 @@

    [property:Object uniforms]

    注意,uniforms逐帧被刷新,所以更新uniform值将立即更新GLSL代码中的相应值。

    +

    [property:Boolean uniformsNeedUpdate]

    +

    + Can be used to force a uniform update while changing uniforms in [page:Object3D.onBeforeRender](). Default is *false*. +

    -

    [property:Number vertexColors]

    -

    通过定义*colors*属性的生成方式来定义顶点是如何着色的。 - 可选值为[page:Materials THREE.NoColors], [page:Materials THREE.FaceColors] 和 - [page:Materials THREE.VertexColors]。 缺省为 THREE.NoColors。 +

    [property:Boolean vertexColors]

    +

    + Defines whether vertex coloring is used. Default is *false*.

    [property:String vertexShader]

    diff --git a/docs/api/zh/materials/ShadowMaterial.html b/docs/api/zh/materials/ShadowMaterial.html index 9983fff87a98da..0fb610138b3735 100644 --- a/docs/api/zh/materials/ShadowMaterial.html +++ b/docs/api/zh/materials/ShadowMaterial.html @@ -1,5 +1,5 @@ - + @@ -8,7 +8,7 @@ - [page:Material] → [page:ShaderMaterial] → + [page:Material] →

    阴影材质([name])

    @@ -16,38 +16,43 @@

    阴影材质([name])

    此材质可以接收阴影,但在其他方面完全透明。

    -

    例子(Example)

    - [example:webgl_geometry_spline_editor geometry / spline / editor] +

    代码示例

    -var planeGeometry = new THREE.PlaneGeometry( 2000, 2000 ); -planeGeometry.rotateX( - Math.PI / 2 ); + var planeGeometry = new THREE.PlaneBufferGeometry( 2000, 2000 ); + planeGeometry.rotateX( - Math.PI / 2 ); -var planeMaterial = new THREE.ShadowMaterial(); -planeMaterial.opacity = 0.2; + var planeMaterial = new THREE.ShadowMaterial(); + planeMaterial.opacity = 0.2; -var plane = new THREE.Mesh( planeGeometry, planeMaterial ); -plane.position.y = -200; -plane.receiveShadow = true; -scene.add( plane ); + var plane = new THREE.Mesh( planeGeometry, planeMaterial ); + plane.position.y = -200; + plane.receiveShadow = true; + scene.add( plane ); +

    例子

    + +

    + [example:webgl_geometry_spline_editor geometry / spline / editor] +

    +

    构造函数(Constructor)

    [name]( [param:Object parameters] )

    [page:Object parameters] - (可选)用于定义材质外观的对象,具有一个或多个属性。 - 材质的任何属性都可以从此处传入(包括从[page:Material] 和 [page:ShaderMaterial]继承的任何属性)。

    + 材质的任何属性都可以从此处传入(包括从[page:Material]]继承的任何属性)。

    属性(Properties)

    -

    共有属性请参见其基类[page:Material]和[page:ShaderMaterial]。

    +

    共有属性请参见其基类[page:Material]。

    [property:Boolean transparent]

    定义此材质是否透明。默认值为 *true*。

    方法(Methods)

    -

    共有方法请参见其基类[page:Material]和[page:ShaderMaterial]。

    +

    共有方法请参见其基类[page:Material]。

    源码(Source)

    diff --git a/docs/api/zh/materials/SpriteMaterial.html b/docs/api/zh/materials/SpriteMaterial.html index c3de04d2e67300..abb118ee166c8b 100644 --- a/docs/api/zh/materials/SpriteMaterial.html +++ b/docs/api/zh/materials/SpriteMaterial.html @@ -1,5 +1,5 @@ - + @@ -14,26 +14,28 @@

    点精灵材质([name])

    一种使用[page:Sprite]的材质。

    -

    例子(Examples)

    -
    - [example:webgl_sprites WebGL / sprites]
    - [example:software_sandbox software / sandbox]
    - [example:svg_sandbox svg / sandbox]
    - [example:webgl_materials_cubemap_dynamic webgl / materials / cubemap / dynamic] -
    +

    代码示例

    -var spriteMap = new THREE.TextureLoader().load( 'textures/sprite.png' ); - -var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); + var spriteMap = new THREE.TextureLoader().load( 'textures/sprite.png' ); -var sprite = new THREE.Sprite( spriteMaterial ); -sprite.scale.set(200, 200, 1) + var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); -scene.add( sprite ); + var sprite = new THREE.Sprite( spriteMaterial ); + sprite.scale.set(200, 200, 1) + scene.add( sprite ); +

    例子

    +

    + [example:webgl_sprites WebGL / sprites]
    + [example:software_sandbox software / sandbox]
    + [example:svg_sandbox svg / sandbox]
    + [example:webgl_materials_cubemap_dynamic webgl / materials / cubemap / dynamic] +

    + +

    构造函数(Constructor)

    [name]( [param:Object parameters] )

    diff --git a/docs/api/zh/math/Box2.html b/docs/api/zh/math/Box2.html index e2c5e124b9130a..6aaafb514cb1a7 100644 --- a/docs/api/zh/math/Box2.html +++ b/docs/api/zh/math/Box2.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Box3.html b/docs/api/zh/math/Box3.html index 46520cf6addb81..12bd5bc5cf0bba 100644 --- a/docs/api/zh/math/Box3.html +++ b/docs/api/zh/math/Box3.html @@ -1,5 +1,5 @@ - + @@ -14,23 +14,24 @@

    [name]

    在3D空间中表示一个盒子或立方体。其主要用于表示物体在世界坐标中的边界框。

    -

    示例

    +

    代码示例

    - // Creating the object whose bounding box we want to compute - var sphereObject = new THREE.Mesh( - new THREE.SphereGeometry(), - new THREE.MeshBasicMaterial( 0xff0000 ) + var box = new THREE.Box3(); + + var mesh = new THREE.Mesh( + new THREE.SphereBufferGeometry(), + new THREE.MeshBasicMaterial() ); - // Creating the actual bounding box with Box3 - sphereObject.geometry.computeBoundingBox(); - var box = sphereObject.geometry.boundingBox.clone(); + + // ensure the bounding box is computed for its geometry + // this should be done only once (assuming static geometries) + mesh.geometry.computeBoundingBox(); // ... - - // In the animation loop, to keep the bounding box updated after move/rotate/scale operations - sphereObject.updateMatrixWorld( true ); - box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld ); + + // in the animation loop, compute the current bounding box with the world matrix + box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );

    构造器(Constructor)

    diff --git a/docs/api/zh/math/Color.html b/docs/api/zh/math/Color.html index 58bfa354223c4f..8ee2289a0b57f7 100644 --- a/docs/api/zh/math/Color.html +++ b/docs/api/zh/math/Color.html @@ -1,5 +1,5 @@ - + @@ -15,28 +15,28 @@

    颜色([name])

    -

    示例(Examples)

    +

    代码示例

    颜色可以用以下任意一种方式初始化。 -//empty constructor - will default white -var color = new THREE.Color(); + //empty constructor - will default white + var color = new THREE.Color(); -//Hexadecimal color (recommended) -var color = new THREE.Color( 0xff0000 ); + //Hexadecimal color (recommended) + var color = new THREE.Color( 0xff0000 ); -//RGB string -var color = new THREE.Color("rgb(255, 0, 0)"); -var color = new THREE.Color("rgb(100%, 0%, 0%)"); + //RGB string + var color = new THREE.Color("rgb(255, 0, 0)"); + var color = new THREE.Color("rgb(100%, 0%, 0%)"); -//X11 color name - all 140 color names are supported. -//Note the lack of CamelCase in the name -var color = new THREE.Color( 'skyblue' ); + //X11 color name - all 140 color names are supported. + //Note the lack of CamelCase in the name + var color = new THREE.Color( 'skyblue' ); -//HSL string -var color = new THREE.Color("hsl(0, 100%, 50%)"); + //HSL string + var color = new THREE.Color("hsl(0, 100%, 50%)"); -//Separate RGB values between 0 and 1 -var color = new THREE.Color( 1, 0, 0 ); + //Separate RGB values between 0 and 1 + var color = new THREE.Color( 1, 0, 0 ); @@ -119,7 +119,7 @@

    [method:Color convertGammaToLinear]( [param:Float gammaFactor] )

    [page:Float gammaFactor] - (可选参数). 默认值 *2.0*.

    通过取颜色 [page:.r r], [page:.g g] and [page:.b b] 的 [page:Float gammaFactor] 次方将颜色从伽马空间转换成线性空间。

    - +

    [method:Color convertLinearToGamma]( [param:Float gammaFactor] )

    [page:Float gammaFactor] - (可选参数). 默认值 *2.0*.

    diff --git a/docs/api/zh/math/Cylindrical.html b/docs/api/zh/math/Cylindrical.html index 2b916694a4b4a5..f2d67b548b4bfc 100644 --- a/docs/api/zh/math/Cylindrical.html +++ b/docs/api/zh/math/Cylindrical.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Euler.html b/docs/api/zh/math/Euler.html index 77a7ec267cf0fe..018cbe1883f49d 100644 --- a/docs/api/zh/math/Euler.html +++ b/docs/api/zh/math/Euler.html @@ -1,5 +1,5 @@ - + @@ -15,9 +15,10 @@

    欧拉角([name])

    欧拉角描述一个旋转变换,通过指定轴顺序和其各个轴向上的指定旋转角度来旋转一个物体。

    -

    示例(Example)

    +

    代码示例

    - var a = new THREE.Euler( 0, 1, 1.57, 'XYZ' ); + + var a = new THREE.Euler( 0, 1, 1.57, 'XYZ' ); var b = new THREE.Vector3( 1, 0, 1 ); b.applyEuler(a); @@ -77,7 +78,7 @@

    [method:Boolean equals]( [param:Euler euler] )

    [method:Euler fromArray]( [param:Array array] )

    长度为3或4的一个 [page:Array array] 。array[3] 是一个可选的 [page:.order order] 参数。

    - + 将欧拉角的x分量设置为 array[0]。
    将欧拉角的x分量设置为 array[1]。
    将欧拉角的x分量设置为 array[2]。
    diff --git a/docs/api/zh/math/Frustum.html b/docs/api/zh/math/Frustum.html index 61d7bc43e6da00..2fe4c8e8ed2fdf 100644 --- a/docs/api/zh/math/Frustum.html +++ b/docs/api/zh/math/Frustum.html @@ -1,5 +1,5 @@ - + @@ -86,29 +86,17 @@

    [method:Boolean intersectsSprite]( [param:Sprite sprite] )

    检查精灵[page:Sprite sprite]是否与截锥体相交。

    -

    [method:Frustum set]( [param:Plane p0], [param:Plane p1], [param:Plane p2], [param:Plane p3], [param:Plane p4], [param:Plane p5] )

    +

    [method:this set]( [param:Plane p0], [param:Plane p1], [param:Plane p2], [param:Plane p3], [param:Plane p4], [param:Plane p5] )

    - 使用传入的平面设置当前视锥体。没有隐式的顺序。 + Sets the frustum from the passed planes. No plane order is implied.
    + Note that this method only copies the values from the given objects.

    -

    [method:Frustum setFromMatrix]( [param:Matrix4 matrix] )

    +

    [method:this setFromProjectionMatrix]( [param:Matrix4 matrix] )

    - [page:Matrix4 matrix] - [page:Matrix4] 用于设置 [page:.planes planes]

    - - [page:WebGLRenderer] 使用 [page:Camera Camera]的投影矩阵([page:Camera.projectionMatrix projectionMatrix] ) - 和相机世界变换矩阵的逆矩阵 [page:Camera.matrixWorldInverse matrixWorldInverse] 来设置视锥体。 -

    - - - - - - - - - - - + [page:Matrix4 matrix] - Projection [page:Matrix4] used to set the [page:.planes planes]

    + Sets the frustum planes from the projection matrix. +

    Source

    diff --git a/docs/api/zh/math/Interpolant.html b/docs/api/zh/math/Interpolant.html index 79b775da60756d..e79a1f3fb000ef 100644 --- a/docs/api/zh/math/Interpolant.html +++ b/docs/api/zh/math/Interpolant.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Line3.html b/docs/api/zh/math/Line3.html index eaeac0e4245d96..c5e768320effb0 100644 --- a/docs/api/zh/math/Line3.html +++ b/docs/api/zh/math/Line3.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Math.html b/docs/api/zh/math/MathUtils.html similarity index 81% rename from docs/api/zh/math/Math.html rename to docs/api/zh/math/MathUtils.html index c0e736404f3aa6..5f02b360763b00 100644 --- a/docs/api/zh/math/Math.html +++ b/docs/api/zh/math/MathUtils.html @@ -1,5 +1,5 @@ - + @@ -100,6 +100,19 @@

    [method:Float smootherstep]( [param:Float x], [param:Float min], [param:Floa 返回一个0-1之间的值。它和smoothstep相同,但变动更平缓。[link:https://en.wikipedia.org/wiki/Smoothstep#Variations variation on smoothstep] 在x=0和x=1处有0阶和二阶导数。

    +

    [method:null setQuaternionFromProperEuler]( [param:Quaternion q], [param:Float a], [param:Float b], [param:Float c], [param:String order] )

    +

    + [page:Quaternion q] - the quaternion to be set
    + [page:Float a] - the rotation applied to the first axis, in radians
    + [page:Float b] - the rotation applied to the second axis, in radians
    + [page:Float c] - the rotation applied to the third axis, in radians
    + [page:String order] - a string specifying the axes order: 'XYX', 'XZX', 'YXY', 'YZY', 'ZXZ', or 'ZYZ'

    + + Sets quaternion [page:Quaternion q] from the [link:http://en.wikipedia.org/wiki/Euler_angles intrinsic Proper Euler Angles] defined by angles [page:Float a], [page:Float b], and [page:Float c], and order [page:String order].
    + + Rotations are applied to the axes in the order specified by [page:String order]: rotation by angle [page:Float a] is applied first, then by angle [page:Float b], then by angle [page:Float c]. Angles are in radians. +

    +

    Source

    diff --git a/docs/api/zh/math/Matrix3.html b/docs/api/zh/math/Matrix3.html index 0f99e089766d11..49f4e7bfc07111 100644 --- a/docs/api/zh/math/Matrix3.html +++ b/docs/api/zh/math/Matrix3.html @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@

    三维矩阵([name])

    一个表示3X3矩阵[link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].的类。

    -

    示例(Example)

    +

    代码示例

    var m = new Matrix3(); @@ -62,14 +62,6 @@

    [property:Array elements]

    方法(Methods)

    -

    [method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )

    -

    - [page:BufferAttribute attribute] - 表示三维向量缓存属性。

    - - 用这个矩阵乘以缓存属性[page:BufferAttribute attribute]里的所有3d向量。 -

    - -

    [method:Matrix3 clone]()

    创建一个新的矩阵,元素 [page:.elements elements] 与该矩阵相同。

    @@ -84,6 +76,23 @@

    [method:Float determinant]()

    [method:Boolean equals]( [param:Matrix3 m] )

    如果矩阵[page:Matrix3 m] 与当前矩阵所有对应元素相同则返回true。

    +

    [method:this extractBasis]( [param:Vector3 xAxis], [param:Vector3 yAxis], [param:Vector3 zAxis] )

    +

    + Extracts the [link:https://en.wikipedia.org/wiki/Basis_(linear_algebra) basis] of this + matrix into the three axis vectors provided. If this matrix is: + +a, b, c, +d, e, f, +g, h, i + + then the [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] will be set to: + +xAxis = (a, d, g) +yAxis = (b, e, h) +zAxis = (c, f, i) + +

    +

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    [page:Array array] - 用来存储设置元素数据的数组
    @@ -92,14 +101,14 @@

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    使用基于列优先格式[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]的数组来设置该矩阵。

    -

    [method:this getInverse]( [param:Matrix3 m], [param:Boolean throwOnDegenerate] )

    +

    [method:this getInverse]( [param:Matrix3 m] )

    - [page:Matrix3 m] - 取逆的矩阵。
    - [page:Boolean throwOnDegenerate] - (optional) 如果设置为true,如果矩阵是退化的(如果不可逆的话),则会抛出一个错误。

    + [page:Matrix3 m] - 取逆的矩阵。

    + + Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix3 m], + using the [link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method]. - 使用逆矩阵计算方法[link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method], - 将当前矩阵设置为给定矩阵的逆矩阵[link:https://en.wikipedia.org/wiki/Invertible_matrix inverse],如果[page:Boolean throwOnDegenerate] - 参数没有设置且给定矩阵不可逆,那么将当前矩阵设置为3X3单位矩阵。 + You can not invert a matrix with a determinant of zero. If you attempt this, the method returns a zero matrix instead.

    [method:this getNormalMatrix]( [param:Matrix4 m] )

    diff --git a/docs/api/zh/math/Matrix4.html b/docs/api/zh/math/Matrix4.html index ce0322bdeec638..88f8e71a1de404 100644 --- a/docs/api/zh/math/Matrix4.html +++ b/docs/api/zh/math/Matrix4.html @@ -1,5 +1,5 @@ - + @@ -71,6 +71,24 @@

    注意行优先列优先的顺序。

    请记住,如果您正在阅读源代码,您必须对这里列出的任何矩阵进行转置[link:https://en.wikipedia.org/wiki/Transpose transpose],以理解计算。

    +

    Extracting position, rotation and scale

    +

    + There are several options available for extracting position, rotation and scale from a Matrix4. +

      +
    • + [page:Vector3.setFromMatrixPosition]: can be used to extract the translation component. +
    • +
    • + [page:Vector3.setFromMatrixScale]: can be used to extract the scale component. +
    • +
    • + [page:Quaternion.setFromRotationMatrix], [page:Euler.setFromRotationMatrix] or [page:.extractRotation extractRotation] can be used to extract the rotation component. +
    • +
    • + [page:.decompose decompose] can be used to extract position, rotation and scale all at once. +
    • +
    +

    构造器(Constructor)

    @@ -93,14 +111,6 @@

    [property:Array elements]

    方法(Methods)

    -

    [method:Array applyToBufferAttribute]( [param:BufferAttribute attribute] )

    -

    - [page:BufferAttribute attribute] - 表示三维向量缓存属性。

    - - 用这个矩阵乘以缓存属性[page:BufferAttribute attribute]里的所有3d向量。 -

    - -

    [method:Matrix4 clone]()

    创建一个新的矩阵,元素[page:.elements elements]与该矩阵相同。

    @@ -165,16 +175,15 @@

    [method:this fromArray]( [param:Array array], [param:Integer offset] )

    使用基于列优先格式[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major]的数组来设置该矩阵。

    -

    [method:this getInverse]( [param:Matrix4 m], [param:Boolean throwOnDegenerate] )

    +

    [method:this getInverse]( [param:Matrix4 m] )

    - [page:Matrix3 m] - 取逆的矩阵。
    - [page:Boolean throwOnDegenerate] - (optional) 如果设置为true,如果矩阵是退化的(如果不可逆的话),则会抛出一个错误。

    + [page:Matrix3 m] - 取逆的矩阵。

    - 使用逆矩阵计算方法[link:https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution analytic method], - 将当前矩阵设置为给定矩阵的逆矩阵[link:https://en.wikipedia.org/wiki/Invertible_matrix inverse],如果[page:Boolean throwOnDegenerate] - 参数没有设置且给定矩阵不可逆,那么将当前矩阵设置为3X3单位矩阵。 -

    + Set this matrix to the [link:https://en.wikipedia.org/wiki/Invertible_matrix inverse] of the passed matrix [page:Matrix4 m], + using the method outlined [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm here]. + You can not invert a matrix with a determinant of zero. If you attempt this, the method returns a zero matrix instead. +

    [method:Float getMaxScaleOnAxis]()

    获取3个轴方向的最大缩放值。

    diff --git a/docs/api/zh/math/Plane.html b/docs/api/zh/math/Plane.html index 8697ce2653a34a..6bd76f7f64bcd7 100644 --- a/docs/api/zh/math/Plane.html +++ b/docs/api/zh/math/Plane.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Quaternion.html b/docs/api/zh/math/Quaternion.html index 50aa96f37f816a..a3465732d9aafa 100644 --- a/docs/api/zh/math/Quaternion.html +++ b/docs/api/zh/math/Quaternion.html @@ -1,5 +1,5 @@ - + @@ -11,15 +11,11 @@

    [name]

    - Implementation of a [link:http://en.wikipedia.org/wiki/Quaternion quaternion]. - This is used for [link:https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation rotating things] - without encountering the dreaded - [link:http://en.wikipedia.org/wiki/Gimbal_lock gimbal lock] issue, amongst other - advantages. + Implementation of a [link:http://en.wikipedia.org/wiki/Quaternion quaternion].
    + Quaternions are used in three.js to represent [link:https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation rotations].

    - -

    Example

    +

    代码示例

    var quaternion = new THREE.Quaternion(); @@ -113,7 +109,7 @@

    [method:Float length]()

    [method:Float lengthSq]()

    - Computes the [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] + Computes the squared [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] (straight-line length) of this quaternion, considered as a 4 dimensional vector. This can be useful if you are comparing the lengths of two quaternions, as this is a slightly more efficient calculation than [page:.length length](). @@ -199,6 +195,14 @@

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    Returns the numerical elements of this quaternion in an array of format [x, y, z, w].

    +

    [method:this fromBufferAttribute]( [param:BufferAttribute attribute], [param:Integer index] )

    +

    + [page:BufferAttribute attribute] - the source attribute.
    + [page:Integer index] - index in the attribute.

    + + Sets [page:.x x], [page:.y y], [page:.z z], [page:.w w] properties of this quaternion from the [page:BufferAttribute attribute]. +

    +

    Static Methods

    diff --git a/docs/api/zh/math/Ray.html b/docs/api/zh/math/Ray.html index fcc7356d5fec0d..aa2924d0b2dc4c 100644 --- a/docs/api/zh/math/Ray.html +++ b/docs/api/zh/math/Ray.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Sphere.html b/docs/api/zh/math/Sphere.html index b73ac6e9b8a8aa..d6d81712aeac75 100644 --- a/docs/api/zh/math/Sphere.html +++ b/docs/api/zh/math/Sphere.html @@ -1,5 +1,5 @@ - + @@ -70,8 +70,14 @@

    [method:Float distanceToPoint]( [param:Vector3 point] )

    若这个点,则距离将为负值。

    -

    [method:Boolean empty]()

    -

    检查球是否为空(其半径设为了0).

    +

    [method:Boolean isEmpty]()

    +

    + 检查球是否为空(the radius set to a negative number). + Spheres with a radius of 0 contain only their center point and are not considered to be empty. +

    + +

    [method:Sphere makeEmpty]()

    +

    Makes the sphere empty by setting [page:.center center] to (0, 0, 0) and [page:.radius radius] to -1.

    [method:Boolean equals]( [param:Sphere sphere] )

    diff --git a/docs/api/zh/math/Spherical.html b/docs/api/zh/math/Spherical.html index f449aa6bd3f2a0..42f08210d156e8 100644 --- a/docs/api/zh/math/Spherical.html +++ b/docs/api/zh/math/Spherical.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Triangle.html b/docs/api/zh/math/Triangle.html index 6e5b59462f1af9..76ff942af4e11c 100644 --- a/docs/api/zh/math/Triangle.html +++ b/docs/api/zh/math/Triangle.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/math/Vector2.html b/docs/api/zh/math/Vector2.html index ab45aa9f97c023..4e9dd13117bd13 100644 --- a/docs/api/zh/math/Vector2.html +++ b/docs/api/zh/math/Vector2.html @@ -1,5 +1,5 @@ - + @@ -34,8 +34,7 @@

    二维向量([name])

    其他的一些事物也可以使用二维向量进行表示,比如说动量矢量、复数等等;但以上这些是它在three.js中的常用用途。

    -

    示例

    - +

    代码示例

    var a = new THREE.Vector2( 0, 1 ); @@ -171,7 +170,7 @@

    [method:Float dot]( [param:Vector2 v] )

    [method:Float cross]( [param:Vector2 v] )

    - 计算该vector和所传入[page:Vector2 v]的叉积([link:https://en.wikipedia.org/wiki/Cross_product cross product])。 + 计算该vector和所传入[page:Vector2 v]的叉积([link:https://en.wikipedia.org/wiki/Cross_product cross product])。 请注意,“叉积”在2D中并没有被明确定义。该函数计算的是2D图形中经常使用的几何叉积。

    @@ -196,7 +195,7 @@

    [method:this fromBufferAttribute]( [param:BufferAttribute attribute], [param [page:BufferAttribute attribute] - 来源的attribute。
    [page:Integer index] - 在attribute中的索引。

    - 从[page:BufferAttribute attribute]中设置向量的[page:.x x]值和[page:.y y]值。 + 从[page:BufferAttribute attribute]中设置向量的[page:.x x]值和[page:.y y]值。 、

    [method:Float getComponent]( [param:Integer index] )

    @@ -280,7 +279,7 @@

    [method:this rotateAround]( [param:Vector2 center], [param:float angle] )

    [method:this round]()

    -

    +

    向量中的[page:.x x]分量和[page:.y y]分量四舍五入取整为最接近的整数值。

    @@ -334,10 +333,15 @@

    [method:Array toArray]( [param:Array array], [param:Integer offset] )

    返回一个数组[x, y],或者将x和y复制到所传入的[page:Array array]中。

    +

    [method:this random]()

    +

    + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

    +

    源代码

    [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]

    - \ No newline at end of file + diff --git a/docs/api/zh/math/Vector3.html b/docs/api/zh/math/Vector3.html index 98321d5e919dab..90c0983dbec1c1 100644 --- a/docs/api/zh/math/Vector3.html +++ b/docs/api/zh/math/Vector3.html @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@

    三维向量([name])

    一个三维向量表示的是一个有顺序的、三个为一组的数字组合(标记为x、y和z), 可被用来表示很多事物,例如: - +

      @@ -36,16 +36,15 @@

      三维向量([name])

      但以上这些是它在three.js中的常用用途。

      - -

      示例

      +

      代码示例

      -var a = new THREE.Vector3( 0, 1, 0 ); + var a = new THREE.Vector3( 0, 1, 0 ); -//no arguments; will be initialised to (0, 0, 0) -var b = new THREE.Vector3( ); + //no arguments; will be initialised to (0, 0, 0) + var b = new THREE.Vector3( ); -var d = a.distanceTo( b ); + var d = a.distanceTo( b ); @@ -114,7 +113,7 @@

      [method:this applyQuaternion]( [param:Quaternion quaternion] )

      [method:Float angleTo]( [param:Vector3 v] )

      - 以弧度返回该向量与向量[page:Vector3 v]之间的角度。 Neither this vector nor [page:Vector3 v] can be the zero vector. + 以弧度返回该向量与向量[page:Vector3 v]之间的角度。

      [method:this ceil]()

      @@ -301,7 +300,7 @@

      [method:this project]( [param:Camera camera] )

      [page:Camera camera] — 在投影中使用的摄像机。

      - 使用所传入的摄像机来投影([link:https://en.wikipedia.org/wiki/Vector_projection projects])该向量。 + Projects this vector from world space into the camera's normalized device coordinate (NDC) space.

      [method:this projectOnPlane]( [param:Vector3 planeNormal] )

      @@ -313,13 +312,13 @@

      [method:this projectOnPlane]( [param:Vector3 planeNormal] )

      [method:this projectOnVector]( [param:Vector3] )

      -

      投影([link:https://en.wikipedia.org/wiki/Vector_projection Projects])该向量到向量[page:Vector3 v]上。[page:Vector3 v]不能是零向量。

      +

      投影([link:https://en.wikipedia.org/wiki/Vector_projection Projects])该向量到向量[page:Vector3 v]上。

      [method:this reflect]( [param:Vector3 normal] )

      [page:Vector3 normal] - the normal to the reflecting plane

      - Reflect the vector off of plane orthogonal to [page:Vector3 normal]. Normal is assumed to + Reflect this vector off of plane orthogonal to [page:Vector3 normal]. Normal is assumed to have unit length.

      @@ -424,10 +423,13 @@

      [method:this unproject]( [param:Camera camera] )

      [page:Camera camera] — 在投影中使用的摄像机。

      - [link:https://en.wikipedia.org/wiki/Vector_projection Unprojects] the vector with the - camera's projection matrix. + Projects this vector from the camera's normalized device coordinate (NDC) space into world space.

      +

      [method:this random]()

      +

      + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

      源代码

      diff --git a/docs/api/zh/math/Vector4.html b/docs/api/zh/math/Vector4.html index 2b3e27c571d7f2..bed9bc1f2caa78 100644 --- a/docs/api/zh/math/Vector4.html +++ b/docs/api/zh/math/Vector4.html @@ -1,5 +1,5 @@ - + @@ -35,16 +35,15 @@

      四维向量([name])

      其他的一些事物也可以使用四维向量进行表示,但以上这些是它在three.js中的常用用途。

      - -

      示例

      +

      代码示例

      -var a = new THREE.Vector4( 0, 1, 0, 0 ); + var a = new THREE.Vector4( 0, 1, 0, 0 ); -//no arguments; will be initialised to (0, 0, 0, 1) -var b = new THREE.Vector4( ); + //no arguments; will be initialised to (0, 0, 0, 1) + var b = new THREE.Vector4( ); -var d = a.dot( b ); + var d = a.dot( b ); @@ -323,6 +322,11 @@

      [method:Array toArray]( [param:Array array], [param:Integer offset] )

      返回一个数组[x, y, z, w],或者将x、y、z和w复制到所传入的[page:Array array]中。

      +

      [method:this random]()

      +

      + Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1. +

      +

      源代码

      diff --git a/docs/api/zh/math/interpolants/CubicInterpolant.html b/docs/api/zh/math/interpolants/CubicInterpolant.html index 6811554f8b7be2..af5b02079e6834 100644 --- a/docs/api/zh/math/interpolants/CubicInterpolant.html +++ b/docs/api/zh/math/interpolants/CubicInterpolant.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

      三次插值([name])

      -

      例子(Example)

      +

      代码示例

      var interpolant = new THREE.[name]( diff --git a/docs/api/zh/math/interpolants/DiscreteInterpolant.html b/docs/api/zh/math/interpolants/DiscreteInterpolant.html index e45c6bc833d71c..93d43134c57cac 100644 --- a/docs/api/zh/math/interpolants/DiscreteInterpolant.html +++ b/docs/api/zh/math/interpolants/DiscreteInterpolant.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

      离散插值([name])

      -

      例子(Example)

      +

      代码示例

      var interpolant = new THREE.[name]( diff --git a/docs/api/zh/math/interpolants/LinearInterpolant.html b/docs/api/zh/math/interpolants/LinearInterpolant.html index 692a8f077439fd..5e64a9420940d8 100644 --- a/docs/api/zh/math/interpolants/LinearInterpolant.html +++ b/docs/api/zh/math/interpolants/LinearInterpolant.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

      线性插值([name])

      -

      例子(Example)

      +

      代码示例

      var interpolant = new THREE.[name]( diff --git a/docs/api/zh/math/interpolants/QuaternionLinearInterpolant.html b/docs/api/zh/math/interpolants/QuaternionLinearInterpolant.html index 3e3a4ba4b25372..b9acc7567cf88e 100644 --- a/docs/api/zh/math/interpolants/QuaternionLinearInterpolant.html +++ b/docs/api/zh/math/interpolants/QuaternionLinearInterpolant.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

      四元数线性插值([name])

      -

      例子(Example)

      +

      代码示例

      var interpolant = new THREE.[name]( diff --git a/docs/api/zh/objects/Bone.html b/docs/api/zh/objects/Bone.html index f45503f96f5c08..eee42ca11ce478 100644 --- a/docs/api/zh/objects/Bone.html +++ b/docs/api/zh/objects/Bone.html @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@

      骨骼([name])

      骨骼几乎和空白[page:Object3D]相同。

      -

      示例

      +

      代码示例

      var root = new THREE.Bone(); diff --git a/docs/api/zh/objects/Group.html b/docs/api/zh/objects/Group.html index 2cbb4598eb1e25..dbf3b306e4fc8c 100644 --- a/docs/api/zh/objects/Group.html +++ b/docs/api/zh/objects/Group.html @@ -1,5 +1,5 @@ - + @@ -16,8 +16,7 @@

      组([name])

      它几乎和[page:Object3D Object3D]是相同的,其目的是使得组中对象在语法上的结构更加清晰。

      - -

      示例

      +

      代码示例

      var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); diff --git a/docs/api/zh/objects/InstancedMesh.html b/docs/api/zh/objects/InstancedMesh.html index a58354fe1ad810..69d3d407e0cbde 100644 --- a/docs/api/zh/objects/InstancedMesh.html +++ b/docs/api/zh/objects/InstancedMesh.html @@ -1,5 +1,5 @@ - + @@ -17,11 +17,18 @@

      [name]

      objects with the same geometry and material but with different world transformations. The usage of [name] will help you to reduce the number of draw calls and thus improve the overall rendering performance in your application.

      +

      + The current implementation requires that materials are not shared between [name] and other 3D objects. +

      -

      Example

      +

      Examples

      - [example:webgl_instancing_suzanne WebGL / instancing / suzanne]
      + [example:webgl_instancing_dynamic WebGL / instancing / dynamic]
      + [example:webgl_instancing_modified WebGL / instancing / modified]
      + [example:webgl_instancing_performance WebGL / instancing / performance]
      + [example:webgl_instancing_scatter WebGL / instancing / scatter]
      + [example:webgl_instancing_raycast WebGL / instancing / raycast]

      Constructor

      @@ -47,9 +54,11 @@

      [property:Integer count]

      [property:BufferAttribute instanceMatrix]

      - Represents the local transformation of all instances. For internal use only. + Represents the local transformation of all instances. + You have to set its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify instanced data via [page:.setMatrixAt]().

      +

      Methods

      See the base [page:Mesh] class for common methods.

      diff --git a/docs/api/zh/objects/LOD.html b/docs/api/zh/objects/LOD.html index 7dc36cfa89c8ac..19a7663f6dc6b3 100644 --- a/docs/api/zh/objects/LOD.html +++ b/docs/api/zh/objects/LOD.html @@ -1,5 +1,5 @@ - + @@ -18,29 +18,31 @@

      多细节层次([name],Levels of Detail)

      通常情况下,你会创建多个几何体,比如说三个,一个距离很远(低细节),一个距离适中(中等细节),还有一个距离非常近(高质量)。

      -

      示例

      - -

      - [example:webgl_lod webgl / lod ] -

      +

      代码示例

      -var lod = new THREE.LOD(); + var lod = new THREE.LOD(); -//Create spheres with 3 levels of detail and create new LOD levels for them -for( var i = 0; i < 3; i++ ) { + //Create spheres with 3 levels of detail and create new LOD levels for them + for( var i = 0; i < 3; i++ ) { - var geometry = new THREE.IcosahedronBufferGeometry( 10, 3 - i ) + var geometry = new THREE.IcosahedronBufferGeometry( 10, 3 - i ) - var mesh = new THREE.Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, material ); - lod.addLevel( mesh, i * 75 ); + lod.addLevel( mesh, i * 75 ); -} + } -scene.add( lod ); + scene.add( lod ); +

      例子

      + +

      + [example:webgl_lod webgl / lod ] +

      +

      Constructor

      [name]( )

      diff --git a/docs/api/zh/objects/Line.html b/docs/api/zh/objects/Line.html index 0dd4148a7488c9..9a2169d37b6fac 100644 --- a/docs/api/zh/objects/Line.html +++ b/docs/api/zh/objects/Line.html @@ -1,5 +1,5 @@ - + @@ -19,19 +19,19 @@

      线([name])

      而不是[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawElements gl.LINES]。

      +

      代码示例

      -

      示例

      - - var material = new THREE.LineBasicMaterial({ + + var material = new THREE.LineBasicMaterial({ color: 0x0000ff }); - var geometry = new THREE.Geometry(); - geometry.vertices.push( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( 0, 10, 0 ), - new THREE.Vector3( 10, 0, 0 ) - ); + var points = []; + points.push( new THREE.Vector3( - 10, 0, 0 ) ); + points.push( new THREE.Vector3( 0, 10, 0 ) ); + points.push( new THREE.Vector3( 10, 0, 0 ) ); + + var geometry = new THREE.BufferGeometry().setFromPoints( points ); var line = new THREE.Line( geometry, material ); scene.add( line ); @@ -47,9 +47,6 @@

      [name]( [param:Geometry geometry], [param:Material material] )

      [page:Material material] —— 线的材质,默认值是一个新的具有随机颜色的[page:LineBasicMaterial]。

      -

      如果没有指定材质,一个随机颜色的线的材质将会被创建,并应用到该物体上。

      - -

      属性

      共有属性请参见其基类[page:Object3D]。

      diff --git a/docs/api/zh/objects/LineLoop.html b/docs/api/zh/objects/LineLoop.html index 0e1869f53410ad..a4e57a2345051e 100644 --- a/docs/api/zh/objects/LineLoop.html +++ b/docs/api/zh/objects/LineLoop.html @@ -1,5 +1,5 @@ - + @@ -29,9 +29,6 @@

      [name]( [param:Geometry geometry], [param:Material material] )

      [page:Material material] —— 线的材质,默认值是[page:LineBasicMaterial LineBasicMaterial]。

      -

      如果没有指定材质,一个随机颜色的线的材质将会被创建,并应用到该物体上。

      - -

      属性

      共有属性请参见其基类[page:Line]。

      diff --git a/docs/api/zh/objects/LineSegments.html b/docs/api/zh/objects/LineSegments.html index f7ae3fb8963e39..6ab4cac49abe6e 100644 --- a/docs/api/zh/objects/LineSegments.html +++ b/docs/api/zh/objects/LineSegments.html @@ -1,5 +1,5 @@ - + @@ -28,9 +28,6 @@

      [name]( [param:Geometry geometry], [param:Material material] )

      [page:Material material] —— 线的材质,默认值是[page:LineBasicMaterial LineBasicMaterial]。

      -

      如果没有指定材质,一个随机颜色的线的材质将会被创建,并应用到该物体上。

      - -

      属性

      共有属性请参见其基类[page:Line]。

      diff --git a/docs/api/zh/objects/Mesh.html b/docs/api/zh/objects/Mesh.html index 32a0815ec01bfc..ddea408437b287 100644 --- a/docs/api/zh/objects/Mesh.html +++ b/docs/api/zh/objects/Mesh.html @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@

      网格([name])

      -

      示例

      +

      代码示例

      var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); diff --git a/docs/api/zh/objects/Points.html b/docs/api/zh/objects/Points.html index 19d3e384e79936..7cd71570d74b25 100644 --- a/docs/api/zh/objects/Points.html +++ b/docs/api/zh/objects/Points.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/objects/Skeleton.html b/docs/api/zh/objects/Skeleton.html index 2265e9dd5125e1..34fc391795653b 100644 --- a/docs/api/zh/objects/Skeleton.html +++ b/docs/api/zh/objects/Skeleton.html @@ -1,5 +1,5 @@ - + @@ -15,29 +15,30 @@

      骨架([name])

      使用一个[page:Bone bones]数组来创建一个可以由[page:SkinnedMesh]使用的骨架。

      -

      实例

      - -// Create a simple "arm" +

      代码示例

      + + // Create a simple "arm" -var bones = []; + var bones = []; -var shoulder = new THREE.Bone(); -var elbow = new THREE.Bone(); -var hand = new THREE.Bone(); + var shoulder = new THREE.Bone(); + var elbow = new THREE.Bone(); + var hand = new THREE.Bone(); -shoulder.add( elbow ); -elbow.add( hand ); + shoulder.add( elbow ); + elbow.add( hand ); -bones.push( shoulder ); -bones.push( elbow ); -bones.push( hand ); + bones.push( shoulder ); + bones.push( elbow ); + bones.push( hand ); -shoulder.position.y = -5; -elbow.position.y = 0; -hand.position.y = 5; + shoulder.position.y = -5; + elbow.position.y = 0; + hand.position.y = 5; + + var armSkeleton = new THREE.Skeleton( bones ); + -var armSkeleton = new THREE.Skeleton( bones ); -

      请查看[page:SkinnedMesh]页面,来查看其在标准的[page:BufferGeometry]中使用的示例。

      @@ -102,11 +103,16 @@

      [method:null update]()

      [method:Bone getBoneByName]( [param:String name] )

      - + name —— 匹配Bone对象中.name属性的字符串。

      在骨架中的骨骼数组中遍览,并返回第一个能够和name匹配上的骨骼对象。

      +

      [method:null dispose]()

      +

      + Can be used if an instance of [name] becomes obsolete in an application. The method will free internal resources. +

      +

      源代码

      diff --git a/docs/api/zh/objects/SkinnedMesh.html b/docs/api/zh/objects/SkinnedMesh.html index 279173b36a16c6..695e4eac648b6c 100644 --- a/docs/api/zh/objects/SkinnedMesh.html +++ b/docs/api/zh/objects/SkinnedMesh.html @@ -1,5 +1,5 @@ - + @@ -35,7 +35,7 @@

      蒙皮网格([name])

      -

      示例

      +

      代码示例

      var geometry = new THREE.CylinderBufferGeometry( 5, 5, 5, 5, 15, 5, 30 ); diff --git a/docs/api/zh/objects/Sprite.html b/docs/api/zh/objects/Sprite.html index 2644d91b39d268..52b9cf4456aafe 100644 --- a/docs/api/zh/objects/Sprite.html +++ b/docs/api/zh/objects/Sprite.html @@ -1,5 +1,5 @@ - + @@ -17,11 +17,11 @@

      精灵([name])

      精灵不会投射任何阴影,即使设置了castShadow = true也将不会有任何效果。

      -

      示例

      +

      代码示例

      var spriteMap = new THREE.TextureLoader().load( "sprite.png" ); -var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } ); +var spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap } ); var sprite = new THREE.Sprite( spriteMaterial ); scene.add( sprite ); diff --git a/docs/api/zh/renderers/WebGLRenderTargetCube.html b/docs/api/zh/renderers/WebGLCubeRenderTarget.html similarity index 88% rename from docs/api/zh/renderers/WebGLRenderTargetCube.html rename to docs/api/zh/renderers/WebGLCubeRenderTarget.html index 2ba4ab51e2641f..9e27eeb02171a8 100644 --- a/docs/api/zh/renderers/WebGLRenderTargetCube.html +++ b/docs/api/zh/renderers/WebGLCubeRenderTarget.html @@ -1,5 +1,5 @@ - + @@ -24,10 +24,9 @@

      例子

      构造器

      -

      [name]([param:Number width], [param:Number height], [param:Object options])

      +

      [name]([param:Number size], [param:Object options])

      - [page:Float width] - renderTarget的宽度
      - [page:Float height] - renderTarget的高度
      + [page:Float size] - the size, in pixels.
      options - (可选)一个保存着自动生成的目标纹理的纹理参数以及表示是否使用深度缓存/模板缓存的布尔值的对象。 有关纹理参数的说明,请参阅[page:Texture Texture]. 以下是合理选项:

      @@ -54,7 +53,7 @@

      方法

      继承方法,请参阅[page:WebGLRenderTarget]

      -

      [method:WebGLRenderTargetCube fromEquirectangularTexture]( [param:WebGLRenderer renderer], [param:Texture texture] )

      +

      [method:WebGLCubeRenderTarget fromEquirectangularTexture]( [param:WebGLRenderer renderer], [param:Texture texture] )

      [page:WebGLRenderer renderer] — 渲染器。
      [page:Texture texture] — equirectangular 纹理。 diff --git a/docs/api/zh/renderers/WebGLMultisampleRenderTarget.html b/docs/api/zh/renderers/WebGLMultisampleRenderTarget.html index b5691980d9d550..abdff7cf302fe5 100644 --- a/docs/api/zh/renderers/WebGLMultisampleRenderTarget.html +++ b/docs/api/zh/renderers/WebGLMultisampleRenderTarget.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/WebGLRenderTarget.html b/docs/api/zh/renderers/WebGLRenderTarget.html index dbad6f3a64eeea..b89ed6adb975c2 100644 --- a/docs/api/zh/renderers/WebGLRenderTarget.html +++ b/docs/api/zh/renderers/WebGLRenderTarget.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/WebGLRenderer.html b/docs/api/zh/renderers/WebGLRenderer.html index 4bce08b1e1c456..e4b83fca391e92 100644 --- a/docs/api/zh/renderers/WebGLRenderer.html +++ b/docs/api/zh/renderers/WebGLRenderer.html @@ -1,5 +1,5 @@ - + @@ -145,6 +145,7 @@

      [property:Float gammaFactor]

      [property:number outputEncoding]

      Defines the output encoding of the renderer. Default is [page:Textures THREE.LinearEncoding].

      +

      If a render target has been set using [page:WebGLRenderer.setRenderTarget .setRenderTarget] then renderTarget.texture.encoding will be used instead.

      See the [page:Textures texture constants] page for details of other formats.

      [property:Object info]

      @@ -243,7 +244,7 @@

      [property:Object state]

      [property:Constant toneMapping]

      - 默认是[page:Renderer LinearToneMapping]。查看[page:Renderer Renderer constants]以获取其它备选项 + 默认是[page:Renderer NoToneMapping]。查看[page:Renderer Renderer constants]以获取其它备选项

      [property:Number toneMappingExposure]

      @@ -256,14 +257,9 @@

      [property:Number toneMappingWhitePoint]

      色调映射的白点。默认是*1*

      -

      [property:Object xr]

      +

      [property:WebXRManager xr]

      - Provides access to the WebXR related interface of the renderer. -

      - -

      [property:Boolean xr.enabled]

      -

      - Whether the renderer should enable XR rendering or not. Default is *false*. + Provides access to the WebXR related [page:WebXRManager interface] of the renderer.

      方法

      @@ -368,7 +364,7 @@

      [method:null readRenderTargetPixels]( [param:WebGLRenderTarget renderTarget]

      buffer - Uint8Array is the only destination type supported in all cases, other types are renderTarget and platform dependent. See [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.12 WebGL spec] for details.

      将enderTarget中的像素数据读取到传入的缓冲区中。这是[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/readPixels WebGLRenderingContext.readPixels]()的包装器
      示例:[example:webgl_interactive_cubes_gpu interactive / cubes / gpu]

      -

      For reading out a [page:WebGLRenderTargetCube WebGLRenderTargetCube] use the optional parameter activeCubeFaceIndex to determine which face should be read.

      +

      For reading out a [page:WebGLCubeRenderTarget WebGLCubeRenderTarget] use the optional parameter activeCubeFaceIndex to determine which face should be read.

      [method:null render]( [param:Scene scene], [param:Camera camera], [param:WebGLRenderTarget renderTarget], [param:Boolean forceClear] )

      @@ -384,12 +380,11 @@

      [method:null render]( [param:Scene scene], [param:Camera camera], [param:Web

      [method:null renderBufferDirect]( [param:Camera camera], [param:Fog fog], [param:Geometry geometry], [param:Material material], [param:Object3D object], [param:Object group] )

      使用相机和指定材质渲染缓冲几何组。

      -

      [method:null renderBufferImmediate]( [param:Object3D object], [param:shaderprogram program], [param:Material shading] )

      +

      [method:null renderBufferImmediate]( [param:Object3D object], [param:WebGLProgram program] )

      object - 一个[page:Object3D]实例
      - program - 一个shaderProgram实例
      - shading - 一个Material实例

      + program - 一个[page:WebGLProgram]实例
      - 渲染即使缓冲,由enderImmediateObject对象调用 + 渲染即使缓冲,由renderObjectImmediate对象调用

      [method:null setAnimationLoop]( [param:Function callback] )

      @@ -402,13 +397,16 @@

      [method:null setClearAlpha]( [param:Float alpha] )

      [method:null setClearColor]( [param:Color color], [param:Float alpha] )

      设置颜色及其透明度

      +

      [method:null setFramebuffer]( [param:WebGLFramebuffer value] )

      +

      Sets the given WebGLFramebuffer. This method can only be used if no render target is set via [page:WebGLRenderer.setRenderTarget .setRenderTarget]().

      +

      [method:null setPixelRatio]( [param:number value] )

      设置设备像素比。通常用于避免HiDPI设备上绘图模糊

      [method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipmapLevel] )

      renderTarget -- 需要被激活的[page:WebGLRenderTarget renderTarget](可选)。若此参数为空,则将canvas设置成活跃render target。
      - activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLRenderTargetCube] (optional).
      + activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLCubeRenderTarget] (optional).
      activeMipmapLevel -- Specifies the active mipmap level (optional).

      该方法设置活跃rendertarget。

      diff --git a/docs/api/zh/renderers/shaders/ShaderChunk.html b/docs/api/zh/renderers/shaders/ShaderChunk.html index d3e059aea45b8f..92c1eeb6c8dda2 100644 --- a/docs/api/zh/renderers/shaders/ShaderChunk.html +++ b/docs/api/zh/renderers/shaders/ShaderChunk.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/shaders/ShaderLib.html b/docs/api/zh/renderers/shaders/ShaderLib.html index e336826ec36ffd..050fb5ab58f3d7 100644 --- a/docs/api/zh/renderers/shaders/ShaderLib.html +++ b/docs/api/zh/renderers/shaders/ShaderLib.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/shaders/UniformsLib.html b/docs/api/zh/renderers/shaders/UniformsLib.html index 4f6c4ac6b69cdf..0b3a4b84e77a85 100644 --- a/docs/api/zh/renderers/shaders/UniformsLib.html +++ b/docs/api/zh/renderers/shaders/UniformsLib.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/shaders/UniformsUtils.html b/docs/api/zh/renderers/shaders/UniformsUtils.html index 8201da89c3720a..ce81f0614be5ce 100644 --- a/docs/api/zh/renderers/shaders/UniformsUtils.html +++ b/docs/api/zh/renderers/shaders/UniformsUtils.html @@ -1,5 +1,5 @@ - + @@ -12,13 +12,24 @@

      [name]

      Uniform工具. 支持uniform变量的合并和克隆

      -

      属性

      - +

      方法

      +

      [method:Object clone]( [param:Object src] )

      +

      + src -- An object representing uniform definitions.

      -

      方法

      + Clones the given uniform definitions by performing a deep-copy. That means if + the [page:Uniform.value value] of a uniform refers to an object like a [page:Vector3] + or [page:Texture], the cloned uniform will refer to a new object reference. +

      +

      [method:Object merge]( [param:Array uniforms] )

      +

      + uniforms -- An array of objects containing uniform definitions.

      + Merges the given uniform definitions into a single object. Since the method + internally uses [page:.clone](), it performs a deep-copy when producing the + merged uniform definitions.

      源码

      diff --git a/docs/api/zh/renderers/webgl/WebGLProgram.html b/docs/api/zh/renderers/webgl/WebGLProgram.html index 6b3b734efd0217..dde592dce14a17 100644 --- a/docs/api/zh/renderers/webgl/WebGLProgram.html +++ b/docs/api/zh/renderers/webgl/WebGLProgram.html @@ -1,5 +1,5 @@ - + @@ -105,28 +105,31 @@

      片元着色器:

      构造器

      -

      [name]( [param:WebGLRenderer renderer], [param:Object code], [param:Material material], [param:Object parameters] )

      -

      参数详见[page:WebGLRenderer WebGLRenderer]

      +

      [name]( [param:WebGLRenderer renderer], [param:String cacheKey], [param:Object parameters] )

      +

      参数详见[page:WebGLRenderer WebGLRenderer].

      属性

      +

      [property:String name]

      +

      The name of the respective shader program.

      +

      [property:String id]

      -

      +

      The identifier of this instance.

      -

      [property:String code]

      -

      +

      [property:String cacheKey]

      +

      This key enables the reusability of a single [name] for different materials.

      [property:Integer usedTimes]

      -

      +

      How many times this instance is used for rendering render items.

      [property:Object program]

      -

      +

      The actual shader program.

      [property:WebGLShader vertexShader]

      -

      +

      An instance of [page:WebGLShader] representing the vertex shader.

      [property:WebGLShader fragmentShader]

      -

      +

      An instance of [page:WebGLShader] representing the frament shader.

      方法

      @@ -140,6 +143,11 @@

      [method:Object getAttributes]()

      返回所有活动态的顶点属性位置的name-value映射

      +

      [method:null destroy]()

      +

      + Destroys an instance of [name]. +

      +

      源码

      diff --git a/docs/api/zh/renderers/webgl/WebGLShader.html b/docs/api/zh/renderers/webgl/WebGLShader.html index 0d93a72e973a0c..a66f21fa9f2f30 100644 --- a/docs/api/zh/renderers/webgl/WebGLShader.html +++ b/docs/api/zh/renderers/webgl/WebGLShader.html @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@

      [name]

      编译顶点或片元着色器的更底层的函数

      -

      示例

      +

      代码示例

      var gl = renderer.getContext(); diff --git a/docs/api/zh/renderers/webgl/WebGLState.html b/docs/api/zh/renderers/webgl/WebGLState.html index efb1bad0a85e4f..20cb1cf64af58d 100644 --- a/docs/api/zh/renderers/webgl/WebGLState.html +++ b/docs/api/zh/renderers/webgl/WebGLState.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/renderers/webxr/WebXRManager.html b/docs/api/zh/renderers/webxr/WebXRManager.html new file mode 100644 index 00000000000000..cc0cb2066ebe01 --- /dev/null +++ b/docs/api/zh/renderers/webxr/WebXRManager.html @@ -0,0 +1,90 @@ + + + + + + + + + + + +

      [name]

      + +

      + + This class represents an abstraction of the WebXR Device API and is internally used by [page:WebGLRenderer]. + [name] also provides a public interface that allows users to enable/disable XR and perform XR related tasks like + for instance retrieving controllers. +

      + +

      Properties

      + +

      [property:Boolean enabled]

      +

      + This flag notifies the renderer to be ready for XR rendering. Default is *false*. Set it to *true* if you are going + to use XR in your app. +

      + +

      [property:Boolean isPresenting]

      +

      + Whether XR presentation is active or not. Default is *false*. This flag is read-only and automatically set by [name]. +

      + +

      Methods

      + +

      [method:Group getController]( [param:Integer index] )

      +

      + [page:Integer index] — The index of the controller.

      + + Returns a [page:Group] representing the so called *target ray* space of the controller. + Use this space for visualizing 3D objects that support the user in pointing tasks like UI interaction. +

      + +

      [method:Group getControllerGrip]( [param:Integer index] )

      +

      + [page:Integer index] — The index of the controller.

      + + Returns a [page:Group] representing the so called *grip* space of the controller. + Use this space if the user is going to hold other 3D objects like a lightsaber. +

      + +

      + Note: If you want to show something in the user's hand AND offer a pointing ray at the same time, you'll want to attached the handheld object to the + group returned by [page:.getControllerGrip]() and the ray to the group returned by [page:.getController](). The idea is to have two different groups + in two different coordinate spaces for the same WebXR controller. +

      + +

      [method:void setFramebufferScaleFactor]( [param:Float framebufferScaleFactor] )

      +

      + [page:Float framebufferScaleFactor] — The framebuffer scale factor to set.

      + + Specifies the scaling factor to use when determining the size of the framebuffer when rendering to a XR device. + The value is relative to the default XR device display resolution. Default is *1*. A value of *0.5* would specify + a framebuffer with 50% of the display's native resolution. +

      + +

      + Note: It is not possible to change the framebuffer scale factor while presenting XR content. +

      + +

      [method:void setReferenceSpaceType]( [param:String referenceSpaceType] )

      +

      + [page:String referenceSpaceType] — The reference space type to set.

      + + Can be used to configure a spatial relationship with the user's physical environment. Depending on how the user moves in 3D space, setting an + appropriate reference space can improve tracking. Default is *local-floor*. + Please check out the [link:https://developer.mozilla.org/en-US/docs/Web/API/XRReferenceSpaceType MDN] for possible values and their use cases. +

      + +

      + Note: It is not possible to change the reference space type while presenting XR content. +

      + +

      Source

      + +

      + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] +

      + + diff --git a/docs/api/zh/scenes/Fog.html b/docs/api/zh/scenes/Fog.html index 3964d1570c5ece..82070d5da7374f 100644 --- a/docs/api/zh/scenes/Fog.html +++ b/docs/api/zh/scenes/Fog.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/scenes/FogExp2.html b/docs/api/zh/scenes/FogExp2.html index e307097d9e0d36..2cafa20ed8c3c2 100644 --- a/docs/api/zh/scenes/FogExp2.html +++ b/docs/api/zh/scenes/FogExp2.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/scenes/Scene.html b/docs/api/zh/scenes/Scene.html index 436b75264272c2..7b40a53a19d2e3 100644 --- a/docs/api/zh/scenes/Scene.html +++ b/docs/api/zh/scenes/Scene.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/textures/CanvasTexture.html b/docs/api/zh/textures/CanvasTexture.html index 42375eda6bf023..ccd93a7a2cf0e7 100644 --- a/docs/api/zh/textures/CanvasTexture.html +++ b/docs/api/zh/textures/CanvasTexture.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/textures/CompressedTexture.html b/docs/api/zh/textures/CompressedTexture.html index 2c122a5dfd7884..35cfcec0b97081 100644 --- a/docs/api/zh/textures/CompressedTexture.html +++ b/docs/api/zh/textures/CompressedTexture.html @@ -1,5 +1,5 @@ - + diff --git a/docs/api/zh/textures/CubeTexture.html b/docs/api/zh/textures/CubeTexture.html index 14ba4ef5ac57ab..351afaee263001 100644 --- a/docs/api/zh/textures/CubeTexture.html +++ b/docs/api/zh/textures/CubeTexture.html @@ -1,5 +1,5 @@ - + @@ -9,17 +9,17 @@ [page:Texture] → - +

      立方纹理([name])

      创建一个由6张图片所组成的纹理对象。

      -

      示例

      +

      代码示例

      var loader = new THREE.CubeTextureLoader(); loader.setPath( 'textures/cube/pisa/' ); - + var textureCube = loader.load( [ 'px.png', 'nx.png', 'py.png', 'ny.png', @@ -33,7 +33,7 @@

      构造函数

      [name]( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy )

      - +

      CubeTexture(立方贴图)的功能以及用法几乎和[page:Texture]是相同的。区别在于,CubeTexture中的图像是6个单独的图像所组成的数组, 纹理映射选项为[page:Textures THREE.CubeReflectionMapping](默认值)或[page:Textures THREE.CubeRefractionMapping]。 @@ -45,10 +45,10 @@

      属性

      请参阅[page:Texture]页面。

      方法

      - +

      请参阅[page:Texture]页面。

      - +

      源代码

      diff --git a/docs/api/zh/textures/DataTexture.html b/docs/api/zh/textures/DataTexture.html index bb948abba58ef8..58941101582482 100644 --- a/docs/api/zh/textures/DataTexture.html +++ b/docs/api/zh/textures/DataTexture.html @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@

      [name]( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, In order to use the types THREE.FloatType and THREE.HalfFloatType, the WebGL implementation must support the respective extensions OES_texture_float and OES_texture_half_float. In order to use THREE.LinearFilter for component-wise, bilinear interpolation of the texels based on these types, the WebGL extensions OES_texture_float_linear or OES_texture_half_float_linear must also be present.

      -

      Example

      +

      代码示例

      // create a buffer with color data diff --git a/docs/api/zh/textures/DataTexture3D.html b/docs/api/zh/textures/DataTexture3D.html index 39be8bdf59fc0c..924a157da3d422 100644 --- a/docs/api/zh/textures/DataTexture3D.html +++ b/docs/api/zh/textures/DataTexture3D.html @@ -1,5 +1,5 @@ - + @@ -27,10 +27,12 @@

      [name]( [param:TypedArray data], [param:Number width], [param:Number height] [page:Number depth] -- 纹理的深度。

      -

      示例

      +

      例子

      -
      [example:webgl2_materials_texture3d WebGL2 / materials / texture3d]
      -
      [example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray]
      +

      + [example:webgl2_materials_texture3d WebGL2 / materials / texture3d]
      + [example:webgl2_materials_texture2darray WebGL2 / materials / texture2darray] +

      属性

      diff --git a/docs/api/zh/textures/DepthTexture.html b/docs/api/zh/textures/DepthTexture.html index 0ccae83c7e51a1..57569149855009 100644 --- a/docs/api/zh/textures/DepthTexture.html +++ b/docs/api/zh/textures/DepthTexture.html @@ -1,5 +1,5 @@ - + @@ -16,9 +16,10 @@

      深度纹理([name])

      创建一个作为深度纹理贴图来使用的纹理。需要支持[link:https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/ WEBGL_depth_texture]扩展。

      -

      示例

      - - [example:webgl_depth_texture depth / texture] +

      例子

      +

      + [example:webgl_depth_texture depth / texture] +

      构造函数

      [name]( [param:Number width], [param:Number height], [param:Constant type], [param:Constant wrapS], [param:Constant wrapT], [param:Constant magFilter], [param:Constant minFilter], [param:Number anisotropy], [param:Constant format] )

      diff --git a/docs/api/zh/textures/Texture.html b/docs/api/zh/textures/Texture.html index fd461be9e85d67..35f3f812e05bad 100644 --- a/docs/api/zh/textures/Texture.html +++ b/docs/api/zh/textures/Texture.html @@ -1,5 +1,5 @@ - + @@ -17,7 +17,7 @@

      构造函数

      [name]( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding )

      -

      源代码

      +

      代码示例

      // load a texture, set wrap mode to repeat diff --git a/docs/api/zh/textures/VideoTexture.html b/docs/api/zh/textures/VideoTexture.html index 102452082f219c..0321b48b036ca2 100644 --- a/docs/api/zh/textures/VideoTexture.html +++ b/docs/api/zh/textures/VideoTexture.html @@ -1,5 +1,5 @@ - + @@ -18,9 +18,7 @@

      视频纹理([name])

      它和其基类[page:Texture Texture]几乎是相同的,除了它总是将[page:Texture.needsUpdate needsUpdate]设置为*true*,以便使得贴图能够在视频播放时进行更新。自动创建[page:Texture.mipmaps mipmaps]也会被禁用。

      -

      示例

      - -

      [example:webgl_materials_video materials / video ]

      +

      代码示例

      //assuming you have created a HTML video element with id="video" @@ -32,6 +30,9 @@

      示例

      texture.format = THREE.RGBFormat;
      +

      例子

      + +

      [example:webgl_materials_video materials / video ]

      构造函数

      [name]( [param:Video video], [param:Constant mapping], [param:Constant wrapS], [param:Constant wrapT], [param:Constant magFilter], [param:Constant minFilter], [param:Constant format], [param:Constant type], [param:Number anisotropy] )

      diff --git a/docs/examples/en/animations/CCDIKSolver.html b/docs/examples/en/animations/CCDIKSolver.html index 3592789821e327..3912b172cbf8c6 100644 --- a/docs/examples/en/animations/CCDIKSolver.html +++ b/docs/examples/en/animations/CCDIKSolver.html @@ -15,13 +15,13 @@

      [name]

      [name] is designed to work with [page:SkinnedMesh] loaded by [page:MMDLoader] but also can be used for generic [page:SkinnedMesh].

      -

      Example

      +

      Code Example

      var ikSolver; // Load MMD resources and instantiate CCDIKSolver - new THREE.MMDLoader().load( + new MMDLoader().load( 'models/mmd/miku.pmd', function ( mesh ) { @@ -40,12 +40,13 @@

      Example

      }
      - [example:webgl_loader_mmd]
      - [example:webgl_loader_mmd_pose]
      - [example:webgl_loader_mmd_audio]
      +

      Examples

      -
      -
      +

      + [example:webgl_loader_mmd]
      + [example:webgl_loader_mmd_pose]
      + [example:webgl_loader_mmd_audio] +

      Constructor

      @@ -98,7 +99,7 @@

      [method:CCDIKSolver update]()

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/CCDIKSolver.js examples/js/animation/CCDIKSolver.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/CCDIKSolver.js examples/jsm/animation/CCDIKSolver.js]

      diff --git a/docs/examples/en/animations/MMDAnimationHelper.html b/docs/examples/en/animations/MMDAnimationHelper.html index 5fa9c9d8329641..0c9aa6c1879992 100644 --- a/docs/examples/en/animations/MMDAnimationHelper.html +++ b/docs/examples/en/animations/MMDAnimationHelper.html @@ -10,19 +10,19 @@

      [name]

      -

      A animation helper for MMD resources.

      +

      A animation helper for MMD resources.

      [name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics. It uses [page:CCDIKSolver] and [page:MMDPhysics] inside.

      -

      Example

      +

      Code Example

      // Instantiate a helper - var helper = new THREE.MMDAnimationHelper(); + var helper = new MMDAnimationHelper(); // Load MMD resources and add to helper - new THREE.MMDLoader().loadWithAnimation( + new MMDLoader().loadWithAnimation( 'models/mmd/miku.pmd', 'models/mmd/dance.vmd', function ( mmd ) { @@ -62,12 +62,13 @@

      Example

      }
      - [example:webgl_loader_mmd]
      - [example:webgl_loader_mmd_pose]
      - [example:webgl_loader_mmd_audio]
      +

      Examples

      -
      -
      +

      + [example:webgl_loader_mmd]
      + [example:webgl_loader_mmd_pose]
      + [example:webgl_loader_mmd_audio] +

      Constructor

      @@ -165,7 +166,7 @@

      [method:MMDAnimationHelper update]( [param:Nummber delta] )

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDAnimationHelper.js examples/js/animation/MMDAnimationHelper.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDAnimationHelper.js examples/jsm/animation/MMDAnimationHelper.js]

      diff --git a/docs/examples/en/animations/MMDPhysics.html b/docs/examples/en/animations/MMDPhysics.html index be52ce0518cb6a..1523685bd1f1e4 100644 --- a/docs/examples/en/animations/MMDPhysics.html +++ b/docs/examples/en/animations/MMDPhysics.html @@ -10,21 +10,21 @@

      [name]

      -

      A Physics handler for MMD resources.

      +

      A Physics handler for MMD resources.

      [name] calculates Physics for model loaded by [page:MMDLoader] with ammo.js (Bullet-based JavaScript Physics engine).

      -

      Example

      +

      Code Example

      var physics; // Load MMD resources and instantiate MMDPhysics - new THREE.MMDLoader().load( + new MMDLoader().load( 'models/mmd/miku.pmd', function ( mesh ) { - physics = new THREE.MMDPhysics( mesh ) + physics = new MMDPhysics( mesh ) scene.add( mesh ); } @@ -40,11 +40,12 @@

      Example

      }
      - [example:webgl_loader_mmd]
      - [example:webgl_loader_mmd_audio]
      +

      Examples

      -
      -
      +

      + [example:webgl_loader_mmd]
      + [example:webgl_loader_mmd_audio] +

      Constructor

      @@ -108,7 +109,7 @@

      [method:CCDIKSolver warmup]( [param:Integer cycles] )

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDPhysics.js examples/js/animation/MMDPhysics.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDPhysics.js examples/jsm/animation/MMDPhysics.js]

      diff --git a/docs/examples/en/controls/DeviceOrientationControls.html b/docs/examples/en/controls/DeviceOrientationControls.html index 34cdd9ea0cb4b8..2fa54a1aa8c756 100644 --- a/docs/examples/en/controls/DeviceOrientationControls.html +++ b/docs/examples/en/controls/DeviceOrientationControls.html @@ -15,7 +15,7 @@

      [name]

      Can be used to orient the camera based on the mobile device's orientation.

      -

      Example

      +

      Examples

      [example:misc_controls_deviceorientation misc / controls / deviceorientation ]

      @@ -83,7 +83,7 @@

      [method:null update] ()

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DeviceOrientationControls.js examples/js/controls/DeviceOrientationControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DeviceOrientationControls.js examples/jsm/controls/DeviceOrientationControls.js]

      diff --git a/docs/examples/en/controls/DragControls.html b/docs/examples/en/controls/DragControls.html index a22c12445d66ac..2782a47419d250 100644 --- a/docs/examples/en/controls/DragControls.html +++ b/docs/examples/en/controls/DragControls.html @@ -16,29 +16,30 @@

      [name]

      This class can be used to provide a drag'n'drop interaction.

      -

      Example

      - -

      [example:misc_controls_drag misc / controls / drag ]

      +

      Code Example

      -var controls = new THREE.DragControls( objects, camera, renderer.domElement ); - -// add event listener to highlight dragged objects + var controls = new DragControls( objects, camera, renderer.domElement ); -controls.addEventListener( 'dragstart', function ( event ) { + // add event listener to highlight dragged objects - event.object.material.emissive.set( 0xaaaaaa ); + controls.addEventListener( 'dragstart', function ( event ) { -} ); + event.object.material.emissive.set( 0xaaaaaa ); -controls.addEventListener( 'dragend', function ( event ) { + } ); - event.object.material.emissive.set( 0x000000 ); + controls.addEventListener( 'dragend', function ( event ) { -} ); + event.object.material.emissive.set( 0x000000 ); + } ); +

      Examples

      + +

      [example:misc_controls_drag misc / controls / drag ]

      +

      Constructor

      [name]( [param:Array objects], [param:Camera camera], [param:HTMLDOMElement domElement] )

      @@ -91,6 +92,12 @@

      [property:Boolean enabled]

      Whether or not the controls are enabled.

      +

      [property:Boolean transformGroup]

      +

      + This option only works if the [page:DragControls.objects] array contains a single draggable group object. + If set to *true*, [name] does not transform individual objects but the entire group. Default is *false*. +

      +

      Methods

      See the base [page:EventDispatcher] class for common methods.

      @@ -110,10 +117,15 @@

      [method:null dispose] ()

      Should be called if the controls is no longer required.

      +

      [method:Array getObjects] ()

      +

      + Returns the array of draggable objects. +

      +

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DragControls.js examples/js/controls/DragControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DragControls.js examples/jsm/controls/DragControls.js]

      diff --git a/docs/examples/en/controls/FirstPersonControls.html b/docs/examples/en/controls/FirstPersonControls.html index 4445b2b96eb944..3f89a334da52bd 100644 --- a/docs/examples/en/controls/FirstPersonControls.html +++ b/docs/examples/en/controls/FirstPersonControls.html @@ -15,7 +15,7 @@

      [name]

      This class is an alternative implementation of [page:FlyControls].

      -

      Example

      +

      Examples

      [example:webgl_geometry_terrain webgl / geometry / terrain ]

      @@ -159,7 +159,7 @@

      [method:null update] ( [param:Number delta] )

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FirstPersonControls.js examples/js/controls/FirstPersonControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FirstPersonControls.js examples/jsm/controls/FirstPersonControls.js]

      diff --git a/docs/examples/en/controls/FlyControls.html b/docs/examples/en/controls/FlyControls.html index 58e6e9d33f22fc..d4a979c5420e3f 100644 --- a/docs/examples/en/controls/FlyControls.html +++ b/docs/examples/en/controls/FlyControls.html @@ -16,7 +16,7 @@

      [name]

      3D space without any limitations (e.g. focus on a specific target).

      -

      Example

      +

      Examples

      [example:misc_controls_fly misc / controls / fly ]

      @@ -88,7 +88,7 @@

      [method:null update] ( [param:Number delta] )

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FlyControls.js examples/js/controls/FlyControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FlyControls.js examples/jsm/controls/FlyControls.js]

      diff --git a/docs/examples/en/controls/OrbitControls.html b/docs/examples/en/controls/OrbitControls.html index b1541ef594fdb7..0f9b1de1b3c06b 100644 --- a/docs/examples/en/controls/OrbitControls.html +++ b/docs/examples/en/controls/OrbitControls.html @@ -18,38 +18,39 @@

      [name]

      - -

      Example

      - -

      [example:misc_controls_orbit misc / controls / orbit ]

      +

      Code Example

      -var renderer = new THREE.WebGLRenderer(); -renderer.setSize( window.innerWidth, window.innerHeight ); -document.body.appendChild( renderer.domElement ); + var renderer = new THREE.WebGLRenderer(); + renderer.setSize( window.innerWidth, window.innerHeight ); + document.body.appendChild( renderer.domElement ); -var scene = new THREE.Scene(); + var scene = new THREE.Scene(); -var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); + var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); -var controls = new THREE.OrbitControls( camera, renderer.domElement ); + var controls = new OrbitControls( camera, renderer.domElement ); -//controls.update() must be called after any manual changes to the camera's transform -camera.position.set( 0, 20, 100 ); -controls.update(); + //controls.update() must be called after any manual changes to the camera's transform + camera.position.set( 0, 20, 100 ); + controls.update(); -function animate() { + function animate() { - requestAnimationFrame( animate ); + requestAnimationFrame( animate ); - // required if controls.enableDamping or controls.autoRotate are set to true - controls.update(); + // required if controls.enableDamping or controls.autoRotate are set to true + controls.update(); - renderer.render( scene, camera ); + renderer.render( scene, camera ); -} + } +

      Examples

      + +

      [example:misc_controls_orbit misc / controls / orbit ]

      +

      Constructor

      [name]( [param:Camera object], [param:HTMLDOMElement domElement] )

      @@ -292,7 +293,7 @@

      [method:Boolean update] ()

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/OrbitControls.js examples/js/controls/OrbitControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/OrbitControls.js examples/jsm/controls/OrbitControls.js]

      diff --git a/docs/examples/en/controls/PointerLockControls.html b/docs/examples/en/controls/PointerLockControls.html index 34962c31319193..b0d1203675cf35 100644 --- a/docs/examples/en/controls/PointerLockControls.html +++ b/docs/examples/en/controls/PointerLockControls.html @@ -17,29 +17,30 @@

      [name]

      [name] is a perfect choice for first person 3D games.

      -

      Example

      - -

      [example:misc_controls_pointerlock misc / controls / pointerlock ]

      +

      Code Example

      -var controls = new PointerLockControls( camera, document.body ); - -// add event listener to show/hide a UI (e.g. the game's menu) + var controls = new PointerLockControls( camera, document.body ); -controls.addEventListener( 'lock', function () { + // add event listener to show/hide a UI (e.g. the game's menu) - menu.style.display = 'none'; + controls.addEventListener( 'lock', function () { -} ); + menu.style.display = 'none'; -controls.addEventListener( 'unlock', function () { + } ); - menu.style.display = 'block'; + controls.addEventListener( 'unlock', function () { -} ); + menu.style.display = 'block'; + } ); +

      Examples

      + +

      [example:misc_controls_pointerlock misc / controls / pointerlock ]

      +

      Constructor

      [name]( [param:Camera camera], [param:HTMLDOMElement domElement] )

      @@ -143,7 +144,7 @@

      [method:null unlock] ()

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js examples/js/controls/PointerLockControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/PointerLockControls.js examples/jsm/controls/PointerLockControls.js]

      diff --git a/docs/examples/en/controls/TrackballControls.html b/docs/examples/en/controls/TrackballControls.html index 2428f5db5a8979..9830c7732c5e5c 100644 --- a/docs/examples/en/controls/TrackballControls.html +++ b/docs/examples/en/controls/TrackballControls.html @@ -19,7 +19,7 @@

      [name]

      -

      Example

      +

      Examples

      [example:misc_controls_trackball misc / controls / trackball ]

      @@ -201,7 +201,7 @@

      [method:null zoomCamera] ()

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TrackballControls.js examples/jsm/controls/TrackballControls.js]

      diff --git a/docs/examples/en/controls/TransformControls.html b/docs/examples/en/controls/TransformControls.html index def2b76c3496fe..02a0059af8b4dc 100644 --- a/docs/examples/en/controls/TransformControls.html +++ b/docs/examples/en/controls/TransformControls.html @@ -14,10 +14,12 @@

      [name]

      This class can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender. - Unlike other controls, it is not intended to transform the scene's camera. + Unlike other controls, it is not intended to transform the scene's camera.

      + + [name] expects that its attached 3D object is part of the scene graph.

      -

      Example

      +

      Examples

      [example:misc_controls_transform misc / controls / transform ]

      @@ -218,7 +220,7 @@

      [method:null setTranslationSnap] ( [param:Number translationSnap] )

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TransformControls.js examples/js/controls/TransformControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TransformControls.js examples/jsm/controls/TransformControls.js]

      diff --git a/docs/examples/en/exporters/ColladaExporter.html b/docs/examples/en/exporters/ColladaExporter.html index f049e391d78e6c..065469e13238a8 100644 --- a/docs/examples/en/exporters/ColladaExporter.html +++ b/docs/examples/en/exporters/ColladaExporter.html @@ -18,11 +18,11 @@

      [name]

      This exporter only supports exporting geometry, materials, textures, and scene hierarchy.

      -

      Example

      +

      Code Example

      // Instantiate an exporter - var exporter = new THREE.ColladaExporter(); + var exporter = new ColladaExporter(); // Parse the input and generate the ply output var data = exporter.parse( scene, null, options ); @@ -77,7 +77,7 @@

      [method:null parse]( [param:Object3D input], [param:Function onCompleted], [

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/ColladaExporter.js examples/js/exporters/ColladaExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/ColladaExporter.js examples/jsm/exporters/ColladaExporter.js]

      diff --git a/docs/examples/en/exporters/GLTFExporter.html b/docs/examples/en/exporters/GLTFExporter.html index 6560fa1e789f6d..70b42cff3b4c04 100644 --- a/docs/examples/en/exporters/GLTFExporter.html +++ b/docs/examples/en/exporters/GLTFExporter.html @@ -34,11 +34,11 @@

      Extensions

    • KHR_texture_transform
    -

    Example

    +

    Code Example

    // Instantiate a exporter - var exporter = new THREE.GLTFExporter(); + var exporter = new GLTFExporter(); // Parse the input and generate the glTF output exporter.parse( scene, function ( gltf ) { @@ -47,7 +47,11 @@

    Example

    }, options );
    - [example:misc_exporter_gltf] +

    Examples

    + +

    + [example:misc_exporter_gltf] +

    Constructor

    @@ -108,7 +112,7 @@

    [method:null parse]( [param:Object3D input], [param:Function onCompleted], [

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/GLTFExporter.js examples/js/exporters/GLTFExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]

    diff --git a/docs/examples/en/exporters/PLYExporter.html b/docs/examples/en/exporters/PLYExporter.html index 68dcbb9a67d0d0..c0b4b0a0c7ca67 100644 --- a/docs/examples/en/exporters/PLYExporter.html +++ b/docs/examples/en/exporters/PLYExporter.html @@ -19,11 +19,11 @@

    [name]

    uv coordinates. No textures or texture references are saved.

    -

    Example

    +

    Code Example

    // Instantiate an exporter - var exporter = new THREE.PLYExporter(); + var exporter = new PLYExporter(); // Parse the input and generate the ply output var data = exporter.parse( scene, options ); @@ -60,7 +60,7 @@

    [method:null parse]( [param:Object3D input], [param:Function onDone], [param

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/PLYExporter.js examples/js/exporters/PLYExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/PLYExporter.js examples/jsm/exporters/PLYExporter.js]

    diff --git a/docs/examples/en/geometries/ConvexBufferGeometry.html b/docs/examples/en/geometries/ConvexBufferGeometry.html index d222caa6d23ae0..e37c236334a243 100644 --- a/docs/examples/en/geometries/ConvexBufferGeometry.html +++ b/docs/examples/en/geometries/ConvexBufferGeometry.html @@ -16,32 +16,18 @@

    [name]

    [name] can be used to generate a convex hull for a given array of 3D points. The average time complexity for this task is considered to be O(nlog(n)).

    - - -

    Example

    - -

    [example:webgl_geometry_convex geometry / convex ]

    - - var geometry = new THREE.ConvexBufferGeometry( points ); + var geometry = new ConvexBufferGeometry( points ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    Examples

    + +

    [example:webgl_geometry_convex geometry / convex ]

    +

    Constructor

    [name]( [param:Array points] )

    @@ -53,7 +39,7 @@

    [name]( [param:Array points] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/ConvexGeometry.js examples/js/geometries/ConvexGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/ConvexGeometry.js examples/jsm/geometries/ConvexGeometry.js]

    diff --git a/docs/examples/en/geometries/ConvexGeometry.html b/docs/examples/en/geometries/ConvexGeometry.html index a6bb891b3ae48d..402414e83a1eb6 100644 --- a/docs/examples/en/geometries/ConvexGeometry.html +++ b/docs/examples/en/geometries/ConvexGeometry.html @@ -15,32 +15,18 @@

    [name]

    [name] can be used to generate a convex hull for a given array of 3D points. The average time complexity for this task is considered to be O(nlog(n)).

    - - -

    Example

    - -

    [example:webgl_geometry_convex geometry / convex ]

    - - var geometry = new THREE.ConvexGeometry( points ); + var geometry = new ConvexGeometry( points ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    Examples

    + +

    [example:webgl_geometry_convex geometry / convex ]

    +

    Constructor

    [name]( [param:Array points] )

    @@ -52,7 +38,7 @@

    [name]( [param:Array points] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/ConvexGeometry.js examples/js/geometries/ConvexGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/ConvexGeometry.js examples/jsm/geometries/ConvexGeometry.js]

    diff --git a/docs/examples/en/geometries/DecalGeometry.html b/docs/examples/en/geometries/DecalGeometry.html index 1ce4343d533e4f..9a7f33f6dd75cb 100644 --- a/docs/examples/en/geometries/DecalGeometry.html +++ b/docs/examples/en/geometries/DecalGeometry.html @@ -14,32 +14,19 @@

    [name]

    [name] can be used to create a decal mesh that serves different kinds of purposes e.g. adding unique details to models, performing dynamic visual environmental changes or covering seams.

    - - -

    Example

    - -

    [example:webgl_decals decals ]

    - - var geometry = new THREE.DecalGeometry( mesh, position, orientation, size ); + + var geometry = new DecalGeometry( mesh, position, orientation, size ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    Examples

    + +

    [example:webgl_decals WebGL / decals]

    +

    Constructor

    [name]( [param:Mesh mesh], [param:Vector3 position], [param:Euler orientation], [param:Vector3 size] )

    @@ -53,7 +40,7 @@

    [name]( [param:Mesh mesh], [param:Vector3 position], [param:Euler orientatio

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/DecalGeometry.js examples/js/geometries/DecalGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/DecalGeometry.js examples/jsm/geometries/DecalGeometry.js]

    diff --git a/docs/examples/en/helpers/FaceNormalsHelper.html b/docs/examples/en/helpers/FaceNormalsHelper.html index dfbca7ec633002..288b0f03e0aae1 100644 --- a/docs/examples/en/helpers/FaceNormalsHelper.html +++ b/docs/examples/en/helpers/FaceNormalsHelper.html @@ -21,22 +21,23 @@

    [name]

    For [page:BufferGeometry] use a [page:VertexNormalsHelper] instead.

    - -

    Example

    - -
    [example:webgl_helpers WebGL / helpers]
    +

    Code Example

    geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); box = new THREE.Mesh( geometry, material ); - helper = new THREE.FaceNormalsHelper( box, 2, 0x00ff00, 1 ); + helper = new FaceNormalsHelper( box, 2, 0x00ff00, 1 ); scene.add( box ); scene.add( helper ); +

    Examples

    + +

    [example:webgl_helpers WebGL / helpers]

    +

    Constructor

    diff --git a/docs/examples/en/helpers/LightProbeHelper.html b/docs/examples/en/helpers/LightProbeHelper.html index c72806a37c0dc8..e8a4e21d6735f8 100644 --- a/docs/examples/en/helpers/LightProbeHelper.html +++ b/docs/examples/en/helpers/LightProbeHelper.html @@ -16,17 +16,18 @@

    [name]

    Renders a sphere to visualize a light probe in the scene.

    -

    Example

    - -
    [example:webgl_lightprobe_cubecamera WebGL / lightprobe / cubecamera]
    +

    Code Example

    var helper = new LightProbeHelper( lightProbe, 1 ); scene.add( helper ); -

    Constructor

    +

    Examples

    +

    [example:webgl_lightprobe_cubecamera WebGL / lightprobe / cubecamera]

    + +

    Constructor

    [name]( [param:LightProbe lightProbe], [param:Number size] )

    diff --git a/docs/examples/en/helpers/PositionalAudioHelper.html b/docs/examples/en/helpers/PositionalAudioHelper.html index 0552237c94b81b..f262c5bb9f3554 100644 --- a/docs/examples/en/helpers/PositionalAudioHelper.html +++ b/docs/examples/en/helpers/PositionalAudioHelper.html @@ -14,19 +14,18 @@

    [name]

    This helper displays the directional cone of a [page:PositionalAudio].

    -

    Example

    - -
    [example:webaudio_orientation webaudio / orientation ]
    -

    Code Example

    -var positionalAudio = new THREE.PositionalAudio( listener ); -positionalAudio.setDirectionalCone( 180, 230, 0.1 ); + var positionalAudio = new THREE.PositionalAudio( listener ); + positionalAudio.setDirectionalCone( 180, 230, 0.1 ); -var helper = new PositionalAudioHelper( positionalAudio ); -positionalAudio.add( helper ); + var helper = new PositionalAudioHelper( positionalAudio ); + positionalAudio.add( helper ); +

    Examples

    + +
    [example:webaudio_orientation webaudio / orientation ]

    Constructor

    diff --git a/docs/examples/en/helpers/RectAreaLightHelper.html b/docs/examples/en/helpers/RectAreaLightHelper.html index 372962a63c4910..3c9f15d6f2af70 100644 --- a/docs/examples/en/helpers/RectAreaLightHelper.html +++ b/docs/examples/en/helpers/RectAreaLightHelper.html @@ -16,14 +16,12 @@

    [name]

    Creates a visual aid for a [page:RectAreaLight].

    -

    Example

    +

    Code Example

    -var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); - -var helper = new THREE.RectAreaLightHelper( light ); - -light.add( helper ); // helper must be added as a child of the light + var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); + var helper = new RectAreaLightHelper( light ); + light.add( helper ); // helper must be added as a child of the light diff --git a/docs/examples/en/helpers/VertexNormalsHelper.html b/docs/examples/en/helpers/VertexNormalsHelper.html index fc8b2b7ba210c8..834dddc41551a0 100644 --- a/docs/examples/en/helpers/VertexNormalsHelper.html +++ b/docs/examples/en/helpers/VertexNormalsHelper.html @@ -20,21 +20,23 @@

    [name]

    Unlike [page:FaceNormalsHelper], this works with [page:BufferGeometry].

    -

    Example

    - - [example:webgl_helpers WebGL / helpers] +

    Code Example

    - var geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); + var geometry = new THREE.BoxBufferGeometry( 10, 10, 10, 2, 2, 2 ); var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); var box = new THREE.Mesh( geometry, material ); - var helper = new THREE.VertexNormalsHelper( box, 2, 0x00ff00, 1 ); + var helper = new VertexNormalsHelper( box, 2, 0x00ff00, 1 ); scene.add( box ); scene.add( helper ); +

    Examples

    +

    + [example:webgl_helpers WebGL / helpers] +

    Constructor

    diff --git a/docs/examples/en/helpers/VertexTangentsHelper.html b/docs/examples/en/helpers/VertexTangentsHelper.html index 94bbe5b61538ef..b63aa2b23fe36d 100644 --- a/docs/examples/en/helpers/VertexTangentsHelper.html +++ b/docs/examples/en/helpers/VertexTangentsHelper.html @@ -20,21 +20,22 @@

    [name]

    This helper supports [page:BufferGeometry] only.

    -

    Example

    - - [example:webgl_helpers WebGL / helpers] - +

    Code Example

    var geometry = new THREE.BoxBufferGeometry( 10, 10, 10, 2, 2, 2 ); var material = new THREE.MeshNormalMaterial(); var box = new THREE.Mesh( geometry, material ); - var helper = new THREE.VertexTangentsHelper( box, 1, 0x00ffff, 1 ); + var helper = new VertexTangentsHelper( box, 1, 0x00ffff, 1 ); scene.add( box ); scene.add( helper ); +

    Examples

    +

    + [example:webgl_helpers WebGL / helpers] +

    Constructor

    diff --git a/docs/examples/en/loaders/BasisTextureLoader.html b/docs/examples/en/loaders/BasisTextureLoader.html index a986252938702b..e4989f74d4e881 100644 --- a/docs/examples/en/loaders/BasisTextureLoader.html +++ b/docs/examples/en/loaders/BasisTextureLoader.html @@ -29,10 +29,10 @@

    [name]

    directory.

    -

    Example

    +

    Code Example

    - var basisLoader = new THREE.BasisTextureLoader(); + var basisLoader = new BasisTextureLoader(); basisLoader.setTranscoderPath( 'examples/js/libs/basis/' ); basisLoader.detectSupport( renderer ); basisLoader.load( 'diffuse.basis', function ( texture ) { @@ -50,7 +50,11 @@

    Example

    } );
    - [example:webgl_loader_texture_basis] +

    Examples

    + +

    + [example:webgl_loader_texture_basis] +

    Browser compatibility

    @@ -134,7 +138,7 @@

    [method:this dispose]()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/BasisTextureLoader.js examples/js/loaders/BasisTextureLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/BasisTextureLoader.js examples/jsm/loaders/BasisTextureLoader.js]

    diff --git a/docs/examples/en/loaders/DRACOLoader.html b/docs/examples/en/loaders/DRACOLoader.html index a84a6488eabf13..603bfafef594c4 100644 --- a/docs/examples/en/loaders/DRACOLoader.html +++ b/docs/examples/en/loaders/DRACOLoader.html @@ -27,11 +27,11 @@

    [name]

    using Draco with glTF, an instance of DRACOLoader will be used internally by [page:GLTFLoader].

    -

    Example

    +

    Code Example

    // Instantiate a loader - var loader = new THREE.DRACOLoader(); + var loader = new DRACOLoader(); // Specify path to a folder containing WASM/JS decoding libraries. loader.setDecoderPath( '/examples/js/libs/draco/' ); @@ -66,7 +66,11 @@

    Example

    );
    - [example:webgl_loader_draco] +

    Examples

    + +

    + [example:webgl_loader_draco] +

    Browser compatibility

    @@ -145,7 +149,7 @@

    [method:this dispose]()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DRACOLoader.js examples/js/loaders/DRACOLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/DRACOLoader.js examples/jsm/loaders/DRACOLoader.js]

    diff --git a/docs/examples/en/loaders/GLTFLoader.html b/docs/examples/en/loaders/GLTFLoader.html index f2761b13ea2462..71601de71412a7 100644 --- a/docs/examples/en/loaders/GLTFLoader.html +++ b/docs/examples/en/loaders/GLTFLoader.html @@ -51,14 +51,14 @@

    Extensions

    #[link:https://github.com/mrdoob/three.js/issues/12788 12788].

    -

    Example

    +

    Code Example

    // Instantiate a loader - var loader = new THREE.GLTFLoader(); + var loader = new GLTFLoader(); // Optional: Provide a DRACOLoader instance to decode compressed mesh data - var dracoLoader = new THREE.DRACOLoader(); + var dracoLoader = new DRACOLoader(); dracoLoader.setDecoderPath( '/examples/js/libs/draco/' ); loader.setDRACOLoader( dracoLoader ); @@ -72,8 +72,8 @@

    Example

    scene.add( gltf.scene ); gltf.animations; // Array<THREE.AnimationClip> - gltf.scene; // THREE.Scene - gltf.scenes; // Array<THREE.Scene> + gltf.scene; // THREE.Group + gltf.scenes; // Array<THREE.Group> gltf.cameras; // Array<THREE.Camera> gltf.asset; // Object @@ -93,7 +93,11 @@

    Example

    );
    - [example:webgl_loader_gltf] +

    Examples

    + +

    + [example:webgl_loader_gltf] +

    Browser compatibility

    @@ -186,6 +190,7 @@

    [method:null setDRACOLoader]( [param:DRACOLoader dracoLoader] )

    Refer to this [link:https://github.com/mrdoob/three.js/tree/dev/examples/js/libs/draco#readme readme] for the details of Draco and its decoder.

    +

    [method:null setDDSLoader]( [param:DDSLoader ddsLoader] )

    [page:DDSLoader ddsLoader] — Instance of THREE.DDSLoader, to be used for loading compressed textures with the MSFT_TEXTURE_DDS extension. @@ -199,13 +204,13 @@

    [method:null parse]( [param:ArrayBuffer data], [param:String path], [param:F [page:Function onError] — (optional) A function to be called if an error occurs during parsing. The function receives error as an argument.

    - Parse a glTF-based ArrayBuffer or JSON String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array scenes], .[page:Array cameras], .[page:Array animations], and .[page:Object asset]. + Parse a glTF-based ArrayBuffer or JSON String and fire [page:Function onLoad] callback when complete. The argument to [page:Function onLoad] will be an [page:object] that contains loaded parts: .[page:Group scene], .[page:Array scenes], .[page:Array cameras], .[page:Array animations], and .[page:Object asset].

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GLTFLoader.js examples/jsm/loaders/GLTFLoader.js]

    diff --git a/docs/examples/en/loaders/MMDLoader.html b/docs/examples/en/loaders/MMDLoader.html index 182d6b0958516d..d7d20ed793ccb0 100644 --- a/docs/examples/en/loaders/MMDLoader.html +++ b/docs/examples/en/loaders/MMDLoader.html @@ -12,17 +12,17 @@

    [name]

    -

    A loader for MMD resources.

    +

    A loader for MMD resources.

    [name] creates Three.js Objects from MMD resources as PMD, PMX, VMD, and VPD files. See [page:MMDAnimationHelper] for MMD animation handling as IK, Grant, and Physics.

    If you want raw content of MMD resources, use .loadPMD/PMX/VMD/VPD methods. -

    Example

    +

    Code Example

    // Instantiate a loader - var loader = new THREE.MMDLoader(); + var loader = new MMDLoader(); // Load a MMD model loader.load( @@ -49,12 +49,12 @@

    Example

    );
    +

    Examples

    +

    [example:webgl_loader_mmd]
    [example:webgl_loader_mmd_pose]
    - [example:webgl_loader_mmd_audio]
    - -
    -


    + [example:webgl_loader_mmd_audio] +

    Constructor

    @@ -118,7 +118,7 @@

    [method:MMDLoader setAnimationPath]( [param:String animationPath] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/MMDLoader.js examples/js/loaders/MMDLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/MMDLoader.js examples/jsm/loaders/MMDLoader.js]

    diff --git a/docs/examples/en/loaders/MTLLoader.html b/docs/examples/en/loaders/MTLLoader.html index 06622f5a6e5c18..72c683ff406339 100644 --- a/docs/examples/en/loaders/MTLLoader.html +++ b/docs/examples/en/loaders/MTLLoader.html @@ -73,7 +73,7 @@

    [method:MTLLoaderMaterialCreator parse]( [param:String text, param:String pa

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/[name].js examples/js/loaders/[name].js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/[name].js examples/jsm/loaders/[name].js]

    diff --git a/docs/examples/en/loaders/OBJLoader.html b/docs/examples/en/loaders/OBJLoader.html index 28ec22bda53e1b..89408171d48b21 100644 --- a/docs/examples/en/loaders/OBJLoader.html +++ b/docs/examples/en/loaders/OBJLoader.html @@ -19,12 +19,11 @@

    [name]

    vertices, and texture vertices.

    - -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.OBJLoader(); + var loader = new OBJLoader(); // load a resource loader.load( @@ -51,8 +50,10 @@

    Example

    );
    - [example:webgl_loader_obj] - +

    Examples

    +

    + [example:webgl_loader_obj] +

    Constructor

    @@ -102,7 +103,7 @@

    [method:OBJLoader setMaterials]( [param:MTLLoader.MaterialCreator materials]

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js examples/js/loaders/OBJLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader.js examples/jsm/loaders/OBJLoader.js]

    diff --git a/docs/examples/en/loaders/OBJLoader2.html b/docs/examples/en/loaders/OBJLoader2.html index f84e429a606316..1bf7c8e2b94835 100644 --- a/docs/examples/en/loaders/OBJLoader2.html +++ b/docs/examples/en/loaders/OBJLoader2.html @@ -18,11 +18,11 @@

    [name]

    vertices, and texture vertices.

    -

    Examples

    +

    Code Example

    // instantiate the loader - let loader = new THREE.OBJLoader2(); + let loader = new OBJLoader2(); // function called on successful load function callbackOnLoad ( object3d ) { @@ -33,9 +33,11 @@

    Examples

    loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null );
    - [example:webgl_loader_obj2] - Simple example
    - [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel]))
    - +

    Examples

    +

    + [example:webgl_loader_obj2] - Simple example
    + [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel])) +

    Constructor

    diff --git a/docs/examples/en/loaders/OBJLoader2Parallel.html b/docs/examples/en/loaders/OBJLoader2Parallel.html index 11b3e021840a1f..75f88bfb144f2e 100644 --- a/docs/examples/en/loaders/OBJLoader2Parallel.html +++ b/docs/examples/en/loaders/OBJLoader2Parallel.html @@ -18,7 +18,7 @@

    [name]

    vertices, and texture vertices.

    -

    Examples

    +

    Code Example

    // instantiate the loader @@ -36,8 +36,10 @@

    Examples

    objLoader2Parallel.load( 'models/obj/walt/WaltHead.obj', callbackOnLoad, null, null, null );
    - [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main)
    - +

    Examples

    +

    + [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main) +

    Constructor

    diff --git a/docs/examples/en/loaders/PCDLoader.html b/docs/examples/en/loaders/PCDLoader.html index 4d341a17f0de7d..dcb82090afadd0 100644 --- a/docs/examples/en/loaders/PCDLoader.html +++ b/docs/examples/en/loaders/PCDLoader.html @@ -17,12 +17,12 @@

    [name]

    Loader support ascii and (compressed) binary.

    -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.PCDLoader(); + var loader = new PCDLoader(); // load a resource loader.load( @@ -49,8 +49,10 @@

    Example

    );
    - [example:webgl_loader_pcd] - +

    Examples

    +

    + [example:webgl_loader_pcd] +

    Constructor

    @@ -99,7 +101,7 @@

    [method:Object3D parse]( [param:Arraybuffer data],[param:String url] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PCDLoader.js examples/js/loaders/PCDLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PCDLoader.js examples/jsm/loaders/PCDLoader.js]

    diff --git a/docs/examples/en/loaders/PDBLoader.html b/docs/examples/en/loaders/PDBLoader.html index 46bd0cf7ca0203..f4109c11fee839 100644 --- a/docs/examples/en/loaders/PDBLoader.html +++ b/docs/examples/en/loaders/PDBLoader.html @@ -16,16 +16,16 @@

    [name]

    The Protein Data Bank file format is a textual file describing the three-dimensional structures of molecules.

    -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.PDBLoader(); + var loader = new PDBLoader(); // load a PDB resource loader.load( // resource URL - 'models/molecules/caffeine.pdb', + 'models/pdb/caffeine.pdb', // called when the resource is loaded function ( pdb ) { @@ -51,8 +51,10 @@

    Example

    );
    - [example:webgl_loader_pdb] - +

    Examples

    +

    + [example:webgl_loader_pdb] +

    Constructor

    @@ -92,7 +94,7 @@

    [method:Object parse]( [param:String text] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PDBLoader.js examples/js/loaders/PDBLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PDBLoader.js examples/jsm/loaders/PDBLoader.js]

    diff --git a/docs/examples/en/loaders/PRWMLoader.html b/docs/examples/en/loaders/PRWMLoader.html index 4e58a4b5d9ea82..6b81c547087308 100644 --- a/docs/examples/en/loaders/PRWMLoader.html +++ b/docs/examples/en/loaders/PRWMLoader.html @@ -20,11 +20,11 @@

    [name]

    on this here.

    -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.PRWMLoader(); + var loader = new PRWMLoader(); // load a resource loader.load( @@ -52,8 +52,10 @@

    Example

    );
    - [example:webgl_loader_prwm] - +

    Examples

    +

    + [example:webgl_loader_prwm] +

    Constructor

    @@ -99,7 +101,7 @@

    PRWMLoader.isBigEndianPlatform( )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PRWMLoader.js examples/js/loaders/PRWMLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PRWMLoader.js examples/jsm/loaders/PRWMLoader.js]

    diff --git a/docs/examples/en/loaders/SVGLoader.html b/docs/examples/en/loaders/SVGLoader.html index 55148bdaf1894c..13bdf20fe1f2d2 100644 --- a/docs/examples/en/loaders/SVGLoader.html +++ b/docs/examples/en/loaders/SVGLoader.html @@ -16,11 +16,11 @@

    [name]

    Scalable Vector Graphics is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.

    -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.SVGLoader(); + var loader = new SVGLoader(); // load a SVG resource loader.load( @@ -73,7 +73,10 @@

    Example

    );
    - [example:webgl_loader_svg] +

    Examples

    +

    + [example:webgl_loader_svg] +

    Constructor

    @@ -105,7 +108,7 @@

    [method:null load]( [param:String url], [param:Function onLoad], [param:Func

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/SVGLoader.js examples/js/loaders/SVGLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/SVGLoader.js examples/jsm/loaders/SVGLoader.js]

    diff --git a/docs/examples/en/loaders/TGALoader.html b/docs/examples/en/loaders/TGALoader.html index 1101c3b681adc8..4401a6e58c7044 100644 --- a/docs/examples/en/loaders/TGALoader.html +++ b/docs/examples/en/loaders/TGALoader.html @@ -16,11 +16,11 @@

    [name]

    TGA is a raster graphics, image file format.

    -

    Example

    +

    Code Example

    // instantiate a loader - var loader = new THREE.TGALoader(); + var loader = new TGALoader(); // load a resource var texture = loader.load( @@ -52,7 +52,10 @@

    Example

    } );
    - [example:webgl_loader_texture_tga] +

    Examples

    +

    + [example:webgl_loader_texture_tga] +

    Constructor

    @@ -84,7 +87,7 @@

    [method:DataTexture load]( [param:String url], [param:Function onLoad], [par

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/TGALoader.js examples/js/loaders/TGALoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/TGALoader.js examples/jsm/loaders/TGALoader.js]

    diff --git a/docs/examples/en/math/Lut.html b/docs/examples/en/math/Lut.html index 30ba06af8f76b6..d0a06900affe8b 100644 --- a/docs/examples/en/math/Lut.html +++ b/docs/examples/en/math/Lut.html @@ -2,7 +2,7 @@ - + @@ -14,12 +14,12 @@

    [name]

    Represents a lookup table for colormaps. It is used to determine the color values from a range of data values.

    +

    Code Example

    -

    Example

    - var lut = new THREE.Lut( "rainbow", 512 ); - var data = [0, 10.1, 4.2, 3.4, 63, 28]; - lut.setMax(63); - color = lut.getColor(10); + + var lut = new Lut( 'rainbow', 512 ); + var color = lut.getColor( 0.5 ); +

    Constructor

    @@ -139,7 +139,7 @@

    [method:Lut getColor]( value ) [param:Lut this]

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/[path].js examples/js/math/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/[path].js examples/jsm/math/[path].js]

    diff --git a/docs/examples/en/math/MeshSurfaceSampler.html b/docs/examples/en/math/MeshSurfaceSampler.html index c637436b9481d3..ee4ccd9d620671 100644 --- a/docs/examples/en/math/MeshSurfaceSampler.html +++ b/docs/examples/en/math/MeshSurfaceSampler.html @@ -14,11 +14,11 @@

    [name]

    Weighted sampling is useful for effects like heavier foliage growth in certain areas of terrain, or concentrated particle emissions from specific parts of a mesh. Vertex weights may be written programmatically, or painted by hand as vertex colors in 3D tools like Blender.

    -

    Example

    +

    Code Example

    // Create a sampler for a Mesh surface. - var sampler = new THREE.MeshSurfaceSampler( surfaceMesh ) + var sampler = new MeshSurfaceSampler( surfaceMesh ) .setWeightAttribute( 'color' ) .build(); @@ -45,10 +45,10 @@

    Example

    scene.add( mesh );
    - [example:webgl_instancing_scatter] - -
    -
    +

    Examples

    +

    + [example:webgl_instancing_scatter] +

    Constructor

    @@ -80,7 +80,7 @@

    [method:this sample]( [param:Vector3 targetPosition], [param:Vector3 targetN

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/MeshSurfaceSampler.js examples/js/math/MeshSurfaceSampler.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/MeshSurfaceSampler.js examples/jsm/math/MeshSurfaceSampler.js]

    diff --git a/docs/examples/en/math/convexhull/ConvexHull.html b/docs/examples/en/math/convexhull/ConvexHull.html index 68ca0d8e1e298d..09ef56195a57ac 100644 --- a/docs/examples/en/math/convexhull/ConvexHull.html +++ b/docs/examples/en/math/convexhull/ConvexHull.html @@ -20,6 +20,7 @@

    Constructor

    [name]()

    + Creates a new instance of [name].

    Properties

    @@ -57,28 +58,35 @@

    [property:Array vertices]

    Methods

    [method:HalfEdge addAdjoiningFace]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    - [page:HalfEdge horizonEdge] - A single edge of the horizon.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.
    + [page:HalfEdge horizonEdge] - A single edge of the horizon.

    -

    Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order. - All the half edges are created in CCW order thus the face is always pointing outside the hull

    + Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order. + All the half edges are created in CCW order thus the face is always pointing outside the hull +

    [method:ConvexHull addNewFaces]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    - [page:HalfEdge horizon] - An array of half-edges that form the horizon.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.
    + [page:HalfEdge horizon] - An array of half-edges that form the horizon.

    -

    Adds 'horizon.length' faces to the hull, each face will be linked with the horizon opposite face and the face on the left/right.

    + Adds 'horizon.length' faces to the hull, each face will be linked with the horizon opposite face and the face on the left/right. +

    [method:ConvexHull addVertexToFace]( [param:VertexNode vertex], [param:Face face] )

    - [page:VertexNodeNode vertex] - The vertex to add.

    - [page:Face face] - The target face.

    +

    + [page:VertexNodeNode vertex] - The vertex to add.
    + [page:Face face] - The target face.

    -

    Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.

    + Adds a vertex to the 'assigned' list of vertices and assigns it to the given face. +

    [method:ConvexHull addVertexToHull]( [param:VertexNode eyeVertex] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    -

    Adds a vertex to the hull with the following algorithm + Adds a vertex to the hull with the following algorithm

    • Compute the 'horizon' which is a chain of half edges. For an edge to belong to this group it must be the edge connecting a face that can see 'eyeVertex' and a face which cannot see 'eyeVertex'.
    • All the faces that can see 'eyeVertex' have its visible vertices removed from the assigned vertex list.
    • @@ -100,27 +108,32 @@

      [method:Object computeExtremes]()

      Computes the extremes values (min/max vectors) which will be used to compute the inital hull.

      [method:ConvexHull computeHorizon]( [param:Vector3 eyePoint], [param:HalfEdge crossEdge], [param:Face face], [param:Array horizon] )

      - [page:Vector3 eyePoint] - The 3D-coordinates of a point.

      - [page:HalfEdge crossEdge] - The edge used to jump to the current face.

      - [page:Face face] - The current face being tested.

      - [page:Array horizon] - The edges that form part of the horizon in CCW order.

      +

      + [page:Vector3 eyePoint] - The 3D-coordinates of a point.
      + [page:HalfEdge crossEdge] - The edge used to jump to the current face.
      + [page:Face face] - The current face being tested.
      + [page:Array horizon] - The edges that form part of the horizon in CCW order.

      -

      Computes a chain of half edges in CCW order called the 'horizon'. For an edge to be part of the horizon it must join a face that can see 'eyePoint' and a face that cannot see 'eyePoint'.

      + Computes a chain of half edges in CCW order called the 'horizon'. For an edge to be part of the horizon it must join a face that can see 'eyePoint' and a face that cannot see 'eyePoint'. +

      [method:ConvexHull computeInitialHull]()

      Computes the initial simplex assigning to its faces all the points that are candidates to form part of the hull.

      [method:ConvexHull containsPoint]( [param:Vector3 point] )

      - [page:Vector3 point] - A point in 3D space.

      +

      + [page:Vector3 point] - A point in 3D space.

      -

      Returns *true* if the given point is inside this convex hull.

      + Returns *true* if the given point is inside this convex hull. +

      [method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absorbingFace] )

      - [page:Face face] - The given face.

      - [page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.

      +

      + [page:Face face] - The given face.
      + [page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.

      -

      Removes all the visible vertices that 'face' is able to see. + Removes all the visible vertices that 'face' is able to see.

      • If 'absorbingFace' doesn't exist, then all the removed vertices will be added to the 'unassigned' vertex list.
      • If 'absorbingFace' exists, then this method will assign all the vertices of 'face' that can see 'absorbingFace'.
      • @@ -129,15 +142,19 @@

        [method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absor

        [method:Vector3 intersectRay]( [param:Ray ray], [param:Vector3 target] )

        - [page:Ray ray] - The given ray.

        - [page:Vector3 target] - The target vector representing the intersection point.

        +

        + [page:Ray ray] - The given ray.
        + [page:Vector3 target] - The target vector representing the intersection point.

        -

        Performs a ray intersection test with this convext hull. If no intersection is found, *null* is returned.

        + Performs a ray intersection test with this convext hull. If no intersection is found, *null* is returned. +

        [method:Boolean intersectsRay]( [param:Ray ray] )

        - [page:Ray ray] - The given ray.

        +

        + [page:Ray ray] - The given ray.

        -

        Returns *true* if the given ray intersects with this convex hull.

        + Returns *true* if the given ray intersects with this convex hull. +

        [method:ConvexHull makeEmpty]()

        @@ -158,36 +175,45 @@

        [method:ConvexHull reindexFaces]()

        Removes inactive (e.g. deleted) faces from the internal face list.

        [method:VertexNode removeAllVerticesFromFace]( [param:Face face] )

        - [page:Face face] - The given face.

        +

        + [page:Face face] - The given face.

        -

        Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list.

        + Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list. +

        [method:ConvexHull removeVertexFromFace]( [param:VertexNode vertex], [param:Face face] )

        - [page:VertexNode vertex] - The vertex to remove.

        - [page:Face face] - The target face.

        +

        + [page:VertexNode vertex] - The vertex to remove.
        + [page:Face face] - The target face.

        -

        Removes a vertex from the 'assigned' list of vertices and from the given face. It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal.

        + Removes a vertex from the 'assigned' list of vertices and from the given face. It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal. +

        [method:ConvexHull resolveUnassignedPoints]( [param:Array newFaces] )

        - [page:Face newFaces] - An array of new faces.

        +

        + [page:Face newFaces] - An array of new faces.

        -

        Reassigns as many vertices as possible from the unassigned list to the new faces.

        + Reassigns as many vertices as possible from the unassigned list to the new faces. +

        [method:ConvexHull setFromObject]( [param:Object3D object] )

        - [page:Object3D object] - [page:Object3D] to compute the convex hull of.

        +

        + [page:Object3D object] - [page:Object3D] to compute the convex hull of.

        -

        Computes the convex hull of an [page:Object3D] (including its children), - accounting for the world transforms of both the object and its childrens.

        + Computes the convex hull of an [page:Object3D] (including its children),accounting for the world transforms of both the object and its childrens. +

        [method:ConvexHull setFromPoints]( [param:Array points] )

        - [page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.

        +

        + [page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.

        -

        Computes to convex hull for the given array of points.

        + Computes to convex hull for the given array of points. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/ConvexHull.js]

        diff --git a/docs/examples/en/math/convexhull/Face.html b/docs/examples/en/math/convexhull/Face.html index 98cf402834f89b..f1797665aeaaba 100644 --- a/docs/examples/en/math/convexhull/Face.html +++ b/docs/examples/en/math/convexhull/Face.html @@ -20,6 +20,7 @@

        Constructor

        [name]()

        + Creates a new instance of [name].

        Properties

        @@ -62,30 +63,36 @@

        [property:HalfEdge edge]

        Methods

        [method:Face create]( [param:VertexNode a], [param:VertexNode b], [param:VertexNode c] )

        - [page:VertexNode a] - First vertex of the face.

        - [page:VertexNode b] - Second vertex of the face.

        - [page:VertexNode c] - Third vertex of the face.

        +

        + [page:VertexNode a] - First vertex of the face.
        + [page:VertexNode b] - Second vertex of the face.
        + [page:VertexNode c] - Third vertex of the face.

        -

        Creates a face.

        + Creates a face. +

        [method:HalfEdge getEdge]( [param:Integer i] )

        - [page:Integer i] - The index of the edge.

        +

        + [page:Integer i] - The index of the edge.

        -

        Returns an edge by the given index.

        + Returns an edge by the given index. +

        [method:Face compute] ()

        Computes all properties of the face.

        [method:Float distanceToPoint]( [param:Vector3 point] )

        - [page:Vector3 point] - Any point in 3D space.

        +

        + [page:Vector3 point] - Any point in 3D space.

        -

        Returns the signed distance from a given point to the plane representation of this face.

        + Returns the signed distance from a given point to the plane representation of this face. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/en/math/convexhull/HalfEdge.html b/docs/examples/en/math/convexhull/HalfEdge.html index 200ed43442bcbd..2834cf81fbdf57 100644 --- a/docs/examples/en/math/convexhull/HalfEdge.html +++ b/docs/examples/en/math/convexhull/HalfEdge.html @@ -20,8 +20,10 @@

        Constructor

        [name]( [param:VertexNode vertex], [param:Face face] )

        - [page:VertexNode vertex] - [page:VertexNode] A reference to its destination vertex.

        - [page:Face face] - [page:Face] A reference to its face.
        + [page:VertexNode vertex] - [page:VertexNode] A reference to its destination vertex.
        + [page:Face face] - [page:Face] A reference to its face.

        + + Creates a new instance of [name].

        Properties

        @@ -68,14 +70,16 @@

        [method:Float lengthSquared]()

        (straight-line length) of the edge.

        [method:HalfEdge setTwin]( [param:HalfEdge edge] )

        - [page:HalfEdge edge] - Any half-edge.

        +

        + [page:HalfEdge edge] - Any half-edge.

        -

        Sets the twin edge of this half-edge. It also ensures that the twin reference of the given half-edge is correctly set.

        + Sets the twin edge of this half-edge. It also ensures that the twin reference of the given half-edge is correctly set. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/en/math/convexhull/VertexList.html b/docs/examples/en/math/convexhull/VertexList.html index 54fc759aefcbe9..fa050a83a91cd4 100644 --- a/docs/examples/en/math/convexhull/VertexList.html +++ b/docs/examples/en/math/convexhull/VertexList.html @@ -20,6 +20,7 @@

        Constructor

        [name]()

        + Creates a new instance of [name].

        Properties

        @@ -47,38 +48,48 @@

        [method:VertexList clear]()

        [method:VertexList insertBefore]( [param:Vertex target], [param:Vertex vertex] )

        - [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.

        - [page:Vertex vertex] - The vertex to insert.

        -

        + [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.
        + [page:Vertex vertex] - The vertex to insert.

        -

        Inserts a vertex before a target vertex.

        + Inserts a vertex before a target vertex. +

        [method:VertexList insertAfter]( [param:Vertex target], [param:Vertex vertex] )

        - [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.

        - [page:Vertex vertex] - The vertex to insert.

        +

        + [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.
        + [page:Vertex vertex] - The vertex to insert.

        -

        Inserts a vertex after a target vertex.

        + Inserts a vertex after a target vertex. +

        [method:VertexList append]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The vertex to append.

        +

        + [page:Vertex vertex] - The vertex to append.

        -

        Appends a vertex to the end of the linked list.

        + Appends a vertex to the end of the linked list. +

        [method:VertexList appendChain]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The head vertex of a chain of vertices.

        +

        + [page:Vertex vertex] - The head vertex of a chain of vertices.

        -

        Appends a chain of vertices where the given vertex is the head.

        + Appends a chain of vertices where the given vertex is the head. +

        [method:VertexList remove]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The vertex to remove.

        +

        + [page:Vertex vertex] - The vertex to remove.

        -

        Removes a vertex from the linked list.

        + Removes a vertex from the linked list. +

        [method:VertexList removeSubList]( [param:Vertex a], [param:Vertex b] )

        - [page:Vertex a] - The head of the sublist.

        - [page:Vertex b] - The tail of the sublist.

        +

        + [page:Vertex a] - The head of the sublist.
        + [page:Vertex b] - The tail of the sublist.

        -

        Removes a sublist of vertices from the linked list.

        + Removes a sublist of vertices from the linked list. +

        [method:Boolean isEmpty]()

        @@ -87,7 +98,7 @@

        [method:Boolean isEmpty]()

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/en/math/convexhull/VertexNode.html b/docs/examples/en/math/convexhull/VertexNode.html index 179dc88c3bfdcc..e963c28835b0ef 100644 --- a/docs/examples/en/math/convexhull/VertexNode.html +++ b/docs/examples/en/math/convexhull/VertexNode.html @@ -21,6 +21,8 @@

        Constructor

        [name]( [param:Vector3 point] )

        [page:Vector3 point] - [page:Vector3] A point (x, y, z) in 3D space.

        + + Creates a new instance of [name].

        Properties

        @@ -48,7 +50,7 @@

        [property:Face face]

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/en/objects/Lensflare.html b/docs/examples/en/objects/Lensflare.html index 79391c1c6463df..5ceb56ee533eff 100644 --- a/docs/examples/en/objects/Lensflare.html +++ b/docs/examples/en/objects/Lensflare.html @@ -13,32 +13,33 @@

        [name]

        - Creates a simulated lens flare that tracks a light.

        + Creates a simulated lens flare that tracks a light.

        -

        Example

        +

        Code Example

        -

        - [example:webgl_lensflares lensflares] + + var light = new THREE.PointLight( 0xffffff, 1.5, 2000 ); - -var light = new THREE.PointLight( 0xffffff, 1.5, 2000 ); + var textureLoader = new THREE.TextureLoader(); -var textureLoader = new THREE.TextureLoader(); + var textureFlare0 = textureLoader.load( "textures/lensflare/lensflare0.png" ); + var textureFlare1 = textureLoader.load( "textures/lensflare/lensflare2.png" ); + var textureFlare2 = textureLoader.load( "textures/lensflare/lensflare3.png" ); -var textureFlare0 = textureLoader.load( "textures/lensflare/lensflare0.png" ); -var textureFlare1 = textureLoader.load( "textures/lensflare/lensflare2.png" ); -var textureFlare2 = textureLoader.load( "textures/lensflare/lensflare3.png" ); + var lensflare = new Lensflare(); -var lensflare = new THREE.Lensflare(); + lensflare.addElement( new LensflareElement( textureFlare0, 512, 0 ) ); + lensflare.addElement( new LensflareElement( textureFlare1, 512, 0 ) ); + lensflare.addElement( new LensflareElement( textureFlare2, 60, 0.6 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare0, 512, 0 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare1, 512, 0 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare2, 60, 0.6 ) ); + light.add( lensflare ); + -light.add( lensflare ); - +

        Examples

        +

        + [example:webgl_lensflares WebGL / lensflares]

        Constructor

        @@ -59,7 +60,7 @@

        Properties

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/objects/Lensflare.js examples/js/objects/Lensflare.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Lensflare.js examples/jsm/objects/Lensflare.js]

        diff --git a/docs/examples/en/postprocessing/EffectComposer.html b/docs/examples/en/postprocessing/EffectComposer.html index 8a6e0d8528788b..8e6ebc8927a661 100644 --- a/docs/examples/en/postprocessing/EffectComposer.html +++ b/docs/examples/en/postprocessing/EffectComposer.html @@ -56,7 +56,7 @@

        [name]( [param:WebGLRenderer renderer], [param:WebGLRenderTarget renderTarge

        Properties

        -

        [property:Boolean passes]

        +

        [property:Array passes]

        An array representing the (ordered) chain of post-processing passes.

        @@ -151,7 +151,7 @@

        [method:void swapBuffers]()

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/postprocessing/EffectComposer.js examples/js/postprocessing/EffectComposer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/EffectComposer.js examples/jsm/postprocessing/EffectComposer.js]

        diff --git a/docs/examples/en/renderers/CSS2DRenderer.html b/docs/examples/en/renderers/CSS2DRenderer.html index 646744d7f324f2..42ae2eeb9e6ab3 100644 --- a/docs/examples/en/renderers/CSS2DRenderer.html +++ b/docs/examples/en/renderers/CSS2DRenderer.html @@ -14,22 +14,6 @@

        [name]

        The renderer is very useful if you want to combine HTML based labels with 3D objects. Here too, the respective DOM elements are wrapped into an instance of *CSS2DObject* and added to the scene graph.

        - -

        Examples

        @@ -61,7 +45,7 @@

        [method:null setSize]([param:Number width], [param:Number height])

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CSS2DRenderer.js examples/js/renderers/CSS2DRenderer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS2DRenderer.js examples/jsm/renderers/CSS2DRenderer.js]

        diff --git a/docs/examples/en/renderers/CSS3DRenderer.html b/docs/examples/en/renderers/CSS3DRenderer.html index 00d9d44ad3d658..8f94854c4a368d 100644 --- a/docs/examples/en/renderers/CSS3DRenderer.html +++ b/docs/examples/en/renderers/CSS3DRenderer.html @@ -23,22 +23,6 @@

        [name]

        So [name] is just focused on ordinary DOM elements. These elements are wrapped into special objects (*CSS3DObject* or *CSS3DSprite*) and then added to the scene graph.

        - -

        Examples

        @@ -73,7 +57,7 @@

        [method:null setSize]([param:Number width], [param:Number height])

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CSS3DRenderer.js examples/js/renderers/CSS3DRenderer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS3DRenderer.js examples/jsm/renderers/CSS3DRenderer.js]

        diff --git a/docs/examples/en/renderers/SVGRenderer.html b/docs/examples/en/renderers/SVGRenderer.html index e1c61481f36d6e..48743fef686d0a 100644 --- a/docs/examples/en/renderers/SVGRenderer.html +++ b/docs/examples/en/renderers/SVGRenderer.html @@ -34,22 +34,6 @@

        [name]

    - -

    Examples

    @@ -103,7 +87,7 @@

    [method:null setSize]( [param:Number width], [param:Number height] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/SVGRenderer.js examples/js/renderers/SVGRenderer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/SVGRenderer.js examples/jsm/renderers/SVGRenderer.js]

    diff --git a/docs/examples/en/utils/BufferGeometryUtils.html b/docs/examples/en/utils/BufferGeometryUtils.html index b76c448c99cf9a..595e9cf194abc0 100644 --- a/docs/examples/en/utils/BufferGeometryUtils.html +++ b/docs/examples/en/utils/BufferGeometryUtils.html @@ -11,7 +11,7 @@

    [name]

    - A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.

    + A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.

    @@ -21,7 +21,7 @@

    [method:null computeTangents]( [param:BufferGeometry geometry] )

    geometry -- A [page:BufferGeometry BufferGeometry] instance, which must have index, position, normal, and uv attributes.

    - Calculates and adds tangent attribute to a geometry.

    + Calculates and adds tangent attribute to a geometry.

    @@ -31,7 +31,7 @@

    [method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [pa useGroups -- Whether groups should be generated for the merged geometry or not.

    Merges a set of geometries into a single instance. All geometries must have compatible attributes. - If merge does not succeed, the method returns null.

    + If merge does not succeed, the method returns null.

    @@ -86,7 +86,7 @@

    [method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry]

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/BufferGeometryUtils.js examples/js/utils/BufferGeometryUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]

    diff --git a/docs/examples/en/utils/SceneUtils.html b/docs/examples/en/utils/SceneUtils.html index f17fc4923ec154..3538519c923747 100644 --- a/docs/examples/en/utils/SceneUtils.html +++ b/docs/examples/en/utils/SceneUtils.html @@ -15,6 +15,13 @@

    [name]

    Methods

    +

    [method:Group createMultiMaterialObject]( [param:InstancedMesh instancedMesh] )

    +

    + instancedMesh -- The instanced mesh. +

    +

    + Creates a new group object that contains a new mesh for each instance of the given instanced mesh. +

    [method:Group createMultiMaterialObject]( [param:Geometry geometry], [param:Array materials] )

    @@ -29,7 +36,7 @@

    [method:Group createMultiMaterialObject]( [param:Geometry geometry], [param:

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SceneUtils.js examples/js/utils/SceneUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]

    diff --git a/docs/examples/en/utils/SkeletonUtils.html b/docs/examples/en/utils/SkeletonUtils.html index ba9ed261a60502..f9adec5a1e2835 100644 --- a/docs/examples/en/utils/SkeletonUtils.html +++ b/docs/examples/en/utils/SkeletonUtils.html @@ -56,7 +56,7 @@

    [method:AnimationClip retargetClip]( [param:SkeletonHelper target], [param:S

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SkeletonUtils.js examples/js/utils/SkeletonUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SkeletonUtils.js examples/jsm/utils/SkeletonUtils.js]

    diff --git a/docs/examples/zh/animations/CCDIKSolver.html b/docs/examples/zh/animations/CCDIKSolver.html index 3592789821e327..c03c375ed0a1c0 100644 --- a/docs/examples/zh/animations/CCDIKSolver.html +++ b/docs/examples/zh/animations/CCDIKSolver.html @@ -1,5 +1,5 @@ - + @@ -15,13 +15,13 @@

    [name]

    [name] is designed to work with [page:SkinnedMesh] loaded by [page:MMDLoader] but also can be used for generic [page:SkinnedMesh].

    -

    Example

    +

    代码示例

    var ikSolver; // Load MMD resources and instantiate CCDIKSolver - new THREE.MMDLoader().load( + new MMDLoader().load( 'models/mmd/miku.pmd', function ( mesh ) { @@ -40,12 +40,13 @@

    Example

    }
    - [example:webgl_loader_mmd]
    - [example:webgl_loader_mmd_pose]
    - [example:webgl_loader_mmd_audio]
    +

    例子

    -
    -
    +

    + [example:webgl_loader_mmd]
    + [example:webgl_loader_mmd_pose]
    + [example:webgl_loader_mmd_audio] +

    Constructor

    @@ -98,7 +99,7 @@

    [method:CCDIKSolver update]()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/CCDIKSolver.js examples/js/animation/CCDIKSolver.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/CCDIKSolver.js examples/jsm/animation/CCDIKSolver.js]

    diff --git a/docs/examples/zh/animations/MMDAnimationHelper.html b/docs/examples/zh/animations/MMDAnimationHelper.html index 5fa9c9d8329641..8a8c77b78b05b5 100644 --- a/docs/examples/zh/animations/MMDAnimationHelper.html +++ b/docs/examples/zh/animations/MMDAnimationHelper.html @@ -1,5 +1,5 @@ - + @@ -10,19 +10,19 @@

    [name]

    -

    A animation helper for MMD resources.

    +

    A animation helper for MMD resources.

    [name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics. It uses [page:CCDIKSolver] and [page:MMDPhysics] inside.

    -

    Example

    +

    代码示例

    // Instantiate a helper - var helper = new THREE.MMDAnimationHelper(); + var helper = new MMDAnimationHelper(); // Load MMD resources and add to helper - new THREE.MMDLoader().loadWithAnimation( + new MMDLoader().loadWithAnimation( 'models/mmd/miku.pmd', 'models/mmd/dance.vmd', function ( mmd ) { @@ -62,12 +62,13 @@

    Example

    }
    - [example:webgl_loader_mmd]
    - [example:webgl_loader_mmd_pose]
    - [example:webgl_loader_mmd_audio]
    +

    例子

    -
    -
    +

    + [example:webgl_loader_mmd]
    + [example:webgl_loader_mmd_pose]
    + [example:webgl_loader_mmd_audio] +

    Constructor

    @@ -165,7 +166,7 @@

    [method:MMDAnimationHelper update]( [param:Nummber delta] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDAnimationHelper.js examples/js/animation/MMDAnimationHelper.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDAnimationHelper.js examples/jsm/animation/MMDAnimationHelper.js]

    diff --git a/docs/examples/zh/animations/MMDPhysics.html b/docs/examples/zh/animations/MMDPhysics.html index be52ce0518cb6a..7e98104070add1 100644 --- a/docs/examples/zh/animations/MMDPhysics.html +++ b/docs/examples/zh/animations/MMDPhysics.html @@ -1,5 +1,5 @@ - + @@ -10,21 +10,21 @@

    [name]

    -

    A Physics handler for MMD resources.

    +

    A Physics handler for MMD resources.

    [name] calculates Physics for model loaded by [page:MMDLoader] with ammo.js (Bullet-based JavaScript Physics engine).

    -

    Example

    +

    代码示例

    var physics; // Load MMD resources and instantiate MMDPhysics - new THREE.MMDLoader().load( + new MMDLoader().load( 'models/mmd/miku.pmd', function ( mesh ) { - physics = new THREE.MMDPhysics( mesh ) + physics = new MMDPhysics( mesh ) scene.add( mesh ); } @@ -40,11 +40,12 @@

    Example

    }
    - [example:webgl_loader_mmd]
    - [example:webgl_loader_mmd_audio]
    +

    例子

    -
    -
    +

    + [example:webgl_loader_mmd]
    + [example:webgl_loader_mmd_audio] +

    Constructor

    @@ -108,7 +109,7 @@

    [method:CCDIKSolver warmup]( [param:Integer cycles] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDPhysics.js examples/js/animation/MMDPhysics.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/animation/MMDPhysics.js examples/jsm/animation/MMDPhysics.js]

    diff --git a/docs/examples/zh/controls/DeviceOrientationControls.html b/docs/examples/zh/controls/DeviceOrientationControls.html index 34cdd9ea0cb4b8..f66ccdcc808d2b 100644 --- a/docs/examples/zh/controls/DeviceOrientationControls.html +++ b/docs/examples/zh/controls/DeviceOrientationControls.html @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@

    [name]

    Can be used to orient the camera based on the mobile device's orientation.

    -

    Example

    +

    例子

    [example:misc_controls_deviceorientation misc / controls / deviceorientation ]

    @@ -83,7 +83,7 @@

    [method:null update] ()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DeviceOrientationControls.js examples/js/controls/DeviceOrientationControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DeviceOrientationControls.js examples/jsm/controls/DeviceOrientationControls.js]

    diff --git a/docs/examples/zh/controls/DragControls.html b/docs/examples/zh/controls/DragControls.html index a22c12445d66ac..b74484ae9450c9 100644 --- a/docs/examples/zh/controls/DragControls.html +++ b/docs/examples/zh/controls/DragControls.html @@ -1,5 +1,5 @@ - + @@ -16,29 +16,30 @@

    [name]

    This class can be used to provide a drag'n'drop interaction.

    -

    Example

    - -

    [example:misc_controls_drag misc / controls / drag ]

    +

    代码示例

    -var controls = new THREE.DragControls( objects, camera, renderer.domElement ); - -// add event listener to highlight dragged objects + var controls = new DragControls( objects, camera, renderer.domElement ); -controls.addEventListener( 'dragstart', function ( event ) { + // add event listener to highlight dragged objects - event.object.material.emissive.set( 0xaaaaaa ); + controls.addEventListener( 'dragstart', function ( event ) { -} ); + event.object.material.emissive.set( 0xaaaaaa ); -controls.addEventListener( 'dragend', function ( event ) { + } ); - event.object.material.emissive.set( 0x000000 ); + controls.addEventListener( 'dragend', function ( event ) { -} ); + event.object.material.emissive.set( 0x000000 ); + } ); +

    例子

    + +

    [example:misc_controls_drag misc / controls / drag ]

    +

    Constructor

    [name]( [param:Array objects], [param:Camera camera], [param:HTMLDOMElement domElement] )

    @@ -91,6 +92,12 @@

    [property:Boolean enabled]

    Whether or not the controls are enabled.

    +

    [property:Boolean transformGroup]

    +

    + This option only works if the [page:DragControls.objects] array contains a single draggable group object. + If set to *true*, [name] does not transform individual objects but the entire group. Default is *false*. +

    +

    Methods

    See the base [page:EventDispatcher] class for common methods.

    @@ -110,10 +117,15 @@

    [method:null dispose] ()

    Should be called if the controls is no longer required.

    +

    [method:Array getObjects] ()

    +

    + Returns the array of draggable objects. +

    +

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/DragControls.js examples/js/controls/DragControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DragControls.js examples/jsm/controls/DragControls.js]

    diff --git a/docs/examples/zh/controls/FirstPersonControls.html b/docs/examples/zh/controls/FirstPersonControls.html index 4445b2b96eb944..f4fcf291b89fe8 100644 --- a/docs/examples/zh/controls/FirstPersonControls.html +++ b/docs/examples/zh/controls/FirstPersonControls.html @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@

    [name]

    This class is an alternative implementation of [page:FlyControls].

    -

    Example

    +

    例子

    [example:webgl_geometry_terrain webgl / geometry / terrain ]

    @@ -159,7 +159,7 @@

    [method:null update] ( [param:Number delta] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FirstPersonControls.js examples/js/controls/FirstPersonControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FirstPersonControls.js examples/jsm/controls/FirstPersonControls.js]

    diff --git a/docs/examples/zh/controls/FlyControls.html b/docs/examples/zh/controls/FlyControls.html index 58e6e9d33f22fc..d255747091a493 100644 --- a/docs/examples/zh/controls/FlyControls.html +++ b/docs/examples/zh/controls/FlyControls.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

    [name]

    3D space without any limitations (e.g. focus on a specific target).

    -

    Example

    +

    例子

    [example:misc_controls_fly misc / controls / fly ]

    @@ -88,7 +88,7 @@

    [method:null update] ( [param:Number delta] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/FlyControls.js examples/js/controls/FlyControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FlyControls.js examples/jsm/controls/FlyControls.js]

    diff --git a/docs/examples/zh/controls/OrbitControls.html b/docs/examples/zh/controls/OrbitControls.html index 42b9d8b3093b8e..bfdde0b8aa134c 100644 --- a/docs/examples/zh/controls/OrbitControls.html +++ b/docs/examples/zh/controls/OrbitControls.html @@ -1,5 +1,5 @@ - + @@ -18,38 +18,39 @@

    轨道控制器([name])

    - -

    示例

    - -

    [example:misc_controls_orbit misc / controls / orbit ]

    +

    代码示例

    -var renderer = new THREE.WebGLRenderer(); -renderer.setSize( window.innerWidth, window.innerHeight ); -document.body.appendChild( renderer.domElement ); + var renderer = new THREE.WebGLRenderer(); + renderer.setSize( window.innerWidth, window.innerHeight ); + document.body.appendChild( renderer.domElement ); -var scene = new THREE.Scene(); + var scene = new THREE.Scene(); -var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); + var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 ); -var controls = new THREE.OrbitControls( camera, renderer.domElement ); + var controls = new OrbitControls( camera, renderer.domElement ); -//controls.update() must be called after any manual changes to the camera's transform -camera.position.set( 0, 20, 100 ); -controls.update(); + //controls.update() must be called after any manual changes to the camera's transform + camera.position.set( 0, 20, 100 ); + controls.update(); -function animate() { + function animate() { - requestAnimationFrame( animate ); + requestAnimationFrame( animate ); - // required if controls.enableDamping or controls.autoRotate are set to true - controls.update(); + // required if controls.enableDamping or controls.autoRotate are set to true + controls.update(); - renderer.render( scene, camera ); + renderer.render( scene, camera ); -} + } +

    例子

    + +

    [example:misc_controls_orbit misc / controls / orbit ]

    +

    Constructor

    [name]( [param:Camera object], [param:HTMLDOMElement domElement] )

    @@ -291,7 +292,7 @@

    [method:Boolean update] ()

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/OrbitControls.js examples/js/controls/OrbitControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/OrbitControls.js examples/jsm/controls/OrbitControls.js]

    diff --git a/docs/examples/zh/controls/PointerLockControls.html b/docs/examples/zh/controls/PointerLockControls.html index 34962c31319193..f405c85b7ab829 100644 --- a/docs/examples/zh/controls/PointerLockControls.html +++ b/docs/examples/zh/controls/PointerLockControls.html @@ -1,5 +1,5 @@ - + @@ -17,29 +17,30 @@

    [name]

    [name] is a perfect choice for first person 3D games.

    -

    Example

    - -

    [example:misc_controls_pointerlock misc / controls / pointerlock ]

    +

    代码示例

    -var controls = new PointerLockControls( camera, document.body ); - -// add event listener to show/hide a UI (e.g. the game's menu) + var controls = new PointerLockControls( camera, document.body ); -controls.addEventListener( 'lock', function () { + // add event listener to show/hide a UI (e.g. the game's menu) - menu.style.display = 'none'; + controls.addEventListener( 'lock', function () { -} ); + menu.style.display = 'none'; -controls.addEventListener( 'unlock', function () { + } ); - menu.style.display = 'block'; + controls.addEventListener( 'unlock', function () { -} ); + menu.style.display = 'block'; + } ); +

    例子

    + +

    [example:misc_controls_pointerlock misc / controls / pointerlock ]

    +

    Constructor

    [name]( [param:Camera camera], [param:HTMLDOMElement domElement] )

    @@ -143,7 +144,7 @@

    [method:null unlock] ()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js examples/js/controls/PointerLockControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/PointerLockControls.js examples/jsm/controls/PointerLockControls.js]

    diff --git a/docs/examples/zh/controls/TrackballControls.html b/docs/examples/zh/controls/TrackballControls.html index 2428f5db5a8979..a7cf28ce8a6427 100644 --- a/docs/examples/zh/controls/TrackballControls.html +++ b/docs/examples/zh/controls/TrackballControls.html @@ -1,5 +1,5 @@ - + @@ -19,7 +19,7 @@

    [name]

    -

    Example

    +

    例子

    [example:misc_controls_trackball misc / controls / trackball ]

    @@ -201,7 +201,7 @@

    [method:null zoomCamera] ()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TrackballControls.js examples/js/controls/TrackballControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TrackballControls.js examples/jsm/controls/TrackballControls.js]

    diff --git a/docs/examples/zh/controls/TransformControls.html b/docs/examples/zh/controls/TransformControls.html index def2b76c3496fe..ed9489a29e96a7 100644 --- a/docs/examples/zh/controls/TransformControls.html +++ b/docs/examples/zh/controls/TransformControls.html @@ -1,5 +1,5 @@ - + @@ -14,10 +14,12 @@

    [name]

    This class can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender. - Unlike other controls, it is not intended to transform the scene's camera. + Unlike other controls, it is not intended to transform the scene's camera.

    + + [name] expects that its attached 3D object is part of the scene graph.

    -

    Example

    +

    例子

    [example:misc_controls_transform misc / controls / transform ]

    @@ -218,7 +220,7 @@

    [method:null setTranslationSnap] ( [param:Number translationSnap] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/TransformControls.js examples/js/controls/TransformControls.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TransformControls.js examples/jsm/controls/TransformControls.js]

    diff --git a/docs/examples/zh/exporters/ColladaExporter.html b/docs/examples/zh/exporters/ColladaExporter.html index f049e391d78e6c..3c407ca275ecf7 100644 --- a/docs/examples/zh/exporters/ColladaExporter.html +++ b/docs/examples/zh/exporters/ColladaExporter.html @@ -1,5 +1,5 @@ - + @@ -18,11 +18,11 @@

    [name]

    This exporter only supports exporting geometry, materials, textures, and scene hierarchy.

    -

    Example

    +

    代码示例

    // Instantiate an exporter - var exporter = new THREE.ColladaExporter(); + var exporter = new ColladaExporter(); // Parse the input and generate the ply output var data = exporter.parse( scene, null, options ); @@ -77,7 +77,7 @@

    [method:null parse]( [param:Object3D input], [param:Function onCompleted], [

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/ColladaExporter.js examples/js/exporters/ColladaExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/ColladaExporter.js examples/jsm/exporters/ColladaExporter.js]

    diff --git a/docs/examples/zh/exporters/GLTFExporter.html b/docs/examples/zh/exporters/GLTFExporter.html index 6560fa1e789f6d..8c93a420f153a4 100644 --- a/docs/examples/zh/exporters/GLTFExporter.html +++ b/docs/examples/zh/exporters/GLTFExporter.html @@ -1,5 +1,5 @@ - + @@ -34,11 +34,11 @@

    Extensions

  • KHR_texture_transform
  • -

    Example

    +

    代码示例

    // Instantiate a exporter - var exporter = new THREE.GLTFExporter(); + var exporter = new GLTFExporter(); // Parse the input and generate the glTF output exporter.parse( scene, function ( gltf ) { @@ -47,7 +47,11 @@

    Example

    }, options );
    - [example:misc_exporter_gltf] +

    例子

    + +

    + [example:misc_exporter_gltf] +

    Constructor

    @@ -108,7 +112,7 @@

    [method:null parse]( [param:Object3D input], [param:Function onCompleted], [

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/GLTFExporter.js examples/js/exporters/GLTFExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]

    diff --git a/docs/examples/zh/exporters/PLYExporter.html b/docs/examples/zh/exporters/PLYExporter.html index 68dcbb9a67d0d0..bfec6c2346d298 100644 --- a/docs/examples/zh/exporters/PLYExporter.html +++ b/docs/examples/zh/exporters/PLYExporter.html @@ -1,5 +1,5 @@ - + @@ -19,11 +19,11 @@

    [name]

    uv coordinates. No textures or texture references are saved.

    -

    Example

    +

    代码示例

    // Instantiate an exporter - var exporter = new THREE.PLYExporter(); + var exporter = new PLYExporter(); // Parse the input and generate the ply output var data = exporter.parse( scene, options ); @@ -60,7 +60,7 @@

    [method:null parse]( [param:Object3D input], [param:Function onDone], [param

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/PLYExporter.js examples/js/exporters/PLYExporter.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/PLYExporter.js examples/jsm/exporters/PLYExporter.js]

    diff --git a/docs/examples/zh/geometries/ConvexBufferGeometry.html b/docs/examples/zh/geometries/ConvexBufferGeometry.html index d222caa6d23ae0..d3d69a4c5b7766 100644 --- a/docs/examples/zh/geometries/ConvexBufferGeometry.html +++ b/docs/examples/zh/geometries/ConvexBufferGeometry.html @@ -1,5 +1,5 @@ - + @@ -16,32 +16,18 @@

    [name]

    [name] can be used to generate a convex hull for a given array of 3D points. The average time complexity for this task is considered to be O(nlog(n)).

    - - -

    Example

    - -

    [example:webgl_geometry_convex geometry / convex ]

    - - var geometry = new THREE.ConvexBufferGeometry( points ); + var geometry = new ConvexBufferGeometry( points ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    例子

    + +

    [example:webgl_geometry_convex geometry / convex ]

    +

    Constructor

    [name]( [param:Array points] )

    @@ -53,7 +39,7 @@

    [name]( [param:Array points] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/ConvexGeometry.js examples/js/geometries/ConvexGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/ConvexGeometry.js examples/jsm/geometries/ConvexGeometry.js]

    diff --git a/docs/examples/zh/geometries/ConvexGeometry.html b/docs/examples/zh/geometries/ConvexGeometry.html index a6bb891b3ae48d..34a0b8258ccf71 100644 --- a/docs/examples/zh/geometries/ConvexGeometry.html +++ b/docs/examples/zh/geometries/ConvexGeometry.html @@ -1,5 +1,5 @@ - + @@ -15,32 +15,18 @@

    [name]

    [name] can be used to generate a convex hull for a given array of 3D points. The average time complexity for this task is considered to be O(nlog(n)).

    - - -

    Example

    - -

    [example:webgl_geometry_convex geometry / convex ]

    - - var geometry = new THREE.ConvexGeometry( points ); + var geometry = new ConvexGeometry( points ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00} ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    例子

    + +

    [example:webgl_geometry_convex geometry / convex ]

    +

    Constructor

    [name]( [param:Array points] )

    @@ -52,7 +38,7 @@

    [name]( [param:Array points] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/ConvexGeometry.js examples/js/geometries/ConvexGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/ConvexGeometry.js examples/jsm/geometries/ConvexGeometry.js]

    diff --git a/docs/examples/zh/geometries/DecalGeometry.html b/docs/examples/zh/geometries/DecalGeometry.html index 1ce4343d533e4f..c37016d7a4dbf8 100644 --- a/docs/examples/zh/geometries/DecalGeometry.html +++ b/docs/examples/zh/geometries/DecalGeometry.html @@ -1,5 +1,5 @@ - + @@ -14,32 +14,19 @@

    [name]

    [name] can be used to create a decal mesh that serves different kinds of purposes e.g. adding unique details to models, performing dynamic visual environmental changes or covering seams.

    - - -

    Example

    - -

    [example:webgl_decals decals ]

    - - var geometry = new THREE.DecalGeometry( mesh, position, orientation, size ); + + var geometry = new DecalGeometry( mesh, position, orientation, size ); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); +

    例子

    + +

    [example:webgl_decals WebGL / decals]

    +

    Constructor

    [name]( [param:Mesh mesh], [param:Vector3 position], [param:Euler orientation], [param:Vector3 size] )

    @@ -53,7 +40,7 @@

    [name]( [param:Mesh mesh], [param:Vector3 position], [param:Euler orientatio

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/geometries/DecalGeometry.js examples/js/geometries/DecalGeometry.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/DecalGeometry.js examples/jsm/geometries/DecalGeometry.js]

    diff --git a/docs/examples/zh/helpers/FaceNormalsHelper.html b/docs/examples/zh/helpers/FaceNormalsHelper.html index c2a8c89787ccdb..25b0320417b163 100644 --- a/docs/examples/zh/helpers/FaceNormalsHelper.html +++ b/docs/examples/zh/helpers/FaceNormalsHelper.html @@ -21,22 +21,23 @@

    [name]

    对于 [page:BufferGeometry] 类型几何体的对象请使用 [page:VertexNormalsHelper] 代替.

    - -

    例子

    - -
    [example:webgl_helpers WebGL / helpers]
    +

    代码示例

    geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); box = new THREE.Mesh( geometry, material ); - helper = new THREE.FaceNormalsHelper( box, 2, 0x00ff00, 1 ); + helper = new FaceNormalsHelper( box, 2, 0x00ff00, 1 ); scene.add( box ); scene.add( helper ); +

    例子

    + +
    [example:webgl_helpers WebGL / helpers]
    +

    构造函数

    diff --git a/docs/examples/zh/helpers/LightProbeHelper.html b/docs/examples/zh/helpers/LightProbeHelper.html index c72806a37c0dc8..fe82099d624dcc 100644 --- a/docs/examples/zh/helpers/LightProbeHelper.html +++ b/docs/examples/zh/helpers/LightProbeHelper.html @@ -1,5 +1,5 @@ - + @@ -16,15 +16,17 @@

    [name]

    Renders a sphere to visualize a light probe in the scene.

    -

    Example

    - -
    [example:webgl_lightprobe_cubecamera WebGL / lightprobe / cubecamera]
    +

    代码示例

    var helper = new LightProbeHelper( lightProbe, 1 ); scene.add( helper ); +

    例子

    + +

    [example:webgl_lightprobe_cubecamera WebGL / lightprobe / cubecamera]

    +

    Constructor

    diff --git a/docs/examples/zh/helpers/PositionalAudioHelper.html b/docs/examples/zh/helpers/PositionalAudioHelper.html index a76de5f6a1b1fd..81ac5bb70eb1cf 100644 --- a/docs/examples/zh/helpers/PositionalAudioHelper.html +++ b/docs/examples/zh/helpers/PositionalAudioHelper.html @@ -1,5 +1,5 @@ - + @@ -14,19 +14,17 @@

    [name]

    这一辅助对象显示[page:PositionalAudio]的方向锥。

    -

    示例

    - -
    [example:webaudio_orientation webaudio / orientation ]
    - -

    示例代码

    +

    代码示例

    -var positionalAudio = new THREE.PositionalAudio( listener ); -positionalAudio.setDirectionalCone( 180, 230, 0.1 ); + var positionalAudio = new THREE.PositionalAudio( listener ); + positionalAudio.setDirectionalCone( 180, 230, 0.1 ); -var helper = new PositionalAudioHelper( positionalAudio ); -positionalAudio.add( helper ); + var helper = new PositionalAudioHelper( positionalAudio ); + positionalAudio.add( helper ); +

    例子

    +
    [example:webaudio_orientation webaudio / orientation ]

    构造函数

    diff --git a/docs/examples/zh/helpers/RectAreaLightHelper.html b/docs/examples/zh/helpers/RectAreaLightHelper.html index 593c7f779f330d..52696d9d9675b9 100644 --- a/docs/examples/zh/helpers/RectAreaLightHelper.html +++ b/docs/examples/zh/helpers/RectAreaLightHelper.html @@ -16,14 +16,12 @@

    [name]

    创建一个表示 [page:RectAreaLight] 的辅助对象.

    -

    例子

    +

    代码示例

    -var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); - -var helper = new THREE.RectAreaLightHelper( light ); - -scene.add( helper ); + var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); + var helper = new RectAreaLightHelper( light ); + scene.add( helper ); diff --git a/docs/examples/zh/helpers/VertexNormalsHelper.html b/docs/examples/zh/helpers/VertexNormalsHelper.html index 9c8f71f0bb95bc..8fead40566cfa7 100644 --- a/docs/examples/zh/helpers/VertexNormalsHelper.html +++ b/docs/examples/zh/helpers/VertexNormalsHelper.html @@ -20,21 +20,23 @@

    [name]

    不像面法线辅助对象 [page:FaceNormalsHelper], 该辅助对象在 [page:BufferGeometry] 上也能正常运行.

    -

    例子

    - - [example:webgl_helpers WebGL / helpers] +

    代码示例

    - var geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); + var geometry = new THREE.BoxBufferGeometry( 10, 10, 10, 2, 2, 2 ); var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); var box = new THREE.Mesh( geometry, material ); - var helper = new THREE.VertexNormalsHelper( box, 2, 0x00ff00, 1 ); + var helper = new VertexNormalsHelper( box, 2, 0x00ff00, 1 ); scene.add( box ); scene.add( helper ); +

    例子

    +

    + [example:webgl_helpers WebGL / helpers] +

    构造函数

    diff --git a/docs/examples/zh/helpers/VertexTangentsHelper.html b/docs/examples/zh/helpers/VertexTangentsHelper.html index 94bbe5b61538ef..e92a8b8ac91519 100644 --- a/docs/examples/zh/helpers/VertexTangentsHelper.html +++ b/docs/examples/zh/helpers/VertexTangentsHelper.html @@ -1,5 +1,5 @@ - + @@ -20,21 +20,23 @@

    [name]

    This helper supports [page:BufferGeometry] only.

    -

    Example

    - - [example:webgl_helpers WebGL / helpers] +

    代码示例

    var geometry = new THREE.BoxBufferGeometry( 10, 10, 10, 2, 2, 2 ); var material = new THREE.MeshNormalMaterial(); var box = new THREE.Mesh( geometry, material ); - var helper = new THREE.VertexTangentsHelper( box, 1, 0x00ffff, 1 ); + var helper = new VertexTangentsHelper( box, 1, 0x00ffff, 1 ); scene.add( box ); scene.add( helper ); +

    例子

    +

    + [example:webgl_helpers WebGL / helpers] +

    Constructor

    diff --git a/docs/examples/zh/loaders/BasisTextureLoader.html b/docs/examples/zh/loaders/BasisTextureLoader.html index a986252938702b..248ab6fe500df7 100644 --- a/docs/examples/zh/loaders/BasisTextureLoader.html +++ b/docs/examples/zh/loaders/BasisTextureLoader.html @@ -1,5 +1,5 @@ - + @@ -29,10 +29,10 @@

    [name]

    directory.

    -

    Example

    +

    代码示例

    - var basisLoader = new THREE.BasisTextureLoader(); + var basisLoader = new BasisTextureLoader(); basisLoader.setTranscoderPath( 'examples/js/libs/basis/' ); basisLoader.detectSupport( renderer ); basisLoader.load( 'diffuse.basis', function ( texture ) { @@ -50,7 +50,11 @@

    Example

    } );
    - [example:webgl_loader_texture_basis] +

    例子

    + +

    + [example:webgl_loader_texture_basis] +

    Browser compatibility

    @@ -134,7 +138,7 @@

    [method:this dispose]()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/BasisTextureLoader.js examples/js/loaders/BasisTextureLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/BasisTextureLoader.js examples/jsm/loaders/BasisTextureLoader.js]

    diff --git a/docs/examples/zh/loaders/DRACOLoader.html b/docs/examples/zh/loaders/DRACOLoader.html index a84a6488eabf13..dcf62ac8b9e4fd 100644 --- a/docs/examples/zh/loaders/DRACOLoader.html +++ b/docs/examples/zh/loaders/DRACOLoader.html @@ -1,5 +1,5 @@ - + @@ -27,11 +27,11 @@

    [name]

    using Draco with glTF, an instance of DRACOLoader will be used internally by [page:GLTFLoader].

    -

    Example

    +

    代码示例

    // Instantiate a loader - var loader = new THREE.DRACOLoader(); + var loader = new DRACOLoader(); // Specify path to a folder containing WASM/JS decoding libraries. loader.setDecoderPath( '/examples/js/libs/draco/' ); @@ -66,7 +66,11 @@

    Example

    );
    - [example:webgl_loader_draco] +

    例子

    + +

    + [example:webgl_loader_draco] +

    Browser compatibility

    @@ -145,7 +149,7 @@

    [method:this dispose]()

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/DRACOLoader.js examples/js/loaders/DRACOLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/DRACOLoader.js examples/jsm/loaders/DRACOLoader.js]

    diff --git a/docs/examples/zh/loaders/GLTFLoader.html b/docs/examples/zh/loaders/GLTFLoader.html index 0288aa6b17efc1..c77bcdcf1be544 100644 --- a/docs/examples/zh/loaders/GLTFLoader.html +++ b/docs/examples/zh/loaders/GLTFLoader.html @@ -1,5 +1,5 @@ - + @@ -50,14 +50,14 @@

    扩展

    #[link:https://github.com/mrdoob/three.js/issues/12788 12788]。

    -

    示例

    +

    代码示例

    // Instantiate a loader - var loader = new THREE.GLTFLoader(); + var loader = new GLTFLoader(); // Optional: Provide a DRACOLoader instance to decode compressed mesh data - var dracoLoader = new THREE.DRACOLoader(); + var dracoLoader = new DRACOLoader(); dracoLoader.setDecoderPath( '/examples/js/libs/draco/' ); loader.setDRACOLoader( dracoLoader ); @@ -71,8 +71,8 @@

    示例

    scene.add( gltf.scene ); gltf.animations; // Array<THREE.AnimationClip> - gltf.scene; // THREE.Scene - gltf.scenes; // Array<THREE.Scene> + gltf.scene; // THREE.Group + gltf.scenes; // Array<THREE.Group> gltf.cameras; // Array<THREE.Camera> gltf.asset; // Object @@ -92,7 +92,11 @@

    示例

    );
    - [example:webgl_loader_gltf] +

    例子

    + +

    + [example:webgl_loader_gltf] +

    浏览器兼容性

    @@ -124,7 +128,7 @@

    纹理

    自定义扩展

    - 来自未知扩展的元数据会被保存到Object3D、Scene和Material实例中上的“.userData.gltfExtensions”, + 来自未知扩展的元数据会被保存到Object3D、Group和Material实例中上的“.userData.gltfExtensions”, 或被附加到 response “gltf”对象。示例:

    @@ -194,13 +198,13 @@

    [method:null parse]( [param:ArrayBuffer data], [param:String path], [param:F [page:Function onError] — (可选)若在解析过程发生错误,将被调用的函数。该函数接收error来作为参数。

    - 解析基于glTF的ArrayBuffer或JSON字符串,并在完成后触发[page:Function onLoad]回调。[page:Function onLoad]的参数将是一个包含有已加载部分的[page:object]:.[page:Scene scene]、 .[page:Array scenes]、 .[page:Array cameras]、 .[page:Array animations] 和 .[page:Object asset]。 + 解析基于glTF的ArrayBuffer或JSON字符串,并在完成后触发[page:Function onLoad]回调。[page:Function onLoad]的参数将是一个包含有已加载部分的[page:object]:.[page:Group scene]、 .[page:Array scenes]、 .[page:Array cameras]、 .[page:Array animations] 和 .[page:Object asset]。

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GLTFLoader.js examples/jsm/loaders/GLTFLoader.js]

    diff --git a/docs/examples/zh/loaders/MMDLoader.html b/docs/examples/zh/loaders/MMDLoader.html index b4ad1bd84ec060..3d70adfa582967 100644 --- a/docs/examples/zh/loaders/MMDLoader.html +++ b/docs/examples/zh/loaders/MMDLoader.html @@ -1,5 +1,5 @@ - + @@ -12,17 +12,17 @@

    MMD加载器([name])

    -

    一个用于加载MMD资源的加载器。

    +

    一个用于加载MMD资源的加载器。

    [name]从MMD资源(例如PMD、PMX、VMD和VPD文件)中创建Three.js物体(对象)。 请参阅[page:MMDAnimationHelper]来了解MMD动画的处理,例如IK、Grant和Physics。

    - 如果你想要MMD资源的原始内容,请使用.loadPMD/PMX/VMD/VPD方法。 + 如果你想要MMD资源的原始内容,请使用.loadPMD/PMX/VMD/VPD方法。 -

    示例

    +

    代码示例

    // Instantiate a loader - var loader = new THREE.MMDLoader(); + var loader = new MMDLoader(); // Load a MMD model loader.load( @@ -49,12 +49,12 @@

    示例

    );
    +

    例子

    +

    [example:webgl_loader_mmd]
    [example:webgl_loader_mmd_pose]
    - [example:webgl_loader_mmd_audio]
    - -
    -


    + [example:webgl_loader_mmd_audio] +

    构造函数

    @@ -118,7 +118,7 @@

    [method:MMDLoader setAnimationPath]( [param:String animationPath] )

    源代码

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/MMDLoader.js examples/js/loaders/MMDLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/MMDLoader.js examples/jsm/loaders/MMDLoader.js]

    diff --git a/docs/examples/zh/loaders/MTLLoader.html b/docs/examples/zh/loaders/MTLLoader.html index cb33f2009ffae4..1324a7db7a1e11 100644 --- a/docs/examples/zh/loaders/MTLLoader.html +++ b/docs/examples/zh/loaders/MTLLoader.html @@ -1,5 +1,5 @@ - + @@ -73,7 +73,7 @@

    [method:MTLLoaderMaterialCreator parse]( [param:String text, param:String pa

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/[name].js examples/js/loaders/[name].js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/[name].js examples/jsm/loaders/[name].js]

    diff --git a/docs/examples/zh/loaders/OBJLoader.html b/docs/examples/zh/loaders/OBJLoader.html index 28ec22bda53e1b..2c3f1fe705e6cc 100644 --- a/docs/examples/zh/loaders/OBJLoader.html +++ b/docs/examples/zh/loaders/OBJLoader.html @@ -1,5 +1,5 @@ - + @@ -19,12 +19,11 @@

    [name]

    vertices, and texture vertices.

    - -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.OBJLoader(); + var loader = new OBJLoader(); // load a resource loader.load( @@ -51,8 +50,10 @@

    Example

    );
    - [example:webgl_loader_obj] - +

    例子

    +

    + [example:webgl_loader_obj] +

    Constructor

    @@ -102,7 +103,7 @@

    [method:OBJLoader setMaterials]( [param:MTLLoader.MaterialCreator materials]

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/OBJLoader.js examples/js/loaders/OBJLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/OBJLoader.js examples/jsm/loaders/OBJLoader.js]

    diff --git a/docs/examples/zh/loaders/OBJLoader2.html b/docs/examples/zh/loaders/OBJLoader2.html index f84e429a606316..2af5fc6dec90e6 100644 --- a/docs/examples/zh/loaders/OBJLoader2.html +++ b/docs/examples/zh/loaders/OBJLoader2.html @@ -1,5 +1,5 @@ - + @@ -18,11 +18,11 @@

    [name]

    vertices, and texture vertices.

    -

    Examples

    +

    代码示例

    // instantiate the loader - let loader = new THREE.OBJLoader2(); + let loader = new OBJLoader2(); // function called on successful load function callbackOnLoad ( object3d ) { @@ -33,9 +33,11 @@

    Examples

    loader.load( 'obj/female02/female02.obj', callbackOnLoad, null, null, null );
    - [example:webgl_loader_obj2] - Simple example
    - [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel]))
    - +

    例子

    +

    + [example:webgl_loader_obj2] - Simple example
    + [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync or in parallel to main (see [page:OBJLoader2Parallel])) +

    Constructor

    diff --git a/docs/examples/zh/loaders/OBJLoader2Parallel.html b/docs/examples/zh/loaders/OBJLoader2Parallel.html index 11b3e021840a1f..18a9da172f9e93 100644 --- a/docs/examples/zh/loaders/OBJLoader2Parallel.html +++ b/docs/examples/zh/loaders/OBJLoader2Parallel.html @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@

    [name]

    vertices, and texture vertices.

    -

    Examples

    +

    代码示例

    // instantiate the loader @@ -36,8 +36,10 @@

    Examples

    objLoader2Parallel.load( 'models/obj/walt/WaltHead.obj', callbackOnLoad, null, null, null );
    - [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main)
    - +

    例子

    +

    + [example:webgl_loader_obj2_options] - Example for multiple use-cases (parse and load, sync (see [page:OBJLoader2]) or in parallel to main) +

    Constructor

    diff --git a/docs/examples/zh/loaders/PCDLoader.html b/docs/examples/zh/loaders/PCDLoader.html index 4d341a17f0de7d..4742116e33983d 100644 --- a/docs/examples/zh/loaders/PCDLoader.html +++ b/docs/examples/zh/loaders/PCDLoader.html @@ -1,5 +1,5 @@ - + @@ -17,12 +17,12 @@

    [name]

    Loader support ascii and (compressed) binary.

    -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.PCDLoader(); + var loader = new PCDLoader(); // load a resource loader.load( @@ -49,8 +49,10 @@

    Example

    );
    - [example:webgl_loader_pcd] - +

    例子

    +

    + [example:webgl_loader_pcd] +

    Constructor

    @@ -99,7 +101,7 @@

    [method:Object3D parse]( [param:Arraybuffer data],[param:String url] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PCDLoader.js examples/js/loaders/PCDLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PCDLoader.js examples/jsm/loaders/PCDLoader.js]

    diff --git a/docs/examples/zh/loaders/PDBLoader.html b/docs/examples/zh/loaders/PDBLoader.html index 46bd0cf7ca0203..53ec22ecaa58dd 100644 --- a/docs/examples/zh/loaders/PDBLoader.html +++ b/docs/examples/zh/loaders/PDBLoader.html @@ -1,5 +1,5 @@ - + @@ -16,16 +16,16 @@

    [name]

    The Protein Data Bank file format is a textual file describing the three-dimensional structures of molecules.

    -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.PDBLoader(); + var loader = new PDBLoader(); // load a PDB resource loader.load( // resource URL - 'models/molecules/caffeine.pdb', + 'models/pdb/caffeine.pdb', // called when the resource is loaded function ( pdb ) { @@ -51,8 +51,10 @@

    Example

    );
    - [example:webgl_loader_pdb] - +

    例子

    +

    + [example:webgl_loader_pdb] +

    Constructor

    @@ -92,7 +94,7 @@

    [method:Object parse]( [param:String text] )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PDBLoader.js examples/js/loaders/PDBLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PDBLoader.js examples/jsm/loaders/PDBLoader.js]

    diff --git a/docs/examples/zh/loaders/PRWMLoader.html b/docs/examples/zh/loaders/PRWMLoader.html index 4e58a4b5d9ea82..d35b2f4334ff6b 100644 --- a/docs/examples/zh/loaders/PRWMLoader.html +++ b/docs/examples/zh/loaders/PRWMLoader.html @@ -1,5 +1,5 @@ - + @@ -20,11 +20,11 @@

    [name]

    on this here.

    -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.PRWMLoader(); + var loader = new PRWMLoader(); // load a resource loader.load( @@ -52,8 +52,10 @@

    Example

    );
    - [example:webgl_loader_prwm] - +

    例子

    +

    + [example:webgl_loader_prwm] +

    Constructor

    @@ -99,7 +101,7 @@

    PRWMLoader.isBigEndianPlatform( )

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PRWMLoader.js examples/js/loaders/PRWMLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PRWMLoader.js examples/jsm/loaders/PRWMLoader.js]

    diff --git a/docs/examples/zh/loaders/SVGLoader.html b/docs/examples/zh/loaders/SVGLoader.html index 55148bdaf1894c..f2d17d215d6662 100644 --- a/docs/examples/zh/loaders/SVGLoader.html +++ b/docs/examples/zh/loaders/SVGLoader.html @@ -1,5 +1,5 @@ - + @@ -16,11 +16,11 @@

    [name]

    Scalable Vector Graphics is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.

    -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.SVGLoader(); + var loader = new SVGLoader(); // load a SVG resource loader.load( @@ -73,7 +73,10 @@

    Example

    );
    - [example:webgl_loader_svg] +

    例子

    +

    + [example:webgl_loader_svg] +

    Constructor

    @@ -105,7 +108,7 @@

    [method:null load]( [param:String url], [param:Function onLoad], [param:Func

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/SVGLoader.js examples/js/loaders/SVGLoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/SVGLoader.js examples/jsm/loaders/SVGLoader.js]

    diff --git a/docs/examples/zh/loaders/TGALoader.html b/docs/examples/zh/loaders/TGALoader.html index 1101c3b681adc8..2a1dc775a98a97 100644 --- a/docs/examples/zh/loaders/TGALoader.html +++ b/docs/examples/zh/loaders/TGALoader.html @@ -1,5 +1,5 @@ - + @@ -16,11 +16,11 @@

    [name]

    TGA is a raster graphics, image file format.

    -

    Example

    +

    代码示例

    // instantiate a loader - var loader = new THREE.TGALoader(); + var loader = new TGALoader(); // load a resource var texture = loader.load( @@ -52,7 +52,10 @@

    Example

    } );
    - [example:webgl_loader_texture_tga] +

    例子

    +

    + [example:webgl_loader_texture_tga] +

    Constructor

    @@ -84,7 +87,7 @@

    [method:DataTexture load]( [param:String url], [param:Function onLoad], [par

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/TGALoader.js examples/js/loaders/TGALoader.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/TGALoader.js examples/jsm/loaders/TGALoader.js]

    diff --git a/docs/examples/zh/math/Lut.html b/docs/examples/zh/math/Lut.html index 30ba06af8f76b6..1f849a35b45dbc 100644 --- a/docs/examples/zh/math/Lut.html +++ b/docs/examples/zh/math/Lut.html @@ -1,8 +1,8 @@ - + - + @@ -15,11 +15,11 @@

    [name]

    -

    Example

    - var lut = new THREE.Lut( "rainbow", 512 ); - var data = [0, 10.1, 4.2, 3.4, 63, 28]; - lut.setMax(63); - color = lut.getColor(10); +

    代码示例

    + + var lut = new Lut( 'rainbow', 512 ); + var color = lut.getColor( 0.5 ); +

    Constructor

    @@ -139,7 +139,7 @@

    [method:Lut getColor]( value ) [param:Lut this]

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/[path].js examples/js/math/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/[path].js examples/jsm/math/[path].js]

    diff --git a/docs/examples/zh/math/MeshSurfaceSampler.html b/docs/examples/zh/math/MeshSurfaceSampler.html index 9d186032233f21..32a1fd216349b7 100644 --- a/docs/examples/zh/math/MeshSurfaceSampler.html +++ b/docs/examples/zh/math/MeshSurfaceSampler.html @@ -1,5 +1,5 @@ - + @@ -14,11 +14,11 @@

    [name]

    Weighted sampling is useful for effects like heavier foliage growth in certain areas of terrain, or concentrated particle emissions from specific parts of a mesh. Vertex weights may be written programmatically, or painted by hand as vertex colors in 3D tools like Blender.

    -

    Example

    +

    代码示例

    - // Create a sampler for a BufferGeometry surface. - var sampler = new THREE.MeshSurfaceSampler( surfaceMesh ) + // Create a sampler for a Mesh surface. + var sampler = new MeshSurfaceSampler( surfaceMesh ) .setWeightAttribute( 'color' ) .build(); @@ -45,10 +45,10 @@

    Example

    scene.add( mesh );
    - [example:webgl_instancing_scatter] - -
    -
    +

    例子

    +

    + [example:webgl_instancing_scatter] +

    Constructor

    @@ -80,7 +80,7 @@

    [method:this sample]( [param:Vector3 targetPosition], [param:Vector3 targetN

    Source

    - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/MeshSurfaceSampler.js examples/js/math/MeshSurfaceSampler.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/MeshSurfaceSampler.js examples/jsm/math/MeshSurfaceSampler.js]

    diff --git a/docs/examples/zh/math/convexhull/ConvexHull.html b/docs/examples/zh/math/convexhull/ConvexHull.html index 68ca0d8e1e298d..4d1067a44bec2f 100644 --- a/docs/examples/zh/math/convexhull/ConvexHull.html +++ b/docs/examples/zh/math/convexhull/ConvexHull.html @@ -1,5 +1,5 @@ - + @@ -20,6 +20,7 @@

    Constructor

    [name]()

    + Creates a new instance of [name].

    Properties

    @@ -57,28 +58,35 @@

    [property:Array vertices]

    Methods

    [method:HalfEdge addAdjoiningFace]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    - [page:HalfEdge horizonEdge] - A single edge of the horizon.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.
    + [page:HalfEdge horizonEdge] - A single edge of the horizon.

    -

    Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order. - All the half edges are created in CCW order thus the face is always pointing outside the hull

    + Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order. + All the half edges are created in CCW order thus the face is always pointing outside the hull +

    [method:ConvexHull addNewFaces]( [param:VertexNode eyeVertex], [param:HalfEdge horizonEdge] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    - [page:HalfEdge horizon] - An array of half-edges that form the horizon.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.
    + [page:HalfEdge horizon] - An array of half-edges that form the horizon.

    -

    Adds 'horizon.length' faces to the hull, each face will be linked with the horizon opposite face and the face on the left/right.

    + Adds 'horizon.length' faces to the hull, each face will be linked with the horizon opposite face and the face on the left/right. +

    [method:ConvexHull addVertexToFace]( [param:VertexNode vertex], [param:Face face] )

    - [page:VertexNodeNode vertex] - The vertex to add.

    - [page:Face face] - The target face.

    +

    + [page:VertexNodeNode vertex] - The vertex to add.
    + [page:Face face] - The target face.

    -

    Adds a vertex to the 'assigned' list of vertices and assigns it to the given face.

    + Adds a vertex to the 'assigned' list of vertices and assigns it to the given face. +

    [method:ConvexHull addVertexToHull]( [param:VertexNode eyeVertex] )

    - [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    +

    + [page:VertexNode eyeVertex] - The vertex that is added to the hull.

    -

    Adds a vertex to the hull with the following algorithm + Adds a vertex to the hull with the following algorithm

    • Compute the 'horizon' which is a chain of half edges. For an edge to belong to this group it must be the edge connecting a face that can see 'eyeVertex' and a face which cannot see 'eyeVertex'.
    • All the faces that can see 'eyeVertex' have its visible vertices removed from the assigned vertex list.
    • @@ -100,27 +108,32 @@

      [method:Object computeExtremes]()

      Computes the extremes values (min/max vectors) which will be used to compute the inital hull.

      [method:ConvexHull computeHorizon]( [param:Vector3 eyePoint], [param:HalfEdge crossEdge], [param:Face face], [param:Array horizon] )

      - [page:Vector3 eyePoint] - The 3D-coordinates of a point.

      - [page:HalfEdge crossEdge] - The edge used to jump to the current face.

      - [page:Face face] - The current face being tested.

      - [page:Array horizon] - The edges that form part of the horizon in CCW order.

      +

      + [page:Vector3 eyePoint] - The 3D-coordinates of a point.
      + [page:HalfEdge crossEdge] - The edge used to jump to the current face.
      + [page:Face face] - The current face being tested.
      + [page:Array horizon] - The edges that form part of the horizon in CCW order.

      -

      Computes a chain of half edges in CCW order called the 'horizon'. For an edge to be part of the horizon it must join a face that can see 'eyePoint' and a face that cannot see 'eyePoint'.

      + Computes a chain of half edges in CCW order called the 'horizon'. For an edge to be part of the horizon it must join a face that can see 'eyePoint' and a face that cannot see 'eyePoint'. +

      [method:ConvexHull computeInitialHull]()

      Computes the initial simplex assigning to its faces all the points that are candidates to form part of the hull.

      [method:ConvexHull containsPoint]( [param:Vector3 point] )

      - [page:Vector3 point] - A point in 3D space.

      +

      + [page:Vector3 point] - A point in 3D space.

      -

      Returns *true* if the given point is inside this convex hull.

      + Returns *true* if the given point is inside this convex hull. +

      [method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absorbingFace] )

      - [page:Face face] - The given face.

      - [page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.

      +

      + [page:Face face] - The given face.
      + [page:Face absorbingFace] - An optional face that tries to absorb the vertices of the first face.

      -

      Removes all the visible vertices that 'face' is able to see. + Removes all the visible vertices that 'face' is able to see.

      • If 'absorbingFace' doesn't exist, then all the removed vertices will be added to the 'unassigned' vertex list.
      • If 'absorbingFace' exists, then this method will assign all the vertices of 'face' that can see 'absorbingFace'.
      • @@ -129,15 +142,19 @@

        [method:ConvexHull deleteFaceVertices]( [param:Face face], [param:Face absor

        [method:Vector3 intersectRay]( [param:Ray ray], [param:Vector3 target] )

        - [page:Ray ray] - The given ray.

        - [page:Vector3 target] - The target vector representing the intersection point.

        +

        + [page:Ray ray] - The given ray.
        + [page:Vector3 target] - The target vector representing the intersection point.

        -

        Performs a ray intersection test with this convext hull. If no intersection is found, *null* is returned.

        + Performs a ray intersection test with this convext hull. If no intersection is found, *null* is returned. +

        [method:Boolean intersectsRay]( [param:Ray ray] )

        - [page:Ray ray] - The given ray.

        +

        + [page:Ray ray] - The given ray.

        -

        Returns *true* if the given ray intersects with this convex hull.

        + Returns *true* if the given ray intersects with this convex hull. +

        [method:ConvexHull makeEmpty]()

        @@ -158,36 +175,45 @@

        [method:ConvexHull reindexFaces]()

        Removes inactive (e.g. deleted) faces from the internal face list.

        [method:VertexNode removeAllVerticesFromFace]( [param:Face face] )

        - [page:Face face] - The given face.

        +

        + [page:Face face] - The given face.

        -

        Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list.

        + Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list. +

        [method:ConvexHull removeVertexFromFace]( [param:VertexNode vertex], [param:Face face] )

        - [page:VertexNode vertex] - The vertex to remove.

        - [page:Face face] - The target face.

        +

        + [page:VertexNode vertex] - The vertex to remove.
        + [page:Face face] - The target face.

        -

        Removes a vertex from the 'assigned' list of vertices and from the given face. It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal.

        + Removes a vertex from the 'assigned' list of vertices and from the given face. It also makes sure that the link from 'face' to the first vertex it sees in 'assigned' is linked correctly after the removal. +

        [method:ConvexHull resolveUnassignedPoints]( [param:Array newFaces] )

        - [page:Face newFaces] - An array of new faces.

        +

        + [page:Face newFaces] - An array of new faces.

        -

        Reassigns as many vertices as possible from the unassigned list to the new faces.

        + Reassigns as many vertices as possible from the unassigned list to the new faces. +

        [method:ConvexHull setFromObject]( [param:Object3D object] )

        - [page:Object3D object] - [page:Object3D] to compute the convex hull of.

        +

        + [page:Object3D object] - [page:Object3D] to compute the convex hull of.

        -

        Computes the convex hull of an [page:Object3D] (including its children), - accounting for the world transforms of both the object and its childrens.

        + Computes the convex hull of an [page:Object3D] (including its children),accounting for the world transforms of both the object and its childrens. +

        [method:ConvexHull setFromPoints]( [param:Array points] )

        - [page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.

        +

        + [page:Array points] - Array of [page:Vector3 Vector3s] that the resulting convex hull will contain.

        -

        Computes to convex hull for the given array of points.

        + Computes to convex hull for the given array of points. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/ConvexHull.js]

        diff --git a/docs/examples/zh/math/convexhull/Face.html b/docs/examples/zh/math/convexhull/Face.html index 98cf402834f89b..fe84efade997f9 100644 --- a/docs/examples/zh/math/convexhull/Face.html +++ b/docs/examples/zh/math/convexhull/Face.html @@ -1,5 +1,5 @@ - + @@ -20,6 +20,7 @@

        Constructor

        [name]()

        + Creates a new instance of [name].

        Properties

        @@ -62,30 +63,36 @@

        [property:HalfEdge edge]

        Methods

        [method:Face create]( [param:VertexNode a], [param:VertexNode b], [param:VertexNode c] )

        - [page:VertexNode a] - First vertex of the face.

        - [page:VertexNode b] - Second vertex of the face.

        - [page:VertexNode c] - Third vertex of the face.

        +

        + [page:VertexNode a] - First vertex of the face.
        + [page:VertexNode b] - Second vertex of the face.
        + [page:VertexNode c] - Third vertex of the face.

        -

        Creates a face.

        + Creates a face. +

        [method:HalfEdge getEdge]( [param:Integer i] )

        - [page:Integer i] - The index of the edge.

        +

        + [page:Integer i] - The index of the edge.

        -

        Returns an edge by the given index.

        + Returns an edge by the given index. +

        [method:Face compute] ()

        Computes all properties of the face.

        [method:Float distanceToPoint]( [param:Vector3 point] )

        - [page:Vector3 point] - Any point in 3D space.

        +

        + [page:Vector3 point] - Any point in 3D space.

        -

        Returns the signed distance from a given point to the plane representation of this face.

        + Returns the signed distance from a given point to the plane representation of this face. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/zh/math/convexhull/HalfEdge.html b/docs/examples/zh/math/convexhull/HalfEdge.html index 200ed43442bcbd..7b557862d97e60 100644 --- a/docs/examples/zh/math/convexhull/HalfEdge.html +++ b/docs/examples/zh/math/convexhull/HalfEdge.html @@ -1,5 +1,5 @@ - + @@ -20,10 +20,11 @@

        Constructor

        [name]( [param:VertexNode vertex], [param:Face face] )

        - [page:VertexNode vertex] - [page:VertexNode] A reference to its destination vertex.

        - [page:Face face] - [page:Face] A reference to its face.
        -

        + [page:VertexNode vertex] - [page:VertexNode] A reference to its destination vertex.
        + [page:Face face] - [page:Face] A reference to its face.

        + Creates a new instance of [name]. +

        Properties

        [property:VertexNode vertex]

        @@ -68,14 +69,16 @@

        [method:Float lengthSquared]()

        (straight-line length) of the edge.

        [method:HalfEdge setTwin]( [param:HalfEdge edge] )

        - [page:HalfEdge edge] - Any half-edge.

        +

        + [page:HalfEdge edge] - Any half-edge.

        -

        Sets the twin edge of this half-edge. It also ensures that the twin reference of the given half-edge is correctly set.

        + Sets the twin edge of this half-edge. It also ensures that the twin reference of the given half-edge is correctly set. +

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/zh/math/convexhull/VertexList.html b/docs/examples/zh/math/convexhull/VertexList.html index 54fc759aefcbe9..fa458dc841b245 100644 --- a/docs/examples/zh/math/convexhull/VertexList.html +++ b/docs/examples/zh/math/convexhull/VertexList.html @@ -1,5 +1,5 @@ - + @@ -20,6 +20,7 @@

        Constructor

        [name]()

        + Creates a new instance of [name].

        Properties

        @@ -47,38 +48,48 @@

        [method:VertexList clear]()

        [method:VertexList insertBefore]( [param:Vertex target], [param:Vertex vertex] )

        - [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.

        - [page:Vertex vertex] - The vertex to insert.

        -

        + [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.
        + [page:Vertex vertex] - The vertex to insert.

        -

        Inserts a vertex before a target vertex.

        + Inserts a vertex before a target vertex. +

        [method:VertexList insertAfter]( [param:Vertex target], [param:Vertex vertex] )

        - [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.

        - [page:Vertex vertex] - The vertex to insert.

        +

        + [page:Vertex target] - The target vertex. It's assumed that this vertex belongs to the linked list.
        + [page:Vertex vertex] - The vertex to insert.

        -

        Inserts a vertex after a target vertex.

        + Inserts a vertex after a target vertex. +

        [method:VertexList append]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The vertex to append.

        +

        + [page:Vertex vertex] - The vertex to append.

        -

        Appends a vertex to the end of the linked list.

        + Appends a vertex to the end of the linked list. +

        [method:VertexList appendChain]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The head vertex of a chain of vertices.

        +

        + [page:Vertex vertex] - The head vertex of a chain of vertices.

        -

        Appends a chain of vertices where the given vertex is the head.

        + Appends a chain of vertices where the given vertex is the head. +

        [method:VertexList remove]( [param:Vertex vertex] )

        - [page:Vertex vertex] - The vertex to remove.

        +

        + [page:Vertex vertex] - The vertex to remove.

        -

        Removes a vertex from the linked list.

        + Removes a vertex from the linked list. +

        [method:VertexList removeSubList]( [param:Vertex a], [param:Vertex b] )

        - [page:Vertex a] - The head of the sublist.

        - [page:Vertex b] - The tail of the sublist.

        +

        + [page:Vertex a] - The head of the sublist.
        + [page:Vertex b] - The tail of the sublist.

        -

        Removes a sublist of vertices from the linked list.

        + Removes a sublist of vertices from the linked list. +

        [method:Boolean isEmpty]()

        @@ -87,7 +98,7 @@

        [method:Boolean isEmpty]()

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/zh/math/convexhull/VertexNode.html b/docs/examples/zh/math/convexhull/VertexNode.html index 179dc88c3bfdcc..c41f7ff27ac699 100644 --- a/docs/examples/zh/math/convexhull/VertexNode.html +++ b/docs/examples/zh/math/convexhull/VertexNode.html @@ -1,5 +1,5 @@ - + @@ -21,6 +21,8 @@

        Constructor

        [name]( [param:Vector3 point] )

        [page:Vector3 point] - [page:Vector3] A point (x, y, z) in 3D space.

        + + Creates a new instance of [name].

        Properties

        @@ -48,7 +50,7 @@

        [property:Face face]

        Source

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/math/ConvexHull.js examples/js/math/ConvexHull.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/math/ConvexHull.js examples/jsm/math/ConvexHull.js]

        diff --git a/docs/examples/zh/objects/Lensflare.html b/docs/examples/zh/objects/Lensflare.html index 1d57b83707eb2e..8354e52c5993f7 100644 --- a/docs/examples/zh/objects/Lensflare.html +++ b/docs/examples/zh/objects/Lensflare.html @@ -1,5 +1,5 @@ - + @@ -13,32 +13,33 @@

        镜头光晕([name])

        - 创建一个模拟追踪着灯光的镜头光晕。

        + 创建一个模拟追踪着灯光的镜头光晕。

        -

        示例

        +

        代码示例

        -

        - [example:webgl_lensflares lensflares] + + var light = new THREE.PointLight( 0xffffff, 1.5, 2000 ); - -var light = new THREE.PointLight( 0xffffff, 1.5, 2000 ); + var textureLoader = new THREE.TextureLoader(); -var textureLoader = new THREE.TextureLoader(); + var textureFlare0 = textureLoader.load( "textures/lensflare/lensflare0.png" ); + var textureFlare1 = textureLoader.load( "textures/lensflare/lensflare2.png" ); + var textureFlare2 = textureLoader.load( "textures/lensflare/lensflare3.png" ); -var textureFlare0 = textureLoader.load( "textures/lensflare/lensflare0.png" ); -var textureFlare1 = textureLoader.load( "textures/lensflare/lensflare2.png" ); -var textureFlare2 = textureLoader.load( "textures/lensflare/lensflare3.png" ); + var lensflare = new Lensflare(); -var lensflare = new THREE.Lensflare(); + lensflare.addElement( new LensflareElement( textureFlare0, 512, 0 ) ); + lensflare.addElement( new LensflareElement( textureFlare1, 512, 0 ) ); + lensflare.addElement( new LensflareElement( textureFlare2, 60, 0.6 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare0, 512, 0 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare1, 512, 0 ) ); -lensflare.addElement( new THREE.LensflareElement( textureFlare2, 60, 0.6 ) ); + light.add( lensflare ); + -light.add( lensflare ); - +

        例子

        +

        + [example:webgl_lensflares WebGL / lensflares]

        Constructor

        @@ -59,7 +60,7 @@

        属性

        源代码

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/objects/Lensflare.js examples/js/objects/Lensflare.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Lensflare.js examples/jsm/objects/Lensflare.js]

        diff --git a/docs/examples/zh/postprocessing/EffectComposer.html b/docs/examples/zh/postprocessing/EffectComposer.html index 8506a8038f6893..d3d09f8a037c55 100644 --- a/docs/examples/zh/postprocessing/EffectComposer.html +++ b/docs/examples/zh/postprocessing/EffectComposer.html @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@

        效果合成器([name])

        后期处理过程根据它们添加/插入的顺序来执行,最后一个过程会被自动渲染到屏幕上。

        -

        示例

        +

        例子

        [example:webgl_postprocessing postprocessing]
        @@ -55,7 +55,7 @@

        [name]( [param:WebGLRenderer renderer], [param:WebGLRenderTarget renderTarge

        属性

        -

        [property:Boolean passes]

        +

        [property:Array passes]

        一个用于表示后期处理过程链(包含顺序)的数组。

        @@ -152,7 +152,7 @@

        [method:void swapBuffers]()

        源代码

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/postprocessing/EffectComposer.js examples/js/postprocessing/EffectComposer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/postprocessing/EffectComposer.js examples/jsm/postprocessing/EffectComposer.js]

        diff --git a/docs/examples/zh/renderers/CSS2DRenderer.html b/docs/examples/zh/renderers/CSS2DRenderer.html index 5fbada5783a825..591693d7653fc7 100644 --- a/docs/examples/zh/renderers/CSS2DRenderer.html +++ b/docs/examples/zh/renderers/CSS2DRenderer.html @@ -1,5 +1,5 @@ - + @@ -14,23 +14,7 @@

        CSS 2D渲染器([name])

        如果你希望将三维物体和基于HTML的标签相结合,则这一渲染器将十分有用。在这里,各个DOM元素也被包含到一个*CSS2DObject*实例中,并被添加到场景图中。

        - - -

        示例

        +

        例子

        [example:css2d_label]
        @@ -61,7 +45,7 @@

        [method:null setSize]([param:Number width], [param:Number height])

        源代码

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CSS2DRenderer.js examples/js/renderers/CSS2DRenderer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS2DRenderer.js examples/jsm/renderers/CSS2DRenderer.js]

        diff --git a/docs/examples/zh/renderers/CSS3DRenderer.html b/docs/examples/zh/renderers/CSS3DRenderer.html index e4376cb28d7e6d..2b8213edd9fd0d 100644 --- a/docs/examples/zh/renderers/CSS3DRenderer.html +++ b/docs/examples/zh/renderers/CSS3DRenderer.html @@ -1,5 +1,5 @@ - + @@ -24,23 +24,7 @@

        CSS 3D渲染器([name])

        因此,[name]仅仅关注普通的DOM元素,这些元素被包含到了特殊的对象中(*CSS3DObject*或者*CSS3DSprite*),然后被加入到场景图中。

        - - -

        示例

        +

        例子

        [example:css3d_molecules molecules]
        @@ -74,7 +58,7 @@

        [method:null setSize]([param:Number width], [param:Number height])

        源代码

        - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/renderers/CSS3DRenderer.js examples/js/renderers/CSS3DRenderer.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/CSS3DRenderer.js examples/jsm/renderers/CSS3DRenderer.js]

        diff --git a/docs/examples/zh/renderers/SVGRenderer.html b/docs/examples/zh/renderers/SVGRenderer.html index 27fc606c67e46f..775e6acd9115ff 100644 --- a/docs/examples/zh/renderers/SVGRenderer.html +++ b/docs/examples/zh/renderers/SVGRenderer.html @@ -1,5 +1,5 @@ - + @@ -34,23 +34,7 @@

        SVG渲染器([name])

      - - -

      示例

      +

      例子

      [example:svg_lines lines]
      @@ -95,6 +79,8 @@

      [method:null setSize]( [param:Number width], [param:Number height] )

      源代码

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/[path].js examples/js/[path].js] +

      + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/renderers/SVGRenderer.js examples/jsm/renderers/SVGRenderer.js] +

      diff --git a/docs/examples/zh/utils/BufferGeometryUtils.html b/docs/examples/zh/utils/BufferGeometryUtils.html index b76c448c99cf9a..23b9af647bdef9 100644 --- a/docs/examples/zh/utils/BufferGeometryUtils.html +++ b/docs/examples/zh/utils/BufferGeometryUtils.html @@ -1,5 +1,5 @@ - + @@ -11,7 +11,7 @@

      [name]

      - A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.

      + A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.

      @@ -21,7 +21,7 @@

      [method:null computeTangents]( [param:BufferGeometry geometry] )

      geometry -- A [page:BufferGeometry BufferGeometry] instance, which must have index, position, normal, and uv attributes.

      - Calculates and adds tangent attribute to a geometry.

      + Calculates and adds tangent attribute to a geometry.

      @@ -31,7 +31,7 @@

      [method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [pa useGroups -- Whether groups should be generated for the merged geometry or not.

      Merges a set of geometries into a single instance. All geometries must have compatible attributes. - If merge does not succeed, the method returns null.

      + If merge does not succeed, the method returns null.

      @@ -86,7 +86,7 @@

      [method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry]

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/BufferGeometryUtils.js examples/js/utils/BufferGeometryUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]

      diff --git a/docs/examples/zh/utils/SceneUtils.html b/docs/examples/zh/utils/SceneUtils.html index f17fc4923ec154..c1581acc3ade2e 100644 --- a/docs/examples/zh/utils/SceneUtils.html +++ b/docs/examples/zh/utils/SceneUtils.html @@ -1,5 +1,5 @@ - + @@ -29,7 +29,7 @@

      [method:Group createMultiMaterialObject]( [param:Geometry geometry], [param:

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SceneUtils.js examples/js/utils/SceneUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SceneUtils.js examples/jsm/utils/SceneUtils.js]

      diff --git a/docs/examples/zh/utils/SkeletonUtils.html b/docs/examples/zh/utils/SkeletonUtils.html index ba9ed261a60502..e63064c6969810 100644 --- a/docs/examples/zh/utils/SkeletonUtils.html +++ b/docs/examples/zh/utils/SkeletonUtils.html @@ -1,5 +1,5 @@ - + @@ -56,7 +56,7 @@

      [method:AnimationClip retargetClip]( [param:SkeletonHelper target], [param:S

      Source

      - [link:https://github.com/mrdoob/three.js/blob/master/examples/js/utils/SkeletonUtils.js examples/js/utils/SkeletonUtils.js] + [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/SkeletonUtils.js examples/jsm/utils/SkeletonUtils.js]

      diff --git a/docs/index.html b/docs/index.html index 81853e7cc832cc..b9dbf772251a9f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -10,7 +10,7 @@ -
      +