copper3d 3.9.2 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +95 -5
  2. package/dist/Loader/copperNrrdLoader.d.ts +74 -0
  3. package/dist/Loader/copperNrrdLoader.js +182 -8
  4. package/dist/Loader/copperNrrdLoader.js.map +1 -1
  5. package/dist/Loader/nrrdWorker.d.ts +1 -0
  6. package/dist/Loader/nrrdWorker.js +29 -0
  7. package/dist/Loader/nrrdWorker.js.map +1 -0
  8. package/dist/Loader/nrrdWorkerCore.d.ts +87 -0
  9. package/dist/Loader/nrrdWorkerCore.js +223 -0
  10. package/dist/Loader/nrrdWorkerCore.js.map +1 -0
  11. package/dist/Utils/segmentation/NrrdTools.d.ts +62 -0
  12. package/dist/Utils/segmentation/NrrdTools.js +108 -0
  13. package/dist/Utils/segmentation/NrrdTools.js.map +1 -1
  14. package/dist/Utils/segmentation/tools/DataLoader.d.ts +48 -1
  15. package/dist/Utils/segmentation/tools/DataLoader.js +128 -30
  16. package/dist/Utils/segmentation/tools/DataLoader.js.map +1 -1
  17. package/dist/Utils/segmentation/tools/DragSliceTool.js +10 -3
  18. package/dist/Utils/segmentation/tools/DragSliceTool.js.map +1 -1
  19. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js +11 -0
  20. package/dist/Utils/segmentation/tools/SliceRenderPipeline.js.map +1 -1
  21. package/dist/Utils/segmentation/tools/ToolHost.d.ts +9 -1
  22. package/dist/bundle.esm.js +449 -47
  23. package/dist/bundle.umd.js +450 -46
  24. package/dist/index.d.ts +5 -3
  25. package/dist/index.js +3 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/types/Loader/copperNrrdLoader.d.ts +74 -0
  28. package/dist/types/Loader/nrrdWorker.d.ts +1 -0
  29. package/dist/types/Loader/nrrdWorkerCore.d.ts +87 -0
  30. package/dist/types/Utils/segmentation/NrrdTools.d.ts +62 -0
  31. package/dist/types/Utils/segmentation/tools/DataLoader.d.ts +48 -1
  32. package/dist/types/Utils/segmentation/tools/ToolHost.d.ts +9 -1
  33. package/dist/types/index.d.ts +5 -3
  34. package/package.json +1 -1
@@ -80504,9 +80504,9 @@ void main() {
80504
80504
  var dicomParser = unwrapExports(dicomParser_min);
80505
80505
 
80506
80506
  // import { TAG_DICT } from "../lib/dicom_pharser_dictionary";
80507
- const loader$1 = new FileLoader().setResponseType("arraybuffer");
80507
+ const loader = new FileLoader().setResponseType("arraybuffer");
80508
80508
  function copperDicomLoader(url, callback) {
80509
- loader$1.load(url, (arrayBuffer) => {
80509
+ loader.load(url, (arrayBuffer) => {
80510
80510
  var _a;
80511
80511
  var dicomFileAsBuffer = new Uint8Array(arrayBuffer);
80512
80512
  const dataSet = dicomParser.parseDicom(dicomFileAsBuffer);
@@ -85523,9 +85523,145 @@ void main() {
85523
85523
  return newPixels;
85524
85524
  }
85525
85525
 
85526
- let loader;
85527
- loader = new NRRDLoader();
85528
- // loader.setSegmentationn(true);
85526
+ const workerCode = "(function () {\n 'use strict';\n\n /******************************************************************************\r\n Copyright (c) Microsoft Corporation.\r\n\r\n Permission to use, copy, modify, and/or distribute this software for any\r\n purpose with or without fee is hereby granted.\r\n\r\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\n AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\n LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\n OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\n PERFORMANCE OF THIS SOFTWARE.\r\n ***************************************************************************** */\r\n\r\n function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n }\r\n\r\n typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n };\n\n /**\n * @license\n * Copyright 2010-2026 Three.js Authors\n * SPDX-License-Identifier: MIT\n */\n const REVISION = '185';\n\n /**\n * Only front faces are rendered.\n *\n * @type {number}\n * @constant\n */\n const FrontSide = 0;\n\n /**\n * Only back faces are rendered.\n *\n * @type {number}\n * @constant\n */\n const BackSide = 1;\n\n /**\n * Both front and back faces are rendered.\n *\n * @type {number}\n * @constant\n */\n const DoubleSide = 2;\n\n /**\n * The default blending.\n *\n * @type {number}\n * @constant\n */\n const NormalBlending = 1;\n\n /**\n * A `source + destination` blending equation.\n *\n * @type {number}\n * @constant\n */\n const AddEquation = 100;\n\n /**\n * Multiplies all colors by the source alpha value.\n *\n * @type {number}\n * @constant\n */\n const SrcAlphaFactor = 204;\n\n /**\n * Multiplies all colors by 1 minus the source alpha value.\n *\n * @type {number}\n * @constant\n */\n const OneMinusSrcAlphaFactor = 205;\n\n /**\n * Pass if the incoming value is less than or equal to the depth buffer value.\n *\n * @type {number}\n * @constant\n */\n const LessEqualDepth = 3;\n\n /**\n * Multiplies the environment map color with the surface color.\n *\n * @type {number}\n * @constant\n */\n const MultiplyOperation = 0;\n\n /**\n * Maps textures using the geometry's UV coordinates.\n *\n * @type {number}\n * @constant\n */\n const UVMapping = 300;\n\n /**\n * The texture will simply repeat to infinity.\n *\n * @type {number}\n * @constant\n */\n const RepeatWrapping = 1000;\n\n /**\n * The last pixel of the texture stretches to the edge of the mesh.\n *\n * @type {number}\n * @constant\n */\n const ClampToEdgeWrapping = 1001;\n\n /**\n * The texture will repeats to infinity, mirroring on each repeat.\n *\n * @type {number}\n * @constant\n */\n const MirroredRepeatWrapping = 1002;\n\n /**\n * Returns the weighted average of the four texture elements that are closest to the specified\n * texture coordinates, and can include items wrapped or repeated from other parts of a texture,\n * depending on the values of `wrapS` and `wrapT`, and on the exact mapping.\n *\n * @type {number}\n * @constant\n */\n const LinearFilter = 1006;\n\n /**\n * Chooses the two mipmaps that most closely match the size of the pixel being textured and uses\n * the `LinearFilter` criterion to produce a texture value from each mipmap. The final texture value\n * is a weighted average of those two values.\n *\n * @type {number}\n * @constant\n */\n const LinearMipmapLinearFilter = 1008;\n\n /**\n * An unsigned byte data type for textures.\n *\n * @type {number}\n * @constant\n */\n const UnsignedByteType = 1009;\n\n /**\n * A float data type for textures.\n *\n * @type {number}\n * @constant\n */\n const FloatType = 1015;\n\n /**\n * Reads the red, green, blue and alpha components.\n *\n * @type {number}\n * @constant\n */\n const RGBAFormat = 1023;\n\n // Color space string identifiers, matching CSS Color Module Level 4 and WebGPU names where available.\n\n /**\n * No color space.\n *\n * @type {string}\n * @constant\n */\n const NoColorSpace = '';\n\n /**\n * sRGB color space.\n *\n * @type {string}\n * @constant\n */\n const SRGBColorSpace = 'srgb';\n\n /**\n * sRGB-linear color space.\n *\n * @type {string}\n * @constant\n */\n const LinearSRGBColorSpace = 'srgb-linear';\n\n /**\n * Linear transfer function.\n *\n * @type {string}\n * @constant\n */\n const LinearTransfer = 'linear';\n\n /**\n * sRGB transfer function.\n *\n * @type {string}\n * @constant\n */\n const SRGBTransfer = 'srgb';\n\n /**\n * Keeps the current value.\n *\n * @type {number}\n * @constant\n */\n const KeepStencilOp = 7680;\n\n /**\n * Will always return true.\n *\n * @type {number}\n * @constant\n */\n const AlwaysStencilFunc = 519;\n\n /**\n * The contents are intended to be specified once by the application, and used many\n * times as the source for drawing and image specification commands.\n *\n * @type {number}\n * @constant\n */\n const StaticDrawUsage = 35044;\n\n /**\n * WebGL coordinate system.\n *\n * @type {number}\n * @constant\n */\n const WebGLCoordinateSystem = 2000;\n\n /**\n * WebGPU coordinate system.\n *\n * @type {number}\n * @constant\n */\n const WebGPUCoordinateSystem = 2001;\n\n /**\n * This type represents mouse buttons and interaction types in context of controls.\n *\n * @typedef {Object} ConstantsMouse\n * @property {number} MIDDLE - The left mouse button.\n * @property {number} LEFT - The middle mouse button.\n * @property {number} RIGHT - The right mouse button.\n * @property {number} ROTATE - A rotate interaction.\n * @property {number} DOLLY - A dolly interaction.\n * @property {number} PAN - A pan interaction.\n **/\n\n /**\n * This type represents touch interaction types in context of controls.\n *\n * @typedef {Object} ConstantsTouch\n * @property {number} ROTATE - A rotate interaction.\n * @property {number} PAN - A pan interaction.\n * @property {number} DOLLY_PAN - The dolly-pan interaction.\n * @property {number} DOLLY_ROTATE - A dolly-rotate interaction.\n **/\n\n /**\n * This type represents the different timestamp query types.\n *\n * @typedef {Object} ConstantsTimestampQuery\n * @property {string} COMPUTE - A `compute` timestamp query.\n * @property {string} RENDER - A `render` timestamp query.\n **/\n\n /**\n * Represents the different interpolation sampling types.\n *\n * @typedef {Object} ConstantsInterpolationSamplingType\n * @property {string} PERSPECTIVE - Perspective-correct interpolation.\n * @property {string} LINEAR - Linear interpolation.\n * @property {string} FLAT - Flat interpolation.\n */\n\n /**\n * Represents the different interpolation sampling modes.\n *\n * @typedef {Object} ConstantsInterpolationSamplingMode\n * @property {string} NORMAL - Normal sampling mode.\n * @property {string} CENTROID - Centroid sampling mode.\n * @property {string} SAMPLE - Sample-specific sampling mode.\n * @property {string} FIRST - Flat interpolation using the first vertex.\n * @property {string} EITHER - Flat interpolation using either vertex.\n */\n\n /**\n * Checks if an array contains values that require Uint32 representation.\n *\n * This function determines whether the array contains any values >= 65535,\n * which would require a Uint32Array rather than a Uint16Array for proper storage.\n * The function iterates from the end of the array, assuming larger values are\n * typically located at the end.\n *\n * @private\n * @param {Array<number>} array - The array to check.\n * @return {boolean} True if the array contains values >= 65535, false otherwise.\n */\n function arrayNeedsUint32( array ) {\n\n \t// assumes larger values usually on last\n\n \tfor ( let i = array.length - 1; i >= 0; -- i ) {\n\n \t\tif ( array[ i ] >= 65535 ) return true; // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565\n\n \t}\n\n \treturn false;\n\n }\n\n /**\n * Creates an XHTML element with the specified tag name.\n *\n * This function uses the XHTML namespace to create DOM elements,\n * ensuring proper element creation in XML-based contexts.\n *\n * @private\n * @param {string} name - The tag name of the element to create (e.g., 'canvas', 'div').\n * @return {HTMLElement} The created XHTML element.\n */\n function createElementNS( name ) {\n\n \treturn document.createElementNS( 'http://www.w3.org/1999/xhtml', name );\n\n }\n\n /**\n * Internal cache for tracking warning messages to prevent duplicate warnings.\n *\n * @private\n * @type {Object<string, boolean>}\n */\n const _cache = {};\n\n /**\n * Enhances log/warn/error messages related to TSL.\n *\n * @param {Array<any>} params - The original message parameters.\n * @returns {Array<any>} The filtered and enhanced message parameters.\n */\n function enhanceLogMessage( params ) {\n\n \tconst message = params[ 0 ];\n\n \tif ( typeof message === 'string' && message.startsWith( 'TSL:' ) ) {\n\n \t\tconst stackTrace = params[ 1 ];\n\n \t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n \t\t\tparams[ 0 ] += ' ' + stackTrace.getLocation();\n\n \t\t} else {\n\n \t\t\tparams[ 1 ] = 'Stack trace not available. Enable \"THREE.Node.captureStackTrace\" to capture stack traces.';\n\n \t\t}\n\n \t}\n\n \treturn params;\n\n }\n\n /**\n * Logs a warning message with the 'THREE.' prefix.\n *\n * If a custom console function is set via setConsoleFunction(), it will be used\n * instead of the native console.warn. The first parameter is treated as the\n * method name and is automatically prefixed with 'THREE.'.\n *\n * @param {...any} params - The message components. The first param is used as\n * the method name and prefixed with 'THREE.'.\n */\n function warn( ...params ) {\n\n \tparams = enhanceLogMessage( params );\n\n \tconst message = 'THREE.' + params.shift();\n\n \t{\n\n \t\tconst stackTrace = params[ 0 ];\n\n \t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n \t\t\tconsole.warn( stackTrace.getError( message ) );\n\n \t\t} else {\n\n \t\t\tconsole.warn( message, ...params );\n\n \t\t}\n\n \t}\n\n }\n\n /**\n * Logs an error message with the 'THREE.' prefix.\n *\n * If a custom console function is set via setConsoleFunction(), it will be used\n * instead of the native console.error. The first parameter is treated as the\n * method name and is automatically prefixed with 'THREE.'.\n *\n * @param {...any} params - The message components. The first param is used as\n * the method name and prefixed with 'THREE.'.\n */\n function error( ...params ) {\n\n \tparams = enhanceLogMessage( params );\n\n \tconst message = 'THREE.' + params.shift();\n\n \t{\n\n \t\tconst stackTrace = params[ 0 ];\n\n \t\tif ( stackTrace && stackTrace.isStackTrace ) {\n\n \t\t\tconsole.error( stackTrace.getError( message ) );\n\n \t\t} else {\n\n \t\t\tconsole.error( message, ...params );\n\n \t\t}\n\n \t}\n\n }\n\n /**\n * Logs a warning message only once, preventing duplicate warnings.\n *\n * This function maintains an internal cache of warning messages and will only\n * output each unique warning message once. Useful for warnings that may be\n * triggered repeatedly but should only be shown to the user once.\n *\n * @param {...any} params - The warning message components.\n */\n function warnOnce( ...params ) {\n\n \tconst message = params.join( ' ' );\n\n \tif ( message in _cache ) return;\n\n \t_cache[ message ] = true;\n\n \twarn( ...params );\n\n }\n\n /**\n * This modules allows to dispatch event objects on custom JavaScript objects.\n *\n * Main repository: [eventdispatcher.js](https://github.com/mrdoob/eventdispatcher.js/)\n *\n * Code Example:\n * ```js\n * class Car extends EventDispatcher {\n * \tstart() {\n *\t\tthis.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );\n *\t}\n *};\n *\n * // Using events with the custom object\n * const car = new Car();\n * car.addEventListener( 'start', function ( event ) {\n * \talert( event.message );\n * } );\n *\n * car.start();\n * ```\n */\n class EventDispatcher {\n\n \t/**\n \t * Adds the given event listener to the given event type.\n \t *\n \t * @param {string} type - The type of event to listen to.\n \t * @param {Function} listener - The function that gets called when the event is fired.\n \t */\n \taddEventListener( type, listener ) {\n\n \t\tif ( this._listeners === undefined ) this._listeners = {};\n\n \t\tconst listeners = this._listeners;\n\n \t\tif ( listeners[ type ] === undefined ) {\n\n \t\t\tlisteners[ type ] = [];\n\n \t\t}\n\n \t\tif ( listeners[ type ].indexOf( listener ) === -1 ) {\n\n \t\t\tlisteners[ type ].push( listener );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns `true` if the given event listener has been added to the given event type.\n \t *\n \t * @param {string} type - The type of event.\n \t * @param {Function} listener - The listener to check.\n \t * @return {boolean} Whether the given event listener has been added to the given event type.\n \t */\n \thasEventListener( type, listener ) {\n\n \t\tconst listeners = this._listeners;\n\n \t\tif ( listeners === undefined ) return false;\n\n \t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== -1;\n\n \t}\n\n \t/**\n \t * Removes the given event listener from the given event type.\n \t *\n \t * @param {string} type - The type of event.\n \t * @param {Function} listener - The listener to remove.\n \t */\n \tremoveEventListener( type, listener ) {\n\n \t\tconst listeners = this._listeners;\n\n \t\tif ( listeners === undefined ) return;\n\n \t\tconst listenerArray = listeners[ type ];\n\n \t\tif ( listenerArray !== undefined ) {\n\n \t\t\tconst index = listenerArray.indexOf( listener );\n\n \t\t\tif ( index !== -1 ) {\n\n \t\t\t\tlistenerArray.splice( index, 1 );\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Dispatches an event object.\n \t *\n \t * @param {Object} event - The event that gets fired.\n \t */\n \tdispatchEvent( event ) {\n\n \t\tconst listeners = this._listeners;\n\n \t\tif ( listeners === undefined ) return;\n\n \t\tconst listenerArray = listeners[ event.type ];\n\n \t\tif ( listenerArray !== undefined ) {\n\n \t\t\tevent.target = this;\n\n \t\t\t// Make a copy, in case listeners are removed while iterating.\n \t\t\tconst array = listenerArray.slice( 0 );\n\n \t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n \t\t\t\tarray[ i ].call( this, event );\n\n \t\t\t}\n\n \t\t\tevent.target = null;\n\n \t\t}\n\n \t}\n\n }\n\n const _lut = [ '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff' ];\n\n /**\n * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)\n * (universally unique identifier).\n *\n * @return {string} The UUID.\n */\n function generateUUID() {\n\n \t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n \tconst d0 = Math.random() * 0xffffffff | 0;\n \tconst d1 = Math.random() * 0xffffffff | 0;\n \tconst d2 = Math.random() * 0xffffffff | 0;\n \tconst d3 = Math.random() * 0xffffffff | 0;\n \tconst uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +\n \t\t\t_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +\n \t\t\t_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +\n \t\t\t_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];\n\n \t// .toLowerCase() here flattens concatenated strings to save heap memory space.\n \treturn uuid.toLowerCase();\n\n }\n\n /**\n * Clamps the given value between min and max.\n *\n * @param {number} value - The value to clamp.\n * @param {number} min - The min value.\n * @param {number} max - The max value.\n * @return {number} The clamped value.\n */\n function clamp( value, min, max ) {\n\n \treturn Math.max( min, Math.min( max, value ) );\n\n }\n\n /**\n * Computes the Euclidean modulo of the given parameters that\n * is `( ( n % m ) + m ) % m`.\n *\n * @param {number} n - The first parameter.\n * @param {number} m - The second parameter.\n * @return {number} The Euclidean modulo.\n */\n function euclideanModulo( n, m ) {\n\n \t// https://en.wikipedia.org/wiki/Modulo_operation\n\n \treturn ( ( n % m ) + m ) % m;\n\n }\n\n /**\n * Returns a value linearly interpolated from two known points based on the given interval -\n * `t = 0` will return `x` and `t = 1` will return `y`.\n *\n * @param {number} x - The start point\n * @param {number} y - The end point.\n * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.\n * @return {number} The interpolated value.\n */\n function lerp( x, y, t ) {\n\n \treturn ( 1 - t ) * x + t * y;\n\n }\n\n /**\n * Denormalizes the given value according to the given typed array.\n *\n * @param {number} value - The value to denormalize.\n * @param {TypedArray} array - The typed array that defines the data type of the value.\n * @return {number} The denormalize (float) value in the range `[0,1]`.\n */\n function denormalize( value, array ) {\n\n \tswitch ( array.constructor ) {\n\n \t\tcase Float32Array:\n\n \t\t\treturn value;\n\n \t\tcase Uint32Array:\n\n \t\t\treturn value / 4294967295.0;\n\n \t\tcase Uint16Array:\n\n \t\t\treturn value / 65535.0;\n\n \t\tcase Uint8Array:\n\n \t\t\treturn value / 255.0;\n\n \t\tcase Int32Array:\n\n \t\t\treturn Math.max( value / 2147483647.0, -1 );\n\n \t\tcase Int16Array:\n\n \t\t\treturn Math.max( value / 32767.0, -1 );\n\n \t\tcase Int8Array:\n\n \t\t\treturn Math.max( value / 127.0, -1 );\n\n \t\tdefault:\n\n \t\t\tthrow new Error( 'THREE.MathUtils: Invalid component type.' );\n\n \t}\n\n }\n\n /**\n * Normalizes the given value according to the given typed array.\n *\n * @param {number} value - The float value in the range `[0,1]` to normalize.\n * @param {TypedArray} array - The typed array that defines the data type of the value.\n * @return {number} The normalize value.\n */\n function normalize( value, array ) {\n\n \tswitch ( array.constructor ) {\n\n \t\tcase Float32Array:\n\n \t\t\treturn value;\n\n \t\tcase Uint32Array:\n\n \t\t\treturn Math.round( value * 4294967295.0 );\n\n \t\tcase Uint16Array:\n\n \t\t\treturn Math.round( value * 65535.0 );\n\n \t\tcase Uint8Array:\n\n \t\t\treturn Math.round( value * 255.0 );\n\n \t\tcase Int32Array:\n\n \t\t\treturn Math.round( value * 2147483647.0 );\n\n \t\tcase Int16Array:\n\n \t\t\treturn Math.round( value * 32767.0 );\n\n \t\tcase Int8Array:\n\n \t\t\treturn Math.round( value * 127.0 );\n\n \t\tdefault:\n\n \t\t\tthrow new Error( 'THREE.MathUtils: Invalid component type.' );\n\n \t}\n\n }\n\n /**\n * Class representing a 2D vector. A 2D vector is an ordered pair of numbers\n * (labeled x and y), which can be used to represent a number of things, such as:\n *\n * - A point in 2D space (i.e. a position on a plane).\n * - A direction and length across a plane. In three.js the length will\n * always be the Euclidean distance(straight-line distance) from `(0, 0)` to `(x, y)`\n * and the direction is also measured from `(0, 0)` towards `(x, y)`.\n * - Any arbitrary ordered pair of numbers.\n *\n * There are other things a 2D vector can be used to represent, such as\n * momentum vectors, complex numbers and so on, however these are the most\n * common uses in three.js.\n *\n * Iterating through a vector instance will yield its components `(x, y)` in\n * the corresponding order.\n * ```js\n * const a = new THREE.Vector2( 0, 1 );\n *\n * //no arguments; will be initialised to (0, 0)\n * const b = new THREE.Vector2( );\n *\n * const d = a.distanceTo( b );\n * ```\n */\n class Vector2 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tVector2.prototype.isVector2 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 2D vector.\n \t *\n \t * @param {number} [x=0] - The x value of this vector.\n \t * @param {number} [y=0] - The y value of this vector.\n \t */\n \tconstructor( x = 0, y = 0 ) {\n\n \t\t/**\n \t\t * The x value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.x = x;\n\n \t\t/**\n \t\t * The y value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.y = y;\n\n \t}\n\n \t/**\n \t * Alias for {@link Vector2#x}.\n \t *\n \t * @type {number}\n \t */\n \tget width() {\n\n \t\treturn this.x;\n\n \t}\n\n \tset width( value ) {\n\n \t\tthis.x = value;\n\n \t}\n\n \t/**\n \t * Alias for {@link Vector2#y}.\n \t *\n \t * @type {number}\n \t */\n \tget height() {\n\n \t\treturn this.y;\n\n \t}\n\n \tset height( value ) {\n\n \t\tthis.y = value;\n\n \t}\n\n \t/**\n \t * Sets the vector components.\n \t *\n \t * @param {number} x - The value of the x component.\n \t * @param {number} y - The value of the y component.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tset( x, y ) {\n\n \t\tthis.x = x;\n \t\tthis.y = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the same value.\n \t *\n \t * @param {number} scalar - The value to set for all vector components.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsetScalar( scalar ) {\n\n \t\tthis.x = scalar;\n \t\tthis.y = scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's x component to the given value\n \t *\n \t * @param {number} x - The value to set.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsetX( x ) {\n\n \t\tthis.x = x;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's y component to the given value\n \t *\n \t * @param {number} y - The value to set.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsetY( y ) {\n\n \t\tthis.y = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Allows to set a vector component with an index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y.\n \t * @param {number} value - The value to set.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsetComponent( index, value ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: this.x = value; break;\n \t\t\tcase 1: this.y = value; break;\n \t\t\tdefault: throw new Error( 'THREE.Vector2: index is out of range: ' + index );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the value of the vector component which matches the given index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y.\n \t * @return {number} A vector component value.\n \t */\n \tgetComponent( index ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: return this.x;\n \t\t\tcase 1: return this.y;\n \t\t\tdefault: throw new Error( 'THREE.Vector2: index is out of range: ' + index );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns a new vector with copied values from this instance.\n \t *\n \t * @return {Vector2} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this.x, this.y );\n\n \t}\n\n \t/**\n \t * Copies the values of the given vector to this instance.\n \t *\n \t * @param {Vector2} v - The vector to copy.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tcopy( v ) {\n\n \t\tthis.x = v.x;\n \t\tthis.y = v.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector to this instance.\n \t *\n \t * @param {Vector2} v - The vector to add.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tadd( v ) {\n\n \t\tthis.x += v.x;\n \t\tthis.y += v.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given scalar value to all components of this instance.\n \t *\n \t * @param {number} s - The scalar to add.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \taddScalar( s ) {\n\n \t\tthis.x += s;\n \t\tthis.y += s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector2} a - The first vector.\n \t * @param {Vector2} b - The second vector.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \taddVectors( a, b ) {\n\n \t\tthis.x = a.x + b.x;\n \t\tthis.y = a.y + b.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector scaled by the given factor to this instance.\n \t *\n \t * @param {Vector2} v - The vector.\n \t * @param {number} s - The factor that scales `v`.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \taddScaledVector( v, s ) {\n\n \t\tthis.x += v.x * s;\n \t\tthis.y += v.y * s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vector from this instance.\n \t *\n \t * @param {Vector2} v - The vector to subtract.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsub( v ) {\n\n \t\tthis.x -= v.x;\n \t\tthis.y -= v.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given scalar value from all components of this instance.\n \t *\n \t * @param {number} s - The scalar to subtract.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsubScalar( s ) {\n\n \t\tthis.x -= s;\n \t\tthis.y -= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector2} a - The first vector.\n \t * @param {Vector2} b - The second vector.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsubVectors( a, b ) {\n\n \t\tthis.x = a.x - b.x;\n \t\tthis.y = a.y - b.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given vector with this instance.\n \t *\n \t * @param {Vector2} v - The vector to multiply.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tmultiply( v ) {\n\n \t\tthis.x *= v.x;\n \t\tthis.y *= v.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given scalar value with all components of this instance.\n \t *\n \t * @param {number} scalar - The scalar to multiply.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tmultiplyScalar( scalar ) {\n\n \t\tthis.x *= scalar;\n \t\tthis.y *= scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Divides this instance by the given vector.\n \t *\n \t * @param {Vector2} v - The vector to divide.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tdivide( v ) {\n\n \t\tthis.x /= v.x;\n \t\tthis.y /= v.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Divides this vector by the given scalar.\n \t *\n \t * @param {number} scalar - The scalar to divide.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tdivideScalar( scalar ) {\n\n \t\treturn this.multiplyScalar( 1 / scalar );\n\n \t}\n\n \t/**\n \t * Multiplies this vector (with an implicit 1 as the 3rd component) by\n \t * the given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The matrix to apply.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tapplyMatrix3( m ) {\n\n \t\tconst x = this.x, y = this.y;\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n \t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x or y value is greater than the given vector's x or y\n \t * value, replace that value with the corresponding min value.\n \t *\n \t * @param {Vector2} v - The vector.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tmin( v ) {\n\n \t\tthis.x = Math.min( this.x, v.x );\n \t\tthis.y = Math.min( this.y, v.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x or y value is less than the given vector's x or y\n \t * value, replace that value with the corresponding max value.\n \t *\n \t * @param {Vector2} v - The vector.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tmax( v ) {\n\n \t\tthis.x = Math.max( this.x, v.x );\n \t\tthis.y = Math.max( this.y, v.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x or y value is greater than the max vector's x or y\n \t * value, it is replaced by the corresponding value.\n \t * If this vector's x or y value is less than the min vector's x or y value,\n \t * it is replaced by the corresponding value.\n \t *\n \t * @param {Vector2} min - The minimum x and y values.\n \t * @param {Vector2} max - The maximum x and y values in the desired range.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tclamp( min, max ) {\n\n \t\t// assumes min < max, componentwise\n\n \t\tthis.x = clamp( this.x, min.x, max.x );\n \t\tthis.y = clamp( this.y, min.y, max.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x or y values are greater than the max value, they are\n \t * replaced by the max value.\n \t * If this vector's x or y values are less than the min value, they are\n \t * replaced by the min value.\n \t *\n \t * @param {number} minVal - The minimum value the components will be clamped to.\n \t * @param {number} maxVal - The maximum value the components will be clamped to.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tclampScalar( minVal, maxVal ) {\n\n \t\tthis.x = clamp( this.x, minVal, maxVal );\n \t\tthis.y = clamp( this.y, minVal, maxVal );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's length is greater than the max value, it is replaced by\n \t * the max value.\n \t * If this vector's length is less than the min value, it is replaced by the\n \t * min value.\n \t *\n \t * @param {number} min - The minimum value the vector length will be clamped to.\n \t * @param {number} max - The maximum value the vector length will be clamped to.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tclampLength( min, max ) {\n\n \t\tconst length = this.length();\n\n \t\treturn this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded down to the nearest integer value.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tfloor() {\n\n \t\tthis.x = Math.floor( this.x );\n \t\tthis.y = Math.floor( this.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded up to the nearest integer value.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tceil() {\n\n \t\tthis.x = Math.ceil( this.x );\n \t\tthis.y = Math.ceil( this.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded to the nearest integer value\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tround() {\n\n \t\tthis.x = Math.round( this.x );\n \t\tthis.y = Math.round( this.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded towards zero (up if negative,\n \t * down if positive) to an integer value.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \troundToZero() {\n\n \t\tthis.x = Math.trunc( this.x );\n \t\tthis.y = Math.trunc( this.y );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Inverts this vector - i.e. sets x = -x and y = -y.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tnegate() {\n\n \t\tthis.x = - this.x;\n \t\tthis.y = - this.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Calculates the dot product of the given vector with this instance.\n \t *\n \t * @param {Vector2} v - The vector to compute the dot product with.\n \t * @return {number} The result of the dot product.\n \t */\n \tdot( v ) {\n\n \t\treturn this.x * v.x + this.y * v.y;\n\n \t}\n\n \t/**\n \t * Calculates the cross product of the given vector with this instance.\n \t *\n \t * @param {Vector2} v - The vector to compute the cross product with.\n \t * @return {number} The result of the cross product.\n \t */\n \tcross( v ) {\n\n \t\treturn this.x * v.y - this.y * v.x;\n\n \t}\n\n \t/**\n \t * Computes the square of the Euclidean length (straight-line length) from\n \t * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should\n \t * compare the length squared instead as it is slightly more efficient to calculate.\n \t *\n \t * @return {number} The square length of this vector.\n \t */\n \tlengthSq() {\n\n \t\treturn this.x * this.x + this.y * this.y;\n\n \t}\n\n \t/**\n \t * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tlength() {\n\n \t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n \t}\n\n \t/**\n \t * Computes the Manhattan length of this vector.\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tmanhattanLength() {\n\n \t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n \t}\n\n \t/**\n \t * Converts this vector to a unit vector - that is, sets it equal to a vector\n \t * with the same direction as this one, but with a vector length of `1`.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tnormalize() {\n\n \t\treturn this.divideScalar( this.length() || 1 );\n\n \t}\n\n \t/**\n \t * Computes the angle in radians of this vector with respect to the positive x-axis.\n \t *\n \t * @return {number} The angle in radians.\n \t */\n \tangle() {\n\n \t\tconst angle = Math.atan2( - this.y, - this.x ) + Math.PI;\n\n \t\treturn angle;\n\n \t}\n\n \t/**\n \t * Returns the angle between the given vector and this instance in radians.\n \t *\n \t * @param {Vector2} v - The vector to compute the angle with.\n \t * @return {number} The angle in radians.\n \t */\n \tangleTo( v ) {\n\n \t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n \t\tif ( denominator === 0 ) return Math.PI / 2;\n\n \t\tconst theta = this.dot( v ) / denominator;\n\n \t\t// clamp, to handle numerical problems\n\n \t\treturn Math.acos( clamp( theta, -1, 1 ) );\n\n \t}\n\n \t/**\n \t * Computes the distance from the given vector to this instance.\n \t *\n \t * @param {Vector2} v - The vector to compute the distance to.\n \t * @return {number} The distance.\n \t */\n \tdistanceTo( v ) {\n\n \t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n \t}\n\n \t/**\n \t * Computes the squared distance from the given vector to this instance.\n \t * If you are just comparing the distance with another distance, you should compare\n \t * the distance squared instead as it is slightly more efficient to calculate.\n \t *\n \t * @param {Vector2} v - The vector to compute the squared distance to.\n \t * @return {number} The squared distance.\n \t */\n \tdistanceToSquared( v ) {\n\n \t\tconst dx = this.x - v.x, dy = this.y - v.y;\n \t\treturn dx * dx + dy * dy;\n\n \t}\n\n \t/**\n \t * Computes the Manhattan distance from the given vector to this instance.\n \t *\n \t * @param {Vector2} v - The vector to compute the Manhattan distance to.\n \t * @return {number} The Manhattan distance.\n \t */\n \tmanhattanDistanceTo( v ) {\n\n \t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n \t}\n\n \t/**\n \t * Sets this vector to a vector with the same direction as this one, but\n \t * with the specified length.\n \t *\n \t * @param {number} length - The new length of this vector.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tsetLength( length ) {\n\n \t\treturn this.normalize().multiplyScalar( length );\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vector and this instance, where\n \t * alpha is the percent distance along the line - alpha = 0 will be this\n \t * vector, and alpha = 1 will be the given one.\n \t *\n \t * @param {Vector2} v - The vector to interpolate towards.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tlerp( v, alpha ) {\n\n \t\tthis.x += ( v.x - this.x ) * alpha;\n \t\tthis.y += ( v.y - this.y ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vectors, where alpha is the percent\n \t * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n \t * be the second one. The result is stored in this instance.\n \t *\n \t * @param {Vector2} v1 - The first vector.\n \t * @param {Vector2} v2 - The second vector.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tlerpVectors( v1, v2, alpha ) {\n\n \t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n \t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this vector is equal with the given one.\n \t *\n \t * @param {Vector2} v - The vector to test for equality.\n \t * @return {boolean} Whether this vector is equal with the given one.\n \t */\n \tequals( v ) {\n\n \t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n \t}\n\n \t/**\n \t * Sets this vector's x value to be `array[ offset ]` and y\n \t * value to be `array[ offset + 1 ]`.\n \t *\n \t * @param {Array<number>} array - An array holding the vector component values.\n \t * @param {number} [offset=0] - The offset into the array.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tthis.x = array[ offset ];\n \t\tthis.y = array[ offset + 1 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the components of this vector to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the vector components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The vector components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this.x;\n \t\tarray[ offset + 1 ] = this.y;\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Sets the components of this vector from the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n \t * @param {number} index - The index into the attribute.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \tfromBufferAttribute( attribute, index ) {\n\n \t\tthis.x = attribute.getX( index );\n \t\tthis.y = attribute.getY( index );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates this vector around the given center by the given angle.\n \t *\n \t * @param {Vector2} center - The point around which to rotate.\n \t * @param {number} angle - The angle to rotate, in radians.\n \t * @return {Vector2} A reference to this vector.\n \t */\n \trotateAround( center, angle ) {\n\n \t\tconst c = Math.cos( angle ), s = Math.sin( angle );\n\n \t\tconst x = this.x - center.x;\n \t\tconst y = this.y - center.y;\n\n \t\tthis.x = x * c - y * s + center.x;\n \t\tthis.y = x * s + y * c + center.y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets each component of this vector to a pseudo-random value between `0` and\n \t * `1`, excluding `1`.\n \t *\n \t * @return {Vector2} A reference to this vector.\n \t */\n \trandom() {\n\n \t\tthis.x = Math.random();\n \t\tthis.y = Math.random();\n\n \t\treturn this;\n\n \t}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this.x;\n \t\tyield this.y;\n\n \t}\n\n }\n\n /**\n * Class for representing a Quaternion. Quaternions are used in three.js to represent rotations.\n *\n * Iterating through a vector instance will yield its components `(x, y, z, w)` in\n * the corresponding order.\n *\n * Note that three.js expects Quaternions to be normalized.\n * ```js\n * const quaternion = new THREE.Quaternion();\n * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );\n *\n * const vector = new THREE.Vector3( 1, 0, 0 );\n * vector.applyQuaternion( quaternion );\n * ```\n */\n class Quaternion {\n\n \t/**\n \t * Constructs a new quaternion.\n \t *\n \t * @param {number} [x=0] - The x value of this quaternion.\n \t * @param {number} [y=0] - The y value of this quaternion.\n \t * @param {number} [z=0] - The z value of this quaternion.\n \t * @param {number} [w=1] - The w value of this quaternion.\n \t */\n \tconstructor( x = 0, y = 0, z = 0, w = 1 ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isQuaternion = true;\n\n \t\tthis._x = x;\n \t\tthis._y = y;\n \t\tthis._z = z;\n \t\tthis._w = w;\n\n \t}\n\n \t/**\n \t * Interpolates between two quaternions via SLERP. This implementation assumes the\n \t * quaternion data are managed in flat arrays.\n \t *\n \t * @param {Array<number>} dst - The destination array.\n \t * @param {number} dstOffset - An offset into the destination array.\n \t * @param {Array<number>} src0 - The source array of the first quaternion.\n \t * @param {number} srcOffset0 - An offset into the first source array.\n \t * @param {Array<number>} src1 - The source array of the second quaternion.\n \t * @param {number} srcOffset1 - An offset into the second source array.\n \t * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.\n \t * @see {@link Quaternion#slerp}\n \t */\n \tstatic slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n \t\tlet x0 = src0[ srcOffset0 + 0 ],\n \t\t\ty0 = src0[ srcOffset0 + 1 ],\n \t\t\tz0 = src0[ srcOffset0 + 2 ],\n \t\t\tw0 = src0[ srcOffset0 + 3 ];\n\n \t\tlet x1 = src1[ srcOffset1 + 0 ],\n \t\t\ty1 = src1[ srcOffset1 + 1 ],\n \t\t\tz1 = src1[ srcOffset1 + 2 ],\n \t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n \t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n \t\t\tlet dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;\n\n \t\t\tif ( dot < 0 ) {\n\n \t\t\t\tx1 = - x1;\n \t\t\t\ty1 = - y1;\n \t\t\t\tz1 = - z1;\n \t\t\t\tw1 = - w1;\n\n \t\t\t\tdot = - dot;\n\n \t\t\t}\n\n \t\t\tlet s = 1 - t;\n\n \t\t\tif ( dot < 0.9995 ) {\n\n \t\t\t\t// slerp\n\n \t\t\t\tconst theta = Math.acos( dot );\n \t\t\t\tconst sin = Math.sin( theta );\n\n \t\t\t\ts = Math.sin( s * theta ) / sin;\n \t\t\t\tt = Math.sin( t * theta ) / sin;\n\n \t\t\t\tx0 = x0 * s + x1 * t;\n \t\t\t\ty0 = y0 * s + y1 * t;\n \t\t\t\tz0 = z0 * s + z1 * t;\n \t\t\t\tw0 = w0 * s + w1 * t;\n\n \t\t\t} else {\n\n \t\t\t\t// for small angles, lerp then normalize\n\n \t\t\t\tx0 = x0 * s + x1 * t;\n \t\t\t\ty0 = y0 * s + y1 * t;\n \t\t\t\tz0 = z0 * s + z1 * t;\n \t\t\t\tw0 = w0 * s + w1 * t;\n\n \t\t\t\tconst f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n \t\t\t\tx0 *= f;\n \t\t\t\ty0 *= f;\n \t\t\t\tz0 *= f;\n \t\t\t\tw0 *= f;\n\n \t\t\t}\n\n \t\t}\n\n \t\tdst[ dstOffset ] = x0;\n \t\tdst[ dstOffset + 1 ] = y0;\n \t\tdst[ dstOffset + 2 ] = z0;\n \t\tdst[ dstOffset + 3 ] = w0;\n\n \t}\n\n \t/**\n \t * Multiplies two quaternions. This implementation assumes the quaternion data are managed\n \t * in flat arrays.\n \t *\n \t * @param {Array<number>} dst - The destination array.\n \t * @param {number} dstOffset - An offset into the destination array.\n \t * @param {Array<number>} src0 - The source array of the first quaternion.\n \t * @param {number} srcOffset0 - An offset into the first source array.\n \t * @param {Array<number>} src1 - The source array of the second quaternion.\n \t * @param {number} srcOffset1 - An offset into the second source array.\n \t * @return {Array<number>} The destination array.\n \t * @see {@link Quaternion#multiplyQuaternions}.\n \t */\n \tstatic multiplyQuaternionsFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {\n\n \t\tconst x0 = src0[ srcOffset0 ];\n \t\tconst y0 = src0[ srcOffset0 + 1 ];\n \t\tconst z0 = src0[ srcOffset0 + 2 ];\n \t\tconst w0 = src0[ srcOffset0 + 3 ];\n\n \t\tconst x1 = src1[ srcOffset1 ];\n \t\tconst y1 = src1[ srcOffset1 + 1 ];\n \t\tconst z1 = src1[ srcOffset1 + 2 ];\n \t\tconst w1 = src1[ srcOffset1 + 3 ];\n\n \t\tdst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n \t\tdst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n \t\tdst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n \t\tdst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\n \t\treturn dst;\n\n \t}\n\n \t/**\n \t * The x value of this quaternion.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget x() {\n\n \t\treturn this._x;\n\n \t}\n\n \tset x( value ) {\n\n \t\tthis._x = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * The y value of this quaternion.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget y() {\n\n \t\treturn this._y;\n\n \t}\n\n \tset y( value ) {\n\n \t\tthis._y = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * The z value of this quaternion.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget z() {\n\n \t\treturn this._z;\n\n \t}\n\n \tset z( value ) {\n\n \t\tthis._z = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * The w value of this quaternion.\n \t *\n \t * @type {number}\n \t * @default 1\n \t */\n \tget w() {\n\n \t\treturn this._w;\n\n \t}\n\n \tset w( value ) {\n\n \t\tthis._w = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * Sets the quaternion components.\n \t *\n \t * @param {number} x - The x value of this quaternion.\n \t * @param {number} y - The y value of this quaternion.\n \t * @param {number} z - The z value of this quaternion.\n \t * @param {number} w - The w value of this quaternion.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tset( x, y, z, w ) {\n\n \t\tthis._x = x;\n \t\tthis._y = y;\n \t\tthis._z = z;\n \t\tthis._w = w;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new quaternion with copied values from this instance.\n \t *\n \t * @return {Quaternion} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n \t}\n\n \t/**\n \t * Copies the values of the given quaternion to this instance.\n \t *\n \t * @param {Quaternion} quaternion - The quaternion to copy.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tcopy( quaternion ) {\n\n \t\tthis._x = quaternion.x;\n \t\tthis._y = quaternion.y;\n \t\tthis._z = quaternion.z;\n \t\tthis._w = quaternion.w;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this quaternion from the rotation specified by the given\n \t * Euler angles.\n \t *\n \t * @param {Euler} euler - The Euler angles.\n \t * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tsetFromEuler( euler, update = true ) {\n\n \t\tconst x = euler._x, y = euler._y, z = euler._z, order = euler._order;\n\n \t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n \t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n \t\t//\tcontent/SpinCalc.m\n\n \t\tconst cos = Math.cos;\n \t\tconst sin = Math.sin;\n\n \t\tconst c1 = cos( x / 2 );\n \t\tconst c2 = cos( y / 2 );\n \t\tconst c3 = cos( z / 2 );\n\n \t\tconst s1 = sin( x / 2 );\n \t\tconst s2 = sin( y / 2 );\n \t\tconst s3 = sin( z / 2 );\n\n \t\tswitch ( order ) {\n\n \t\t\tcase 'XYZ':\n \t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tcase 'YXZ':\n \t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tcase 'ZXY':\n \t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tcase 'ZYX':\n \t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tcase 'YZX':\n \t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tcase 'XZY':\n \t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n \t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n \t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n \t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n \t\t\t\tbreak;\n\n \t\t\tdefault:\n \t\t\t\twarn( 'Quaternion: .setFromEuler() encountered an unknown order: ' + order );\n\n \t\t}\n\n \t\tif ( update === true ) this._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this quaternion from the given axis and angle.\n \t *\n \t * @param {Vector3} axis - The normalized axis.\n \t * @param {number} angle - The angle in radians.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tsetFromAxisAngle( axis, angle ) {\n\n \t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n \t\tconst halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n \t\tthis._x = axis.x * s;\n \t\tthis._y = axis.y * s;\n \t\tthis._z = axis.z * s;\n \t\tthis._w = Math.cos( halfAngle );\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this quaternion from the given rotation matrix.\n \t *\n \t * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tsetFromRotationMatrix( m ) {\n\n \t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n \t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n \t\tconst te = m.elements,\n\n \t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n \t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n \t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n \t\t\ttrace = m11 + m22 + m33;\n\n \t\tif ( trace > 0 ) {\n\n \t\t\tconst s = 0.5 / Math.sqrt( trace + 1.0 );\n\n \t\t\tthis._w = 0.25 / s;\n \t\t\tthis._x = ( m32 - m23 ) * s;\n \t\t\tthis._y = ( m13 - m31 ) * s;\n \t\t\tthis._z = ( m21 - m12 ) * s;\n\n \t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n \t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n \t\t\tthis._w = ( m32 - m23 ) / s;\n \t\t\tthis._x = 0.25 * s;\n \t\t\tthis._y = ( m12 + m21 ) / s;\n \t\t\tthis._z = ( m13 + m31 ) / s;\n\n \t\t} else if ( m22 > m33 ) {\n\n \t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n \t\t\tthis._w = ( m13 - m31 ) / s;\n \t\t\tthis._x = ( m12 + m21 ) / s;\n \t\t\tthis._y = 0.25 * s;\n \t\t\tthis._z = ( m23 + m32 ) / s;\n\n \t\t} else {\n\n \t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n \t\t\tthis._w = ( m21 - m12 ) / s;\n \t\t\tthis._x = ( m13 + m31 ) / s;\n \t\t\tthis._y = ( m23 + m32 ) / s;\n \t\t\tthis._z = 0.25 * s;\n\n \t\t}\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this quaternion to the rotation required to rotate the direction vector\n \t * `vFrom` to the direction vector `vTo`.\n \t *\n \t * @param {Vector3} vFrom - The first (normalized) direction vector.\n \t * @param {Vector3} vTo - The second (normalized) direction vector.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tsetFromUnitVectors( vFrom, vTo ) {\n\n \t\t// assumes direction vectors vFrom and vTo are normalized\n\n \t\tlet r = vFrom.dot( vTo ) + 1;\n\n \t\tif ( r < 1e-8 ) { // the epsilon value has been discussed in #31286\n\n \t\t\t// vFrom and vTo point in opposite directions\n\n \t\t\tr = 0;\n\n \t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n \t\t\t\tthis._x = - vFrom.y;\n \t\t\t\tthis._y = vFrom.x;\n \t\t\t\tthis._z = 0;\n \t\t\t\tthis._w = r;\n\n \t\t\t} else {\n\n \t\t\t\tthis._x = 0;\n \t\t\t\tthis._y = - vFrom.z;\n \t\t\t\tthis._z = vFrom.y;\n \t\t\t\tthis._w = r;\n\n \t\t\t}\n\n \t\t} else {\n\n \t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\n \t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n \t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n \t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n \t\t\tthis._w = r;\n\n \t\t}\n\n \t\treturn this.normalize();\n\n \t}\n\n \t/**\n \t * Returns the angle between this quaternion and the given one in radians.\n \t *\n \t * @param {Quaternion} q - The quaternion to compute the angle with.\n \t * @return {number} The angle in radians.\n \t */\n \tangleTo( q ) {\n\n \t\treturn 2 * Math.acos( Math.abs( clamp( this.dot( q ), -1, 1 ) ) );\n\n \t}\n\n \t/**\n \t * Rotates this quaternion by a given angular step to the given quaternion.\n \t * The method ensures that the final quaternion will not overshoot `q`.\n \t *\n \t * @param {Quaternion} q - The target quaternion.\n \t * @param {number} step - The angular step in radians.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \trotateTowards( q, step ) {\n\n \t\tconst angle = this.angleTo( q );\n\n \t\tif ( angle === 0 ) return this;\n\n \t\tconst t = Math.min( 1, step / angle );\n\n \t\tthis.slerp( q, t );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this quaternion to the identity quaternion; that is, to the\n \t * quaternion that represents \"no rotation\".\n \t *\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tidentity() {\n\n \t\treturn this.set( 0, 0, 0, 1 );\n\n \t}\n\n \t/**\n \t * Inverts this quaternion via {@link Quaternion#conjugate}. The\n \t * quaternion is assumed to have unit length.\n \t *\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tinvert() {\n\n \t\treturn this.conjugate();\n\n \t}\n\n \t/**\n \t * Returns the rotational conjugate of this quaternion. The conjugate of a\n \t * quaternion represents the same rotation in the opposite direction about\n \t * the rotational axis.\n \t *\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tconjugate() {\n\n \t\tthis._x *= -1;\n \t\tthis._y *= -1;\n \t\tthis._z *= -1;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Calculates the dot product of this quaternion and the given one.\n \t *\n \t * @param {Quaternion} v - The quaternion to compute the dot product with.\n \t * @return {number} The result of the dot product.\n \t */\n \tdot( v ) {\n\n \t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n \t}\n\n \t/**\n \t * Computes the squared Euclidean length (straight-line length) of this quaternion,\n \t * considered as a 4 dimensional vector. This can be useful if you are comparing the\n \t * lengths of two quaternions, as this is a slightly more efficient calculation than\n \t * {@link Quaternion#length}.\n \t *\n \t * @return {number} The squared Euclidean length.\n \t */\n \tlengthSq() {\n\n \t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n \t}\n\n \t/**\n \t * Computes the Euclidean length (straight-line length) of this quaternion,\n \t * considered as a 4 dimensional vector.\n \t *\n \t * @return {number} The Euclidean length.\n \t */\n \tlength() {\n\n \t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n \t}\n\n \t/**\n \t * Normalizes this quaternion - that is, calculated the quaternion that performs\n \t * the same rotation as this one, but has a length equal to `1`.\n \t *\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tnormalize() {\n\n \t\tlet l = this.length();\n\n \t\tif ( l === 0 ) {\n\n \t\t\tthis._x = 0;\n \t\t\tthis._y = 0;\n \t\t\tthis._z = 0;\n \t\t\tthis._w = 1;\n\n \t\t} else {\n\n \t\t\tl = 1 / l;\n\n \t\t\tthis._x = this._x * l;\n \t\t\tthis._y = this._y * l;\n \t\t\tthis._z = this._z * l;\n \t\t\tthis._w = this._w * l;\n\n \t\t}\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies this quaternion by the given one.\n \t *\n \t * @param {Quaternion} q - The quaternion.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tmultiply( q ) {\n\n \t\treturn this.multiplyQuaternions( this, q );\n\n \t}\n\n \t/**\n \t * Pre-multiplies this quaternion by the given one.\n \t *\n \t * @param {Quaternion} q - The quaternion.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tpremultiply( q ) {\n\n \t\treturn this.multiplyQuaternions( q, this );\n\n \t}\n\n \t/**\n \t * Multiplies the given quaternions and stores the result in this instance.\n \t *\n \t * @param {Quaternion} a - The first quaternion.\n \t * @param {Quaternion} b - The second quaternion.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tmultiplyQuaternions( a, b ) {\n\n \t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n \t\tconst qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n \t\tconst qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n \t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n \t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n \t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n \t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Performs a spherical linear interpolation between this quaternion and the target quaternion.\n \t *\n \t * @param {Quaternion} qb - The target quaternion.\n \t * @param {number} t - The interpolation factor. A value in the range `[0,1]` will interpolate. A value outside the range `[0,1]` will extrapolate.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tslerp( qb, t ) {\n\n \t\tlet x = qb._x, y = qb._y, z = qb._z, w = qb._w;\n\n \t\tlet dot = this.dot( qb );\n\n \t\tif ( dot < 0 ) {\n\n \t\t\tx = - x;\n \t\t\ty = - y;\n \t\t\tz = - z;\n \t\t\tw = - w;\n\n \t\t\tdot = - dot;\n\n \t\t}\n\n \t\tlet s = 1 - t;\n\n \t\tif ( dot < 0.9995 ) {\n\n \t\t\t// slerp\n\n \t\t\tconst theta = Math.acos( dot );\n \t\t\tconst sin = Math.sin( theta );\n\n \t\t\ts = Math.sin( s * theta ) / sin;\n \t\t\tt = Math.sin( t * theta ) / sin;\n\n \t\t\tthis._x = this._x * s + x * t;\n \t\t\tthis._y = this._y * s + y * t;\n \t\t\tthis._z = this._z * s + z * t;\n \t\t\tthis._w = this._w * s + w * t;\n\n \t\t\tthis._onChangeCallback();\n\n \t\t} else {\n\n \t\t\t// for small angles, lerp then normalize\n\n \t\t\tthis._x = this._x * s + x * t;\n \t\t\tthis._y = this._y * s + y * t;\n \t\t\tthis._z = this._z * s + z * t;\n \t\t\tthis._w = this._w * s + w * t;\n\n \t\t\tthis.normalize(); // normalize calls _onChangeCallback()\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Performs a spherical linear interpolation between the given quaternions\n \t * and stores the result in this quaternion.\n \t *\n \t * @param {Quaternion} qa - The source quaternion.\n \t * @param {Quaternion} qb - The target quaternion.\n \t * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tslerpQuaternions( qa, qb, t ) {\n\n \t\treturn this.copy( qa ).slerp( qb, t );\n\n \t}\n\n \t/**\n \t * Sets this quaternion to a uniformly random, normalized quaternion.\n \t *\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \trandom() {\n\n \t\t// Ken Shoemake\n \t\t// Uniform random rotations\n \t\t// D. Kirk, editor, Graphics Gems III, pages 124-132. Academic Press, New York, 1992.\n\n \t\tconst theta1 = 2 * Math.PI * Math.random();\n \t\tconst theta2 = 2 * Math.PI * Math.random();\n\n \t\tconst x0 = Math.random();\n \t\tconst r1 = Math.sqrt( 1 - x0 );\n \t\tconst r2 = Math.sqrt( x0 );\n\n \t\treturn this.set(\n \t\t\tr1 * Math.sin( theta1 ),\n \t\t\tr1 * Math.cos( theta1 ),\n \t\t\tr2 * Math.sin( theta2 ),\n \t\t\tr2 * Math.cos( theta2 ),\n \t\t);\n\n \t}\n\n \t/**\n \t * Returns `true` if this quaternion is equal with the given one.\n \t *\n \t * @param {Quaternion} quaternion - The quaternion to test for equality.\n \t * @return {boolean} Whether this quaternion is equal with the given one.\n \t */\n \tequals( quaternion ) {\n\n \t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n \t}\n\n \t/**\n \t * Sets this quaternion's components from the given array.\n \t *\n \t * @param {Array<number>} array - An array holding the quaternion component values.\n \t * @param {number} [offset=0] - The offset into the array.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tthis._x = array[ offset ];\n \t\tthis._y = array[ offset + 1 ];\n \t\tthis._z = array[ offset + 2 ];\n \t\tthis._w = array[ offset + 3 ];\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the components of this quaternion to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the quaternion components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The quaternion components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this._x;\n \t\tarray[ offset + 1 ] = this._y;\n \t\tarray[ offset + 2 ] = this._z;\n \t\tarray[ offset + 3 ] = this._w;\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Sets the components of this quaternion from the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.\n \t * @param {number} index - The index into the attribute.\n \t * @return {Quaternion} A reference to this quaternion.\n \t */\n \tfromBufferAttribute( attribute, index ) {\n\n \t\tthis._x = attribute.getX( index );\n \t\tthis._y = attribute.getY( index );\n \t\tthis._z = attribute.getZ( index );\n \t\tthis._w = attribute.getW( index );\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * This methods defines the serialization result of this class. Returns the\n \t * numerical elements of this quaternion in an array of format `[x, y, z, w]`.\n \t *\n \t * @return {Array<number>} The serialized quaternion.\n \t */\n \ttoJSON() {\n\n \t\treturn this.toArray();\n\n \t}\n\n \t_onChange( callback ) {\n\n \t\tthis._onChangeCallback = callback;\n\n \t\treturn this;\n\n \t}\n\n \t_onChangeCallback() {}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this._x;\n \t\tyield this._y;\n \t\tyield this._z;\n \t\tyield this._w;\n\n \t}\n\n }\n\n /**\n * Class representing a 3D vector. A 3D vector is an ordered triplet of numbers\n * (labeled x, y and z), which can be used to represent a number of things, such as:\n *\n * - A point in 3D space.\n * - A direction and length in 3D space. In three.js the length will\n * always be the Euclidean distance(straight-line distance) from `(0, 0, 0)` to `(x, y, z)`\n * and the direction is also measured from `(0, 0, 0)` towards `(x, y, z)`.\n * - Any arbitrary ordered triplet of numbers.\n *\n * There are other things a 3D vector can be used to represent, such as\n * momentum vectors and so on, however these are the most\n * common uses in three.js.\n *\n * Iterating through a vector instance will yield its components `(x, y, z)` in\n * the corresponding order.\n * ```js\n * const a = new THREE.Vector3( 0, 1, 0 );\n *\n * //no arguments; will be initialised to (0, 0, 0)\n * const b = new THREE.Vector3( );\n *\n * const d = a.distanceTo( b );\n * ```\n */\n class Vector3 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tVector3.prototype.isVector3 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 3D vector.\n \t *\n \t * @param {number} [x=0] - The x value of this vector.\n \t * @param {number} [y=0] - The y value of this vector.\n \t * @param {number} [z=0] - The z value of this vector.\n \t */\n \tconstructor( x = 0, y = 0, z = 0 ) {\n\n \t\t/**\n \t\t * The x value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.x = x;\n\n \t\t/**\n \t\t * The y value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.y = y;\n\n \t\t/**\n \t\t * The z value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.z = z;\n\n \t}\n\n \t/**\n \t * Sets the vector components.\n \t *\n \t * @param {number} x - The value of the x component.\n \t * @param {number} y - The value of the y component.\n \t * @param {number} z - The value of the z component.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tset( x, y, z ) {\n\n \t\tif ( z === undefined ) z = this.z; // sprite.scale.set(x,y)\n\n \t\tthis.x = x;\n \t\tthis.y = y;\n \t\tthis.z = z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the same value.\n \t *\n \t * @param {number} scalar - The value to set for all vector components.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetScalar( scalar ) {\n\n \t\tthis.x = scalar;\n \t\tthis.y = scalar;\n \t\tthis.z = scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's x component to the given value.\n \t *\n \t * @param {number} x - The value to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetX( x ) {\n\n \t\tthis.x = x;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's y component to the given value.\n \t *\n \t * @param {number} y - The value to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetY( y ) {\n\n \t\tthis.y = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's z component to the given value.\n \t *\n \t * @param {number} z - The value to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetZ( z ) {\n\n \t\tthis.z = z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Allows to set a vector component with an index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.\n \t * @param {number} value - The value to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetComponent( index, value ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: this.x = value; break;\n \t\t\tcase 1: this.y = value; break;\n \t\t\tcase 2: this.z = value; break;\n \t\t\tdefault: throw new Error( 'THREE.Vector3: index is out of range: ' + index );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the value of the vector component which matches the given index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.\n \t * @return {number} A vector component value.\n \t */\n \tgetComponent( index ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: return this.x;\n \t\t\tcase 1: return this.y;\n \t\t\tcase 2: return this.z;\n \t\t\tdefault: throw new Error( 'THREE.Vector3: index is out of range: ' + index );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns a new vector with copied values from this instance.\n \t *\n \t * @return {Vector3} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this.x, this.y, this.z );\n\n \t}\n\n \t/**\n \t * Copies the values of the given vector to this instance.\n \t *\n \t * @param {Vector3} v - The vector to copy.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tcopy( v ) {\n\n \t\tthis.x = v.x;\n \t\tthis.y = v.y;\n \t\tthis.z = v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector to this instance.\n \t *\n \t * @param {Vector3} v - The vector to add.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tadd( v ) {\n\n \t\tthis.x += v.x;\n \t\tthis.y += v.y;\n \t\tthis.z += v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given scalar value to all components of this instance.\n \t *\n \t * @param {number} s - The scalar to add.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \taddScalar( s ) {\n\n \t\tthis.x += s;\n \t\tthis.y += s;\n \t\tthis.z += s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector3} a - The first vector.\n \t * @param {Vector3} b - The second vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \taddVectors( a, b ) {\n\n \t\tthis.x = a.x + b.x;\n \t\tthis.y = a.y + b.y;\n \t\tthis.z = a.z + b.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector scaled by the given factor to this instance.\n \t *\n \t * @param {Vector3|Vector4} v - The vector.\n \t * @param {number} s - The factor that scales `v`.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \taddScaledVector( v, s ) {\n\n \t\tthis.x += v.x * s;\n \t\tthis.y += v.y * s;\n \t\tthis.z += v.z * s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vector from this instance.\n \t *\n \t * @param {Vector3} v - The vector to subtract.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsub( v ) {\n\n \t\tthis.x -= v.x;\n \t\tthis.y -= v.y;\n \t\tthis.z -= v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given scalar value from all components of this instance.\n \t *\n \t * @param {number} s - The scalar to subtract.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsubScalar( s ) {\n\n \t\tthis.x -= s;\n \t\tthis.y -= s;\n \t\tthis.z -= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector3} a - The first vector.\n \t * @param {Vector3} b - The second vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsubVectors( a, b ) {\n\n \t\tthis.x = a.x - b.x;\n \t\tthis.y = a.y - b.y;\n \t\tthis.z = a.z - b.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given vector with this instance.\n \t *\n \t * @param {Vector3} v - The vector to multiply.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tmultiply( v ) {\n\n \t\tthis.x *= v.x;\n \t\tthis.y *= v.y;\n \t\tthis.z *= v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given scalar value with all components of this instance.\n \t *\n \t * @param {number} scalar - The scalar to multiply.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tmultiplyScalar( scalar ) {\n\n \t\tthis.x *= scalar;\n \t\tthis.y *= scalar;\n \t\tthis.z *= scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector3} a - The first vector.\n \t * @param {Vector3} b - The second vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tmultiplyVectors( a, b ) {\n\n \t\tthis.x = a.x * b.x;\n \t\tthis.y = a.y * b.y;\n \t\tthis.z = a.z * b.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given Euler rotation to this vector.\n \t *\n \t * @param {Euler} euler - The Euler angles.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyEuler( euler ) {\n\n \t\treturn this.applyQuaternion( _quaternion$5.setFromEuler( euler ) );\n\n \t}\n\n \t/**\n \t * Applies a rotation specified by an axis and an angle to this vector.\n \t *\n \t * @param {Vector3} axis - A normalized vector representing the rotation axis.\n \t * @param {number} angle - The angle in radians.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyAxisAngle( axis, angle ) {\n\n \t\treturn this.applyQuaternion( _quaternion$5.setFromAxisAngle( axis, angle ) );\n\n \t}\n\n \t/**\n \t * Multiplies this vector with the given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The 3x3 matrix.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyMatrix3( m ) {\n\n \t\tconst x = this.x, y = this.y, z = this.z;\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n \t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n \t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies this vector by the given normal matrix and normalizes\n \t * the result.\n \t *\n \t * @param {Matrix3} m - The normal matrix.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyNormalMatrix( m ) {\n\n \t\treturn this.applyMatrix3( m ).normalize();\n\n \t}\n\n \t/**\n \t * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and\n \t * divides by perspective.\n \t *\n \t * @param {Matrix4} m - The matrix to apply.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyMatrix4( m ) {\n\n \t\tconst x = this.x, y = this.y, z = this.z;\n \t\tconst e = m.elements;\n\n \t\tconst w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n \t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n \t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n \t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given Quaternion to this vector.\n \t *\n \t * @param {Quaternion} q - The Quaternion.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tapplyQuaternion( q ) {\n\n \t\t// quaternion q is assumed to have unit length\n\n \t\tconst vx = this.x, vy = this.y, vz = this.z;\n \t\tconst qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n \t\t// t = 2 * cross( q.xyz, v );\n \t\tconst tx = 2 * ( qy * vz - qz * vy );\n \t\tconst ty = 2 * ( qz * vx - qx * vz );\n \t\tconst tz = 2 * ( qx * vy - qy * vx );\n\n \t\t// v + q.w * t + cross( q.xyz, t );\n \t\tthis.x = vx + qw * tx + qy * tz - qz * ty;\n \t\tthis.y = vy + qw * ty + qz * tx - qx * tz;\n \t\tthis.z = vz + qw * tz + qx * ty - qy * tx;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Projects this vector from world space into the camera's normalized\n \t * device coordinate (NDC) space.\n \t *\n \t * @param {Camera} camera - The camera.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tproject( camera ) {\n\n \t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n \t}\n\n \t/**\n \t * Unprojects this vector from the camera's normalized device coordinate (NDC)\n \t * space into world space.\n \t *\n \t * @param {Camera} camera - The camera.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tunproject( camera ) {\n\n \t\treturn this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );\n\n \t}\n\n \t/**\n \t * Transforms the direction of this vector by a matrix (the upper left 3 x 3\n \t * subset of the given 4x4 matrix and then normalizes the result.\n \t *\n \t * @param {Matrix4} m - The matrix.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \ttransformDirection( m ) {\n\n \t\t// input: THREE.Matrix4 affine matrix\n \t\t// vector interpreted as a direction\n\n \t\tconst x = this.x, y = this.y, z = this.z;\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n \t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n \t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n \t\treturn this.normalize();\n\n \t}\n\n \t/**\n \t * Divides this instance by the given vector.\n \t *\n \t * @param {Vector3} v - The vector to divide.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tdivide( v ) {\n\n \t\tthis.x /= v.x;\n \t\tthis.y /= v.y;\n \t\tthis.z /= v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Divides this vector by the given scalar.\n \t *\n \t * @param {number} scalar - The scalar to divide.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tdivideScalar( scalar ) {\n\n \t\treturn this.multiplyScalar( 1 / scalar );\n\n \t}\n\n \t/**\n \t * If this vector's x, y or z value is greater than the given vector's x, y or z\n \t * value, replace that value with the corresponding min value.\n \t *\n \t * @param {Vector3} v - The vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tmin( v ) {\n\n \t\tthis.x = Math.min( this.x, v.x );\n \t\tthis.y = Math.min( this.y, v.y );\n \t\tthis.z = Math.min( this.z, v.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y or z value is less than the given vector's x, y or z\n \t * value, replace that value with the corresponding max value.\n \t *\n \t * @param {Vector3} v - The vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tmax( v ) {\n\n \t\tthis.x = Math.max( this.x, v.x );\n \t\tthis.y = Math.max( this.y, v.y );\n \t\tthis.z = Math.max( this.z, v.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y or z value is greater than the max vector's x, y or z\n \t * value, it is replaced by the corresponding value.\n \t * If this vector's x, y or z value is less than the min vector's x, y or z value,\n \t * it is replaced by the corresponding value.\n \t *\n \t * @param {Vector3} min - The minimum x, y and z values.\n \t * @param {Vector3} max - The maximum x, y and z values in the desired range.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tclamp( min, max ) {\n\n \t\t// assumes min < max, componentwise\n\n \t\tthis.x = clamp( this.x, min.x, max.x );\n \t\tthis.y = clamp( this.y, min.y, max.y );\n \t\tthis.z = clamp( this.z, min.z, max.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y or z values are greater than the max value, they are\n \t * replaced by the max value.\n \t * If this vector's x, y or z values are less than the min value, they are\n \t * replaced by the min value.\n \t *\n \t * @param {number} minVal - The minimum value the components will be clamped to.\n \t * @param {number} maxVal - The maximum value the components will be clamped to.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tclampScalar( minVal, maxVal ) {\n\n \t\tthis.x = clamp( this.x, minVal, maxVal );\n \t\tthis.y = clamp( this.y, minVal, maxVal );\n \t\tthis.z = clamp( this.z, minVal, maxVal );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's length is greater than the max value, it is replaced by\n \t * the max value.\n \t * If this vector's length is less than the min value, it is replaced by the\n \t * min value.\n \t *\n \t * @param {number} min - The minimum value the vector length will be clamped to.\n \t * @param {number} max - The maximum value the vector length will be clamped to.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tclampLength( min, max ) {\n\n \t\tconst length = this.length();\n\n \t\treturn this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded down to the nearest integer value.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tfloor() {\n\n \t\tthis.x = Math.floor( this.x );\n \t\tthis.y = Math.floor( this.y );\n \t\tthis.z = Math.floor( this.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded up to the nearest integer value.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tceil() {\n\n \t\tthis.x = Math.ceil( this.x );\n \t\tthis.y = Math.ceil( this.y );\n \t\tthis.z = Math.ceil( this.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded to the nearest integer value\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tround() {\n\n \t\tthis.x = Math.round( this.x );\n \t\tthis.y = Math.round( this.y );\n \t\tthis.z = Math.round( this.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded towards zero (up if negative,\n \t * down if positive) to an integer value.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \troundToZero() {\n\n \t\tthis.x = Math.trunc( this.x );\n \t\tthis.y = Math.trunc( this.y );\n \t\tthis.z = Math.trunc( this.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tnegate() {\n\n \t\tthis.x = - this.x;\n \t\tthis.y = - this.y;\n \t\tthis.z = - this.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Calculates the dot product of the given vector with this instance.\n \t *\n \t * @param {Vector3} v - The vector to compute the dot product with.\n \t * @return {number} The result of the dot product.\n \t */\n \tdot( v ) {\n\n \t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n \t}\n\n \t/**\n \t * Computes the square of the Euclidean length (straight-line length) from\n \t * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should\n \t * compare the length squared instead as it is slightly more efficient to calculate.\n \t *\n \t * @return {number} The square length of this vector.\n \t */\n \tlengthSq() {\n\n \t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n \t}\n\n \t/**\n \t * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tlength() {\n\n \t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n \t}\n\n \t/**\n \t * Computes the Manhattan length of this vector.\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tmanhattanLength() {\n\n \t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n \t}\n\n \t/**\n \t * Converts this vector to a unit vector - that is, sets it equal to a vector\n \t * with the same direction as this one, but with a vector length of `1`.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tnormalize() {\n\n \t\treturn this.divideScalar( this.length() || 1 );\n\n \t}\n\n \t/**\n \t * Sets this vector to a vector with the same direction as this one, but\n \t * with the specified length.\n \t *\n \t * @param {number} length - The new length of this vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetLength( length ) {\n\n \t\treturn this.normalize().multiplyScalar( length );\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vector and this instance, where\n \t * alpha is the percent distance along the line - alpha = 0 will be this\n \t * vector, and alpha = 1 will be the given one.\n \t *\n \t * @param {Vector3} v - The vector to interpolate towards.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tlerp( v, alpha ) {\n\n \t\tthis.x += ( v.x - this.x ) * alpha;\n \t\tthis.y += ( v.y - this.y ) * alpha;\n \t\tthis.z += ( v.z - this.z ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vectors, where alpha is the percent\n \t * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n \t * be the second one. The result is stored in this instance.\n \t *\n \t * @param {Vector3} v1 - The first vector.\n \t * @param {Vector3} v2 - The second vector.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tlerpVectors( v1, v2, alpha ) {\n\n \t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n \t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n \t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Calculates the cross product of the given vector with this instance.\n \t *\n \t * @param {Vector3} v - The vector to compute the cross product with.\n \t * @return {Vector3} The result of the cross product.\n \t */\n \tcross( v ) {\n\n \t\treturn this.crossVectors( this, v );\n\n \t}\n\n \t/**\n \t * Calculates the cross product of the given vectors and stores the result\n \t * in this instance.\n \t *\n \t * @param {Vector3} a - The first vector.\n \t * @param {Vector3} b - The second vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tcrossVectors( a, b ) {\n\n \t\tconst ax = a.x, ay = a.y, az = a.z;\n \t\tconst bx = b.x, by = b.y, bz = b.z;\n\n \t\tthis.x = ay * bz - az * by;\n \t\tthis.y = az * bx - ax * bz;\n \t\tthis.z = ax * by - ay * bx;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Projects this vector onto the given one.\n \t *\n \t * @param {Vector3} v - The vector to project to.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tprojectOnVector( v ) {\n\n \t\tconst denominator = v.lengthSq();\n\n \t\tif ( denominator === 0 ) return this.set( 0, 0, 0 );\n\n \t\tconst scalar = v.dot( this ) / denominator;\n\n \t\treturn this.copy( v ).multiplyScalar( scalar );\n\n \t}\n\n \t/**\n \t * Projects this vector onto a plane by subtracting this\n \t * vector projected onto the plane's normal from this vector.\n \t *\n \t * @param {Vector3} planeNormal - The plane normal.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tprojectOnPlane( planeNormal ) {\n\n \t\t_vector$c.copy( this ).projectOnVector( planeNormal );\n\n \t\treturn this.sub( _vector$c );\n\n \t}\n\n \t/**\n \t * Reflects this vector off a plane orthogonal to the given normal vector.\n \t *\n \t * @param {Vector3} normal - The (normalized) normal vector.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \treflect( normal ) {\n\n \t\treturn this.sub( _vector$c.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n \t}\n \t/**\n \t * Returns the angle between the given vector and this instance in radians.\n \t *\n \t * @param {Vector3} v - The vector to compute the angle with.\n \t * @return {number} The angle in radians.\n \t */\n \tangleTo( v ) {\n\n \t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n \t\tif ( denominator === 0 ) return Math.PI / 2;\n\n \t\tconst theta = this.dot( v ) / denominator;\n\n \t\t// clamp, to handle numerical problems\n\n \t\treturn Math.acos( clamp( theta, -1, 1 ) );\n\n \t}\n\n \t/**\n \t * Computes the distance from the given vector to this instance.\n \t *\n \t * @param {Vector3} v - The vector to compute the distance to.\n \t * @return {number} The distance.\n \t */\n \tdistanceTo( v ) {\n\n \t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n \t}\n\n \t/**\n \t * Computes the squared distance from the given vector to this instance.\n \t * If you are just comparing the distance with another distance, you should compare\n \t * the distance squared instead as it is slightly more efficient to calculate.\n \t *\n \t * @param {Vector3} v - The vector to compute the squared distance to.\n \t * @return {number} The squared distance.\n \t */\n \tdistanceToSquared( v ) {\n\n \t\tconst dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n \t\treturn dx * dx + dy * dy + dz * dz;\n\n \t}\n\n \t/**\n \t * Computes the Manhattan distance from the given vector to this instance.\n \t *\n \t * @param {Vector3} v - The vector to compute the Manhattan distance to.\n \t * @return {number} The Manhattan distance.\n \t */\n \tmanhattanDistanceTo( v ) {\n\n \t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n \t}\n\n \t/**\n \t * Sets the vector components from the given spherical coordinates.\n \t *\n \t * @param {Spherical} s - The spherical coordinates.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromSpherical( s ) {\n\n \t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n \t}\n\n \t/**\n \t * Sets the vector components from the given spherical coordinates.\n \t *\n \t * @param {number} radius - The radius.\n \t * @param {number} phi - The phi angle in radians.\n \t * @param {number} theta - The theta angle in radians.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromSphericalCoords( radius, phi, theta ) {\n\n \t\tconst sinPhiRadius = Math.sin( phi ) * radius;\n\n \t\tthis.x = sinPhiRadius * Math.sin( theta );\n \t\tthis.y = Math.cos( phi ) * radius;\n \t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components from the given cylindrical coordinates.\n \t *\n \t * @param {Cylindrical} c - The cylindrical coordinates.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromCylindrical( c ) {\n\n \t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n \t}\n\n \t/**\n \t * Sets the vector components from the given cylindrical coordinates.\n \t *\n \t * @param {number} radius - The radius.\n \t * @param {number} theta - The theta angle in radians.\n \t * @param {number} y - The y value.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromCylindricalCoords( radius, theta, y ) {\n\n \t\tthis.x = radius * Math.sin( theta );\n \t\tthis.y = y;\n \t\tthis.z = radius * Math.cos( theta );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the position elements of the\n \t * given transformation matrix.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromMatrixPosition( m ) {\n\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 12 ];\n \t\tthis.y = e[ 13 ];\n \t\tthis.z = e[ 14 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the scale elements of the\n \t * given transformation matrix.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromMatrixScale( m ) {\n\n \t\tconst sx = this.setFromMatrixColumn( m, 0 ).length();\n \t\tconst sy = this.setFromMatrixColumn( m, 1 ).length();\n \t\tconst sz = this.setFromMatrixColumn( m, 2 ).length();\n\n \t\tthis.x = sx;\n \t\tthis.y = sy;\n \t\tthis.z = sz;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components from the specified matrix column.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @param {number} index - The column index.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromMatrixColumn( m, index ) {\n\n \t\treturn this.fromArray( m.elements, index * 4 );\n\n \t}\n\n \t/**\n \t * Sets the vector components from the specified matrix column.\n \t *\n \t * @param {Matrix3} m - The 3x3 matrix.\n \t * @param {number} index - The column index.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromMatrix3Column( m, index ) {\n\n \t\treturn this.fromArray( m.elements, index * 3 );\n\n \t}\n\n \t/**\n \t * Sets the vector components from the given Euler angles.\n \t *\n \t * @param {Euler} e - The Euler angles to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromEuler( e ) {\n\n \t\tthis.x = e._x;\n \t\tthis.y = e._y;\n \t\tthis.z = e._z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components from the RGB components of the\n \t * given color.\n \t *\n \t * @param {Color} c - The color to set.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tsetFromColor( c ) {\n\n \t\tthis.x = c.r;\n \t\tthis.y = c.g;\n \t\tthis.z = c.b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this vector is equal with the given one.\n \t *\n \t * @param {Vector3} v - The vector to test for equality.\n \t * @return {boolean} Whether this vector is equal with the given one.\n \t */\n \tequals( v ) {\n\n \t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n \t}\n\n \t/**\n \t * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`\n \t * and z value to be `array[ offset + 2 ]`.\n \t *\n \t * @param {Array<number>} array - An array holding the vector component values.\n \t * @param {number} [offset=0] - The offset into the array.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tthis.x = array[ offset ];\n \t\tthis.y = array[ offset + 1 ];\n \t\tthis.z = array[ offset + 2 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the components of this vector to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the vector components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The vector components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this.x;\n \t\tarray[ offset + 1 ] = this.y;\n \t\tarray[ offset + 2 ] = this.z;\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Sets the components of this vector from the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n \t * @param {number} index - The index into the attribute.\n \t * @return {Vector3} A reference to this vector.\n \t */\n \tfromBufferAttribute( attribute, index ) {\n\n \t\tthis.x = attribute.getX( index );\n \t\tthis.y = attribute.getY( index );\n \t\tthis.z = attribute.getZ( index );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets each component of this vector to a pseudo-random value between `0` and\n \t * `1`, excluding `1`.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \trandom() {\n\n \t\tthis.x = Math.random();\n \t\tthis.y = Math.random();\n \t\tthis.z = Math.random();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this vector to a uniformly random point on a unit sphere.\n \t *\n \t * @return {Vector3} A reference to this vector.\n \t */\n \trandomDirection() {\n\n \t\t// https://mathworld.wolfram.com/SpherePointPicking.html\n\n \t\tconst theta = Math.random() * Math.PI * 2;\n \t\tconst u = Math.random() * 2 - 1;\n \t\tconst c = Math.sqrt( 1 - u * u );\n\n \t\tthis.x = c * Math.cos( theta );\n \t\tthis.y = u;\n \t\tthis.z = c * Math.sin( theta );\n\n \t\treturn this;\n\n \t}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this.x;\n \t\tyield this.y;\n \t\tyield this.z;\n\n \t}\n\n }\n\n const _vector$c = /*@__PURE__*/ new Vector3();\n const _quaternion$5 = /*@__PURE__*/ new Quaternion();\n\n /**\n * Represents a 3x3 matrix.\n *\n * A Note on Row-Major and Column-Major Ordering:\n *\n * The constructor and {@link Matrix3#set} method take arguments in\n * [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order)\n * order, while internally they are stored in the {@link Matrix3#elements} array in column-major order.\n * This means that calling:\n * ```js\n * const m = new THREE.Matrix();\n * m.set( 11, 12, 13,\n * 21, 22, 23,\n * 31, 32, 33 );\n * ```\n * will result in the elements array containing:\n * ```js\n * m.elements = [ 11, 21, 31,\n * 12, 22, 32,\n * 13, 23, 33 ];\n * ```\n * and internally all calculations are performed using column-major ordering.\n * However, as the actual ordering makes no difference mathematically and\n * most people are used to thinking about matrices in row-major order, the\n * three.js documentation shows matrices in row-major order. Just bear in\n * mind that if you are reading the source code, you'll have to take the\n * transpose of any matrices outlined here to make sense of the calculations.\n */\n class Matrix3 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tMatrix3.prototype.isMatrix3 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 3x3 matrix. The arguments are supposed to be\n \t * in row-major order. If no arguments are provided, the constructor\n \t * initializes the matrix as an identity matrix.\n \t *\n \t * @param {number} [n11] - 1-1 matrix element.\n \t * @param {number} [n12] - 1-2 matrix element.\n \t * @param {number} [n13] - 1-3 matrix element.\n \t * @param {number} [n21] - 2-1 matrix element.\n \t * @param {number} [n22] - 2-2 matrix element.\n \t * @param {number} [n23] - 2-3 matrix element.\n \t * @param {number} [n31] - 3-1 matrix element.\n \t * @param {number} [n32] - 3-2 matrix element.\n \t * @param {number} [n33] - 3-3 matrix element.\n \t */\n \tconstructor( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n \t\t/**\n \t\t * A column-major list of matrix values.\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.elements = [\n\n \t\t\t1, 0, 0,\n \t\t\t0, 1, 0,\n \t\t\t0, 0, 1\n\n \t\t];\n\n \t\tif ( n11 !== undefined ) {\n\n \t\t\tthis.set( n11, n12, n13, n21, n22, n23, n31, n32, n33 );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix.The arguments are supposed to be\n \t * in row-major order.\n \t *\n \t * @param {number} [n11] - 1-1 matrix element.\n \t * @param {number} [n12] - 1-2 matrix element.\n \t * @param {number} [n13] - 1-3 matrix element.\n \t * @param {number} [n21] - 2-1 matrix element.\n \t * @param {number} [n22] - 2-2 matrix element.\n \t * @param {number} [n23] - 2-3 matrix element.\n \t * @param {number} [n31] - 3-1 matrix element.\n \t * @param {number} [n32] - 3-2 matrix element.\n \t * @param {number} [n33] - 3-3 matrix element.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tset( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n \t\tconst te = this.elements;\n\n \t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n \t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n \t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix to the 3x3 identity matrix.\n \t *\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tidentity() {\n\n \t\tthis.set(\n\n \t\t\t1, 0, 0,\n \t\t\t0, 1, 0,\n \t\t\t0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the values of the given matrix to this instance.\n \t *\n \t * @param {Matrix3} m - The matrix to copy.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tcopy( m ) {\n\n \t\tconst te = this.elements;\n \t\tconst me = m.elements;\n\n \t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n \t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n \t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Extracts the basis of this matrix into the three axis vectors provided.\n \t *\n \t * @param {Vector3} xAxis - The basis's x axis.\n \t * @param {Vector3} yAxis - The basis's y axis.\n \t * @param {Vector3} zAxis - The basis's z axis.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \textractBasis( xAxis, yAxis, zAxis ) {\n\n \t\txAxis.setFromMatrix3Column( this, 0 );\n \t\tyAxis.setFromMatrix3Column( this, 1 );\n \t\tzAxis.setFromMatrix3Column( this, 2 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tsetFromMatrix4( m ) {\n\n \t\tconst me = m.elements;\n\n \t\tthis.set(\n\n \t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n \t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n \t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Post-multiplies this matrix by the given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The matrix to multiply with.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmultiply( m ) {\n\n \t\treturn this.multiplyMatrices( this, m );\n\n \t}\n\n \t/**\n \t * Pre-multiplies this matrix by the given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The matrix to multiply with.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tpremultiply( m ) {\n\n \t\treturn this.multiplyMatrices( m, this );\n\n \t}\n\n \t/**\n \t * Multiples the given 3x3 matrices and stores the result\n \t * in this matrix.\n \t *\n \t * @param {Matrix3} a - The first matrix.\n \t * @param {Matrix3} b - The second matrix.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmultiplyMatrices( a, b ) {\n\n \t\tconst ae = a.elements;\n \t\tconst be = b.elements;\n \t\tconst te = this.elements;\n\n \t\tconst a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n \t\tconst a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n \t\tconst a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n \t\tconst b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n \t\tconst b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n \t\tconst b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n \t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n \t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n \t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n \t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n \t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n \t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n \t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n \t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n \t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies every component of the matrix by the given scalar.\n \t *\n \t * @param {number} s - The scalar.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmultiplyScalar( s ) {\n\n \t\tconst te = this.elements;\n\n \t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n \t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n \t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes and returns the determinant of this matrix.\n \t *\n \t * @return {number} The determinant.\n \t */\n \tdeterminant() {\n\n \t\tconst te = this.elements;\n\n \t\tconst a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n \t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n \t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n \t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n \t}\n\n \t/**\n \t * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).\n \t * You can not invert with a determinant of zero. If you attempt this, the method produces\n \t * a zero matrix instead.\n \t *\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tinvert() {\n\n \t\tconst te = this.elements,\n\n \t\t\tn11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ],\n \t\t\tn12 = te[ 3 ], n22 = te[ 4 ], n32 = te[ 5 ],\n \t\t\tn13 = te[ 6 ], n23 = te[ 7 ], n33 = te[ 8 ],\n\n \t\t\tt11 = n33 * n22 - n32 * n23,\n \t\t\tt12 = n32 * n13 - n33 * n12,\n \t\t\tt13 = n23 * n12 - n22 * n13,\n\n \t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n \t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n \t\tconst detInv = 1 / det;\n\n \t\tte[ 0 ] = t11 * detInv;\n \t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n \t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n \t\tte[ 3 ] = t12 * detInv;\n \t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n \t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n \t\tte[ 6 ] = t13 * detInv;\n \t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n \t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Transposes this matrix in place.\n \t *\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \ttranspose() {\n\n \t\tlet tmp;\n \t\tconst m = this.elements;\n\n \t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n \t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n \t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the normal matrix which is the inverse transpose of the upper\n \t * left 3x3 portion of the given 4x4 matrix.\n \t *\n \t * @param {Matrix4} matrix4 - The 4x4 matrix.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tgetNormalMatrix( matrix4 ) {\n\n \t\treturn this.setFromMatrix4( matrix4 ).invert().transpose();\n\n \t}\n\n \t/**\n \t * Transposes this matrix into the supplied array, and returns itself unchanged.\n \t *\n \t * @param {Array<number>} r - An array to store the transposed matrix elements.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \ttransposeIntoArray( r ) {\n\n \t\tconst m = this.elements;\n\n \t\tr[ 0 ] = m[ 0 ];\n \t\tr[ 1 ] = m[ 3 ];\n \t\tr[ 2 ] = m[ 6 ];\n \t\tr[ 3 ] = m[ 1 ];\n \t\tr[ 4 ] = m[ 4 ];\n \t\tr[ 5 ] = m[ 7 ];\n \t\tr[ 6 ] = m[ 2 ];\n \t\tr[ 7 ] = m[ 5 ];\n \t\tr[ 8 ] = m[ 8 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the UV transform matrix from offset, repeat, rotation, and center.\n \t *\n \t * @param {number} tx - Offset x.\n \t * @param {number} ty - Offset y.\n \t * @param {number} sx - Repeat x.\n \t * @param {number} sy - Repeat y.\n \t * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.\n \t * @param {number} cx - Center x of rotation.\n \t * @param {number} cy - Center y of rotation\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tsetUvTransform( tx, ty, sx, sy, rotation, cx, cy ) {\n\n \t\tconst c = Math.cos( rotation );\n \t\tconst s = Math.sin( rotation );\n\n \t\tthis.set(\n \t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n \t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n \t\t\t0, 0, 1\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Scales this matrix with the given scalar values.\n \t *\n \t * @deprecated\n \t * @param {number} sx - The amount to scale in the X axis.\n \t * @param {number} sy - The amount to scale in the Y axis.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tscale( sx, sy ) {\n\n \t\twarnOnce( 'Matrix3: .scale() is deprecated. Use .makeScale() instead.' ); // @deprecated r185\n\n \t\tthis.premultiply( _m3.makeScale( sx, sy ) );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates this matrix by the given angle.\n \t *\n \t * @deprecated\n \t * @param {number} theta - The rotation in radians.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \trotate( theta ) {\n\n \t\twarnOnce( 'Matrix3: .rotate() is deprecated. Use .makeRotation() instead.' ); // @deprecated r185\n\n \t\tthis.premultiply( _m3.makeRotation( - theta ) );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Translates this matrix by the given scalar values.\n \t *\n \t * @deprecated\n \t * @param {number} tx - The amount to translate in the X axis.\n \t * @param {number} ty - The amount to translate in the Y axis.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \ttranslate( tx, ty ) {\n\n \t\twarnOnce( 'Matrix3: .translate() is deprecated. Use .makeTranslation() instead.' ); // @deprecated r185\n\n \t\tthis.premultiply( _m3.makeTranslation( tx, ty ) );\n\n \t\treturn this;\n\n \t}\n\n \t// for 2D Transforms\n\n \t/**\n \t * Sets this matrix as a 2D translation transform.\n \t *\n \t * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.\n \t * @param {number} y - The amount to translate in the Y axis.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmakeTranslation( x, y ) {\n\n \t\tif ( x.isVector2 ) {\n\n \t\t\tthis.set(\n\n \t\t\t\t1, 0, x.x,\n \t\t\t\t0, 1, x.y,\n \t\t\t\t0, 0, 1\n\n \t\t\t);\n\n \t\t} else {\n\n \t\t\tthis.set(\n\n \t\t\t\t1, 0, x,\n \t\t\t\t0, 1, y,\n \t\t\t\t0, 0, 1\n\n \t\t\t);\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a 2D rotational transformation.\n \t *\n \t * @param {number} theta - The rotation in radians.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmakeRotation( theta ) {\n\n \t\t// counterclockwise\n\n \t\tconst c = Math.cos( theta );\n \t\tconst s = Math.sin( theta );\n\n \t\tthis.set(\n\n \t\t\tc, - s, 0,\n \t\t\ts, c, 0,\n \t\t\t0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a 2D scale transform.\n \t *\n \t * @param {number} x - The amount to scale in the X axis.\n \t * @param {number} y - The amount to scale in the Y axis.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tmakeScale( x, y ) {\n\n \t\tthis.set(\n\n \t\t\tx, 0, 0,\n \t\t\t0, y, 0,\n \t\t\t0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this matrix is equal with the given one.\n \t *\n \t * @param {Matrix3} matrix - The matrix to test for equality.\n \t * @return {boolean} Whether this matrix is equal with the given one.\n \t */\n \tequals( matrix ) {\n\n \t\tconst te = this.elements;\n \t\tconst me = matrix.elements;\n\n \t\tfor ( let i = 0; i < 9; i ++ ) {\n\n \t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n \t\t}\n\n \t\treturn true;\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix from the given array.\n \t *\n \t * @param {Array<number>} array - The matrix elements in column-major order.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Matrix3} A reference to this matrix.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tfor ( let i = 0; i < 9; i ++ ) {\n\n \t\t\tthis.elements[ i ] = array[ i + offset ];\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the elements of this matrix to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The matrix elements in column-major order.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tconst te = this.elements;\n\n \t\tarray[ offset ] = te[ 0 ];\n \t\tarray[ offset + 1 ] = te[ 1 ];\n \t\tarray[ offset + 2 ] = te[ 2 ];\n\n \t\tarray[ offset + 3 ] = te[ 3 ];\n \t\tarray[ offset + 4 ] = te[ 4 ];\n \t\tarray[ offset + 5 ] = te[ 5 ];\n\n \t\tarray[ offset + 6 ] = te[ 6 ];\n \t\tarray[ offset + 7 ] = te[ 7 ];\n \t\tarray[ offset + 8 ] = te[ 8 ];\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Returns a matrix with copied values from this instance.\n \t *\n \t * @return {Matrix3} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().fromArray( this.elements );\n\n \t}\n\n }\n\n const _m3 = /*@__PURE__*/ new Matrix3();\n\n const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(\n \t0.4123908, 0.3575843, 0.1804808,\n \t0.2126390, 0.7151687, 0.0721923,\n \t0.0193308, 0.1191948, 0.9505322\n );\n\n const XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(\n \t3.2409699, -1.5373832, -0.4986108,\n \t-0.9692436, 1.8759675, 0.0415551,\n \t0.0556301, -0.203977, 1.0569715\n );\n\n function createColorManagement() {\n\n \tconst ColorManagement = {\n\n \t\tenabled: true,\n\n \t\tworkingColorSpace: LinearSRGBColorSpace,\n\n \t\t/**\n \t\t * Implementations of supported color spaces.\n \t\t *\n \t\t * Required:\n \t\t *\t- primaries: chromaticity coordinates [ rx ry gx gy bx by ]\n \t\t *\t- whitePoint: reference white [ x y ]\n \t\t *\t- transfer: transfer function (pre-defined)\n \t\t *\t- toXYZ: Matrix3 RGB to XYZ transform\n \t\t *\t- fromXYZ: Matrix3 XYZ to RGB transform\n \t\t *\t- luminanceCoefficients: RGB luminance coefficients\n \t\t *\n \t\t * Optional:\n \t\t * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }\n \t\t * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }\n \t\t *\n \t\t * Reference:\n \t\t * - https://www.russellcottrell.com/photo/matrixCalculator.htm\n \t\t */\n \t\tspaces: {},\n\n \t\tconvert: function ( color, sourceColorSpace, targetColorSpace ) {\n\n \t\t\tif ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {\n\n \t\t\t\treturn color;\n\n \t\t\t}\n\n \t\t\tif ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {\n\n \t\t\t\tcolor.r = SRGBToLinear( color.r );\n \t\t\t\tcolor.g = SRGBToLinear( color.g );\n \t\t\t\tcolor.b = SRGBToLinear( color.b );\n\n \t\t\t}\n\n \t\t\tif ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {\n\n \t\t\t\tcolor.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );\n \t\t\t\tcolor.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );\n\n \t\t\t}\n\n \t\t\tif ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {\n\n \t\t\t\tcolor.r = LinearToSRGB( color.r );\n \t\t\t\tcolor.g = LinearToSRGB( color.g );\n \t\t\t\tcolor.b = LinearToSRGB( color.b );\n\n \t\t\t}\n\n \t\t\treturn color;\n\n \t\t},\n\n \t\tworkingToColorSpace: function ( color, targetColorSpace ) {\n\n \t\t\treturn this.convert( color, this.workingColorSpace, targetColorSpace );\n\n \t\t},\n\n \t\tcolorSpaceToWorking: function ( color, sourceColorSpace ) {\n\n \t\t\treturn this.convert( color, sourceColorSpace, this.workingColorSpace );\n\n \t\t},\n\n \t\tgetPrimaries: function ( colorSpace ) {\n\n \t\t\treturn this.spaces[ colorSpace ].primaries;\n\n \t\t},\n\n \t\tgetTransfer: function ( colorSpace ) {\n\n \t\t\tif ( colorSpace === NoColorSpace ) return LinearTransfer;\n\n \t\t\treturn this.spaces[ colorSpace ].transfer;\n\n \t\t},\n\n \t\tgetToneMappingMode: function ( colorSpace ) {\n\n \t\t\treturn this.spaces[ colorSpace ].outputColorSpaceConfig.toneMappingMode || 'standard';\n\n \t\t},\n\n \t\tgetLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {\n\n \t\t\treturn target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );\n\n \t\t},\n\n \t\tdefine: function ( colorSpaces ) {\n\n \t\t\tObject.assign( this.spaces, colorSpaces );\n\n \t\t},\n\n \t\t// Internal APIs\n\n \t\t_getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {\n\n \t\t\treturn targetMatrix\n \t\t\t\t.copy( this.spaces[ sourceColorSpace ].toXYZ )\n \t\t\t\t.multiply( this.spaces[ targetColorSpace ].fromXYZ );\n\n \t\t},\n\n \t\t_getDrawingBufferColorSpace: function ( colorSpace ) {\n\n \t\t\treturn this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;\n\n \t\t},\n\n \t\t_getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {\n\n \t\t\treturn this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;\n\n \t\t},\n\n \t\t// Deprecated\n\n \t\tfromWorkingColorSpace: function ( color, targetColorSpace ) {\n\n \t\t\twarnOnce( 'ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().' ); // @deprecated, r177\n\n \t\t\treturn ColorManagement.workingToColorSpace( color, targetColorSpace );\n\n \t\t},\n\n \t\ttoWorkingColorSpace: function ( color, sourceColorSpace ) {\n\n \t\t\twarnOnce( 'ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().' ); // @deprecated, r177\n\n \t\t\treturn ColorManagement.colorSpaceToWorking( color, sourceColorSpace );\n\n \t\t},\n\n \t};\n\n \t/******************************************************************************\n \t * sRGB definitions\n \t */\n\n \tconst REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];\n \tconst REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];\n \tconst D65 = [ 0.3127, 0.3290 ];\n\n \tColorManagement.define( {\n\n \t\t[ LinearSRGBColorSpace ]: {\n \t\t\tprimaries: REC709_PRIMARIES,\n \t\t\twhitePoint: D65,\n \t\t\ttransfer: LinearTransfer,\n \t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n \t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n \t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n \t\t\tworkingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },\n \t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n \t\t},\n\n \t\t[ SRGBColorSpace ]: {\n \t\t\tprimaries: REC709_PRIMARIES,\n \t\t\twhitePoint: D65,\n \t\t\ttransfer: SRGBTransfer,\n \t\t\ttoXYZ: LINEAR_REC709_TO_XYZ,\n \t\t\tfromXYZ: XYZ_TO_LINEAR_REC709,\n \t\t\tluminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,\n \t\t\toutputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }\n \t\t},\n\n \t} );\n\n \treturn ColorManagement;\n\n }\n\n const ColorManagement = /*@__PURE__*/ createColorManagement();\n\n function SRGBToLinear( c ) {\n\n \treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n }\n\n function LinearToSRGB( c ) {\n\n \treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n }\n\n let _canvas;\n\n /**\n * A class containing utility functions for images.\n *\n * @hideconstructor\n */\n class ImageUtils {\n\n \t/**\n \t * Returns a data URI containing a representation of the given image.\n \t *\n \t * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.\n \t * @param {string} [type='image/png'] - Indicates the image format.\n \t * @return {string} The data URI.\n \t */\n \tstatic getDataURL( image, type = 'image/png' ) {\n\n \t\tif ( /^data:/i.test( image.src ) ) {\n\n \t\t\treturn image.src;\n\n \t\t}\n\n \t\tif ( typeof HTMLCanvasElement === 'undefined' ) {\n\n \t\t\treturn image.src;\n\n \t\t}\n\n \t\tlet canvas;\n\n \t\tif ( image instanceof HTMLCanvasElement ) {\n\n \t\t\tcanvas = image;\n\n \t\t} else {\n\n \t\t\tif ( _canvas === undefined ) _canvas = createElementNS( 'canvas' );\n\n \t\t\t_canvas.width = image.width;\n \t\t\t_canvas.height = image.height;\n\n \t\t\tconst context = _canvas.getContext( '2d' );\n\n \t\t\tif ( image instanceof ImageData ) {\n\n \t\t\t\tcontext.putImageData( image, 0, 0 );\n\n \t\t\t} else {\n\n \t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n \t\t\t}\n\n \t\t\tcanvas = _canvas;\n\n \t\t}\n\n \t\treturn canvas.toDataURL( type );\n\n \t}\n\n \t/**\n \t * Converts the given sRGB image data to linear color space.\n \t *\n \t * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.\n \t * @return {HTMLCanvasElement|Object} The converted image.\n \t */\n \tstatic sRGBToLinear( image ) {\n\n \t\tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n \t\t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n \t\t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n \t\t\tconst canvas = createElementNS( 'canvas' );\n\n \t\t\tcanvas.width = image.width;\n \t\t\tcanvas.height = image.height;\n\n \t\t\tconst context = canvas.getContext( '2d' );\n \t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n \t\t\tconst imageData = context.getImageData( 0, 0, image.width, image.height );\n \t\t\tconst data = imageData.data;\n\n \t\t\tfor ( let i = 0; i < data.length; i ++ ) {\n\n \t\t\t\tdata[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255;\n\n \t\t\t}\n\n \t\t\tcontext.putImageData( imageData, 0, 0 );\n\n \t\t\treturn canvas;\n\n \t\t} else if ( image.data ) {\n\n \t\t\tconst data = image.data.slice( 0 );\n\n \t\t\tfor ( let i = 0; i < data.length; i ++ ) {\n\n \t\t\t\tif ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) {\n\n \t\t\t\t\tdata[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\t// assuming float\n\n \t\t\t\t\tdata[ i ] = SRGBToLinear( data[ i ] );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\treturn {\n \t\t\t\tdata: data,\n \t\t\t\twidth: image.width,\n \t\t\t\theight: image.height\n \t\t\t};\n\n \t\t} else {\n\n \t\t\twarn( 'ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );\n \t\t\treturn image;\n\n \t\t}\n\n \t}\n\n }\n\n let _sourceId = 0;\n\n /**\n * Represents the data source of a texture.\n *\n * The main purpose of this class is to decouple the data definition from the texture\n * definition so the same data can be used with multiple texture instances.\n */\n class Source {\n\n \t/**\n \t * Constructs a new video texture.\n \t *\n \t * @param {any} [data=null] - The data definition of a texture.\n \t */\n \tconstructor( data = null ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isSource = true;\n\n \t\t/**\n \t\t * The ID of the source.\n \t\t *\n \t\t * @name Source#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _sourceId ++ } );\n\n \t\t/**\n \t\t * The UUID of the source.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.uuid = generateUUID();\n\n \t\t/**\n \t\t * The data definition of a texture.\n \t\t *\n \t\t * @type {any}\n \t\t */\n \t\tthis.data = data;\n\n \t\t/**\n \t\t * This property is only relevant when {@link Source#needsUpdate} is set to `true` and\n \t\t * provides more control on how texture data should be processed. When `dataReady` is set\n \t\t * to `false`, the engine performs the memory allocation (if necessary) but does not transfer\n \t\t * the data into the GPU memory.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.dataReady = true;\n\n \t\t/**\n \t\t * This starts at `0` and counts how many times {@link Source#needsUpdate} is set to `true`.\n \t\t *\n \t\t * @type {number}\n \t\t * @readonly\n \t\t * @default 0\n \t\t */\n \t\tthis.version = 0;\n\n \t}\n\n \t/**\n \t * Returns the dimensions of the source into the given target vector.\n \t *\n \t * @param {(Vector2|Vector3)} target - The target object the result is written into.\n \t * @return {(Vector2|Vector3)} The dimensions of the source.\n \t */\n \tgetSize( target ) {\n\n \t\tconst data = this.data;\n\n \t\tif ( ( typeof HTMLVideoElement !== 'undefined' ) && ( data instanceof HTMLVideoElement ) ) {\n\n \t\t\ttarget.set( data.videoWidth, data.videoHeight, 0 );\n\n \t\t} else if ( ( typeof VideoFrame !== 'undefined' ) && ( data instanceof VideoFrame ) ) {\n\n \t\t\ttarget.set( data.displayWidth, data.displayHeight, 0 );\n\n \t\t} else if ( data !== null ) {\n\n \t\t\ttarget.set( data.width, data.height, data.depth || 0 );\n\n \t\t} else {\n\n \t\t\ttarget.set( 0, 0, 0 );\n\n \t\t}\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * When the property is set to `true`, the engine allocates the memory\n \t * for the texture (if necessary) and triggers the actual texture upload\n \t * to the GPU next time the source is used.\n \t *\n \t * @type {boolean}\n \t * @default false\n \t * @param {boolean} value\n \t */\n \tset needsUpdate( value ) {\n\n \t\tif ( value === true ) this.version ++;\n\n \t}\n\n \t/**\n \t * Serializes the source into JSON.\n \t *\n \t * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n \t * @return {Object} A JSON object representing the serialized source.\n \t * @see {@link ObjectLoader#parse}\n \t */\n \ttoJSON( meta ) {\n\n \t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n \t\tif ( ! isRootObject && meta.images[ this.uuid ] !== undefined ) {\n\n \t\t\treturn meta.images[ this.uuid ];\n\n \t\t}\n\n \t\tconst output = {\n \t\t\tuuid: this.uuid,\n \t\t\turl: ''\n \t\t};\n\n \t\tconst data = this.data;\n\n \t\tif ( data !== null ) {\n\n \t\t\tlet url;\n\n \t\t\tif ( Array.isArray( data ) ) {\n\n \t\t\t\t// cube texture\n\n \t\t\t\turl = [];\n\n \t\t\t\tfor ( let i = 0, l = data.length; i < l; i ++ ) {\n\n \t\t\t\t\tif ( data[ i ].isDataTexture ) {\n\n \t\t\t\t\t\turl.push( serializeImage( data[ i ].image ) );\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\turl.push( serializeImage( data[ i ] ) );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\t// texture\n\n \t\t\t\turl = serializeImage( data );\n\n \t\t\t}\n\n \t\t\toutput.url = url;\n\n \t\t}\n\n \t\tif ( ! isRootObject ) {\n\n \t\t\tmeta.images[ this.uuid ] = output;\n\n \t\t}\n\n \t\treturn output;\n\n \t}\n\n }\n\n function serializeImage( image ) {\n\n \tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n \t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n \t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n \t\t// default images\n\n \t\treturn ImageUtils.getDataURL( image );\n\n \t} else {\n\n \t\tif ( image.data ) {\n\n \t\t\t// images of DataTexture\n\n \t\t\treturn {\n \t\t\t\tdata: Array.from( image.data ),\n \t\t\t\twidth: image.width,\n \t\t\t\theight: image.height,\n \t\t\t\ttype: image.data.constructor.name\n \t\t\t};\n\n \t\t} else {\n\n \t\t\twarn( 'Texture: Unable to serialize Texture.' );\n \t\t\treturn {};\n\n \t\t}\n\n \t}\n\n }\n\n let _textureId = 0;\n\n const _tempVec3 = /*@__PURE__*/ new Vector3();\n\n /**\n * Base class for all textures.\n *\n * Note: After the initial use of a texture, its dimensions, format, and type\n * cannot be changed. Instead, call {@link Texture#dispose} on the texture and instantiate a new one.\n *\n * @augments EventDispatcher\n */\n class Texture extends EventDispatcher {\n\n \t/**\n \t * Constructs a new texture.\n \t *\n \t * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.\n \t * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.\n \t * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.\n \t * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.\n \t * @param {number} [magFilter=LinearFilter] - The mag filter value.\n \t * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.\n \t * @param {number} [format=RGBAFormat] - The texture format.\n \t * @param {number} [type=UnsignedByteType] - The texture type.\n \t * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.\n \t * @param {string} [colorSpace=NoColorSpace] - The color space.\n \t */\n \tconstructor( image = Texture.DEFAULT_IMAGE, mapping = Texture.DEFAULT_MAPPING, wrapS = ClampToEdgeWrapping, wrapT = ClampToEdgeWrapping, magFilter = LinearFilter, minFilter = LinearMipmapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = Texture.DEFAULT_ANISOTROPY, colorSpace = NoColorSpace ) {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isTexture = true;\n\n \t\t/**\n \t\t * The ID of the texture.\n \t\t *\n \t\t * @name Texture#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _textureId ++ } );\n\n \t\t/**\n \t\t * The UUID of the texture.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.uuid = generateUUID();\n\n \t\t/**\n \t\t * The name of the texture.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.name = '';\n\n \t\t/**\n \t\t * The data definition of a texture. A reference to the data source can be\n \t\t * shared across textures. This is often useful in context of spritesheets\n \t\t * where multiple textures render the same data but with different texture\n \t\t * transformations.\n \t\t *\n \t\t * @type {Source}\n \t\t */\n \t\tthis.source = new Source( image );\n\n \t\t/**\n \t\t * An array holding user-defined mipmaps.\n \t\t *\n \t\t * @type {Array<Object>}\n \t\t */\n \t\tthis.mipmaps = [];\n\n \t\t/**\n \t\t * How the texture is applied to the object. The value `UVMapping`\n \t\t * is the default, where texture or uv coordinates are used to apply the map.\n \t\t *\n \t\t * @type {(UVMapping|CubeReflectionMapping|CubeRefractionMapping|EquirectangularReflectionMapping|EquirectangularRefractionMapping|CubeUVReflectionMapping)}\n \t\t * @default UVMapping\n \t\t*/\n \t\tthis.mapping = mapping;\n\n \t\t/**\n \t\t * Lets you select the uv attribute to map the texture to. `0` for `uv`,\n \t\t * `1` for `uv1`, `2` for `uv2` and `3` for `uv3`.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.channel = 0;\n\n \t\t/**\n \t\t * This defines how the texture is wrapped horizontally and corresponds to\n \t\t * *U* in UV mapping.\n \t\t *\n \t\t * @type {(RepeatWrapping|ClampToEdgeWrapping|MirroredRepeatWrapping)}\n \t\t * @default ClampToEdgeWrapping\n \t\t */\n \t\tthis.wrapS = wrapS;\n\n \t\t/**\n \t\t * This defines how the texture is wrapped horizontally and corresponds to\n \t\t * *V* in UV mapping.\n \t\t *\n \t\t * @type {(RepeatWrapping|ClampToEdgeWrapping|MirroredRepeatWrapping)}\n \t\t * @default ClampToEdgeWrapping\n \t\t */\n \t\tthis.wrapT = wrapT;\n\n \t\t/**\n \t\t * How the texture is sampled when a texel covers more than one pixel.\n \t\t *\n \t\t * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)}\n \t\t * @default LinearFilter\n \t\t */\n \t\tthis.magFilter = magFilter;\n\n \t\t/**\n \t\t * How the texture is sampled when a texel covers less than one pixel.\n \t\t *\n \t\t * @type {(NearestFilter|NearestMipmapNearestFilter|NearestMipmapLinearFilter|LinearFilter|LinearMipmapNearestFilter|LinearMipmapLinearFilter)}\n \t\t * @default LinearMipmapLinearFilter\n \t\t */\n \t\tthis.minFilter = minFilter;\n\n \t\t/**\n \t\t * The number of samples taken along the axis through the pixel that has the\n \t\t * highest density of texels. By default, this value is `1`. A higher value\n \t\t * gives a less blurry result than a basic mipmap, at the cost of more\n \t\t * texture samples being used.\n \t\t *\n \t\t * @type {number}\n \t\t * @default Texture.DEFAULT_ANISOTROPY\n \t\t */\n \t\tthis.anisotropy = anisotropy;\n\n \t\t/**\n \t\t * The format of the texture.\n \t\t *\n \t\t * @type {number}\n \t\t * @default RGBAFormat\n \t\t */\n \t\tthis.format = format;\n\n \t\t/**\n \t\t * The default internal format is derived from {@link Texture#format} and {@link Texture#type} and\n \t\t * defines how the texture data is going to be stored on the GPU.\n \t\t *\n \t\t * This property allows to overwrite the default format.\n \t\t *\n \t\t * @type {?string}\n \t\t * @default null\n \t\t */\n \t\tthis.internalFormat = null;\n\n \t\t/**\n \t\t * The data type of the texture.\n \t\t *\n \t\t * @type {number}\n \t\t * @default UnsignedByteType\n \t\t */\n \t\tthis.type = type;\n\n \t\t/**\n \t\t * How much a single repetition of the texture is offset from the beginning,\n \t\t * in each direction U and V. Typical range is `0.0` to `1.0`.\n \t\t *\n \t\t * @type {Vector2}\n \t\t * @default (0,0)\n \t\t */\n \t\tthis.offset = new Vector2( 0, 0 );\n\n \t\t/**\n \t\t * How many times the texture is repeated across the surface, in each\n \t\t * direction U and V. If repeat is set greater than `1` in either direction,\n \t\t * the corresponding wrap parameter should also be set to `RepeatWrapping`\n \t\t * or `MirroredRepeatWrapping` to achieve the desired tiling effect.\n \t\t *\n \t\t * @type {Vector2}\n \t\t * @default (1,1)\n \t\t */\n \t\tthis.repeat = new Vector2( 1, 1 );\n\n \t\t/**\n \t\t * The point around which rotation occurs. A value of `(0.5, 0.5)` corresponds\n \t\t * to the center of the texture. Default is `(0, 0)`, the lower left.\n \t\t *\n \t\t * @type {Vector2}\n \t\t * @default (0,0)\n \t\t */\n \t\tthis.center = new Vector2( 0, 0 );\n\n \t\t/**\n \t\t * How much the texture is rotated around the center point, in radians.\n \t\t * Positive values are counter-clockwise.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.rotation = 0;\n\n \t\t/**\n \t\t * Whether to update the texture's uv-transformation {@link Texture#matrix}\n \t\t * from the properties {@link Texture#offset}, {@link Texture#repeat},\n \t\t * {@link Texture#rotation}, and {@link Texture#center}.\n \t\t *\n \t\t * Set this to `false` if you are specifying the uv-transform matrix directly.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.matrixAutoUpdate = true;\n\n \t\t/**\n \t\t * The uv-transformation matrix of the texture.\n \t\t *\n \t\t * @type {Matrix3}\n \t\t */\n \t\tthis.matrix = new Matrix3();\n\n \t\t/**\n \t\t * Whether to generate mipmaps (if possible) for a texture.\n \t\t *\n \t\t * Set this to `false` if you are creating mipmaps manually.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.generateMipmaps = true;\n\n \t\t/**\n \t\t * If set to `true`, the alpha channel, if present, is multiplied into the\n \t\t * color channels when the texture is uploaded to the GPU.\n \t\t *\n \t\t * Note that this property has no effect when using `ImageBitmap`. You need to\n \t\t * configure premultiply alpha on bitmap creation instead.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.premultiplyAlpha = false;\n\n \t\t/**\n \t\t * If set to `true`, the texture is flipped along the vertical axis when\n \t\t * uploaded to the GPU.\n \t\t *\n \t\t * Note that this property has no effect when using `ImageBitmap`. You need to\n \t\t * configure the flip on bitmap creation instead.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.flipY = true;\n\n \t\t/**\n \t\t * Specifies the alignment requirements for the start of each pixel row in memory.\n \t\t * The allowable values are `1` (byte-alignment), `2` (rows aligned to even-numbered bytes),\n \t\t * `4` (word-alignment), and `8` (rows start on double-word boundaries).\n \t\t *\n \t\t * @type {number}\n \t\t * @default 4\n \t\t */\n \t\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n \t\t/**\n \t\t * Textures containing color data should be annotated with `SRGBColorSpace` or `LinearSRGBColorSpace`.\n \t\t *\n \t\t * @type {string}\n \t\t * @default NoColorSpace\n \t\t */\n \t\tthis.colorSpace = colorSpace;\n\n \t\t/**\n \t\t * An object that can be used to store custom data about the texture. It\n \t\t * should not hold references to functions as these will not be cloned.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.userData = {};\n\n \t\t/**\n \t\t * This can be used to only update a subregion or specific rows of the texture (for example, just the\n \t\t * first 3 rows). Use the `addUpdateRange()` function to add ranges to this array.\n \t\t *\n \t\t * @type {Array<Object>}\n \t\t */\n \t\tthis.updateRanges = [];\n\n \t\t/**\n \t\t * This starts at `0` and counts how many times {@link Texture#needsUpdate} is set to `true`.\n \t\t *\n \t\t * @type {number}\n \t\t * @readonly\n \t\t * @default 0\n \t\t */\n \t\tthis.version = 0;\n\n \t\t/**\n \t\t * A callback function, called when the texture is updated (e.g., when\n \t\t * {@link Texture#needsUpdate} has been set to true and then the texture is used).\n \t\t *\n \t\t * @type {?Function}\n \t\t * @default null\n \t\t */\n \t\tthis.onUpdate = null;\n\n \t\t/**\n \t\t * An optional back reference to the textures render target.\n \t\t *\n \t\t * @type {?(RenderTarget|WebGLRenderTarget)}\n \t\t * @default null\n \t\t */\n \t\tthis.renderTarget = null;\n\n \t\t/**\n \t\t * Indicates whether a texture belongs to a render target or not.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default false\n \t\t */\n \t\tthis.isRenderTargetTexture = false;\n\n \t\t/**\n \t\t * Indicates if a texture should be handled like a texture array.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default false\n \t\t */\n \t\tthis.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;\n\n \t\t/**\n \t\t * Indicates whether this texture should be processed by `PMREMGenerator` or not\n \t\t * (only relevant for render target textures).\n \t\t *\n \t\t * @type {number}\n \t\t * @readonly\n \t\t * @default 0\n \t\t */\n \t\tthis.pmremVersion = 0;\n\n \t\t/**\n \t\t * Whether the texture should use one of the 16 bit integer formats which are normalized\n \t\t * to [0, 1] or [-1, 1] (depending on signed/unsigned) when sampled.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.normalized = false;\n\n \t}\n\n \t/**\n \t * The width of the texture in pixels.\n \t */\n \tget width() {\n\n \t\treturn this.source.getSize( _tempVec3 ).x;\n\n \t}\n\n \t/**\n \t * The height of the texture in pixels.\n \t */\n \tget height() {\n\n \t\treturn this.source.getSize( _tempVec3 ).y;\n\n \t}\n\n \t/**\n \t * The depth of the texture in pixels.\n \t */\n \tget depth() {\n\n \t\treturn this.source.getSize( _tempVec3 ).z;\n\n \t}\n\n \t/**\n \t * The image object holding the texture data.\n \t *\n \t * @type {?Object}\n \t */\n \tget image() {\n\n \t\treturn this.source.data;\n\n \t}\n\n \tset image( value ) {\n\n \t\tthis.source.data = value;\n\n \t}\n\n \t/**\n \t * Updates the texture transformation matrix from the properties {@link Texture#offset},\n \t * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.\n \t */\n \tupdateMatrix() {\n\n \t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n \t}\n\n \t/**\n \t * Adds a range of data in the data texture to be updated on the GPU.\n \t *\n \t * @param {number} start - Position at which to start update.\n \t * @param {number} count - The number of components to update.\n \t */\n \taddUpdateRange( start, count ) {\n\n \t\tthis.updateRanges.push( { start, count } );\n\n \t}\n\n \t/**\n \t * Clears the update ranges.\n \t */\n \tclearUpdateRanges() {\n\n \t\tthis.updateRanges.length = 0;\n\n \t}\n\n \t/**\n \t * Returns a new texture with copied values from this instance.\n \t *\n \t * @return {Texture} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Copies the values of the given texture to this instance.\n \t *\n \t * @param {Texture} source - The texture to copy.\n \t * @return {Texture} A reference to this instance.\n \t */\n \tcopy( source ) {\n\n \t\tthis.name = source.name;\n\n \t\tthis.source = source.source;\n \t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n \t\tthis.mapping = source.mapping;\n \t\tthis.channel = source.channel;\n\n \t\tthis.wrapS = source.wrapS;\n \t\tthis.wrapT = source.wrapT;\n\n \t\tthis.magFilter = source.magFilter;\n \t\tthis.minFilter = source.minFilter;\n\n \t\tthis.anisotropy = source.anisotropy;\n\n \t\tthis.format = source.format;\n \t\tthis.internalFormat = source.internalFormat;\n \t\tthis.type = source.type;\n \t\tthis.normalized = source.normalized;\n\n \t\tthis.offset.copy( source.offset );\n \t\tthis.repeat.copy( source.repeat );\n \t\tthis.center.copy( source.center );\n \t\tthis.rotation = source.rotation;\n\n \t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n \t\tthis.matrix.copy( source.matrix );\n\n \t\tthis.generateMipmaps = source.generateMipmaps;\n \t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n \t\tthis.flipY = source.flipY;\n \t\tthis.unpackAlignment = source.unpackAlignment;\n \t\tthis.colorSpace = source.colorSpace;\n\n \t\tthis.renderTarget = source.renderTarget;\n \t\tthis.isRenderTargetTexture = source.isRenderTargetTexture;\n \t\tthis.isArrayTexture = source.isArrayTexture;\n\n \t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n \t\tthis.needsUpdate = true;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this texture's properties based on `values`.\n \t * @param {Object} values - A container with texture parameters.\n \t */\n \tsetValues( values ) {\n\n \t\tfor ( const key in values ) {\n\n \t\t\tconst newValue = values[ key ];\n\n \t\t\tif ( newValue === undefined ) {\n\n \t\t\t\twarn( `Texture.setValues(): parameter '${ key }' has value of undefined.` );\n \t\t\t\tcontinue;\n\n \t\t\t}\n\n \t\t\tconst currentValue = this[ key ];\n\n \t\t\tif ( currentValue === undefined ) {\n\n \t\t\t\twarn( `Texture.setValues(): property '${ key }' does not exist.` );\n \t\t\t\tcontinue;\n\n \t\t\t}\n\n \t\t\tif ( ( currentValue && newValue ) && ( currentValue.isVector2 && newValue.isVector2 ) ) {\n\n \t\t\t\tcurrentValue.copy( newValue );\n\n \t\t\t} else if ( ( currentValue && newValue ) && ( currentValue.isVector3 && newValue.isVector3 ) ) {\n\n \t\t\t\tcurrentValue.copy( newValue );\n\n \t\t\t} else if ( ( currentValue && newValue ) && ( currentValue.isMatrix3 && newValue.isMatrix3 ) ) {\n\n \t\t\t\tcurrentValue.copy( newValue );\n\n \t\t\t} else {\n\n \t\t\t\tthis[ key ] = newValue;\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Serializes the texture into JSON.\n \t *\n \t * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n \t * @return {Object} A JSON object representing the serialized texture.\n \t * @see {@link ObjectLoader#parse}\n \t */\n \ttoJSON( meta ) {\n\n \t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n \t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n \t\t\treturn meta.textures[ this.uuid ];\n\n \t\t}\n\n \t\tconst output = {\n\n \t\t\tmetadata: {\n \t\t\t\tversion: 4.7,\n \t\t\t\ttype: 'Texture',\n \t\t\t\tgenerator: 'Texture.toJSON'\n \t\t\t},\n\n \t\t\tuuid: this.uuid,\n \t\t\tname: this.name,\n\n \t\t\timage: this.source.toJSON( meta ).uuid,\n\n \t\t\tmapping: this.mapping,\n \t\t\tchannel: this.channel,\n\n \t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n \t\t\toffset: [ this.offset.x, this.offset.y ],\n \t\t\tcenter: [ this.center.x, this.center.y ],\n \t\t\trotation: this.rotation,\n\n \t\t\twrap: [ this.wrapS, this.wrapT ],\n\n \t\t\tformat: this.format,\n \t\t\tinternalFormat: this.internalFormat,\n \t\t\ttype: this.type,\n \t\t\tnormalized: this.normalized,\n \t\t\tcolorSpace: this.colorSpace,\n\n \t\t\tminFilter: this.minFilter,\n \t\t\tmagFilter: this.magFilter,\n \t\t\tanisotropy: this.anisotropy,\n\n \t\t\tflipY: this.flipY,\n\n \t\t\tgenerateMipmaps: this.generateMipmaps,\n \t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n \t\t\tunpackAlignment: this.unpackAlignment\n\n \t\t};\n\n \t\tif ( Object.keys( this.userData ).length > 0 ) output.userData = this.userData;\n\n \t\tif ( ! isRootObject ) {\n\n \t\t\tmeta.textures[ this.uuid ] = output;\n\n \t\t}\n\n \t\treturn output;\n\n \t}\n\n \t/**\n \t * Frees the GPU-related resources allocated by this instance. Call this\n \t * method whenever this instance is no longer used in your app.\n \t *\n \t * @fires Texture#dispose\n \t */\n \tdispose() {\n\n \t\t/**\n \t\t * Fires when the texture has been disposed of.\n \t\t *\n \t\t * @event Texture#dispose\n \t\t * @type {Object}\n \t\t */\n \t\tthis.dispatchEvent( { type: 'dispose' } );\n\n \t}\n\n \t/**\n \t * Transforms the given uv vector with the textures uv transformation matrix.\n \t *\n \t * @param {Vector2} uv - The uv vector.\n \t * @return {Vector2} The transformed uv vector.\n \t */\n \ttransformUv( uv ) {\n\n \t\tif ( this.mapping !== UVMapping ) return uv;\n\n \t\tuv.applyMatrix3( this.matrix );\n\n \t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n \t\t\tswitch ( this.wrapS ) {\n\n \t\t\t\tcase RepeatWrapping:\n\n \t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n \t\t\t\t\tbreak;\n\n \t\t\t\tcase ClampToEdgeWrapping:\n\n \t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n \t\t\t\t\tbreak;\n\n \t\t\t\tcase MirroredRepeatWrapping:\n\n \t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n \t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n \t\t\t\t\t}\n\n \t\t\t\t\tbreak;\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n \t\t\tswitch ( this.wrapT ) {\n\n \t\t\t\tcase RepeatWrapping:\n\n \t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n \t\t\t\t\tbreak;\n\n \t\t\t\tcase ClampToEdgeWrapping:\n\n \t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n \t\t\t\t\tbreak;\n\n \t\t\t\tcase MirroredRepeatWrapping:\n\n \t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n \t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n \t\t\t\t\t}\n\n \t\t\t\t\tbreak;\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( this.flipY ) {\n\n \t\t\tuv.y = 1 - uv.y;\n\n \t\t}\n\n \t\treturn uv;\n\n \t}\n\n \t/**\n \t * Setting this property to `true` indicates the engine the texture\n \t * must be updated in the next render. This triggers a texture upload\n \t * to the GPU and ensures correct texture parameter configuration.\n \t *\n \t * @type {boolean}\n \t * @default false\n \t * @param {boolean} value\n \t */\n \tset needsUpdate( value ) {\n\n \t\tif ( value === true ) {\n\n \t\t\tthis.version ++;\n \t\t\tthis.source.needsUpdate = true;\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Setting this property to `true` indicates the engine the PMREM\n \t * must be regenerated.\n \t *\n \t * @type {boolean}\n \t * @default false\n \t * @param {boolean} value\n \t */\n \tset needsPMREMUpdate( value ) {\n\n \t\tif ( value === true ) {\n\n \t\t\tthis.pmremVersion ++;\n\n \t\t}\n\n \t}\n\n }\n\n /**\n * The default image for all textures.\n *\n * @static\n * @type {?Image}\n * @default null\n */\n Texture.DEFAULT_IMAGE = null;\n\n /**\n * The default mapping for all textures.\n *\n * @static\n * @type {number}\n * @default UVMapping\n */\n Texture.DEFAULT_MAPPING = UVMapping;\n\n /**\n * The default anisotropy value for all textures.\n *\n * @static\n * @type {number}\n * @default 1\n */\n Texture.DEFAULT_ANISOTROPY = 1;\n\n /**\n * Class representing a 4D vector. A 4D vector is an ordered quadruplet of numbers\n * (labeled x, y, z and w), which can be used to represent a number of things, such as:\n *\n * - A point in 4D space.\n * - A direction and length in 4D space. In three.js the length will\n * always be the Euclidean distance(straight-line distance) from `(0, 0, 0, 0)` to `(x, y, z, w)`\n * and the direction is also measured from `(0, 0, 0, 0)` towards `(x, y, z, w)`.\n * - Any arbitrary ordered quadruplet of numbers.\n *\n * There are other things a 4D vector can be used to represent, however these\n * are the most common uses in *three.js*.\n *\n * Iterating through a vector instance will yield its components `(x, y, z, w)` in\n * the corresponding order.\n * ```js\n * const a = new THREE.Vector4( 0, 1, 0, 0 );\n *\n * //no arguments; will be initialised to (0, 0, 0, 1)\n * const b = new THREE.Vector4( );\n *\n * const d = a.dot( b );\n * ```\n */\n class Vector4 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tVector4.prototype.isVector4 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 4D vector.\n \t *\n \t * @param {number} [x=0] - The x value of this vector.\n \t * @param {number} [y=0] - The y value of this vector.\n \t * @param {number} [z=0] - The z value of this vector.\n \t * @param {number} [w=1] - The w value of this vector.\n \t */\n \tconstructor( x = 0, y = 0, z = 0, w = 1 ) {\n\n \t\t/**\n \t\t * The x value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.x = x;\n\n \t\t/**\n \t\t * The y value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.y = y;\n\n \t\t/**\n \t\t * The z value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.z = z;\n\n \t\t/**\n \t\t * The w value of this vector.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.w = w;\n\n \t}\n\n \t/**\n \t * Alias for {@link Vector4#z}.\n \t *\n \t * @type {number}\n \t */\n \tget width() {\n\n \t\treturn this.z;\n\n \t}\n\n \tset width( value ) {\n\n \t\tthis.z = value;\n\n \t}\n\n \t/**\n \t * Alias for {@link Vector4#w}.\n \t *\n \t * @type {number}\n \t */\n \tget height() {\n\n \t\treturn this.w;\n\n \t}\n\n \tset height( value ) {\n\n \t\tthis.w = value;\n\n \t}\n\n \t/**\n \t * Sets the vector components.\n \t *\n \t * @param {number} x - The value of the x component.\n \t * @param {number} y - The value of the y component.\n \t * @param {number} z - The value of the z component.\n \t * @param {number} w - The value of the w component.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tset( x, y, z, w ) {\n\n \t\tthis.x = x;\n \t\tthis.y = y;\n \t\tthis.z = z;\n \t\tthis.w = w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the same value.\n \t *\n \t * @param {number} scalar - The value to set for all vector components.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetScalar( scalar ) {\n\n \t\tthis.x = scalar;\n \t\tthis.y = scalar;\n \t\tthis.z = scalar;\n \t\tthis.w = scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's x component to the given value\n \t *\n \t * @param {number} x - The value to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetX( x ) {\n\n \t\tthis.x = x;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's y component to the given value\n \t *\n \t * @param {number} y - The value to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetY( y ) {\n\n \t\tthis.y = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's z component to the given value\n \t *\n \t * @param {number} z - The value to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetZ( z ) {\n\n \t\tthis.z = z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector's w component to the given value\n \t *\n \t * @param {number} w - The value to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetW( w ) {\n\n \t\tthis.w = w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Allows to set a vector component with an index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y,\n \t * `2` equals to z, `3` equals to w.\n \t * @param {number} value - The value to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetComponent( index, value ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: this.x = value; break;\n \t\t\tcase 1: this.y = value; break;\n \t\t\tcase 2: this.z = value; break;\n \t\t\tcase 3: this.w = value; break;\n \t\t\tdefault: throw new Error( 'THREE.Vector4: index is out of range: ' + index );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the value of the vector component which matches the given index.\n \t *\n \t * @param {number} index - The component index. `0` equals to x, `1` equals to y,\n \t * `2` equals to z, `3` equals to w.\n \t * @return {number} A vector component value.\n \t */\n \tgetComponent( index ) {\n\n \t\tswitch ( index ) {\n\n \t\t\tcase 0: return this.x;\n \t\t\tcase 1: return this.y;\n \t\t\tcase 2: return this.z;\n \t\t\tcase 3: return this.w;\n \t\t\tdefault: throw new Error( 'THREE.Vector4: index is out of range: ' + index );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns a new vector with copied values from this instance.\n \t *\n \t * @return {Vector4} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n \t}\n\n \t/**\n \t * Copies the values of the given vector to this instance.\n \t *\n \t * @param {Vector3|Vector4} v - The vector to copy.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tcopy( v ) {\n\n \t\tthis.x = v.x;\n \t\tthis.y = v.y;\n \t\tthis.z = v.z;\n \t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector to this instance.\n \t *\n \t * @param {Vector4} v - The vector to add.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tadd( v ) {\n\n \t\tthis.x += v.x;\n \t\tthis.y += v.y;\n \t\tthis.z += v.z;\n \t\tthis.w += v.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given scalar value to all components of this instance.\n \t *\n \t * @param {number} s - The scalar to add.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \taddScalar( s ) {\n\n \t\tthis.x += s;\n \t\tthis.y += s;\n \t\tthis.z += s;\n \t\tthis.w += s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector4} a - The first vector.\n \t * @param {Vector4} b - The second vector.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \taddVectors( a, b ) {\n\n \t\tthis.x = a.x + b.x;\n \t\tthis.y = a.y + b.y;\n \t\tthis.z = a.z + b.z;\n \t\tthis.w = a.w + b.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given vector scaled by the given factor to this instance.\n \t *\n \t * @param {Vector4} v - The vector.\n \t * @param {number} s - The factor that scales `v`.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \taddScaledVector( v, s ) {\n\n \t\tthis.x += v.x * s;\n \t\tthis.y += v.y * s;\n \t\tthis.z += v.z * s;\n \t\tthis.w += v.w * s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vector from this instance.\n \t *\n \t * @param {Vector4} v - The vector to subtract.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsub( v ) {\n\n \t\tthis.x -= v.x;\n \t\tthis.y -= v.y;\n \t\tthis.z -= v.z;\n \t\tthis.w -= v.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given scalar value from all components of this instance.\n \t *\n \t * @param {number} s - The scalar to subtract.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsubScalar( s ) {\n\n \t\tthis.x -= s;\n \t\tthis.y -= s;\n \t\tthis.z -= s;\n \t\tthis.w -= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the given vectors and stores the result in this instance.\n \t *\n \t * @param {Vector4} a - The first vector.\n \t * @param {Vector4} b - The second vector.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsubVectors( a, b ) {\n\n \t\tthis.x = a.x - b.x;\n \t\tthis.y = a.y - b.y;\n \t\tthis.z = a.z - b.z;\n \t\tthis.w = a.w - b.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given vector with this instance.\n \t *\n \t * @param {Vector4} v - The vector to multiply.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tmultiply( v ) {\n\n \t\tthis.x *= v.x;\n \t\tthis.y *= v.y;\n \t\tthis.z *= v.z;\n \t\tthis.w *= v.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given scalar value with all components of this instance.\n \t *\n \t * @param {number} scalar - The scalar to multiply.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tmultiplyScalar( scalar ) {\n\n \t\tthis.x *= scalar;\n \t\tthis.y *= scalar;\n \t\tthis.z *= scalar;\n \t\tthis.w *= scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies this vector with the given 4x4 matrix.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tapplyMatrix4( m ) {\n\n \t\tconst x = this.x, y = this.y, z = this.z, w = this.w;\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n \t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n \t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n \t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Divides this instance by the given vector.\n \t *\n \t * @param {Vector4} v - The vector to divide.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tdivide( v ) {\n\n \t\tthis.x /= v.x;\n \t\tthis.y /= v.y;\n \t\tthis.z /= v.z;\n \t\tthis.w /= v.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Divides this vector by the given scalar.\n \t *\n \t * @param {number} scalar - The scalar to divide.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tdivideScalar( scalar ) {\n\n \t\treturn this.multiplyScalar( 1 / scalar );\n\n \t}\n\n \t/**\n \t * Sets the x, y and z components of this\n \t * vector to the quaternion's axis and w to the angle.\n \t *\n \t * @param {Quaternion} q - The Quaternion to set.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetAxisAngleFromQuaternion( q ) {\n\n \t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n \t\t// q is assumed to be normalized\n\n \t\tthis.w = 2 * Math.acos( q.w );\n\n \t\tconst s = Math.sqrt( 1 - q.w * q.w );\n\n \t\tif ( s < 0.0001 ) {\n\n \t\t\tthis.x = 1;\n \t\t\tthis.y = 0;\n \t\t\tthis.z = 0;\n\n \t\t} else {\n\n \t\t\tthis.x = q.x / s;\n \t\t\tthis.y = q.y / s;\n \t\t\tthis.z = q.z / s;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the x, y and z components of this\n \t * vector to the axis of rotation and w to the angle.\n \t *\n \t * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetAxisAngleFromRotationMatrix( m ) {\n\n \t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n \t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n \t\tlet angle, x, y, z; // variables for result\n \t\tconst epsilon = 0.01,\t\t// margin to allow for rounding errors\n \t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n \t\t\tte = m.elements,\n\n \t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n \t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n \t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n \t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n \t\t ( Math.abs( m13 - m31 ) < epsilon ) &&\n \t\t ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n \t\t\t// singularity found\n \t\t\t// first check for identity matrix which must have +1 for all terms\n \t\t\t// in leading diagonal and zero in other terms\n\n \t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n \t\t\t ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n \t\t\t ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n \t\t\t ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n \t\t\t\t// this singularity is identity matrix so angle = 0\n\n \t\t\t\tthis.set( 1, 0, 0, 0 );\n\n \t\t\t\treturn this; // zero angle, arbitrary axis\n\n \t\t\t}\n\n \t\t\t// otherwise this singularity is angle = 180\n\n \t\t\tangle = Math.PI;\n\n \t\t\tconst xx = ( m11 + 1 ) / 2;\n \t\t\tconst yy = ( m22 + 1 ) / 2;\n \t\t\tconst zz = ( m33 + 1 ) / 2;\n \t\t\tconst xy = ( m12 + m21 ) / 4;\n \t\t\tconst xz = ( m13 + m31 ) / 4;\n \t\t\tconst yz = ( m23 + m32 ) / 4;\n\n \t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n \t\t\t\t// m11 is the largest diagonal term\n\n \t\t\t\tif ( xx < epsilon ) {\n\n \t\t\t\t\tx = 0;\n \t\t\t\t\ty = 0.707106781;\n \t\t\t\t\tz = 0.707106781;\n\n \t\t\t\t} else {\n\n \t\t\t\t\tx = Math.sqrt( xx );\n \t\t\t\t\ty = xy / x;\n \t\t\t\t\tz = xz / x;\n\n \t\t\t\t}\n\n \t\t\t} else if ( yy > zz ) {\n\n \t\t\t\t// m22 is the largest diagonal term\n\n \t\t\t\tif ( yy < epsilon ) {\n\n \t\t\t\t\tx = 0.707106781;\n \t\t\t\t\ty = 0;\n \t\t\t\t\tz = 0.707106781;\n\n \t\t\t\t} else {\n\n \t\t\t\t\ty = Math.sqrt( yy );\n \t\t\t\t\tx = xy / y;\n \t\t\t\t\tz = yz / y;\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\t// m33 is the largest diagonal term so base result on this\n\n \t\t\t\tif ( zz < epsilon ) {\n\n \t\t\t\t\tx = 0.707106781;\n \t\t\t\t\ty = 0.707106781;\n \t\t\t\t\tz = 0;\n\n \t\t\t\t} else {\n\n \t\t\t\t\tz = Math.sqrt( zz );\n \t\t\t\t\tx = xz / z;\n \t\t\t\t\ty = yz / z;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tthis.set( x, y, z, angle );\n\n \t\t\treturn this; // return 180 deg rotation\n\n \t\t}\n\n \t\t// as we have reached here there are no singularities so we can handle normally\n\n \t\tlet s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n \t\t\t( m13 - m31 ) * ( m13 - m31 ) +\n \t\t\t( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n \t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n \t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n \t\t// caught by singularity test above, but I've left it in just in case\n\n \t\tthis.x = ( m32 - m23 ) / s;\n \t\tthis.y = ( m13 - m31 ) / s;\n \t\tthis.z = ( m21 - m12 ) / s;\n \t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the vector components to the position elements of the\n \t * given transformation matrix.\n \t *\n \t * @param {Matrix4} m - The 4x4 matrix.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetFromMatrixPosition( m ) {\n\n \t\tconst e = m.elements;\n\n \t\tthis.x = e[ 12 ];\n \t\tthis.y = e[ 13 ];\n \t\tthis.z = e[ 14 ];\n \t\tthis.w = e[ 15 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w\n \t * value, replace that value with the corresponding min value.\n \t *\n \t * @param {Vector4} v - The vector.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tmin( v ) {\n\n \t\tthis.x = Math.min( this.x, v.x );\n \t\tthis.y = Math.min( this.y, v.y );\n \t\tthis.z = Math.min( this.z, v.z );\n \t\tthis.w = Math.min( this.w, v.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y, z or w value is less than the given vector's x, y, z or w\n \t * value, replace that value with the corresponding max value.\n \t *\n \t * @param {Vector4} v - The vector.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tmax( v ) {\n\n \t\tthis.x = Math.max( this.x, v.x );\n \t\tthis.y = Math.max( this.y, v.y );\n \t\tthis.z = Math.max( this.z, v.z );\n \t\tthis.w = Math.max( this.w, v.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w\n \t * value, it is replaced by the corresponding value.\n \t * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value,\n \t * it is replaced by the corresponding value.\n \t *\n \t * @param {Vector4} min - The minimum x, y and z values.\n \t * @param {Vector4} max - The maximum x, y and z values in the desired range.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tclamp( min, max ) {\n\n \t\t// assumes min < max, componentwise\n\n \t\tthis.x = clamp( this.x, min.x, max.x );\n \t\tthis.y = clamp( this.y, min.y, max.y );\n \t\tthis.z = clamp( this.z, min.z, max.z );\n \t\tthis.w = clamp( this.w, min.w, max.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's x, y, z or w values are greater than the max value, they are\n \t * replaced by the max value.\n \t * If this vector's x, y, z or w values are less than the min value, they are\n \t * replaced by the min value.\n \t *\n \t * @param {number} minVal - The minimum value the components will be clamped to.\n \t * @param {number} maxVal - The maximum value the components will be clamped to.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tclampScalar( minVal, maxVal ) {\n\n \t\tthis.x = clamp( this.x, minVal, maxVal );\n \t\tthis.y = clamp( this.y, minVal, maxVal );\n \t\tthis.z = clamp( this.z, minVal, maxVal );\n \t\tthis.w = clamp( this.w, minVal, maxVal );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * If this vector's length is greater than the max value, it is replaced by\n \t * the max value.\n \t * If this vector's length is less than the min value, it is replaced by the\n \t * min value.\n \t *\n \t * @param {number} min - The minimum value the vector length will be clamped to.\n \t * @param {number} max - The maximum value the vector length will be clamped to.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tclampLength( min, max ) {\n\n \t\tconst length = this.length();\n\n \t\treturn this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded down to the nearest integer value.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tfloor() {\n\n \t\tthis.x = Math.floor( this.x );\n \t\tthis.y = Math.floor( this.y );\n \t\tthis.z = Math.floor( this.z );\n \t\tthis.w = Math.floor( this.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded up to the nearest integer value.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tceil() {\n\n \t\tthis.x = Math.ceil( this.x );\n \t\tthis.y = Math.ceil( this.y );\n \t\tthis.z = Math.ceil( this.z );\n \t\tthis.w = Math.ceil( this.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded to the nearest integer value\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tround() {\n\n \t\tthis.x = Math.round( this.x );\n \t\tthis.y = Math.round( this.y );\n \t\tthis.z = Math.round( this.z );\n \t\tthis.w = Math.round( this.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * The components of this vector are rounded towards zero (up if negative,\n \t * down if positive) to an integer value.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \troundToZero() {\n\n \t\tthis.x = Math.trunc( this.x );\n \t\tthis.y = Math.trunc( this.y );\n \t\tthis.z = Math.trunc( this.z );\n \t\tthis.w = Math.trunc( this.w );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tnegate() {\n\n \t\tthis.x = - this.x;\n \t\tthis.y = - this.y;\n \t\tthis.z = - this.z;\n \t\tthis.w = - this.w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Calculates the dot product of the given vector with this instance.\n \t *\n \t * @param {Vector4} v - The vector to compute the dot product with.\n \t * @return {number} The result of the dot product.\n \t */\n \tdot( v ) {\n\n \t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n \t}\n\n \t/**\n \t * Computes the square of the Euclidean length (straight-line length) from\n \t * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should\n \t * compare the length squared instead as it is slightly more efficient to calculate.\n \t *\n \t * @return {number} The square length of this vector.\n \t */\n \tlengthSq() {\n\n \t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n \t}\n\n \t/**\n \t * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tlength() {\n\n \t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n \t}\n\n \t/**\n \t * Computes the Manhattan length of this vector.\n \t *\n \t * @return {number} The length of this vector.\n \t */\n \tmanhattanLength() {\n\n \t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n \t}\n\n \t/**\n \t * Converts this vector to a unit vector - that is, sets it equal to a vector\n \t * with the same direction as this one, but with a vector length of `1`.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tnormalize() {\n\n \t\treturn this.divideScalar( this.length() || 1 );\n\n \t}\n\n \t/**\n \t * Sets this vector to a vector with the same direction as this one, but\n \t * with the specified length.\n \t *\n \t * @param {number} length - The new length of this vector.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tsetLength( length ) {\n\n \t\treturn this.normalize().multiplyScalar( length );\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vector and this instance, where\n \t * alpha is the percent distance along the line - alpha = 0 will be this\n \t * vector, and alpha = 1 will be the given one.\n \t *\n \t * @param {Vector4} v - The vector to interpolate towards.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tlerp( v, alpha ) {\n\n \t\tthis.x += ( v.x - this.x ) * alpha;\n \t\tthis.y += ( v.y - this.y ) * alpha;\n \t\tthis.z += ( v.z - this.z ) * alpha;\n \t\tthis.w += ( v.w - this.w ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given vectors, where alpha is the percent\n \t * distance along the line - alpha = 0 will be first vector, and alpha = 1 will\n \t * be the second one. The result is stored in this instance.\n \t *\n \t * @param {Vector4} v1 - The first vector.\n \t * @param {Vector4} v2 - The second vector.\n \t * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tlerpVectors( v1, v2, alpha ) {\n\n \t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n \t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n \t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n \t\tthis.w = v1.w + ( v2.w - v1.w ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this vector is equal with the given one.\n \t *\n \t * @param {Vector4} v - The vector to test for equality.\n \t * @return {boolean} Whether this vector is equal with the given one.\n \t */\n \tequals( v ) {\n\n \t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n \t}\n\n \t/**\n \t * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`,\n \t * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`.\n \t *\n \t * @param {Array<number>} array - An array holding the vector component values.\n \t * @param {number} [offset=0] - The offset into the array.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tthis.x = array[ offset ];\n \t\tthis.y = array[ offset + 1 ];\n \t\tthis.z = array[ offset + 2 ];\n \t\tthis.w = array[ offset + 3 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the components of this vector to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the vector components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The vector components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this.x;\n \t\tarray[ offset + 1 ] = this.y;\n \t\tarray[ offset + 2 ] = this.z;\n \t\tarray[ offset + 3 ] = this.w;\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Sets the components of this vector from the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - The buffer attribute holding vector data.\n \t * @param {number} index - The index into the attribute.\n \t * @return {Vector4} A reference to this vector.\n \t */\n \tfromBufferAttribute( attribute, index ) {\n\n \t\tthis.x = attribute.getX( index );\n \t\tthis.y = attribute.getY( index );\n \t\tthis.z = attribute.getZ( index );\n \t\tthis.w = attribute.getW( index );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets each component of this vector to a pseudo-random value between `0` and\n \t * `1`, excluding `1`.\n \t *\n \t * @return {Vector4} A reference to this vector.\n \t */\n \trandom() {\n\n \t\tthis.x = Math.random();\n \t\tthis.y = Math.random();\n \t\tthis.z = Math.random();\n \t\tthis.w = Math.random();\n\n \t\treturn this;\n\n \t}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this.x;\n \t\tyield this.y;\n \t\tyield this.z;\n \t\tyield this.w;\n\n \t}\n\n }\n\n /**\n * Represents a 4x4 matrix.\n *\n * The most common use of a 4x4 matrix in 3D computer graphics is as a transformation matrix.\n * For an introduction to transformation matrices as used in WebGL, check out [this tutorial](https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices)\n *\n * This allows a 3D vector representing a point in 3D space to undergo\n * transformations such as translation, rotation, shear, scale, reflection,\n * orthogonal or perspective projection and so on, by being multiplied by the\n * matrix. This is known as `applying` the matrix to the vector.\n *\n * A Note on Row-Major and Column-Major Ordering:\n *\n * The constructor and {@link Matrix3#set} method take arguments in\n * [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order)\n * order, while internally they are stored in the {@link Matrix3#elements} array in column-major order.\n * This means that calling:\n * ```js\n * const m = new THREE.Matrix4();\n * m.set( 11, 12, 13, 14,\n * 21, 22, 23, 24,\n * 31, 32, 33, 34,\n * 41, 42, 43, 44 );\n * ```\n * will result in the elements array containing:\n * ```js\n * m.elements = [ 11, 21, 31, 41,\n * 12, 22, 32, 42,\n * 13, 23, 33, 43,\n * 14, 24, 34, 44 ];\n * ```\n * and internally all calculations are performed using column-major ordering.\n * However, as the actual ordering makes no difference mathematically and\n * most people are used to thinking about matrices in row-major order, the\n * three.js documentation shows matrices in row-major order. Just bear in\n * mind that if you are reading the source code, you'll have to take the\n * transpose of any matrices outlined here to make sense of the calculations.\n */\n class Matrix4 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tMatrix4.prototype.isMatrix4 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 4x4 matrix. The arguments are supposed to be\n \t * in row-major order. If no arguments are provided, the constructor\n \t * initializes the matrix as an identity matrix.\n \t *\n \t * @param {number} [n11] - 1-1 matrix element.\n \t * @param {number} [n12] - 1-2 matrix element.\n \t * @param {number} [n13] - 1-3 matrix element.\n \t * @param {number} [n14] - 1-4 matrix element.\n \t * @param {number} [n21] - 2-1 matrix element.\n \t * @param {number} [n22] - 2-2 matrix element.\n \t * @param {number} [n23] - 2-3 matrix element.\n \t * @param {number} [n24] - 2-4 matrix element.\n \t * @param {number} [n31] - 3-1 matrix element.\n \t * @param {number} [n32] - 3-2 matrix element.\n \t * @param {number} [n33] - 3-3 matrix element.\n \t * @param {number} [n34] - 3-4 matrix element.\n \t * @param {number} [n41] - 4-1 matrix element.\n \t * @param {number} [n42] - 4-2 matrix element.\n \t * @param {number} [n43] - 4-3 matrix element.\n \t * @param {number} [n44] - 4-4 matrix element.\n \t */\n \tconstructor( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n \t\t/**\n \t\t * A column-major list of matrix values.\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.elements = [\n\n \t\t\t1, 0, 0, 0,\n \t\t\t0, 1, 0, 0,\n \t\t\t0, 0, 1, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t];\n\n \t\tif ( n11 !== undefined ) {\n\n \t\t\tthis.set( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix.The arguments are supposed to be\n \t * in row-major order.\n \t *\n \t * @param {number} [n11] - 1-1 matrix element.\n \t * @param {number} [n12] - 1-2 matrix element.\n \t * @param {number} [n13] - 1-3 matrix element.\n \t * @param {number} [n14] - 1-4 matrix element.\n \t * @param {number} [n21] - 2-1 matrix element.\n \t * @param {number} [n22] - 2-2 matrix element.\n \t * @param {number} [n23] - 2-3 matrix element.\n \t * @param {number} [n24] - 2-4 matrix element.\n \t * @param {number} [n31] - 3-1 matrix element.\n \t * @param {number} [n32] - 3-2 matrix element.\n \t * @param {number} [n33] - 3-3 matrix element.\n \t * @param {number} [n34] - 3-4 matrix element.\n \t * @param {number} [n41] - 4-1 matrix element.\n \t * @param {number} [n42] - 4-2 matrix element.\n \t * @param {number} [n43] - 4-3 matrix element.\n \t * @param {number} [n44] - 4-4 matrix element.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tset( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n \t\tconst te = this.elements;\n\n \t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n \t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n \t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n \t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix to the 4x4 identity matrix.\n \t *\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tidentity() {\n\n \t\tthis.set(\n\n \t\t\t1, 0, 0, 0,\n \t\t\t0, 1, 0, 0,\n \t\t\t0, 0, 1, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a matrix with copied values from this instance.\n \t *\n \t * @return {Matrix4} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new Matrix4().fromArray( this.elements );\n\n \t}\n\n \t/**\n \t * Copies the values of the given matrix to this instance.\n \t *\n \t * @param {Matrix4} m - The matrix to copy.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tcopy( m ) {\n\n \t\tconst te = this.elements;\n \t\tconst me = m.elements;\n\n \t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n \t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n \t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n \t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the translation component of the given matrix\n \t * into this matrix's translation component.\n \t *\n \t * @param {Matrix4} m - The matrix to copy the translation component.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tcopyPosition( m ) {\n\n \t\tconst te = this.elements, me = m.elements;\n\n \t\tte[ 12 ] = me[ 12 ];\n \t\tte[ 13 ] = me[ 13 ];\n \t\tte[ 14 ] = me[ 14 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The 3x3 matrix.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tsetFromMatrix3( m ) {\n\n \t\tconst me = m.elements;\n\n \t\tthis.set(\n\n \t\t\tme[ 0 ], me[ 3 ], me[ 6 ], 0,\n \t\t\tme[ 1 ], me[ 4 ], me[ 7 ], 0,\n \t\t\tme[ 2 ], me[ 5 ], me[ 8 ], 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Extracts the basis of this matrix into the three axis vectors provided.\n \t *\n \t * @param {Vector3} xAxis - The basis's x axis.\n \t * @param {Vector3} yAxis - The basis's y axis.\n \t * @param {Vector3} zAxis - The basis's z axis.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \textractBasis( xAxis, yAxis, zAxis ) {\n\n \t\tif ( this.determinantAffine() === 0 ) {\n\n \t\t\txAxis.set( 1, 0, 0 );\n \t\t\tyAxis.set( 0, 1, 0 );\n \t\t\tzAxis.set( 0, 0, 1 );\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\txAxis.setFromMatrixColumn( this, 0 );\n \t\tyAxis.setFromMatrixColumn( this, 1 );\n \t\tzAxis.setFromMatrixColumn( this, 2 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given basis vectors to this matrix.\n \t *\n \t * @param {Vector3} xAxis - The basis's x axis.\n \t * @param {Vector3} yAxis - The basis's y axis.\n \t * @param {Vector3} zAxis - The basis's z axis.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeBasis( xAxis, yAxis, zAxis ) {\n\n \t\tthis.set(\n \t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n \t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n \t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n \t\t\t0, 0, 0, 1\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Extracts the rotation component of the given matrix\n \t * into this matrix's rotation component.\n \t *\n \t * Note: This method does not support reflection matrices.\n \t *\n \t * @param {Matrix4} m - The matrix.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \textractRotation( m ) {\n\n \t\tif ( m.determinantAffine() === 0 ) {\n\n \t\t\treturn this.identity();\n\n \t\t}\n\n \t\tconst te = this.elements;\n \t\tconst me = m.elements;\n\n \t\tconst scaleX = 1 / _v1$7.setFromMatrixColumn( m, 0 ).length();\n \t\tconst scaleY = 1 / _v1$7.setFromMatrixColumn( m, 1 ).length();\n \t\tconst scaleZ = 1 / _v1$7.setFromMatrixColumn( m, 2 ).length();\n\n \t\tte[ 0 ] = me[ 0 ] * scaleX;\n \t\tte[ 1 ] = me[ 1 ] * scaleX;\n \t\tte[ 2 ] = me[ 2 ] * scaleX;\n \t\tte[ 3 ] = 0;\n\n \t\tte[ 4 ] = me[ 4 ] * scaleY;\n \t\tte[ 5 ] = me[ 5 ] * scaleY;\n \t\tte[ 6 ] = me[ 6 ] * scaleY;\n \t\tte[ 7 ] = 0;\n\n \t\tte[ 8 ] = me[ 8 ] * scaleZ;\n \t\tte[ 9 ] = me[ 9 ] * scaleZ;\n \t\tte[ 10 ] = me[ 10 ] * scaleZ;\n \t\tte[ 11 ] = 0;\n\n \t\tte[ 12 ] = 0;\n \t\tte[ 13 ] = 0;\n \t\tte[ 14 ] = 0;\n \t\tte[ 15 ] = 1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the rotation component (the upper left 3x3 matrix) of this matrix to\n \t * the rotation specified by the given Euler angles. The rest of\n \t * the matrix is set to the identity. Depending on the {@link Euler#order},\n \t * there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix)\n \t * for a complete list.\n \t *\n \t * @param {Euler} euler - The Euler angles.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationFromEuler( euler ) {\n\n \t\tconst te = this.elements;\n\n \t\tconst x = euler.x, y = euler.y, z = euler.z;\n \t\tconst a = Math.cos( x ), b = Math.sin( x );\n \t\tconst c = Math.cos( y ), d = Math.sin( y );\n \t\tconst e = Math.cos( z ), f = Math.sin( z );\n\n \t\tif ( euler.order === 'XYZ' ) {\n\n \t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n \t\t\tte[ 0 ] = c * e;\n \t\t\tte[ 4 ] = - c * f;\n \t\t\tte[ 8 ] = d;\n\n \t\t\tte[ 1 ] = af + be * d;\n \t\t\tte[ 5 ] = ae - bf * d;\n \t\t\tte[ 9 ] = - b * c;\n\n \t\t\tte[ 2 ] = bf - ae * d;\n \t\t\tte[ 6 ] = be + af * d;\n \t\t\tte[ 10 ] = a * c;\n\n \t\t} else if ( euler.order === 'YXZ' ) {\n\n \t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n \t\t\tte[ 0 ] = ce + df * b;\n \t\t\tte[ 4 ] = de * b - cf;\n \t\t\tte[ 8 ] = a * d;\n\n \t\t\tte[ 1 ] = a * f;\n \t\t\tte[ 5 ] = a * e;\n \t\t\tte[ 9 ] = - b;\n\n \t\t\tte[ 2 ] = cf * b - de;\n \t\t\tte[ 6 ] = df + ce * b;\n \t\t\tte[ 10 ] = a * c;\n\n \t\t} else if ( euler.order === 'ZXY' ) {\n\n \t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n \t\t\tte[ 0 ] = ce - df * b;\n \t\t\tte[ 4 ] = - a * f;\n \t\t\tte[ 8 ] = de + cf * b;\n\n \t\t\tte[ 1 ] = cf + de * b;\n \t\t\tte[ 5 ] = a * e;\n \t\t\tte[ 9 ] = df - ce * b;\n\n \t\t\tte[ 2 ] = - a * d;\n \t\t\tte[ 6 ] = b;\n \t\t\tte[ 10 ] = a * c;\n\n \t\t} else if ( euler.order === 'ZYX' ) {\n\n \t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n \t\t\tte[ 0 ] = c * e;\n \t\t\tte[ 4 ] = be * d - af;\n \t\t\tte[ 8 ] = ae * d + bf;\n\n \t\t\tte[ 1 ] = c * f;\n \t\t\tte[ 5 ] = bf * d + ae;\n \t\t\tte[ 9 ] = af * d - be;\n\n \t\t\tte[ 2 ] = - d;\n \t\t\tte[ 6 ] = b * c;\n \t\t\tte[ 10 ] = a * c;\n\n \t\t} else if ( euler.order === 'YZX' ) {\n\n \t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n \t\t\tte[ 0 ] = c * e;\n \t\t\tte[ 4 ] = bd - ac * f;\n \t\t\tte[ 8 ] = bc * f + ad;\n\n \t\t\tte[ 1 ] = f;\n \t\t\tte[ 5 ] = a * e;\n \t\t\tte[ 9 ] = - b * e;\n\n \t\t\tte[ 2 ] = - d * e;\n \t\t\tte[ 6 ] = ad * f + bc;\n \t\t\tte[ 10 ] = ac - bd * f;\n\n \t\t} else if ( euler.order === 'XZY' ) {\n\n \t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n \t\t\tte[ 0 ] = c * e;\n \t\t\tte[ 4 ] = - f;\n \t\t\tte[ 8 ] = d * e;\n\n \t\t\tte[ 1 ] = ac * f + bd;\n \t\t\tte[ 5 ] = a * e;\n \t\t\tte[ 9 ] = ad * f - bc;\n\n \t\t\tte[ 2 ] = bc * f - ad;\n \t\t\tte[ 6 ] = b * e;\n \t\t\tte[ 10 ] = bd * f + ac;\n\n \t\t}\n\n \t\t// bottom row\n \t\tte[ 3 ] = 0;\n \t\tte[ 7 ] = 0;\n \t\tte[ 11 ] = 0;\n\n \t\t// last column\n \t\tte[ 12 ] = 0;\n \t\tte[ 13 ] = 0;\n \t\tte[ 14 ] = 0;\n \t\tte[ 15 ] = 1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the rotation component of this matrix to the rotation specified by\n \t * the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion)\n \t * The rest of the matrix is set to the identity.\n \t *\n \t * @param {Quaternion} q - The Quaternion.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationFromQuaternion( q ) {\n\n \t\treturn this.compose( _zero, q, _one );\n\n \t}\n\n \t/**\n \t * Sets the rotation component of the transformation matrix, looking from `eye` towards\n \t * `target`, and oriented by the up-direction.\n \t *\n \t * @param {Vector3} eye - The eye vector.\n \t * @param {Vector3} target - The target vector.\n \t * @param {Vector3} up - The up vector.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tlookAt( eye, target, up ) {\n\n \t\tconst te = this.elements;\n\n \t\t_z.subVectors( eye, target );\n\n \t\tif ( _z.lengthSq() === 0 ) {\n\n \t\t\t// eye and target are in the same position\n\n \t\t\t_z.z = 1;\n\n \t\t}\n\n \t\t_z.normalize();\n \t\t_x.crossVectors( up, _z );\n\n \t\tif ( _x.lengthSq() === 0 ) {\n\n \t\t\t// up and z are parallel\n\n \t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n \t\t\t\t_z.x += 0.0001;\n\n \t\t\t} else {\n\n \t\t\t\t_z.z += 0.0001;\n\n \t\t\t}\n\n \t\t\t_z.normalize();\n \t\t\t_x.crossVectors( up, _z );\n\n \t\t}\n\n \t\t_x.normalize();\n \t\t_y.crossVectors( _z, _x );\n\n \t\tte[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;\n \t\tte[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;\n \t\tte[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Post-multiplies this matrix by the given 4x4 matrix.\n \t *\n \t * @param {Matrix4} m - The matrix to multiply with.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmultiply( m ) {\n\n \t\treturn this.multiplyMatrices( this, m );\n\n \t}\n\n \t/**\n \t * Pre-multiplies this matrix by the given 4x4 matrix.\n \t *\n \t * @param {Matrix4} m - The matrix to multiply with.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tpremultiply( m ) {\n\n \t\treturn this.multiplyMatrices( m, this );\n\n \t}\n\n \t/**\n \t * Multiples the given 4x4 matrices and stores the result\n \t * in this matrix.\n \t *\n \t * @param {Matrix4} a - The first matrix.\n \t * @param {Matrix4} b - The second matrix.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmultiplyMatrices( a, b ) {\n\n \t\tconst ae = a.elements;\n \t\tconst be = b.elements;\n \t\tconst te = this.elements;\n\n \t\tconst a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n \t\tconst a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n \t\tconst a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n \t\tconst a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n \t\tconst b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n \t\tconst b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n \t\tconst b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n \t\tconst b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n \t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n \t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n \t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n \t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n \t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n \t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n \t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n \t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n \t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n \t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n \t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n \t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n \t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n \t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n \t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n \t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies every component of the matrix by the given scalar.\n \t *\n \t * @param {number} s - The scalar.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmultiplyScalar( s ) {\n\n \t\tconst te = this.elements;\n\n \t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n \t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n \t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n \t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes and returns the determinant of this matrix.\n \t *\n \t * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).\n \t *\n \t * @return {number} The determinant.\n \t */\n \tdeterminant() {\n\n \t\tconst te = this.elements;\n\n \t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n \t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n \t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n \t\tconst n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n \t\tconst t11 = n23 * n34 - n24 * n33;\n \t\tconst t12 = n22 * n34 - n24 * n32;\n \t\tconst t13 = n22 * n33 - n23 * n32;\n\n \t\tconst t21 = n21 * n34 - n24 * n31;\n \t\tconst t22 = n21 * n33 - n23 * n31;\n \t\tconst t23 = n21 * n32 - n22 * n31;\n\n \t\treturn n11 * ( n42 * t11 - n43 * t12 + n44 * t13 ) -\n \t\t\tn12 * ( n41 * t11 - n43 * t21 + n44 * t22 ) +\n \t\t\tn13 * ( n41 * t12 - n42 * t21 + n44 * t23 ) -\n \t\t\tn14 * ( n41 * t13 - n42 * t22 + n43 * t23 );\n\n \t}\n\n \t/**\n \t * Computes and returns the determinant of the 4x4 matrix, but assumes the\n \t * matrix is affine, saving some computations.\n \t *\n \t * For affine matrices (like an object's world matrix), this value equals the\n \t * full 4x4 {@link Matrix4#determinant} but is cheaper to compute.\n \t *\n \t * Assumes the bottom row is [0, 0, 0, 1].\n \t *\n \t * @return {number} The determinant of the matrix.\n \t */\n \tdeterminantAffine() {\n\n \t\tconst te = this.elements;\n\n \t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ];\n \t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ];\n \t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ];\n\n \t\treturn n11 * ( n22 * n33 - n23 * n32 ) -\n \t\t\tn12 * ( n21 * n33 - n23 * n31 ) +\n \t\t\tn13 * ( n21 * n32 - n22 * n31 );\n\n \t}\n\n \t/**\n \t * Transposes this matrix in place.\n \t *\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \ttranspose() {\n\n \t\tconst te = this.elements;\n \t\tlet tmp;\n\n \t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n \t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n \t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n \t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n \t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n \t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the position component for this matrix from the given vector,\n \t * without affecting the rest of the matrix.\n \t *\n \t * @param {number|Vector3} x - The x component of the vector or alternatively the vector object.\n \t * @param {number} y - The y component of the vector.\n \t * @param {number} z - The z component of the vector.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tsetPosition( x, y, z ) {\n\n \t\tconst te = this.elements;\n\n \t\tif ( x.isVector3 ) {\n\n \t\t\tte[ 12 ] = x.x;\n \t\t\tte[ 13 ] = x.y;\n \t\t\tte[ 14 ] = x.z;\n\n \t\t} else {\n\n \t\t\tte[ 12 ] = x;\n \t\t\tte[ 13 ] = y;\n \t\t\tte[ 14 ] = z;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).\n \t * You can not invert with a determinant of zero. If you attempt this, the method produces\n \t * a zero matrix instead.\n \t *\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tinvert() {\n\n \t\t// based on https://github.com/toji/gl-matrix\n \t\tconst te = this.elements,\n\n \t\t\tn11 = te[ 0 ], n21 = te[ 1 ], n31 = te[ 2 ], n41 = te[ 3 ],\n \t\t\tn12 = te[ 4 ], n22 = te[ 5 ], n32 = te[ 6 ], n42 = te[ 7 ],\n \t\t\tn13 = te[ 8 ], n23 = te[ 9 ], n33 = te[ 10 ], n43 = te[ 11 ],\n \t\t\tn14 = te[ 12 ], n24 = te[ 13 ], n34 = te[ 14 ], n44 = te[ 15 ],\n\n \t\t\tt1 = n11 * n22 - n21 * n12,\n \t\t\tt2 = n11 * n32 - n31 * n12,\n \t\t\tt3 = n11 * n42 - n41 * n12,\n \t\t\tt4 = n21 * n32 - n31 * n22,\n \t\t\tt5 = n21 * n42 - n41 * n22,\n \t\t\tt6 = n31 * n42 - n41 * n32,\n \t\t\tt7 = n13 * n24 - n23 * n14,\n \t\t\tt8 = n13 * n34 - n33 * n14,\n \t\t\tt9 = n13 * n44 - n43 * n14,\n \t\t\tt10 = n23 * n34 - n33 * n24,\n \t\t\tt11 = n23 * n44 - n43 * n24,\n \t\t\tt12 = n33 * n44 - n43 * n34;\n\n \t\tconst det = t1 * t12 - t2 * t11 + t3 * t10 + t4 * t9 - t5 * t8 + t6 * t7;\n\n \t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n \t\tconst detInv = 1 / det;\n\n \t\tte[ 0 ] = ( n22 * t12 - n32 * t11 + n42 * t10 ) * detInv;\n \t\tte[ 1 ] = ( n31 * t11 - n21 * t12 - n41 * t10 ) * detInv;\n \t\tte[ 2 ] = ( n24 * t6 - n34 * t5 + n44 * t4 ) * detInv;\n \t\tte[ 3 ] = ( n33 * t5 - n23 * t6 - n43 * t4 ) * detInv;\n\n \t\tte[ 4 ] = ( n32 * t9 - n12 * t12 - n42 * t8 ) * detInv;\n \t\tte[ 5 ] = ( n11 * t12 - n31 * t9 + n41 * t8 ) * detInv;\n \t\tte[ 6 ] = ( n34 * t3 - n14 * t6 - n44 * t2 ) * detInv;\n \t\tte[ 7 ] = ( n13 * t6 - n33 * t3 + n43 * t2 ) * detInv;\n\n \t\tte[ 8 ] = ( n12 * t11 - n22 * t9 + n42 * t7 ) * detInv;\n \t\tte[ 9 ] = ( n21 * t9 - n11 * t11 - n41 * t7 ) * detInv;\n \t\tte[ 10 ] = ( n14 * t5 - n24 * t3 + n44 * t1 ) * detInv;\n \t\tte[ 11 ] = ( n23 * t3 - n13 * t5 - n43 * t1 ) * detInv;\n\n \t\tte[ 12 ] = ( n22 * t8 - n12 * t10 - n32 * t7 ) * detInv;\n \t\tte[ 13 ] = ( n11 * t10 - n21 * t8 + n31 * t7 ) * detInv;\n \t\tte[ 14 ] = ( n24 * t2 - n14 * t4 - n34 * t1 ) * detInv;\n \t\tte[ 15 ] = ( n13 * t4 - n23 * t2 + n33 * t1 ) * detInv;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the columns of this matrix by the given vector.\n \t *\n \t * @param {Vector3} v - The scale vector.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tscale( v ) {\n\n \t\tconst te = this.elements;\n \t\tconst x = v.x, y = v.y, z = v.z;\n\n \t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n \t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n \t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n \t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Gets the maximum scale value of the three axes.\n \t *\n \t * @return {number} The maximum scale.\n \t */\n \tgetMaxScaleOnAxis() {\n\n \t\tconst te = this.elements;\n\n \t\tconst scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n \t\tconst scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n \t\tconst scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n \t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n \t}\n\n \t/**\n \t * Sets this matrix as a translation transform from the given vector.\n \t *\n \t * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector.\n \t * @param {number} y - The amount to translate in the Y axis.\n \t * @param {number} z - The amount to translate in the z axis.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeTranslation( x, y, z ) {\n\n \t\tif ( x.isVector3 ) {\n\n \t\t\tthis.set(\n\n \t\t\t\t1, 0, 0, x.x,\n \t\t\t\t0, 1, 0, x.y,\n \t\t\t\t0, 0, 1, x.z,\n \t\t\t\t0, 0, 0, 1\n\n \t\t\t);\n\n \t\t} else {\n\n \t\t\tthis.set(\n\n \t\t\t\t1, 0, 0, x,\n \t\t\t\t0, 1, 0, y,\n \t\t\t\t0, 0, 1, z,\n \t\t\t\t0, 0, 0, 1\n\n \t\t\t);\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a rotational transformation around the X axis by\n \t * the given angle.\n \t *\n \t * @param {number} theta - The rotation in radians.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationX( theta ) {\n\n \t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n \t\tthis.set(\n\n \t\t\t1, 0, 0, 0,\n \t\t\t0, c, - s, 0,\n \t\t\t0, s, c, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a rotational transformation around the Y axis by\n \t * the given angle.\n \t *\n \t * @param {number} theta - The rotation in radians.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationY( theta ) {\n\n \t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n \t\tthis.set(\n\n \t\t\t c, 0, s, 0,\n \t\t\t 0, 1, 0, 0,\n \t\t\t- s, 0, c, 0,\n \t\t\t 0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a rotational transformation around the Z axis by\n \t * the given angle.\n \t *\n \t * @param {number} theta - The rotation in radians.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationZ( theta ) {\n\n \t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n \t\tthis.set(\n\n \t\t\tc, - s, 0, 0,\n \t\t\ts, c, 0, 0,\n \t\t\t0, 0, 1, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a rotational transformation around the given axis by\n \t * the given angle.\n \t *\n \t * This is a somewhat controversial but mathematically sound alternative to\n \t * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).\n \t *\n \t * @param {Vector3} axis - The normalized rotation axis.\n \t * @param {number} angle - The rotation in radians.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeRotationAxis( axis, angle ) {\n\n \t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n \t\tconst c = Math.cos( angle );\n \t\tconst s = Math.sin( angle );\n \t\tconst t = 1 - c;\n \t\tconst x = axis.x, y = axis.y, z = axis.z;\n \t\tconst tx = t * x, ty = t * y;\n\n \t\tthis.set(\n\n \t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n \t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n \t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a scale transformation.\n \t *\n \t * @param {number} x - The amount to scale in the X axis.\n \t * @param {number} y - The amount to scale in the Y axis.\n \t * @param {number} z - The amount to scale in the Z axis.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeScale( x, y, z ) {\n\n \t\tthis.set(\n\n \t\t\tx, 0, 0, 0,\n \t\t\t0, y, 0, 0,\n \t\t\t0, 0, z, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix as a shear transformation.\n \t *\n \t * @param {number} xy - The amount to shear X by Y.\n \t * @param {number} xz - The amount to shear X by Z.\n \t * @param {number} yx - The amount to shear Y by X.\n \t * @param {number} yz - The amount to shear Y by Z.\n \t * @param {number} zx - The amount to shear Z by X.\n \t * @param {number} zy - The amount to shear Z by Y.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeShear( xy, xz, yx, yz, zx, zy ) {\n\n \t\tthis.set(\n\n \t\t\t1, yx, zx, 0,\n \t\t\txy, 1, zy, 0,\n \t\t\txz, yz, 1, 0,\n \t\t\t0, 0, 0, 1\n\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this matrix to the transformation composed of the given position,\n \t * rotation (Quaternion) and scale.\n \t *\n \t * @param {Vector3} position - The position vector.\n \t * @param {Quaternion} quaternion - The rotation as a Quaternion.\n \t * @param {Vector3} scale - The scale vector.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tcompose( position, quaternion, scale ) {\n\n \t\tconst te = this.elements;\n\n \t\tconst x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n \t\tconst x2 = x + x,\ty2 = y + y, z2 = z + z;\n \t\tconst xx = x * x2, xy = x * y2, xz = x * z2;\n \t\tconst yy = y * y2, yz = y * z2, zz = z * z2;\n \t\tconst wx = w * x2, wy = w * y2, wz = w * z2;\n\n \t\tconst sx = scale.x, sy = scale.y, sz = scale.z;\n\n \t\tte[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n \t\tte[ 1 ] = ( xy + wz ) * sx;\n \t\tte[ 2 ] = ( xz - wy ) * sx;\n \t\tte[ 3 ] = 0;\n\n \t\tte[ 4 ] = ( xy - wz ) * sy;\n \t\tte[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n \t\tte[ 6 ] = ( yz + wx ) * sy;\n \t\tte[ 7 ] = 0;\n\n \t\tte[ 8 ] = ( xz + wy ) * sz;\n \t\tte[ 9 ] = ( yz - wx ) * sz;\n \t\tte[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n \t\tte[ 11 ] = 0;\n\n \t\tte[ 12 ] = position.x;\n \t\tte[ 13 ] = position.y;\n \t\tte[ 14 ] = position.z;\n \t\tte[ 15 ] = 1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Decomposes this matrix into its position, rotation and scale components\n \t * and provides the result in the given objects.\n \t *\n \t * Note: Not all matrices are decomposable in this way. For example, if an\n \t * object has a non-uniformly scaled parent, then the object's world matrix\n \t * may not be decomposable, and this method may not be appropriate.\n \t *\n \t * @param {Vector3} position - The position vector.\n \t * @param {Quaternion} quaternion - The rotation as a Quaternion.\n \t * @param {Vector3} scale - The scale vector.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tdecompose( position, quaternion, scale ) {\n\n \t\tconst te = this.elements;\n\n \t\tposition.x = te[ 12 ];\n \t\tposition.y = te[ 13 ];\n \t\tposition.z = te[ 14 ];\n\n \t\tconst det = this.determinantAffine();\n\n \t\tif ( det === 0 ) {\n\n \t\t\tscale.set( 1, 1, 1 );\n \t\t\tquaternion.identity();\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\tlet sx = _v1$7.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n \t\tconst sy = _v1$7.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n \t\tconst sz = _v1$7.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n \t\t// if determinant is negative, we need to invert one scale\n \t\tif ( det < 0 ) sx = - sx;\n\n \t\t// scale the rotation part\n \t\t_m1$2.copy( this );\n\n \t\tconst invSX = 1 / sx;\n \t\tconst invSY = 1 / sy;\n \t\tconst invSZ = 1 / sz;\n\n \t\t_m1$2.elements[ 0 ] *= invSX;\n \t\t_m1$2.elements[ 1 ] *= invSX;\n \t\t_m1$2.elements[ 2 ] *= invSX;\n\n \t\t_m1$2.elements[ 4 ] *= invSY;\n \t\t_m1$2.elements[ 5 ] *= invSY;\n \t\t_m1$2.elements[ 6 ] *= invSY;\n\n \t\t_m1$2.elements[ 8 ] *= invSZ;\n \t\t_m1$2.elements[ 9 ] *= invSZ;\n \t\t_m1$2.elements[ 10 ] *= invSZ;\n\n \t\tquaternion.setFromRotationMatrix( _m1$2 );\n\n \t\tscale.x = sx;\n \t\tscale.y = sy;\n \t\tscale.z = sz;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Creates a perspective projection matrix. This is used internally by\n \t * {@link PerspectiveCamera#updateProjectionMatrix}.\n\n \t * @param {number} left - Left boundary of the viewing frustum at the near plane.\n \t * @param {number} right - Right boundary of the viewing frustum at the near plane.\n \t * @param {number} top - Top boundary of the viewing frustum at the near plane.\n \t * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.\n \t * @param {number} near - The distance from the camera to the near plane.\n \t * @param {number} far - The distance from the camera to the far plane.\n \t * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.\n \t * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {\n\n \t\tconst te = this.elements;\n\n \t\tconst x = 2 * near / ( right - left );\n \t\tconst y = 2 * near / ( top - bottom );\n\n \t\tconst a = ( right + left ) / ( right - left );\n \t\tconst b = ( top + bottom ) / ( top - bottom );\n\n \t\tlet c, d;\n\n \t\tif ( reversedDepth ) {\n\n \t\t\tc = near / ( far - near );\n \t\t\td = ( far * near ) / ( far - near );\n\n \t\t} else {\n\n \t\t\tif ( coordinateSystem === WebGLCoordinateSystem ) {\n\n \t\t\t\tc = - ( far + near ) / ( far - near );\n \t\t\t\td = ( -2 * far * near ) / ( far - near );\n\n \t\t\t} else if ( coordinateSystem === WebGPUCoordinateSystem ) {\n\n \t\t\t\tc = - far / ( far - near );\n \t\t\t\td = ( - far * near ) / ( far - near );\n\n \t\t\t} else {\n\n \t\t\t\tthrow new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );\n\n \t\t\t}\n\n \t\t}\n\n \t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a; \tte[ 12 ] = 0;\n \t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b; \tte[ 13 ] = 0;\n \t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c; \tte[ 14 ] = d;\n \t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = -1;\tte[ 15 ] = 0;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Creates a orthographic projection matrix. This is used internally by\n \t * {@link OrthographicCamera#updateProjectionMatrix}.\n\n \t * @param {number} left - Left boundary of the viewing frustum at the near plane.\n \t * @param {number} right - Right boundary of the viewing frustum at the near plane.\n \t * @param {number} top - Top boundary of the viewing frustum at the near plane.\n \t * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.\n \t * @param {number} near - The distance from the camera to the near plane.\n \t * @param {number} far - The distance from the camera to the far plane.\n \t * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.\n \t * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tmakeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {\n\n \t\tconst te = this.elements;\n\n \t\tconst x = 2 / ( right - left );\n \t\tconst y = 2 / ( top - bottom );\n\n \t\tconst a = - ( right + left ) / ( right - left );\n \t\tconst b = - ( top + bottom ) / ( top - bottom );\n\n \t\tlet c, d;\n\n \t\tif ( reversedDepth ) {\n\n \t\t\tc = 1 / ( far - near );\n \t\t\td = far / ( far - near );\n\n \t\t} else {\n\n \t\t\tif ( coordinateSystem === WebGLCoordinateSystem ) {\n\n \t\t\t\tc = -2 / ( far - near );\n \t\t\t\td = - ( far + near ) / ( far - near );\n\n \t\t\t} else if ( coordinateSystem === WebGPUCoordinateSystem ) {\n\n \t\t\t\tc = -1 / ( far - near );\n \t\t\t\td = - near / ( far - near );\n\n \t\t\t} else {\n\n \t\t\t\tthrow new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );\n\n \t\t\t}\n\n \t\t}\n\n \t\tte[ 0 ] = x;\t\tte[ 4 ] = 0;\t\tte[ 8 ] = 0; \t\tte[ 12 ] = a;\n \t\tte[ 1 ] = 0; \t\tte[ 5 ] = y;\t\tte[ 9 ] = 0; \t\tte[ 13 ] = b;\n \t\tte[ 2 ] = 0; \t\tte[ 6 ] = 0;\t\tte[ 10 ] = c;\t\tte[ 14 ] = d;\n \t\tte[ 3 ] = 0; \t\tte[ 7 ] = 0;\t\tte[ 11 ] = 0;\t\tte[ 15 ] = 1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this matrix is equal with the given one.\n \t *\n \t * @param {Matrix4} matrix - The matrix to test for equality.\n \t * @return {boolean} Whether this matrix is equal with the given one.\n \t */\n \tequals( matrix ) {\n\n \t\tconst te = this.elements;\n \t\tconst me = matrix.elements;\n\n \t\tfor ( let i = 0; i < 16; i ++ ) {\n\n \t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n \t\t}\n\n \t\treturn true;\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix from the given array.\n \t *\n \t * @param {Array<number>} array - The matrix elements in column-major order.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Matrix4} A reference to this matrix.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tfor ( let i = 0; i < 16; i ++ ) {\n\n \t\t\tthis.elements[ i ] = array[ i + offset ];\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the elements of this matrix to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the matrix elements in column-major order.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The matrix elements in column-major order.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tconst te = this.elements;\n\n \t\tarray[ offset ] = te[ 0 ];\n \t\tarray[ offset + 1 ] = te[ 1 ];\n \t\tarray[ offset + 2 ] = te[ 2 ];\n \t\tarray[ offset + 3 ] = te[ 3 ];\n\n \t\tarray[ offset + 4 ] = te[ 4 ];\n \t\tarray[ offset + 5 ] = te[ 5 ];\n \t\tarray[ offset + 6 ] = te[ 6 ];\n \t\tarray[ offset + 7 ] = te[ 7 ];\n\n \t\tarray[ offset + 8 ] = te[ 8 ];\n \t\tarray[ offset + 9 ] = te[ 9 ];\n \t\tarray[ offset + 10 ] = te[ 10 ];\n \t\tarray[ offset + 11 ] = te[ 11 ];\n\n \t\tarray[ offset + 12 ] = te[ 12 ];\n \t\tarray[ offset + 13 ] = te[ 13 ];\n \t\tarray[ offset + 14 ] = te[ 14 ];\n \t\tarray[ offset + 15 ] = te[ 15 ];\n\n \t\treturn array;\n\n \t}\n\n }\n\n const _v1$7 = /*@__PURE__*/ new Vector3();\n const _m1$2 = /*@__PURE__*/ new Matrix4();\n const _zero = /*@__PURE__*/ new Vector3( 0, 0, 0 );\n const _one = /*@__PURE__*/ new Vector3( 1, 1, 1 );\n const _x = /*@__PURE__*/ new Vector3();\n const _y = /*@__PURE__*/ new Vector3();\n const _z = /*@__PURE__*/ new Vector3();\n\n const _matrix$2 = /*@__PURE__*/ new Matrix4();\n const _quaternion$4 = /*@__PURE__*/ new Quaternion();\n\n /**\n * A class representing Euler angles.\n *\n * Euler angles describe a rotational transformation by rotating an object on\n * its various axes in specified amounts per axis, and a specified axis\n * order.\n *\n * Iterating through an instance will yield its components (x, y, z,\n * order) in the corresponding order.\n *\n * ```js\n * const a = new THREE.Euler( 0, 1, 1.57, 'XYZ' );\n * const b = new THREE.Vector3( 1, 0, 1 );\n * b.applyEuler(a);\n * ```\n */\n class Euler {\n\n \t/**\n \t * Constructs a new euler instance.\n \t *\n \t * @param {number} [x=0] - The angle of the x axis in radians.\n \t * @param {number} [y=0] - The angle of the y axis in radians.\n \t * @param {number} [z=0] - The angle of the z axis in radians.\n \t * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied.\n \t */\n \tconstructor( x = 0, y = 0, z = 0, order = Euler.DEFAULT_ORDER ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isEuler = true;\n\n \t\tthis._x = x;\n \t\tthis._y = y;\n \t\tthis._z = z;\n \t\tthis._order = order;\n\n \t}\n\n \t/**\n \t * The angle of the x axis in radians.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget x() {\n\n \t\treturn this._x;\n\n \t}\n\n \tset x( value ) {\n\n \t\tthis._x = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * The angle of the y axis in radians.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget y() {\n\n \t\treturn this._y;\n\n \t}\n\n \tset y( value ) {\n\n \t\tthis._y = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * The angle of the z axis in radians.\n \t *\n \t * @type {number}\n \t * @default 0\n \t */\n \tget z() {\n\n \t\treturn this._z;\n\n \t}\n\n \tset z( value ) {\n\n \t\tthis._z = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * A string representing the order that the rotations are applied.\n \t *\n \t * @type {string}\n \t * @default 'XYZ'\n \t */\n \tget order() {\n\n \t\treturn this._order;\n\n \t}\n\n \tset order( value ) {\n\n \t\tthis._order = value;\n \t\tthis._onChangeCallback();\n\n \t}\n\n \t/**\n \t * Sets the Euler components.\n \t *\n \t * @param {number} x - The angle of the x axis in radians.\n \t * @param {number} y - The angle of the y axis in radians.\n \t * @param {number} z - The angle of the z axis in radians.\n \t * @param {string} [order] - A string representing the order that the rotations are applied.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tset( x, y, z, order = this._order ) {\n\n \t\tthis._x = x;\n \t\tthis._y = y;\n \t\tthis._z = z;\n \t\tthis._order = order;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new Euler instance with copied values from this instance.\n \t *\n \t * @return {Euler} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n \t}\n\n \t/**\n \t * Copies the values of the given Euler instance to this instance.\n \t *\n \t * @param {Euler} euler - The Euler instance to copy.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tcopy( euler ) {\n\n \t\tthis._x = euler._x;\n \t\tthis._y = euler._y;\n \t\tthis._z = euler._z;\n \t\tthis._order = euler._order;\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the angles of this Euler instance from a pure rotation matrix.\n \t *\n \t * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).\n \t * @param {string} [order] - A string representing the order that the rotations are applied.\n \t * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tsetFromRotationMatrix( m, order = this._order, update = true ) {\n\n \t\tconst te = m.elements;\n \t\tconst m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n \t\tconst m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n \t\tconst m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n \t\tswitch ( order ) {\n\n \t\t\tcase 'XYZ':\n\n \t\t\t\tthis._y = Math.asin( clamp( m13, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m13 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n \t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n \t\t\t\t\tthis._z = 0;\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tcase 'YXZ':\n\n \t\t\t\tthis._x = Math.asin( - clamp( m23, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m23 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n \t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n \t\t\t\t\tthis._z = 0;\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tcase 'ZXY':\n\n \t\t\t\tthis._x = Math.asin( clamp( m32, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m32 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n \t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._y = 0;\n \t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tcase 'ZYX':\n\n \t\t\t\tthis._y = Math.asin( - clamp( m31, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m31 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n \t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._x = 0;\n \t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tcase 'YZX':\n\n \t\t\t\tthis._z = Math.asin( clamp( m21, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m21 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n \t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._x = 0;\n \t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tcase 'XZY':\n\n \t\t\t\tthis._z = Math.asin( - clamp( m12, -1, 1 ) );\n\n \t\t\t\tif ( Math.abs( m12 ) < 0.9999999 ) {\n\n \t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n \t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n \t\t\t\t\tthis._y = 0;\n\n \t\t\t\t}\n\n \t\t\t\tbreak;\n\n \t\t\tdefault:\n\n \t\t\t\twarn( 'Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );\n\n \t\t}\n\n \t\tthis._order = order;\n\n \t\tif ( update === true ) this._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the angles of this Euler instance from a normalized quaternion.\n \t *\n \t * @param {Quaternion} q - A normalized Quaternion.\n \t * @param {string} [order] - A string representing the order that the rotations are applied.\n \t * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tsetFromQuaternion( q, order, update ) {\n\n \t\t_matrix$2.makeRotationFromQuaternion( q );\n\n \t\treturn this.setFromRotationMatrix( _matrix$2, order, update );\n\n \t}\n\n \t/**\n \t * Sets the angles of this Euler instance from the given vector.\n \t *\n \t * @param {Vector3} v - The vector.\n \t * @param {string} [order] - A string representing the order that the rotations are applied.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tsetFromVector3( v, order = this._order ) {\n\n \t\treturn this.set( v.x, v.y, v.z, order );\n\n \t}\n\n \t/**\n \t * Resets the euler angle with a new order by creating a quaternion from this\n \t * euler angle and then setting this euler angle with the quaternion and the\n \t * new order.\n \t *\n \t * Warning: This discards revolution information.\n \t *\n \t * @param {string} [newOrder] - A string representing the new order that the rotations are applied.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \treorder( newOrder ) {\n\n \t\t_quaternion$4.setFromEuler( this );\n\n \t\treturn this.setFromQuaternion( _quaternion$4, newOrder );\n\n \t}\n\n \t/**\n \t * Returns `true` if this Euler instance is equal with the given one.\n \t *\n \t * @param {Euler} euler - The Euler instance to test for equality.\n \t * @return {boolean} Whether this Euler instance is equal with the given one.\n \t */\n \tequals( euler ) {\n\n \t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n \t}\n\n \t/**\n \t * Sets this Euler instance's components to values from the given array. The first three\n \t * entries of the array are assign to the x,y and z components. An optional fourth entry\n \t * defines the Euler order.\n \t *\n \t * @param {Array<number,number,number,?string>} array - An array holding the Euler component values.\n \t * @return {Euler} A reference to this Euler instance.\n \t */\n \tfromArray( array ) {\n\n \t\tthis._x = array[ 0 ];\n \t\tthis._y = array[ 1 ];\n \t\tthis._z = array[ 2 ];\n \t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n \t\tthis._onChangeCallback();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the components of this Euler instance to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number,number,number,string>} [array=[]] - The target array holding the Euler components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number,number,number,string>} The Euler components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this._x;\n \t\tarray[ offset + 1 ] = this._y;\n \t\tarray[ offset + 2 ] = this._z;\n \t\tarray[ offset + 3 ] = this._order;\n\n \t\treturn array;\n\n \t}\n\n \t_onChange( callback ) {\n\n \t\tthis._onChangeCallback = callback;\n\n \t\treturn this;\n\n \t}\n\n \t_onChangeCallback() {}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this._x;\n \t\tyield this._y;\n \t\tyield this._z;\n \t\tyield this._order;\n\n \t}\n\n }\n\n /**\n * The default Euler angle order.\n *\n * @static\n * @type {string}\n * @default 'XYZ'\n */\n Euler.DEFAULT_ORDER = 'XYZ';\n\n /**\n * A layers object assigns an 3D object to 1 or more of 32\n * layers numbered `0` to `31` - internally the layers are stored as a\n * bit mask], and by default all 3D objects are a member of layer `0`.\n *\n * This can be used to control visibility - an object must share a layer with\n * a camera to be visible when that camera's view is\n * rendered.\n *\n * All classes that inherit from {@link Object3D} have an `layers` property which\n * is an instance of this class.\n */\n class Layers {\n\n \t/**\n \t * Constructs a new layers instance, with membership\n \t * initially set to layer `0`.\n \t */\n \tconstructor() {\n\n \t\t/**\n \t\t * A bit mask storing which of the 32 layers this layers object is currently\n \t\t * a member of.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.mask = 1 | 0;\n\n \t}\n\n \t/**\n \t * Sets membership to the given layer, and remove membership all other layers.\n \t *\n \t * @param {number} layer - The layer to set.\n \t */\n \tset( layer ) {\n\n \t\tthis.mask = ( 1 << layer | 0 ) >>> 0;\n\n \t}\n\n \t/**\n \t * Adds membership of the given layer.\n \t *\n \t * @param {number} layer - The layer to enable.\n \t */\n \tenable( layer ) {\n\n \t\tthis.mask |= 1 << layer | 0;\n\n \t}\n\n \t/**\n \t * Adds membership to all layers.\n \t */\n \tenableAll() {\n\n \t\tthis.mask = 0xffffffff | 0;\n\n \t}\n\n \t/**\n \t * Toggles the membership of the given layer.\n \t *\n \t * @param {number} layer - The layer to toggle.\n \t */\n \ttoggle( layer ) {\n\n \t\tthis.mask ^= 1 << layer | 0;\n\n \t}\n\n \t/**\n \t * Removes membership of the given layer.\n \t *\n \t * @param {number} layer - The layer to enable.\n \t */\n \tdisable( layer ) {\n\n \t\tthis.mask &= ~ ( 1 << layer | 0 );\n\n \t}\n\n \t/**\n \t * Removes the membership from all layers.\n \t */\n \tdisableAll() {\n\n \t\tthis.mask = 0;\n\n \t}\n\n \t/**\n \t * Returns `true` if this and the given layers object have at least one\n \t * layer in common.\n \t *\n \t * @param {Layers} layers - The layers to test.\n \t * @return {boolean } Whether this and the given layers object have at least one layer in common or not.\n \t */\n \ttest( layers ) {\n\n \t\treturn ( this.mask & layers.mask ) !== 0;\n\n \t}\n\n \t/**\n \t * Returns `true` if the given layer is enabled.\n \t *\n \t * @param {number} layer - The layer to test.\n \t * @return {boolean } Whether the given layer is enabled or not.\n \t */\n \tisEnabled( layer ) {\n\n \t\treturn ( this.mask & ( 1 << layer | 0 ) ) !== 0;\n\n \t}\n\n }\n\n let _object3DId = 0;\n\n const _v1$6 = /*@__PURE__*/ new Vector3();\n const _q1 = /*@__PURE__*/ new Quaternion();\n const _m1$1 = /*@__PURE__*/ new Matrix4();\n const _target = /*@__PURE__*/ new Vector3();\n\n const _position$4 = /*@__PURE__*/ new Vector3();\n const _scale$3 = /*@__PURE__*/ new Vector3();\n const _quaternion$3 = /*@__PURE__*/ new Quaternion();\n\n const _xAxis = /*@__PURE__*/ new Vector3( 1, 0, 0 );\n const _yAxis = /*@__PURE__*/ new Vector3( 0, 1, 0 );\n const _zAxis = /*@__PURE__*/ new Vector3( 0, 0, 1 );\n\n /**\n * Fires when the object has been added to its parent object.\n *\n * @event Object3D#added\n * @type {Object}\n */\n const _addedEvent = { type: 'added' };\n\n /**\n * Fires when the object has been removed from its parent object.\n *\n * @event Object3D#removed\n * @type {Object}\n */\n const _removedEvent = { type: 'removed' };\n\n /**\n * Fires when a new child object has been added.\n *\n * @event Object3D#childadded\n * @type {Object}\n */\n const _childaddedEvent = { type: 'childadded', child: null };\n\n /**\n * Fires when a child object has been removed.\n *\n * @event Object3D#childremoved\n * @type {Object}\n */\n const _childremovedEvent = { type: 'childremoved', child: null };\n\n /**\n * This is the base class for most objects in three.js and provides a set of\n * properties and methods for manipulating objects in 3D space.\n *\n * @augments EventDispatcher\n */\n class Object3D extends EventDispatcher {\n\n \t/**\n \t * Constructs a new 3D object.\n \t */\n \tconstructor() {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isObject3D = true;\n\n \t\t/**\n \t\t * The ID of the 3D object.\n \t\t *\n \t\t * @name Object3D#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _object3DId ++ } );\n\n \t\t/**\n \t\t * The UUID of the 3D object.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.uuid = generateUUID();\n\n \t\t/**\n \t\t * The name of the 3D object.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.name = '';\n\n \t\t/**\n \t\t * The type property is used for detecting the object type\n \t\t * in context of serialization/deserialization.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.type = 'Object3D';\n\n \t\t/**\n \t\t * A reference to the parent object.\n \t\t *\n \t\t * @type {?Object3D}\n \t\t * @default null\n \t\t */\n \t\tthis.parent = null;\n\n \t\t/**\n \t\t * An array holding the child 3D objects of this instance.\n \t\t *\n \t\t * @type {Array<Object3D>}\n \t\t */\n \t\tthis.children = [];\n\n \t\t/**\n \t\t * Defines the `up` direction of the 3D object which influences\n \t\t * the orientation via methods like {@link Object3D#lookAt}.\n \t\t *\n \t\t * The default values for all 3D objects is defined by `Object3D.DEFAULT_UP`.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.up = Object3D.DEFAULT_UP.clone();\n\n \t\tconst position = new Vector3();\n \t\tconst rotation = new Euler();\n \t\tconst quaternion = new Quaternion();\n \t\tconst scale = new Vector3( 1, 1, 1 );\n\n \t\tfunction onRotationChange() {\n\n \t\t\tquaternion.setFromEuler( rotation, false );\n\n \t\t}\n\n \t\tfunction onQuaternionChange() {\n\n \t\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n \t\t}\n\n \t\trotation._onChange( onRotationChange );\n \t\tquaternion._onChange( onQuaternionChange );\n\n \t\tObject.defineProperties( this, {\n \t\t\t/**\n \t\t\t * Represents the object's local position.\n \t\t\t *\n \t\t\t * @name Object3D#position\n \t\t\t * @type {Vector3}\n \t\t\t * @default (0,0,0)\n \t\t\t */\n \t\t\tposition: {\n \t\t\t\tconfigurable: true,\n \t\t\t\tenumerable: true,\n \t\t\t\tvalue: position\n \t\t\t},\n \t\t\t/**\n \t\t\t * Represents the object's local rotation as Euler angles, in radians.\n \t\t\t *\n \t\t\t * @name Object3D#rotation\n \t\t\t * @type {Euler}\n \t\t\t * @default (0,0,0)\n \t\t\t */\n \t\t\trotation: {\n \t\t\t\tconfigurable: true,\n \t\t\t\tenumerable: true,\n \t\t\t\tvalue: rotation\n \t\t\t},\n \t\t\t/**\n \t\t\t * Represents the object's local rotation as Quaternions.\n \t\t\t *\n \t\t\t * @name Object3D#quaternion\n \t\t\t * @type {Quaternion}\n \t\t\t */\n \t\t\tquaternion: {\n \t\t\t\tconfigurable: true,\n \t\t\t\tenumerable: true,\n \t\t\t\tvalue: quaternion\n \t\t\t},\n \t\t\t/**\n \t\t\t * Represents the object's local scale.\n \t\t\t *\n \t\t\t * @name Object3D#scale\n \t\t\t * @type {Vector3}\n \t\t\t * @default (1,1,1)\n \t\t\t */\n \t\t\tscale: {\n \t\t\t\tconfigurable: true,\n \t\t\t\tenumerable: true,\n \t\t\t\tvalue: scale\n \t\t\t},\n \t\t\t/**\n \t\t\t * Represents the object's model-view matrix.\n \t\t\t *\n \t\t\t * @name Object3D#modelViewMatrix\n \t\t\t * @type {Matrix4}\n \t\t\t */\n \t\t\tmodelViewMatrix: {\n \t\t\t\tvalue: new Matrix4()\n \t\t\t},\n \t\t\t/**\n \t\t\t * Represents the object's normal matrix.\n \t\t\t *\n \t\t\t * @name Object3D#normalMatrix\n \t\t\t * @type {Matrix3}\n \t\t\t */\n \t\t\tnormalMatrix: {\n \t\t\t\tvalue: new Matrix3()\n \t\t\t}\n \t\t} );\n\n \t\t/**\n \t\t * Represents the object's transformation matrix in local space.\n \t\t *\n \t\t * @type {Matrix4}\n \t\t */\n \t\tthis.matrix = new Matrix4();\n\n \t\t/**\n \t\t * Represents the object's transformation matrix in world space.\n \t\t * If the 3D object has no parent, then it's identical to the local transformation matrix\n \t\t *\n \t\t * @type {Matrix4}\n \t\t */\n \t\tthis.matrixWorld = new Matrix4();\n\n \t\t/**\n \t\t * When set to `true`, the engine automatically computes the local matrix from position,\n \t\t * rotation and scale every frame. If set to `false`, the app is responsible for recomputing\n \t\t * the local matrix by calling `updateMatrix()`.\n \t\t *\n \t\t * The default values for all 3D objects is defined by `Object3D.DEFAULT_MATRIX_AUTO_UPDATE`.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.matrixAutoUpdate = Object3D.DEFAULT_MATRIX_AUTO_UPDATE;\n\n \t\t/**\n \t\t * When set to `true`, the engine automatically computes the world matrix from the current local\n \t\t * matrix and the object's transformation hierarchy. If set to `false`, the app is responsible for\n \t\t * recomputing the world matrix by directly updating the `matrixWorld` property.\n \t\t *\n \t\t * The default values for all 3D objects is defined by `Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE`.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.matrixWorldAutoUpdate = Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE; // checked by the renderer\n\n \t\t/**\n \t\t * When set to `true`, it calculates the world matrix in that frame and resets this property\n \t\t * to `false`.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.matrixWorldNeedsUpdate = false;\n\n \t\t/**\n \t\t * The layer membership of the 3D object. The 3D object is only visible if it has\n \t\t * at least one layer in common with the camera in use. This property can also be\n \t\t * used to filter out unwanted objects in ray-intersection tests when using {@link Raycaster}.\n \t\t *\n \t\t * @type {Layers}\n \t\t */\n \t\tthis.layers = new Layers();\n\n \t\t/**\n \t\t * When set to `true`, the 3D object gets rendered.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.visible = true;\n\n \t\t/**\n \t\t * When set to `true`, the 3D object gets rendered into shadow maps.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.castShadow = false;\n\n \t\t/**\n \t\t * When set to `true`, the 3D object is affected by shadows in the scene.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.receiveShadow = false;\n\n \t\t/**\n \t\t * When set to `true`, the 3D object is honored by view frustum culling.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.frustumCulled = true;\n\n \t\t/**\n \t\t * This value allows the default rendering order of scene graph objects to be\n \t\t * overridden although opaque and transparent objects remain sorted independently.\n \t\t * When this property is set for an instance of {@link Group},all descendants\n \t\t * objects will be sorted and rendered together. Sorting is from lowest to highest\n \t\t * render order.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.renderOrder = 0;\n\n \t\t/**\n \t\t * An array holding the animation clips of the 3D object.\n \t\t *\n \t\t * @type {Array<AnimationClip>}\n \t\t */\n \t\tthis.animations = [];\n\n \t\t/**\n \t\t * Custom depth material to be used when rendering to the depth map. Can only be used\n \t\t * in context of meshes. When shadow-casting with a {@link DirectionalLight} or {@link SpotLight},\n \t\t * if you are modifying vertex positions in the vertex shader you must specify a custom depth\n \t\t * material for proper shadows.\n \t\t *\n \t\t * Only relevant in context of {@link WebGLRenderer}.\n \t\t *\n \t\t * @type {(Material|undefined)}\n \t\t * @default undefined\n \t\t */\n \t\tthis.customDepthMaterial = undefined;\n\n \t\t/**\n \t\t * Same as {@link Object3D#customDepthMaterial}, but used with {@link PointLight}.\n \t\t *\n \t\t * Only relevant in context of {@link WebGLRenderer}.\n \t\t *\n \t\t * @type {(Material|undefined)}\n \t\t * @default undefined\n \t\t */\n \t\tthis.customDistanceMaterial = undefined;\n\n \t\t/**\n \t\t * Whether the 3D object is supposed to be static or not. If set to `true`, it means\n \t\t * the 3D object is not going to be changed after the initial renderer. This includes\n \t\t * geometry and material settings. A static 3D object can be processed by the renderer\n \t\t * slightly faster since certain state checks can be bypassed.\n \t\t *\n \t\t * Only relevant in context of {@link WebGPURenderer}.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.static = false;\n\n \t\t/**\n \t\t * An object that can be used to store custom data about the 3D object. It\n \t\t * should not hold references to functions as these will not be cloned.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.userData = {};\n\n \t\t/**\n \t\t * The pivot point for rotation and scale transformations.\n \t\t * When set, rotation and scale are applied around this point\n \t\t * instead of the object's origin.\n \t\t *\n \t\t * @type {?Vector3}\n \t\t * @default null\n \t\t */\n \t\tthis.pivot = null;\n\n \t}\n\n \t/**\n \t * A callback that is executed immediately before a 3D object is rendered to a shadow map.\n \t *\n \t * @param {Renderer|WebGLRenderer} renderer - The renderer.\n \t * @param {Object3D} object - The 3D object.\n \t * @param {Camera} camera - The camera that is used to render the scene.\n \t * @param {Camera} shadowCamera - The shadow camera.\n \t * @param {BufferGeometry} geometry - The 3D object's geometry.\n \t * @param {Material} depthMaterial - The depth material.\n \t * @param {Object} group - The geometry group data.\n \t */\n \tonBeforeShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}\n\n \t/**\n \t * A callback that is executed immediately after a 3D object is rendered to a shadow map.\n \t *\n \t * @param {Renderer|WebGLRenderer} renderer - The renderer.\n \t * @param {Object3D} object - The 3D object.\n \t * @param {Camera} camera - The camera that is used to render the scene.\n \t * @param {Camera} shadowCamera - The shadow camera.\n \t * @param {BufferGeometry} geometry - The 3D object's geometry.\n \t * @param {Material} depthMaterial - The depth material.\n \t * @param {Object} group - The geometry group data.\n \t */\n \tonAfterShadow( /* renderer, object, camera, shadowCamera, geometry, depthMaterial, group */ ) {}\n\n \t/**\n \t * A callback that is executed immediately before a 3D object is rendered.\n \t *\n \t * @param {Renderer|WebGLRenderer} renderer - The renderer.\n \t * @param {Object3D} object - The 3D object.\n \t * @param {Camera} camera - The camera that is used to render the scene.\n \t * @param {BufferGeometry} geometry - The 3D object's geometry.\n \t * @param {Material} material - The 3D object's material.\n \t * @param {Object} group - The geometry group data.\n \t */\n \tonBeforeRender( /* renderer, scene, camera, geometry, material, group */ ) {}\n\n \t/**\n \t * A callback that is executed immediately after a 3D object is rendered.\n \t *\n \t * @param {Renderer|WebGLRenderer} renderer - The renderer.\n \t * @param {Object3D} object - The 3D object.\n \t * @param {Camera} camera - The camera that is used to render the scene.\n \t * @param {BufferGeometry} geometry - The 3D object's geometry.\n \t * @param {Material} material - The 3D object's material.\n \t * @param {Object} group - The geometry group data.\n \t */\n \tonAfterRender( /* renderer, scene, camera, geometry, material, group */ ) {}\n\n \t/**\n \t * Applies the given transformation matrix to the object and updates the object's position,\n \t * rotation and scale.\n \t *\n \t * @param {Matrix4} matrix - The transformation matrix.\n \t */\n \tapplyMatrix4( matrix ) {\n\n \t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n \t\tthis.matrix.premultiply( matrix );\n\n \t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n \t}\n\n \t/**\n \t * Applies a rotation represented by given the quaternion to the 3D object.\n \t *\n \t * @param {Quaternion} q - The quaternion.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tapplyQuaternion( q ) {\n\n \t\tthis.quaternion.premultiply( q );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given rotation represented as an axis/angle couple to the 3D object.\n \t *\n \t * @param {Vector3} axis - The (normalized) axis vector.\n \t * @param {number} angle - The angle in radians.\n \t */\n \tsetRotationFromAxisAngle( axis, angle ) {\n\n \t\t// assumes axis is normalized\n\n \t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n \t}\n\n \t/**\n \t * Sets the given rotation represented as Euler angles to the 3D object.\n \t *\n \t * @param {Euler} euler - The Euler angles.\n \t */\n \tsetRotationFromEuler( euler ) {\n\n \t\tthis.quaternion.setFromEuler( euler, true );\n\n \t}\n\n \t/**\n \t * Sets the given rotation represented as rotation matrix to the 3D object.\n \t *\n \t * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be\n \t * a pure rotation matrix (i.e, unscaled).\n \t */\n \tsetRotationFromMatrix( m ) {\n\n \t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n \t\tthis.quaternion.setFromRotationMatrix( m );\n\n \t}\n\n \t/**\n \t * Sets the given rotation represented as a Quaternion to the 3D object.\n \t *\n \t * @param {Quaternion} q - The Quaternion\n \t */\n \tsetRotationFromQuaternion( q ) {\n\n \t\t// assumes q is normalized\n\n \t\tthis.quaternion.copy( q );\n\n \t}\n\n \t/**\n \t * Rotates the 3D object along an axis in local space.\n \t *\n \t * @param {Vector3} axis - The (normalized) axis vector.\n \t * @param {number} angle - The angle in radians.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \trotateOnAxis( axis, angle ) {\n\n \t\t// rotate object on axis in object space\n \t\t// axis is assumed to be normalized\n\n \t\t_q1.setFromAxisAngle( axis, angle );\n\n \t\tthis.quaternion.multiply( _q1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the 3D object along an axis in world space.\n \t *\n \t * @param {Vector3} axis - The (normalized) axis vector.\n \t * @param {number} angle - The angle in radians.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \trotateOnWorldAxis( axis, angle ) {\n\n \t\t// rotate object on axis in world space\n \t\t// axis is assumed to be normalized\n \t\t// method assumes no rotated parent\n\n \t\t_q1.setFromAxisAngle( axis, angle );\n\n \t\tthis.quaternion.premultiply( _q1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the 3D object around its X axis in local space.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \trotateX( angle ) {\n\n \t\treturn this.rotateOnAxis( _xAxis, angle );\n\n \t}\n\n \t/**\n \t * Rotates the 3D object around its Y axis in local space.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \trotateY( angle ) {\n\n \t\treturn this.rotateOnAxis( _yAxis, angle );\n\n \t}\n\n \t/**\n \t * Rotates the 3D object around its Z axis in local space.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \trotateZ( angle ) {\n\n \t\treturn this.rotateOnAxis( _zAxis, angle );\n\n \t}\n\n \t/**\n \t * Translate the 3D object by a distance along the given axis in local space.\n \t *\n \t * @param {Vector3} axis - The (normalized) axis vector.\n \t * @param {number} distance - The distance in world units.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \ttranslateOnAxis( axis, distance ) {\n\n \t\t// translate object by distance along axis in object space\n \t\t// axis is assumed to be normalized\n\n \t\t_v1$6.copy( axis ).applyQuaternion( this.quaternion );\n\n \t\tthis.position.add( _v1$6.multiplyScalar( distance ) );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Translate the 3D object by a distance along its X-axis in local space.\n \t *\n \t * @param {number} distance - The distance in world units.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \ttranslateX( distance ) {\n\n \t\treturn this.translateOnAxis( _xAxis, distance );\n\n \t}\n\n \t/**\n \t * Translate the 3D object by a distance along its Y-axis in local space.\n \t *\n \t * @param {number} distance - The distance in world units.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \ttranslateY( distance ) {\n\n \t\treturn this.translateOnAxis( _yAxis, distance );\n\n \t}\n\n \t/**\n \t * Translate the 3D object by a distance along its Z-axis in local space.\n \t *\n \t * @param {number} distance - The distance in world units.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \ttranslateZ( distance ) {\n\n \t\treturn this.translateOnAxis( _zAxis, distance );\n\n \t}\n\n \t/**\n \t * Converts the given vector from this 3D object's local space to world space.\n \t *\n \t * @param {Vector3} vector - The vector to convert.\n \t * @return {Vector3} The converted vector.\n \t */\n \tlocalToWorld( vector ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\treturn vector.applyMatrix4( this.matrixWorld );\n\n \t}\n\n \t/**\n \t * Converts the given vector from this 3D object's world space to local space.\n \t *\n \t * @param {Vector3} vector - The vector to convert.\n \t * @return {Vector3} The converted vector.\n \t */\n \tworldToLocal( vector ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\treturn vector.applyMatrix4( _m1$1.copy( this.matrixWorld ).invert() );\n\n \t}\n\n \t/**\n \t * Rotates the object to face a point in world space.\n \t *\n \t * This method does not support objects having non-uniformly-scaled parent(s).\n \t *\n \t * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space\n \t * @param {number} [y] - The y coordinate in world space.\n \t * @param {number} [z] - The z coordinate in world space.\n \t */\n \tlookAt( x, y, z ) {\n\n \t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n \t\tif ( x.isVector3 ) {\n\n \t\t\t_target.copy( x );\n\n \t\t} else {\n\n \t\t\t_target.set( x, y, z );\n\n \t\t}\n\n \t\tconst parent = this.parent;\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\t_position$4.setFromMatrixPosition( this.matrixWorld );\n\n \t\tif ( this.isCamera || this.isLight ) {\n\n \t\t\t_m1$1.lookAt( _position$4, _target, this.up );\n\n \t\t} else {\n\n \t\t\t_m1$1.lookAt( _target, _position$4, this.up );\n\n \t\t}\n\n \t\tthis.quaternion.setFromRotationMatrix( _m1$1 );\n\n \t\tif ( parent ) {\n\n \t\t\t_m1$1.extractRotation( parent.matrixWorld );\n \t\t\t_q1.setFromRotationMatrix( _m1$1 );\n \t\t\tthis.quaternion.premultiply( _q1.invert() );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Adds the given 3D object as a child to this 3D object. An arbitrary number of\n \t * objects may be added. Any current parent on an object passed in here will be\n \t * removed, since an object can have at most one parent.\n \t *\n \t * @fires Object3D#added\n \t * @fires Object3D#childadded\n \t * @param {Object3D} object - The 3D object to add.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tadd( object ) {\n\n \t\tif ( arguments.length > 1 ) {\n\n \t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n \t\t\t\tthis.add( arguments[ i ] );\n\n \t\t\t}\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\tif ( object === this ) {\n\n \t\t\terror( 'Object3D.add: object can\\'t be added as a child of itself.', object );\n \t\t\treturn this;\n\n \t\t}\n\n \t\tif ( object && object.isObject3D ) {\n\n \t\t\tobject.removeFromParent();\n \t\t\tobject.parent = this;\n \t\t\tthis.children.push( object );\n\n \t\t\tobject.dispatchEvent( _addedEvent );\n\n \t\t\t_childaddedEvent.child = object;\n \t\t\tthis.dispatchEvent( _childaddedEvent );\n \t\t\t_childaddedEvent.child = null;\n\n \t\t} else {\n\n \t\t\terror( 'Object3D.add: object not an instance of THREE.Object3D.', object );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Removes the given 3D object as child from this 3D object.\n \t * An arbitrary number of objects may be removed.\n \t *\n \t * @fires Object3D#removed\n \t * @fires Object3D#childremoved\n \t * @param {Object3D} object - The 3D object to remove.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tremove( object ) {\n\n \t\tif ( arguments.length > 1 ) {\n\n \t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n \t\t\t\tthis.remove( arguments[ i ] );\n\n \t\t\t}\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\tconst index = this.children.indexOf( object );\n\n \t\tif ( index !== -1 ) {\n\n \t\t\tobject.parent = null;\n \t\t\tthis.children.splice( index, 1 );\n\n \t\t\tobject.dispatchEvent( _removedEvent );\n\n \t\t\t_childremovedEvent.child = object;\n \t\t\tthis.dispatchEvent( _childremovedEvent );\n \t\t\t_childremovedEvent.child = null;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Removes this 3D object from its current parent.\n \t *\n \t * @fires Object3D#removed\n \t * @fires Object3D#childremoved\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tremoveFromParent() {\n\n \t\tconst parent = this.parent;\n\n \t\tif ( parent !== null ) {\n\n \t\t\tparent.remove( this );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Removes all child objects.\n \t *\n \t * @fires Object3D#removed\n \t * @fires Object3D#childremoved\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tclear() {\n\n \t\treturn this.remove( ... this.children );\n\n \t}\n\n \t/**\n \t * Adds the given 3D object as a child of this 3D object, while maintaining the object's world\n \t * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).\n \t *\n \t * @fires Object3D#added\n \t * @fires Object3D#childadded\n \t * @param {Object3D} object - The 3D object to attach.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tattach( object ) {\n\n \t\t// adds object as a child of this, while maintaining the object's world transform\n\n \t\t// Note: This method does not support scene graphs having non-uniformly-scaled nodes(s)\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\t_m1$1.copy( this.matrixWorld ).invert();\n\n \t\tif ( object.parent !== null ) {\n\n \t\t\tobject.parent.updateWorldMatrix( true, false );\n\n \t\t\t_m1$1.multiply( object.parent.matrixWorld );\n\n \t\t}\n\n \t\tobject.applyMatrix4( _m1$1 );\n\n \t\tobject.removeFromParent();\n \t\tobject.parent = this;\n \t\tthis.children.push( object );\n\n \t\tobject.updateWorldMatrix( false, true );\n\n \t\tobject.dispatchEvent( _addedEvent );\n\n \t\t_childaddedEvent.child = object;\n \t\tthis.dispatchEvent( _childaddedEvent );\n \t\t_childaddedEvent.child = null;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Searches through the 3D object and its children, starting with the 3D object\n \t * itself, and returns the first with a matching ID.\n \t *\n \t * @param {number} id - The id.\n \t * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n \t */\n \tgetObjectById( id ) {\n\n \t\treturn this.getObjectByProperty( 'id', id );\n\n \t}\n\n \t/**\n \t * Searches through the 3D object and its children, starting with the 3D object\n \t * itself, and returns the first with a matching name.\n \t *\n \t * @param {string} name - The name.\n \t * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n \t */\n \tgetObjectByName( name ) {\n\n \t\treturn this.getObjectByProperty( 'name', name );\n\n \t}\n\n \t/**\n \t * Searches through the 3D object and its children, starting with the 3D object\n \t * itself, and returns the first with a matching property value.\n \t *\n \t * @param {string} name - The name of the property.\n \t * @param {any} value - The value.\n \t * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.\n \t */\n \tgetObjectByProperty( name, value ) {\n\n \t\tif ( this[ name ] === value ) return this;\n\n \t\tfor ( let i = 0, l = this.children.length; i < l; i ++ ) {\n\n \t\t\tconst child = this.children[ i ];\n \t\t\tconst object = child.getObjectByProperty( name, value );\n\n \t\t\tif ( object !== undefined ) {\n\n \t\t\t\treturn object;\n\n \t\t\t}\n\n \t\t}\n\n \t\treturn undefined;\n\n \t}\n\n \t/**\n \t * Searches through the 3D object and its children, starting with the 3D object\n \t * itself, and returns all 3D objects with a matching property value.\n \t *\n \t * @param {string} name - The name of the property.\n \t * @param {any} value - The value.\n \t * @param {Array<Object3D>} result - The method stores the result in this array.\n \t * @return {Array<Object3D>} The found 3D objects.\n \t */\n \tgetObjectsByProperty( name, value, result = [] ) {\n\n \t\tif ( this[ name ] === value ) result.push( this );\n\n \t\tconst children = this.children;\n\n \t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\tchildren[ i ].getObjectsByProperty( name, value, result );\n\n \t\t}\n\n \t\treturn result;\n\n \t}\n\n \t/**\n \t * Returns a vector representing the position of the 3D object in world space.\n \t *\n \t * @param {Vector3} target - The target vector the result is stored to.\n \t * @return {Vector3} The 3D object's position in world space.\n \t */\n \tgetWorldPosition( target ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n \t}\n\n \t/**\n \t * Returns a Quaternion representing the position of the 3D object in world space.\n \t *\n \t * @param {Quaternion} target - The target Quaternion the result is stored to.\n \t * @return {Quaternion} The 3D object's rotation in world space.\n \t */\n \tgetWorldQuaternion( target ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\tthis.matrixWorld.decompose( _position$4, target, _scale$3 );\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns a vector representing the scale of the 3D object in world space.\n \t *\n \t * @param {Vector3} target - The target vector the result is stored to.\n \t * @return {Vector3} The 3D object's scale in world space.\n \t */\n \tgetWorldScale( target ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\tthis.matrixWorld.decompose( _position$4, _quaternion$3, target );\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns a vector representing the (\"look\") direction of the 3D object in world space.\n \t *\n \t * @param {Vector3} target - The target vector the result is stored to.\n \t * @return {Vector3} The 3D object's direction in world space.\n \t */\n \tgetWorldDirection( target ) {\n\n \t\tthis.updateWorldMatrix( true, false );\n\n \t\tconst e = this.matrixWorld.elements;\n\n \t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n \t}\n\n \t/**\n \t * Abstract method to get intersections between a casted ray and this\n \t * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}\n \t * implement this method in order to use raycasting.\n \t *\n \t * @abstract\n \t * @param {Raycaster} raycaster - The raycaster.\n \t * @param {Array<Object>} intersects - An array holding the result of the method.\n \t */\n \traycast( /* raycaster, intersects */ ) {}\n\n \t/**\n \t * Executes the callback on this 3D object and all descendants.\n \t *\n \t * Note: Modifying the scene graph inside the callback is discouraged.\n \t *\n \t * @param {Function} callback - A callback function that allows to process the current 3D object.\n \t */\n \ttraverse( callback ) {\n\n \t\tcallback( this );\n\n \t\tconst children = this.children;\n\n \t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\tchildren[ i ].traverse( callback );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Like {@link Object3D#traverse}, but the callback will only be executed for visible 3D objects.\n \t * Descendants of invisible 3D objects are not traversed.\n \t *\n \t * Note: Modifying the scene graph inside the callback is discouraged.\n \t *\n \t * @param {Function} callback - A callback function that allows to process the current 3D object.\n \t */\n \ttraverseVisible( callback ) {\n\n \t\tif ( this.visible === false ) return;\n\n \t\tcallback( this );\n\n \t\tconst children = this.children;\n\n \t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\tchildren[ i ].traverseVisible( callback );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Like {@link Object3D#traverse}, but the callback will only be executed for all ancestors.\n \t *\n \t * Note: Modifying the scene graph inside the callback is discouraged.\n \t *\n \t * @param {Function} callback - A callback function that allows to process the current 3D object.\n \t */\n \ttraverseAncestors( callback ) {\n\n \t\tconst parent = this.parent;\n\n \t\tif ( parent !== null ) {\n\n \t\t\tcallback( parent );\n\n \t\t\tparent.traverseAncestors( callback );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Updates the transformation matrix in local space by computing it from the current\n \t * position, rotation and scale values.\n \t */\n \tupdateMatrix() {\n\n \t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n \t\tconst pivot = this.pivot;\n\n \t\tif ( pivot !== null ) {\n\n \t\t\tconst px = pivot.x, py = pivot.y, pz = pivot.z;\n \t\t\tconst te = this.matrix.elements;\n\n \t\t\tte[ 12 ] += px - te[ 0 ] * px - te[ 4 ] * py - te[ 8 ] * pz;\n \t\t\tte[ 13 ] += py - te[ 1 ] * px - te[ 5 ] * py - te[ 9 ] * pz;\n \t\t\tte[ 14 ] += pz - te[ 2 ] * px - te[ 6 ] * py - te[ 10 ] * pz;\n\n \t\t}\n\n \t\tthis.matrixWorldNeedsUpdate = true;\n\n \t}\n\n \t/**\n \t * Updates the transformation matrix in world space of this 3D objects and its descendants.\n \t *\n \t * To ensure correct results, this method also recomputes the 3D object's transformation matrix in\n \t * local space. The computation of the local and world matrix can be controlled with the\n \t * {@link Object3D#matrixAutoUpdate} and {@link Object3D#matrixWorldAutoUpdate} flags which are both\n \t * `true` by default. Set these flags to `false` if you need more control over the update matrix process.\n \t *\n \t * @param {boolean} [force=false] - When set to `true`, a recomputation of world matrices is forced even\n \t * when {@link Object3D#matrixWorldNeedsUpdate} is `false`.\n \t */\n \tupdateMatrixWorld( force ) {\n\n \t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n \t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n \t\t\tif ( this.matrixWorldAutoUpdate === true ) {\n\n \t\t\t\tif ( this.parent === null ) {\n\n \t\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tthis.matrixWorldNeedsUpdate = false;\n\n \t\t\tforce = true;\n\n \t\t}\n\n \t\t// make sure descendants are updated if required\n\n \t\tconst children = this.children;\n\n \t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\tconst child = children[ i ];\n\n \t\t\tchild.updateMatrixWorld( force );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * An alternative version of {@link Object3D#updateMatrixWorld} with more control over the\n \t * update of ancestor and descendant nodes.\n \t *\n \t * @param {boolean} [updateParents=false] Whether ancestor nodes should be updated or not.\n \t * @param {boolean} [updateChildren=false] Whether descendant nodes should be updated or not.\n \t * @param {boolean} [force=false] - When set to `true`, a recomputation of world matrices is forced even\n \t * when {@link Object3D#matrixWorldNeedsUpdate} is `false`.\n \t */\n \tupdateWorldMatrix( updateParents, updateChildren, force = false ) {\n\n \t\tconst parent = this.parent;\n\n \t\tif ( updateParents === true && parent !== null ) {\n\n \t\t\tparent.updateWorldMatrix( true, false );\n\n \t\t}\n\n \t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n \t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n \t\t\tif ( this.matrixWorldAutoUpdate === true ) {\n\n \t\t\t\tif ( this.parent === null ) {\n\n \t\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tthis.matrixWorldNeedsUpdate = false;\n\n \t\t\tforce = true;\n\n \t\t}\n\n \t\t// make sure descendants are updated\n\n \t\tif ( updateChildren === true ) {\n\n \t\t\tconst children = this.children;\n\n \t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\t\tconst child = children[ i ];\n\n \t\t\t\tchild.updateWorldMatrix( false, true, force );\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Serializes the 3D object into JSON.\n \t *\n \t * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n \t * @return {Object} A JSON object representing the serialized 3D object.\n \t * @see {@link ObjectLoader#parse}\n \t */\n \ttoJSON( meta ) {\n\n \t\t// meta is a string when called from JSON.stringify\n \t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n \t\tconst output = {};\n\n \t\t// meta is a hash used to collect geometries, materials.\n \t\t// not providing it implies that this is the root object\n \t\t// being serialized.\n \t\tif ( isRootObject ) {\n\n \t\t\t// initialize meta obj\n \t\t\tmeta = {\n \t\t\t\tgeometries: {},\n \t\t\t\tmaterials: {},\n \t\t\t\ttextures: {},\n \t\t\t\timages: {},\n \t\t\t\tshapes: {},\n \t\t\t\tskeletons: {},\n \t\t\t\tanimations: {},\n \t\t\t\tnodes: {}\n \t\t\t};\n\n \t\t\toutput.metadata = {\n \t\t\t\tversion: 4.7,\n \t\t\t\ttype: 'Object',\n \t\t\t\tgenerator: 'Object3D.toJSON'\n \t\t\t};\n\n \t\t}\n\n \t\t// standard Object3D serialization\n\n \t\tconst object = {};\n\n \t\tobject.uuid = this.uuid;\n \t\tobject.type = this.type;\n\n \t\tif ( this.name !== '' ) object.name = this.name;\n \t\tif ( this.castShadow === true ) object.castShadow = true;\n \t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n \t\tif ( this.visible === false ) object.visible = false;\n \t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n \t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n \t\tif ( this.static !== false ) object.static = this.static;\n \t\tif ( Object.keys( this.userData ).length > 0 ) object.userData = this.userData;\n\n \t\tobject.layers = this.layers.mask;\n \t\tobject.matrix = this.matrix.toArray();\n \t\tobject.up = this.up.toArray();\n\n \t\tif ( this.pivot !== null ) object.pivot = this.pivot.toArray();\n\n \t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n \t\tif ( this.morphTargetDictionary !== undefined ) object.morphTargetDictionary = Object.assign( {}, this.morphTargetDictionary );\n \t\tif ( this.morphTargetInfluences !== undefined ) object.morphTargetInfluences = this.morphTargetInfluences.slice();\n\n \t\t// object specific properties\n\n \t\tif ( this.isInstancedMesh ) {\n\n \t\t\tobject.type = 'InstancedMesh';\n \t\t\tobject.count = this.count;\n \t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n \t\t\tif ( this.instanceColor !== null ) object.instanceColor = this.instanceColor.toJSON();\n\n \t\t}\n\n \t\tif ( this.isBatchedMesh ) {\n\n \t\t\tobject.type = 'BatchedMesh';\n \t\t\tobject.perObjectFrustumCulled = this.perObjectFrustumCulled;\n \t\t\tobject.sortObjects = this.sortObjects;\n\n \t\t\tobject.drawRanges = this._drawRanges;\n \t\t\tobject.reservedRanges = this._reservedRanges;\n\n \t\t\tobject.geometryInfo = this._geometryInfo.map( info => ( {\n \t\t\t\t...info,\n \t\t\t\tboundingBox: info.boundingBox ? info.boundingBox.toJSON() : undefined,\n \t\t\t\tboundingSphere: info.boundingSphere ? info.boundingSphere.toJSON() : undefined\n \t\t\t} ) );\n \t\t\tobject.instanceInfo = this._instanceInfo.map( info => ( { ...info } ) );\n\n \t\t\tobject.availableInstanceIds = this._availableInstanceIds.slice();\n \t\t\tobject.availableGeometryIds = this._availableGeometryIds.slice();\n\n \t\t\tobject.nextIndexStart = this._nextIndexStart;\n \t\t\tobject.nextVertexStart = this._nextVertexStart;\n \t\t\tobject.geometryCount = this._geometryCount;\n\n \t\t\tobject.maxInstanceCount = this._maxInstanceCount;\n \t\t\tobject.maxVertexCount = this._maxVertexCount;\n \t\t\tobject.maxIndexCount = this._maxIndexCount;\n\n \t\t\tobject.geometryInitialized = this._geometryInitialized;\n\n \t\t\tobject.matricesTexture = this._matricesTexture.toJSON( meta );\n\n \t\t\tobject.indirectTexture = this._indirectTexture.toJSON( meta );\n\n \t\t\tif ( this._colorsTexture !== null ) {\n\n \t\t\t\tobject.colorsTexture = this._colorsTexture.toJSON( meta );\n\n \t\t\t}\n\n \t\t\tif ( this.boundingSphere !== null ) {\n\n \t\t\t\tobject.boundingSphere = this.boundingSphere.toJSON();\n\n \t\t\t}\n\n \t\t\tif ( this.boundingBox !== null ) {\n\n \t\t\t\tobject.boundingBox = this.boundingBox.toJSON();\n\n \t\t\t}\n\n \t\t}\n\n \t\t//\n\n \t\tfunction serialize( library, element ) {\n\n \t\t\tif ( library[ element.uuid ] === undefined ) {\n\n \t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n \t\t\t}\n\n \t\t\treturn element.uuid;\n\n \t\t}\n\n \t\tif ( this.isScene ) {\n\n \t\t\tif ( this.background ) {\n\n \t\t\t\tif ( this.background.isColor ) {\n\n \t\t\t\t\tobject.background = this.background.toJSON();\n\n \t\t\t\t} else if ( this.background.isTexture ) {\n\n \t\t\t\t\tobject.background = this.background.toJSON( meta ).uuid;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tif ( this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== true ) {\n\n \t\t\t\tobject.environment = this.environment.toJSON( meta ).uuid;\n\n \t\t\t}\n\n \t\t} else if ( this.isMesh || this.isLine || this.isPoints ) {\n\n \t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n \t\t\tconst parameters = this.geometry.parameters;\n\n \t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n \t\t\t\tconst shapes = parameters.shapes;\n\n \t\t\t\tif ( Array.isArray( shapes ) ) {\n\n \t\t\t\t\tfor ( let i = 0, l = shapes.length; i < l; i ++ ) {\n\n \t\t\t\t\t\tconst shape = shapes[ i ];\n\n \t\t\t\t\t\tserialize( meta.shapes, shape );\n\n \t\t\t\t\t}\n\n \t\t\t\t} else {\n\n \t\t\t\t\tserialize( meta.shapes, shapes );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( this.isSkinnedMesh ) {\n\n \t\t\tobject.bindMode = this.bindMode;\n \t\t\tobject.bindMatrix = this.bindMatrix.toArray();\n\n \t\t\tif ( this.skeleton !== undefined ) {\n\n \t\t\t\tserialize( meta.skeletons, this.skeleton );\n\n \t\t\t\tobject.skeleton = this.skeleton.uuid;\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( this.material !== undefined ) {\n\n \t\t\tif ( Array.isArray( this.material ) ) {\n\n \t\t\t\tconst uuids = [];\n\n \t\t\t\tfor ( let i = 0, l = this.material.length; i < l; i ++ ) {\n\n \t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n \t\t\t\t}\n\n \t\t\t\tobject.material = uuids;\n\n \t\t\t} else {\n\n \t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n \t\t\t}\n\n \t\t}\n\n \t\t//\n\n \t\tif ( this.children.length > 0 ) {\n\n \t\t\tobject.children = [];\n\n \t\t\tfor ( let i = 0; i < this.children.length; i ++ ) {\n\n \t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n \t\t\t}\n\n \t\t}\n\n \t\t//\n\n \t\tif ( this.animations.length > 0 ) {\n\n \t\t\tobject.animations = [];\n\n \t\t\tfor ( let i = 0; i < this.animations.length; i ++ ) {\n\n \t\t\t\tconst animation = this.animations[ i ];\n\n \t\t\t\tobject.animations.push( serialize( meta.animations, animation ) );\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( isRootObject ) {\n\n \t\t\tconst geometries = extractFromCache( meta.geometries );\n \t\t\tconst materials = extractFromCache( meta.materials );\n \t\t\tconst textures = extractFromCache( meta.textures );\n \t\t\tconst images = extractFromCache( meta.images );\n \t\t\tconst shapes = extractFromCache( meta.shapes );\n \t\t\tconst skeletons = extractFromCache( meta.skeletons );\n \t\t\tconst animations = extractFromCache( meta.animations );\n \t\t\tconst nodes = extractFromCache( meta.nodes );\n\n \t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n \t\t\tif ( materials.length > 0 ) output.materials = materials;\n \t\t\tif ( textures.length > 0 ) output.textures = textures;\n \t\t\tif ( images.length > 0 ) output.images = images;\n \t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n \t\t\tif ( skeletons.length > 0 ) output.skeletons = skeletons;\n \t\t\tif ( animations.length > 0 ) output.animations = animations;\n \t\t\tif ( nodes.length > 0 ) output.nodes = nodes;\n\n \t\t}\n\n \t\toutput.object = object;\n\n \t\treturn output;\n\n \t\t// extract data from the cache hash\n \t\t// remove metadata on each item\n \t\t// and return as array\n \t\tfunction extractFromCache( cache ) {\n\n \t\t\tconst values = [];\n \t\t\tfor ( const key in cache ) {\n\n \t\t\t\tconst data = cache[ key ];\n \t\t\t\tdelete data.metadata;\n \t\t\t\tvalues.push( data );\n\n \t\t\t}\n\n \t\t\treturn values;\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns a new 3D object with copied values from this instance.\n \t *\n \t * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are also cloned.\n \t * @return {Object3D} A clone of this instance.\n \t */\n \tclone( recursive ) {\n\n \t\treturn new this.constructor().copy( this, recursive );\n\n \t}\n\n \t/**\n \t * Copies the values of the given 3D object to this instance.\n \t *\n \t * @param {Object3D} source - The 3D object to copy.\n \t * @param {boolean} [recursive=true] - When set to `true`, descendants of the 3D object are cloned.\n \t * @return {Object3D} A reference to this instance.\n \t */\n \tcopy( source, recursive = true ) {\n\n \t\tthis.name = source.name;\n\n \t\tthis.up.copy( source.up );\n\n \t\tthis.position.copy( source.position );\n \t\tthis.rotation.order = source.rotation.order;\n \t\tthis.quaternion.copy( source.quaternion );\n \t\tthis.scale.copy( source.scale );\n\n \t\tthis.pivot = ( source.pivot !== null ) ? source.pivot.clone() : null;\n\n \t\tthis.matrix.copy( source.matrix );\n \t\tthis.matrixWorld.copy( source.matrixWorld );\n\n \t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n \t\tthis.matrixWorldAutoUpdate = source.matrixWorldAutoUpdate;\n \t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n \t\tthis.layers.mask = source.layers.mask;\n \t\tthis.visible = source.visible;\n\n \t\tthis.castShadow = source.castShadow;\n \t\tthis.receiveShadow = source.receiveShadow;\n\n \t\tthis.frustumCulled = source.frustumCulled;\n \t\tthis.renderOrder = source.renderOrder;\n\n \t\tthis.static = source.static;\n\n \t\tthis.animations = source.animations.slice();\n\n \t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n \t\tif ( recursive === true ) {\n\n \t\t\tfor ( let i = 0; i < source.children.length; i ++ ) {\n\n \t\t\t\tconst child = source.children[ i ];\n \t\t\t\tthis.add( child.clone() );\n\n \t\t\t}\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n }\n\n /**\n * The default up direction for objects, also used as the default\n * position for {@link DirectionalLight} and {@link HemisphereLight}.\n *\n * @static\n * @type {Vector3}\n * @default (0,1,0)\n */\n Object3D.DEFAULT_UP = /*@__PURE__*/ new Vector3( 0, 1, 0 );\n\n /**\n * The default setting for {@link Object3D#matrixAutoUpdate} for\n * newly created 3D objects.\n *\n * @static\n * @type {boolean}\n * @default true\n */\n Object3D.DEFAULT_MATRIX_AUTO_UPDATE = true;\n\n /**\n * The default setting for {@link Object3D#matrixWorldAutoUpdate} for\n * newly created 3D objects.\n *\n * @static\n * @type {boolean}\n * @default true\n */\n Object3D.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = true;\n\n const _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n \t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n \t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n \t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n \t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n \t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n \t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n \t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n \t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n \t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n \t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n \t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n \t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n \t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n \t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n \t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n \t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n \t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n \t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n \t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n \t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n \t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n \t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n \t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\n const _hslA = { h: 0, s: 0, l: 0 };\n const _hslB = { h: 0, s: 0, l: 0 };\n\n function hue2rgb( p, q, t ) {\n\n \tif ( t < 0 ) t += 1;\n \tif ( t > 1 ) t -= 1;\n \tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n \tif ( t < 1 / 2 ) return q;\n \tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n \treturn p;\n\n }\n\n /**\n * A Color instance is represented by RGB components in the linear <i>working\n * color space</i>, which defaults to `LinearSRGBColorSpace`. Inputs\n * conventionally using `SRGBColorSpace` (such as hexadecimals and CSS\n * strings) are converted to the working color space automatically.\n *\n * ```js\n * // converted automatically from SRGBColorSpace to LinearSRGBColorSpace\n * const color = new THREE.Color().setHex( 0x112233 );\n * ```\n * Source color spaces may be specified explicitly, to ensure correct conversions.\n * ```js\n * // assumed already LinearSRGBColorSpace; no conversion\n * const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5 );\n *\n * // converted explicitly from SRGBColorSpace to LinearSRGBColorSpace\n * const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5, SRGBColorSpace );\n * ```\n * If THREE.ColorManagement is disabled, no conversions occur. For details,\n * see <i>Color management</i>. Iterating through a Color instance will yield\n * its components (r, g, b) in the corresponding order. A Color can be initialised\n * in any of the following ways:\n * ```js\n * //empty constructor - will default white\n * const color1 = new THREE.Color();\n *\n * //Hexadecimal color (recommended)\n * const color2 = new THREE.Color( 0xff0000 );\n *\n * //RGB string\n * const color3 = new THREE.Color(\"rgb(255, 0, 0)\");\n * const color4 = new THREE.Color(\"rgb(100%, 0%, 0%)\");\n *\n * //X11 color name - all 140 color names are supported.\n * //Note the lack of CamelCase in the name\n * const color5 = new THREE.Color( 'skyblue' );\n * //HSL string\n * const color6 = new THREE.Color(\"hsl(0, 100%, 50%)\");\n *\n * //Separate RGB values between 0 and 1\n * const color7 = new THREE.Color( 1, 0, 0 );\n * ```\n */\n class Color {\n\n \t/**\n \t * Constructs a new color.\n \t *\n \t * Note that standard method of specifying color in three.js is with a hexadecimal triplet,\n \t * and that method is used throughout the rest of the documentation.\n \t *\n \t * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are\n \t * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.\n \t * @param {number} [g] - The green component.\n \t * @param {number} [b] - The blue component.\n \t */\n \tconstructor( r, g, b ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isColor = true;\n\n \t\t/**\n \t\t * The red component.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.r = 1;\n\n \t\t/**\n \t\t * The green component.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.g = 1;\n\n \t\t/**\n \t\t * The blue component.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.b = 1;\n\n \t\treturn this.set( r, g, b );\n\n \t}\n\n \t/**\n \t * Sets the colors's components from the given values.\n \t *\n \t * @param {(number|string|Color)} [r] - The red component of the color. If `g` and `b` are\n \t * not provided, it can be hexadecimal triplet, a CSS-style string or another `Color` instance.\n \t * @param {number} [g] - The green component.\n \t * @param {number} [b] - The blue component.\n \t * @return {Color} A reference to this color.\n \t */\n \tset( r, g, b ) {\n\n \t\tif ( g === undefined && b === undefined ) {\n\n \t\t\t// r is THREE.Color, hex or string\n\n \t\t\tconst value = r;\n\n \t\t\tif ( value && value.isColor ) {\n\n \t\t\t\tthis.copy( value );\n\n \t\t\t} else if ( typeof value === 'number' ) {\n\n \t\t\t\tthis.setHex( value );\n\n \t\t\t} else if ( typeof value === 'string' ) {\n\n \t\t\t\tthis.setStyle( value );\n\n \t\t\t}\n\n \t\t} else {\n\n \t\t\tthis.setRGB( r, g, b );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the colors's components to the given scalar value.\n \t *\n \t * @param {number} scalar - The scalar value.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetScalar( scalar ) {\n\n \t\tthis.r = scalar;\n \t\tthis.g = scalar;\n \t\tthis.b = scalar;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this color from a hexadecimal value.\n \t *\n \t * @param {number} hex - The hexadecimal value.\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetHex( hex, colorSpace = SRGBColorSpace ) {\n\n \t\thex = Math.floor( hex );\n\n \t\tthis.r = ( hex >> 16 & 255 ) / 255;\n \t\tthis.g = ( hex >> 8 & 255 ) / 255;\n \t\tthis.b = ( hex & 255 ) / 255;\n\n \t\tColorManagement.colorSpaceToWorking( this, colorSpace );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this color from RGB values.\n \t *\n \t * @param {number} r - Red channel value between `0.0` and `1.0`.\n \t * @param {number} g - Green channel value between `0.0` and `1.0`.\n \t * @param {number} b - Blue channel value between `0.0` and `1.0`.\n \t * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetRGB( r, g, b, colorSpace = ColorManagement.workingColorSpace ) {\n\n \t\tthis.r = r;\n \t\tthis.g = g;\n \t\tthis.b = b;\n\n \t\tColorManagement.colorSpaceToWorking( this, colorSpace );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this color from RGB values.\n \t *\n \t * @param {number} h - Hue value between `0.0` and `1.0`.\n \t * @param {number} s - Saturation value between `0.0` and `1.0`.\n \t * @param {number} l - Lightness value between `0.0` and `1.0`.\n \t * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetHSL( h, s, l, colorSpace = ColorManagement.workingColorSpace ) {\n\n \t\t// h,s,l ranges are in 0.0 - 1.0\n \t\th = euclideanModulo( h, 1 );\n \t\ts = clamp( s, 0, 1 );\n \t\tl = clamp( l, 0, 1 );\n\n \t\tif ( s === 0 ) {\n\n \t\t\tthis.r = this.g = this.b = l;\n\n \t\t} else {\n\n \t\t\tconst p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n \t\t\tconst q = ( 2 * l ) - p;\n\n \t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n \t\t\tthis.g = hue2rgb( q, p, h );\n \t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n \t\t}\n\n \t\tColorManagement.colorSpaceToWorking( this, colorSpace );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this color from a CSS-style string. For example, `rgb(250, 0,0)`,\n \t * `rgb(100%, 0%, 0%)`, `hsl(0, 100%, 50%)`, `#ff0000`, `#f00`, or `red` ( or\n \t * any [X11 color name](https://en.wikipedia.org/wiki/X11_color_names#Color_name_chart) -\n \t * all 140 color names are supported).\n \t *\n \t * @param {string} style - Color as a CSS-style string.\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetStyle( style, colorSpace = SRGBColorSpace ) {\n\n \t\tfunction handleAlpha( string ) {\n\n \t\t\tif ( string === undefined ) return;\n\n \t\t\tif ( parseFloat( string ) < 1 ) {\n\n \t\t\t\twarn( 'Color: Alpha component of ' + style + ' will be ignored.' );\n\n \t\t\t}\n\n \t\t}\n\n\n \t\tlet m;\n\n \t\tif ( m = /^(\\w+)\\(([^\\)]*)\\)/.exec( style ) ) {\n\n \t\t\t// rgb / hsl\n\n \t\t\tlet color;\n \t\t\tconst name = m[ 1 ];\n \t\t\tconst components = m[ 2 ];\n\n \t\t\tswitch ( name ) {\n\n \t\t\t\tcase 'rgb':\n \t\t\t\tcase 'rgba':\n\n \t\t\t\t\tif ( color = /^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec( components ) ) {\n\n \t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\n \t\t\t\t\t\thandleAlpha( color[ 4 ] );\n\n \t\t\t\t\t\treturn this.setRGB(\n \t\t\t\t\t\t\tMath.min( 255, parseInt( color[ 1 ], 10 ) ) / 255,\n \t\t\t\t\t\t\tMath.min( 255, parseInt( color[ 2 ], 10 ) ) / 255,\n \t\t\t\t\t\t\tMath.min( 255, parseInt( color[ 3 ], 10 ) ) / 255,\n \t\t\t\t\t\t\tcolorSpace\n \t\t\t\t\t\t);\n\n \t\t\t\t\t}\n\n \t\t\t\t\tif ( color = /^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec( components ) ) {\n\n \t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\n \t\t\t\t\t\thandleAlpha( color[ 4 ] );\n\n \t\t\t\t\t\treturn this.setRGB(\n \t\t\t\t\t\t\tMath.min( 100, parseInt( color[ 1 ], 10 ) ) / 100,\n \t\t\t\t\t\t\tMath.min( 100, parseInt( color[ 2 ], 10 ) ) / 100,\n \t\t\t\t\t\t\tMath.min( 100, parseInt( color[ 3 ], 10 ) ) / 100,\n \t\t\t\t\t\t\tcolorSpace\n \t\t\t\t\t\t);\n\n \t\t\t\t\t}\n\n \t\t\t\t\tbreak;\n\n \t\t\t\tcase 'hsl':\n \t\t\t\tcase 'hsla':\n\n \t\t\t\t\tif ( color = /^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec( components ) ) {\n\n \t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\n \t\t\t\t\t\thandleAlpha( color[ 4 ] );\n\n \t\t\t\t\t\treturn this.setHSL(\n \t\t\t\t\t\t\tparseFloat( color[ 1 ] ) / 360,\n \t\t\t\t\t\t\tparseFloat( color[ 2 ] ) / 100,\n \t\t\t\t\t\t\tparseFloat( color[ 3 ] ) / 100,\n \t\t\t\t\t\t\tcolorSpace\n \t\t\t\t\t\t);\n\n \t\t\t\t\t}\n\n \t\t\t\t\tbreak;\n\n \t\t\t\tdefault:\n\n \t\t\t\t\twarn( 'Color: Unknown color model ' + style );\n\n \t\t\t}\n\n \t\t} else if ( m = /^\\#([A-Fa-f\\d]+)$/.exec( style ) ) {\n\n \t\t\t// hex color\n\n \t\t\tconst hex = m[ 1 ];\n \t\t\tconst size = hex.length;\n\n \t\t\tif ( size === 3 ) {\n\n \t\t\t\t// #ff0\n \t\t\t\treturn this.setRGB(\n \t\t\t\t\tparseInt( hex.charAt( 0 ), 16 ) / 15,\n \t\t\t\t\tparseInt( hex.charAt( 1 ), 16 ) / 15,\n \t\t\t\t\tparseInt( hex.charAt( 2 ), 16 ) / 15,\n \t\t\t\t\tcolorSpace\n \t\t\t\t);\n\n \t\t\t} else if ( size === 6 ) {\n\n \t\t\t\t// #ff0000\n \t\t\t\treturn this.setHex( parseInt( hex, 16 ), colorSpace );\n\n \t\t\t} else {\n\n \t\t\t\twarn( 'Color: Invalid hex color ' + style );\n\n \t\t\t}\n\n \t\t} else if ( style && style.length > 0 ) {\n\n \t\t\treturn this.setColorName( style, colorSpace );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets this color from a color name. Faster than {@link Color#setStyle} if\n \t * you don't need the other CSS-style formats.\n \t *\n \t * For convenience, the list of names is exposed in `Color.NAMES` as a hash.\n \t * ```js\n \t * Color.NAMES.aliceblue // returns 0xF0F8FF\n \t * ```\n \t *\n \t * @param {string} style - The color name.\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetColorName( style, colorSpace = SRGBColorSpace ) {\n\n \t\t// color keywords\n \t\tconst hex = _colorKeywords[ style.toLowerCase() ];\n\n \t\tif ( hex !== undefined ) {\n\n \t\t\t// red\n \t\t\tthis.setHex( hex, colorSpace );\n\n \t\t} else {\n\n \t\t\t// unknown color\n \t\t\twarn( 'Color: Unknown color ' + style );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new color with copied values from this instance.\n \t *\n \t * @return {Color} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this.r, this.g, this.b );\n\n \t}\n\n \t/**\n \t * Copies the values of the given color to this instance.\n \t *\n \t * @param {Color} color - The color to copy.\n \t * @return {Color} A reference to this color.\n \t */\n \tcopy( color ) {\n\n \t\tthis.r = color.r;\n \t\tthis.g = color.g;\n \t\tthis.b = color.b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the given color into this color, and then converts this color from\n \t * `SRGBColorSpace` to `LinearSRGBColorSpace`.\n \t *\n \t * @param {Color} color - The color to copy/convert.\n \t * @return {Color} A reference to this color.\n \t */\n \tcopySRGBToLinear( color ) {\n\n \t\tthis.r = SRGBToLinear( color.r );\n \t\tthis.g = SRGBToLinear( color.g );\n \t\tthis.b = SRGBToLinear( color.b );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the given color into this color, and then converts this color from\n \t * `LinearSRGBColorSpace` to `SRGBColorSpace`.\n \t *\n \t * @param {Color} color - The color to copy/convert.\n \t * @return {Color} A reference to this color.\n \t */\n \tcopyLinearToSRGB( color ) {\n\n \t\tthis.r = LinearToSRGB( color.r );\n \t\tthis.g = LinearToSRGB( color.g );\n \t\tthis.b = LinearToSRGB( color.b );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`.\n \t *\n \t * @return {Color} A reference to this color.\n \t */\n \tconvertSRGBToLinear() {\n\n \t\tthis.copySRGBToLinear( this );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`.\n \t *\n \t * @return {Color} A reference to this color.\n \t */\n \tconvertLinearToSRGB() {\n\n \t\tthis.copyLinearToSRGB( this );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the hexadecimal value of this color.\n \t *\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {number} The hexadecimal value.\n \t */\n \tgetHex( colorSpace = SRGBColorSpace ) {\n\n \t\tColorManagement.workingToColorSpace( _color.copy( this ), colorSpace );\n\n \t\treturn Math.round( clamp( _color.r * 255, 0, 255 ) ) * 65536 + Math.round( clamp( _color.g * 255, 0, 255 ) ) * 256 + Math.round( clamp( _color.b * 255, 0, 255 ) );\n\n \t}\n\n \t/**\n \t * Returns the hexadecimal value of this color as a string (for example, 'FFFFFF').\n \t *\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {string} The hexadecimal value as a string.\n \t */\n \tgetHexString( colorSpace = SRGBColorSpace ) {\n\n \t\treturn ( '000000' + this.getHex( colorSpace ).toString( 16 ) ).slice( -6 );\n\n \t}\n\n \t/**\n \t * Converts the colors RGB values into the HSL format and stores them into the\n \t * given target object.\n \t *\n \t * @param {{h:number,s:number,l:number}} target - The target object that is used to store the method's result.\n \t * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.\n \t * @return {{h:number,s:number,l:number}} The HSL representation of this color.\n \t */\n \tgetHSL( target, colorSpace = ColorManagement.workingColorSpace ) {\n\n \t\t// h,s,l ranges are in 0.0 - 1.0\n\n \t\tColorManagement.workingToColorSpace( _color.copy( this ), colorSpace );\n\n \t\tconst r = _color.r, g = _color.g, b = _color.b;\n\n \t\tconst max = Math.max( r, g, b );\n \t\tconst min = Math.min( r, g, b );\n\n \t\tlet hue, saturation;\n \t\tconst lightness = ( min + max ) / 2.0;\n\n \t\tif ( min === max ) {\n\n \t\t\thue = 0;\n \t\t\tsaturation = 0;\n\n \t\t} else {\n\n \t\t\tconst delta = max - min;\n\n \t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n \t\t\tswitch ( max ) {\n\n \t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n \t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n \t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n \t\t\t}\n\n \t\t\thue /= 6;\n\n \t\t}\n\n \t\ttarget.h = hue;\n \t\ttarget.s = saturation;\n \t\ttarget.l = lightness;\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns the RGB values of this color and stores them into the given target object.\n \t *\n \t * @param {Color} target - The target color that is used to store the method's result.\n \t * @param {string} [colorSpace=ColorManagement.workingColorSpace] - The color space.\n \t * @return {Color} The RGB representation of this color.\n \t */\n \tgetRGB( target, colorSpace = ColorManagement.workingColorSpace ) {\n\n \t\tColorManagement.workingToColorSpace( _color.copy( this ), colorSpace );\n\n \t\ttarget.r = _color.r;\n \t\ttarget.g = _color.g;\n \t\ttarget.b = _color.b;\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns the value of this color as a CSS style string. Example: `rgb(255,0,0)`.\n \t *\n \t * @param {string} [colorSpace=SRGBColorSpace] - The color space.\n \t * @return {string} The CSS representation of this color.\n \t */\n \tgetStyle( colorSpace = SRGBColorSpace ) {\n\n \t\tColorManagement.workingToColorSpace( _color.copy( this ), colorSpace );\n\n \t\tconst r = _color.r, g = _color.g, b = _color.b;\n\n \t\tif ( colorSpace !== SRGBColorSpace ) {\n\n \t\t\t// Requires CSS Color Module Level 4 (https://www.w3.org/TR/css-color-4/).\n \t\t\treturn `color(${ colorSpace } ${ r.toFixed( 3 ) } ${ g.toFixed( 3 ) } ${ b.toFixed( 3 ) })`;\n\n \t\t}\n\n \t\treturn `rgb(${ Math.round( r * 255 ) },${ Math.round( g * 255 ) },${ Math.round( b * 255 ) })`;\n\n \t}\n\n \t/**\n \t * Adds the given HSL values to this color's values.\n \t * Internally, this converts the color's RGB values to HSL, adds HSL\n \t * and then converts the color back to RGB.\n \t *\n \t * @param {number} h - Hue value between `0.0` and `1.0`.\n \t * @param {number} s - Saturation value between `0.0` and `1.0`.\n \t * @param {number} l - Lightness value between `0.0` and `1.0`.\n \t * @return {Color} A reference to this color.\n \t */\n \toffsetHSL( h, s, l ) {\n\n \t\tthis.getHSL( _hslA );\n\n \t\treturn this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );\n\n \t}\n\n \t/**\n \t * Adds the RGB values of the given color to the RGB values of this color.\n \t *\n \t * @param {Color} color - The color to add.\n \t * @return {Color} A reference to this color.\n \t */\n \tadd( color ) {\n\n \t\tthis.r += color.r;\n \t\tthis.g += color.g;\n \t\tthis.b += color.b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the RGB values of the given colors and stores the result in this instance.\n \t *\n \t * @param {Color} color1 - The first color.\n \t * @param {Color} color2 - The second color.\n \t * @return {Color} A reference to this color.\n \t */\n \taddColors( color1, color2 ) {\n\n \t\tthis.r = color1.r + color2.r;\n \t\tthis.g = color1.g + color2.g;\n \t\tthis.b = color1.b + color2.b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given scalar value to the RGB values of this color.\n \t *\n \t * @param {number} s - The scalar to add.\n \t * @return {Color} A reference to this color.\n \t */\n \taddScalar( s ) {\n\n \t\tthis.r += s;\n \t\tthis.g += s;\n \t\tthis.b += s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Subtracts the RGB values of the given color from the RGB values of this color.\n \t *\n \t * @param {Color} color - The color to subtract.\n \t * @return {Color} A reference to this color.\n \t */\n \tsub( color ) {\n\n \t\tthis.r = Math.max( 0, this.r - color.r );\n \t\tthis.g = Math.max( 0, this.g - color.g );\n \t\tthis.b = Math.max( 0, this.b - color.b );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the RGB values of the given color with the RGB values of this color.\n \t *\n \t * @param {Color} color - The color to multiply.\n \t * @return {Color} A reference to this color.\n \t */\n \tmultiply( color ) {\n\n \t\tthis.r *= color.r;\n \t\tthis.g *= color.g;\n \t\tthis.b *= color.b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Multiplies the given scalar value with the RGB values of this color.\n \t *\n \t * @param {number} s - The scalar to multiply.\n \t * @return {Color} A reference to this color.\n \t */\n \tmultiplyScalar( s ) {\n\n \t\tthis.r *= s;\n \t\tthis.g *= s;\n \t\tthis.b *= s;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates this color's RGB values toward the RGB values of the\n \t * given color. The alpha argument can be thought of as the ratio between\n \t * the two colors, where `0.0` is this color and `1.0` is the first argument.\n \t *\n \t * @param {Color} color - The color to converge on.\n \t * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.\n \t * @return {Color} A reference to this color.\n \t */\n \tlerp( color, alpha ) {\n\n \t\tthis.r += ( color.r - this.r ) * alpha;\n \t\tthis.g += ( color.g - this.g ) * alpha;\n \t\tthis.b += ( color.b - this.b ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates between the given colors and stores the result in this instance.\n \t * The alpha argument can be thought of as the ratio between the two colors, where `0.0`\n \t * is the first and `1.0` is the second color.\n \t *\n \t * @param {Color} color1 - The first color.\n \t * @param {Color} color2 - The second color.\n \t * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.\n \t * @return {Color} A reference to this color.\n \t */\n \tlerpColors( color1, color2, alpha ) {\n\n \t\tthis.r = color1.r + ( color2.r - color1.r ) * alpha;\n \t\tthis.g = color1.g + ( color2.g - color1.g ) * alpha;\n \t\tthis.b = color1.b + ( color2.b - color1.b ) * alpha;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Linearly interpolates this color's HSL values toward the HSL values of the\n \t * given color. It differs from {@link Color#lerp} by not interpolating straight\n \t * from one color to the other, but instead going through all the hues in between\n \t * those two colors. The alpha argument can be thought of as the ratio between\n \t * the two colors, where 0.0 is this color and 1.0 is the first argument.\n \t *\n \t * @param {Color} color - The color to converge on.\n \t * @param {number} alpha - The interpolation factor in the closed interval `[0,1]`.\n \t * @return {Color} A reference to this color.\n \t */\n \tlerpHSL( color, alpha ) {\n\n \t\tthis.getHSL( _hslA );\n \t\tcolor.getHSL( _hslB );\n\n \t\tconst h = lerp( _hslA.h, _hslB.h, alpha );\n \t\tconst s = lerp( _hslA.s, _hslB.s, alpha );\n \t\tconst l = lerp( _hslA.l, _hslB.l, alpha );\n\n \t\tthis.setHSL( h, s, l );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the color's RGB components from the given 3D vector.\n \t *\n \t * @param {Vector3} v - The vector to set.\n \t * @return {Color} A reference to this color.\n \t */\n \tsetFromVector3( v ) {\n\n \t\tthis.r = v.x;\n \t\tthis.g = v.y;\n \t\tthis.b = v.z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Transforms this color with the given 3x3 matrix.\n \t *\n \t * @param {Matrix3} m - The matrix.\n \t * @return {Color} A reference to this color.\n \t */\n \tapplyMatrix3( m ) {\n\n \t\tconst r = this.r, g = this.g, b = this.b;\n \t\tconst e = m.elements;\n\n \t\tthis.r = e[ 0 ] * r + e[ 3 ] * g + e[ 6 ] * b;\n \t\tthis.g = e[ 1 ] * r + e[ 4 ] * g + e[ 7 ] * b;\n \t\tthis.b = e[ 2 ] * r + e[ 5 ] * g + e[ 8 ] * b;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this color is equal with the given one.\n \t *\n \t * @param {Color} c - The color to test for equality.\n \t * @return {boolean} Whether this bounding color is equal with the given one.\n \t */\n \tequals( c ) {\n\n \t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n \t}\n\n \t/**\n \t * Sets this color's RGB components from the given array.\n \t *\n \t * @param {Array<number>} array - An array holding the RGB values.\n \t * @param {number} [offset=0] - The offset into the array.\n \t * @return {Color} A reference to this color.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tthis.r = array[ offset ];\n \t\tthis.g = array[ offset + 1 ];\n \t\tthis.b = array[ offset + 2 ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Writes the RGB components of this color to the given array. If no array is provided,\n \t * the method returns a new instance.\n \t *\n \t * @param {Array<number>} [array=[]] - The target array holding the color components.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Array<number>} The color components.\n \t */\n \ttoArray( array = [], offset = 0 ) {\n\n \t\tarray[ offset ] = this.r;\n \t\tarray[ offset + 1 ] = this.g;\n \t\tarray[ offset + 2 ] = this.b;\n\n \t\treturn array;\n\n \t}\n\n \t/**\n \t * Sets the components of this color from the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - The buffer attribute holding color data.\n \t * @param {number} index - The index into the attribute.\n \t * @return {Color} A reference to this color.\n \t */\n \tfromBufferAttribute( attribute, index ) {\n\n \t\tthis.r = attribute.getX( index );\n \t\tthis.g = attribute.getY( index );\n \t\tthis.b = attribute.getZ( index );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * This methods defines the serialization result of this class. Returns the color\n \t * as a hexadecimal value.\n \t *\n \t * @return {number} The hexadecimal value.\n \t */\n \ttoJSON() {\n\n \t\treturn this.getHex();\n\n \t}\n\n \t*[ Symbol.iterator ]() {\n\n \t\tyield this.r;\n \t\tyield this.g;\n \t\tyield this.b;\n\n \t}\n\n }\n\n const _color = /*@__PURE__*/ new Color();\n\n /**\n * A dictionary with X11 color names.\n *\n * Note that multiple words such as Dark Orange become the string 'darkorange'.\n *\n * @static\n * @type {Object}\n */\n Color.NAMES = _colorKeywords;\n\n const _v0$2 = /*@__PURE__*/ new Vector3();\n const _v1$5 = /*@__PURE__*/ new Vector3();\n const _v2$4 = /*@__PURE__*/ new Vector3();\n const _v3$2 = /*@__PURE__*/ new Vector3();\n\n const _vab = /*@__PURE__*/ new Vector3();\n const _vac = /*@__PURE__*/ new Vector3();\n const _vbc = /*@__PURE__*/ new Vector3();\n const _vap = /*@__PURE__*/ new Vector3();\n const _vbp = /*@__PURE__*/ new Vector3();\n const _vcp = /*@__PURE__*/ new Vector3();\n\n const _v40 = /*@__PURE__*/ new Vector4();\n const _v41 = /*@__PURE__*/ new Vector4();\n const _v42 = /*@__PURE__*/ new Vector4();\n\n /**\n * A geometric triangle as defined by three vectors representing its three corners.\n */\n class Triangle {\n\n \t/**\n \t * Constructs a new triangle.\n \t *\n \t * @param {Vector3} [a=(0,0,0)] - The first corner of the triangle.\n \t * @param {Vector3} [b=(0,0,0)] - The second corner of the triangle.\n \t * @param {Vector3} [c=(0,0,0)] - The third corner of the triangle.\n \t */\n \tconstructor( a = new Vector3(), b = new Vector3(), c = new Vector3() ) {\n\n \t\t/**\n \t\t * The first corner of the triangle.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.a = a;\n\n \t\t/**\n \t\t * The second corner of the triangle.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.b = b;\n\n \t\t/**\n \t\t * The third corner of the triangle.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.c = c;\n\n \t}\n\n \t/**\n \t * Computes the normal vector of a triangle.\n \t *\n \t * @param {Vector3} a - The first corner of the triangle.\n \t * @param {Vector3} b - The second corner of the triangle.\n \t * @param {Vector3} c - The third corner of the triangle.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The triangle's normal.\n \t */\n \tstatic getNormal( a, b, c, target ) {\n\n \t\ttarget.subVectors( c, b );\n \t\t_v0$2.subVectors( a, b );\n \t\ttarget.cross( _v0$2 );\n\n \t\tconst targetLengthSq = target.lengthSq();\n \t\tif ( targetLengthSq > 0 ) {\n\n \t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n \t\t}\n\n \t\treturn target.set( 0, 0, 0 );\n\n \t}\n\n \t/**\n \t * Computes a barycentric coordinates from the given vector.\n \t * Returns `null` if the triangle is degenerate.\n \t *\n \t * @param {Vector3} point - A point in 3D space.\n \t * @param {Vector3} a - The first corner of the triangle.\n \t * @param {Vector3} b - The second corner of the triangle.\n \t * @param {Vector3} c - The third corner of the triangle.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The barycentric coordinates for the given point\n \t */\n \tstatic getBarycoord( point, a, b, c, target ) {\n\n \t\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\n \t\t_v0$2.subVectors( c, a );\n \t\t_v1$5.subVectors( b, a );\n \t\t_v2$4.subVectors( point, a );\n\n \t\tconst dot00 = _v0$2.dot( _v0$2 );\n \t\tconst dot01 = _v0$2.dot( _v1$5 );\n \t\tconst dot02 = _v0$2.dot( _v2$4 );\n \t\tconst dot11 = _v1$5.dot( _v1$5 );\n \t\tconst dot12 = _v1$5.dot( _v2$4 );\n\n \t\tconst denom = ( dot00 * dot11 - dot01 * dot01 );\n\n \t\t// collinear or singular triangle\n \t\tif ( denom === 0 ) {\n\n \t\t\ttarget.set( 0, 0, 0 );\n \t\t\treturn null;\n\n \t\t}\n\n \t\tconst invDenom = 1 / denom;\n \t\tconst u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n \t\tconst v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n \t\t// barycentric coordinates must always sum to 1\n \t\treturn target.set( 1 - u - v, v, u );\n\n \t}\n\n \t/**\n \t * Returns `true` if the given point, when projected onto the plane of the\n \t * triangle, lies within the triangle.\n \t *\n \t * @param {Vector3} point - The point in 3D space to test.\n \t * @param {Vector3} a - The first corner of the triangle.\n \t * @param {Vector3} b - The second corner of the triangle.\n \t * @param {Vector3} c - The third corner of the triangle.\n \t * @return {boolean} Whether the given point, when projected onto the plane of the\n \t * triangle, lies within the triangle or not.\n \t */\n \tstatic containsPoint( point, a, b, c ) {\n\n \t\t// if the triangle is degenerate then we can't contain a point\n \t\tif ( this.getBarycoord( point, a, b, c, _v3$2 ) === null ) {\n\n \t\t\treturn false;\n\n \t\t}\n\n \t\treturn ( _v3$2.x >= 0 ) && ( _v3$2.y >= 0 ) && ( ( _v3$2.x + _v3$2.y ) <= 1 );\n\n \t}\n\n \t/**\n \t * Computes the value barycentrically interpolated for the given point on the\n \t * triangle. Returns `null` if the triangle is degenerate.\n \t *\n \t * @param {Vector3} point - Position of interpolated point.\n \t * @param {Vector3} p1 - The first corner of the triangle.\n \t * @param {Vector3} p2 - The second corner of the triangle.\n \t * @param {Vector3} p3 - The third corner of the triangle.\n \t * @param {Vector3} v1 - Value to interpolate of first vertex.\n \t * @param {Vector3} v2 - Value to interpolate of second vertex.\n \t * @param {Vector3} v3 - Value to interpolate of third vertex.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The interpolated value.\n \t */\n \tstatic getInterpolation( point, p1, p2, p3, v1, v2, v3, target ) {\n\n \t\tif ( this.getBarycoord( point, p1, p2, p3, _v3$2 ) === null ) {\n\n \t\t\ttarget.x = 0;\n \t\t\ttarget.y = 0;\n \t\t\tif ( 'z' in target ) target.z = 0;\n \t\t\tif ( 'w' in target ) target.w = 0;\n \t\t\treturn null;\n\n \t\t}\n\n \t\ttarget.setScalar( 0 );\n \t\ttarget.addScaledVector( v1, _v3$2.x );\n \t\ttarget.addScaledVector( v2, _v3$2.y );\n \t\ttarget.addScaledVector( v3, _v3$2.z );\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Computes the value barycentrically interpolated for the given attribute and indices.\n \t *\n \t * @param {BufferAttribute} attr - The attribute to interpolate.\n \t * @param {number} i1 - Index of first vertex.\n \t * @param {number} i2 - Index of second vertex.\n \t * @param {number} i3 - Index of third vertex.\n \t * @param {Vector3} barycoord - The barycoordinate value to use to interpolate.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The interpolated attribute value.\n \t */\n \tstatic getInterpolatedAttribute( attr, i1, i2, i3, barycoord, target ) {\n\n \t\t_v40.setScalar( 0 );\n \t\t_v41.setScalar( 0 );\n \t\t_v42.setScalar( 0 );\n\n \t\t_v40.fromBufferAttribute( attr, i1 );\n \t\t_v41.fromBufferAttribute( attr, i2 );\n \t\t_v42.fromBufferAttribute( attr, i3 );\n\n \t\ttarget.setScalar( 0 );\n \t\ttarget.addScaledVector( _v40, barycoord.x );\n \t\ttarget.addScaledVector( _v41, barycoord.y );\n \t\ttarget.addScaledVector( _v42, barycoord.z );\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns `true` if the triangle is oriented towards the given direction.\n \t *\n \t * @param {Vector3} a - The first corner of the triangle.\n \t * @param {Vector3} b - The second corner of the triangle.\n \t * @param {Vector3} c - The third corner of the triangle.\n \t * @param {Vector3} direction - The (normalized) direction vector.\n \t * @return {boolean} Whether the triangle is oriented towards the given direction or not.\n \t */\n \tstatic isFrontFacing( a, b, c, direction ) {\n\n \t\t_v0$2.subVectors( c, b );\n \t\t_v1$5.subVectors( a, b );\n\n \t\t// strictly front facing\n \t\treturn _v0$2.cross( _v1$5 ).dot( direction ) < 0;\n\n \t}\n\n \t/**\n \t * Sets the triangle's vertices by copying the given values.\n \t *\n \t * @param {Vector3} a - The first corner of the triangle.\n \t * @param {Vector3} b - The second corner of the triangle.\n \t * @param {Vector3} c - The third corner of the triangle.\n \t * @return {Triangle} A reference to this triangle.\n \t */\n \tset( a, b, c ) {\n\n \t\tthis.a.copy( a );\n \t\tthis.b.copy( b );\n \t\tthis.c.copy( c );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the triangle's vertices by copying the given array values.\n \t *\n \t * @param {Array<Vector3>} points - An array with 3D points.\n \t * @param {number} i0 - The array index representing the first corner of the triangle.\n \t * @param {number} i1 - The array index representing the second corner of the triangle.\n \t * @param {number} i2 - The array index representing the third corner of the triangle.\n \t * @return {Triangle} A reference to this triangle.\n \t */\n \tsetFromPointsAndIndices( points, i0, i1, i2 ) {\n\n \t\tthis.a.copy( points[ i0 ] );\n \t\tthis.b.copy( points[ i1 ] );\n \t\tthis.c.copy( points[ i2 ] );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the triangle's vertices by copying the given attribute values.\n \t *\n \t * @param {BufferAttribute} attribute - A buffer attribute with 3D points data.\n \t * @param {number} i0 - The attribute index representing the first corner of the triangle.\n \t * @param {number} i1 - The attribute index representing the second corner of the triangle.\n \t * @param {number} i2 - The attribute index representing the third corner of the triangle.\n \t * @return {Triangle} A reference to this triangle.\n \t */\n \tsetFromAttributeAndIndices( attribute, i0, i1, i2 ) {\n\n \t\tthis.a.fromBufferAttribute( attribute, i0 );\n \t\tthis.b.fromBufferAttribute( attribute, i1 );\n \t\tthis.c.fromBufferAttribute( attribute, i2 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new triangle with copied values from this instance.\n \t *\n \t * @return {Triangle} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Copies the values of the given triangle to this instance.\n \t *\n \t * @param {Triangle} triangle - The triangle to copy.\n \t * @return {Triangle} A reference to this triangle.\n \t */\n \tcopy( triangle ) {\n\n \t\tthis.a.copy( triangle.a );\n \t\tthis.b.copy( triangle.b );\n \t\tthis.c.copy( triangle.c );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the area of the triangle.\n \t *\n \t * @return {number} The triangle's area.\n \t */\n \tgetArea() {\n\n \t\t_v0$2.subVectors( this.c, this.b );\n \t\t_v1$5.subVectors( this.a, this.b );\n\n \t\treturn _v0$2.cross( _v1$5 ).length() * 0.5;\n\n \t}\n\n \t/**\n \t * Computes the midpoint of the triangle.\n \t *\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The triangle's midpoint.\n \t */\n \tgetMidpoint( target ) {\n\n \t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n \t}\n\n \t/**\n \t * Computes the normal of the triangle.\n \t *\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The triangle's normal.\n \t */\n \tgetNormal( target ) {\n\n \t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n \t}\n\n \t/**\n \t * Computes a plane the triangle lies within.\n \t *\n \t * @param {Plane} target - The target vector that is used to store the method's result.\n \t * @return {Plane} The plane the triangle lies within.\n \t */\n \tgetPlane( target ) {\n\n \t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n \t}\n\n \t/**\n \t * Computes a barycentric coordinates from the given vector.\n \t * Returns `null` if the triangle is degenerate.\n \t *\n \t * @param {Vector3} point - A point in 3D space.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The barycentric coordinates for the given point\n \t */\n \tgetBarycoord( point, target ) {\n\n \t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n \t}\n\n \t/**\n \t * Computes the value barycentrically interpolated for the given point on the\n \t * triangle. Returns `null` if the triangle is degenerate.\n \t *\n \t * @param {Vector3} point - Position of interpolated point.\n \t * @param {Vector3} v1 - Value to interpolate of first vertex.\n \t * @param {Vector3} v2 - Value to interpolate of second vertex.\n \t * @param {Vector3} v3 - Value to interpolate of third vertex.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The interpolated value.\n \t */\n \tgetInterpolation( point, v1, v2, v3, target ) {\n\n \t\treturn Triangle.getInterpolation( point, this.a, this.b, this.c, v1, v2, v3, target );\n\n \t}\n\n \t/**\n \t * Returns `true` if the given point, when projected onto the plane of the\n \t * triangle, lies within the triangle.\n \t *\n \t * @param {Vector3} point - The point in 3D space to test.\n \t * @return {boolean} Whether the given point, when projected onto the plane of the\n \t * triangle, lies within the triangle or not.\n \t */\n \tcontainsPoint( point ) {\n\n \t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n \t}\n\n \t/**\n \t * Returns `true` if the triangle is oriented towards the given direction.\n \t *\n \t * @param {Vector3} direction - The (normalized) direction vector.\n \t * @return {boolean} Whether the triangle is oriented towards the given direction or not.\n \t */\n \tisFrontFacing( direction ) {\n\n \t\treturn Triangle.isFrontFacing( this.a, this.b, this.c, direction );\n\n \t}\n\n \t/**\n \t * Returns `true` if this triangle intersects with the given box.\n \t *\n \t * @param {Box3} box - The box to intersect.\n \t * @return {boolean} Whether this triangle intersects with the given box or not.\n \t */\n \tintersectsBox( box ) {\n\n \t\treturn box.intersectsTriangle( this );\n\n \t}\n\n \t/**\n \t * Returns the closest point on the triangle to the given point.\n \t *\n \t * @param {Vector3} p - The point to compute the closest point for.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The closest point on the triangle.\n \t */\n \tclosestPointToPoint( p, target ) {\n\n \t\tconst a = this.a, b = this.b, c = this.c;\n \t\tlet v, w;\n\n \t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n \t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n \t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n \t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n \t\t// the point lies in with the minimum amount of redundant computation.\n\n \t\t_vab.subVectors( b, a );\n \t\t_vac.subVectors( c, a );\n \t\t_vap.subVectors( p, a );\n \t\tconst d1 = _vab.dot( _vap );\n \t\tconst d2 = _vac.dot( _vap );\n \t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n \t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n \t\t\treturn target.copy( a );\n\n \t\t}\n\n \t\t_vbp.subVectors( p, b );\n \t\tconst d3 = _vab.dot( _vbp );\n \t\tconst d4 = _vac.dot( _vbp );\n \t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n \t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n \t\t\treturn target.copy( b );\n\n \t\t}\n\n \t\tconst vc = d1 * d4 - d3 * d2;\n \t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n \t\t\tv = d1 / ( d1 - d3 );\n \t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n \t\t\treturn target.copy( a ).addScaledVector( _vab, v );\n\n \t\t}\n\n \t\t_vcp.subVectors( p, c );\n \t\tconst d5 = _vab.dot( _vcp );\n \t\tconst d6 = _vac.dot( _vcp );\n \t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n \t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n \t\t\treturn target.copy( c );\n\n \t\t}\n\n \t\tconst vb = d5 * d2 - d1 * d6;\n \t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n \t\t\tw = d2 / ( d2 - d6 );\n \t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n \t\t\treturn target.copy( a ).addScaledVector( _vac, w );\n\n \t\t}\n\n \t\tconst va = d3 * d6 - d5 * d4;\n \t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n \t\t\t_vbc.subVectors( c, b );\n \t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n \t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n \t\t\treturn target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC\n\n \t\t}\n\n \t\t// face region\n \t\tconst denom = 1 / ( va + vb + vc );\n \t\t// u = va * denom\n \t\tv = vb * denom;\n \t\tw = vc * denom;\n\n \t\treturn target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );\n\n \t}\n\n \t/**\n \t * Returns `true` if this triangle is equal with the given one.\n \t *\n \t * @param {Triangle} triangle - The triangle to test for equality.\n \t * @return {boolean} Whether this triangle is equal with the given one.\n \t */\n \tequals( triangle ) {\n\n \t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n \t}\n\n }\n\n /**\n * Represents an axis-aligned bounding box (AABB) in 3D space.\n */\n class Box3 {\n\n \t/**\n \t * Constructs a new bounding box.\n \t *\n \t * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.\n \t * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.\n \t */\n \tconstructor( min = new Vector3( + Infinity, + Infinity, + Infinity ), max = new Vector3( - Infinity, - Infinity, - Infinity ) ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isBox3 = true;\n\n \t\t/**\n \t\t * The lower boundary of the box.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.min = min;\n\n \t\t/**\n \t\t * The upper boundary of the box.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.max = max;\n\n \t}\n\n \t/**\n \t * Sets the lower and upper boundaries of this box.\n \t * Please note that this method only copies the values from the given objects.\n \t *\n \t * @param {Vector3} min - The lower boundary of the box.\n \t * @param {Vector3} max - The upper boundary of the box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tset( min, max ) {\n\n \t\tthis.min.copy( min );\n \t\tthis.max.copy( max );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the upper and lower bounds of this box so it encloses the position data\n \t * in the given array.\n \t *\n \t * @param {Array<number>} array - An array holding 3D position data.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tsetFromArray( array ) {\n\n \t\tthis.makeEmpty();\n\n \t\tfor ( let i = 0, il = array.length; i < il; i += 3 ) {\n\n \t\t\tthis.expandByPoint( _vector$b.fromArray( array, i ) );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the upper and lower bounds of this box so it encloses the position data\n \t * in the given buffer attribute.\n \t *\n \t * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tsetFromBufferAttribute( attribute ) {\n\n \t\tthis.makeEmpty();\n\n \t\tfor ( let i = 0, il = attribute.count; i < il; i ++ ) {\n\n \t\t\tthis.expandByPoint( _vector$b.fromBufferAttribute( attribute, i ) );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the upper and lower bounds of this box so it encloses the position data\n \t * in the given array.\n \t *\n \t * @param {Array<Vector3>} points - An array holding 3D position data as instances of {@link Vector3}.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tsetFromPoints( points ) {\n\n \t\tthis.makeEmpty();\n\n \t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n \t\t\tthis.expandByPoint( points[ i ] );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Centers this box on the given center vector and sets this box's width, height and\n \t * depth to the given size values.\n \t *\n \t * @param {Vector3} center - The center of the box.\n \t * @param {Vector3} size - The x, y and z dimensions of the box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tsetFromCenterAndSize( center, size ) {\n\n \t\tconst halfSize = _vector$b.copy( size ).multiplyScalar( 0.5 );\n\n \t\tthis.min.copy( center ).sub( halfSize );\n \t\tthis.max.copy( center ).add( halfSize );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the world-axis-aligned bounding box for the given 3D object\n \t * (including its children), accounting for the object's, and children's,\n \t * world transforms. The function may result in a larger box than strictly necessary.\n \t *\n \t * Note: To compute the correct bounding box, make sure the given 3D object\n \t * has an up-to-date world matrix that reflects the current transformation of its\n \t * ancestor nodes. Call `object.updateWorldMatrix( true, false )` beforehand if\n \t * you're unsure.\n \t *\n \t * @param {Object3D} object - The 3D object to compute the bounding box for.\n \t * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest\n \t * world-axis-aligned bounding box at the expense of more computation.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tsetFromObject( object, precise = false ) {\n\n \t\tthis.makeEmpty();\n\n \t\treturn this.expandByObject( object, precise );\n\n \t}\n\n \t/**\n \t * Returns a new box with copied values from this instance.\n \t *\n \t * @return {Box3} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Copies the values of the given box to this instance.\n \t *\n \t * @param {Box3} box - The box to copy.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tcopy( box ) {\n\n \t\tthis.min.copy( box.min );\n \t\tthis.max.copy( box.max );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Makes this box empty which means in encloses a zero space in 3D.\n \t *\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tmakeEmpty() {\n\n \t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n \t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns true if this box includes zero points within its bounds.\n \t * Note that a box with equal lower and upper bounds still includes one\n \t * point, the one both bounds share.\n \t *\n \t * @return {boolean} Whether this box is empty or not.\n \t */\n \tisEmpty() {\n\n \t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n \t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n \t}\n\n \t/**\n \t * Returns the center point of this box.\n \t *\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The center point.\n \t */\n \tgetCenter( target ) {\n\n \t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n \t}\n\n \t/**\n \t * Returns the dimensions of this box.\n \t *\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The size.\n \t */\n \tgetSize( target ) {\n\n \t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n \t}\n\n \t/**\n \t * Expands the boundaries of this box to include the given point.\n \t *\n \t * @param {Vector3} point - The point that should be included by the bounding box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \texpandByPoint( point ) {\n\n \t\tthis.min.min( point );\n \t\tthis.max.max( point );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Expands this box equilaterally by the given vector. The width of this\n \t * box will be expanded by the x component of the vector in both\n \t * directions. The height of this box will be expanded by the y component of\n \t * the vector in both directions. The depth of this box will be\n \t * expanded by the z component of the vector in both directions.\n \t *\n \t * @param {Vector3} vector - The vector that should expand the bounding box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \texpandByVector( vector ) {\n\n \t\tthis.min.sub( vector );\n \t\tthis.max.add( vector );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Expands each dimension of the box by the given scalar. If negative, the\n \t * dimensions of the box will be contracted.\n \t *\n \t * @param {number} scalar - The scalar value that should expand the bounding box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \texpandByScalar( scalar ) {\n\n \t\tthis.min.addScalar( - scalar );\n \t\tthis.max.addScalar( scalar );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Expands the boundaries of this box to include the given 3D object and\n \t * its children, accounting for the object's, and children's, world\n \t * transforms. The function may result in a larger box than strictly\n \t * necessary (unless the precise parameter is set to true).\n \t *\n \t * @param {Object3D} object - The 3D object that should expand the bounding box.\n \t * @param {boolean} precise - If set to `true`, the method expands the bounding box\n \t * as little as necessary at the expense of more computation.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \texpandByObject( object, precise = false ) {\n\n \t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n \t\t// accounting for both the object's, and children's, world transforms\n\n \t\tobject.updateWorldMatrix( false, false );\n\n \t\tconst geometry = object.geometry;\n\n \t\tif ( geometry !== undefined ) {\n\n \t\t\tconst positionAttribute = geometry.getAttribute( 'position' );\n\n \t\t\t// precise AABB computation based on vertex data requires at least a position attribute.\n \t\t\t// instancing isn't supported so far and uses the normal (conservative) code path.\n\n \t\t\tif ( precise === true && positionAttribute !== undefined && object.isInstancedMesh !== true ) {\n\n \t\t\t\tfor ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {\n\n \t\t\t\t\tif ( object.isMesh === true ) {\n\n \t\t\t\t\t\tobject.getVertexPosition( i, _vector$b );\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\t_vector$b.fromBufferAttribute( positionAttribute, i );\n\n \t\t\t\t\t}\n\n \t\t\t\t\t_vector$b.applyMatrix4( object.matrixWorld );\n \t\t\t\t\tthis.expandByPoint( _vector$b );\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\tif ( object.boundingBox !== undefined ) {\n\n \t\t\t\t\t// object-level bounding box\n\n \t\t\t\t\tif ( object.boundingBox === null ) {\n\n \t\t\t\t\t\tobject.computeBoundingBox();\n\n \t\t\t\t\t}\n\n \t\t\t\t\t_box$4.copy( object.boundingBox );\n\n\n \t\t\t\t} else {\n\n \t\t\t\t\t// geometry-level bounding box\n\n \t\t\t\t\tif ( geometry.boundingBox === null ) {\n\n \t\t\t\t\t\tgeometry.computeBoundingBox();\n\n \t\t\t\t\t}\n\n \t\t\t\t\t_box$4.copy( geometry.boundingBox );\n\n \t\t\t\t}\n\n \t\t\t\t_box$4.applyMatrix4( object.matrixWorld );\n\n \t\t\t\tthis.union( _box$4 );\n\n \t\t\t}\n\n \t\t}\n\n \t\tconst children = object.children;\n\n \t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n \t\t\tthis.expandByObject( children[ i ], precise );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if the given point lies within or on the boundaries of this box.\n \t *\n \t * @param {Vector3} point - The point to test.\n \t * @return {boolean} Whether the bounding box contains the given point or not.\n \t */\n \tcontainsPoint( point ) {\n\n \t\treturn point.x >= this.min.x && point.x <= this.max.x &&\n \t\t\tpoint.y >= this.min.y && point.y <= this.max.y &&\n \t\t\tpoint.z >= this.min.z && point.z <= this.max.z;\n\n \t}\n\n \t/**\n \t * Returns `true` if this bounding box includes the entirety of the given bounding box.\n \t * If this box and the given one are identical, this function also returns `true`.\n \t *\n \t * @param {Box3} box - The bounding box to test.\n \t * @return {boolean} Whether the bounding box contains the given bounding box or not.\n \t */\n \tcontainsBox( box ) {\n\n \t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n \t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n \t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n \t}\n\n \t/**\n \t * Returns a point as a proportion of this box's width, height and depth.\n \t *\n \t * @param {Vector3} point - A point in 3D space.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} A point as a proportion of this box's width, height and depth.\n \t */\n \tgetParameter( point, target ) {\n\n \t\t// This can potentially have a divide by zero if the box\n \t\t// has a size dimension of 0.\n\n \t\treturn target.set(\n \t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n \t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n \t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n \t\t);\n\n \t}\n\n \t/**\n \t * Returns `true` if the given bounding box intersects with this bounding box.\n \t *\n \t * @param {Box3} box - The bounding box to test.\n \t * @return {boolean} Whether the given bounding box intersects with this bounding box.\n \t */\n \tintersectsBox( box ) {\n\n \t\t// using 6 splitting planes to rule out intersections.\n \t\treturn box.max.x >= this.min.x && box.min.x <= this.max.x &&\n \t\t\tbox.max.y >= this.min.y && box.min.y <= this.max.y &&\n \t\t\tbox.max.z >= this.min.z && box.min.z <= this.max.z;\n\n \t}\n\n \t/**\n \t * Returns `true` if the given bounding sphere intersects with this bounding box.\n \t *\n \t * @param {Sphere} sphere - The bounding sphere to test.\n \t * @return {boolean} Whether the given bounding sphere intersects with this bounding box.\n \t */\n \tintersectsSphere( sphere ) {\n\n \t\t// Find the point on the AABB closest to the sphere center.\n \t\tthis.clampPoint( sphere.center, _vector$b );\n\n \t\t// If that point is inside the sphere, the AABB and sphere intersect.\n \t\treturn _vector$b.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n \t}\n\n \t/**\n \t * Returns `true` if the given plane intersects with this bounding box.\n \t *\n \t * @param {Plane} plane - The plane to test.\n \t * @return {boolean} Whether the given plane intersects with this bounding box.\n \t */\n \tintersectsPlane( plane ) {\n\n \t\t// We compute the minimum and maximum dot product values. If those values\n \t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n \t\tlet min, max;\n\n \t\tif ( plane.normal.x > 0 ) {\n\n \t\t\tmin = plane.normal.x * this.min.x;\n \t\t\tmax = plane.normal.x * this.max.x;\n\n \t\t} else {\n\n \t\t\tmin = plane.normal.x * this.max.x;\n \t\t\tmax = plane.normal.x * this.min.x;\n\n \t\t}\n\n \t\tif ( plane.normal.y > 0 ) {\n\n \t\t\tmin += plane.normal.y * this.min.y;\n \t\t\tmax += plane.normal.y * this.max.y;\n\n \t\t} else {\n\n \t\t\tmin += plane.normal.y * this.max.y;\n \t\t\tmax += plane.normal.y * this.min.y;\n\n \t\t}\n\n \t\tif ( plane.normal.z > 0 ) {\n\n \t\t\tmin += plane.normal.z * this.min.z;\n \t\t\tmax += plane.normal.z * this.max.z;\n\n \t\t} else {\n\n \t\t\tmin += plane.normal.z * this.max.z;\n \t\t\tmax += plane.normal.z * this.min.z;\n\n \t\t}\n\n \t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n \t}\n\n \t/**\n \t * Returns `true` if the given triangle intersects with this bounding box.\n \t *\n \t * @param {Triangle} triangle - The triangle to test.\n \t * @return {boolean} Whether the given triangle intersects with this bounding box.\n \t */\n \tintersectsTriangle( triangle ) {\n\n \t\tif ( this.isEmpty() ) {\n\n \t\t\treturn false;\n\n \t\t}\n\n \t\t// compute box center and extents\n \t\tthis.getCenter( _center );\n \t\t_extents.subVectors( this.max, _center );\n\n \t\t// translate triangle to aabb origin\n \t\t_v0$1.subVectors( triangle.a, _center );\n \t\t_v1$4.subVectors( triangle.b, _center );\n \t\t_v2$3.subVectors( triangle.c, _center );\n\n \t\t// compute edge vectors for triangle\n \t\t_f0.subVectors( _v1$4, _v0$1 );\n \t\t_f1.subVectors( _v2$3, _v1$4 );\n \t\t_f2.subVectors( _v0$1, _v2$3 );\n\n \t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n \t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n \t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n \t\tlet axes = [\n \t\t\t0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,\n \t\t\t_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,\n \t\t\t- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0\n \t\t];\n \t\tif ( ! satForAxes( axes, _v0$1, _v1$4, _v2$3, _extents ) ) {\n\n \t\t\treturn false;\n\n \t\t}\n\n \t\t// test 3 face normals from the aabb\n \t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n \t\tif ( ! satForAxes( axes, _v0$1, _v1$4, _v2$3, _extents ) ) {\n\n \t\t\treturn false;\n\n \t\t}\n\n \t\t// finally testing the face normal of the triangle\n \t\t// use already existing triangle edge vectors here\n \t\t_triangleNormal.crossVectors( _f0, _f1 );\n \t\taxes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];\n\n \t\treturn satForAxes( axes, _v0$1, _v1$4, _v2$3, _extents );\n\n \t}\n\n \t/**\n \t * Clamps the given point within the bounds of this box.\n \t *\n \t * @param {Vector3} point - The point to clamp.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The clamped point.\n \t */\n \tclampPoint( point, target ) {\n\n \t\treturn target.copy( point ).clamp( this.min, this.max );\n\n \t}\n\n \t/**\n \t * Returns the euclidean distance from any edge of this box to the specified point. If\n \t * the given point lies inside of this box, the distance will be `0`.\n \t *\n \t * @param {Vector3} point - The point to compute the distance to.\n \t * @return {number} The euclidean distance.\n \t */\n \tdistanceToPoint( point ) {\n\n \t\treturn this.clampPoint( point, _vector$b ).distanceTo( point );\n\n \t}\n\n \t/**\n \t * Returns a bounding sphere that encloses this bounding box.\n \t *\n \t * @param {Sphere} target - The target sphere that is used to store the method's result.\n \t * @return {Sphere} The bounding sphere that encloses this bounding box.\n \t */\n \tgetBoundingSphere( target ) {\n\n \t\tif ( this.isEmpty() ) {\n\n \t\t\ttarget.makeEmpty();\n\n \t\t} else {\n\n \t\t\tthis.getCenter( target.center );\n\n \t\t\ttarget.radius = this.getSize( _vector$b ).length() * 0.5;\n\n \t\t}\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Computes the intersection of this bounding box and the given one, setting the upper\n \t * bound of this box to the lesser of the two boxes' upper bounds and the\n \t * lower bound of this box to the greater of the two boxes' lower bounds. If\n \t * there's no overlap, makes this box empty.\n \t *\n \t * @param {Box3} box - The bounding box to intersect with.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tintersect( box ) {\n\n \t\tthis.min.max( box.min );\n \t\tthis.max.min( box.max );\n\n \t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n \t\tif ( this.isEmpty() ) this.makeEmpty();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the union of this box and another and the given one, setting the upper\n \t * bound of this box to the greater of the two boxes' upper bounds and the\n \t * lower bound of this box to the lesser of the two boxes' lower bounds.\n \t *\n \t * @param {Box3} box - The bounding box that will be unioned with this instance.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tunion( box ) {\n\n \t\tthis.min.min( box.min );\n \t\tthis.max.max( box.max );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Transforms this bounding box by the given 4x4 transformation matrix.\n \t *\n \t * @param {Matrix4} matrix - The transformation matrix.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tapplyMatrix4( matrix ) {\n\n \t\t// transform of empty box is an empty box.\n \t\tif ( this.isEmpty() ) return this;\n\n \t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n \t\t_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n \t\t_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n \t\t_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n \t\t_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n \t\t_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n \t\t_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n \t\t_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n \t\t_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n \t\tthis.setFromPoints( _points );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds the given offset to both the upper and lower bounds of this bounding box,\n \t * effectively moving it in 3D space.\n \t *\n \t * @param {Vector3} offset - The offset that should be used to translate the bounding box.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \ttranslate( offset ) {\n\n \t\tthis.min.add( offset );\n \t\tthis.max.add( offset );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this bounding box is equal with the given one.\n \t *\n \t * @param {Box3} box - The box to test for equality.\n \t * @return {boolean} Whether this bounding box is equal with the given one.\n \t */\n \tequals( box ) {\n\n \t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n \t}\n\n \t/**\n \t * Returns a serialized structure of the bounding box.\n \t *\n \t * @return {Object} Serialized structure with fields representing the object state.\n \t */\n \ttoJSON() {\n\n \t\treturn {\n \t\t\tmin: this.min.toArray(),\n \t\t\tmax: this.max.toArray()\n \t\t};\n\n \t}\n\n \t/**\n \t * Returns a serialized structure of the bounding box.\n \t *\n \t * @param {Object} json - The serialized json to set the box from.\n \t * @return {Box3} A reference to this bounding box.\n \t */\n \tfromJSON( json ) {\n\n \t\tthis.min.fromArray( json.min );\n \t\tthis.max.fromArray( json.max );\n \t\treturn this;\n\n \t}\n\n }\n\n const _points = [\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3(),\n \t/*@__PURE__*/ new Vector3()\n ];\n\n const _vector$b = /*@__PURE__*/ new Vector3();\n\n const _box$4 = /*@__PURE__*/ new Box3();\n\n // triangle centered vertices\n\n const _v0$1 = /*@__PURE__*/ new Vector3();\n const _v1$4 = /*@__PURE__*/ new Vector3();\n const _v2$3 = /*@__PURE__*/ new Vector3();\n\n // triangle edge vectors\n\n const _f0 = /*@__PURE__*/ new Vector3();\n const _f1 = /*@__PURE__*/ new Vector3();\n const _f2 = /*@__PURE__*/ new Vector3();\n\n const _center = /*@__PURE__*/ new Vector3();\n const _extents = /*@__PURE__*/ new Vector3();\n const _triangleNormal = /*@__PURE__*/ new Vector3();\n const _testAxis = /*@__PURE__*/ new Vector3();\n\n function satForAxes( axes, v0, v1, v2, extents ) {\n\n \tfor ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n \t\t_testAxis.fromArray( axes, i );\n \t\t// project the aabb onto the separating axis\n \t\tconst r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );\n \t\t// project all 3 vertices of the triangle onto the separating axis\n \t\tconst p0 = v0.dot( _testAxis );\n \t\tconst p1 = v1.dot( _testAxis );\n \t\tconst p2 = v2.dot( _testAxis );\n \t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n \t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n \t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n \t\t\t// the axis is separating and we can exit\n \t\t\treturn false;\n\n \t\t}\n\n \t}\n\n \treturn true;\n\n }\n\n const _vector$a = /*@__PURE__*/ new Vector3();\n const _vector2$1 = /*@__PURE__*/ new Vector2();\n\n let _id$2 = 0;\n\n /**\n * This class stores data for an attribute (such as vertex positions, face\n * indices, normals, colors, UVs, and any custom attributes ) associated with\n * a geometry, which allows for more efficient passing of data to the GPU.\n *\n * When working with vector-like data, the `fromBufferAttribute( attribute, index )`\n * helper methods on vector and color class might be helpful. E.g. {@link Vector3#fromBufferAttribute}.\n */\n class BufferAttribute extends EventDispatcher {\n\n \t/**\n \t * Constructs a new buffer attribute.\n \t *\n \t * @param {TypedArray} array - The array holding the attribute data.\n \t * @param {number} itemSize - The item size.\n \t * @param {boolean} [normalized=false] - Whether the data are normalized or not.\n \t */\n \tconstructor( array, itemSize, normalized = false ) {\n\n \t\tsuper();\n\n \t\tif ( Array.isArray( array ) ) {\n\n \t\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n \t\t}\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isBufferAttribute = true;\n\n \t\t/**\n \t\t * The ID of the buffer attribute.\n \t\t *\n \t\t * @name BufferAttribute#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _id$2 ++ } );\n\n \t\t/**\n \t\t * The name of the buffer attribute.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.name = '';\n\n \t\t/**\n \t\t * The array holding the attribute data. It should have `itemSize * numVertices`\n \t\t * elements, where `numVertices` is the number of vertices in the associated geometry.\n \t\t *\n \t\t * @type {TypedArray}\n \t\t */\n \t\tthis.array = array;\n\n \t\t/**\n \t\t * The number of values of the array that should be associated with a particular vertex.\n \t\t * For instance, if this attribute is storing a 3-component vector (such as a position,\n \t\t * normal, or color), then the value should be `3`.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.itemSize = itemSize;\n\n \t\t/**\n \t\t * Represents the number of items this buffer attribute stores. It is internally computed\n \t\t * by dividing the `array` length by the `itemSize`.\n \t\t *\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\n \t\t/**\n \t\t * Applies to integer data only. Indicates how the underlying data in the buffer maps to\n \t\t * the values in the GLSL code. For instance, if `array` is an instance of `UInt16Array`,\n \t\t * and `normalized` is `true`, the values `0 - +65535` in the array data will be mapped to\n \t\t * `0.0f - +1.0f` in the GLSL attribute. If `normalized` is `false`, the values will be converted\n \t\t * to floats unmodified, i.e. `65535` becomes `65535.0f`.\n \t\t *\n \t\t * @type {boolean}\n \t\t */\n \t\tthis.normalized = normalized;\n\n \t\t/**\n \t\t * Defines the intended usage pattern of the data store for optimization purposes.\n \t\t *\n \t\t * Note: After the initial use of a buffer, its usage cannot be changed. Instead,\n \t\t * instantiate a new one and set the desired usage before the next render.\n \t\t *\n \t\t * @type {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)}\n \t\t * @default StaticDrawUsage\n \t\t */\n \t\tthis.usage = StaticDrawUsage;\n\n \t\t/**\n \t\t * This can be used to only update some components of stored vectors (for example, just the\n \t\t * component related to color). Use the `addUpdateRange()` function to add ranges to this array.\n \t\t *\n \t\t * @type {Array<Object>}\n \t\t */\n \t\tthis.updateRanges = [];\n\n \t\t/**\n \t\t * Configures the bound GPU type for use in shaders.\n \t\t *\n \t\t * Note: this only has an effect for integer arrays and is not configurable for float arrays.\n \t\t * For lower precision float types, use `Float16BufferAttribute`.\n \t\t *\n \t\t * @type {(FloatType|IntType)}\n \t\t * @default FloatType\n \t\t */\n \t\tthis.gpuType = FloatType;\n\n \t\t/**\n \t\t * A version number, incremented every time the `needsUpdate` is set to `true`.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.version = 0;\n\n \t}\n\n \t/**\n \t * A callback function that is executed after the renderer has transferred the attribute\n \t * array data to the GPU.\n \t */\n \tonUploadCallback() {}\n\n \t/**\n \t * Flag to indicate that this attribute has changed and should be re-sent to\n \t * the GPU. Set this to `true` when you modify the value of the array.\n \t *\n \t * @type {number}\n \t * @default false\n \t * @param {boolean} value\n \t */\n \tset needsUpdate( value ) {\n\n \t\tif ( value === true ) this.version ++;\n\n \t}\n\n \t/**\n \t * Sets the usage of this buffer attribute.\n \t *\n \t * @param {(StaticDrawUsage|DynamicDrawUsage|StreamDrawUsage|StaticReadUsage|DynamicReadUsage|StreamReadUsage|StaticCopyUsage|DynamicCopyUsage|StreamCopyUsage)} value - The usage to set.\n \t * @return {BufferAttribute} A reference to this buffer attribute.\n \t */\n \tsetUsage( value ) {\n\n \t\tthis.usage = value;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Adds a range of data in the data array to be updated on the GPU.\n \t *\n \t * @param {number} start - Position at which to start update.\n \t * @param {number} count - The number of components to update.\n \t */\n \taddUpdateRange( start, count ) {\n\n \t\tthis.updateRanges.push( { start, count } );\n\n \t}\n\n \t/**\n \t * Clears the update ranges.\n \t */\n \tclearUpdateRanges() {\n\n \t\tthis.updateRanges.length = 0;\n\n \t}\n\n \t/**\n \t * Copies the values of the given buffer attribute to this instance.\n \t *\n \t * @param {BufferAttribute} source - The buffer attribute to copy.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tcopy( source ) {\n\n \t\tthis.name = source.name;\n \t\tthis.array = new source.array.constructor( source.array );\n \t\tthis.itemSize = source.itemSize;\n \t\tthis.count = source.count;\n \t\tthis.normalized = source.normalized;\n\n \t\tthis.usage = source.usage;\n \t\tthis.gpuType = source.gpuType;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies a vector from the given buffer attribute to this one. The start\n \t * and destination position in the attribute buffers are represented by the\n \t * given indices.\n \t *\n \t * @param {number} index1 - The destination index into this buffer attribute.\n \t * @param {BufferAttribute} attribute - The buffer attribute to copy from.\n \t * @param {number} index2 - The source index into the given buffer attribute.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tcopyAt( index1, attribute, index2 ) {\n\n \t\tindex1 *= this.itemSize;\n \t\tindex2 *= attribute.itemSize;\n\n \t\tfor ( let i = 0, l = this.itemSize; i < l; i ++ ) {\n\n \t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the given array data into this buffer attribute.\n \t *\n \t * @param {(TypedArray|Array)} array - The array to copy.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tcopyArray( array ) {\n\n \t\tthis.array.set( array );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given 3x3 matrix to the given attribute. Works with\n \t * item size `2` and `3`.\n \t *\n \t * @param {Matrix3} m - The matrix to apply.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tapplyMatrix3( m ) {\n\n \t\tif ( this.itemSize === 2 ) {\n\n \t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n \t\t\t\t_vector2$1.fromBufferAttribute( this, i );\n \t\t\t\t_vector2$1.applyMatrix3( m );\n\n \t\t\t\tthis.setXY( i, _vector2$1.x, _vector2$1.y );\n\n \t\t\t}\n\n \t\t} else if ( this.itemSize === 3 ) {\n\n \t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n \t\t\t\t_vector$a.fromBufferAttribute( this, i );\n \t\t\t\t_vector$a.applyMatrix3( m );\n\n \t\t\t\tthis.setXYZ( i, _vector$a.x, _vector$a.y, _vector$a.z );\n\n \t\t\t}\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given 4x4 matrix to the given attribute. Only works with\n \t * item size `3`.\n \t *\n \t * @param {Matrix4} m - The matrix to apply.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tapplyMatrix4( m ) {\n\n \t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n \t\t\t_vector$a.fromBufferAttribute( this, i );\n\n \t\t\t_vector$a.applyMatrix4( m );\n\n \t\t\tthis.setXYZ( i, _vector$a.x, _vector$a.y, _vector$a.z );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given 3x3 normal matrix to the given attribute. Only works with\n \t * item size `3`.\n \t *\n \t * @param {Matrix3} m - The normal matrix to apply.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tapplyNormalMatrix( m ) {\n\n \t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n \t\t\t_vector$a.fromBufferAttribute( this, i );\n\n \t\t\t_vector$a.applyNormalMatrix( m );\n\n \t\t\tthis.setXYZ( i, _vector$a.x, _vector$a.y, _vector$a.z );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the given 4x4 matrix to the given attribute. Only works with\n \t * item size `3` and with direction vectors.\n \t *\n \t * @param {Matrix4} m - The matrix to apply.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \ttransformDirection( m ) {\n\n \t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n \t\t\t_vector$a.fromBufferAttribute( this, i );\n\n \t\t\t_vector$a.transformDirection( m );\n\n \t\t\tthis.setXYZ( i, _vector$a.x, _vector$a.y, _vector$a.z );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given array data in the buffer attribute.\n \t *\n \t * @param {(TypedArray|Array)} value - The array data to set.\n \t * @param {number} [offset=0] - The offset in this buffer attribute's array.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tset( value, offset = 0 ) {\n\n \t\t// Matching BufferAttribute constructor, do not normalize the array.\n \t\tthis.array.set( value, offset );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the given component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} component - The component index.\n \t * @return {number} The returned value.\n \t */\n \tgetComponent( index, component ) {\n\n \t\tlet value = this.array[ index * this.itemSize + component ];\n\n \t\tif ( this.normalized ) value = denormalize( value, this.array );\n\n \t\treturn value;\n\n \t}\n\n \t/**\n \t * Sets the given value to the given component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} component - The component index.\n \t * @param {number} value - The value to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetComponent( index, component, value ) {\n\n \t\tif ( this.normalized ) value = normalize( value, this.array );\n\n \t\tthis.array[ index * this.itemSize + component ] = value;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the x component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @return {number} The x component.\n \t */\n \tgetX( index ) {\n\n \t\tlet x = this.array[ index * this.itemSize ];\n\n \t\tif ( this.normalized ) x = denormalize( x, this.array );\n\n \t\treturn x;\n\n \t}\n\n \t/**\n \t * Sets the x component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} x - The value to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetX( index, x ) {\n\n \t\tif ( this.normalized ) x = normalize( x, this.array );\n\n \t\tthis.array[ index * this.itemSize ] = x;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the y component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @return {number} The y component.\n \t */\n \tgetY( index ) {\n\n \t\tlet y = this.array[ index * this.itemSize + 1 ];\n\n \t\tif ( this.normalized ) y = denormalize( y, this.array );\n\n \t\treturn y;\n\n \t}\n\n \t/**\n \t * Sets the y component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} y - The value to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetY( index, y ) {\n\n \t\tif ( this.normalized ) y = normalize( y, this.array );\n\n \t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the z component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @return {number} The z component.\n \t */\n \tgetZ( index ) {\n\n \t\tlet z = this.array[ index * this.itemSize + 2 ];\n\n \t\tif ( this.normalized ) z = denormalize( z, this.array );\n\n \t\treturn z;\n\n \t}\n\n \t/**\n \t * Sets the z component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} z - The value to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetZ( index, z ) {\n\n \t\tif ( this.normalized ) z = normalize( z, this.array );\n\n \t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the w component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @return {number} The w component.\n \t */\n \tgetW( index ) {\n\n \t\tlet w = this.array[ index * this.itemSize + 3 ];\n\n \t\tif ( this.normalized ) w = denormalize( w, this.array );\n\n \t\treturn w;\n\n \t}\n\n \t/**\n \t * Sets the w component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} w - The value to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetW( index, w ) {\n\n \t\tif ( this.normalized ) w = normalize( w, this.array );\n\n \t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the x and y component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} x - The value for the x component to set.\n \t * @param {number} y - The value for the y component to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetXY( index, x, y ) {\n\n \t\tindex *= this.itemSize;\n\n \t\tif ( this.normalized ) {\n\n \t\t\tx = normalize( x, this.array );\n \t\t\ty = normalize( y, this.array );\n\n \t\t}\n\n \t\tthis.array[ index + 0 ] = x;\n \t\tthis.array[ index + 1 ] = y;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the x, y and z component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} x - The value for the x component to set.\n \t * @param {number} y - The value for the y component to set.\n \t * @param {number} z - The value for the z component to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetXYZ( index, x, y, z ) {\n\n \t\tindex *= this.itemSize;\n\n \t\tif ( this.normalized ) {\n\n \t\t\tx = normalize( x, this.array );\n \t\t\ty = normalize( y, this.array );\n \t\t\tz = normalize( z, this.array );\n\n \t\t}\n\n \t\tthis.array[ index + 0 ] = x;\n \t\tthis.array[ index + 1 ] = y;\n \t\tthis.array[ index + 2 ] = z;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the x, y, z and w component of the vector at the given index.\n \t *\n \t * @param {number} index - The index into the buffer attribute.\n \t * @param {number} x - The value for the x component to set.\n \t * @param {number} y - The value for the y component to set.\n \t * @param {number} z - The value for the z component to set.\n \t * @param {number} w - The value for the w component to set.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tsetXYZW( index, x, y, z, w ) {\n\n \t\tindex *= this.itemSize;\n\n \t\tif ( this.normalized ) {\n\n \t\t\tx = normalize( x, this.array );\n \t\t\ty = normalize( y, this.array );\n \t\t\tz = normalize( z, this.array );\n \t\t\tw = normalize( w, this.array );\n\n \t\t}\n\n \t\tthis.array[ index + 0 ] = x;\n \t\tthis.array[ index + 1 ] = y;\n \t\tthis.array[ index + 2 ] = z;\n \t\tthis.array[ index + 3 ] = w;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given callback function that is executed after the Renderer has transferred\n \t * the attribute array data to the GPU. Can be used to perform clean-up operations after\n \t * the upload when attribute data are not needed anymore on the CPU side.\n \t *\n \t * @param {Function} callback - The `onUpload()` callback.\n \t * @return {BufferAttribute} A reference to this instance.\n \t */\n \tonUpload( callback ) {\n\n \t\tthis.onUploadCallback = callback;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new buffer attribute with copied values from this instance.\n \t *\n \t * @return {BufferAttribute} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n \t}\n\n \t/**\n \t * Serializes the buffer attribute into JSON.\n \t *\n \t * @return {Object} A JSON object representing the serialized buffer attribute.\n \t */\n \ttoJSON() {\n\n \t\tconst data = {\n \t\t\titemSize: this.itemSize,\n \t\t\ttype: this.array.constructor.name,\n \t\t\tarray: Array.from( this.array ),\n \t\t\tnormalized: this.normalized\n \t\t};\n\n \t\tif ( this.name !== '' ) data.name = this.name;\n \t\tif ( this.usage !== StaticDrawUsage ) data.usage = this.usage;\n\n \t\treturn data;\n\n \t}\n\n \t/**\n \t * Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.\n \t */\n \tdispose() {\n\n \t\tthis.dispatchEvent( { type: 'dispose' } );\n\n \t}\n\n }\n\n /**\n * Convenient class that can be used when creating a `UInt16` buffer attribute with\n * a plain `Array` instance.\n *\n * @augments BufferAttribute\n */\n class Uint16BufferAttribute extends BufferAttribute {\n\n \t/**\n \t * Constructs a new buffer attribute.\n \t *\n \t * @param {(Array<number>|Uint16Array)} array - The array holding the attribute data.\n \t * @param {number} itemSize - The item size.\n \t * @param {boolean} [normalized=false] - Whether the data are normalized or not.\n \t */\n \tconstructor( array, itemSize, normalized ) {\n\n \t\tsuper( new Uint16Array( array ), itemSize, normalized );\n\n \t}\n\n }\n\n /**\n * Convenient class that can be used when creating a `UInt32` buffer attribute with\n * a plain `Array` instance.\n *\n * @augments BufferAttribute\n */\n class Uint32BufferAttribute extends BufferAttribute {\n\n \t/**\n \t * Constructs a new buffer attribute.\n \t *\n \t * @param {(Array<number>|Uint32Array)} array - The array holding the attribute data.\n \t * @param {number} itemSize - The item size.\n \t * @param {boolean} [normalized=false] - Whether the data are normalized or not.\n \t */\n \tconstructor( array, itemSize, normalized ) {\n\n \t\tsuper( new Uint32Array( array ), itemSize, normalized );\n\n \t}\n\n }\n\n /**\n * Convenient class that can be used when creating a `Float32` buffer attribute with\n * a plain `Array` instance.\n *\n * @augments BufferAttribute\n */\n class Float32BufferAttribute extends BufferAttribute {\n\n \t/**\n \t * Constructs a new buffer attribute.\n \t *\n \t * @param {(Array<number>|Float32Array)} array - The array holding the attribute data.\n \t * @param {number} itemSize - The item size.\n \t * @param {boolean} [normalized=false] - Whether the data are normalized or not.\n \t */\n \tconstructor( array, itemSize, normalized ) {\n\n \t\tsuper( new Float32Array( array ), itemSize, normalized );\n\n \t}\n\n }\n\n const _box$3 = /*@__PURE__*/ new Box3();\n const _v1$3 = /*@__PURE__*/ new Vector3();\n const _v2$2 = /*@__PURE__*/ new Vector3();\n\n /**\n * An analytical 3D sphere defined by a center and radius. This class is mainly\n * used as a Bounding Sphere for 3D objects.\n */\n class Sphere {\n\n \t/**\n \t * Constructs a new sphere.\n \t *\n \t * @param {Vector3} [center=(0,0,0)] - The center of the sphere\n \t * @param {number} [radius=-1] - The radius of the sphere.\n \t */\n \tconstructor( center = new Vector3(), radius = -1 ) {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isSphere = true;\n\n \t\t/**\n \t\t * The center of the sphere\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.center = center;\n\n \t\t/**\n \t\t * The radius of the sphere.\n \t\t *\n \t\t * @type {number}\n \t\t */\n \t\tthis.radius = radius;\n\n \t}\n\n \t/**\n \t * Sets the sphere's components by copying the given values.\n \t *\n \t * @param {Vector3} center - The center.\n \t * @param {number} radius - The radius.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tset( center, radius ) {\n\n \t\tthis.center.copy( center );\n \t\tthis.radius = radius;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the minimum bounding sphere for list of points.\n \t * If the optional center point is given, it is used as the sphere's\n \t * center. Otherwise, the center of the axis-aligned bounding box\n \t * encompassing the points is calculated.\n \t *\n \t * @param {Array<Vector3>} points - A list of points in 3D space.\n \t * @param {Vector3} [optionalCenter] - The center of the sphere.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tsetFromPoints( points, optionalCenter ) {\n\n \t\tconst center = this.center;\n\n \t\tif ( optionalCenter !== undefined ) {\n\n \t\t\tcenter.copy( optionalCenter );\n\n \t\t} else {\n\n \t\t\t_box$3.setFromPoints( points ).getCenter( center );\n\n \t\t}\n\n \t\tlet maxRadiusSq = 0;\n\n \t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n \t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n \t\t}\n\n \t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the values of the given sphere to this instance.\n \t *\n \t * @param {Sphere} sphere - The sphere to copy.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tcopy( sphere ) {\n\n \t\tthis.center.copy( sphere.center );\n \t\tthis.radius = sphere.radius;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if the sphere is empty (the radius set to a negative number).\n \t *\n \t * Spheres with a radius of `0` contain only their center point and are not\n \t * considered to be empty.\n \t *\n \t * @return {boolean} Whether this sphere is empty or not.\n \t */\n \tisEmpty() {\n\n \t\treturn ( this.radius < 0 );\n\n \t}\n\n \t/**\n \t * Makes this sphere empty which means in encloses a zero space in 3D.\n \t *\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tmakeEmpty() {\n\n \t\tthis.center.set( 0, 0, 0 );\n \t\tthis.radius = -1;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this sphere contains the given point inclusive of\n \t * the surface of the sphere.\n \t *\n \t * @param {Vector3} point - The point to check.\n \t * @return {boolean} Whether this sphere contains the given point or not.\n \t */\n \tcontainsPoint( point ) {\n\n \t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n \t}\n\n \t/**\n \t * Returns the closest distance from the boundary of the sphere to the\n \t * given point. If the sphere contains the point, the distance will\n \t * be negative.\n \t *\n \t * @param {Vector3} point - The point to compute the distance to.\n \t * @return {number} The distance to the point.\n \t */\n \tdistanceToPoint( point ) {\n\n \t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n \t}\n\n \t/**\n \t * Returns `true` if this sphere intersects with the given one.\n \t *\n \t * @param {Sphere} sphere - The sphere to test.\n \t * @return {boolean} Whether this sphere intersects with the given one or not.\n \t */\n \tintersectsSphere( sphere ) {\n\n \t\tconst radiusSum = this.radius + sphere.radius;\n\n \t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n \t}\n\n \t/**\n \t * Returns `true` if this sphere intersects with the given box.\n \t *\n \t * @param {Box3} box - The box to test.\n \t * @return {boolean} Whether this sphere intersects with the given box or not.\n \t */\n \tintersectsBox( box ) {\n\n \t\treturn box.intersectsSphere( this );\n\n \t}\n\n \t/**\n \t * Returns `true` if this sphere intersects with the given plane.\n \t *\n \t * @param {Plane} plane - The plane to test.\n \t * @return {boolean} Whether this sphere intersects with the given plane or not.\n \t */\n \tintersectsPlane( plane ) {\n\n \t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n \t}\n\n \t/**\n \t * Clamps a point within the sphere. If the point is outside the sphere, it\n \t * will clamp it to the closest point on the edge of the sphere. Points\n \t * already inside the sphere will not be affected.\n \t *\n \t * @param {Vector3} point - The plane to clamp.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The clamped point.\n \t */\n \tclampPoint( point, target ) {\n\n \t\tconst deltaLengthSq = this.center.distanceToSquared( point );\n\n \t\ttarget.copy( point );\n\n \t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n \t\t\ttarget.sub( this.center ).normalize();\n \t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n \t\t}\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Returns a bounding box that encloses this sphere.\n \t *\n \t * @param {Box3} target - The target box that is used to store the method's result.\n \t * @return {Box3} The bounding box that encloses this sphere.\n \t */\n \tgetBoundingBox( target ) {\n\n \t\tif ( this.isEmpty() ) {\n\n \t\t\t// Empty sphere produces empty bounding box\n \t\t\ttarget.makeEmpty();\n \t\t\treturn target;\n\n \t\t}\n\n \t\ttarget.set( this.center, this.center );\n \t\ttarget.expandByScalar( this.radius );\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Transforms this sphere with the given 4x4 transformation matrix.\n \t *\n \t * @param {Matrix4} matrix - The transformation matrix.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tapplyMatrix4( matrix ) {\n\n \t\tthis.center.applyMatrix4( matrix );\n \t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Translates the sphere's center by the given offset.\n \t *\n \t * @param {Vector3} offset - The offset.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \ttranslate( offset ) {\n\n \t\tthis.center.add( offset );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Expands the boundaries of this sphere to include the given point.\n \t *\n \t * @param {Vector3} point - The point to include.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \texpandByPoint( point ) {\n\n \t\tif ( this.isEmpty() ) {\n\n \t\t\tthis.center.copy( point );\n\n \t\t\tthis.radius = 0;\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\t_v1$3.subVectors( point, this.center );\n\n \t\tconst lengthSq = _v1$3.lengthSq();\n\n \t\tif ( lengthSq > ( this.radius * this.radius ) ) {\n\n \t\t\t// calculate the minimal sphere\n\n \t\t\tconst length = Math.sqrt( lengthSq );\n\n \t\t\tconst delta = ( length - this.radius ) * 0.5;\n\n \t\t\tthis.center.addScaledVector( _v1$3, delta / length );\n\n \t\t\tthis.radius += delta;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Expands this sphere to enclose both the original sphere and the given sphere.\n \t *\n \t * @param {Sphere} sphere - The sphere to include.\n \t * @return {Sphere} A reference to this sphere.\n \t */\n \tunion( sphere ) {\n\n \t\tif ( sphere.isEmpty() ) {\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\tif ( this.isEmpty() ) {\n\n \t\t\tthis.copy( sphere );\n\n \t\t\treturn this;\n\n \t\t}\n\n \t\tif ( this.center.equals( sphere.center ) === true ) {\n\n \t\t\t this.radius = Math.max( this.radius, sphere.radius );\n\n \t\t} else {\n\n \t\t\t_v2$2.subVectors( sphere.center, this.center ).setLength( sphere.radius );\n\n \t\t\tthis.expandByPoint( _v1$3.copy( sphere.center ).add( _v2$2 ) );\n\n \t\t\tthis.expandByPoint( _v1$3.copy( sphere.center ).sub( _v2$2 ) );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this sphere is equal with the given one.\n \t *\n \t * @param {Sphere} sphere - The sphere to test for equality.\n \t * @return {boolean} Whether this bounding sphere is equal with the given one.\n \t */\n \tequals( sphere ) {\n\n \t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n \t}\n\n \t/**\n \t * Returns a new sphere with copied values from this instance.\n \t *\n \t * @return {Sphere} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Returns a serialized structure of the bounding sphere.\n \t *\n \t * @return {Object} Serialized structure with fields representing the object state.\n \t */\n \ttoJSON() {\n\n \t\treturn {\n \t\t\tradius: this.radius,\n \t\t\tcenter: this.center.toArray()\n \t\t};\n\n \t}\n\n \t/**\n \t * Returns a serialized structure of the bounding sphere.\n \t *\n \t * @param {Object} json - The serialized json to set the sphere from.\n \t * @return {Sphere} A reference to this bounding sphere.\n \t */\n \tfromJSON( json ) {\n\n \t\tthis.radius = json.radius;\n \t\tthis.center.fromArray( json.center );\n \t\treturn this;\n\n \t}\n\n }\n\n let _id$1 = 0;\n\n const _m1 = /*@__PURE__*/ new Matrix4();\n const _obj = /*@__PURE__*/ new Object3D();\n const _offset = /*@__PURE__*/ new Vector3();\n const _box$2 = /*@__PURE__*/ new Box3();\n const _boxMorphTargets = /*@__PURE__*/ new Box3();\n const _vector$9 = /*@__PURE__*/ new Vector3();\n\n /**\n * A representation of mesh, line, or point geometry. Includes vertex\n * positions, face indices, normals, colors, UVs, and custom attributes\n * within buffers, reducing the cost of passing all this data to the GPU.\n *\n * ```js\n * const geometry = new THREE.BufferGeometry();\n * // create a simple square shape. We duplicate the top left and bottom right\n * // vertices because each vertex needs to appear once per triangle.\n * const vertices = new Float32Array( [\n * \t-1.0, -1.0, 1.0, // v0\n * \t 1.0, -1.0, 1.0, // v1\n * \t 1.0, 1.0, 1.0, // v2\n *\n * \t 1.0, 1.0, 1.0, // v3\n * \t-1.0, 1.0, 1.0, // v4\n * \t-1.0, -1.0, 1.0 // v5\n * ] );\n * // itemSize = 3 because there are 3 values (components) per vertex\n * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );\n * const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );\n * const mesh = new THREE.Mesh( geometry, material );\n * ```\n *\n * @augments EventDispatcher\n */\n class BufferGeometry extends EventDispatcher {\n\n \t/**\n \t * Constructs a new geometry.\n \t */\n \tconstructor() {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isBufferGeometry = true;\n\n \t\t/**\n \t\t * The ID of the geometry.\n \t\t *\n \t\t * @name BufferGeometry#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _id$1 ++ } );\n\n \t\t/**\n \t\t * The UUID of the geometry.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.uuid = generateUUID();\n\n \t\t/**\n \t\t * The name of the geometry.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.name = '';\n \t\tthis.type = 'BufferGeometry';\n\n \t\t/**\n \t\t * Allows for vertices to be re-used across multiple triangles; this is\n \t\t * called using \"indexed triangles\". Each triangle is associated with the\n \t\t * indices of three vertices. This attribute therefore stores the index of\n \t\t * each vertex for each triangular face. If this attribute is not set, the\n \t\t * renderer assumes that each three contiguous positions represent a single triangle.\n \t\t *\n \t\t * @type {?BufferAttribute}\n \t\t * @default null\n \t\t */\n \t\tthis.index = null;\n\n \t\t/**\n \t\t * A (storage) buffer attribute which was generated with a compute shader and\n \t\t * now defines indirect draw calls.\n \t\t *\n \t\t * Can only be used with {@link WebGPURenderer} and a WebGPU backend.\n \t\t *\n \t\t * @type {?BufferAttribute}\n \t\t * @default null\n \t\t */\n \t\tthis.indirect = null;\n\n \t\t/**\n \t\t * The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.\n \t\t *\n \t\t * Can only be used with {@link WebGPURenderer} and a WebGPU backend.\n \t\t *\n \t\t * @type {number|Array<number>}\n \t\t * @default 0\n \t\t */\n \t\tthis.indirectOffset = 0;\n\n \t\t/**\n \t\t * This dictionary has as id the name of the attribute to be set and as value\n \t\t * the buffer attribute to set it to. Rather than accessing this property directly,\n \t\t * use `setAttribute()` and `getAttribute()` to access attributes of this geometry.\n \t\t *\n \t\t * @type {Object<string,(BufferAttribute|InterleavedBufferAttribute)>}\n \t\t */\n \t\tthis.attributes = {};\n\n \t\t/**\n \t\t * This dictionary holds the morph targets of the geometry.\n \t\t *\n \t\t * Note: Once the geometry has been rendered, the morph attribute data cannot\n \t\t * be changed. You will have to call `dispose()`, and create a new geometry instance.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.morphAttributes = {};\n\n \t\t/**\n \t\t * Used to control the morph target behavior; when set to `true`, the morph\n \t\t * target data is treated as relative offsets, rather than as absolute\n \t\t * positions/normals.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.morphTargetsRelative = false;\n\n \t\t/**\n \t\t * Split the geometry into groups, each of which will be rendered in a\n \t\t * separate draw call. This allows an array of materials to be used with the geometry.\n \t\t *\n \t\t * Use `addGroup()` and `clearGroups()` to edit groups, rather than modifying this array directly.\n \t\t *\n \t\t * Every vertex and index must belong to exactly one group — groups must not share vertices or\n \t\t * indices, and must not leave vertices or indices unused.\n \t\t *\n \t\t * @type {Array<Object>}\n \t\t */\n \t\tthis.groups = [];\n\n \t\t/**\n \t\t * Bounding box for the geometry which can be calculated with `computeBoundingBox()`.\n \t\t *\n \t\t * @type {?Box3}\n \t\t * @default null\n \t\t */\n \t\tthis.boundingBox = null;\n\n \t\t/**\n \t\t * Bounding sphere for the geometry which can be calculated with `computeBoundingSphere()`.\n \t\t *\n \t\t * @type {?Sphere}\n \t\t * @default null\n \t\t */\n \t\tthis.boundingSphere = null;\n\n \t\t/**\n \t\t * Determines the part of the geometry to render. This should not be set directly,\n \t\t * instead use `setDrawRange()`.\n \t\t *\n \t\t * @type {{start:number,count:number}}\n \t\t */\n \t\tthis.drawRange = { start: 0, count: Infinity };\n\n \t\t/**\n \t\t * An object that can be used to store custom data about the geometry.\n \t\t * It should not hold references to functions as these will not be cloned.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.userData = {};\n\n \t\t/**\n \t\t * `true` when the geometry has been transformed since construction\n \t\t * (e.g. via {@link BufferGeometry#applyMatrix4}). Only relevant for\n \t\t * geometry generators (subclasses that populate `parameters`): when set,\n \t\t * {@link BufferGeometry#toJSON} omits `parameters` since they no longer\n \t\t * describe the geometry.\n \t\t *\n \t\t * @private\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis._transformed = false;\n\n \t}\n\n \t/**\n \t * Returns the index of this geometry.\n \t *\n \t * @return {?BufferAttribute} The index. Returns `null` if no index is defined.\n \t */\n \tgetIndex() {\n\n \t\treturn this.index;\n\n \t}\n\n \t/**\n \t * Sets the given index to this geometry.\n \t *\n \t * @param {Array<number>|BufferAttribute} index - The index to set.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tsetIndex( index ) {\n\n \t\tif ( Array.isArray( index ) ) {\n\n \t\t\tthis.index = new ( arrayNeedsUint32( index ) ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n \t\t} else {\n\n \t\t\tthis.index = index;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given indirect attribute to this geometry.\n \t *\n \t * @param {BufferAttribute} indirect - The attribute holding indirect draw calls.\n \t * @param {number|Array<number>} [indirectOffset=0] - The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tsetIndirect( indirect, indirectOffset = 0 ) {\n\n \t\tthis.indirect = indirect;\n \t\tthis.indirectOffset = indirectOffset;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the indirect attribute of this geometry.\n \t *\n \t * @return {?BufferAttribute} The indirect attribute. Returns `null` if no indirect attribute is defined.\n \t */\n \tgetIndirect() {\n\n \t\treturn this.indirect;\n\n \t}\n\n \t/**\n \t * Returns the buffer attribute for the given name.\n \t *\n \t * @param {string} name - The attribute name.\n \t * @return {BufferAttribute|InterleavedBufferAttribute|undefined} The buffer attribute.\n \t * Returns `undefined` if not attribute has been found.\n \t */\n \tgetAttribute( name ) {\n\n \t\treturn this.attributes[ name ];\n\n \t}\n\n \t/**\n \t * Sets the given attribute for the given name.\n \t *\n \t * @param {string} name - The attribute name.\n \t * @param {BufferAttribute|InterleavedBufferAttribute} attribute - The attribute to set.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tsetAttribute( name, attribute ) {\n\n \t\tthis.attributes[ name ] = attribute;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Deletes the attribute for the given name.\n \t *\n \t * @param {string} name - The attribute name to delete.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tdeleteAttribute( name ) {\n\n \t\tdelete this.attributes[ name ];\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this geometry has an attribute for the given name.\n \t *\n \t * @param {string} name - The attribute name.\n \t * @return {boolean} Whether this geometry has an attribute for the given name or not.\n \t */\n \thasAttribute( name ) {\n\n \t\treturn this.attributes[ name ] !== undefined;\n\n \t}\n\n \t/**\n \t * Adds a group to this geometry.\n \t *\n \t * @param {number} start - The first element in this draw call. That is the first\n \t * vertex for non-indexed geometry, otherwise the first triangle index.\n \t * @param {number} count - Specifies how many vertices (or indices) are part of this group.\n \t * @param {number} [materialIndex=0] - The material array index to use.\n \t */\n \taddGroup( start, count, materialIndex = 0 ) {\n\n \t\tthis.groups.push( {\n\n \t\t\tstart: start,\n \t\t\tcount: count,\n \t\t\tmaterialIndex: materialIndex\n\n \t\t} );\n\n \t}\n\n \t/**\n \t * Clears all groups.\n \t */\n \tclearGroups() {\n\n \t\tthis.groups = [];\n\n \t}\n\n \t/**\n \t * Sets the draw range for this geometry.\n \t *\n \t * @param {number} start - The first vertex for non-indexed geometry, otherwise the first triangle index.\n \t * @param {number} count - For non-indexed BufferGeometry, `count` is the number of vertices to render.\n \t * For indexed BufferGeometry, `count` is the number of indices to render.\n \t */\n \tsetDrawRange( start, count ) {\n\n \t\tthis.drawRange.start = start;\n \t\tthis.drawRange.count = count;\n\n \t}\n\n \t/**\n \t * Applies the given 4x4 transformation matrix to the geometry.\n \t *\n \t * @param {Matrix4} matrix - The matrix to apply.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tapplyMatrix4( matrix ) {\n\n \t\tconst position = this.attributes.position;\n\n \t\tif ( position !== undefined ) {\n\n \t\t\tposition.applyMatrix4( matrix );\n\n \t\t\tposition.needsUpdate = true;\n\n \t\t}\n\n \t\tconst normal = this.attributes.normal;\n\n \t\tif ( normal !== undefined ) {\n\n \t\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n \t\t\tnormal.applyNormalMatrix( normalMatrix );\n\n \t\t\tnormal.needsUpdate = true;\n\n \t\t}\n\n \t\tconst tangent = this.attributes.tangent;\n\n \t\tif ( tangent !== undefined ) {\n\n \t\t\ttangent.transformDirection( matrix );\n\n \t\t\ttangent.needsUpdate = true;\n\n \t\t}\n\n \t\tif ( this.boundingBox !== null ) {\n\n \t\t\tthis.computeBoundingBox();\n\n \t\t}\n\n \t\tif ( this.boundingSphere !== null ) {\n\n \t\t\tthis.computeBoundingSphere();\n\n \t\t}\n\n \t\tthis._transformed = true;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Applies the rotation represented by the Quaternion to the geometry.\n \t *\n \t * @param {Quaternion} q - The Quaternion to apply.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tapplyQuaternion( q ) {\n\n \t\t_m1.makeRotationFromQuaternion( q );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the geometry about the X axis. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#rotation} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \trotateX( angle ) {\n\n \t\t// rotate geometry around world x-axis\n\n \t\t_m1.makeRotationX( angle );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the geometry about the Y axis. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#rotation} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \trotateY( angle ) {\n\n \t\t// rotate geometry around world y-axis\n\n \t\t_m1.makeRotationY( angle );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the geometry about the Z axis. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#rotation} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {number} angle - The angle in radians.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \trotateZ( angle ) {\n\n \t\t// rotate geometry around world z-axis\n\n \t\t_m1.makeRotationZ( angle );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Translates the geometry. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#position} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {number} x - The x offset.\n \t * @param {number} y - The y offset.\n \t * @param {number} z - The z offset.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \ttranslate( x, y, z ) {\n\n \t\t// translate geometry\n\n \t\t_m1.makeTranslation( x, y, z );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Scales the geometry. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#scale} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {number} x - The x scale.\n \t * @param {number} y - The y scale.\n \t * @param {number} z - The z scale.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tscale( x, y, z ) {\n\n \t\t// scale geometry\n\n \t\t_m1.makeScale( x, y, z );\n\n \t\tthis.applyMatrix4( _m1 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Rotates the geometry to face a point in 3D space. This is typically done as a one time\n \t * operation, and not during a loop. Use {@link Object3D#lookAt} for typical\n \t * real-time mesh rotation.\n \t *\n \t * @param {Vector3} vector - The target point.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tlookAt( vector ) {\n\n \t\t_obj.lookAt( vector );\n\n \t\t_obj.updateMatrix();\n\n \t\tthis.applyMatrix4( _obj.matrix );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Center the geometry based on its bounding box.\n \t *\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tcenter() {\n\n \t\tthis.computeBoundingBox();\n\n \t\tthis.boundingBox.getCenter( _offset ).negate();\n\n \t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Defines a geometry by creating a `position` attribute based on the given array of points. The array\n \t * can hold 2D or 3D vectors. When using two-dimensional data, the `z` coordinate for all vertices is\n \t * set to `0`.\n \t *\n \t * If the method is used with an existing `position` attribute, the vertex data are overwritten with the\n \t * data from the array. The length of the array must match the vertex count.\n \t *\n \t * @param {Array<Vector2>|Array<Vector3>} points - The points.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tsetFromPoints( points ) {\n\n \t\tconst positionAttribute = this.getAttribute( 'position' );\n\n \t\tif ( positionAttribute === undefined ) {\n\n \t\t\tconst position = [];\n\n \t\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n \t\t\t\tconst point = points[ i ];\n \t\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n \t\t\t}\n\n \t\t\tthis.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n \t\t} else {\n\n \t\t\tconst l = Math.min( points.length, positionAttribute.count ); // make sure data do not exceed buffer size\n\n \t\t\tfor ( let i = 0; i < l; i ++ ) {\n\n \t\t\t\tconst point = points[ i ];\n \t\t\t\tpositionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );\n\n \t\t\t}\n\n \t\t\tif ( points.length > positionAttribute.count ) {\n\n \t\t\t\twarn( 'BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );\n\n \t\t\t}\n\n \t\t\tpositionAttribute.needsUpdate = true;\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Computes the bounding box of the geometry, and updates the `boundingBox` member.\n \t * The bounding box is not computed by the engine; it must be computed by your app.\n \t * You may need to recompute the bounding box if the geometry vertices are modified.\n \t */\n \tcomputeBoundingBox() {\n\n \t\tif ( this.boundingBox === null ) {\n\n \t\t\tthis.boundingBox = new Box3();\n\n \t\t}\n\n \t\tconst position = this.attributes.position;\n \t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n \t\tif ( position && position.isGLBufferAttribute ) {\n\n \t\t\terror( 'BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.', this );\n\n \t\t\tthis.boundingBox.set(\n \t\t\t\tnew Vector3( - Infinity, - Infinity, - Infinity ),\n \t\t\t\tnew Vector3( + Infinity, + Infinity, + Infinity )\n \t\t\t);\n\n \t\t\treturn;\n\n \t\t}\n\n \t\tif ( position !== undefined ) {\n\n \t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n \t\t\t// process morph attributes if present\n\n \t\t\tif ( morphAttributesPosition ) {\n\n \t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n \t\t\t\t\t_box$2.setFromBufferAttribute( morphAttribute );\n\n \t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n \t\t\t\t\t\t_vector$9.addVectors( this.boundingBox.min, _box$2.min );\n \t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector$9 );\n\n \t\t\t\t\t\t_vector$9.addVectors( this.boundingBox.max, _box$2.max );\n \t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector$9 );\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\tthis.boundingBox.expandByPoint( _box$2.min );\n \t\t\t\t\t\tthis.boundingBox.expandByPoint( _box$2.max );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t} else {\n\n \t\t\tthis.boundingBox.makeEmpty();\n\n \t\t}\n\n \t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n \t\t\terror( 'BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Computes the bounding sphere of the geometry, and updates the `boundingSphere` member.\n \t * The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.\n \t * You may need to recompute the bounding sphere if the geometry vertices are modified.\n \t */\n \tcomputeBoundingSphere() {\n\n \t\tif ( this.boundingSphere === null ) {\n\n \t\t\tthis.boundingSphere = new Sphere();\n\n \t\t}\n\n \t\tconst position = this.attributes.position;\n \t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n \t\tif ( position && position.isGLBufferAttribute ) {\n\n \t\t\terror( 'BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.', this );\n\n \t\t\tthis.boundingSphere.set( new Vector3(), Infinity );\n\n \t\t\treturn;\n\n \t\t}\n\n \t\tif ( position ) {\n\n \t\t\t// first, find the center of the bounding sphere\n\n \t\t\tconst center = this.boundingSphere.center;\n\n \t\t\t_box$2.setFromBufferAttribute( position );\n\n \t\t\t// process morph attributes if present\n\n \t\t\tif ( morphAttributesPosition ) {\n\n \t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n \t\t\t\t\t_boxMorphTargets.setFromBufferAttribute( morphAttribute );\n\n \t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n \t\t\t\t\t\t_vector$9.addVectors( _box$2.min, _boxMorphTargets.min );\n \t\t\t\t\t\t_box$2.expandByPoint( _vector$9 );\n\n \t\t\t\t\t\t_vector$9.addVectors( _box$2.max, _boxMorphTargets.max );\n \t\t\t\t\t\t_box$2.expandByPoint( _vector$9 );\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\t_box$2.expandByPoint( _boxMorphTargets.min );\n \t\t\t\t\t\t_box$2.expandByPoint( _boxMorphTargets.max );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\t_box$2.getCenter( center );\n\n \t\t\t// second, try to find a boundingSphere with a radius smaller than the\n \t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n \t\t\tlet maxRadiusSq = 0;\n\n \t\t\tfor ( let i = 0, il = position.count; i < il; i ++ ) {\n\n \t\t\t\t_vector$9.fromBufferAttribute( position, i );\n\n \t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$9 ) );\n\n \t\t\t}\n\n \t\t\t// process morph attributes if present\n\n \t\t\tif ( morphAttributesPosition ) {\n\n \t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n \t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n \t\t\t\t\tfor ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {\n\n \t\t\t\t\t\t_vector$9.fromBufferAttribute( morphAttribute, j );\n\n \t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n \t\t\t\t\t\t\t_offset.fromBufferAttribute( position, j );\n \t\t\t\t\t\t\t_vector$9.add( _offset );\n\n \t\t\t\t\t\t}\n\n \t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$9 ) );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n \t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n \t\t\t\terror( 'BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Calculates and adds a tangent attribute to this geometry.\n \t *\n \t * The computation is only supported for indexed geometries and if position, normal, and uv attributes\n \t * are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by\n \t * {@link BufferGeometryUtils#computeMikkTSpaceTangents} instead.\n \t */\n \tcomputeTangents() {\n\n \t\tconst index = this.index;\n \t\tconst attributes = this.attributes;\n\n \t\t// based on http://www.terathon.com/code/tangent.html\n \t\t// (per vertex tangents)\n\n \t\tif ( index === null ||\n \t\t\t attributes.position === undefined ||\n \t\t\t attributes.normal === undefined ||\n \t\t\t attributes.uv === undefined ) {\n\n \t\t\terror( 'BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)' );\n \t\t\treturn;\n\n \t\t}\n\n \t\tconst positionAttribute = attributes.position;\n \t\tconst normalAttribute = attributes.normal;\n \t\tconst uvAttribute = attributes.uv;\n\n \t\tlet tangentAttribute = this.getAttribute( 'tangent' );\n\n \t\tif ( tangentAttribute === undefined || tangentAttribute.count !== positionAttribute.count ) {\n\n \t\t\ttangentAttribute = new BufferAttribute( new Float32Array( 4 * positionAttribute.count ), 4 );\n \t\t\tthis.setAttribute( 'tangent', tangentAttribute );\n\n \t\t}\n\n \t\tconst tan1 = [], tan2 = [];\n\n \t\tfor ( let i = 0; i < positionAttribute.count; i ++ ) {\n\n \t\t\ttan1[ i ] = new Vector3();\n \t\t\ttan2[ i ] = new Vector3();\n\n \t\t}\n\n \t\tconst vA = new Vector3(),\n \t\t\tvB = new Vector3(),\n \t\t\tvC = new Vector3(),\n\n \t\t\tuvA = new Vector2(),\n \t\t\tuvB = new Vector2(),\n \t\t\tuvC = new Vector2(),\n\n \t\t\tsdir = new Vector3(),\n \t\t\ttdir = new Vector3();\n\n \t\tfunction handleTriangle( a, b, c ) {\n\n \t\t\tvA.fromBufferAttribute( positionAttribute, a );\n \t\t\tvB.fromBufferAttribute( positionAttribute, b );\n \t\t\tvC.fromBufferAttribute( positionAttribute, c );\n\n \t\t\tuvA.fromBufferAttribute( uvAttribute, a );\n \t\t\tuvB.fromBufferAttribute( uvAttribute, b );\n \t\t\tuvC.fromBufferAttribute( uvAttribute, c );\n\n \t\t\tvB.sub( vA );\n \t\t\tvC.sub( vA );\n\n \t\t\tuvB.sub( uvA );\n \t\t\tuvC.sub( uvA );\n\n \t\t\tconst r = 1.0 / ( uvB.x * uvC.y - uvC.x * uvB.y );\n\n \t\t\t// silently ignore degenerate uv triangles having coincident or colinear vertices\n\n \t\t\tif ( ! isFinite( r ) ) return;\n\n \t\t\tsdir.copy( vB ).multiplyScalar( uvC.y ).addScaledVector( vC, - uvB.y ).multiplyScalar( r );\n \t\t\ttdir.copy( vC ).multiplyScalar( uvB.x ).addScaledVector( vB, - uvC.x ).multiplyScalar( r );\n\n \t\t\ttan1[ a ].add( sdir );\n \t\t\ttan1[ b ].add( sdir );\n \t\t\ttan1[ c ].add( sdir );\n\n \t\t\ttan2[ a ].add( tdir );\n \t\t\ttan2[ b ].add( tdir );\n \t\t\ttan2[ c ].add( tdir );\n\n \t\t}\n\n \t\tlet groups = this.groups;\n\n \t\tif ( groups.length === 0 ) {\n\n \t\t\tgroups = [ {\n \t\t\t\tstart: 0,\n \t\t\t\tcount: index.count\n \t\t\t} ];\n\n \t\t}\n\n \t\tfor ( let i = 0, il = groups.length; i < il; ++ i ) {\n\n \t\t\tconst group = groups[ i ];\n\n \t\t\tconst start = group.start;\n \t\t\tconst count = group.count;\n\n \t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n \t\t\t\thandleTriangle(\n \t\t\t\t\tindex.getX( j + 0 ),\n \t\t\t\t\tindex.getX( j + 1 ),\n \t\t\t\t\tindex.getX( j + 2 )\n \t\t\t\t);\n\n \t\t\t}\n\n \t\t}\n\n \t\tconst tmp = new Vector3(), tmp2 = new Vector3();\n \t\tconst n = new Vector3(), n2 = new Vector3();\n\n \t\tfunction handleVertex( v ) {\n\n \t\t\tn.fromBufferAttribute( normalAttribute, v );\n \t\t\tn2.copy( n );\n\n \t\t\tconst t = tan1[ v ];\n\n \t\t\t// Gram-Schmidt orthogonalize\n\n \t\t\ttmp.copy( t );\n \t\t\ttmp.sub( n.multiplyScalar( n.dot( t ) ) ).normalize();\n\n \t\t\t// Calculate handedness\n\n \t\t\ttmp2.crossVectors( n2, t );\n \t\t\tconst test = tmp2.dot( tan2[ v ] );\n \t\t\tconst w = ( test < 0.0 ) ? -1 : 1.0;\n\n \t\t\ttangentAttribute.setXYZW( v, tmp.x, tmp.y, tmp.z, w );\n\n \t\t}\n\n \t\tfor ( let i = 0, il = groups.length; i < il; ++ i ) {\n\n \t\t\tconst group = groups[ i ];\n\n \t\t\tconst start = group.start;\n \t\t\tconst count = group.count;\n\n \t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n \t\t\t\thandleVertex( index.getX( j + 0 ) );\n \t\t\t\thandleVertex( index.getX( j + 1 ) );\n \t\t\t\thandleVertex( index.getX( j + 2 ) );\n\n \t\t\t}\n\n \t\t}\n\n \t\tthis._transformed = true;\n\n \t}\n\n \t/**\n \t * Computes vertex normals for the given vertex data. For indexed geometries, the method sets\n \t * each vertex normal to be the average of the face normals of the faces that share that vertex.\n \t * For non-indexed geometries, vertices are not shared, and the method sets each vertex normal\n \t * to be the same as the face normal.\n \t */\n \tcomputeVertexNormals() {\n\n \t\tconst index = this.index;\n \t\tconst positionAttribute = this.getAttribute( 'position' );\n\n \t\tif ( positionAttribute !== undefined ) {\n\n \t\t\tlet normalAttribute = this.getAttribute( 'normal' );\n\n \t\t\tif ( normalAttribute === undefined || normalAttribute.count !== positionAttribute.count ) {\n\n \t\t\t\tnormalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );\n \t\t\t\tthis.setAttribute( 'normal', normalAttribute );\n\n \t\t\t} else {\n\n \t\t\t\t// reset existing normals to zero\n\n \t\t\t\tfor ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {\n\n \t\t\t\t\tnormalAttribute.setXYZ( i, 0, 0, 0 );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tconst pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n \t\t\tconst nA = new Vector3(), nB = new Vector3(), nC = new Vector3();\n \t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n \t\t\t// indexed elements\n\n \t\t\tif ( index ) {\n\n \t\t\t\tfor ( let i = 0, il = index.count; i < il; i += 3 ) {\n\n \t\t\t\t\tconst vA = index.getX( i + 0 );\n \t\t\t\t\tconst vB = index.getX( i + 1 );\n \t\t\t\t\tconst vC = index.getX( i + 2 );\n\n \t\t\t\t\tpA.fromBufferAttribute( positionAttribute, vA );\n \t\t\t\t\tpB.fromBufferAttribute( positionAttribute, vB );\n \t\t\t\t\tpC.fromBufferAttribute( positionAttribute, vC );\n\n \t\t\t\t\tcb.subVectors( pC, pB );\n \t\t\t\t\tab.subVectors( pA, pB );\n \t\t\t\t\tcb.cross( ab );\n\n \t\t\t\t\tnA.fromBufferAttribute( normalAttribute, vA );\n \t\t\t\t\tnB.fromBufferAttribute( normalAttribute, vB );\n \t\t\t\t\tnC.fromBufferAttribute( normalAttribute, vC );\n\n \t\t\t\t\tnA.add( cb );\n \t\t\t\t\tnB.add( cb );\n \t\t\t\t\tnC.add( cb );\n\n \t\t\t\t\tnormalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );\n \t\t\t\t\tnormalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );\n \t\t\t\t\tnormalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n \t\t\t\tfor ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {\n\n \t\t\t\t\tpA.fromBufferAttribute( positionAttribute, i + 0 );\n \t\t\t\t\tpB.fromBufferAttribute( positionAttribute, i + 1 );\n \t\t\t\t\tpC.fromBufferAttribute( positionAttribute, i + 2 );\n\n \t\t\t\t\tcb.subVectors( pC, pB );\n \t\t\t\t\tab.subVectors( pA, pB );\n \t\t\t\t\tcb.cross( ab );\n\n \t\t\t\t\tnormalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );\n \t\t\t\t\tnormalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );\n \t\t\t\t\tnormalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tthis.normalizeNormals();\n\n \t\t\tnormalAttribute.needsUpdate = true;\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Ensures every normal vector in a geometry will have a magnitude of `1`. This will\n \t * correct lighting on the geometry surfaces.\n \t */\n \tnormalizeNormals() {\n\n \t\tconst normals = this.attributes.normal;\n\n \t\tfor ( let i = 0, il = normals.count; i < il; i ++ ) {\n\n \t\t\t_vector$9.fromBufferAttribute( normals, i );\n\n \t\t\t_vector$9.normalize();\n\n \t\t\tnormals.setXYZ( i, _vector$9.x, _vector$9.y, _vector$9.z );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Return a new non-index version of this indexed geometry. If the geometry\n \t * is already non-indexed, the method is a NOOP.\n \t *\n \t * @return {BufferGeometry} The non-indexed version of this indexed geometry.\n \t */\n \ttoNonIndexed() {\n\n \t\tfunction convertBufferAttribute( attribute, indices ) {\n\n \t\t\tconst array = attribute.array;\n \t\t\tconst itemSize = attribute.itemSize;\n \t\t\tconst normalized = attribute.normalized;\n\n \t\t\tconst array2 = new array.constructor( indices.length * itemSize );\n\n \t\t\tlet index = 0, index2 = 0;\n\n \t\t\tfor ( let i = 0, l = indices.length; i < l; i ++ ) {\n\n \t\t\t\tif ( attribute.isInterleavedBufferAttribute ) {\n\n \t\t\t\t\tindex = indices[ i ] * attribute.data.stride + attribute.offset;\n\n \t\t\t\t} else {\n\n \t\t\t\t\tindex = indices[ i ] * itemSize;\n\n \t\t\t\t}\n\n \t\t\t\tfor ( let j = 0; j < itemSize; j ++ ) {\n\n \t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\treturn new BufferAttribute( array2, itemSize, normalized );\n\n \t\t}\n\n \t\t//\n\n \t\tif ( this.index === null ) {\n\n \t\t\twarn( 'BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.' );\n \t\t\treturn this;\n\n \t\t}\n\n \t\tconst geometry2 = new BufferGeometry();\n\n \t\tconst indices = this.index.array;\n \t\tconst attributes = this.attributes;\n\n \t\t// attributes\n\n \t\tfor ( const name in attributes ) {\n\n \t\t\tconst attribute = attributes[ name ];\n\n \t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n \t\t\tgeometry2.setAttribute( name, newAttribute );\n\n \t\t}\n\n \t\t// morph attributes\n\n \t\tconst morphAttributes = this.morphAttributes;\n\n \t\tfor ( const name in morphAttributes ) {\n\n \t\t\tconst morphArray = [];\n \t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n \t\t\tfor ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {\n\n \t\t\t\tconst attribute = morphAttribute[ i ];\n\n \t\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n \t\t\t\tmorphArray.push( newAttribute );\n\n \t\t\t}\n\n \t\t\tgeometry2.morphAttributes[ name ] = morphArray;\n\n \t\t}\n\n \t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative;\n\n \t\t// groups\n\n \t\tconst groups = this.groups;\n\n \t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n \t\t\tconst group = groups[ i ];\n \t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n \t\t}\n\n \t\treturn geometry2;\n\n \t}\n\n \t/**\n \t * Serializes the geometry into JSON.\n \t *\n \t * @return {Object} A JSON object representing the serialized geometry.\n \t */\n \ttoJSON() {\n\n \t\tconst data = {\n \t\t\tmetadata: {\n \t\t\t\tversion: 4.7,\n \t\t\t\ttype: 'BufferGeometry',\n \t\t\t\tgenerator: 'BufferGeometry.toJSON'\n \t\t\t}\n \t\t};\n\n \t\t// standard BufferGeometry serialization\n\n \t\tdata.uuid = this.uuid;\n \t\tdata.type = ( this.parameters !== undefined && this._transformed === true ) ? 'BufferGeometry' : this.type;\n \t\tif ( this.name !== '' ) data.name = this.name;\n \t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n \t\tif ( this.parameters !== undefined && this._transformed !== true ) {\n\n \t\t\tconst parameters = this.parameters;\n\n \t\t\tfor ( const key in parameters ) {\n\n \t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n \t\t\t}\n\n \t\t\treturn data;\n\n \t\t}\n\n \t\t// for simplicity the code assumes attributes are not shared across geometries, see #15811\n\n \t\tdata.data = { attributes: {} };\n\n \t\tconst index = this.index;\n\n \t\tif ( index !== null ) {\n\n \t\t\tdata.data.index = {\n \t\t\t\ttype: index.array.constructor.name,\n \t\t\t\tarray: Array.prototype.slice.call( index.array )\n \t\t\t};\n\n \t\t}\n\n \t\tconst attributes = this.attributes;\n\n \t\tfor ( const key in attributes ) {\n\n \t\t\tconst attribute = attributes[ key ];\n\n \t\t\tdata.data.attributes[ key ] = attribute.toJSON( data.data );\n\n \t\t}\n\n \t\tconst morphAttributes = {};\n \t\tlet hasMorphAttributes = false;\n\n \t\tfor ( const key in this.morphAttributes ) {\n\n \t\t\tconst attributeArray = this.morphAttributes[ key ];\n\n \t\t\tconst array = [];\n\n \t\t\tfor ( let i = 0, il = attributeArray.length; i < il; i ++ ) {\n\n \t\t\t\tconst attribute = attributeArray[ i ];\n\n \t\t\t\tarray.push( attribute.toJSON( data.data ) );\n\n \t\t\t}\n\n \t\t\tif ( array.length > 0 ) {\n\n \t\t\t\tmorphAttributes[ key ] = array;\n\n \t\t\t\thasMorphAttributes = true;\n\n \t\t\t}\n\n \t\t}\n\n \t\tif ( hasMorphAttributes ) {\n\n \t\t\tdata.data.morphAttributes = morphAttributes;\n \t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\n \t\t}\n\n \t\tconst groups = this.groups;\n\n \t\tif ( groups.length > 0 ) {\n\n \t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n \t\t}\n\n \t\tconst boundingSphere = this.boundingSphere;\n\n \t\tif ( boundingSphere !== null ) {\n\n \t\t\tdata.data.boundingSphere = boundingSphere.toJSON();\n\n \t\t}\n\n \t\treturn data;\n\n \t}\n\n \t/**\n \t * Returns a new geometry with copied values from this instance.\n \t *\n \t * @return {BufferGeometry} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Copies the values of the given geometry to this instance.\n \t *\n \t * @param {BufferGeometry} source - The geometry to copy.\n \t * @return {BufferGeometry} A reference to this instance.\n \t */\n \tcopy( source ) {\n\n \t\t// reset\n\n \t\tthis.index = null;\n \t\tthis.attributes = {};\n \t\tthis.morphAttributes = {};\n \t\tthis.groups = [];\n \t\tthis.boundingBox = null;\n \t\tthis.boundingSphere = null;\n\n \t\t// used for storing cloned, shared data\n\n \t\tconst data = {};\n\n \t\t// name\n\n \t\tthis.name = source.name;\n\n \t\t// index\n\n \t\tconst index = source.index;\n\n \t\tif ( index !== null ) {\n\n \t\t\tthis.setIndex( index.clone() );\n\n \t\t}\n\n \t\t// attributes\n\n \t\tconst attributes = source.attributes;\n\n \t\tfor ( const name in attributes ) {\n\n \t\t\tconst attribute = attributes[ name ];\n \t\t\tthis.setAttribute( name, attribute.clone( data ) );\n\n \t\t}\n\n \t\t// morph attributes\n\n \t\tconst morphAttributes = source.morphAttributes;\n\n \t\tfor ( const name in morphAttributes ) {\n\n \t\t\tconst array = [];\n \t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n \t\t\tfor ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n \t\t\t\tarray.push( morphAttribute[ i ].clone( data ) );\n\n \t\t\t}\n\n \t\t\tthis.morphAttributes[ name ] = array;\n\n \t\t}\n\n \t\tthis.morphTargetsRelative = source.morphTargetsRelative;\n\n \t\t// groups\n\n \t\tconst groups = source.groups;\n\n \t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n \t\t\tconst group = groups[ i ];\n \t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n \t\t}\n\n \t\t// bounding box\n\n \t\tconst boundingBox = source.boundingBox;\n\n \t\tif ( boundingBox !== null ) {\n\n \t\t\tthis.boundingBox = boundingBox.clone();\n\n \t\t}\n\n \t\t// bounding sphere\n\n \t\tconst boundingSphere = source.boundingSphere;\n\n \t\tif ( boundingSphere !== null ) {\n\n \t\t\tthis.boundingSphere = boundingSphere.clone();\n\n \t\t}\n\n \t\t// draw range\n\n \t\tthis.drawRange.start = source.drawRange.start;\n \t\tthis.drawRange.count = source.drawRange.count;\n\n \t\t// user data\n\n \t\tthis.userData = source.userData;\n\n \t\t// transformed flag\n\n \t\tthis._transformed = source._transformed;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Frees the GPU-related resources allocated by this instance. Call this\n \t * method whenever this instance is no longer used in your app.\n \t *\n \t * @fires BufferGeometry#dispose\n \t */\n \tdispose() {\n\n \t\tthis.dispatchEvent( { type: 'dispose' } );\n\n \t}\n\n }\n\n let _materialId = 0;\n\n /**\n * Abstract base class for materials.\n *\n * Materials define the appearance of renderable 3D objects.\n *\n * @abstract\n * @augments EventDispatcher\n */\n class Material extends EventDispatcher {\n\n \t/**\n \t * Constructs a new material.\n \t */\n \tconstructor() {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isMaterial = true;\n\n \t\t/**\n \t\t * The ID of the material.\n \t\t *\n \t\t * @name Material#id\n \t\t * @type {number}\n \t\t * @readonly\n \t\t */\n \t\tObject.defineProperty( this, 'id', { value: _materialId ++ } );\n\n \t\t/**\n \t\t * The UUID of the material.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.uuid = generateUUID();\n\n \t\t/**\n \t\t * The name of the material.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.name = '';\n\n \t\t/**\n \t\t * The type property is used for detecting the object type\n \t\t * in context of serialization/deserialization.\n \t\t *\n \t\t * @type {string}\n \t\t * @readonly\n \t\t */\n \t\tthis.type = 'Material';\n\n \t\t/**\n \t\t * Defines the blending type of the material.\n \t\t *\n \t\t * It must be set to `CustomBlending` if custom blending properties like\n \t\t * {@link Material#blendSrc}, {@link Material#blendDst} or {@link Material#blendEquation}\n \t\t * should have any effect.\n \t\t *\n \t\t * @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending)}\n \t\t * @default NormalBlending\n \t\t */\n \t\tthis.blending = NormalBlending;\n\n \t\t/**\n \t\t * Defines which side of faces will be rendered - front, back or both.\n \t\t *\n \t\t * @type {(FrontSide|BackSide|DoubleSide)}\n \t\t * @default FrontSide\n \t\t */\n \t\tthis.side = FrontSide;\n\n \t\t/**\n \t\t * If set to `true`, vertex colors should be used.\n \t\t *\n \t\t * The engine supports RGB and RGBA vertex colors depending on whether a three (RGB) or\n \t\t * four (RGBA) component color buffer attribute is used.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.vertexColors = false;\n\n \t\t/**\n \t\t * Defines how transparent the material is.\n \t\t * A value of `0.0` indicates fully transparent, `1.0` is fully opaque.\n \t\t *\n \t\t * If the {@link Material#transparent} is not set to `true`,\n \t\t * the material will remain fully opaque and this value will only affect its color.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.opacity = 1;\n\n \t\t/**\n \t\t * Defines whether this material is transparent. This has an effect on\n \t\t * rendering as transparent objects need special treatment and are rendered\n \t\t * after non-transparent objects.\n \t\t *\n \t\t * When set to true, the extent to which the material is transparent is\n \t\t * controlled by {@link Material#opacity}.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.transparent = false;\n\n \t\t/**\n \t\t * Enables alpha hashed transparency, an alternative to {@link Material#transparent} or\n \t\t * {@link Material#alphaTest}. The material will not be rendered if opacity is lower than\n \t\t * a random threshold. Randomization introduces some grain or noise, but approximates alpha\n \t\t * blending without the associated problems of sorting. Using TAA can reduce the resulting noise.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.alphaHash = false;\n\n \t\t/**\n \t\t * Defines the blending source factor.\n \t\t *\n \t\t * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}\n \t\t * @default SrcAlphaFactor\n \t\t */\n \t\tthis.blendSrc = SrcAlphaFactor;\n\n \t\t/**\n \t\t * Defines the blending destination factor.\n \t\t *\n \t\t * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}\n \t\t * @default OneMinusSrcAlphaFactor\n \t\t */\n \t\tthis.blendDst = OneMinusSrcAlphaFactor;\n\n \t\t/**\n \t\t * Defines the blending equation.\n \t\t *\n \t\t * @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}\n \t\t * @default AddEquation\n \t\t */\n \t\tthis.blendEquation = AddEquation;\n\n \t\t/**\n \t\t * Defines the blending source alpha factor.\n \t\t *\n \t\t * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}\n \t\t * @default null\n \t\t */\n \t\tthis.blendSrcAlpha = null;\n\n \t\t/**\n \t\t * Defines the blending destination alpha factor.\n \t\t *\n \t\t * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}\n \t\t * @default null\n \t\t */\n \t\tthis.blendDstAlpha = null;\n\n \t\t/**\n \t\t * Defines the blending equation of the alpha channel.\n \t\t *\n \t\t * @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}\n \t\t * @default null\n \t\t */\n \t\tthis.blendEquationAlpha = null;\n\n \t\t/**\n \t\t * Represents the RGB values of the constant blend color.\n \t\t *\n \t\t * This property has only an effect when using custom blending with `ConstantColor` or `OneMinusConstantColor`.\n \t\t *\n \t\t * @type {Color}\n \t\t * @default (0,0,0)\n \t\t */\n \t\tthis.blendColor = new Color( 0, 0, 0 );\n\n \t\t/**\n \t\t * Represents the alpha value of the constant blend color.\n \t\t *\n \t\t * This property has only an effect when using custom blending with `ConstantAlpha` or `OneMinusConstantAlpha`.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.blendAlpha = 0;\n\n \t\t/**\n \t\t * Defines the depth function.\n \t\t *\n \t\t * @type {(NeverDepth|AlwaysDepth|LessDepth|LessEqualDepth|EqualDepth|GreaterEqualDepth|GreaterDepth|NotEqualDepth)}\n \t\t * @default LessEqualDepth\n \t\t */\n \t\tthis.depthFunc = LessEqualDepth;\n\n \t\t/**\n \t\t * Whether to have depth test enabled when rendering this material.\n \t\t * When the depth test is disabled, the depth write will also be implicitly disabled.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.depthTest = true;\n\n \t\t/**\n \t\t * Whether rendering this material has any effect on the depth buffer.\n \t\t *\n \t\t * When drawing 2D overlays it can be useful to disable the depth writing in\n \t\t * order to layer several things together without creating z-index artifacts.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.depthWrite = true;\n\n \t\t/**\n \t\t * The bit mask to use when writing to the stencil buffer.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0xff\n \t\t */\n \t\tthis.stencilWriteMask = 0xff;\n\n \t\t/**\n \t\t * The stencil comparison function to use.\n \t\t *\n \t\t * @type {NeverStencilFunc|LessStencilFunc|EqualStencilFunc|LessEqualStencilFunc|GreaterStencilFunc|NotEqualStencilFunc|GreaterEqualStencilFunc|AlwaysStencilFunc}\n \t\t * @default AlwaysStencilFunc\n \t\t */\n \t\tthis.stencilFunc = AlwaysStencilFunc;\n\n \t\t/**\n \t\t * The value to use when performing stencil comparisons or stencil operations.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.stencilRef = 0;\n\n \t\t/**\n \t\t * The bit mask to use when comparing against the stencil buffer.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0xff\n \t\t */\n \t\tthis.stencilFuncMask = 0xff;\n\n \t\t/**\n \t\t * Which stencil operation to perform when the comparison function returns `false`.\n \t\t *\n \t\t * @type {ZeroStencilOp|KeepStencilOp|ReplaceStencilOp|IncrementStencilOp|DecrementStencilOp|IncrementWrapStencilOp|DecrementWrapStencilOp|InvertStencilOp}\n \t\t * @default KeepStencilOp\n \t\t */\n \t\tthis.stencilFail = KeepStencilOp;\n\n \t\t/**\n \t\t * Which stencil operation to perform when the comparison function returns\n \t\t * `true` but the depth test fails.\n \t\t *\n \t\t * @type {ZeroStencilOp|KeepStencilOp|ReplaceStencilOp|IncrementStencilOp|DecrementStencilOp|IncrementWrapStencilOp|DecrementWrapStencilOp|InvertStencilOp}\n \t\t * @default KeepStencilOp\n \t\t */\n \t\tthis.stencilZFail = KeepStencilOp;\n\n \t\t/**\n \t\t * Which stencil operation to perform when the comparison function returns\n \t\t * `true` and the depth test passes.\n \t\t *\n \t\t * @type {ZeroStencilOp|KeepStencilOp|ReplaceStencilOp|IncrementStencilOp|DecrementStencilOp|IncrementWrapStencilOp|DecrementWrapStencilOp|InvertStencilOp}\n \t\t * @default KeepStencilOp\n \t\t */\n \t\tthis.stencilZPass = KeepStencilOp;\n\n \t\t/**\n \t\t * Whether stencil operations are performed against the stencil buffer. In\n \t\t * order to perform writes or comparisons against the stencil buffer this\n \t\t * value must be `true`.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.stencilWrite = false;\n\n \t\t/**\n \t\t * User-defined clipping planes specified as THREE.Plane objects in world\n \t\t * space. These planes apply to the objects this material is attached to.\n \t\t * Points in space whose signed distance to the plane is negative are clipped\n \t\t * (not rendered). This requires {@link WebGLRenderer#localClippingEnabled} to\n \t\t * be `true`.\n \t\t *\n \t\t * @type {?Array<Plane>}\n \t\t * @default null\n \t\t */\n \t\tthis.clippingPlanes = null;\n\n \t\t/**\n \t\t * Changes the behavior of clipping planes so that only their intersection is\n \t\t * clipped, rather than their union.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.clipIntersection = false;\n\n \t\t/**\n \t\t * Defines whether to clip shadows according to the clipping planes specified\n \t\t * on this material.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.clipShadows = false;\n\n \t\t/**\n \t\t * Defines which side of faces cast shadows. If `null`, the side casting shadows\n \t\t * is determined as follows:\n \t\t *\n \t\t * - When {@link Material#side} is set to `FrontSide`, the back side cast shadows.\n \t\t * - When {@link Material#side} is set to `BackSide`, the front side cast shadows.\n \t\t * - When {@link Material#side} is set to `DoubleSide`, both sides cast shadows.\n \t\t *\n \t\t * @type {?(FrontSide|BackSide|DoubleSide)}\n \t\t * @default null\n \t\t */\n \t\tthis.shadowSide = null;\n\n \t\t/**\n \t\t * Whether to render the material's color.\n \t\t *\n \t\t * This can be used in conjunction with {@link Object3D#renderOder} to create invisible\n \t\t * objects that occlude other objects.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.colorWrite = true;\n\n \t\t/**\n \t\t * Override the renderer's default precision for this material.\n \t\t *\n \t\t * @type {?('highp'|'mediump'|'lowp')}\n \t\t * @default null\n \t\t */\n \t\tthis.precision = null;\n\n \t\t/**\n \t\t * Whether to use polygon offset or not. When enabled, each fragment's depth value will\n \t\t * be offset after it is interpolated from the depth values of the appropriate vertices.\n \t\t * The offset is added before the depth test is performed and before the value is written\n \t\t * into the depth buffer.\n \t\t *\n \t\t * Can be useful for rendering hidden-line images, for applying decals to surfaces, and for\n \t\t * rendering solids with highlighted edges.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.polygonOffset = false;\n\n \t\t/**\n \t\t * Specifies a scale factor that is used to create a variable depth offset for each polygon.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.polygonOffsetFactor = 0;\n\n \t\t/**\n \t\t * Is multiplied by an implementation-specific value to create a constant depth offset.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.polygonOffsetUnits = 0;\n\n \t\t/**\n \t\t * Whether to apply dithering to the color to remove the appearance of banding.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.dithering = false;\n\n \t\t/**\n \t\t * Whether alpha to coverage should be enabled or not. Can only be used with MSAA-enabled contexts\n \t\t * (meaning when the renderer was created with *antialias* parameter set to `true`). Enabling this\n \t\t * will smooth aliasing on clip plane edges and alphaTest-clipped edges.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.alphaToCoverage = false;\n\n \t\t/**\n \t\t * Whether to premultiply the alpha (transparency) value.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.premultipliedAlpha = false;\n\n \t\t/**\n \t\t * Whether double-sided, transparent objects should be rendered with a single pass or not.\n \t\t *\n \t\t * The engine renders double-sided, transparent objects with two draw calls (back faces first,\n \t\t * then front faces) to mitigate transparency artifacts. There are scenarios however where this\n \t\t * approach produces no quality gains but still doubles draw calls e.g. when rendering flat\n \t\t * vegetation like grass sprites. In these cases, set the `forceSinglePass` flag to `true` to\n \t\t * disable the two pass rendering to avoid performance issues.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.forceSinglePass = false;\n\n \t\t/**\n \t\t * Whether it's possible to override the material with {@link Scene#overrideMaterial} or not.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.allowOverride = true;\n\n \t\t/**\n \t\t * Defines whether 3D objects using this material are visible.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.visible = true;\n\n \t\t/**\n \t\t * Defines whether this material is tone mapped according to the renderer's tone mapping setting.\n \t\t *\n \t\t * It is ignored when rendering to a render target or using post processing or when using\n \t\t * `WebGPURenderer`. In all these cases, all materials are honored by tone mapping.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.toneMapped = true;\n\n \t\t/**\n \t\t * An object that can be used to store custom data about the Material. It\n \t\t * should not hold references to functions as these will not be cloned.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.userData = {};\n\n \t\t/**\n \t\t * This starts at `0` and counts how many times {@link Material#needsUpdate} is set to `true`.\n \t\t *\n \t\t * @type {number}\n \t\t * @readonly\n \t\t * @default 0\n \t\t */\n \t\tthis.version = 0;\n\n \t\tthis._alphaTest = 0;\n\n \t}\n\n \t/**\n \t * Sets the alpha value to be used when running an alpha test. The material\n \t * will not be rendered if the opacity is lower than this value.\n \t *\n \t * @type {number}\n \t * @readonly\n \t * @default 0\n \t */\n \tget alphaTest() {\n\n \t\treturn this._alphaTest;\n\n \t}\n\n \tset alphaTest( value ) {\n\n \t\tif ( this._alphaTest > 0 !== value > 0 ) {\n\n \t\t\tthis.version ++;\n\n \t\t}\n\n \t\tthis._alphaTest = value;\n\n \t}\n\n \t/**\n \t * An optional callback that is executed immediately before the material is used to render a 3D object.\n \t *\n \t * This method can only be used when rendering with {@link WebGLRenderer}.\n \t *\n \t * @param {WebGLRenderer} renderer - The renderer.\n \t * @param {Scene} scene - The scene.\n \t * @param {Camera} camera - The camera that is used to render the scene.\n \t * @param {BufferGeometry} geometry - The 3D object's geometry.\n \t * @param {Object3D} object - The 3D object.\n \t * @param {Object} group - The geometry group data.\n \t */\n \tonBeforeRender( /* renderer, scene, camera, geometry, object, group */ ) {}\n\n \t/**\n \t * An optional callback that is executed immediately before the shader\n \t * program is compiled. This function is called with the shader source code\n \t * as a parameter. Useful for the modification of built-in materials.\n \t *\n \t * This method can only be used when rendering with {@link WebGLRenderer}. The\n \t * recommended approach when customizing materials is to use `WebGPURenderer` with the new\n \t * Node Material system and [TSL](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language).\n \t *\n \t * @param {{vertexShader:string,fragmentShader:string,uniforms:Object}} shaderobject - The object holds the uniforms and the vertex and fragment shader source.\n \t * @param {WebGLRenderer} renderer - A reference to the renderer.\n \t */\n \tonBeforeCompile( /* shaderobject, renderer */ ) {}\n\n \t/**\n \t * In case {@link Material#onBeforeCompile} is used, this callback can be used to identify\n \t * values of settings used in `onBeforeCompile()`, so three.js can reuse a cached\n \t * shader or recompile the shader for this material as needed.\n \t *\n \t * This method can only be used when rendering with {@link WebGLRenderer}.\n \t *\n \t * @return {string} The custom program cache key.\n \t */\n \tcustomProgramCacheKey() {\n\n \t\treturn this.onBeforeCompile.toString();\n\n \t}\n\n \t/**\n \t * This method can be used to set default values from parameter objects.\n \t * It is a generic implementation so it can be used with different types\n \t * of materials.\n \t *\n \t * @param {Object} [values] - The material values to set.\n \t */\n \tsetValues( values ) {\n\n \t\tif ( values === undefined ) return;\n\n \t\tfor ( const key in values ) {\n\n \t\t\tconst newValue = values[ key ];\n\n \t\t\tif ( newValue === undefined ) {\n\n \t\t\t\twarn( `Material: parameter '${ key }' has value of undefined.` );\n \t\t\t\tcontinue;\n\n \t\t\t}\n\n \t\t\tconst currentValue = this[ key ];\n\n \t\t\tif ( currentValue === undefined ) {\n\n \t\t\t\twarn( `Material: '${ key }' is not a property of THREE.${ this.type }.` );\n \t\t\t\tcontinue;\n\n \t\t\t}\n\n \t\t\tif ( currentValue && currentValue.isColor ) {\n\n \t\t\t\tcurrentValue.set( newValue );\n\n \t\t\t} else if (\n \t\t\t\t( ( currentValue && currentValue.isVector2 ) && ( newValue && newValue.isVector2 ) ) ||\n \t\t\t\t( ( currentValue && currentValue.isEuler ) && ( newValue && newValue.isEuler ) ) ||\n \t\t\t\t( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) )\n \t\t\t) {\n\n \t\t\t\tcurrentValue.copy( newValue );\n\n \t\t\t} else {\n\n \t\t\t\tthis[ key ] = newValue;\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Serializes the material into JSON.\n \t *\n \t * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.\n \t * @return {Object} A JSON object representing the serialized material.\n \t * @see {@link ObjectLoader#parse}\n \t */\n \ttoJSON( meta ) {\n\n \t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n \t\tif ( isRootObject ) {\n\n \t\t\tmeta = {\n \t\t\t\ttextures: {},\n \t\t\t\timages: {}\n \t\t\t};\n\n \t\t}\n\n \t\tconst data = {\n \t\t\tmetadata: {\n \t\t\t\tversion: 4.7,\n \t\t\t\ttype: 'Material',\n \t\t\t\tgenerator: 'Material.toJSON'\n \t\t\t}\n \t\t};\n\n \t\t// standard Material serialization\n \t\tdata.uuid = this.uuid;\n \t\tdata.type = this.type;\n\n \t\tif ( this.name !== '' ) data.name = this.name;\n\n \t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n \t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n \t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n \t\tif ( this.sheen !== undefined ) data.sheen = this.sheen;\n \t\tif ( this.sheenColor && this.sheenColor.isColor ) data.sheenColor = this.sheenColor.getHex();\n \t\tif ( this.sheenRoughness !== undefined ) data.sheenRoughness = this.sheenRoughness;\n \t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n \t\tif ( this.emissiveIntensity !== undefined && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n \t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n \t\tif ( this.specularIntensity !== undefined ) data.specularIntensity = this.specularIntensity;\n \t\tif ( this.specularColor && this.specularColor.isColor ) data.specularColor = this.specularColor.getHex();\n \t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n \t\tif ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;\n \t\tif ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;\n\n \t\tif ( this.clearcoatMap && this.clearcoatMap.isTexture ) {\n\n \t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {\n\n \t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {\n\n \t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;\n \t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\n \t\t}\n\n \t\tif ( this.sheenColorMap && this.sheenColorMap.isTexture ) {\n\n \t\t\tdata.sheenColorMap = this.sheenColorMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture ) {\n\n \t\t\tdata.sheenRoughnessMap = this.sheenRoughnessMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.dispersion !== undefined ) data.dispersion = this.dispersion;\n\n \t\tif ( this.iridescence !== undefined ) data.iridescence = this.iridescence;\n \t\tif ( this.iridescenceIOR !== undefined ) data.iridescenceIOR = this.iridescenceIOR;\n \t\tif ( this.iridescenceThicknessRange !== undefined ) data.iridescenceThicknessRange = this.iridescenceThicknessRange;\n\n \t\tif ( this.iridescenceMap && this.iridescenceMap.isTexture ) {\n\n \t\t\tdata.iridescenceMap = this.iridescenceMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture ) {\n\n \t\t\tdata.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.anisotropy !== undefined ) data.anisotropy = this.anisotropy;\n \t\tif ( this.anisotropyRotation !== undefined ) data.anisotropyRotation = this.anisotropyRotation;\n\n \t\tif ( this.anisotropyMap && this.anisotropyMap.isTexture ) {\n\n \t\t\tdata.anisotropyMap = this.anisotropyMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n \t\tif ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;\n \t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\n \t\tif ( this.lightMap && this.lightMap.isTexture ) {\n\n \t\t\tdata.lightMap = this.lightMap.toJSON( meta ).uuid;\n \t\t\tdata.lightMapIntensity = this.lightMapIntensity;\n\n \t\t}\n\n \t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n \t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n \t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n \t\t}\n\n \t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n \t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n \t\t\tdata.bumpScale = this.bumpScale;\n\n \t\t}\n\n \t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n \t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n \t\t\tdata.normalMapType = this.normalMapType;\n \t\t\tdata.normalScale = this.normalScale.toArray();\n\n \t\t}\n\n \t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n \t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n \t\t\tdata.displacementScale = this.displacementScale;\n \t\t\tdata.displacementBias = this.displacementBias;\n\n \t\t}\n\n \t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n \t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n \t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n \t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n \t\tif ( this.specularIntensityMap && this.specularIntensityMap.isTexture ) data.specularIntensityMap = this.specularIntensityMap.toJSON( meta ).uuid;\n \t\tif ( this.specularColorMap && this.specularColorMap.isTexture ) data.specularColorMap = this.specularColorMap.toJSON( meta ).uuid;\n\n \t\tif ( this.envMap && this.envMap.isTexture ) {\n\n \t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\n \t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\n \t\t}\n\n \t\tif ( this.envMapRotation !== undefined ) data.envMapRotation = this.envMapRotation.toArray();\n \t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n \t\tif ( this.reflectivity !== undefined ) data.reflectivity = this.reflectivity;\n \t\tif ( this.refractionRatio !== undefined ) data.refractionRatio = this.refractionRatio;\n\n \t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n \t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n \t\t}\n\n \t\tif ( this.transmission !== undefined ) data.transmission = this.transmission;\n \t\tif ( this.transmissionMap && this.transmissionMap.isTexture ) data.transmissionMap = this.transmissionMap.toJSON( meta ).uuid;\n \t\tif ( this.thickness !== undefined ) data.thickness = this.thickness;\n \t\tif ( this.thicknessMap && this.thicknessMap.isTexture ) data.thicknessMap = this.thicknessMap.toJSON( meta ).uuid;\n \t\tif ( this.attenuationDistance !== undefined && this.attenuationDistance !== Infinity ) data.attenuationDistance = this.attenuationDistance;\n \t\tif ( this.attenuationColor !== undefined ) data.attenuationColor = this.attenuationColor.getHex();\n\n \t\tif ( this.size !== undefined ) data.size = this.size;\n \t\tif ( this.shadowSide !== null ) data.shadowSide = this.shadowSide;\n \t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n \t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n \t\tif ( this.side !== FrontSide ) data.side = this.side;\n \t\tif ( this.vertexColors === true ) data.vertexColors = true;\n\n \t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n \t\tif ( this.transparent === true ) data.transparent = true;\n\n \t\tif ( this.blendSrc !== SrcAlphaFactor ) data.blendSrc = this.blendSrc;\n \t\tif ( this.blendDst !== OneMinusSrcAlphaFactor ) data.blendDst = this.blendDst;\n \t\tif ( this.blendEquation !== AddEquation ) data.blendEquation = this.blendEquation;\n \t\tif ( this.blendSrcAlpha !== null ) data.blendSrcAlpha = this.blendSrcAlpha;\n \t\tif ( this.blendDstAlpha !== null ) data.blendDstAlpha = this.blendDstAlpha;\n \t\tif ( this.blendEquationAlpha !== null ) data.blendEquationAlpha = this.blendEquationAlpha;\n \t\tif ( this.blendColor && this.blendColor.isColor ) data.blendColor = this.blendColor.getHex();\n \t\tif ( this.blendAlpha !== 0 ) data.blendAlpha = this.blendAlpha;\n\n \t\tif ( this.depthFunc !== LessEqualDepth ) data.depthFunc = this.depthFunc;\n \t\tif ( this.depthTest === false ) data.depthTest = this.depthTest;\n \t\tif ( this.depthWrite === false ) data.depthWrite = this.depthWrite;\n \t\tif ( this.colorWrite === false ) data.colorWrite = this.colorWrite;\n\n \t\tif ( this.stencilWriteMask !== 0xff ) data.stencilWriteMask = this.stencilWriteMask;\n \t\tif ( this.stencilFunc !== AlwaysStencilFunc ) data.stencilFunc = this.stencilFunc;\n \t\tif ( this.stencilRef !== 0 ) data.stencilRef = this.stencilRef;\n \t\tif ( this.stencilFuncMask !== 0xff ) data.stencilFuncMask = this.stencilFuncMask;\n \t\tif ( this.stencilFail !== KeepStencilOp ) data.stencilFail = this.stencilFail;\n \t\tif ( this.stencilZFail !== KeepStencilOp ) data.stencilZFail = this.stencilZFail;\n \t\tif ( this.stencilZPass !== KeepStencilOp ) data.stencilZPass = this.stencilZPass;\n \t\tif ( this.stencilWrite === true ) data.stencilWrite = this.stencilWrite;\n\n \t\t// rotation (SpriteMaterial)\n \t\tif ( this.rotation !== undefined && this.rotation !== 0 ) data.rotation = this.rotation;\n\n \t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n \t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n \t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n \t\tif ( this.linewidth !== undefined && this.linewidth !== 1 ) data.linewidth = this.linewidth;\n \t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n \t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n \t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n \t\tif ( this.dithering === true ) data.dithering = true;\n\n \t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n \t\tif ( this.alphaHash === true ) data.alphaHash = true;\n \t\tif ( this.alphaToCoverage === true ) data.alphaToCoverage = true;\n \t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;\n \t\tif ( this.forceSinglePass === true ) data.forceSinglePass = true;\n \t\tif ( this.allowOverride === false ) data.allowOverride = false;\n\n \t\tif ( this.wireframe === true ) data.wireframe = true;\n \t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n \t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n \t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n \t\tif ( this.flatShading === true ) data.flatShading = true;\n\n \t\tif ( this.visible === false ) data.visible = false;\n\n \t\tif ( this.toneMapped === false ) data.toneMapped = false;\n\n \t\tif ( this.fog === false ) data.fog = false;\n\n \t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n \t\t// TODO: Copied from Object3D.toJSON\n\n \t\tfunction extractFromCache( cache ) {\n\n \t\t\tconst values = [];\n\n \t\t\tfor ( const key in cache ) {\n\n \t\t\t\tconst data = cache[ key ];\n \t\t\t\tdelete data.metadata;\n \t\t\t\tvalues.push( data );\n\n \t\t\t}\n\n \t\t\treturn values;\n\n \t\t}\n\n \t\tif ( isRootObject ) {\n\n \t\t\tconst textures = extractFromCache( meta.textures );\n \t\t\tconst images = extractFromCache( meta.images );\n\n \t\t\tif ( textures.length > 0 ) data.textures = textures;\n \t\t\tif ( images.length > 0 ) data.images = images;\n\n \t\t}\n\n \t\treturn data;\n\n \t}\n\n \t/**\n \t * Deserializes the material from the given JSON.\n \t *\n \t * @param {Object} json - The JSON holding the serialized material.\n \t * @param {Object<string,Texture>} textures - A dictionary holding textures referenced by the material.\n \t * @return {Material} A reference to this material.\n \t */\n \tfromJSON( json, textures ) {\n\n \t\tif ( json.uuid !== undefined ) this.uuid = json.uuid;\n \t\tif ( json.name !== undefined ) this.name = json.name;\n \t\tif ( json.color !== undefined && this.color !== undefined ) this.color.setHex( json.color );\n \t\tif ( json.roughness !== undefined ) this.roughness = json.roughness;\n \t\tif ( json.metalness !== undefined ) this.metalness = json.metalness;\n \t\tif ( json.sheen !== undefined ) this.sheen = json.sheen;\n \t\tif ( json.sheenColor !== undefined ) this.sheenColor = new Color().setHex( json.sheenColor );\n \t\tif ( json.sheenRoughness !== undefined ) this.sheenRoughness = json.sheenRoughness;\n \t\tif ( json.emissive !== undefined && this.emissive !== undefined ) this.emissive.setHex( json.emissive );\n \t\tif ( json.specular !== undefined && this.specular !== undefined ) this.specular.setHex( json.specular );\n \t\tif ( json.specularIntensity !== undefined ) this.specularIntensity = json.specularIntensity;\n \t\tif ( json.specularColor !== undefined && this.specularColor !== undefined ) this.specularColor.setHex( json.specularColor );\n \t\tif ( json.shininess !== undefined ) this.shininess = json.shininess;\n \t\tif ( json.clearcoat !== undefined ) this.clearcoat = json.clearcoat;\n \t\tif ( json.clearcoatRoughness !== undefined ) this.clearcoatRoughness = json.clearcoatRoughness;\n \t\tif ( json.dispersion !== undefined ) this.dispersion = json.dispersion;\n \t\tif ( json.iridescence !== undefined ) this.iridescence = json.iridescence;\n \t\tif ( json.iridescenceIOR !== undefined ) this.iridescenceIOR = json.iridescenceIOR;\n \t\tif ( json.iridescenceThicknessRange !== undefined ) this.iridescenceThicknessRange = json.iridescenceThicknessRange;\n \t\tif ( json.transmission !== undefined ) this.transmission = json.transmission;\n \t\tif ( json.thickness !== undefined ) this.thickness = json.thickness;\n \t\tif ( json.attenuationDistance !== undefined ) this.attenuationDistance = json.attenuationDistance;\n \t\tif ( json.attenuationColor !== undefined && this.attenuationColor !== undefined ) this.attenuationColor.setHex( json.attenuationColor );\n \t\tif ( json.anisotropy !== undefined ) this.anisotropy = json.anisotropy;\n \t\tif ( json.anisotropyRotation !== undefined ) this.anisotropyRotation = json.anisotropyRotation;\n \t\tif ( json.fog !== undefined ) this.fog = json.fog;\n \t\tif ( json.flatShading !== undefined ) this.flatShading = json.flatShading;\n \t\tif ( json.blending !== undefined ) this.blending = json.blending;\n \t\tif ( json.combine !== undefined ) this.combine = json.combine;\n \t\tif ( json.side !== undefined ) this.side = json.side;\n \t\tif ( json.shadowSide !== undefined ) this.shadowSide = json.shadowSide;\n \t\tif ( json.opacity !== undefined ) this.opacity = json.opacity;\n \t\tif ( json.transparent !== undefined ) this.transparent = json.transparent;\n \t\tif ( json.alphaTest !== undefined ) this.alphaTest = json.alphaTest;\n \t\tif ( json.alphaHash !== undefined ) this.alphaHash = json.alphaHash;\n \t\tif ( json.depthFunc !== undefined ) this.depthFunc = json.depthFunc;\n \t\tif ( json.depthTest !== undefined ) this.depthTest = json.depthTest;\n \t\tif ( json.depthWrite !== undefined ) this.depthWrite = json.depthWrite;\n \t\tif ( json.colorWrite !== undefined ) this.colorWrite = json.colorWrite;\n \t\tif ( json.blendSrc !== undefined ) this.blendSrc = json.blendSrc;\n \t\tif ( json.blendDst !== undefined ) this.blendDst = json.blendDst;\n \t\tif ( json.blendEquation !== undefined ) this.blendEquation = json.blendEquation;\n \t\tif ( json.blendSrcAlpha !== undefined ) this.blendSrcAlpha = json.blendSrcAlpha;\n \t\tif ( json.blendDstAlpha !== undefined ) this.blendDstAlpha = json.blendDstAlpha;\n \t\tif ( json.blendEquationAlpha !== undefined ) this.blendEquationAlpha = json.blendEquationAlpha;\n \t\tif ( json.blendColor !== undefined && this.blendColor !== undefined ) this.blendColor.setHex( json.blendColor );\n \t\tif ( json.blendAlpha !== undefined ) this.blendAlpha = json.blendAlpha;\n \t\tif ( json.stencilWriteMask !== undefined ) this.stencilWriteMask = json.stencilWriteMask;\n \t\tif ( json.stencilFunc !== undefined ) this.stencilFunc = json.stencilFunc;\n \t\tif ( json.stencilRef !== undefined ) this.stencilRef = json.stencilRef;\n \t\tif ( json.stencilFuncMask !== undefined ) this.stencilFuncMask = json.stencilFuncMask;\n \t\tif ( json.stencilFail !== undefined ) this.stencilFail = json.stencilFail;\n \t\tif ( json.stencilZFail !== undefined ) this.stencilZFail = json.stencilZFail;\n \t\tif ( json.stencilZPass !== undefined ) this.stencilZPass = json.stencilZPass;\n \t\tif ( json.stencilWrite !== undefined ) this.stencilWrite = json.stencilWrite;\n\n \t\tif ( json.wireframe !== undefined ) this.wireframe = json.wireframe;\n \t\tif ( json.wireframeLinewidth !== undefined ) this.wireframeLinewidth = json.wireframeLinewidth;\n \t\tif ( json.wireframeLinecap !== undefined ) this.wireframeLinecap = json.wireframeLinecap;\n \t\tif ( json.wireframeLinejoin !== undefined ) this.wireframeLinejoin = json.wireframeLinejoin;\n\n \t\tif ( json.rotation !== undefined ) this.rotation = json.rotation;\n\n \t\tif ( json.linewidth !== undefined ) this.linewidth = json.linewidth;\n \t\tif ( json.dashSize !== undefined ) this.dashSize = json.dashSize;\n \t\tif ( json.gapSize !== undefined ) this.gapSize = json.gapSize;\n \t\tif ( json.scale !== undefined ) this.scale = json.scale;\n\n \t\tif ( json.polygonOffset !== undefined ) this.polygonOffset = json.polygonOffset;\n \t\tif ( json.polygonOffsetFactor !== undefined ) this.polygonOffsetFactor = json.polygonOffsetFactor;\n \t\tif ( json.polygonOffsetUnits !== undefined ) this.polygonOffsetUnits = json.polygonOffsetUnits;\n\n \t\tif ( json.dithering !== undefined ) this.dithering = json.dithering;\n\n \t\tif ( json.alphaToCoverage !== undefined ) this.alphaToCoverage = json.alphaToCoverage;\n \t\tif ( json.premultipliedAlpha !== undefined ) this.premultipliedAlpha = json.premultipliedAlpha;\n \t\tif ( json.forceSinglePass !== undefined ) this.forceSinglePass = json.forceSinglePass;\n \t\tif ( json.allowOverride !== undefined ) this.allowOverride = json.allowOverride;\n\n \t\tif ( json.visible !== undefined ) this.visible = json.visible;\n\n \t\tif ( json.toneMapped !== undefined ) this.toneMapped = json.toneMapped;\n\n \t\tif ( json.userData !== undefined ) this.userData = json.userData;\n\n \t\tif ( json.vertexColors !== undefined ) {\n\n \t\t\tif ( typeof json.vertexColors === 'number' ) {\n\n \t\t\t\tthis.vertexColors = json.vertexColors > 0;\n\n \t\t\t} else {\n\n \t\t\t\tthis.vertexColors = json.vertexColors;\n\n \t\t\t}\n\n \t\t}\n\n \t\t// for PointsMaterial\n\n \t\tif ( json.size !== undefined ) this.size = json.size;\n \t\tif ( json.sizeAttenuation !== undefined ) this.sizeAttenuation = json.sizeAttenuation;\n\n \t\t// maps\n\n \t\tif ( json.map !== undefined ) this.map = textures[ json.map ] || null;\n \t\tif ( json.matcap !== undefined ) this.matcap = textures[ json.matcap ] || null;\n\n \t\tif ( json.alphaMap !== undefined ) this.alphaMap = textures[ json.alphaMap ] || null;\n\n \t\tif ( json.bumpMap !== undefined ) this.bumpMap = textures[ json.bumpMap ] || null;\n \t\tif ( json.bumpScale !== undefined ) this.bumpScale = json.bumpScale;\n\n \t\tif ( json.normalMap !== undefined ) this.normalMap = textures[ json.normalMap ] || null;\n \t\tif ( json.normalMapType !== undefined ) this.normalMapType = json.normalMapType;\n \t\tif ( json.normalScale !== undefined ) {\n\n \t\t\tlet normalScale = json.normalScale;\n\n \t\t\tif ( Array.isArray( normalScale ) === false ) {\n\n \t\t\t\t// Blender exporter used to export a scalar. See #7459\n\n \t\t\t\tnormalScale = [ normalScale, normalScale ];\n\n \t\t\t}\n\n \t\t\tthis.normalScale = new Vector2().fromArray( normalScale );\n\n \t\t}\n\n \t\tif ( json.displacementMap !== undefined ) this.displacementMap = textures[ json.displacementMap ] || null;\n \t\tif ( json.displacementScale !== undefined ) this.displacementScale = json.displacementScale;\n \t\tif ( json.displacementBias !== undefined ) this.displacementBias = json.displacementBias;\n\n \t\tif ( json.roughnessMap !== undefined ) this.roughnessMap = textures[ json.roughnessMap ] || null;\n \t\tif ( json.metalnessMap !== undefined ) this.metalnessMap = textures[ json.metalnessMap ] || null;\n\n \t\tif ( json.emissiveMap !== undefined ) this.emissiveMap = textures[ json.emissiveMap ] || null;\n \t\tif ( json.emissiveIntensity !== undefined ) this.emissiveIntensity = json.emissiveIntensity;\n\n \t\tif ( json.specularMap !== undefined ) this.specularMap = textures[ json.specularMap ] || null;\n \t\tif ( json.specularIntensityMap !== undefined ) this.specularIntensityMap = textures[ json.specularIntensityMap ] || null;\n \t\tif ( json.specularColorMap !== undefined ) this.specularColorMap = textures[ json.specularColorMap ] || null;\n\n \t\tif ( json.envMap !== undefined ) this.envMap = textures[ json.envMap ] || null;\n \t\tif ( json.envMapRotation !== undefined ) this.envMapRotation.fromArray( json.envMapRotation );\n \t\tif ( json.envMapIntensity !== undefined ) this.envMapIntensity = json.envMapIntensity;\n\n \t\tif ( json.reflectivity !== undefined ) this.reflectivity = json.reflectivity;\n \t\tif ( json.refractionRatio !== undefined ) this.refractionRatio = json.refractionRatio;\n\n \t\tif ( json.lightMap !== undefined ) this.lightMap = textures[ json.lightMap ] || null;\n \t\tif ( json.lightMapIntensity !== undefined ) this.lightMapIntensity = json.lightMapIntensity;\n\n \t\tif ( json.aoMap !== undefined ) this.aoMap = textures[ json.aoMap ] || null;\n \t\tif ( json.aoMapIntensity !== undefined ) this.aoMapIntensity = json.aoMapIntensity;\n\n \t\tif ( json.gradientMap !== undefined ) this.gradientMap = textures[ json.gradientMap ] || null;\n\n \t\tif ( json.clearcoatMap !== undefined ) this.clearcoatMap = textures[ json.clearcoatMap ] || null;\n \t\tif ( json.clearcoatRoughnessMap !== undefined ) this.clearcoatRoughnessMap = textures[ json.clearcoatRoughnessMap ] || null;\n \t\tif ( json.clearcoatNormalMap !== undefined ) this.clearcoatNormalMap = textures[ json.clearcoatNormalMap ] || null;\n \t\tif ( json.clearcoatNormalScale !== undefined ) this.clearcoatNormalScale = new Vector2().fromArray( json.clearcoatNormalScale );\n\n \t\tif ( json.iridescenceMap !== undefined ) this.iridescenceMap = textures[ json.iridescenceMap ] || null;\n \t\tif ( json.iridescenceThicknessMap !== undefined ) this.iridescenceThicknessMap = textures[ json.iridescenceThicknessMap ] || null;\n\n \t\tif ( json.transmissionMap !== undefined ) this.transmissionMap = textures[ json.transmissionMap ] || null;\n \t\tif ( json.thicknessMap !== undefined ) this.thicknessMap = textures[ json.thicknessMap ] || null;\n\n \t\tif ( json.anisotropyMap !== undefined ) this.anisotropyMap = textures[ json.anisotropyMap ] || null;\n\n \t\tif ( json.sheenColorMap !== undefined ) this.sheenColorMap = textures[ json.sheenColorMap ] || null;\n \t\tif ( json.sheenRoughnessMap !== undefined ) this.sheenRoughnessMap = textures[ json.sheenRoughnessMap ] || null;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a new material with copied values from this instance.\n \t *\n \t * @return {Material} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n \t/**\n \t * Copies the values of the given material to this instance.\n \t *\n \t * @param {Material} source - The material to copy.\n \t * @return {Material} A reference to this instance.\n \t */\n \tcopy( source ) {\n\n \t\tthis.name = source.name;\n\n \t\tthis.blending = source.blending;\n \t\tthis.side = source.side;\n \t\tthis.vertexColors = source.vertexColors;\n\n \t\tthis.opacity = source.opacity;\n \t\tthis.transparent = source.transparent;\n\n \t\tthis.blendSrc = source.blendSrc;\n \t\tthis.blendDst = source.blendDst;\n \t\tthis.blendEquation = source.blendEquation;\n \t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n \t\tthis.blendDstAlpha = source.blendDstAlpha;\n \t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n \t\tthis.blendColor.copy( source.blendColor );\n \t\tthis.blendAlpha = source.blendAlpha;\n\n \t\tthis.depthFunc = source.depthFunc;\n \t\tthis.depthTest = source.depthTest;\n \t\tthis.depthWrite = source.depthWrite;\n\n \t\tthis.stencilWriteMask = source.stencilWriteMask;\n \t\tthis.stencilFunc = source.stencilFunc;\n \t\tthis.stencilRef = source.stencilRef;\n \t\tthis.stencilFuncMask = source.stencilFuncMask;\n \t\tthis.stencilFail = source.stencilFail;\n \t\tthis.stencilZFail = source.stencilZFail;\n \t\tthis.stencilZPass = source.stencilZPass;\n \t\tthis.stencilWrite = source.stencilWrite;\n\n \t\tconst srcPlanes = source.clippingPlanes;\n \t\tlet dstPlanes = null;\n\n \t\tif ( srcPlanes !== null ) {\n\n \t\t\tconst n = srcPlanes.length;\n \t\t\tdstPlanes = new Array( n );\n\n \t\t\tfor ( let i = 0; i !== n; ++ i ) {\n\n \t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n \t\t\t}\n\n \t\t}\n\n \t\tthis.clippingPlanes = dstPlanes;\n \t\tthis.clipIntersection = source.clipIntersection;\n \t\tthis.clipShadows = source.clipShadows;\n\n \t\tthis.shadowSide = source.shadowSide;\n\n \t\tthis.colorWrite = source.colorWrite;\n\n \t\tthis.precision = source.precision;\n\n \t\tthis.polygonOffset = source.polygonOffset;\n \t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n \t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n \t\tthis.dithering = source.dithering;\n\n \t\tthis.alphaTest = source.alphaTest;\n \t\tthis.alphaHash = source.alphaHash;\n \t\tthis.alphaToCoverage = source.alphaToCoverage;\n \t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n \t\tthis.forceSinglePass = source.forceSinglePass;\n \t\tthis.allowOverride = source.allowOverride;\n\n \t\tthis.visible = source.visible;\n\n \t\tthis.toneMapped = source.toneMapped;\n\n \t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Frees the GPU-related resources allocated by this instance. Call this\n \t * method whenever this instance is no longer used in your app.\n \t *\n \t * @fires Material#dispose\n \t */\n \tdispose() {\n\n \t\t/**\n \t\t * Fires when the material has been disposed of.\n \t\t *\n \t\t * @event Material#dispose\n \t\t * @type {Object}\n \t\t */\n \t\tthis.dispatchEvent( { type: 'dispose' } );\n\n \t}\n\n \t/**\n \t * Setting this property to `true` indicates the engine the material\n \t * needs to be recompiled.\n \t *\n \t * @type {boolean}\n \t * @default false\n \t * @param {boolean} value\n \t */\n \tset needsUpdate( value ) {\n\n \t\tif ( value === true ) this.version ++;\n\n \t}\n\n }\n\n const _vector$7 = /*@__PURE__*/ new Vector3();\n const _segCenter = /*@__PURE__*/ new Vector3();\n const _segDir = /*@__PURE__*/ new Vector3();\n const _diff = /*@__PURE__*/ new Vector3();\n\n const _edge1 = /*@__PURE__*/ new Vector3();\n const _edge2 = /*@__PURE__*/ new Vector3();\n const _normal$1 = /*@__PURE__*/ new Vector3();\n\n /**\n * A ray that emits from an origin in a certain direction. The class is used by\n * {@link Raycaster} to assist with raycasting. Raycasting is used for\n * mouse picking (working out what objects in the 3D space the mouse is over)\n * amongst other things.\n */\n class Ray {\n\n \t/**\n \t * Constructs a new ray.\n \t *\n \t * @param {Vector3} [origin=(0,0,0)] - The origin of the ray.\n \t * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray.\n \t */\n \tconstructor( origin = new Vector3(), direction = new Vector3( 0, 0, -1 ) ) {\n\n \t\t/**\n \t\t * The origin of the ray.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.origin = origin;\n\n \t\t/**\n \t\t * The (normalized) direction of the ray.\n \t\t *\n \t\t * @type {Vector3}\n \t\t */\n \t\tthis.direction = direction;\n\n \t}\n\n \t/**\n \t * Sets the ray's components by copying the given values.\n \t *\n \t * @param {Vector3} origin - The origin.\n \t * @param {Vector3} direction - The direction.\n \t * @return {Ray} A reference to this ray.\n \t */\n \tset( origin, direction ) {\n\n \t\tthis.origin.copy( origin );\n \t\tthis.direction.copy( direction );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Copies the values of the given ray to this instance.\n \t *\n \t * @param {Ray} ray - The ray to copy.\n \t * @return {Ray} A reference to this ray.\n \t */\n \tcopy( ray ) {\n\n \t\tthis.origin.copy( ray.origin );\n \t\tthis.direction.copy( ray.direction );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns a vector that is located at a given distance along this ray.\n \t *\n \t * @param {number} t - The distance along the ray to retrieve a position for.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} A position on the ray.\n \t */\n \tat( t, target ) {\n\n \t\treturn target.copy( this.origin ).addScaledVector( this.direction, t );\n\n \t}\n\n \t/**\n \t * Adjusts the direction of the ray to point at the given vector in world space.\n \t *\n \t * @param {Vector3} v - The target position.\n \t * @return {Ray} A reference to this ray.\n \t */\n \tlookAt( v ) {\n\n \t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Shift the origin of this ray along its direction by the given distance.\n \t *\n \t * @param {number} t - The distance along the ray to interpolate.\n \t * @return {Ray} A reference to this ray.\n \t */\n \trecast( t ) {\n\n \t\tthis.origin.copy( this.at( t, _vector$7 ) );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns the point along this ray that is closest to the given point.\n \t *\n \t * @param {Vector3} point - A point in 3D space to get the closet location on the ray for.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {Vector3} The closest point on this ray.\n \t */\n \tclosestPointToPoint( point, target ) {\n\n \t\ttarget.subVectors( point, this.origin );\n\n \t\tconst directionDistance = target.dot( this.direction );\n\n \t\tif ( directionDistance < 0 ) {\n\n \t\t\treturn target.copy( this.origin );\n\n \t\t}\n\n \t\treturn target.copy( this.origin ).addScaledVector( this.direction, directionDistance );\n\n \t}\n\n \t/**\n \t * Returns the distance of the closest approach between this ray and the given point.\n \t *\n \t * @param {Vector3} point - A point in 3D space to compute the distance to.\n \t * @return {number} The distance.\n \t */\n \tdistanceToPoint( point ) {\n\n \t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n \t}\n\n \t/**\n \t * Returns the squared distance of the closest approach between this ray and the given point.\n \t *\n \t * @param {Vector3} point - A point in 3D space to compute the distance to.\n \t * @return {number} The squared distance.\n \t */\n \tdistanceSqToPoint( point ) {\n\n \t\tconst directionDistance = _vector$7.subVectors( point, this.origin ).dot( this.direction );\n\n \t\t// point behind the ray\n\n \t\tif ( directionDistance < 0 ) {\n\n \t\t\treturn this.origin.distanceToSquared( point );\n\n \t\t}\n\n \t\t_vector$7.copy( this.origin ).addScaledVector( this.direction, directionDistance );\n\n \t\treturn _vector$7.distanceToSquared( point );\n\n \t}\n\n \t/**\n \t * Returns the squared distance between this ray and the given line segment.\n \t *\n \t * @param {Vector3} v0 - The start point of the line segment.\n \t * @param {Vector3} v1 - The end point of the line segment.\n \t * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment.\n \t * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray.\n \t * @return {number} The squared distance.\n \t */\n \tdistanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n \t\t// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteDistRaySegment.h\n \t\t// It returns the min distance between the ray and the segment\n \t\t// defined by v0 and v1\n \t\t// It can also set two optional targets :\n \t\t// - The closest point on the ray\n \t\t// - The closest point on the segment\n\n \t\t_segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n \t\t_segDir.copy( v1 ).sub( v0 ).normalize();\n \t\t_diff.copy( this.origin ).sub( _segCenter );\n\n \t\tconst segExtent = v0.distanceTo( v1 ) * 0.5;\n \t\tconst a01 = - this.direction.dot( _segDir );\n \t\tconst b0 = _diff.dot( this.direction );\n \t\tconst b1 = - _diff.dot( _segDir );\n \t\tconst c = _diff.lengthSq();\n \t\tconst det = Math.abs( 1 - a01 * a01 );\n \t\tlet s0, s1, sqrDist, extDet;\n\n \t\tif ( det > 0 ) {\n\n \t\t\t// The ray and segment are not parallel.\n\n \t\t\ts0 = a01 * b1 - b0;\n \t\t\ts1 = a01 * b0 - b1;\n \t\t\textDet = segExtent * det;\n\n \t\t\tif ( s0 >= 0 ) {\n\n \t\t\t\tif ( s1 >= - extDet ) {\n\n \t\t\t\t\tif ( s1 <= extDet ) {\n\n \t\t\t\t\t\t// region 0\n \t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n \t\t\t\t\t\tconst invDet = 1 / det;\n \t\t\t\t\t\ts0 *= invDet;\n \t\t\t\t\t\ts1 *= invDet;\n \t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\t// region 1\n\n \t\t\t\t\t\ts1 = segExtent;\n \t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n \t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t\t\t\t}\n\n \t\t\t\t} else {\n\n \t\t\t\t\t// region 5\n\n \t\t\t\t\ts1 = - segExtent;\n \t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n \t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\tif ( s1 <= - extDet ) {\n\n \t\t\t\t\t// region 4\n\n \t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n \t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n \t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t\t\t} else if ( s1 <= extDet ) {\n\n \t\t\t\t\t// region 3\n\n \t\t\t\t\ts0 = 0;\n \t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n \t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t\t\t} else {\n\n \t\t\t\t\t// region 2\n\n \t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n \t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n \t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t} else {\n\n \t\t\t// Ray and segment are parallel.\n\n \t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n \t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n \t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n \t\t}\n\n \t\tif ( optionalPointOnRay ) {\n\n \t\t\toptionalPointOnRay.copy( this.origin ).addScaledVector( this.direction, s0 );\n\n \t\t}\n\n \t\tif ( optionalPointOnSegment ) {\n\n \t\t\toptionalPointOnSegment.copy( _segCenter ).addScaledVector( _segDir, s1 );\n\n \t\t}\n\n \t\treturn sqrDist;\n\n \t}\n\n \t/**\n \t * Intersects this ray with the given sphere, returning the intersection\n \t * point or `null` if there is no intersection.\n \t *\n \t * @param {Sphere} sphere - The sphere to intersect.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The intersection point.\n \t */\n \tintersectSphere( sphere, target ) {\n\n \t\t_vector$7.subVectors( sphere.center, this.origin );\n \t\tconst tca = _vector$7.dot( this.direction );\n \t\tconst d2 = _vector$7.dot( _vector$7 ) - tca * tca;\n \t\tconst radius2 = sphere.radius * sphere.radius;\n\n \t\tif ( d2 > radius2 ) return null;\n\n \t\tconst thc = Math.sqrt( radius2 - d2 );\n\n \t\t// t0 = first intersect point - entrance on front of sphere\n \t\tconst t0 = tca - thc;\n\n \t\t// t1 = second intersect point - exit point on back of sphere\n \t\tconst t1 = tca + thc;\n\n \t\t// test to see if t1 is behind the ray - if so, return null\n \t\tif ( t1 < 0 ) return null;\n\n \t\t// test to see if t0 is behind the ray:\n \t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n \t\t// in order to always return an intersect point that is in front of the ray.\n \t\tif ( t0 < 0 ) return this.at( t1, target );\n\n \t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n \t\treturn this.at( t0, target );\n\n \t}\n\n \t/**\n \t * Returns `true` if this ray intersects with the given sphere.\n \t *\n \t * @param {Sphere} sphere - The sphere to intersect.\n \t * @return {boolean} Whether this ray intersects with the given sphere or not.\n \t */\n \tintersectsSphere( sphere ) {\n\n \t\tif ( sphere.radius < 0 ) return false; // handle empty spheres, see #31187\n\n \t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n \t}\n\n \t/**\n \t * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray\n \t * does not intersect with the plane.\n \t *\n \t * @param {Plane} plane - The plane to compute the distance to.\n \t * @return {?number} Whether this ray intersects with the given sphere or not.\n \t */\n \tdistanceToPlane( plane ) {\n\n \t\tconst denominator = plane.normal.dot( this.direction );\n\n \t\tif ( denominator === 0 ) {\n\n \t\t\t// line is coplanar, return origin\n \t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n \t\t\t\treturn 0;\n\n \t\t\t}\n\n \t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\tconst t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n \t\t// Return if the ray never intersects the plane\n\n \t\treturn t >= 0 ? t : null;\n\n \t}\n\n \t/**\n \t * Intersects this ray with the given plane, returning the intersection\n \t * point or `null` if there is no intersection.\n \t *\n \t * @param {Plane} plane - The plane to intersect.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The intersection point.\n \t */\n \tintersectPlane( plane, target ) {\n\n \t\tconst t = this.distanceToPlane( plane );\n\n \t\tif ( t === null ) {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\treturn this.at( t, target );\n\n \t}\n\n \t/**\n \t * Returns `true` if this ray intersects with the given plane.\n \t *\n \t * @param {Plane} plane - The plane to intersect.\n \t * @return {boolean} Whether this ray intersects with the given plane or not.\n \t */\n \tintersectsPlane( plane ) {\n\n \t\t// check if the ray lies on the plane first\n\n \t\tconst distToPoint = plane.distanceToPoint( this.origin );\n\n \t\tif ( distToPoint === 0 ) {\n\n \t\t\treturn true;\n\n \t\t}\n\n \t\tconst denominator = plane.normal.dot( this.direction );\n\n \t\tif ( denominator * distToPoint < 0 ) {\n\n \t\t\treturn true;\n\n \t\t}\n\n \t\t// ray origin is behind the plane (and is pointing behind it)\n\n \t\treturn false;\n\n \t}\n\n \t/**\n \t * Intersects this ray with the given bounding box, returning the intersection\n \t * point or `null` if there is no intersection.\n \t *\n \t * @param {Box3} box - The box to intersect.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The intersection point.\n \t */\n \tintersectBox( box, target ) {\n\n \t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n \t\tconst invdirx = 1 / this.direction.x,\n \t\t\tinvdiry = 1 / this.direction.y,\n \t\t\tinvdirz = 1 / this.direction.z;\n\n \t\tconst origin = this.origin;\n\n \t\tif ( invdirx >= 0 ) {\n\n \t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n \t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n \t\t} else {\n\n \t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n \t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n \t\t}\n\n \t\tif ( invdiry >= 0 ) {\n\n \t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n \t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n \t\t} else {\n\n \t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n \t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n \t\t}\n\n \t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n \t\tif ( tymin > tmin || isNaN( tmin ) ) tmin = tymin;\n\n \t\tif ( tymax < tmax || isNaN( tmax ) ) tmax = tymax;\n\n \t\tif ( invdirz >= 0 ) {\n\n \t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n \t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n \t\t} else {\n\n \t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n \t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n \t\t}\n\n \t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n \t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n \t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n \t\t//return point closest to the ray (positive side)\n\n \t\tif ( tmax < 0 ) return null;\n\n \t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n \t}\n\n \t/**\n \t * Returns `true` if this ray intersects with the given box.\n \t *\n \t * @param {Box3} box - The box to intersect.\n \t * @return {boolean} Whether this ray intersects with the given box or not.\n \t */\n \tintersectsBox( box ) {\n\n \t\treturn this.intersectBox( box, _vector$7 ) !== null;\n\n \t}\n\n \t/**\n \t * Intersects this ray with the given triangle, returning the intersection\n \t * point or `null` if there is no intersection.\n \t *\n \t * @param {Vector3} a - The first vertex of the triangle.\n \t * @param {Vector3} b - The second vertex of the triangle.\n \t * @param {Vector3} c - The third vertex of the triangle.\n \t * @param {boolean} backfaceCulling - Whether to use backface culling or not.\n \t * @param {Vector3} target - The target vector that is used to store the method's result.\n \t * @return {?Vector3} The intersection point.\n \t */\n \tintersectTriangle( a, b, c, backfaceCulling, target ) {\n\n \t\t// Compute the offset origin, edges, and normal.\n\n \t\t// from https://github.com/pmjoniak/GeometricTools/blob/master/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n \t\t_edge1.subVectors( b, a );\n \t\t_edge2.subVectors( c, a );\n \t\t_normal$1.crossVectors( _edge1, _edge2 );\n\n \t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n \t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n \t\t// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n \t\t// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n \t\t// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n \t\tlet DdN = this.direction.dot( _normal$1 );\n \t\tlet sign;\n\n \t\tif ( DdN > 0 ) {\n\n \t\t\tif ( backfaceCulling ) return null;\n \t\t\tsign = 1;\n\n \t\t} else if ( DdN < 0 ) {\n\n \t\t\tsign = -1;\n \t\t\tDdN = - DdN;\n\n \t\t} else {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\t_diff.subVectors( this.origin, a );\n \t\tconst DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );\n\n \t\t// b1 < 0, no intersection\n \t\tif ( DdQxE2 < 0 ) {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\tconst DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );\n\n \t\t// b2 < 0, no intersection\n \t\tif ( DdE1xQ < 0 ) {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\t// b1+b2 > 1, no intersection\n \t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\t// Line intersects triangle, check if ray does.\n \t\tconst QdN = - sign * _diff.dot( _normal$1 );\n\n \t\t// t < 0, no intersection\n \t\tif ( QdN < 0 ) {\n\n \t\t\treturn null;\n\n \t\t}\n\n \t\t// Ray intersects triangle.\n \t\treturn this.at( QdN / DdN, target );\n\n \t}\n\n \t/**\n \t * Transforms this ray with the given 4x4 transformation matrix.\n \t *\n \t * @param {Matrix4} matrix4 - The transformation matrix.\n \t * @return {Ray} A reference to this ray.\n \t */\n \tapplyMatrix4( matrix4 ) {\n\n \t\tthis.origin.applyMatrix4( matrix4 );\n \t\tthis.direction.transformDirection( matrix4 );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Returns `true` if this ray is equal with the given one.\n \t *\n \t * @param {Ray} ray - The ray to test for equality.\n \t * @return {boolean} Whether this ray is equal with the given one.\n \t */\n \tequals( ray ) {\n\n \t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n \t}\n\n \t/**\n \t * Returns a new ray with copied values from this instance.\n \t *\n \t * @return {Ray} A clone of this instance.\n \t */\n \tclone() {\n\n \t\treturn new this.constructor().copy( this );\n\n \t}\n\n }\n\n /**\n * A material for drawing geometries in a simple shaded (flat or wireframe) way.\n *\n * This material is not affected by lights.\n *\n * @augments Material\n * @demo scenes/material-browser.html#MeshBasicMaterial\n */\n class MeshBasicMaterial extends Material {\n\n \t/**\n \t * Constructs a new mesh basic material.\n \t *\n \t * @param {Object} [parameters] - An object with one or more properties\n \t * defining the material's appearance. Any property of the material\n \t * (including any property from inherited materials) can be passed\n \t * in here. Color values can be passed any type of value accepted\n \t * by {@link Color#set}.\n \t */\n \tconstructor( parameters ) {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isMeshBasicMaterial = true;\n\n \t\tthis.type = 'MeshBasicMaterial';\n\n \t\t/**\n \t\t * Color of the material.\n \t\t *\n \t\t * @type {Color}\n \t\t * @default (1,1,1)\n \t\t */\n \t\tthis.color = new Color( 0xffffff ); // diffuse\n\n \t\t/**\n \t\t * The color map. May optionally include an alpha channel, typically combined\n \t\t * with {@link Material#transparent} or {@link Material#alphaTest}. The texture map\n \t\t * color is modulated by the diffuse `color`.\n \t\t *\n \t\t * `map` represents color data, and the texture must be assigned a\n \t\t * {@link Texture#colorSpace}. Most `map` textures set\n \t\t * `texture.colorSpace = SRGBColorSpace`.\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.map = null;\n\n \t\t/**\n \t\t * The light map. Requires a second set of UVs.\n \t\t *\n \t\t * `lightMap` represents pre-baked illuminance data, and the texture must be assigned\n \t\t * a {@link Texture#colorSpace}. Most `lightMap` textures set\n \t\t * `texture.colorSpace = LinearSRGBColorSpace` and use float-type formats\n \t\t * such as `.exr` or `.hdr`.\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.lightMap = null;\n\n \t\t/**\n \t\t * Intensity of the baked light.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.lightMapIntensity = 1.0;\n\n \t\t/**\n \t\t * The red channel of this texture is used as the ambient occlusion map.\n \t\t * Requires a second set of UVs.\n \t\t *\n \t\t * `aoMap` represents non-color data. Any texture assigned must have\n \t\t * `texture.colorSpace = NoColorSpace` (default).\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.aoMap = null;\n\n \t\t/**\n \t\t * Intensity of the ambient occlusion effect. Range is `[0,1]`, where `0`\n \t\t * disables ambient occlusion. Where intensity is `1` and the AO map's\n \t\t * red channel is also `1`, ambient light is fully occluded on a surface.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.aoMapIntensity = 1.0;\n\n \t\t/**\n \t\t * Specular map used by the material.\n \t\t *\n \t\t * `specularMap` represents color data, and the texture must be assigned a\n \t\t * {@link Texture#colorSpace}. Most `specularMap` textures set\n \t\t * `texture.colorSpace = SRGBColorSpace`.\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.specularMap = null;\n\n \t\t/**\n \t\t * The alpha map is a grayscale texture that controls the opacity across the\n \t\t * surface (black: fully transparent; white: fully opaque).\n \t\t *\n \t\t * Only the color of the texture is used, ignoring the alpha channel if one\n \t\t * exists. For RGB and RGBA textures, the renderer will use the green channel\n \t\t * when sampling this texture due to the extra bit of precision provided for\n \t\t * green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and\n \t\t * luminance/alpha textures will also still work as expected.\n \t\t *\n \t\t * `alphaMap` represents non-color data. Any texture assigned must have\n \t\t * `texture.colorSpace = NoColorSpace` (default).\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.alphaMap = null;\n\n \t\t/**\n \t\t * The environment map.\n \t\t *\n \t\t * `envMap` represents luminance data, and the texture must be assigned\n \t\t * a {@link Texture#colorSpace}. Most `envMap` textures set\n \t\t * `texture.colorSpace = LinearSRGBColorSpace` and use float-type formats\n \t\t * such as `.exr` or `.hdr`.\n \t\t *\n \t\t * @type {?Texture}\n \t\t * @default null\n \t\t */\n \t\tthis.envMap = null;\n\n \t\t/**\n \t\t * The rotation of the environment map in radians.\n \t\t *\n \t\t * @type {Euler}\n \t\t * @default (0,0,0)\n \t\t */\n \t\tthis.envMapRotation = new Euler();\n\n \t\t/**\n \t\t * How to combine the result of the surface's color with the environment map, if any.\n \t\t *\n \t\t * When set to `MixOperation`, the {@link MeshBasicMaterial#reflectivity} is used to\n \t\t * blend between the two colors.\n \t\t *\n \t\t * @type {(MultiplyOperation|MixOperation|AddOperation)}\n \t\t * @default MultiplyOperation\n \t\t */\n \t\tthis.combine = MultiplyOperation;\n\n \t\t/**\n \t\t * How much the environment map affects the surface.\n \t\t * The valid range is between `0` (no reflections) and `1` (full reflections).\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.reflectivity = 1;\n\n \t\t/**\n \t\t * The index of refraction (IOR) of air (approximately 1) divided by the\n \t\t * index of refraction of the material. It is used with environment mapping\n \t\t * modes {@link CubeRefractionMapping} and {@link EquirectangularRefractionMapping}.\n \t\t * The refraction ratio should not exceed `1`.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0.98\n \t\t */\n \t\tthis.refractionRatio = 0.98;\n\n \t\t/**\n \t\t * Renders the geometry as a wireframe.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.wireframe = false;\n\n \t\t/**\n \t\t * Controls the thickness of the wireframe.\n \t\t *\n \t\t * Can only be used with {@link SVGRenderer}.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.wireframeLinewidth = 1;\n\n \t\t/**\n \t\t * Defines appearance of wireframe ends.\n \t\t *\n \t\t * Can only be used with {@link SVGRenderer}.\n \t\t *\n \t\t * @type {('round'|'bevel'|'miter')}\n \t\t * @default 'round'\n \t\t */\n \t\tthis.wireframeLinecap = 'round';\n\n \t\t/**\n \t\t * Defines appearance of wireframe joints.\n \t\t *\n \t\t * Can only be used with {@link SVGRenderer}.\n \t\t *\n \t\t * @type {('round'|'bevel'|'miter')}\n \t\t * @default 'round'\n \t\t */\n \t\tthis.wireframeLinejoin = 'round';\n\n \t\t/**\n \t\t * Whether the material is affected by fog or not.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.fog = true;\n\n \t\tthis.setValues( parameters );\n\n \t}\n\n \tcopy( source ) {\n\n \t\tsuper.copy( source );\n\n \t\tthis.color.copy( source.color );\n\n \t\tthis.map = source.map;\n\n \t\tthis.lightMap = source.lightMap;\n \t\tthis.lightMapIntensity = source.lightMapIntensity;\n\n \t\tthis.aoMap = source.aoMap;\n \t\tthis.aoMapIntensity = source.aoMapIntensity;\n\n \t\tthis.specularMap = source.specularMap;\n\n \t\tthis.alphaMap = source.alphaMap;\n\n \t\tthis.envMap = source.envMap;\n \t\tthis.envMapRotation.copy( source.envMapRotation );\n \t\tthis.combine = source.combine;\n \t\tthis.reflectivity = source.reflectivity;\n \t\tthis.refractionRatio = source.refractionRatio;\n\n \t\tthis.wireframe = source.wireframe;\n \t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n \t\tthis.wireframeLinecap = source.wireframeLinecap;\n \t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n \t\tthis.fog = source.fog;\n\n \t\treturn this;\n\n \t}\n\n }\n\n const _inverseMatrix$3 = /*@__PURE__*/ new Matrix4();\n const _ray$3 = /*@__PURE__*/ new Ray();\n const _sphere$6 = /*@__PURE__*/ new Sphere();\n const _sphereHitAt = /*@__PURE__*/ new Vector3();\n\n const _vA = /*@__PURE__*/ new Vector3();\n const _vB = /*@__PURE__*/ new Vector3();\n const _vC = /*@__PURE__*/ new Vector3();\n\n const _tempA = /*@__PURE__*/ new Vector3();\n const _morphA = /*@__PURE__*/ new Vector3();\n\n const _intersectionPoint = /*@__PURE__*/ new Vector3();\n const _intersectionPointWorld = /*@__PURE__*/ new Vector3();\n\n /**\n * Class representing triangular polygon mesh based objects.\n *\n * ```js\n * const geometry = new THREE.BoxGeometry( 1, 1, 1 );\n * const material = new THREE.MeshBasicMaterial( { color: 0xffff00 } );\n * const mesh = new THREE.Mesh( geometry, material );\n * scene.add( mesh );\n * ```\n *\n * @augments Object3D\n */\n class Mesh extends Object3D {\n\n \t/**\n \t * Constructs a new mesh.\n \t *\n \t * @param {BufferGeometry} [geometry] - The mesh geometry.\n \t * @param {Material|Array<Material>} [material] - The mesh material.\n \t */\n \tconstructor( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) {\n\n \t\tsuper();\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tthis.isMesh = true;\n\n \t\tthis.type = 'Mesh';\n\n \t\t/**\n \t\t * The mesh geometry.\n \t\t *\n \t\t * @type {BufferGeometry}\n \t\t */\n \t\tthis.geometry = geometry;\n\n \t\t/**\n \t\t * The mesh material.\n \t\t *\n \t\t * @type {Material|Array<Material>}\n \t\t * @default MeshBasicMaterial\n \t\t */\n \t\tthis.material = material;\n\n \t\t/**\n \t\t * A dictionary representing the morph targets in the geometry. The key is the\n \t\t * morph targets name, the value its attribute index. This member is `undefined`\n \t\t * by default and only set when morph targets are detected in the geometry.\n \t\t *\n \t\t * @type {Object<string,number>|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.morphTargetDictionary = undefined;\n\n \t\t/**\n \t\t * An array of weights typically in the range `[0,1]` that specify how much of the morph\n \t\t * is applied. This member is `undefined` by default and only set when morph targets are\n \t\t * detected in the geometry.\n \t\t *\n \t\t * @type {Array<number>|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.morphTargetInfluences = undefined;\n\n \t\t/**\n \t\t * The number of instances of this mesh.\n \t\t * Can only be used with {@link WebGPURenderer}.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 1\n \t\t */\n \t\tthis.count = 1;\n\n \t\tthis.updateMorphTargets();\n\n \t}\n\n \tcopy( source, recursive ) {\n\n \t\tsuper.copy( source, recursive );\n\n \t\tif ( source.morphTargetInfluences !== undefined ) {\n\n \t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n \t\t}\n\n \t\tif ( source.morphTargetDictionary !== undefined ) {\n\n \t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n \t\t}\n\n \t\tthis.material = Array.isArray( source.material ) ? source.material.slice() : source.material;\n \t\tthis.geometry = source.geometry;\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the values of {@link Mesh#morphTargetDictionary} and {@link Mesh#morphTargetInfluences}\n \t * to make sure existing morph targets can influence this 3D object.\n \t */\n \tupdateMorphTargets() {\n\n \t\tconst geometry = this.geometry;\n\n \t\tconst morphAttributes = geometry.morphAttributes;\n \t\tconst keys = Object.keys( morphAttributes );\n\n \t\tif ( keys.length > 0 ) {\n\n \t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n \t\t\tif ( morphAttribute !== undefined ) {\n\n \t\t\t\tthis.morphTargetInfluences = [];\n \t\t\t\tthis.morphTargetDictionary = {};\n\n \t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n \t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n \t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n \t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Returns the local-space position of the vertex at the given index, taking into\n \t * account the current animation state of both morph targets and skinning.\n \t *\n \t * @param {number} index - The vertex index.\n \t * @param {Vector3} target - The target object that is used to store the method's result.\n \t * @return {Vector3} The vertex position in local space.\n \t */\n \tgetVertexPosition( index, target ) {\n\n \t\tconst geometry = this.geometry;\n \t\tconst position = geometry.attributes.position;\n \t\tconst morphPosition = geometry.morphAttributes.position;\n \t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\n \t\ttarget.fromBufferAttribute( position, index );\n\n \t\tconst morphInfluences = this.morphTargetInfluences;\n\n \t\tif ( morphPosition && morphInfluences ) {\n\n \t\t\t_morphA.set( 0, 0, 0 );\n\n \t\t\tfor ( let i = 0, il = morphPosition.length; i < il; i ++ ) {\n\n \t\t\t\tconst influence = morphInfluences[ i ];\n \t\t\t\tconst morphAttribute = morphPosition[ i ];\n\n \t\t\t\tif ( influence === 0 ) continue;\n\n \t\t\t\t_tempA.fromBufferAttribute( morphAttribute, index );\n\n \t\t\t\tif ( morphTargetsRelative ) {\n\n \t\t\t\t\t_morphA.addScaledVector( _tempA, influence );\n\n \t\t\t\t} else {\n\n \t\t\t\t\t_morphA.addScaledVector( _tempA.sub( target ), influence );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\ttarget.add( _morphA );\n\n \t\t}\n\n \t\treturn target;\n\n \t}\n\n \t/**\n \t * Computes intersection points between a casted ray and this line.\n \t *\n \t * @param {Raycaster} raycaster - The raycaster.\n \t * @param {Array<Object>} intersects - The target array that holds the intersection points.\n \t */\n \traycast( raycaster, intersects ) {\n\n \t\tconst geometry = this.geometry;\n \t\tconst material = this.material;\n \t\tconst matrixWorld = this.matrixWorld;\n\n \t\tif ( material === undefined ) return;\n\n \t\t// test with bounding sphere in world space\n\n \t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n \t\t_sphere$6.copy( geometry.boundingSphere );\n \t\t_sphere$6.applyMatrix4( matrixWorld );\n\n \t\t// check distance from ray origin to bounding sphere\n\n \t\t_ray$3.copy( raycaster.ray ).recast( raycaster.near );\n\n \t\tif ( _sphere$6.containsPoint( _ray$3.origin ) === false ) {\n\n \t\t\tif ( _ray$3.intersectSphere( _sphere$6, _sphereHitAt ) === null ) return;\n\n \t\t\tif ( _ray$3.origin.distanceToSquared( _sphereHitAt ) > ( raycaster.far - raycaster.near ) ** 2 ) return;\n\n \t\t}\n\n \t\t// convert ray to local space of mesh\n\n \t\t_inverseMatrix$3.copy( matrixWorld ).invert();\n \t\t_ray$3.copy( raycaster.ray ).applyMatrix4( _inverseMatrix$3 );\n\n \t\t// test with bounding box in local space\n\n \t\tif ( geometry.boundingBox !== null ) {\n\n \t\t\tif ( _ray$3.intersectsBox( geometry.boundingBox ) === false ) return;\n\n \t\t}\n\n \t\t// test for intersections with geometry\n\n \t\tthis._computeIntersections( raycaster, intersects, _ray$3 );\n\n \t}\n\n \t_computeIntersections( raycaster, intersects, rayLocalSpace ) {\n\n \t\tlet intersection;\n\n \t\tconst geometry = this.geometry;\n \t\tconst material = this.material;\n\n \t\tconst index = geometry.index;\n \t\tconst position = geometry.attributes.position;\n \t\tconst uv = geometry.attributes.uv;\n \t\tconst uv1 = geometry.attributes.uv1;\n \t\tconst normal = geometry.attributes.normal;\n \t\tconst groups = geometry.groups;\n \t\tconst drawRange = geometry.drawRange;\n\n \t\tif ( index !== null ) {\n\n \t\t\t// indexed buffer geometry\n\n \t\t\tif ( Array.isArray( material ) ) {\n\n \t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst group = groups[ i ];\n \t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n \t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n \t\t\t\t\tconst end = Math.min( index.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );\n\n \t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n \t\t\t\t\t\tconst a = index.getX( j );\n \t\t\t\t\t\tconst b = index.getX( j + 1 );\n \t\t\t\t\t\tconst c = index.getX( j + 2 );\n\n \t\t\t\t\t\tintersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );\n\n \t\t\t\t\t\tif ( intersection ) {\n\n \t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n \t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n \t\t\t\t\t\t\tintersects.push( intersection );\n\n \t\t\t\t\t\t}\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\tconst start = Math.max( 0, drawRange.start );\n \t\t\t\tconst end = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n \t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n \t\t\t\t\tconst a = index.getX( i );\n \t\t\t\t\tconst b = index.getX( i + 1 );\n \t\t\t\t\tconst c = index.getX( i + 2 );\n\n \t\t\t\t\tintersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );\n\n \t\t\t\t\tif ( intersection ) {\n\n \t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n \t\t\t\t\t\tintersects.push( intersection );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t} else if ( position !== undefined ) {\n\n \t\t\t// non-indexed buffer geometry\n\n \t\t\tif ( Array.isArray( material ) ) {\n\n \t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst group = groups[ i ];\n \t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n \t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n \t\t\t\t\tconst end = Math.min( position.count, Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) ) );\n\n \t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n \t\t\t\t\t\tconst a = j;\n \t\t\t\t\t\tconst b = j + 1;\n \t\t\t\t\t\tconst c = j + 2;\n\n \t\t\t\t\t\tintersection = checkGeometryIntersection( this, groupMaterial, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );\n\n \t\t\t\t\t\tif ( intersection ) {\n\n \t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n \t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n \t\t\t\t\t\t\tintersects.push( intersection );\n\n \t\t\t\t\t\t}\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t} else {\n\n \t\t\t\tconst start = Math.max( 0, drawRange.start );\n \t\t\t\tconst end = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n \t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n \t\t\t\t\tconst a = i;\n \t\t\t\t\tconst b = i + 1;\n \t\t\t\t\tconst c = i + 2;\n\n \t\t\t\t\tintersection = checkGeometryIntersection( this, material, raycaster, rayLocalSpace, uv, uv1, normal, a, b, c );\n\n \t\t\t\t\tif ( intersection ) {\n\n \t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n \t\t\t\t\t\tintersects.push( intersection );\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t}\n\n \t}\n\n }\n\n function checkIntersection$1( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n \tlet intersect;\n\n \tif ( material.side === BackSide ) {\n\n \t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n \t} else {\n\n \t\tintersect = ray.intersectTriangle( pA, pB, pC, ( material.side === FrontSide ), point );\n\n \t}\n\n \tif ( intersect === null ) return null;\n\n \t_intersectionPointWorld.copy( point );\n \t_intersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n \tconst distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );\n\n \tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n \treturn {\n \t\tdistance: distance,\n \t\tpoint: _intersectionPointWorld.clone(),\n \t\tobject: object\n \t};\n\n }\n\n function checkGeometryIntersection( object, material, raycaster, ray, uv, uv1, normal, a, b, c ) {\n\n \tobject.getVertexPosition( a, _vA );\n \tobject.getVertexPosition( b, _vB );\n \tobject.getVertexPosition( c, _vC );\n\n \tconst intersection = checkIntersection$1( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );\n\n \tif ( intersection ) {\n\n \t\tconst barycoord = new Vector3();\n \t\tTriangle.getBarycoord( _intersectionPoint, _vA, _vB, _vC, barycoord );\n\n \t\tif ( uv ) {\n\n \t\t\tintersection.uv = Triangle.getInterpolatedAttribute( uv, a, b, c, barycoord, new Vector2() );\n\n \t\t}\n\n \t\tif ( uv1 ) {\n\n \t\t\tintersection.uv1 = Triangle.getInterpolatedAttribute( uv1, a, b, c, barycoord, new Vector2() );\n\n \t\t}\n\n \t\tif ( normal ) {\n\n \t\t\tintersection.normal = Triangle.getInterpolatedAttribute( normal, a, b, c, barycoord, new Vector3() );\n\n \t\t\tif ( intersection.normal.dot( ray.direction ) > 0 ) {\n\n \t\t\t\tintersection.normal.multiplyScalar( -1 );\n\n \t\t\t}\n\n \t\t}\n\n \t\tconst face = {\n \t\t\ta: a,\n \t\t\tb: b,\n \t\t\tc: c,\n \t\t\tnormal: new Vector3(),\n \t\t\tmaterialIndex: 0\n \t\t};\n\n \t\tTriangle.getNormal( _vA, _vB, _vC, face.normal );\n\n \t\tintersection.face = face;\n \t\tintersection.barycoord = barycoord;\n\n \t}\n\n \treturn intersection;\n\n }\n\n /**\n * A geometry class for representing a plane.\n *\n * ```js\n * const geometry = new THREE.PlaneGeometry( 1, 1 );\n * const material = new THREE.MeshBasicMaterial( { color: 0xffff00, side: THREE.DoubleSide } );\n * const plane = new THREE.Mesh( geometry, material );\n * scene.add( plane );\n * ```\n *\n * @augments BufferGeometry\n * @demo scenes/geometry-browser.html#PlaneGeometry\n */\n class PlaneGeometry extends BufferGeometry {\n\n \t/**\n \t * Constructs a new plane geometry.\n \t *\n \t * @param {number} [width=1] - The width along the X axis.\n \t * @param {number} [height=1] - The height along the Y axis\n \t * @param {number} [widthSegments=1] - The number of segments along the X axis.\n \t * @param {number} [heightSegments=1] - The number of segments along the Y axis.\n \t */\n \tconstructor( width = 1, height = 1, widthSegments = 1, heightSegments = 1 ) {\n\n \t\tsuper();\n\n \t\tthis.type = 'PlaneGeometry';\n\n \t\t/**\n \t\t * Holds the constructor parameters that have been\n \t\t * used to generate the geometry. Any modification\n \t\t * after instantiation does not change the geometry.\n \t\t *\n \t\t * @type {Object}\n \t\t */\n \t\tthis.parameters = {\n \t\t\twidth: width,\n \t\t\theight: height,\n \t\t\twidthSegments: widthSegments,\n \t\t\theightSegments: heightSegments\n \t\t};\n\n \t\tconst width_half = width / 2;\n \t\tconst height_half = height / 2;\n\n \t\tconst gridX = Math.floor( widthSegments );\n \t\tconst gridY = Math.floor( heightSegments );\n\n \t\tconst gridX1 = gridX + 1;\n \t\tconst gridY1 = gridY + 1;\n\n \t\tconst segment_width = width / gridX;\n \t\tconst segment_height = height / gridY;\n\n \t\t//\n\n \t\tconst indices = [];\n \t\tconst vertices = [];\n \t\tconst normals = [];\n \t\tconst uvs = [];\n\n \t\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n \t\t\tconst y = iy * segment_height - height_half;\n\n \t\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n \t\t\t\tconst x = ix * segment_width - width_half;\n\n \t\t\t\tvertices.push( x, - y, 0 );\n\n \t\t\t\tnormals.push( 0, 0, 1 );\n\n \t\t\t\tuvs.push( ix / gridX );\n \t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n \t\t\t}\n\n \t\t}\n\n \t\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n \t\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n \t\t\t\tconst a = ix + gridX1 * iy;\n \t\t\t\tconst b = ix + gridX1 * ( iy + 1 );\n \t\t\t\tconst c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n \t\t\t\tconst d = ( ix + 1 ) + gridX1 * iy;\n\n \t\t\t\tindices.push( a, b, d );\n \t\t\t\tindices.push( b, c, d );\n\n \t\t\t}\n\n \t\t}\n\n \t\tthis.setIndex( indices );\n \t\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n \t\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n \t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n \t}\n\n \tcopy( source ) {\n\n \t\tsuper.copy( source );\n\n \t\tthis.parameters = Object.assign( {}, source.parameters );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Factory method for creating an instance of this class from the given\n \t * JSON object.\n \t *\n \t * @param {Object} data - A JSON object representing the serialized geometry.\n \t * @return {PlaneGeometry} A new instance.\n \t */\n \tstatic fromJSON( data ) {\n\n \t\treturn new PlaneGeometry( data.width, data.height, data.widthSegments, data.heightSegments );\n\n \t}\n\n }\n\n /**\n * @class\n * @classdesc A simple caching system, used internally by {@link FileLoader}.\n * To enable caching across all loaders that use {@link FileLoader}, add `THREE.Cache.enabled = true.` once in your app.\n * @hideconstructor\n */\n const Cache = {\n\n \t/**\n \t * Whether caching is enabled or not.\n \t *\n \t * @static\n \t * @type {boolean}\n \t * @default false\n \t */\n \tenabled: false,\n\n \t/**\n \t * A dictionary that holds cached files.\n \t *\n \t * @static\n \t * @type {Object<string,Object>}\n \t */\n \tfiles: {},\n\n \t/**\n \t * Adds a cache entry with a key to reference the file. If this key already\n \t * holds a file, it is overwritten.\n \t *\n \t * @static\n \t * @param {string} key - The key to reference the cached file.\n \t * @param {Object} file - The file to be cached.\n \t */\n \tadd: function ( key, file ) {\n\n \t\tif ( this.enabled === false ) return;\n\n \t\tif ( isBlobURL( key ) ) return;\n\n \t\t// log( 'Cache', 'Adding key:', key );\n\n \t\tthis.files[ key ] = file;\n\n \t},\n\n \t/**\n \t * Gets the cached value for the given key.\n \t *\n \t * @static\n \t * @param {string} key - The key to reference the cached file.\n \t * @return {Object|undefined} The cached file. If the key does not exist `undefined` is returned.\n \t */\n \tget: function ( key ) {\n\n \t\tif ( this.enabled === false ) return;\n\n \t\tif ( isBlobURL( key ) ) return;\n\n \t\t// log( 'Cache', 'Checking key:', key );\n\n \t\treturn this.files[ key ];\n\n \t},\n\n \t/**\n \t * Removes the cached file associated with the given key.\n \t *\n \t * @static\n \t * @param {string} key - The key to reference the cached file.\n \t */\n \tremove: function ( key ) {\n\n \t\tdelete this.files[ key ];\n\n \t},\n\n \t/**\n \t * Remove all values from the cache.\n \t *\n \t * @static\n \t */\n \tclear: function () {\n\n \t\tthis.files = {};\n\n \t}\n\n };\n\n /**\n * Returns true if the given cache key contains the blob: scheme.\n *\n * @private\n * @param {string} key - The cache key.\n * @return {boolean} Whether the given cache key contains the blob: scheme or not.\n */\n function isBlobURL( key ) {\n\n \ttry {\n\n \t\tconst urlString = key.slice( key.indexOf( ':' ) + 1 ); // remove type identifier\n\n \t\tconst url = new URL( urlString );\n \t\treturn url.protocol === 'blob:';\n\n \t} catch ( e ) {\n\n \t\t// If the string is not a valid URL, it throws an error\n \t\treturn false;\n\n \t}\n\n }\n\n /**\n * Handles and keeps track of loaded and pending data. A default global\n * instance of this class is created and used by loaders if not supplied\n * manually.\n *\n * In general that should be sufficient, however there are times when it can\n * be useful to have separate loaders - for example if you want to show\n * separate loading bars for objects and textures.\n *\n * ```js\n * const manager = new THREE.LoadingManager();\n * manager.onLoad = () => console.log( 'Loading complete!' );\n *\n * const loader1 = new OBJLoader( manager );\n * const loader2 = new ColladaLoader( manager );\n * ```\n */\n class LoadingManager {\n\n \t/**\n \t * Constructs a new loading manager.\n \t *\n \t * @param {Function} [onLoad] - Executes when all items have been loaded.\n \t * @param {Function} [onProgress] - Executes when single items have been loaded.\n \t * @param {Function} [onError] - Executes when an error occurs.\n \t */\n \tconstructor( onLoad, onProgress, onError ) {\n\n \t\tconst scope = this;\n\n \t\tlet isLoading = false;\n \t\tlet itemsLoaded = 0;\n \t\tlet itemsTotal = 0;\n \t\tlet urlModifier = undefined;\n \t\tconst handlers = [];\n\n \t\t// Refer to #5689 for the reason why we don't set .onStart\n \t\t// in the constructor\n\n \t\t/**\n \t\t * Executes when an item starts loading.\n \t\t *\n \t\t * @type {Function|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.onStart = undefined;\n\n \t\t/**\n \t\t * Executes when all items have been loaded.\n \t\t *\n \t\t * @type {Function|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.onLoad = onLoad;\n\n \t\t/**\n \t\t * Executes when single items have been loaded.\n \t\t *\n \t\t * @type {Function|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.onProgress = onProgress;\n\n \t\t/**\n \t\t * Executes when an error occurs.\n \t\t *\n \t\t * @type {Function|undefined}\n \t\t * @default undefined\n \t\t */\n \t\tthis.onError = onError;\n\n \t\t/**\n \t\t * Used for aborting ongoing requests in loaders using this manager.\n \t\t *\n \t\t * @private\n \t\t * @type {AbortController | null}\n \t\t */\n \t\tthis._abortController = null;\n\n \t\t/**\n \t\t * This should be called by any loader using the manager when the loader\n \t\t * starts loading an item.\n \t\t *\n \t\t * @param {string} url - The URL to load.\n \t\t */\n \t\tthis.itemStart = function ( url ) {\n\n \t\t\titemsTotal ++;\n\n \t\t\tif ( isLoading === false ) {\n\n \t\t\t\tif ( scope.onStart !== undefined ) {\n\n \t\t\t\t\tscope.onStart( url, itemsLoaded, itemsTotal );\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tisLoading = true;\n\n \t\t};\n\n \t\t/**\n \t\t * This should be called by any loader using the manager when the loader\n \t\t * ended loading an item.\n \t\t *\n \t\t * @param {string} url - The URL of the loaded item.\n \t\t */\n \t\tthis.itemEnd = function ( url ) {\n\n \t\t\titemsLoaded ++;\n\n \t\t\tif ( scope.onProgress !== undefined ) {\n\n \t\t\t\tscope.onProgress( url, itemsLoaded, itemsTotal );\n\n \t\t\t}\n\n \t\t\tif ( itemsLoaded === itemsTotal ) {\n\n \t\t\t\tisLoading = false;\n\n \t\t\t\tif ( scope.onLoad !== undefined ) {\n\n \t\t\t\t\tscope.onLoad();\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t};\n\n \t\t/**\n \t\t * This should be called by any loader using the manager when the loader\n \t\t * encounters an error when loading an item.\n \t\t *\n \t\t * @param {string} url - The URL of the item that produces an error.\n \t\t */\n \t\tthis.itemError = function ( url ) {\n\n \t\t\tif ( scope.onError !== undefined ) {\n\n \t\t\t\tscope.onError( url );\n\n \t\t\t}\n\n \t\t};\n\n \t\t/**\n \t\t * Given a URL, uses the URL modifier callback (if any) and returns a\n \t\t * resolved URL. If no URL modifier is set, returns the original URL.\n \t\t *\n \t\t * @param {string} url - The URL to load.\n \t\t * @return {string} The resolved URL.\n \t\t */\n \t\tthis.resolveURL = function ( url ) {\n\n \t\t\t// Normalize to NFC so that Unicode URIs (e.g. from glTF)\n \t\t\t// are percent-encoded correctly per RFC 3987.\n\n \t\t\turl = url.normalize( 'NFC' );\n\n \t\t\tif ( urlModifier ) {\n\n \t\t\t\treturn urlModifier( url );\n\n \t\t\t}\n\n \t\t\treturn url;\n\n \t\t};\n\n \t\t/**\n \t\t * If provided, the callback will be passed each resource URL before a\n \t\t * request is sent. The callback may return the original URL, or a new URL to\n \t\t * override loading behavior. This behavior can be used to load assets from\n \t\t * .ZIP files, drag-and-drop APIs, and Data URIs.\n \t\t *\n \t\t * ```js\n \t\t * const blobs = {'fish.gltf': blob1, 'diffuse.png': blob2, 'normal.png': blob3};\n \t\t *\n \t\t * const manager = new THREE.LoadingManager();\n \t\t *\n \t\t * // Initialize loading manager with URL callback.\n \t\t * const objectURLs = [];\n \t\t * manager.setURLModifier( ( url ) => {\n \t\t *\n \t\t * \turl = URL.createObjectURL( blobs[ url ] );\n \t\t * \tobjectURLs.push( url );\n \t\t * \treturn url;\n \t\t *\n \t\t * } );\n \t\t *\n \t\t * // Load as usual, then revoke the blob URLs.\n \t\t * const loader = new GLTFLoader( manager );\n \t\t * loader.load( 'fish.gltf', (gltf) => {\n \t\t *\n \t\t * \tscene.add( gltf.scene );\n \t\t * \tobjectURLs.forEach( ( url ) => URL.revokeObjectURL( url ) );\n \t\t *\n \t\t * } );\n \t\t * ```\n \t\t *\n \t\t * @param {function(string):string} transform - URL modifier callback. Called with an URL and must return a resolved URL.\n \t\t * @return {LoadingManager} A reference to this loading manager.\n \t\t */\n \t\tthis.setURLModifier = function ( transform ) {\n\n \t\t\turlModifier = transform;\n\n \t\t\treturn this;\n\n \t\t};\n\n \t\t/**\n \t\t * Registers a loader with the given regular expression. Can be used to\n \t\t * define what loader should be used in order to load specific files. A\n \t\t * typical use case is to overwrite the default loader for textures.\n \t\t *\n \t\t * ```js\n \t\t * // add handler for TGA textures\n \t\t * manager.addHandler( /\\.tga$/i, new TGALoader() );\n \t\t * ```\n \t\t *\n \t\t * @param {string} regex - A regular expression.\n \t\t * @param {Loader} loader - A loader that should handle matched cases.\n \t\t * @return {LoadingManager} A reference to this loading manager.\n \t\t */\n \t\tthis.addHandler = function ( regex, loader ) {\n\n \t\t\thandlers.push( regex, loader );\n\n \t\t\treturn this;\n\n \t\t};\n\n \t\t/**\n \t\t * Removes the loader for the given regular expression.\n \t\t *\n \t\t * @param {string} regex - A regular expression.\n \t\t * @return {LoadingManager} A reference to this loading manager.\n \t\t */\n \t\tthis.removeHandler = function ( regex ) {\n\n \t\t\tconst index = handlers.indexOf( regex );\n\n \t\t\tif ( index !== -1 ) {\n\n \t\t\t\thandlers.splice( index, 2 );\n\n \t\t\t}\n\n \t\t\treturn this;\n\n \t\t};\n\n \t\t/**\n \t\t * Can be used to retrieve the registered loader for the given file path.\n \t\t *\n \t\t * @param {string} file - The file path.\n \t\t * @return {?Loader} The registered loader. Returns `null` if no loader was found.\n \t\t */\n \t\tthis.getHandler = function ( file ) {\n\n \t\t\tfor ( let i = 0, l = handlers.length; i < l; i += 2 ) {\n\n \t\t\t\tconst regex = handlers[ i ];\n \t\t\t\tconst loader = handlers[ i + 1 ];\n\n \t\t\t\tif ( regex.global ) regex.lastIndex = 0; // see #17920\n\n \t\t\t\tif ( regex.test( file ) ) {\n\n \t\t\t\t\treturn loader;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\treturn null;\n\n \t\t};\n\n \t\t/**\n \t\t * Can be used to abort ongoing loading requests in loaders using this manager.\n \t\t * The abort only works if the loaders implement {@link Loader#abort} and `AbortSignal.any()`\n \t\t * is supported in the browser.\n \t\t *\n \t\t * @return {LoadingManager} A reference to this loading manager.\n \t\t */\n \t\tthis.abort = function () {\n\n\n \t\t\tthis.abortController.abort();\n \t\t\tthis._abortController = null;\n\n \t\t\treturn this;\n\n \t\t};\n\n \t}\n\n \t// TODO: Revert this back to a single member variable once this issue has been fixed\n \t// https://github.com/cloudflare/workerd/issues/3657\n\n \t/**\n \t * Used for aborting ongoing requests in loaders using this manager.\n \t *\n \t * @type {AbortController}\n \t */\n \tget abortController() {\n\n \t\tif ( ! this._abortController ) {\n\n \t\t\tthis._abortController = new AbortController();\n\n \t\t}\n\n \t\treturn this._abortController;\n\n \t}\n\n }\n\n /**\n * The global default loading manager.\n *\n * @constant\n * @type {LoadingManager}\n */\n const DefaultLoadingManager = /*@__PURE__*/ new LoadingManager();\n\n /**\n * Abstract base class for loaders.\n *\n * @abstract\n */\n class Loader {\n\n \t/**\n \t * Constructs a new loader.\n \t *\n \t * @param {LoadingManager} [manager] - The loading manager.\n \t */\n \tconstructor( manager ) {\n\n \t\t/**\n \t\t * The loading manager.\n \t\t *\n \t\t * @type {LoadingManager}\n \t\t * @default DefaultLoadingManager\n \t\t */\n \t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n \t\t/**\n \t\t * The crossOrigin string to implement CORS for loading the url from a\n \t\t * different domain that allows CORS.\n \t\t *\n \t\t * @type {string}\n \t\t * @default 'anonymous'\n \t\t */\n \t\tthis.crossOrigin = 'anonymous';\n\n \t\t/**\n \t\t * Whether the XMLHttpRequest uses credentials.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.withCredentials = false;\n\n \t\t/**\n \t\t * The base path from which the asset will be loaded.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.path = '';\n\n \t\t/**\n \t\t * The base path from which additional resources like textures will be loaded.\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.resourcePath = '';\n\n \t\t/**\n \t\t * The [request header](https://developer.mozilla.org/en-US/docs/Glossary/Request_header)\n \t\t * used in HTTP request.\n \t\t *\n \t\t * @type {Object<string, any>}\n \t\t */\n \t\tthis.requestHeader = {};\n\n \t\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n \t\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * This method needs to be implemented by all concrete loaders. It holds the\n \t * logic for loading assets from the backend.\n \t *\n \t * @abstract\n \t * @param {string} url - The path/URL of the file to be loaded.\n \t * @param {Function} onLoad - Executed when the loading process has been finished.\n \t * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.\n \t * @param {onErrorCallback} [onError] - Executed when errors occur.\n \t */\n \tload( /* url, onLoad, onProgress, onError */ ) {}\n\n \t/**\n \t * A async version of {@link Loader#load}.\n \t *\n \t * @param {string} url - The path/URL of the file to be loaded.\n \t * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.\n \t * @return {Promise} A Promise that resolves when the asset has been loaded.\n \t */\n \tloadAsync( url, onProgress ) {\n\n \t\tconst scope = this;\n\n \t\treturn new Promise( function ( resolve, reject ) {\n\n \t\t\tscope.load( url, resolve, onProgress, reject );\n\n \t\t} );\n\n \t}\n\n \t/**\n \t * This method needs to be implemented by all concrete loaders. It holds the\n \t * logic for parsing the asset into three.js entities.\n \t *\n \t * @abstract\n \t * @param {any} data - The data to parse.\n \t */\n \tparse( /* data */ ) {}\n\n \t/**\n \t * Sets the `crossOrigin` String to implement CORS for loading the URL\n \t * from a different domain that allows CORS.\n \t *\n \t * @param {string} crossOrigin - The `crossOrigin` value.\n \t * @return {Loader} A reference to this instance.\n \t */\n \tsetCrossOrigin( crossOrigin ) {\n\n \t\tthis.crossOrigin = crossOrigin;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Whether the XMLHttpRequest uses credentials such as cookies, authorization\n \t * headers or TLS client certificates, see [XMLHttpRequest.withCredentials](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials).\n \t *\n \t * Note: This setting has no effect if you are loading files locally or from the same domain.\n \t *\n \t * @param {boolean} value - The `withCredentials` value.\n \t * @return {Loader} A reference to this instance.\n \t */\n \tsetWithCredentials( value ) {\n\n \t\tthis.withCredentials = value;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the base path for the asset.\n \t *\n \t * @param {string} path - The base path.\n \t * @return {Loader} A reference to this instance.\n \t */\n \tsetPath( path ) {\n\n \t\tthis.path = path;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the base path for dependent resources like textures.\n \t *\n \t * @param {string} resourcePath - The resource path.\n \t * @return {Loader} A reference to this instance.\n \t */\n \tsetResourcePath( resourcePath ) {\n\n \t\tthis.resourcePath = resourcePath;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the given request header.\n \t *\n \t * @param {Object} requestHeader - A [request header](https://developer.mozilla.org/en-US/docs/Glossary/Request_header)\n \t * for configuring the HTTP request.\n \t * @return {Loader} A reference to this instance.\n \t */\n \tsetRequestHeader( requestHeader ) {\n\n \t\tthis.requestHeader = requestHeader;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * This method can be implemented in loaders for aborting ongoing requests.\n \t *\n \t * @abstract\n \t * @return {Loader} A reference to this instance.\n \t */\n \tabort() {\n\n \t\treturn this;\n\n \t}\n\n }\n\n /**\n * Callback for onProgress in loaders.\n *\n * @callback onProgressCallback\n * @param {ProgressEvent} event - An instance of `ProgressEvent` that represents the current loading status.\n */\n\n /**\n * Callback for onError in loaders.\n *\n * @callback onErrorCallback\n * @param {Error} error - The error which occurred during the loading process.\n */\n\n /**\n * The default material name that is used by loaders\n * when creating materials for loaded 3D objects.\n *\n * Note: Not all loaders might honor this setting.\n *\n * @static\n * @type {string}\n * @default '__DEFAULT'\n */\n Loader.DEFAULT_MATERIAL_NAME = '__DEFAULT';\n\n const loading = {};\n\n class HttpError extends Error {\n\n \tconstructor( message, response ) {\n\n \t\tsuper( message );\n \t\tthis.response = response;\n\n \t}\n\n }\n\n /**\n * A low level class for loading resources with the Fetch API, used internally by\n * most loaders. It can also be used directly to load any file type that does\n * not have a loader.\n *\n * This loader supports caching. If you want to use it, add `THREE.Cache.enabled = true;`\n * once to your application.\n *\n * ```js\n * const loader = new THREE.FileLoader();\n * const data = await loader.loadAsync( 'example.txt' );\n * ```\n *\n * @augments Loader\n */\n class FileLoader extends Loader {\n\n \t/**\n \t * Constructs a new file loader.\n \t *\n \t * @param {LoadingManager} [manager] - The loading manager.\n \t */\n \tconstructor( manager ) {\n\n \t\tsuper( manager );\n\n \t\t/**\n \t\t * The expected mime type. Valid values can be found\n \t\t * [here](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#mimetype)\n \t\t *\n \t\t * @type {string}\n \t\t */\n \t\tthis.mimeType = '';\n\n \t\t/**\n \t\t * The expected response type.\n \t\t *\n \t\t * @type {('arraybuffer'|'blob'|'document'|'json'|'')}\n \t\t * @default ''\n \t\t */\n \t\tthis.responseType = '';\n\n \t\t/**\n \t\t * Used for aborting requests.\n \t\t *\n \t\t * @private\n \t\t * @type {AbortController}\n \t\t */\n \t\tthis._abortController = new AbortController();\n\n \t}\n\n \t/**\n \t * Starts loading from the given URL and pass the loaded response to the `onLoad()` callback.\n \t *\n \t * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.\n \t * @param {function(any)} onLoad - Executed when the loading process has been finished.\n \t * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.\n \t * @param {onErrorCallback} [onError] - Executed when errors occur.\n \t */\n \tload( url, onLoad, onProgress, onError ) {\n\n \t\tif ( url === undefined ) url = '';\n\n \t\tif ( this.path !== undefined ) url = this.path + url;\n\n \t\turl = this.manager.resolveURL( url );\n\n \t\tconst cached = Cache.get( `file:${url}` );\n\n \t\tif ( cached !== undefined ) {\n\n \t\t\tthis.manager.itemStart( url );\n\n \t\t\tsetTimeout( () => {\n\n \t\t\t\tif ( onLoad ) onLoad( cached );\n\n \t\t\t\tthis.manager.itemEnd( url );\n\n \t\t\t}, 0 );\n\n \t\t\treturn;\n\n \t\t}\n\n \t\t// Check if request is duplicate\n\n \t\tif ( loading[ url ] !== undefined ) {\n\n \t\t\tloading[ url ].push( {\n\n \t\t\t\tonLoad: onLoad,\n \t\t\t\tonProgress: onProgress,\n \t\t\t\tonError: onError\n\n \t\t\t} );\n\n \t\t\treturn;\n\n \t\t}\n\n \t\t// Initialise array for duplicate requests\n \t\tloading[ url ] = [];\n\n \t\tloading[ url ].push( {\n \t\t\tonLoad: onLoad,\n \t\t\tonProgress: onProgress,\n \t\t\tonError: onError,\n \t\t} );\n\n \t\t// create request\n \t\tconst req = new Request( url, {\n \t\t\theaders: new Headers( this.requestHeader ),\n \t\t\tcredentials: this.withCredentials ? 'include' : 'same-origin',\n \t\t\tsignal: ( typeof AbortSignal.any === 'function' ) ? AbortSignal.any( [ this._abortController.signal, this.manager.abortController.signal ] ) : this._abortController.signal\n \t\t} );\n\n \t\t// record states ( avoid data race )\n \t\tconst mimeType = this.mimeType;\n \t\tconst responseType = this.responseType;\n\n \t\t// start the fetch\n \t\tfetch( req )\n \t\t\t.then( response => {\n\n \t\t\t\tif ( response.status === 200 || response.status === 0 ) {\n\n \t\t\t\t\t// Some browsers return HTTP Status 0 when using non-http protocol\n \t\t\t\t\t// e.g. 'file://' or 'data://'. Handle as success.\n\n \t\t\t\t\tif ( response.status === 0 ) {\n\n \t\t\t\t\t\twarn( 'FileLoader: HTTP Status 0 received.' );\n\n \t\t\t\t\t}\n\n \t\t\t\t\t// Workaround: Checking if response.body === undefined for Alipay browser #23548\n\n \t\t\t\t\tif ( typeof ReadableStream === 'undefined' || response.body === undefined || response.body.getReader === undefined ) {\n\n \t\t\t\t\t\treturn response;\n\n \t\t\t\t\t}\n\n \t\t\t\t\tconst callbacks = loading[ url ];\n \t\t\t\t\tconst reader = response.body.getReader();\n\n \t\t\t\t\t// Nginx needs X-File-Size check\n \t\t\t\t\t// https://serverfault.com/questions/482875/why-does-nginx-remove-content-length-header-for-chunked-content\n \t\t\t\t\tconst contentLength = response.headers.get( 'X-File-Size' ) || response.headers.get( 'Content-Length' );\n \t\t\t\t\tconst total = contentLength ? parseInt( contentLength ) : 0;\n \t\t\t\t\tconst lengthComputable = total !== 0;\n \t\t\t\t\tlet loaded = 0;\n\n \t\t\t\t\t// periodically read data into the new stream tracking while download progress\n \t\t\t\t\tconst stream = new ReadableStream( {\n \t\t\t\t\t\tstart( controller ) {\n\n \t\t\t\t\t\t\treadData();\n\n \t\t\t\t\t\t\tfunction readData() {\n\n \t\t\t\t\t\t\t\treader.read().then( ( { done, value } ) => {\n\n \t\t\t\t\t\t\t\t\tif ( done ) {\n\n \t\t\t\t\t\t\t\t\t\tcontroller.close();\n\n \t\t\t\t\t\t\t\t\t} else {\n\n \t\t\t\t\t\t\t\t\t\tloaded += value.byteLength;\n\n \t\t\t\t\t\t\t\t\t\tconst event = new ProgressEvent( 'progress', { lengthComputable, loaded, total } );\n \t\t\t\t\t\t\t\t\t\tfor ( let i = 0, il = callbacks.length; i < il; i ++ ) {\n\n \t\t\t\t\t\t\t\t\t\t\tconst callback = callbacks[ i ];\n \t\t\t\t\t\t\t\t\t\t\tif ( callback.onProgress ) callback.onProgress( event );\n\n \t\t\t\t\t\t\t\t\t\t}\n\n \t\t\t\t\t\t\t\t\t\tcontroller.enqueue( value );\n \t\t\t\t\t\t\t\t\t\treadData();\n\n \t\t\t\t\t\t\t\t\t}\n\n \t\t\t\t\t\t\t\t}, ( e ) => {\n\n \t\t\t\t\t\t\t\t\tcontroller.error( e );\n\n \t\t\t\t\t\t\t\t} );\n\n \t\t\t\t\t\t\t}\n\n \t\t\t\t\t\t}\n\n \t\t\t\t\t} );\n\n \t\t\t\t\treturn new Response( stream );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tthrow new HttpError( `fetch for \"${response.url}\" responded with ${response.status}: ${response.statusText}`, response );\n\n \t\t\t\t}\n\n \t\t\t} )\n \t\t\t.then( response => {\n\n \t\t\t\tswitch ( responseType ) {\n\n \t\t\t\t\tcase 'arraybuffer':\n\n \t\t\t\t\t\treturn response.arrayBuffer();\n\n \t\t\t\t\tcase 'blob':\n\n \t\t\t\t\t\treturn response.blob();\n\n \t\t\t\t\tcase 'document':\n\n \t\t\t\t\t\treturn response.text()\n \t\t\t\t\t\t\t.then( text => {\n\n \t\t\t\t\t\t\t\tconst parser = new DOMParser();\n \t\t\t\t\t\t\t\treturn parser.parseFromString( text, mimeType );\n\n \t\t\t\t\t\t\t} );\n\n \t\t\t\t\tcase 'json':\n\n \t\t\t\t\t\treturn response.json();\n\n \t\t\t\t\tdefault:\n\n \t\t\t\t\t\tif ( mimeType === '' ) {\n\n \t\t\t\t\t\t\treturn response.text();\n\n \t\t\t\t\t\t} else {\n\n \t\t\t\t\t\t\t// sniff encoding\n \t\t\t\t\t\t\tconst re = /charset=\"?([^;\"\\s]*)\"?/i;\n \t\t\t\t\t\t\tconst exec = re.exec( mimeType );\n \t\t\t\t\t\t\tconst label = exec && exec[ 1 ] ? exec[ 1 ].toLowerCase() : undefined;\n \t\t\t\t\t\t\tconst decoder = new TextDecoder( label );\n \t\t\t\t\t\t\treturn response.arrayBuffer().then( ab => decoder.decode( ab ) );\n\n \t\t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t} )\n \t\t\t.then( data => {\n\n \t\t\t\t// Add to cache only on HTTP success, so that we do not cache\n \t\t\t\t// error response bodies as proper responses to requests.\n \t\t\t\tCache.add( `file:${url}`, data );\n\n \t\t\t\tconst callbacks = loading[ url ];\n \t\t\t\tdelete loading[ url ];\n\n \t\t\t\tfor ( let i = 0, il = callbacks.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst callback = callbacks[ i ];\n \t\t\t\t\tif ( callback.onLoad ) callback.onLoad( data );\n\n \t\t\t\t}\n\n \t\t\t} )\n \t\t\t.catch( err => {\n\n \t\t\t\t// Abort errors and other errors are handled the same\n\n \t\t\t\tconst callbacks = loading[ url ];\n\n \t\t\t\tif ( callbacks === undefined ) {\n\n \t\t\t\t\t// When onLoad was called and url was deleted in `loading`\n \t\t\t\t\tthis.manager.itemError( url );\n \t\t\t\t\tthrow err;\n\n \t\t\t\t}\n\n \t\t\t\tdelete loading[ url ];\n\n \t\t\t\tfor ( let i = 0, il = callbacks.length; i < il; i ++ ) {\n\n \t\t\t\t\tconst callback = callbacks[ i ];\n \t\t\t\t\tif ( callback.onError ) callback.onError( err );\n\n \t\t\t\t}\n\n \t\t\t\tthis.manager.itemError( url );\n\n \t\t\t} )\n \t\t\t.finally( () => {\n\n \t\t\t\tthis.manager.itemEnd( url );\n\n \t\t\t} );\n\n \t\tthis.manager.itemStart( url );\n\n \t}\n\n \t/**\n \t * Sets the expected response type.\n \t *\n \t * @param {('arraybuffer'|'blob'|'document'|'json'|'')} value - The response type.\n \t * @return {FileLoader} A reference to this file loader.\n \t */\n \tsetResponseType( value ) {\n\n \t\tthis.responseType = value;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the expected mime type of the loaded file.\n \t *\n \t * @param {string} value - The mime type.\n \t * @return {FileLoader} A reference to this file loader.\n \t */\n \tsetMimeType( value ) {\n\n \t\tthis.mimeType = value;\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Aborts ongoing fetch requests.\n \t *\n \t * @return {FileLoader} A reference to this instance.\n \t */\n \tabort() {\n\n \t\tthis._abortController.abort();\n \t\tthis._abortController = new AbortController();\n\n \t\treturn this;\n\n \t}\n\n }\n\n /**\n * Represents a 2x2 matrix.\n *\n * A Note on Row-Major and Column-Major Ordering:\n *\n * The constructor and {@link Matrix2#set} method take arguments in\n * [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order)\n * order, while internally they are stored in the {@link Matrix2#elements} array in column-major order.\n * This means that calling:\n * ```js\n * const m = new THREE.Matrix2();\n * m.set( 11, 12,\n * 21, 22 );\n * ```\n * will result in the elements array containing:\n * ```js\n * m.elements = [ 11, 21,\n * 12, 22 ];\n * ```\n * and internally all calculations are performed using column-major ordering.\n * However, as the actual ordering makes no difference mathematically and\n * most people are used to thinking about matrices in row-major order, the\n * three.js documentation shows matrices in row-major order. Just bear in\n * mind that if you are reading the source code, you'll have to take the\n * transpose of any matrices outlined here to make sense of the calculations.\n */\n class Matrix2 {\n\n \tstatic {\n\n \t\t/**\n \t\t * This flag can be used for type testing.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @readonly\n \t\t * @default true\n \t\t */\n \t\tMatrix2.prototype.isMatrix2 = true;\n\n \t}\n\n \t/**\n \t * Constructs a new 2x2 matrix. The arguments are supposed to be\n \t * in row-major order. If no arguments are provided, the constructor\n \t * initializes the matrix as an identity matrix.\n \t *\n \t * @param {number} [n11] - 1-1 matrix element.\n \t * @param {number} [n12] - 1-2 matrix element.\n \t * @param {number} [n21] - 2-1 matrix element.\n \t * @param {number} [n22] - 2-2 matrix element.\n \t */\n \tconstructor( n11, n12, n21, n22 ) {\n\n \t\t/**\n \t\t * A column-major list of matrix values.\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.elements = [\n \t\t\t1, 0,\n \t\t\t0, 1,\n \t\t];\n\n \t\tif ( n11 !== undefined ) {\n\n \t\t\tthis.set( n11, n12, n21, n22 );\n\n \t\t}\n\n \t}\n\n \t/**\n \t * Sets this matrix to the 2x2 identity matrix.\n \t *\n \t * @return {Matrix2} A reference to this matrix.\n \t */\n \tidentity() {\n\n \t\tthis.set(\n \t\t\t1, 0,\n \t\t\t0, 1,\n \t\t);\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix from the given array.\n \t *\n \t * @param {Array<number>} array - The matrix elements in column-major order.\n \t * @param {number} [offset=0] - Index of the first element in the array.\n \t * @return {Matrix2} A reference to this matrix.\n \t */\n \tfromArray( array, offset = 0 ) {\n\n \t\tfor ( let i = 0; i < 4; i ++ ) {\n\n \t\t\tthis.elements[ i ] = array[ i + offset ];\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Sets the elements of the matrix.The arguments are supposed to be\n \t * in row-major order.\n \t *\n \t * @param {number} n11 - 1-1 matrix element.\n \t * @param {number} n12 - 1-2 matrix element.\n \t * @param {number} n21 - 2-1 matrix element.\n \t * @param {number} n22 - 2-2 matrix element.\n \t * @return {Matrix2} A reference to this matrix.\n \t */\n \tset( n11, n12, n21, n22 ) {\n\n \t\tconst te = this.elements;\n\n \t\tte[ 0 ] = n11; te[ 2 ] = n12;\n \t\tte[ 1 ] = n21; te[ 3 ] = n22;\n\n \t\treturn this;\n\n \t}\n\n }\n\n if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n \t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'register', { detail: {\n \t\trevision: REVISION,\n \t} } ) );\n\n }\n\n if ( typeof window !== 'undefined' ) {\n\n \tif ( window.__THREE__ ) {\n\n \t\twarn( 'WARNING: Multiple instances of Three.js being imported.' );\n\n \t} else {\n\n \t\twindow.__THREE__ = REVISION;\n\n \t}\n\n }\n\n /**\n * @license\n * Copyright 2010-2026 Three.js Authors\n * SPDX-License-Identifier: MIT\n */\n const _m$1 = /*@__PURE__*/ new Matrix3();\n\n _m$1.set( -1, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );\n const _m = /*@__PURE__*/ new Matrix3();\n\n _m.set( -1, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );\n\n /*!\n fflate - fast JavaScript compression/decompression\n <https://101arrowz.github.io/fflate>\n Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE\n version 0.8.2\n */\n\n // aliases for shorter compressed code (most minifers don't do this)\n var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;\n // fixed length extra bits\n var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);\n // fixed distance extra bits\n var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);\n // code length index map\n var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n // get base, reverse index map from extra bits\n var freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new i32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return { b: b, r: r };\n };\n var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;\n // we can ignore the fact that the other numbers are wrong; they never happen anyway\n fl[28] = 258, revfl[258] = 28;\n var _b = freb(fdeb, 0), fd = _b.b;\n // map of value to reverse (assuming 16 bits)\n var rev = new u16(32768);\n for (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;\n }\n // create huffman tree from u8 \"map\": index -> code length for code index\n // mb (max bits) must be at most 15\n // TODO: optimize/split up?\n var hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i) {\n if (cd[i])\n ++l[cd[i] - 1];\n }\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 1; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i) {\n if (cd[i]) {\n co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);\n }\n }\n }\n return co;\n });\n // fixed length tree\n var flt = new u8(288);\n for (var i = 0; i < 144; ++i)\n flt[i] = 8;\n for (var i = 144; i < 256; ++i)\n flt[i] = 9;\n for (var i = 256; i < 280; ++i)\n flt[i] = 7;\n for (var i = 280; i < 288; ++i)\n flt[i] = 8;\n // fixed distance tree\n var fdt = new u8(32);\n for (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n // fixed length map\n var flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n // fixed distance map\n var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n // find max of array\n var max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n };\n // read d, starting at bit p and mask with m\n var bits = function (d, p, m) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;\n };\n // read d, starting at bit p continuing for at least 16 bits\n var bits16 = function (d, p) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));\n };\n // get end of byte\n var shft = function (p) { return ((p + 7) / 8) | 0; };\n // typed array slice - allows garbage collector to free original reference,\n // while being more compatible than .slice\n var slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n return new u8(v.subarray(s, e));\n };\n // error codes\n var ec = [\n 'unexpected EOF',\n 'invalid block type',\n 'invalid length/literal',\n 'invalid distance',\n 'stream finished',\n 'no stream handler',\n ,\n 'no callback',\n 'invalid UTF-8 data',\n 'extra field too long',\n 'date not in range 1980-2099',\n 'filename too long',\n 'stream finishing',\n 'invalid zip data'\n // determined by unknown compression method\n ];\n var err = function (ind, msg, nt) {\n var e = new Error(msg || ec[ind]);\n e.code = ind;\n if (Error.captureStackTrace)\n Error.captureStackTrace(e, err);\n if (!nt)\n throw e;\n return e;\n };\n // expands raw DEFLATE data\n var inflt = function (dat, st, buf, dict) {\n // source length dict length\n var sl = dat.length, dl = dict ? dict.length : 0;\n if (!sl || st.f && !st.l)\n return buf || new u8(0);\n var noBuf = !buf;\n // have to estimate size\n var resize = noBuf || st.i != 2;\n // no state\n var noSt = st.i;\n // Assumes roughly 33% compression ratio average\n if (noBuf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n err(0);\n break;\n }\n // ensure size\n if (resize)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8, st.f = final;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n err(1);\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17\n if (resize)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var lpos = pos;\n for (;; lpos = pos) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >> 4;\n pos += c & 15;\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (!c)\n err(2);\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lpos = pos, lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;\n if (!d)\n err(3);\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & (1 << b) - 1, pos += b;\n }\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (resize)\n cbuf(bt + 131072);\n var end = bt + add;\n if (bt < dt) {\n var shift = dl - dt, dend = Math.min(dt, end);\n if (shift + bt < 0)\n err(3);\n for (; bt < dend; ++bt)\n buf[bt] = dict[shift + bt];\n }\n for (; bt < end; ++bt)\n buf[bt] = buf[bt - dt];\n }\n }\n st.l = lm, st.p = lpos, st.b = bt, st.f = final;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n // don't reallocate for streams or user buffers\n return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);\n };\n // empty\n var et = /*#__PURE__*/ new u8(0);\n // gzip footer: -8 to -4 = CRC, -4 to -0 is length\n // gzip start\n var gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n err(6, 'invalid gzip data');\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += (d[10] | d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n };\n // gzip length\n var gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;\n };\n /**\n * Expands GZIP data\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\n function gunzipSync(data, opts) {\n var st = gzs(data);\n if (st + 8 > data.length)\n err(6, 'invalid gzip data');\n return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);\n }\n // text decoder\n var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();\n // text decoder stream\n var tds = 0;\n try {\n td.decode(et, { stream: true });\n tds = 1;\n }\n catch (e) { }\n\n /**\n * This class has been made to hold a slice of a volume data.\n *\n * @see {@link Volume}\n * @three_import import { VolumeSlice } from 'three/addons/misc/VolumeSlice.js';\n */\n class VolumeSlice {\n\n \t/**\n \t * Constructs a new volume slice.\n \t *\n \t * @param {Volume} volume - The associated volume.\n \t * @param {number} [index=0] - The index of the slice.\n \t * @param {('x'|'y'|'z')} [axis='z'] - For now only 'x', 'y' or 'z' but later it will change to a normal vector.\n \t */\n \tconstructor( volume, index = 0, axis = 'z' ) {\n\n \t\tconst slice = this;\n\n \t\t/**\n \t\t * The associated volume.\n \t\t *\n \t\t * @type {Volume}\n \t\t */\n \t\tthis.volume = volume;\n\n \t\tObject.defineProperty( this, 'index', {\n \t\t\tget: function () {\n\n \t\t\t\treturn index;\n\n \t\t\t},\n \t\t\t/**\n \t\t\t * The index of the slice, if changed, will automatically call updateGeometry at the next repaint.\n \t\t\t *\n \t\t\t * @name VolumeSlice#index\n \t\t\t * @type {number}\n \t\t\t * @default 0\n \t\t\t * @param {number} value\n \t\t\t * @return {number}\n \t\t\t */\n \t\t\tset: function ( value ) {\n\n \t\t\t\tindex = value;\n \t\t\t\tslice.geometryNeedsUpdate = true;\n\n \t\t\t}\n \t\t} );\n\n \t\t/**\n \t\t * The normal axis.\n \t\t *\n \t\t * @type {('x'|'y'|'z')}\n \t\t */\n \t\tthis.axis = axis;\n\n \t\t/**\n \t\t * The final canvas used for the texture.\n \t\t *\n \t\t * @type {HTMLCanvasElement}\n \t\t */\n \t\tthis.canvas = document.createElement( 'canvas' );\n\n \t\t/**\n \t\t * The rendering context of the canvas.\n \t\t *\n \t\t * @type {CanvasRenderingContext2D}\n \t\t */\n \t\tthis.ctx;\n\n \t\t/**\n \t\t * The intermediary canvas used to paint the data.\n \t\t *\n \t\t * @type {HTMLCanvasElement}\n \t\t */\n \t\tthis.canvasBuffer = document.createElement( 'canvas' );\n\n \t\t/**\n \t\t * The rendering context of the canvas buffer,\n \t\t *\n \t\t * @type {CanvasRenderingContext2D}\n \t\t */\n \t\tthis.ctxBuffer;\n\n \t\tthis.updateGeometry();\n\n\n \t\tconst canvasMap = new Texture( this.canvas );\n \t\tcanvasMap.minFilter = LinearFilter;\n \t\tcanvasMap.generateMipmaps = false;\n \t\tcanvasMap.wrapS = canvasMap.wrapT = ClampToEdgeWrapping;\n \t\tcanvasMap.colorSpace = SRGBColorSpace;\n \t\tconst material = new MeshBasicMaterial( { map: canvasMap, side: DoubleSide, transparent: true } );\n\n \t\t/**\n \t\t * The mesh ready to get used in the scene.\n \t\t *\n \t\t * @type {Mesh}\n \t\t */\n \t\tthis.mesh = new Mesh( this.geometry, material );\n \t\tthis.mesh.matrixAutoUpdate = false;\n\n \t\t/**\n \t\t * If set to `true`, `updateGeometry()` will be triggered at the next repaint.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default true\n \t\t */\n \t\tthis.geometryNeedsUpdate = true;\n \t\tthis.repaint();\n\n \t\t/**\n \t\t * Width of slice in the original coordinate system, corresponds to the width of the buffer canvas.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.iLength = 0;\n\n \t\t/**\n \t\t * Height of slice in the original coordinate system, corresponds to the height of the buffer canvas.\n \t\t *\n \t\t * @type {number}\n \t\t * @default 0\n \t\t */\n \t\tthis.jLength = 0;\n\n \t\t/**\n \t\t * Function that allow the slice to access right data.\n \t\t *\n \t\t * @type {?Function}\n \t\t * @see {@link Volume#extractPerpendicularPlane}\n \t\t */\n \t\tthis.sliceAccess = null;\n\n \t}\n\n \t/**\n \t * Refresh the texture and the geometry if geometryNeedsUpdate is set to `true`.\n \t */\n \trepaint() {\n\n \t\tif ( this.geometryNeedsUpdate ) {\n\n \t\t\tthis.updateGeometry();\n\n \t\t}\n\n \t\tconst iLength = this.iLength,\n \t\t\tjLength = this.jLength,\n \t\t\tsliceAccess = this.sliceAccess,\n \t\t\tvolume = this.volume,\n \t\t\tcanvas = this.canvasBuffer,\n \t\t\tctx = this.ctxBuffer;\n\n\n \t\t// get the imageData and pixel array from the canvas\n \t\tconst imgData = ctx.getImageData( 0, 0, iLength, jLength );\n \t\tconst data = imgData.data;\n \t\tconst volumeData = volume.data;\n \t\tconst upperThreshold = volume.upperThreshold;\n \t\tconst lowerThreshold = volume.lowerThreshold;\n \t\tconst windowLow = volume.windowLow;\n \t\tconst windowHigh = volume.windowHigh;\n\n \t\t// manipulate some pixel elements\n \t\tlet pixelCount = 0;\n\n \t\tif ( volume.dataType === 'label' ) {\n\n \t\t\tconsole.error( 'THREE.VolumeSlice.repaint: label are not supported yet' );\n\n \t\t\t// This part is currently useless but will be used when colortables will be handled\n\n \t\t\t// for ( let j = 0; j < jLength; j ++ ) {\n\n \t\t\t// \tfor ( let i = 0; i < iLength; i ++ ) {\n\n \t\t\t// \t\tlet label = volumeData[ sliceAccess( i, j ) ];\n \t\t\t// \t\tlabel = label >= this.colorMap.length ? ( label % this.colorMap.length ) + 1 : label;\n \t\t\t// \t\tconst color = this.colorMap[ label ];\n \t\t\t// \t\tdata[ 4 * pixelCount ] = ( color >> 24 ) & 0xff;\n \t\t\t// \t\tdata[ 4 * pixelCount + 1 ] = ( color >> 16 ) & 0xff;\n \t\t\t// \t\tdata[ 4 * pixelCount + 2 ] = ( color >> 8 ) & 0xff;\n \t\t\t// \t\tdata[ 4 * pixelCount + 3 ] = color & 0xff;\n \t\t\t// \t\tpixelCount ++;\n\n \t\t\t// \t}\n\n \t\t\t// }\n\n \t\t} else {\n\n \t\t\tfor ( let j = 0; j < jLength; j ++ ) {\n\n \t\t\t\tfor ( let i = 0; i < iLength; i ++ ) {\n\n \t\t\t\t\tlet value = volumeData[ sliceAccess( i, j ) ];\n \t\t\t\t\tlet alpha = 0xff;\n \t\t\t\t\t//apply threshold\n \t\t\t\t\talpha = upperThreshold >= value ? ( lowerThreshold <= value ? alpha : 0 ) : 0;\n \t\t\t\t\t//apply window level\n \t\t\t\t\tvalue = Math.floor( 255 * ( value - windowLow ) / ( windowHigh - windowLow ) );\n \t\t\t\t\tvalue = value > 255 ? 255 : ( value < 0 ? 0 : value | 0 );\n\n \t\t\t\t\tdata[ 4 * pixelCount ] = value;\n \t\t\t\t\tdata[ 4 * pixelCount + 1 ] = value;\n \t\t\t\t\tdata[ 4 * pixelCount + 2 ] = value;\n \t\t\t\t\tdata[ 4 * pixelCount + 3 ] = alpha;\n \t\t\t\t\tpixelCount ++;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t}\n\n \t\tctx.putImageData( imgData, 0, 0 );\n \t\tthis.ctx.drawImage( canvas, 0, 0, iLength, jLength, 0, 0, this.canvas.width, this.canvas.height );\n\n\n \t\tthis.mesh.material.map.needsUpdate = true;\n\n \t}\n\n \t/**\n \t * Refresh the geometry according to axis and index.\n \t * @see {@link Volume#extractPerpendicularPlane}\n \t */\n \tupdateGeometry() {\n\n \t\tconst extracted = this.volume.extractPerpendicularPlane( this.axis, this.index );\n \t\tthis.sliceAccess = extracted.sliceAccess;\n \t\tthis.jLength = extracted.jLength;\n \t\tthis.iLength = extracted.iLength;\n \t\tthis.matrix = extracted.matrix;\n\n \t\tthis.canvas.width = extracted.planeWidth;\n \t\tthis.canvas.height = extracted.planeHeight;\n \t\tthis.canvasBuffer.width = this.iLength;\n \t\tthis.canvasBuffer.height = this.jLength;\n \t\tthis.ctx = this.canvas.getContext( '2d' );\n \t\tthis.ctxBuffer = this.canvasBuffer.getContext( '2d' );\n\n \t\tif ( this.geometry ) this.geometry.dispose(); // dispose existing geometry\n\n \t\tthis.geometry = new PlaneGeometry( extracted.planeWidth, extracted.planeHeight );\n\n \t\tif ( this.mesh ) {\n\n \t\t\tthis.mesh.geometry = this.geometry;\n \t\t\t//reset mesh matrix\n \t\t\tthis.mesh.matrix.identity();\n \t\t\tthis.mesh.applyMatrix4( this.matrix );\n\n \t\t}\n\n \t\tthis.geometryNeedsUpdate = false;\n\n \t}\n\n }\n\n /**\n * This class had been written to handle the output of the {@link NRRDLoader}.\n * It contains a volume of data and information about it. For now it only handles 3 dimensional data.\n *\n * @three_import import { Volume } from 'three/addons/misc/Volume.js';\n */\n class Volume {\n\n \t/**\n \t * Constructs a new volume.\n \t *\n \t * @param {number} [xLength] - Width of the volume.\n \t * @param {number} [yLength] - Length of the volume.\n \t * @param {number} [zLength] - Depth of the volume.\n \t * @param {string} [type] - The type of data (uint8, uint16, ...).\n \t * @param {ArrayBuffer} [arrayBuffer] - The buffer with volume data.\n \t */\n \tconstructor( xLength, yLength, zLength, type, arrayBuffer ) {\n\n \t\tif ( xLength !== undefined ) {\n\n \t\t\t/**\n \t\t\t * Width of the volume in the IJK coordinate system.\n \t\t\t *\n \t\t\t * @type {number}\n \t\t\t * @default 1\n \t\t\t */\n \t\t\tthis.xLength = Number( xLength ) || 1;\n\n \t\t\t/**\n \t\t\t * Height of the volume in the IJK coordinate system.\n \t\t\t *\n \t\t\t * @type {number}\n \t\t\t * @default 1\n \t\t\t */\n \t\t\tthis.yLength = Number( yLength ) || 1;\n\n \t\t\t/**\n \t\t\t * Depth of the volume in the IJK coordinate system.\n \t\t\t *\n \t\t\t * @type {number}\n \t\t\t * @default 1\n \t\t\t */\n \t\t\tthis.zLength = Number( zLength ) || 1;\n\n \t\t\t/**\n \t\t\t * The order of the Axis dictated by the NRRD header\n \t\t\t *\n \t\t\t * @type {Array<string>}\n \t\t\t */\n \t\t\tthis.axisOrder = [ 'x', 'y', 'z' ];\n\n \t\t\t/**\n \t\t\t * The data of the volume.\n \t\t\t *\n \t\t\t * @type {TypedArray}\n \t\t\t */\n \t\t\tthis.data;\n\n \t\t\tswitch ( type ) {\n\n \t\t\t\tcase 'Uint8' :\n \t\t\t\tcase 'uint8' :\n \t\t\t\tcase 'uchar' :\n \t\t\t\tcase 'unsigned char' :\n \t\t\t\tcase 'uint8_t' :\n \t\t\t\t\tthis.data = new Uint8Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Int8' :\n \t\t\t\tcase 'int8' :\n \t\t\t\tcase 'signed char' :\n \t\t\t\tcase 'int8_t' :\n \t\t\t\t\tthis.data = new Int8Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Int16' :\n \t\t\t\tcase 'int16' :\n \t\t\t\tcase 'short' :\n \t\t\t\tcase 'short int' :\n \t\t\t\tcase 'signed short' :\n \t\t\t\tcase 'signed short int' :\n \t\t\t\tcase 'int16_t' :\n \t\t\t\t\tthis.data = new Int16Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Uint16' :\n \t\t\t\tcase 'uint16' :\n \t\t\t\tcase 'ushort' :\n \t\t\t\tcase 'unsigned short' :\n \t\t\t\tcase 'unsigned short int' :\n \t\t\t\tcase 'uint16_t' :\n \t\t\t\t\tthis.data = new Uint16Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Int32' :\n \t\t\t\tcase 'int32' :\n \t\t\t\tcase 'int' :\n \t\t\t\tcase 'signed int' :\n \t\t\t\tcase 'int32_t' :\n \t\t\t\t\tthis.data = new Int32Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Uint32' :\n \t\t\t\tcase 'uint32' :\n \t\t\t\tcase 'uint' :\n \t\t\t\tcase 'unsigned int' :\n \t\t\t\tcase 'uint32_t' :\n \t\t\t\t\tthis.data = new Uint32Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'longlong' :\n \t\t\t\tcase 'long long' :\n \t\t\t\tcase 'long long int' :\n \t\t\t\tcase 'signed long long' :\n \t\t\t\tcase 'signed long long int' :\n \t\t\t\tcase 'int64' :\n \t\t\t\tcase 'int64_t' :\n \t\t\t\tcase 'ulonglong' :\n \t\t\t\tcase 'unsigned long long' :\n \t\t\t\tcase 'unsigned long long int' :\n \t\t\t\tcase 'uint64' :\n \t\t\t\tcase 'uint64_t' :\n \t\t\t\t\tthrow new Error( 'THREE.Volume: type is not supported in JavaScript.' );\n \t\t\t\tcase 'Float32' :\n \t\t\t\tcase 'float32' :\n \t\t\t\tcase 'float' :\n \t\t\t\t\tthis.data = new Float32Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'Float64' :\n \t\t\t\tcase 'float64' :\n \t\t\t\tcase 'double' :\n \t\t\t\t\tthis.data = new Float64Array( arrayBuffer );\n \t\t\t\t\tbreak;\n \t\t\t\tdefault :\n \t\t\t\t\tthis.data = new Uint8Array( arrayBuffer );\n\n \t\t\t}\n\n \t\t\tif ( this.data.length !== this.xLength * this.yLength * this.zLength ) {\n\n \t\t\t\tthrow new Error( 'THREE.Volume: lengths are not matching arrayBuffer size.' );\n\n \t\t\t}\n\n \t\t}\n\n \t\t/**\n \t\t * Spacing to apply to the volume from IJK to RAS coordinate system\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.spacing = [ 1, 1, 1 ];\n\n \t\t/**\n \t\t * Offset of the volume in the RAS coordinate system\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.offset = [ 0, 0, 0 ];\n\n \t\t/**\n \t\t * The IJK to RAS matrix.\n \t\t *\n \t\t * @type {Martrix3}\n \t\t */\n \t\tthis.matrix = new Matrix3();\n \t\tthis.matrix.identity();\n\n \t\t/**\n \t\t * The RAS to IJK matrix.\n \t\t *\n \t\t * @type {Martrix3}\n \t\t */\n \t\tthis.inverseMatrix = new Matrix3();\n\n \t\tlet lowerThreshold = - Infinity;\n \t\tObject.defineProperty( this, 'lowerThreshold', {\n \t\t\tget: function () {\n\n \t\t\t\treturn lowerThreshold;\n\n \t\t\t},\n \t\t\t/**\n \t\t\t * The voxels with values under this threshold won't appear in the slices.\n \t\t\t * If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume.\n \t\t\t *\n \t\t\t * @name Volume#lowerThreshold\n \t\t\t * @type {number}\n \t\t\t * @param {number} value\n \t\t\t */\n \t\t\tset: function ( value ) {\n\n \t\t\t\tlowerThreshold = value;\n \t\t\t\tthis.sliceList.forEach( function ( slice ) {\n\n \t\t\t\t\tslice.geometryNeedsUpdate = true;\n\n \t\t\t\t} );\n\n \t\t\t}\n \t\t} );\n\n \t\tlet upperThreshold = Infinity;\n \t\tObject.defineProperty( this, 'upperThreshold', {\n \t\t\tget: function () {\n\n \t\t\t\treturn upperThreshold;\n\n \t\t\t},\n \t\t\t/**\n \t\t\t * The voxels with values over this threshold won't appear in the slices.\n \t\t\t * If changed, geometryNeedsUpdate is automatically set to true on all the slices associated to this volume\n \t\t\t *\n \t\t\t * @name Volume#upperThreshold\n \t\t\t * @type {number}\n \t\t\t * @param {number} value\n \t\t\t */\n \t\t\tset: function ( value ) {\n\n \t\t\t\tupperThreshold = value;\n \t\t\t\tthis.sliceList.forEach( function ( slice ) {\n\n \t\t\t\t\tslice.geometryNeedsUpdate = true;\n\n \t\t\t\t} );\n\n \t\t\t}\n \t\t} );\n\n\n \t\t/**\n \t\t * The list of all the slices associated to this volume\n \t\t *\n \t\t * @type {Array<VolumeSlice>}\n \t\t */\n \t\tthis.sliceList = [];\n\n \t\t/**\n \t\t * Whether to use segmentation mode or not.\n \t\t * It can load 16-bits nrrds correctly.\n \t\t *\n \t\t * @type {boolean}\n \t\t * @default false\n \t\t */\n \t\tthis.segmentation = false;\n\n\n \t\t/**\n \t\t * This array holds the dimensions of the volume in the RAS space\n \t\t *\n \t\t * @type {Array<number>}\n \t\t */\n \t\tthis.RASDimensions = [];\n\n \t}\n\n \t/**\n \t * Shortcut for data[access(i,j,k)].\n \t *\n \t * @param {number} i - First coordinate.\n \t * @param {number} j - Second coordinate.\n \t * @param {number} k - Third coordinate.\n \t * @returns {number} The value in the data array.\n \t */\n \tgetData( i, j, k ) {\n\n \t\treturn this.data[ k * this.xLength * this.yLength + j * this.xLength + i ];\n\n \t}\n\n \t/**\n \t * Compute the index in the data array corresponding to the given coordinates in IJK system.\n \t *\n \t * @param {number} i - First coordinate.\n \t * @param {number} j - Second coordinate.\n \t * @param {number} k - Third coordinate.\n \t * @returns {number} The index.\n \t */\n \taccess( i, j, k ) {\n\n \t\treturn k * this.xLength * this.yLength + j * this.xLength + i;\n\n \t}\n\n \t/**\n \t * Retrieve the IJK coordinates of the voxel corresponding of the given index in the data.\n \t *\n \t * @param {number} index - Index of the voxel.\n \t * @returns {Array<number>} The IJK coordinates as `[x,y,z]`.\n \t */\n \treverseAccess( index ) {\n\n \t\tconst z = Math.floor( index / ( this.yLength * this.xLength ) );\n \t\tconst y = Math.floor( ( index - z * this.yLength * this.xLength ) / this.xLength );\n \t\tconst x = index - z * this.yLength * this.xLength - y * this.xLength;\n \t\treturn [ x, y, z ];\n\n \t}\n\n \t/**\n \t * Apply a function to all the voxels, be careful, the value will be replaced.\n \t *\n \t * @param {Function} functionToMap A function to apply to every voxel, will be called with the following parameters:\n \t * value of the voxel, index of the voxel, the data (TypedArray).\n \t * @param {Object} context - You can specify a context in which call the function, default if this Volume.\n \t * @returns {Volume} A reference to this instance.\n \t */\n \tmap( functionToMap, context ) {\n\n \t\tconst length = this.data.length;\n \t\tcontext = context || this;\n\n \t\tfor ( let i = 0; i < length; i ++ ) {\n\n \t\t\tthis.data[ i ] = functionToMap.call( context, this.data[ i ], i, this.data );\n\n \t\t}\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Compute the orientation of the slice and returns all the information relative to the geometry such as sliceAccess,\n \t * the plane matrix (orientation and position in RAS coordinate) and the dimensions of the plane in both coordinate system.\n \t *\n \t * @param {('x'|'y'|'z')} axis - The normal axis to the slice.\n \t * @param {number} RASIndex - The index of the slice.\n \t * @returns {Object} An object containing all the useful information on the geometry of the slice.\n \t */\n \textractPerpendicularPlane( axis, RASIndex ) {\n\n \t\tlet firstSpacing,\n \t\t\tsecondSpacing,\n \t\t\tpositionOffset,\n \t\t\tIJKIndex;\n\n \t\tconst axisInIJK = new Vector3(),\n \t\t\tfirstDirection = new Vector3(),\n \t\t\tsecondDirection = new Vector3(),\n \t\t\tplaneMatrix = ( new Matrix4() ).identity(),\n \t\t\tvolume = this;\n\n \t\tconst dimensions = new Vector3( this.xLength, this.yLength, this.zLength );\n\n\n \t\tswitch ( axis ) {\n\n \t\t\tcase 'x' :\n \t\t\t\taxisInIJK.set( 1, 0, 0 );\n \t\t\t\tfirstDirection.set( 0, 0, - 1 );\n \t\t\t\tsecondDirection.set( 0, - 1, 0 );\n \t\t\t\tfirstSpacing = this.spacing[ this.axisOrder.indexOf( 'z' ) ];\n \t\t\t\tsecondSpacing = this.spacing[ this.axisOrder.indexOf( 'y' ) ];\n \t\t\t\tIJKIndex = new Vector3( RASIndex, 0, 0 );\n\n \t\t\t\tplaneMatrix.multiply( ( new Matrix4() ).makeRotationY( Math.PI / 2 ) );\n \t\t\t\tpositionOffset = ( volume.RASDimensions[ 0 ] - 1 ) / 2;\n \t\t\t\tplaneMatrix.setPosition( new Vector3( RASIndex - positionOffset, 0, 0 ) );\n \t\t\t\tbreak;\n \t\t\tcase 'y' :\n \t\t\t\taxisInIJK.set( 0, 1, 0 );\n \t\t\t\tfirstDirection.set( 1, 0, 0 );\n \t\t\t\tsecondDirection.set( 0, 0, 1 );\n \t\t\t\tfirstSpacing = this.spacing[ this.axisOrder.indexOf( 'x' ) ];\n \t\t\t\tsecondSpacing = this.spacing[ this.axisOrder.indexOf( 'z' ) ];\n \t\t\t\tIJKIndex = new Vector3( 0, RASIndex, 0 );\n\n \t\t\t\tplaneMatrix.multiply( ( new Matrix4() ).makeRotationX( - Math.PI / 2 ) );\n \t\t\t\tpositionOffset = ( volume.RASDimensions[ 1 ] - 1 ) / 2;\n \t\t\t\tplaneMatrix.setPosition( new Vector3( 0, RASIndex - positionOffset, 0 ) );\n \t\t\t\tbreak;\n \t\t\tcase 'z' :\n \t\t\tdefault :\n \t\t\t\taxisInIJK.set( 0, 0, 1 );\n \t\t\t\tfirstDirection.set( 1, 0, 0 );\n \t\t\t\tsecondDirection.set( 0, - 1, 0 );\n \t\t\t\tfirstSpacing = this.spacing[ this.axisOrder.indexOf( 'x' ) ];\n \t\t\t\tsecondSpacing = this.spacing[ this.axisOrder.indexOf( 'y' ) ];\n \t\t\t\tIJKIndex = new Vector3( 0, 0, RASIndex );\n\n \t\t\t\tpositionOffset = ( volume.RASDimensions[ 2 ] - 1 ) / 2;\n \t\t\t\tplaneMatrix.setPosition( new Vector3( 0, 0, RASIndex - positionOffset ) );\n \t\t\t\tbreak;\n\n \t\t}\n\n \t\tif ( ! this.segmentation ) {\n\n \t\t\tfirstDirection.applyMatrix4( volume.inverseMatrix ).normalize();\n \t\t\tsecondDirection.applyMatrix4( volume.inverseMatrix ).normalize();\n \t\t\taxisInIJK.applyMatrix4( volume.inverseMatrix ).normalize();\n\n \t\t}\n\n \t\tfirstDirection.arglet = 'i';\n \t\tsecondDirection.arglet = 'j';\n \t\tconst iLength = Math.floor( Math.abs( firstDirection.dot( dimensions ) ) );\n \t\tconst jLength = Math.floor( Math.abs( secondDirection.dot( dimensions ) ) );\n \t\tconst planeWidth = Math.abs( iLength * firstSpacing );\n \t\tconst planeHeight = Math.abs( jLength * secondSpacing );\n\n \t\tIJKIndex = Math.abs( Math.round( IJKIndex.applyMatrix4( volume.inverseMatrix ).dot( axisInIJK ) ) );\n \t\tconst base = [ new Vector3( 1, 0, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ) ];\n \t\tconst iDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {\n\n \t\t\treturn Math.abs( x.dot( base[ 0 ] ) ) > 0.9;\n\n \t\t} );\n \t\tconst jDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {\n\n \t\t\treturn Math.abs( x.dot( base[ 1 ] ) ) > 0.9;\n\n \t\t} );\n \t\tconst kDirection = [ firstDirection, secondDirection, axisInIJK ].find( function ( x ) {\n\n \t\t\treturn Math.abs( x.dot( base[ 2 ] ) ) > 0.9;\n\n \t\t} );\n\n \t\tfunction sliceAccess( i, j ) {\n\n \t\t\tconst si = ( iDirection === axisInIJK ) ? IJKIndex : ( iDirection.arglet === 'i' ? i : j );\n \t\t\tconst sj = ( jDirection === axisInIJK ) ? IJKIndex : ( jDirection.arglet === 'i' ? i : j );\n \t\t\tconst sk = ( kDirection === axisInIJK ) ? IJKIndex : ( kDirection.arglet === 'i' ? i : j );\n\n \t\t\t// invert indices if necessary\n\n \t\t\tconst accessI = ( iDirection.dot( base[ 0 ] ) > 0 ) ? si : ( volume.xLength - 1 ) - si;\n \t\t\tconst accessJ = ( jDirection.dot( base[ 1 ] ) > 0 ) ? sj : ( volume.yLength - 1 ) - sj;\n \t\t\tconst accessK = ( kDirection.dot( base[ 2 ] ) > 0 ) ? sk : ( volume.zLength - 1 ) - sk;\n\n \t\t\treturn volume.access( accessI, accessJ, accessK );\n\n \t\t}\n\n \t\treturn {\n \t\t\tiLength: iLength,\n \t\t\tjLength: jLength,\n \t\t\tsliceAccess: sliceAccess,\n \t\t\tmatrix: planeMatrix,\n \t\t\tplaneWidth: planeWidth,\n \t\t\tplaneHeight: planeHeight\n \t\t};\n\n \t}\n\n \t/**\n \t * Returns a slice corresponding to the given axis and index.\n \t * The coordinate are given in the Right Anterior Superior coordinate format.\n \t *\n \t * @param {('x'|'y'|'z')} axis - The normal axis to the slice.\n \t * @param {number} index - The index of the slice.\n \t * @returns {VolumeSlice} The extracted slice.\n \t */\n \textractSlice( axis, index ) {\n\n \t\tconst slice = new VolumeSlice( this, index, axis );\n \t\tthis.sliceList.push( slice );\n \t\treturn slice;\n\n \t}\n\n \t/**\n \t * Call repaint on all the slices extracted from this volume.\n \t *\n \t * @see {@link VolumeSlice#repaint}\n \t * @returns {Volume} A reference to this volume.\n \t */\n \trepaintAllSlices() {\n\n \t\tthis.sliceList.forEach( function ( slice ) {\n\n \t\t\tslice.repaint();\n\n \t\t} );\n\n \t\treturn this;\n\n \t}\n\n \t/**\n \t * Compute the minimum and the maximum of the data in the volume.\n \t *\n \t * @returns {Array<number>} The min/max data as `[min,max]`.\n \t */\n \tcomputeMinMax() {\n\n \t\tlet min = Infinity;\n \t\tlet max = - Infinity;\n\n \t\t// buffer the length\n \t\tconst datasize = this.data.length;\n\n \t\tlet i = 0;\n\n \t\tfor ( i = 0; i < datasize; i ++ ) {\n\n \t\t\tif ( ! isNaN( this.data[ i ] ) ) {\n\n \t\t\t\tconst value = this.data[ i ];\n \t\t\t\tmin = Math.min( min, value );\n \t\t\t\tmax = Math.max( max, value );\n\n \t\t\t}\n\n \t\t}\n\n \t\tthis.min = min;\n \t\tthis.max = max;\n\n \t\treturn [ min, max ];\n\n \t}\n\n }\n\n /**\n * A loader for the NRRD format.\n *\n * ```js\n * const loader = new NRRDLoader();\n * const volume = await loader.loadAsync( 'models/nrrd/I.nrrd' );\n * ```\n *\n * @augments Loader\n * @three_import import { NRRDLoader } from 'three/addons/loaders/NRRDLoader.js';\n */\n class NRRDLoader extends Loader {\n\n \t/**\n \t * Constructs a new NRRD loader.\n \t *\n \t * @param {LoadingManager} [manager] - The loading manager.\n \t */\n \tconstructor( manager ) {\n\n \t\tsuper( manager );\n\n \t}\n\n \t/**\n \t * Starts loading from the given URL and passes the loaded NRRD asset\n \t * to the `onLoad()` callback.\n \t *\n \t * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.\n \t * @param {function(Volume)} onLoad - Executed when the loading process has been finished.\n \t * @param {onProgressCallback} onProgress - Executed while the loading is in progress.\n \t * @param {onErrorCallback} onError - Executed when errors occur.\n \t */\n \tload( url, onLoad, onProgress, onError ) {\n\n \t\tconst scope = this;\n\n \t\tconst loader = new FileLoader( scope.manager );\n \t\tloader.setPath( scope.path );\n \t\tloader.setResponseType( 'arraybuffer' );\n \t\tloader.setRequestHeader( scope.requestHeader );\n \t\tloader.setWithCredentials( scope.withCredentials );\n \t\tloader.load( url, function ( data ) {\n\n \t\t\ttry {\n\n \t\t\t\tonLoad( scope.parse( data ) );\n\n \t\t\t} catch ( e ) {\n\n \t\t\t\tif ( onError ) {\n\n \t\t\t\t\tonError( e );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tconsole.error( e );\n\n \t\t\t\t}\n\n \t\t\t\tscope.manager.itemError( url );\n\n \t\t\t}\n\n \t\t}, onProgress, onError );\n\n \t}\n\n \t/**\n \t * Toggles the segmentation mode.\n \t *\n \t * @param {boolean} segmentation - Whether to use segmentation mode or not.\n \t */\n \tsetSegmentation( segmentation ) {\n\n \t\tthis.segmentation = segmentation;\n\n \t}\n\n \t/**\n \t * Parses the given NRRD data and returns the resulting volume data.\n \t *\n \t * @param {ArrayBuffer} data - The raw NRRD data as an array buffer.\n \t * @return {Volume} The parsed volume.\n \t */\n \tparse( data ) {\n\n \t\t// this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X\n\n \t\tlet _data = data;\n\n \t\tlet _dataPointer = 0;\n\n \t\tconst _nativeLittleEndian = new Int8Array( new Int16Array( [ 1 ] ).buffer )[ 0 ] > 0;\n\n \t\tconst _littleEndian = true;\n\n \t\tconst headerObject = {};\n\n \t\tfunction scan( type, chunks ) {\n\n \t\t\tlet _chunkSize = 1;\n \t\t\tlet _array_type = Uint8Array;\n\n \t\t\tswitch ( type ) {\n\n \t\t\t\t// 1 byte data types\n \t\t\t\tcase 'uchar':\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'schar':\n \t\t\t\t\t_array_type = Int8Array;\n \t\t\t\t\tbreak;\n \t\t\t\t// 2 byte data types\n \t\t\t\tcase 'ushort':\n \t\t\t\t\t_array_type = Uint16Array;\n \t\t\t\t\t_chunkSize = 2;\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'sshort':\n \t\t\t\t\t_array_type = Int16Array;\n \t\t\t\t\t_chunkSize = 2;\n \t\t\t\t\tbreak;\n \t\t\t\t// 4 byte data types\n \t\t\t\tcase 'uint':\n \t\t\t\t\t_array_type = Uint32Array;\n \t\t\t\t\t_chunkSize = 4;\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'sint':\n \t\t\t\t\t_array_type = Int32Array;\n \t\t\t\t\t_chunkSize = 4;\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'float':\n \t\t\t\t\t_array_type = Float32Array;\n \t\t\t\t\t_chunkSize = 4;\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'complex':\n \t\t\t\t\t_array_type = Float64Array;\n \t\t\t\t\t_chunkSize = 8;\n \t\t\t\t\tbreak;\n \t\t\t\tcase 'double':\n \t\t\t\t\t_array_type = Float64Array;\n \t\t\t\t\t_chunkSize = 8;\n \t\t\t\t\tbreak;\n\n \t\t\t}\n\n \t\t\t// increase the data pointer in-place\n \t\t\tlet _bytes = new _array_type( _data.slice( _dataPointer,\n \t\t\t\t_dataPointer += chunks * _chunkSize ) );\n\n \t\t\t// if required, flip the endianness of the bytes\n \t\t\tif ( _nativeLittleEndian != _littleEndian ) {\n\n \t\t\t\t// we need to flip here since the format doesn't match the native endianness\n \t\t\t\t_bytes = flipEndianness( _bytes, _chunkSize );\n\n \t\t\t}\n\n \t\t\t// return the byte array\n \t\t\treturn _bytes;\n\n \t\t}\n\n \t\t//Flips typed array endianness in-place. Based on https://github.com/kig/DataStream.js/blob/master/DataStream.js.\n\n \t\tfunction flipEndianness( array, chunkSize ) {\n\n \t\t\tconst u8 = new Uint8Array( array.buffer, array.byteOffset, array.byteLength );\n \t\t\tfor ( let i = 0; i < array.byteLength; i += chunkSize ) {\n\n \t\t\t\tfor ( let j = i + chunkSize - 1, k = i; j > k; j --, k ++ ) {\n\n \t\t\t\t\tconst tmp = u8[ k ];\n \t\t\t\t\tu8[ k ] = u8[ j ];\n \t\t\t\t\tu8[ j ] = tmp;\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\treturn array;\n\n \t\t}\n\n \t\t//parse the header\n \t\tfunction parseHeader( header ) {\n\n \t\t\tlet data, field, fn, i, l, m, _i, _len;\n \t\t\tconst lines = header.split( /\\r?\\n/ );\n \t\t\tfor ( _i = 0, _len = lines.length; _i < _len; _i ++ ) {\n\n \t\t\t\tl = lines[ _i ];\n \t\t\t\tif ( l.match( /NRRD\\d+/ ) ) {\n\n \t\t\t\t\theaderObject.isNrrd = true;\n\n \t\t\t\t} else if ( ! l.match( /^#/ ) && ( m = l.match( /(.*):(.*)/ ) ) ) {\n\n \t\t\t\t\tfield = m[ 1 ].trim();\n \t\t\t\t\tdata = m[ 2 ].trim();\n \t\t\t\t\tfn = _fieldFunctions[ field ];\n \t\t\t\t\tif ( fn ) {\n\n \t\t\t\t\t\tfn.call( headerObject, data );\n\n \t\t\t\t\t} else {\n\n \t\t\t\t\t\theaderObject[ field ] = data;\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tif ( ! headerObject.isNrrd ) {\n\n \t\t\t\tthrow new Error( 'THREE.NRRDLoader: Not an NRRD file' );\n\n \t\t\t}\n\n \t\t\tif ( headerObject.encoding === 'bz2' || headerObject.encoding === 'bzip2' ) {\n\n \t\t\t\tthrow new Error( 'THREE.NRRDLoader: Bzip is not supported' );\n\n \t\t\t}\n\n \t\t\tif ( ! headerObject.vectors ) {\n\n \t\t\t\t//if no space direction is set, let's use the identity\n \t\t\t\theaderObject.vectors = [ ];\n \t\t\t\theaderObject.vectors.push( [ 1, 0, 0 ] );\n \t\t\t\theaderObject.vectors.push( [ 0, 1, 0 ] );\n \t\t\t\theaderObject.vectors.push( [ 0, 0, 1 ] );\n\n \t\t\t\t//apply spacing if defined\n \t\t\t\tif ( headerObject.spacings ) {\n\n \t\t\t\t\tfor ( i = 0; i <= 2; i ++ ) {\n\n \t\t\t\t\t\tif ( ! isNaN( headerObject.spacings[ i ] ) ) {\n\n \t\t\t\t\t\t\tfor ( let j = 0; j <= 2; j ++ ) {\n\n \t\t\t\t\t\t\t\theaderObject.vectors[ i ][ j ] *= headerObject.spacings[ i ];\n\n \t\t\t\t\t\t\t}\n\n \t\t\t\t\t\t}\n\n \t\t\t\t\t}\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t}\n\n \t\t//parse the data when registered as one of this type : 'text', 'ascii', 'txt'\n \t\tfunction parseDataAsText( data, start, end ) {\n\n \t\t\tlet number = '';\n \t\t\tstart = start || 0;\n \t\t\tend = end || data.length;\n \t\t\tlet value;\n \t\t\t//length of the result is the product of the sizes\n \t\t\tconst lengthOfTheResult = headerObject.sizes.reduce( function ( previous, current ) {\n\n \t\t\t\treturn previous * current;\n\n \t\t\t}, 1 );\n\n \t\t\tlet base = 10;\n \t\t\tif ( headerObject.encoding === 'hex' ) {\n\n \t\t\t\tbase = 16;\n\n \t\t\t}\n\n \t\t\tconst result = new headerObject.__array( lengthOfTheResult );\n \t\t\tlet resultIndex = 0;\n \t\t\tlet parsingFunction = parseInt;\n \t\t\tif ( headerObject.__array === Float32Array || headerObject.__array === Float64Array ) {\n\n \t\t\t\tparsingFunction = parseFloat;\n\n \t\t\t}\n\n \t\t\tfor ( let i = start; i < end; i ++ ) {\n\n \t\t\t\tvalue = data[ i ];\n \t\t\t\t//if value is not a space\n \t\t\t\tif ( ( value < 9 || value > 13 ) && value !== 32 ) {\n\n \t\t\t\t\tnumber += String.fromCharCode( value );\n\n \t\t\t\t} else {\n\n \t\t\t\t\tif ( number !== '' ) {\n\n \t\t\t\t\t\tresult[ resultIndex ] = parsingFunction( number, base );\n \t\t\t\t\t\tresultIndex ++;\n\n \t\t\t\t\t}\n\n \t\t\t\t\tnumber = '';\n\n \t\t\t\t}\n\n \t\t\t}\n\n \t\t\tif ( number !== '' ) {\n\n \t\t\t\tresult[ resultIndex ] = parsingFunction( number, base );\n \t\t\t\tresultIndex ++;\n\n \t\t\t}\n\n \t\t\treturn result;\n\n \t\t}\n\n \t\tconst _bytes = scan( 'uchar', data.byteLength );\n \t\tconst _length = _bytes.length;\n \t\tlet _header = null;\n \t\tlet _data_start = 0;\n \t\tlet i;\n \t\tfor ( i = 1; i < _length; i ++ ) {\n\n \t\t\tif ( _bytes[ i - 1 ] == 10 && _bytes[ i ] == 10 ) {\n\n \t\t\t\t// we found two line breaks in a row\n \t\t\t\t// now we know what the header is\n \t\t\t\t_header = this._parseChars( _bytes, 0, i - 2 );\n \t\t\t\t// this is were the data starts\n \t\t\t\t_data_start = i + 1;\n \t\t\t\tbreak;\n\n \t\t\t}\n\n \t\t}\n\n \t\t// parse the header\n \t\tparseHeader( _header );\n\n \t\t_data = _bytes.subarray( _data_start ); // the data without header\n \t\tif ( headerObject.encoding.substring( 0, 2 ) === 'gz' ) {\n\n \t\t\t// we need to decompress the datastream\n \t\t\t// here we start the unzipping and get a typed Uint8Array back\n \t\t\t_data = gunzipSync( new Uint8Array( _data ) );\n\n \t\t} else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) {\n\n \t\t\t_data = parseDataAsText( _data );\n\n \t\t} else if ( headerObject.encoding === 'raw' ) {\n\n \t\t\t//we need to copy the array to create a new array buffer, else we retrieve the original arraybuffer with the header\n \t\t\tconst _copy = new Uint8Array( _data.length );\n\n \t\t\tfor ( let i = 0; i < _data.length; i ++ ) {\n\n \t\t\t\t_copy[ i ] = _data[ i ];\n\n \t\t\t}\n\n \t\t\t_data = _copy;\n\n \t\t}\n\n \t\t// .. let's use the underlying array buffer\n \t\t_data = _data.buffer;\n\n \t\tconst volume = new Volume();\n \t\tvolume.header = headerObject;\n \t\tvolume.segmentation = this.segmentation;\n \t\t//\n \t\t// parse the (unzipped) data to a datastream of the correct type\n \t\t//\n \t\tvolume.data = new headerObject.__array( _data );\n \t\t// get the min and max intensities\n \t\tconst min_max = volume.computeMinMax();\n \t\tconst min = min_max[ 0 ];\n \t\tconst max = min_max[ 1 ];\n \t\t// attach the scalar range to the volume\n \t\tvolume.windowLow = min;\n \t\tvolume.windowHigh = max;\n\n \t\t// get the image dimensions\n \t\tvolume.dimensions = [ headerObject.sizes[ 0 ], headerObject.sizes[ 1 ], headerObject.sizes[ 2 ] ];\n \t\tvolume.xLength = volume.dimensions[ 0 ];\n \t\tvolume.yLength = volume.dimensions[ 1 ];\n \t\tvolume.zLength = volume.dimensions[ 2 ];\n\n \t\t// Identify axis order in the space-directions matrix from the header if possible.\n \t\tif ( headerObject.vectors ) {\n\n \t\t\tconst xIndex = headerObject.vectors.findIndex( vector => vector[ 0 ] !== 0 );\n \t\t\tconst yIndex = headerObject.vectors.findIndex( vector => vector[ 1 ] !== 0 );\n \t\t\tconst zIndex = headerObject.vectors.findIndex( vector => vector[ 2 ] !== 0 );\n\n \t\t\tconst axisOrder = [];\n\n \t\t\tif ( xIndex !== yIndex && xIndex !== zIndex && yIndex !== zIndex ) {\n\n \t\t\t\taxisOrder[ xIndex ] = 'x';\n \t\t\t\taxisOrder[ yIndex ] = 'y';\n \t\t\t\taxisOrder[ zIndex ] = 'z';\n\n \t\t\t} else {\n\n \t\t\t\taxisOrder[ 0 ] = 'x';\n \t\t\t\taxisOrder[ 1 ] = 'y';\n \t\t\t\taxisOrder[ 2 ] = 'z';\n\n \t\t\t}\n\n \t\t\tvolume.axisOrder = axisOrder;\n\n \t\t} else {\n\n \t\t\tvolume.axisOrder = [ 'x', 'y', 'z' ];\n\n \t\t}\n\n \t\t// spacing\n \t\tconst spacingX = new Vector3().fromArray( headerObject.vectors[ 0 ] ).length();\n \t\tconst spacingY = new Vector3().fromArray( headerObject.vectors[ 1 ] ).length();\n \t\tconst spacingZ = new Vector3().fromArray( headerObject.vectors[ 2 ] ).length();\n \t\tvolume.spacing = [ spacingX, spacingY, spacingZ ];\n\n\n \t\t// Create IJKtoRAS matrix\n \t\tvolume.matrix = new Matrix4();\n\n \t\tconst transitionMatrix = new Matrix4();\n\n \t\tif ( headerObject.space === 'left-posterior-superior' ) {\n\n \t\t\ttransitionMatrix.set(\n \t\t\t\t- 1, 0, 0, 0,\n \t\t\t\t0, - 1, 0, 0,\n \t\t\t\t0, 0, 1, 0,\n \t\t\t\t0, 0, 0, 1\n \t\t\t);\n\n \t\t} else if ( headerObject.space === 'left-anterior-superior' ) {\n\n \t\t\ttransitionMatrix.set(\n \t\t\t\t1, 0, 0, 0,\n \t\t\t\t0, 1, 0, 0,\n \t\t\t\t0, 0, - 1, 0,\n \t\t\t\t0, 0, 0, 1\n \t\t\t);\n\n \t\t}\n\n\n \t\tif ( ! headerObject.vectors ) {\n\n \t\t\tvolume.matrix.set(\n \t\t\t\t1, 0, 0, 0,\n \t\t\t\t0, 1, 0, 0,\n \t\t\t\t0, 0, 1, 0,\n \t\t\t\t0, 0, 0, 1 );\n\n \t\t} else {\n\n \t\t\tconst v = headerObject.vectors;\n\n \t\t\tconst ijk_to_transition = new Matrix4().set(\n \t\t\t\tv[ 0 ][ 0 ], v[ 1 ][ 0 ], v[ 2 ][ 0 ], 0,\n \t\t\t\tv[ 0 ][ 1 ], v[ 1 ][ 1 ], v[ 2 ][ 1 ], 0,\n \t\t\t\tv[ 0 ][ 2 ], v[ 1 ][ 2 ], v[ 2 ][ 2 ], 0,\n \t\t\t\t0, 0, 0, 1\n \t\t\t);\n\n \t\t\tconst transition_to_ras = new Matrix4().multiplyMatrices( ijk_to_transition, transitionMatrix );\n\n \t\t\tvolume.matrix = transition_to_ras;\n\n \t\t}\n\n \t\tvolume.inverseMatrix = new Matrix4();\n \t\tvolume.inverseMatrix.copy( volume.matrix ).invert();\n\n \t\tvolume.RASDimensions = [\n \t\t\tMath.floor( volume.xLength * spacingX ),\n \t\t\tMath.floor( volume.yLength * spacingY ),\n \t\t\tMath.floor( volume.zLength * spacingZ )\n \t\t];\n\n \t\t// .. and set the default threshold\n \t\t// only if the threshold was not already set\n \t\tif ( volume.lowerThreshold === - Infinity ) {\n\n \t\t\tvolume.lowerThreshold = min;\n\n \t\t}\n\n \t\tif ( volume.upperThreshold === Infinity ) {\n\n \t\t\tvolume.upperThreshold = max;\n\n \t\t}\n\n \t\treturn volume;\n\n \t}\n\n \t_parseChars( array, start, end ) {\n\n \t\t// without borders, use the whole array\n \t\tif ( start === undefined ) {\n\n \t\t\tstart = 0;\n\n \t\t}\n\n \t\tif ( end === undefined ) {\n\n \t\t\tend = array.length;\n\n \t\t}\n\n \t\tlet output = '';\n \t\t// create and append the chars\n \t\tlet i = 0;\n \t\tfor ( i = start; i < end; ++ i ) {\n\n \t\t\toutput += String.fromCharCode( array[ i ] );\n\n \t\t}\n\n \t\treturn output;\n\n \t}\n\n }\n\n const _fieldFunctions = {\n\n \ttype: function ( data ) {\n\n \t\tswitch ( data ) {\n\n \t\t\tcase 'uchar':\n \t\t\tcase 'unsigned char':\n \t\t\tcase 'uint8':\n \t\t\tcase 'uint8_t':\n \t\t\t\tthis.__array = Uint8Array;\n \t\t\t\tbreak;\n \t\t\tcase 'signed char':\n \t\t\tcase 'int8':\n \t\t\tcase 'int8_t':\n \t\t\t\tthis.__array = Int8Array;\n \t\t\t\tbreak;\n \t\t\tcase 'short':\n \t\t\tcase 'short int':\n \t\t\tcase 'signed short':\n \t\t\tcase 'signed short int':\n \t\t\tcase 'int16':\n \t\t\tcase 'int16_t':\n \t\t\t\tthis.__array = Int16Array;\n \t\t\t\tbreak;\n \t\t\tcase 'ushort':\n \t\t\tcase 'unsigned short':\n \t\t\tcase 'unsigned short int':\n \t\t\tcase 'uint16':\n \t\t\tcase 'uint16_t':\n \t\t\t\tthis.__array = Uint16Array;\n \t\t\t\tbreak;\n \t\t\tcase 'int':\n \t\t\tcase 'signed int':\n \t\t\tcase 'int32':\n \t\t\tcase 'int32_t':\n \t\t\t\tthis.__array = Int32Array;\n \t\t\t\tbreak;\n \t\t\tcase 'uint':\n \t\t\tcase 'unsigned int':\n \t\t\tcase 'uint32':\n \t\t\tcase 'uint32_t':\n \t\t\t\tthis.__array = Uint32Array;\n \t\t\t\tbreak;\n \t\t\tcase 'float':\n \t\t\t\tthis.__array = Float32Array;\n \t\t\t\tbreak;\n \t\t\tcase 'double':\n \t\t\t\tthis.__array = Float64Array;\n \t\t\t\tbreak;\n \t\t\tdefault:\n \t\t\t\tthrow new Error( 'THREE.NRRDLoader: Unsupported NRRD data type: ' + data );\n\n \t\t}\n\n \t\treturn this.type = data;\n\n \t},\n\n \tendian: function ( data ) {\n\n \t\treturn this.endian = data;\n\n \t},\n\n \tencoding: function ( data ) {\n\n \t\treturn this.encoding = data;\n\n \t},\n\n \tdimension: function ( data ) {\n\n \t\treturn this.dim = parseInt( data, 10 );\n\n \t},\n\n \tsizes: function ( data ) {\n\n \t\tlet i;\n \t\treturn this.sizes = ( function () {\n\n \t\t\tconst _ref = data.split( /\\s+/ );\n \t\t\tconst _results = [];\n\n \t\t\tfor ( let _i = 0, _len = _ref.length; _i < _len; _i ++ ) {\n\n \t\t\t\ti = _ref[ _i ];\n \t\t\t\t_results.push( parseInt( i, 10 ) );\n\n \t\t\t}\n\n \t\t\treturn _results;\n\n \t\t} )();\n\n \t},\n\n \tspace: function ( data ) {\n\n \t\treturn this.space = data;\n\n \t},\n\n \t'space origin': function ( data ) {\n\n \t\treturn this.space_origin = data.split( '(' )[ 1 ].split( ')' )[ 0 ].split( ',' );\n\n \t},\n\n \t'space directions': function ( data ) {\n\n \t\tlet f, v;\n \t\tconst parts = data.match( /\\(.*?\\)/g );\n \t\treturn this.vectors = ( function () {\n\n \t\t\tconst _results = [];\n\n \t\t\tfor ( let _i = 0, _len = parts.length; _i < _len; _i ++ ) {\n\n \t\t\t\tv = parts[ _i ];\n \t\t\t\t_results.push( ( function () {\n\n \t\t\t\t\tconst _ref = v.slice( 1, - 1 ).split( /,/ );\n \t\t\t\t\tconst _results2 = [];\n\n \t\t\t\t\tfor ( let _j = 0, _len2 = _ref.length; _j < _len2; _j ++ ) {\n\n \t\t\t\t\t\tf = _ref[ _j ];\n \t\t\t\t\t\t_results2.push( parseFloat( f ) );\n\n \t\t\t\t\t}\n\n \t\t\t\t\treturn _results2;\n\n \t\t\t\t} )() );\n\n \t\t\t}\n\n \t\t\treturn _results;\n\n \t\t} )();\n\n \t},\n\n \tspacings: function ( data ) {\n\n \t\tlet f;\n \t\tconst parts = data.split( /\\s+/ );\n \t\treturn this.spacings = ( function () {\n\n \t\t\tconst _results = [];\n\n \t\t\tfor ( let _i = 0, _len = parts.length; _i < _len; _i ++ ) {\n\n \t\t\t\tf = parts[ _i ];\n \t\t\t\t_results.push( parseFloat( f ) );\n\n \t\t\t}\n\n \t\t\treturn _results;\n\n \t\t} )();\n\n \t}\n\n };\n\n /**\n * Runs entirely off the main thread: fetch, gunzip (via `NRRDLoader.parse`'s own\n * `fflate.gunzipSync`) and the NRRD header/typed-array parse. This module has no DOM\n * dependency -- `NRRDLoader.parse` and `Volume` only touch `ArrayBuffer`s and three's math\n * classes (`Matrix4`, `Vector3`), never `document` -- so it is safe to import both inside a\n * Web Worker and, for tests, inside the main jsdom realm (see `__tests__/helpers/\n * fakeNrrdWorker.ts`, which drives this same module in-process instead of through a real\n * `postMessage` boundary).\n *\n * Structured as plain functions over an explicit `NrrdWorkerState`, with an injected `emit`\n * callback instead of a bare `self.postMessage`, so the real worker entry (`nrrdWorker.ts`)\n * and the in-process test double can share the exact same logic.\n */\n const loader = new NRRDLoader();\n /**\n * Mirrors `copperNrrdLoader.ts`'s own `installMinMaxOverride` -- same lever, same reason\n * (three exposes no hook between \"Volume built\" and \"computeMinMax() called\", only the\n * method itself), just installed against *this* module's own `Volume` class. Worker and main\n * thread each get their own bundle of `three/examples/jsm/misc/Volume.js`, so patching the\n * prototype here never touches the main thread's copy.\n */\n let pendingMinMax = null;\n const MINMAX_OVERRIDE_INSTALLED = Symbol(\"copper-worker-minmax-override\");\n function installMinMaxOverride() {\n const proto = Volume.prototype;\n if (proto[MINMAX_OVERRIDE_INSTALLED])\n return;\n const original = proto.computeMinMax;\n proto.computeMinMax = function computeMinMaxOrSupplied() {\n if (pendingMinMax) {\n const [min, max] = pendingMinMax;\n this.min = min;\n this.max = max;\n return pendingMinMax;\n }\n return original.call(this);\n };\n proto[MINMAX_OVERRIDE_INSTALLED] = true;\n }\n function createNrrdWorkerState() {\n installMinMaxOverride();\n return { pendingByUrl: new Map(), callerToUrl: new Map() };\n }\n /**\n * Fetches `url` to completion, reporting `{loaded, total}` progress. No abort handling of its\n * own -- the caller passes a signal it controls (the shared per-URL `AbortController`).\n */\n function fetchRawBuffer(url, signal, onProgress) {\n return __awaiter(this, void 0, void 0, function* () {\n const response = yield fetch(url, { signal });\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const total = Number(response.headers.get(\"content-length\")) || 0;\n if (!response.body) {\n return response.arrayBuffer();\n }\n const reader = response.body.getReader();\n const chunks = [];\n let loaded = 0;\n for (;;) {\n const { done, value } = yield reader.read();\n if (done)\n break;\n chunks.push(value);\n loaded += value.byteLength;\n onProgress(loaded, total);\n }\n const merged = new Uint8Array(loaded);\n let offset = 0;\n for (const chunk of chunks) {\n merged.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return merged.buffer;\n });\n }\n /** Turns a real, just-parsed `Volume` into a transferable, structured-clone-safe payload.\n * Every field is a value the real `NRRDLoader.parse()` already computed -- this only unwraps\n * it from class instances (`Matrix4`) and non-cloneable fields (`header.__array`, a\n * constructor function) that cannot cross the worker/main-thread boundary as-is. */\n function buildPayload(volume) {\n const header = Object.assign({}, volume.header);\n delete header.__array;\n return {\n xLength: volume.xLength,\n yLength: volume.yLength,\n zLength: volume.zLength,\n type: volume.header.type,\n header,\n spacing: volume.spacing,\n axisOrder: volume.axisOrder,\n RASDimensions: volume.RASDimensions,\n segmentation: volume.segmentation,\n min: volume.min,\n max: volume.max,\n windowLow: volume.windowLow,\n windowHigh: volume.windowHigh,\n lowerThreshold: volume.lowerThreshold,\n upperThreshold: volume.upperThreshold,\n matrixElements: Array.from(volume.matrix.elements),\n inverseMatrixElements: Array.from(volume.inverseMatrix.elements),\n buffer: volume.data.buffer,\n };\n }\n function errorMessage(err) {\n if (err instanceof Error)\n return { name: err.name, message: err.message };\n return { name: \"Error\", message: String(err) };\n }\n /**\n * Handles one `{cmd: \"load\"}` command. Dedupes the underlying fetch by URL exactly like\n * `copperNrrdLoader.ts`'s old `sharedFetchNrrdArrayBuffer` did (one real request per URL,\n * shared by every attached caller) -- only the transport moved, not the sharing rule. Once\n * the shared bytes arrive, this caller runs its OWN `loader.parse()` with its OWN\n * `knownMinMax`, independently of every other attached caller -- parsing is cheap relative to\n * fetch+gunzip and was never shared even before this change (see `copperNrrdLoader.ts`'s doc\n * comment on `sharedFetchNrrdArrayBuffer`), so a second caller's different `knownMinMax` can\n * never be silently handed the first caller's window.\n */\n function handleLoadMessage(state, msg, emit) {\n return __awaiter(this, void 0, void 0, function* () {\n const { id, url, segmentation, knownMinMax } = msg;\n let entry = state.pendingByUrl.get(url);\n if (!entry) {\n const controller = new AbortController();\n const bufferPromise = fetchRawBuffer(url, controller.signal, (loaded, total) => {\n for (const [callerId, callerUrl] of state.callerToUrl) {\n if (callerUrl === url)\n emit({ id: callerId, type: \"progress\", loaded, total });\n }\n }).finally(() => {\n if (state.pendingByUrl.get(url) === entry)\n state.pendingByUrl.delete(url);\n });\n entry = { bufferPromise, controller, attached: 0 };\n state.pendingByUrl.set(url, entry);\n }\n entry.attached++;\n state.callerToUrl.set(id, url);\n const detach = () => {\n entry.attached--;\n if (entry.attached <= 0) {\n entry.controller.abort();\n if (state.pendingByUrl.get(url) === entry)\n state.pendingByUrl.delete(url);\n }\n };\n let buffer;\n try {\n buffer = yield entry.bufferPromise;\n }\n catch (err) {\n // A caller already detached (via an explicit abort message) has its own `attached`\n // decrement done there -- doing it again here would double-count. Its promise on the\n // main thread was also already rejected locally, so there is nothing left to emit.\n const stillAttached = state.callerToUrl.has(id);\n if (stillAttached) {\n detach();\n state.callerToUrl.delete(id);\n emit(Object.assign({ id, type: \"error\" }, errorMessage(err)));\n }\n return;\n }\n const stillAttached = state.callerToUrl.has(id);\n if (stillAttached) {\n detach();\n state.callerToUrl.delete(id);\n }\n if (!stillAttached)\n return; // detached (aborted) while the fetch was in flight\n try {\n pendingMinMax = knownMinMax !== null && knownMinMax !== void 0 ? knownMinMax : null;\n let volume;\n try {\n loader.setSegmentation(segmentation);\n volume = loader.parse(buffer);\n }\n finally {\n pendingMinMax = null;\n }\n const payload = buildPayload(volume);\n emit({ id, type: \"loaded\", payload }, [payload.buffer]);\n }\n catch (err) {\n emit(Object.assign({ id, type: \"error\" }, errorMessage(err)));\n }\n });\n }\n /**\n * Handles one `{cmd: \"abort\"}` command. The caller's own promise on the main thread is\n * already rejected by the time this arrives (see `copperNrrdLoader.ts`'s `loadViaWorker` --\n * it rejects locally the instant the caller's `AbortSignal` fires, exactly like the old\n * `sharedFetchNrrdArrayBuffer` did). This only updates the shared bookkeeping: the real\n * network transfer stops only once every attached caller has dropped off.\n */\n function handleAbortMessage(state, msg) {\n const url = state.callerToUrl.get(msg.id);\n if (!url)\n return;\n state.callerToUrl.delete(msg.id);\n const entry = state.pendingByUrl.get(url);\n if (!entry)\n return;\n entry.attached--;\n if (entry.attached <= 0) {\n entry.controller.abort();\n if (state.pendingByUrl.get(url) === entry)\n state.pendingByUrl.delete(url);\n }\n }\n\n /// <reference lib=\"webworker\" />\n /**\n * The real Worker entry point -- a thin `self.onmessage` wrapper around `nrrdWorkerCore.ts`,\n * which holds every bit of actual logic (fetch dedup, cancellation, parse). Bundled inline\n * (see the `?worker&inline` import in `copperNrrdLoader.ts`) so the plugin build never needs\n * to serve a second file: the plugin's UMD bundle is uploaded as a single `code/` tree and\n * mounted at an unpredictable base path, and an inlined worker has no separate URL to\n * resolve.\n *\n * One `self` per Worker instance, and one Worker instance per `copperNrrdLoader.ts` module\n * (see its module-level `sharedWorker`) -- so this state is naturally scoped to one worker's\n * lifetime, with no cross-instance leakage to guard against.\n */\n const state = createNrrdWorkerState();\n self.onmessage = (event) => {\n const msg = event.data;\n if (msg.cmd === \"load\") {\n void handleLoadMessage(state, msg, (message, transfer) => {\n self.postMessage(message, transfer !== null && transfer !== void 0 ? transfer : []);\n });\n }\n else if (msg.cmd === \"abort\") {\n handleAbortMessage(state, msg);\n }\n };\n\n})();\n";
85527
+
85528
+ function InlineWorker(options) {
85529
+ const urlApi = self.URL || self.webkitURL;
85530
+ let objectUrl;
85531
+ try {
85532
+ objectUrl = urlApi.createObjectURL(
85533
+ new Blob([workerCode], { type: "text/javascript;charset=utf-8" })
85534
+ );
85535
+ return new Worker(objectUrl, options);
85536
+ } catch (err) {
85537
+ // Blob URLs can be blocked by a strict CSP; a data URL is the fallback.
85538
+ return new Worker(
85539
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(workerCode),
85540
+ options
85541
+ );
85542
+ } finally {
85543
+ // The worker's script fetch is queued synchronously by the constructor above,
85544
+ // so the URL is no longer needed by the time this runs.
85545
+ if (objectUrl) urlApi.revokeObjectURL(objectUrl);
85546
+ }
85547
+ }
85548
+
85549
+ function createRealNrrdWorker() {
85550
+ return new InlineWorker();
85551
+ }
85552
+ let workerFactory = createRealNrrdWorker;
85553
+ let sharedWorker;
85554
+ function getSharedWorker() {
85555
+ if (!sharedWorker) {
85556
+ sharedWorker = workerFactory();
85557
+ sharedWorker.onmessage = (event) => {
85558
+ var _a;
85559
+ const msg = event.data;
85560
+ const pending = pendingRequests.get(msg.id);
85561
+ if (!pending)
85562
+ return;
85563
+ if (msg.type === "progress") {
85564
+ (_a = pending.onProgress) === null || _a === void 0 ? void 0 : _a.call(pending, msg.loaded, msg.total);
85565
+ }
85566
+ else if (msg.type === "loaded") {
85567
+ pendingRequests.delete(msg.id);
85568
+ pending.onLoaded(msg.payload);
85569
+ }
85570
+ else {
85571
+ pendingRequests.delete(msg.id);
85572
+ const err = new Error(msg.message);
85573
+ err.name = msg.name;
85574
+ pending.onError(err);
85575
+ }
85576
+ };
85577
+ }
85578
+ return sharedWorker;
85579
+ }
85580
+ /** Keyed by a per-call request id, not by URL -- the worker owns the URL-level fetch dedup
85581
+ * (see `nrrdWorkerCore.ts`'s `handleLoadMessage`); this map only correlates each caller's own
85582
+ * reply. */
85583
+ const pendingRequests = new Map();
85584
+ let requestSeq = 0;
85585
+ /**
85586
+ * Sends one `{cmd: "load"}` request to the shared NRRD worker and resolves with the
85587
+ * rehydrated `Volume` (or rejects). Replaces the old `sharedFetchNrrdArrayBuffer` +
85588
+ * per-caller `loader.parse()` pair -- the fetch dedup and per-caller parse both now happen
85589
+ * inside the worker (`nrrdWorkerCore.ts`), off the main thread.
85590
+ *
85591
+ * Cancellation mirrors the old behavior exactly: a caller's own `AbortSignal` firing rejects
85592
+ * only THIS promise, immediately, without waiting for the worker -- the worker is only
85593
+ * notified (fire-and-forget `{cmd: "abort"}`) so it can update its own attached-count
85594
+ * bookkeeping and stop the real network transfer once nobody is left attached.
85595
+ */
85596
+ function loadViaWorker(url, segmentation, knownMinMax, onProgress, signal) {
85597
+ const worker = getSharedWorker();
85598
+ const id = `nrrd-${++requestSeq}`;
85599
+ return new Promise((resolve, reject) => {
85600
+ let settled = false;
85601
+ const onAbort = () => {
85602
+ if (settled)
85603
+ return;
85604
+ settled = true;
85605
+ pendingRequests.delete(id);
85606
+ worker.postMessage({ cmd: "abort", id });
85607
+ reject(new DOMException("The operation was aborted.", "AbortError"));
85608
+ };
85609
+ if (signal) {
85610
+ if (signal.aborted) {
85611
+ onAbort();
85612
+ return;
85613
+ }
85614
+ signal.addEventListener("abort", onAbort, { once: true });
85615
+ }
85616
+ pendingRequests.set(id, {
85617
+ onProgress: (loaded, total) => {
85618
+ onProgress === null || onProgress === void 0 ? void 0 : onProgress(new ProgressEvent("progress", { loaded, total, lengthComputable: total > 0 }));
85619
+ },
85620
+ onLoaded: (payload) => {
85621
+ if (settled)
85622
+ return;
85623
+ settled = true;
85624
+ if (signal)
85625
+ signal.removeEventListener("abort", onAbort);
85626
+ try {
85627
+ resolve(rehydrateVolume(payload));
85628
+ }
85629
+ catch (err) {
85630
+ reject(err);
85631
+ }
85632
+ },
85633
+ onError: (err) => {
85634
+ if (settled)
85635
+ return;
85636
+ settled = true;
85637
+ if (signal)
85638
+ signal.removeEventListener("abort", onAbort);
85639
+ reject(err);
85640
+ },
85641
+ });
85642
+ worker.postMessage({ cmd: "load", id, url, segmentation, knownMinMax });
85643
+ });
85644
+ }
85645
+ function rehydrateVolume(payload) {
85646
+ // three's constructor is typed for its own narrower shape; the assignments below are
85647
+ // exactly the fields NRRDLoader.parse() adds, so the instance does carry them.
85648
+ const volume = new Volume(payload.xLength, payload.yLength, payload.zLength, payload.type, payload.buffer);
85649
+ volume.header = payload.header;
85650
+ volume.segmentation = payload.segmentation;
85651
+ volume.dimensions = [payload.xLength, payload.yLength, payload.zLength];
85652
+ volume.axisOrder = payload.axisOrder;
85653
+ volume.spacing = payload.spacing;
85654
+ volume.matrix = new Matrix4().fromArray(payload.matrixElements);
85655
+ volume.inverseMatrix = new Matrix4().fromArray(payload.inverseMatrixElements);
85656
+ volume.RASDimensions = payload.RASDimensions;
85657
+ volume.min = payload.min;
85658
+ volume.max = payload.max;
85659
+ volume.windowLow = payload.windowLow;
85660
+ volume.windowHigh = payload.windowHigh;
85661
+ volume.lowerThreshold = payload.lowerThreshold;
85662
+ volume.upperThreshold = payload.upperThreshold;
85663
+ return volume;
85664
+ }
85529
85665
  let cube;
85530
85666
  let gui;
85531
85667
  let oldGuiDom;
@@ -85562,13 +85698,51 @@ void main() {
85562
85698
  }
85563
85699
  }
85564
85700
  }
85701
+ /**
85702
+ * Extracts a slice plane a narrower `axes` load skipped, the first time something asks for
85703
+ * it (see `NrrdTools.setSliceOrientation`). Mutates `slices` (and `meshes`, if given) in
85704
+ * place so every existing reference to the same object -- there is exactly one per volume --
85705
+ * picks up the new plane; callers do not need to replace anything. A no-op if the axis is
85706
+ * already present.
85707
+ *
85708
+ * All three axes' slices share one `Volume` instance (see `onLoad` below), so whichever axis
85709
+ * IS already extracted is where the volume, dimensions, spacing and RAS dimensions are read
85710
+ * from -- there is no separate "the volume" reference kept around for this.
85711
+ */
85712
+ function ensureAxisExtracted(slices, axis, meshes) {
85713
+ var _a, _b;
85714
+ const existing = slices[axis];
85715
+ if (existing)
85716
+ return existing;
85717
+ const anySlice = (_b = (_a = slices.x) !== null && _a !== void 0 ? _a : slices.y) !== null && _b !== void 0 ? _b : slices.z;
85718
+ const volume = anySlice.volume;
85719
+ const dimensions = volume.dimensions;
85720
+ const rasdimensions = volume.RASDimensions;
85721
+ const ratio = volume.spacing;
85722
+ const axisIndex = axis === "x" ? 0 : axis === "y" ? 1 : 2;
85723
+ const initIndex = Math.floor(dimensions[axisIndex] / 2);
85724
+ const slice = volume.extractSlice(axis, initIndex * ratio[axisIndex]);
85725
+ repairSliceGeometry(slice);
85726
+ slice.initIndex = initIndex;
85727
+ slice.MaxIndex = dimensions[axisIndex] - 1;
85728
+ slice.RSARatio = ratio[axisIndex];
85729
+ slice.RSAMaxIndex = rasdimensions[axisIndex] - 1;
85730
+ // Match whatever per-contrast bookkeeping the already-extracted axes carry (see
85731
+ // DataLoader.setContrastOrder), so a plane extracted late is indistinguishable from one
85732
+ // extracted at load time.
85733
+ if (anySlice.contrastOrder !== undefined)
85734
+ slice.contrastOrder = anySlice.contrastOrder;
85735
+ slices[axis] = slice;
85736
+ if (meshes)
85737
+ meshes[axis] = slice.mesh;
85738
+ return slice;
85739
+ }
85565
85740
  function copperNrrdLoader(url, loadingBar, segmentation, callback, opts) {
85566
85741
  let nrrdMeshes;
85567
85742
  let nrrdSlices;
85568
85743
  let { loadingContainer, progress } = loadingBar;
85569
85744
  let name = url.split("/").pop();
85570
- loader.setSegmentation(segmentation);
85571
- loader.load(url, function (volume) {
85745
+ const onLoad = (volume) => {
85572
85746
  var _a;
85573
85747
  configGui(opts);
85574
85748
  const rasdimensions = volume.RASDimensions;
@@ -85690,7 +85864,8 @@ void main() {
85690
85864
  callback && callback(volume, nrrdMeshes, nrrdSlices);
85691
85865
  }
85692
85866
  gui = undefined;
85693
- }, function (xhr) {
85867
+ };
85868
+ const onXhrProgress = (xhr) => {
85694
85869
  var _a;
85695
85870
  loadingContainer.style.display = "flex";
85696
85871
  progress.innerText = `File: ${name} ${Math.ceil((xhr.loaded / xhr.total) * 100)} % loaded`;
@@ -85700,13 +85875,17 @@ void main() {
85700
85875
  // After the built-in bar, so a throwing callback cannot leave the bar
85701
85876
  // stuck showing a stale percentage.
85702
85877
  (_a = opts === null || opts === void 0 ? void 0 : opts.onProgress) === null || _a === void 0 ? void 0 : _a.call(opts, xhr);
85703
- }, function (error) {
85878
+ };
85879
+ const onLoadError = (error) => {
85704
85880
  var _a;
85705
85881
  // The loading bar has no failure state of its own; leaving it up
85706
85882
  // forever is what made a failed volume look like a slow one.
85707
85883
  loadingContainer.style.display = "none";
85708
85884
  (_a = opts === null || opts === void 0 ? void 0 : opts.onError) === null || _a === void 0 ? void 0 : _a.call(opts, error);
85709
- });
85885
+ };
85886
+ loadViaWorker(url, segmentation, opts === null || opts === void 0 ? void 0 : opts.knownMinMax, onXhrProgress, opts === null || opts === void 0 ? void 0 : opts.signal)
85887
+ .then(onLoad)
85888
+ .catch(onLoadError);
85710
85889
  }
85711
85890
  function copperNrrdTexture3dLoader(url, scene, container, callback) {
85712
85891
  // for case 12
@@ -108891,9 +109070,16 @@ void main() {
108891
109070
  view.changedHeight = image.originHeight;
108892
109071
  }
108893
109072
  const needToUpdateSlice = this.updateCurrentContrastSlice();
108894
- needToUpdateSlice.repaint.call(needToUpdateSlice);
108895
- view.currentSliceIndex = newIndex;
108896
- this.drawDragSlice(needToUpdateSlice.canvas);
109073
+ // A move can be scheduled (setSliceMoving's requestAnimationFrame deferral) and then
109074
+ // reach here after something else -- an axis switch, a contrast toggle -- has
109075
+ // rebuilt `displaySlices` out from under `contrastNum`. Skip the stale move rather
109076
+ // than crash on a `displaySlices[contrastNum]` that no longer exists; the next real
109077
+ // move (or the rebuild's own repaint) puts the correct slice on screen.
109078
+ if (needToUpdateSlice) {
109079
+ needToUpdateSlice.repaint.call(needToUpdateSlice);
109080
+ view.currentSliceIndex = newIndex;
109081
+ this.drawDragSlice(needToUpdateSlice.canvas);
109082
+ }
108897
109083
  }
108898
109084
  view.preSliceIndex = newIndex * image.RSARatio;
108899
109085
  this.updateShowNumDiv(view.contrastNum);
@@ -114305,6 +114491,12 @@ void main() {
114305
114491
  }
114306
114492
  else {
114307
114493
  remainSlices.forEach((slice, index) => {
114494
+ // skipSlicesDic is keyed by index and persists across switchSlicesPreservingView,
114495
+ // which does not reconcile it against the new array's length. Switching to a series
114496
+ // with fewer contrasts leaves indices with no backing slice; without this guard they
114497
+ // push undefined into displaySlices and the canvas goes blank.
114498
+ if (!this.ctx.protectedData.backUpDisplaySlices[index])
114499
+ return;
114308
114500
  if (!!slice) {
114309
114501
  this.ctx.protectedData.displaySlices.push(this.ctx.protectedData.backUpDisplaySlices[index]);
114310
114502
  this.ctx.protectedData.skipSlicesDic[index] =
@@ -114326,6 +114518,11 @@ void main() {
114326
114518
  switchPreservingView() {
114327
114519
  // Rebuild displaySlices from the new allSlicesArray
114328
114520
  this.setDisplaySlicesBaseOnAxis();
114521
+ // The previous series may have had more contrasts than this one.
114522
+ const lastContrast = this.ctx.protectedData.displaySlices.length - 1;
114523
+ if (this.ctx.nrrd_states.view.contrastNum > lastContrast) {
114524
+ this.ctx.nrrd_states.view.contrastNum = Math.max(0, lastContrast);
114525
+ }
114329
114526
  // Update mainPreSlices reference
114330
114527
  this.setMainPreSlice();
114331
114528
  this.updateMaxIndex();
@@ -114668,6 +114865,58 @@ void main() {
114668
114865
  }
114669
114866
  }
114670
114867
 
114868
+ /**
114869
+ * NrrdTools.setMasksFromNIfTI forwards its `Map<string, Uint8Array>` argument
114870
+ * straight through to here with no second channel for metadata, so a caller that
114871
+ * wants setMasksFromNIfTI to validate a buffer's own grid has to attach it out of
114872
+ * band. Keyed by the buffer's identity (not its layer id) because a caller may
114873
+ * decode several layers before this map is consulted.
114874
+ */
114875
+ const maskGridByBuffer = new WeakMap();
114876
+ /**
114877
+ * Records the NIfTI header's voxel grid [x, y, z] for a mask buffer that will be
114878
+ * passed to `setMasksFromNIfTI`. Call this before that call for every buffer whose
114879
+ * origin file's grid should be checked against the loaded NRRD's -- a buffer with
114880
+ * no registered grid is refused rather than assumed to match (see
114881
+ * `setMasksFromNIfTI`).
114882
+ */
114883
+ function registerNiftiMaskGrid(data, dims) {
114884
+ maskGridByBuffer.set(data, dims);
114885
+ }
114886
+ /**
114887
+ * Builds a `NrrdHeaderLike` from a loaded slice's underlying volume.
114888
+ *
114889
+ * `nrrd_x_mm`/`nrrd_y_mm`/`nrrd_z_mm` used to be read off `slice.z.canvas.width`,
114890
+ * `slice.z.canvas.height` and `slice.x.canvas.width` — the physical size (mm) of
114891
+ * the plane THREE's Volume/VolumeSlice extracted. Those canvases are always
114892
+ * sized to `dimensions[axis] * spacing[axis]` for the two in-plane axes
114893
+ * (Volume.extractPerpendicularPlane: planeWidth/planeHeight = iLength/jLength,
114894
+ * which are exactly the voxel counts, times spacing), so the same mm extents
114895
+ * are derivable from dimensions/spacing alone without touching a canvas —
114896
+ * which is what makes `initFromHeader` possible before any pixels exist.
114897
+ *
114898
+ * One catch verified against a real THREE.Volume/VolumeSlice: `canvas.width`/
114899
+ * `canvas.height` are HTML "unsigned long" properties, so assigning a
114900
+ * non-integer `dimensions[i] * spacing[i]` truncates it (e.g. 44.8 -> 44).
114901
+ * `initFromHeader` reproduces that with `Math.floor` (values are never
114902
+ * negative, so floor and the DOM's truncation agree). Spacing is never
114903
+ * negative because THREE's `Volume.spacing` is a magnitude derived from the
114904
+ * NRRD/NIfTI affine, not a signed per-axis direction component -- a
114905
+ * flipped-axis volume changes the affine's sign, not this value.
114906
+ */
114907
+ function headerFromSlice(slice) {
114908
+ var _a, _b;
114909
+ // All three axes' slices point at the same shared Volume instance (copperNrrdLoader.ts
114910
+ // builds them all from one volume), so reading from whichever axis IS present is safe --
114911
+ // a narrowed-axes load (see copperNrrdLoader's `axes` option) may only have "z" extracted
114912
+ // at this point, so this can no longer assume `.x`.
114913
+ const volume = ((_b = (_a = slice.x) !== null && _a !== void 0 ? _a : slice.y) !== null && _b !== void 0 ? _b : slice.z).volume;
114914
+ return {
114915
+ dimensions: volume.dimensions,
114916
+ spacing: volume.spacing,
114917
+ space_origin: volume.header.space_origin,
114918
+ };
114919
+ }
114671
114920
  /**
114672
114921
  * Handles data loading for NRRD slices and mask volumes.
114673
114922
  *
@@ -114681,22 +114930,23 @@ void main() {
114681
114930
  }
114682
114931
  /****************************Slice Loading****************************************************/
114683
114932
  /**
114684
- * Load all NRRD contrast slices and initialize MaskVolumes with real dimensions.
114933
+ * Size image-metadata state and MaskVolumes from volume geometry alone,
114934
+ * before any slice pixel data has arrived. `allSlicesArray` is untouched.
114685
114935
  */
114686
- setAllSlices(allSlices) {
114687
- this.ctx.protectedData.allSlicesArray = [...allSlices];
114688
- const randomSlice = this.ctx.protectedData.allSlicesArray[0];
114689
- this.ctx.nrrd_states.image.nrrd_x_mm = randomSlice.z.canvas.width;
114690
- this.ctx.nrrd_states.image.nrrd_y_mm = randomSlice.z.canvas.height;
114691
- this.ctx.nrrd_states.image.nrrd_z_mm = randomSlice.x.canvas.width;
114692
- this.ctx.nrrd_states.image.nrrd_x_pixel = randomSlice.x.volume.dimensions[0];
114693
- this.ctx.nrrd_states.image.nrrd_y_pixel = randomSlice.x.volume.dimensions[1];
114694
- this.ctx.nrrd_states.image.nrrd_z_pixel = randomSlice.x.volume.dimensions[2];
114695
- this.ctx.nrrd_states.image.voxelSpacing = randomSlice.x.volume.spacing;
114696
- this.ctx.nrrd_states.image.ratios.x = randomSlice.x.volume.spacing[0];
114697
- this.ctx.nrrd_states.image.ratios.y = randomSlice.x.volume.spacing[1];
114698
- this.ctx.nrrd_states.image.ratios.z = randomSlice.x.volume.spacing[2];
114699
- this.ctx.nrrd_states.image.dimensions = randomSlice.x.volume.dimensions;
114936
+ initFromHeader(header) {
114937
+ const [dx, dy, dz] = header.dimensions;
114938
+ const [sx, sy, sz] = header.spacing;
114939
+ this.ctx.nrrd_states.image.nrrd_x_mm = Math.floor(dx * sx);
114940
+ this.ctx.nrrd_states.image.nrrd_y_mm = Math.floor(dy * sy);
114941
+ this.ctx.nrrd_states.image.nrrd_z_mm = Math.floor(dz * sz);
114942
+ this.ctx.nrrd_states.image.nrrd_x_pixel = dx;
114943
+ this.ctx.nrrd_states.image.nrrd_y_pixel = dy;
114944
+ this.ctx.nrrd_states.image.nrrd_z_pixel = dz;
114945
+ this.ctx.nrrd_states.image.voxelSpacing = header.spacing;
114946
+ this.ctx.nrrd_states.image.ratios.x = sx;
114947
+ this.ctx.nrrd_states.image.ratios.y = sy;
114948
+ this.ctx.nrrd_states.image.ratios.z = sz;
114949
+ this.ctx.nrrd_states.image.dimensions = header.dimensions;
114700
114950
  // Re-initialize MaskVolume with real NRRD dimensions.
114701
114951
  // This replaces the 1×1×1 placeholders from CommToolsData constructor.
114702
114952
  // Invalidate reusable buffer from previous dataset.
@@ -114717,13 +114967,50 @@ void main() {
114717
114967
  const c = MASK_CHANNEL_COLORS[channel];
114718
114968
  this.ctx.nrrd_states.sphere.sphereMaskVolume.setChannelColor(label, { r: c.r, g: c.g, b: c.b, a: c.a });
114719
114969
  }
114720
- this.ctx.nrrd_states.image.spaceOrigin = randomSlice.x.volume.header.space_origin.map((item) => {
114970
+ this.ctx.nrrd_states.image.spaceOrigin = header.space_origin.map((item) => {
114721
114971
  return item * 1;
114722
114972
  });
114723
- this.ctx.protectedData.allSlicesArray.forEach((item, index) => {
114724
- item.x.contrastOrder = index;
114725
- item.y.contrastOrder = index;
114726
- item.z.contrastOrder = index;
114973
+ }
114974
+ /**
114975
+ * Records a slice's position in the contrast series. Does not refresh the
114976
+ * display slices/undo-history side effects — see `appendSlice` for that.
114977
+ */
114978
+ setContrastOrder(slice, order) {
114979
+ this.ctx.protectedData.allSlicesArray.push(slice);
114980
+ // A narrowed-axes load (see copperNrrdLoader's `axes` option) may not have every plane
114981
+ // extracted yet -- only stamp the ones that exist. `ensureAxisExtracted` copies this same
114982
+ // value onto a plane extracted later (see NrrdTools.setSliceOrientation), so a late
114983
+ // extraction still ends up stamped.
114984
+ if (slice.x)
114985
+ slice.x.contrastOrder = order;
114986
+ if (slice.y)
114987
+ slice.y.contrastOrder = order;
114988
+ if (slice.z)
114989
+ slice.z.contrastOrder = order;
114990
+ }
114991
+ /**
114992
+ * Appends one already-loaded slice to the contrast series and refreshes the
114993
+ * display slices / undo state for it. For loading N slices at once, prefer
114994
+ * `setAllSlices`: calling this once per slice would rebuild the display-slice
114995
+ * list from a still-growing `allSlicesArray` on every call, and
114996
+ * `setDisplaySlicesBaseOnAxis`'s skip-list bookkeeping (`skipSlicesDic`)
114997
+ * assumes each call sees the final array, not an intermediate one.
114998
+ */
114999
+ appendSlice(slice, order) {
115000
+ this.setContrastOrder(slice, order);
115001
+ this.callbacks.setDisplaySlicesBaseOnAxis();
115002
+ this.callbacks.afterLoadSlice();
115003
+ }
115004
+ /**
115005
+ * Load all NRRD contrast slices and initialize MaskVolumes with real dimensions.
115006
+ */
115007
+ setAllSlices(allSlices) {
115008
+ this.initFromHeader(headerFromSlice(allSlices[0]));
115009
+ // Replace, not append: a fresh case load must discard whatever series
115010
+ // (if any) was previously loaded, exactly like the pre-split assignment.
115011
+ this.ctx.protectedData.allSlicesArray.length = 0;
115012
+ allSlices.forEach((slice, index) => {
115013
+ this.setContrastOrder(slice, index);
114727
115014
  });
114728
115015
  // Phase 3: initPaintImages removed (MaskVolume initialized separately)
114729
115016
  // this.initPaintImages(this.nrrd_states.image.dimensions);
@@ -114778,7 +115065,12 @@ void main() {
114778
115065
  /**
114779
115066
  * Load raw voxel data into MaskVolume layers.
114780
115067
  *
114781
- * Expects pre-extracted voxel bytes (e.g. from useNiftiVoxelData).
115068
+ * Expects pre-extracted voxel bytes (e.g. from useNiftiVoxelData). A buffer is
115069
+ * refused -- not truncated or zero-padded -- when its own NIfTI grid (registered
115070
+ * via `registerNiftiMaskGrid`) does not match the loaded NRRD's grid. Truncating
115071
+ * a longer buffer or zero-padding a shorter one used to render it silently
115072
+ * offset onto the wrong voxels with no error; a refused mask is recoverable,
115073
+ * a misplaced one is not.
114782
115074
  *
114783
115075
  * @param layerVoxels Map of layer ID to raw voxel Uint8Array
114784
115076
  * Keys should be 'layer1', 'layer2', 'layer3'
@@ -114792,22 +115084,25 @@ void main() {
114792
115084
  loadingBar.progress.innerText = "Loading mask layers from NIfTI...";
114793
115085
  }
114794
115086
  try {
115087
+ const nrrdDims = this.ctx.nrrd_states.image.dimensions;
114795
115088
  for (const [layerId, rawData] of layerVoxels) {
114796
115089
  const volume = this.ctx.protectedData.maskData.volumes[layerId];
114797
115090
  if (!volume) {
114798
115091
  console.warn(`setMasksFromNIfTI: unknown layer "${layerId}", skipping`);
114799
115092
  continue;
114800
115093
  }
114801
- const expectedLen = volume.getRawData().length;
114802
- // Ensure we copy exactly the right number of bytes
114803
- if (rawData.length >= expectedLen) {
114804
- volume.setRawData(rawData.slice(0, expectedLen));
114805
- }
114806
- else {
114807
- const padded = new Uint8Array(expectedLen);
114808
- padded.set(rawData);
114809
- volume.setRawData(padded);
115094
+ const maskDims = maskGridByBuffer.get(rawData);
115095
+ const onGrid = !!maskDims &&
115096
+ maskDims.length === nrrdDims.length &&
115097
+ maskDims.every((d, i) => d === nrrdDims[i]);
115098
+ if (!onGrid) {
115099
+ const maskGridLabel = maskDims ? maskDims.join("x") : "unknown";
115100
+ const nrrdGridLabel = nrrdDims.join("x");
115101
+ console.error(`setMasksFromNIfTI: layer "${layerId}" grid [${maskGridLabel}] does not match the image grid [${nrrdGridLabel}]; refusing to load`);
115102
+ this.callbacks.notifyUser(`Mask for ${layerId} (grid ${maskGridLabel}) does not match the image grid (${nrrdGridLabel}). Mask was not loaded.`, "error");
115103
+ continue;
114810
115104
  }
115105
+ volume.setRawData(rawData);
114811
115106
  }
114812
115107
  // Reload the current slice from MaskVolume to canvas
114813
115108
  this.callbacks.reloadMasksFromVolume();
@@ -114854,6 +115149,19 @@ void main() {
114854
115149
  this._pendingSliceStep = 0;
114855
115150
  /** Whether calculator mode is active (not part of gui_states interface) */
114856
115151
  this._calculatorActive = false;
115152
+ /**
115153
+ * How a message reaches the reader. Defaults to the console: this package ships without
115154
+ * a UI and must not import the host application's, or it cannot be built on its own.
115155
+ * A host that has a toast or a banner assigns this after construction.
115156
+ */
115157
+ this.notifyUser = (message, level) => {
115158
+ if (level === "error")
115159
+ console.error(message);
115160
+ else if (level === "warning")
115161
+ console.warn(message);
115162
+ else
115163
+ console.info(message);
115164
+ };
114857
115165
  /** Stored closure callbacks from gui.ts setupGui() */
114858
115166
  this.guiCallbacks = null;
114859
115167
  // ═══════════════════════════════════════════════════════════════════════════
@@ -114946,6 +115254,7 @@ void main() {
114946
115254
  syncLayerSliceData: (index, mode) => this.drawCore.syncLayerSliceData(index, mode),
114947
115255
  reloadMasksFromVolume: () => this.reloadMasksFromVolume(),
114948
115256
  resetZoom: () => this.executeAction("resetZoom"),
115257
+ notifyUser: (message, level) => this.notifyUser(message, level),
114949
115258
  });
114950
115259
  }
114951
115260
  // ═══════════════════════════════════════════════════════════════════════════
@@ -115459,6 +115768,14 @@ void main() {
115459
115768
  this.state.nrrd_states.interaction.isCursorSelect = false;
115460
115769
  }
115461
115770
  }
115771
+ // A narrowed-axes case load (see copperNrrdLoader's `axes` option) only extracts "z" up
115772
+ // front; switching to sagittal/coronal is the first time anything needs the other planes.
115773
+ // Extract them here, for every loaded contrast, before the display pipeline reads
115774
+ // `slices[axisTo]` (SliceRenderPipeline.setDisplaySlicesBaseOnAxis) -- a no-op per slice
115775
+ // that already has this axis.
115776
+ for (const slice of this.state.protectedData.allSlicesArray) {
115777
+ ensureAxisExtracted(slice, axisTo);
115778
+ }
115462
115779
  this.state.protectedData.axis = axisTo;
115463
115780
  this.sliceRenderPipeline.resetDisplaySlicesStatus();
115464
115781
  }
@@ -115478,6 +115795,50 @@ void main() {
115478
115795
  this.state.nrrd_states.view.contrastNum = 0;
115479
115796
  this.sliceRenderPipeline.resetDisplaySlicesStatus();
115480
115797
  }
115798
+ /**
115799
+ * Batched form of `addSkip`/`removeSkip` for reconciling many positions at once (e.g. a
115800
+ * case load's initial phase selection, see `useCaseManagement.reconcileSkips`) without
115801
+ * paying `resetDisplaySlicesStatus()`'s full display/canvas/mask refresh once per position.
115802
+ *
115803
+ * Calling `addSkip`/`removeSkip` in a loop is correct but wasteful here: every entry but
115804
+ * the last is immediately superseded (this always runs synchronously, with nothing reading
115805
+ * the display in between, and the caller's own follow-up -- `landOn`'s `setContrastIndex`
115806
+ * -- overwrites `contrastNum` again right after). Measured at over 1 second of main-thread
115807
+ * time for a 5-phase series once per-volume extraction stopped dominating the case-load
115808
+ * block (narrower `axes`, see copperNrrdLoader) -- this was always there, just smaller than
115809
+ * the cost it used to sit next to.
115810
+ */
115811
+ setSkips(entries) {
115812
+ for (const { index, skip } of entries) {
115813
+ if (skip) {
115814
+ this.state.protectedData.skipSlicesDic[index] =
115815
+ this.state.protectedData.backUpDisplaySlices[index];
115816
+ this.state.nrrd_states.view.contrastNum =
115817
+ index >= this.state.protectedData.displaySlices.length
115818
+ ? this.state.protectedData.displaySlices.length
115819
+ : index;
115820
+ }
115821
+ else {
115822
+ this.state.protectedData.skipSlicesDic[index] = undefined;
115823
+ this.state.nrrd_states.view.contrastNum = 0;
115824
+ }
115825
+ }
115826
+ this.sliceRenderPipeline.resetDisplaySlicesStatus();
115827
+ }
115828
+ /**
115829
+ * Move to a specific contrast without moving the slice.
115830
+ *
115831
+ * `index` addresses `displaySlices` — the SELECTED subset — not the full contrast list.
115832
+ * With three of five phases selected, valid values are 0..2. Callers that think in phase
115833
+ * names must convert first.
115834
+ */
115835
+ setContrastIndex(index) {
115836
+ const last = this.state.protectedData.displaySlices.length - 1;
115837
+ if (last < 0)
115838
+ return;
115839
+ this.state.nrrd_states.view.contrastNum = Math.min(Math.max(index, 0), last);
115840
+ this.sliceRenderPipeline.resetDisplaySlicesStatus();
115841
+ }
115481
115842
  setSliceMoving(step) {
115482
115843
  if (this.state.protectedData.mainPreSlices) {
115483
115844
  this._pendingSliceStep += step;
@@ -115510,6 +115871,47 @@ void main() {
115510
115871
  this.state.protectedData.allSlicesArray = [...allSlices];
115511
115872
  this.sliceRenderPipeline.resetDisplaySlicesStatus();
115512
115873
  }
115874
+ /**
115875
+ * Batched form of `setSkips` + `setContrastIndex` for a load that ends by reconciling skip
115876
+ * state and landing on a phase in the same turn (see
115877
+ * `useCaseManagement.handleAllImagesLoaded`). Calling them separately is correct but
115878
+ * wasteful: each pays `resetDisplaySlicesStatus()`'s full display/canvas/mask refresh, and
115879
+ * with nothing reading the display in between, only the second call's paint was ever
115880
+ * visible -- measured at two ~300ms refreshes back-to-back once `setSkips` had already
115881
+ * absorbed the earlier per-phase `addSkip`/`removeSkip` loop cost.
115882
+ *
115883
+ * `contrastIndex` is set before the single `resetDisplaySlicesStatus()` call, not after:
115884
+ * the resulting `displaySlices` length/order depends only on `skipSlicesDic`, which is
115885
+ * already written by the time it runs, so the callbacks inside that one refresh
115886
+ * (`repraintCurrentContrastSlice` etc.) paint the target contrast directly. The clamp
115887
+ * below still runs after, against the freshly rebuilt `displaySlices`, for parity with
115888
+ * `setContrastIndex`'s own bounds check.
115889
+ */
115890
+ commitSkipsAndContrast(skipEntries, contrastIndex) {
115891
+ for (const { index, skip } of skipEntries) {
115892
+ this.state.protectedData.skipSlicesDic[index] = skip
115893
+ ? this.state.protectedData.backUpDisplaySlices[index]
115894
+ : undefined;
115895
+ }
115896
+ this.state.nrrd_states.view.contrastNum = Math.max(contrastIndex, 0);
115897
+ this.sliceRenderPipeline.resetDisplaySlicesStatus();
115898
+ const last = this.state.protectedData.displaySlices.length - 1;
115899
+ if (this.state.nrrd_states.view.contrastNum > last) {
115900
+ this.state.nrrd_states.view.contrastNum = Math.max(0, last);
115901
+ }
115902
+ }
115903
+ /**
115904
+ * Case-load completion, fully batched: swap in the acquisition-ordered slice array,
115905
+ * reconcile skip state, and land on the target contrast -- one `resetDisplaySlicesStatus()`
115906
+ * instead of three (`switchAllSlicesArrayData` + `setSkips` + `setContrastIndex` used to
115907
+ * each pay their own full refresh here; see `commitSkipsAndContrast` above for why only
115908
+ * the batched form's single refresh is needed).
115909
+ */
115910
+ commitSeriesLoad(allSlices, skipEntries, contrastIndex) {
115911
+ this.state.protectedData.allSlicesArray.length = 0;
115912
+ this.state.protectedData.allSlicesArray = [...allSlices];
115913
+ this.commitSkipsAndContrast(skipEntries, contrastIndex);
115914
+ }
115513
115915
  /**
115514
115916
  * Swap slice data while preserving current slice index, zoom, and pan position.
115515
115917
  * Used for register/origin image switching where the view state should persist.
@@ -117189,15 +117591,15 @@ void main() {
117189
117591
  }
117190
117592
 
117191
117593
  // import * as kiwrious from "copper3d_plugin_heart_k";
117192
- // "v3.9.2" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
117594
+ // "v3.10.0" is injected at build time by rollup @rollup/plugin-replace, sourced from package.json version.
117193
117595
  // When copper3d is consumed from local source (no rollup replace step), the identifier is undefined and
117194
117596
  // referencing it throws a ReferenceError — guard it so local loading still works.
117195
117597
  let _revision = "unknown";
117196
117598
  try {
117197
- _revision = "v3.9.2";
117599
+ _revision = "v3.10.0";
117198
117600
  }
117199
117601
  catch (_a) {
117200
- /* "v3.9.2" not injected (local source build) */
117602
+ /* "v3.10.0" not injected (local source build) */
117201
117603
  }
117202
117604
  const REVISION = _revision;
117203
117605
  // Expose on global so the version can be read in a production browser console via window.__COPPER3D_VERSION__
@@ -117245,6 +117647,7 @@ void main() {
117245
117647
  exports.disposeObject3D = disposeObject3D;
117246
117648
  exports.disposeScene = disposeScene;
117247
117649
  exports.easeInOutCubic = easeInOutCubic;
117650
+ exports.ensureAxisExtracted = ensureAxisExtracted;
117248
117651
  exports.exposureExponent = exposureExponent;
117249
117652
  exports.fitDistance = fitDistance;
117250
117653
  exports.fitView = fitView;
@@ -117261,6 +117664,7 @@ void main() {
117261
117664
  exports.orbitStepPose = orbitStepPose;
117262
117665
  exports.orbitSwingAngle = orbitSwingAngle;
117263
117666
  exports.poseDistance = poseDistance;
117667
+ exports.registerNiftiMaskGrid = registerNiftiMaskGrid;
117264
117668
  exports.removeGuiFolderChilden = removeGuiFolderChilden;
117265
117669
  exports.removeSceneFromMap = removeSceneFromMap;
117266
117670
  exports.restoreFade = restoreFade;