meta-client
Version:
Meta.js (Client)
1 lines • 1.68 MB
JSON
{"id":"src\\Space\\Meta\\Graphics\\three\\GLTFLoader.js","dependencies":[{"name":"C:\\Users\\florianmaxim\\work\\meta\\package.json","includedInParent":true,"mtime":1531738454768},{"name":"C:\\Users\\florianmaxim\\work\\meta\\.babelrc","includedInParent":true,"mtime":1531738212210},{"name":"three","loc":{"line":1,"column":23},"parent":"C:\\Users\\florianmaxim\\work\\meta\\src\\Space\\Meta\\Graphics\\three\\GLTFLoader.js","resolved":"C:\\Users\\florianmaxim\\work\\meta\\node_modules\\three\\build\\three.module.js"}],"generated":{"js":"'use strict';\n\nvar _three = require('three');\n\nvar THREE = _interopRequireWildcard(_three);\n\nfunction _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }\n\n/**\r\n * @author Rich Tibbett / https://github.com/richtr\r\n * @author mrdoob / http://mrdoob.com/\r\n * @author Tony Parisi / http://www.tonyparisi.com/\r\n * @author Takahiro / https://github.com/takahirox\r\n * @author Don McCurdy / https://www.donmccurdy.com\r\n */\n\nconsole.log('hello');\n\nTHREE.GLTFLoader = function () {\n\n\t\t\tfunction GLTFLoader(manager) {\n\n\t\t\t\t\t\tthis.manager = manager !== undefined ? manager : THREE.DefaultLoadingManager;\n\t\t\t\t\t\tthis.dracoLoader = null;\n\t\t\t}\n\n\t\t\tGLTFLoader.prototype = {\n\n\t\t\t\t\t\tconstructor: GLTFLoader,\n\n\t\t\t\t\t\tcrossOrigin: 'anonymous',\n\n\t\t\t\t\t\tload: function load(url, onLoad, onProgress, onError) {\n\n\t\t\t\t\t\t\t\t\tvar scope = this;\n\n\t\t\t\t\t\t\t\t\tvar path = this.path !== undefined ? this.path : THREE.LoaderUtils.extractUrlBase(url);\n\n\t\t\t\t\t\t\t\t\tvar loader = new THREE.FileLoader(scope.manager);\n\n\t\t\t\t\t\t\t\t\tloader.setResponseType('arraybuffer');\n\n\t\t\t\t\t\t\t\t\tloader.load(url, function (data) {\n\n\t\t\t\t\t\t\t\t\t\t\t\ttry {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tscope.parse(data, path, onLoad, onError);\n\t\t\t\t\t\t\t\t\t\t\t\t} catch (e) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (onError !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tonError(e);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthrow e;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}, onProgress, onError);\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tsetCrossOrigin: function setCrossOrigin(value) {\n\n\t\t\t\t\t\t\t\t\tthis.crossOrigin = value;\n\t\t\t\t\t\t\t\t\treturn this;\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tsetPath: function setPath(value) {\n\n\t\t\t\t\t\t\t\t\tthis.path = value;\n\t\t\t\t\t\t\t\t\treturn this;\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tsetDRACOLoader: function setDRACOLoader(dracoLoader) {\n\n\t\t\t\t\t\t\t\t\tthis.dracoLoader = dracoLoader;\n\t\t\t\t\t\t\t\t\treturn this;\n\t\t\t\t\t\t},\n\n\t\t\t\t\t\tparse: function parse(data, path, onLoad, onError) {\n\n\t\t\t\t\t\t\t\t\tvar content;\n\t\t\t\t\t\t\t\t\tvar extensions = {};\n\n\t\t\t\t\t\t\t\t\tif (typeof data === 'string') {\n\n\t\t\t\t\t\t\t\t\t\t\t\tcontent = data;\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar magic = THREE.LoaderUtils.decodeText(new Uint8Array(data, 0, 4));\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (magic === BINARY_EXTENSION_HEADER_MAGIC) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttry {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t} catch (error) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (onError) onError(error);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontent = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontent = THREE.LoaderUtils.decodeText(new Uint8Array(data));\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tvar json = JSON.parse(content);\n\n\t\t\t\t\t\t\t\t\tif (json.asset === undefined || json.asset.version[0] < 2) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (onError) onError(new Error('THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.'));\n\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (json.extensionsUsed) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tfor (var i = 0; i < json.extensionsUsed.length; ++i) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar extensionName = json.extensionsUsed[i];\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar extensionsRequired = json.extensionsRequired || [];\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tswitch (extensionName) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase EXTENSIONS.KHR_LIGHTS:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[extensionName] = new GLTFLightsExtension(json);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase EXTENSIONS.KHR_MATERIALS_UNLIT:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[extensionName] = new GLTFMaterialsUnlitExtension(json);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[extensionName] = new GLTFDracoMeshCompressionExtension(json, this.dracoLoader);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase EXTENSIONS.MSFT_TEXTURE_DDS:\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\textensions[EXTENSIONS.MSFT_TEXTURE_DDS] = new GLTFTextureDDSExtension();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (extensionsRequired.indexOf(extensionName) >= 0) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconsole.warn('THREE.GLTFLoader: Unknown extension \"' + extensionName + '\".');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tvar parser = new GLTFParser(json, extensions, {\n\n\t\t\t\t\t\t\t\t\t\t\t\tpath: path || this.path || '',\n\t\t\t\t\t\t\t\t\t\t\t\tcrossOrigin: this.crossOrigin,\n\t\t\t\t\t\t\t\t\t\t\t\tmanager: this.manager\n\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\tparser.parse(function (scene, scenes, cameras, animations, json) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar glTF = {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tscene: scene,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tscenes: scenes,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcameras: cameras,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tanimations: animations,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tasset: json.asset,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparser: parser,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuserData: {}\n\t\t\t\t\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\t\t\t\t\taddUnknownExtensionsToUserData(extensions, glTF, json);\n\n\t\t\t\t\t\t\t\t\t\t\t\tonLoad(glTF);\n\t\t\t\t\t\t\t\t\t}, onError);\n\t\t\t\t\t\t}\n\n\t\t\t};\n\n\t\t\t/* GLTFREGISTRY */\n\n\t\t\tfunction GLTFRegistry() {\n\n\t\t\t\t\t\tvar objects = {};\n\n\t\t\t\t\t\treturn {\n\n\t\t\t\t\t\t\t\t\tget: function get(key) {\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn objects[key];\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\tadd: function add(key, object) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tobjects[key] = object;\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\tremove: function remove(key) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tdelete objects[key];\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\tremoveAll: function removeAll() {\n\n\t\t\t\t\t\t\t\t\t\t\t\tobjects = {};\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t};\n\t\t\t}\n\n\t\t\t/*********************************/\n\t\t\t/********** EXTENSIONS ***********/\n\t\t\t/*********************************/\n\n\t\t\tvar EXTENSIONS = {\n\t\t\t\t\t\tKHR_BINARY_GLTF: 'KHR_binary_glTF',\n\t\t\t\t\t\tKHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',\n\t\t\t\t\t\tKHR_LIGHTS: 'KHR_lights',\n\t\t\t\t\t\tKHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',\n\t\t\t\t\t\tKHR_MATERIALS_UNLIT: 'KHR_materials_unlit',\n\t\t\t\t\t\tMSFT_TEXTURE_DDS: 'MSFT_texture_dds'\n\t\t\t};\n\n\t\t\t/**\r\n * DDS Texture Extension\r\n *\r\n * Specification:\r\n * https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds\r\n *\r\n */\n\t\t\tfunction GLTFTextureDDSExtension() {\n\n\t\t\t\t\t\tif (!THREE.DDSLoader) {\n\n\t\t\t\t\t\t\t\t\tthrow new Error('THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.name = EXTENSIONS.MSFT_TEXTURE_DDS;\n\t\t\t\t\t\tthis.ddsLoader = new THREE.DDSLoader();\n\t\t\t}\n\n\t\t\t/**\r\n * Lights Extension\r\n *\r\n * Specification: PENDING\r\n */\n\t\t\tfunction GLTFLightsExtension(json) {\n\n\t\t\t\t\t\tthis.name = EXTENSIONS.KHR_LIGHTS;\n\n\t\t\t\t\t\tthis.lights = {};\n\n\t\t\t\t\t\tvar extension = json.extensions && json.extensions[EXTENSIONS.KHR_LIGHTS] || {};\n\t\t\t\t\t\tvar lights = extension.lights || {};\n\n\t\t\t\t\t\tfor (var lightId in lights) {\n\n\t\t\t\t\t\t\t\t\tvar light = lights[lightId];\n\t\t\t\t\t\t\t\t\tvar lightNode;\n\n\t\t\t\t\t\t\t\t\tvar color = new THREE.Color().fromArray(light.color);\n\n\t\t\t\t\t\t\t\t\tswitch (light.type) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase 'directional':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode = new THREE.DirectionalLight(color);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.target.position.set(0, 0, 1);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.add(lightNode.target);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase 'point':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode = new THREE.PointLight(color);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase 'spot':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode = new THREE.SpotLight(color);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Handle spotlight properties.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlight.spot = light.spot || {};\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlight.spot.innerConeAngle = light.spot.innerConeAngle !== undefined ? light.spot.innerConeAngle : 0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlight.spot.outerConeAngle = light.spot.outerConeAngle !== undefined ? light.spot.outerConeAngle : Math.PI / 4.0;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.angle = light.spot.outerConeAngle;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.penumbra = 1.0 - light.spot.innerConeAngle / light.spot.outerConeAngle;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.target.position.set(0, 0, 1);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.add(lightNode.target);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t\t\t\tcase 'ambient':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode = new THREE.AmbientLight(color);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (lightNode) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tlightNode.decay = 2;\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (light.intensity !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlightNode.intensity = light.intensity;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tlightNode.name = light.name || 'light_' + lightId;\n\t\t\t\t\t\t\t\t\t\t\t\tthis.lights[lightId] = lightNode;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\r\n * Unlit Materials Extension (pending)\r\n *\r\n * PR: https://github.com/KhronosGroup/glTF/pull/1163\r\n */\n\t\t\tfunction GLTFMaterialsUnlitExtension(json) {\n\n\t\t\t\t\t\tthis.name = EXTENSIONS.KHR_MATERIALS_UNLIT;\n\t\t\t}\n\n\t\t\tGLTFMaterialsUnlitExtension.prototype.getMaterialType = function (material) {\n\n\t\t\t\t\t\treturn THREE.MeshBasicMaterial;\n\t\t\t};\n\n\t\t\tGLTFMaterialsUnlitExtension.prototype.extendParams = function (materialParams, material, parser) {\n\n\t\t\t\t\t\tvar pending = [];\n\n\t\t\t\t\t\tmaterialParams.color = new THREE.Color(1.0, 1.0, 1.0);\n\t\t\t\t\t\tmaterialParams.opacity = 1.0;\n\n\t\t\t\t\t\tvar metallicRoughness = material.pbrMetallicRoughness;\n\n\t\t\t\t\t\tif (metallicRoughness) {\n\n\t\t\t\t\t\t\t\t\tif (Array.isArray(metallicRoughness.baseColorFactor)) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar array = metallicRoughness.baseColorFactor;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterialParams.color.fromArray(array);\n\t\t\t\t\t\t\t\t\t\t\t\tmaterialParams.opacity = array[3];\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (metallicRoughness.baseColorTexture !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tpending.push(parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture.index));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn Promise.all(pending);\n\t\t\t};\n\n\t\t\t/* BINARY EXTENSION */\n\n\t\t\tvar BINARY_EXTENSION_BUFFER_NAME = 'binary_glTF';\n\t\t\tvar BINARY_EXTENSION_HEADER_MAGIC = 'glTF';\n\t\t\tvar BINARY_EXTENSION_HEADER_LENGTH = 12;\n\t\t\tvar BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 };\n\n\t\t\tfunction GLTFBinaryExtension(data) {\n\n\t\t\t\t\t\tthis.name = EXTENSIONS.KHR_BINARY_GLTF;\n\t\t\t\t\t\tthis.content = null;\n\t\t\t\t\t\tthis.body = null;\n\n\t\t\t\t\t\tvar headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);\n\n\t\t\t\t\t\tthis.header = {\n\t\t\t\t\t\t\t\t\tmagic: THREE.LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),\n\t\t\t\t\t\t\t\t\tversion: headerView.getUint32(4, true),\n\t\t\t\t\t\t\t\t\tlength: headerView.getUint32(8, true)\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tif (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {\n\n\t\t\t\t\t\t\t\t\tthrow new Error('THREE.GLTFLoader: Unsupported glTF-Binary header.');\n\t\t\t\t\t\t} else if (this.header.version < 2.0) {\n\n\t\t\t\t\t\t\t\t\tthrow new Error('THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);\n\t\t\t\t\t\tvar chunkIndex = 0;\n\n\t\t\t\t\t\twhile (chunkIndex < chunkView.byteLength) {\n\n\t\t\t\t\t\t\t\t\tvar chunkLength = chunkView.getUint32(chunkIndex, true);\n\t\t\t\t\t\t\t\t\tchunkIndex += 4;\n\n\t\t\t\t\t\t\t\t\tvar chunkType = chunkView.getUint32(chunkIndex, true);\n\t\t\t\t\t\t\t\t\tchunkIndex += 4;\n\n\t\t\t\t\t\t\t\t\tif (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar contentArray = new Uint8Array(data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength);\n\t\t\t\t\t\t\t\t\t\t\t\tthis.content = THREE.LoaderUtils.decodeText(contentArray);\n\t\t\t\t\t\t\t\t\t} else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;\n\t\t\t\t\t\t\t\t\t\t\t\tthis.body = data.slice(byteOffset, byteOffset + chunkLength);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Clients must ignore chunks with unknown types.\n\n\t\t\t\t\t\t\t\t\tchunkIndex += chunkLength;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.content === null) {\n\n\t\t\t\t\t\t\t\t\tthrow new Error('THREE.GLTFLoader: JSON content not found.');\n\t\t\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\r\n * DRACO Mesh Compression Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/pull/874\r\n */\n\t\t\tfunction GLTFDracoMeshCompressionExtension(json, dracoLoader) {\n\n\t\t\t\t\t\tif (!dracoLoader) {\n\n\t\t\t\t\t\t\t\t\tthrow new Error('THREE.GLTFLoader: No DRACOLoader instance provided.');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;\n\t\t\t\t\t\tthis.json = json;\n\t\t\t\t\t\tthis.dracoLoader = dracoLoader;\n\t\t\t}\n\n\t\t\tGLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function (primitive, parser) {\n\n\t\t\t\t\t\tvar json = this.json;\n\t\t\t\t\t\tvar dracoLoader = this.dracoLoader;\n\t\t\t\t\t\tvar bufferViewIndex = primitive.extensions[this.name].bufferView;\n\t\t\t\t\t\tvar gltfAttributeMap = primitive.extensions[this.name].attributes;\n\t\t\t\t\t\tvar threeAttributeMap = {};\n\t\t\t\t\t\tvar attributeNormalizedMap = {};\n\t\t\t\t\t\tvar attributeTypeMap = {};\n\n\t\t\t\t\t\tfor (var attributeName in gltfAttributeMap) {\n\n\t\t\t\t\t\t\t\t\tif (!(attributeName in ATTRIBUTES)) continue;\n\n\t\t\t\t\t\t\t\t\tthreeAttributeMap[ATTRIBUTES[attributeName]] = gltfAttributeMap[attributeName];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (attributeName in primitive.attributes) {\n\n\t\t\t\t\t\t\t\t\tif (ATTRIBUTES[attributeName] !== undefined && gltfAttributeMap[attributeName] !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar accessorDef = json.accessors[primitive.attributes[attributeName]];\n\t\t\t\t\t\t\t\t\t\t\t\tvar componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];\n\n\t\t\t\t\t\t\t\t\t\t\t\tattributeTypeMap[ATTRIBUTES[attributeName]] = componentType;\n\t\t\t\t\t\t\t\t\t\t\t\tattributeNormalizedMap[ATTRIBUTES[attributeName]] = accessorDef.normalized === true;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn parser.getDependency('bufferView', bufferViewIndex).then(function (bufferView) {\n\n\t\t\t\t\t\t\t\t\treturn new Promise(function (resolve) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tdracoLoader.decodeDracoFile(bufferView, function (geometry) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfor (var attributeName in geometry.attributes) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar attribute = geometry.attributes[attributeName];\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar normalized = attributeNormalizedMap[attributeName];\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (normalized !== undefined) attribute.normalized = normalized;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tresolve(geometry);\n\t\t\t\t\t\t\t\t\t\t\t\t}, threeAttributeMap, attributeTypeMap);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t};\n\n\t\t\t/**\r\n * Specular-Glossiness Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness\r\n */\n\t\t\tfunction GLTFMaterialsPbrSpecularGlossinessExtension() {\n\n\t\t\t\t\t\treturn {\n\n\t\t\t\t\t\t\t\t\tname: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,\n\n\t\t\t\t\t\t\t\t\tspecularGlossinessParams: ['color', 'map', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveIntensity', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'displacementMap', 'displacementScale', 'displacementBias', 'specularMap', 'specular', 'glossinessMap', 'glossiness', 'alphaMap', 'envMap', 'envMapIntensity', 'refractionRatio'],\n\n\t\t\t\t\t\t\t\t\tgetMaterialType: function getMaterialType() {\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn THREE.ShaderMaterial;\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\textendParams: function extendParams(params, material, parser) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar pbrSpecularGlossiness = material.extensions[this.name];\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar shader = THREE.ShaderLib['standard'];\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar uniforms = THREE.UniformsUtils.clone(shader.uniforms);\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar specularMapParsFragmentChunk = ['#ifdef USE_SPECULARMAP', '\tuniform sampler2D specularMap;', '#endif'].join('\\n');\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar glossinessMapParsFragmentChunk = ['#ifdef USE_GLOSSINESSMAP', '\tuniform sampler2D glossinessMap;', '#endif'].join('\\n');\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar specularMapFragmentChunk = ['vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', '\tvec4 texelSpecular = texture2D( specularMap, vUv );', '\ttexelSpecular = sRGBToLinear( texelSpecular );', '\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', '\tspecularFactor *= texelSpecular.rgb;', '#endif'].join('\\n');\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar glossinessMapFragmentChunk = ['float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', '\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );', '\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', '\tglossinessFactor *= texelGlossiness.a;', '#endif'].join('\\n');\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar lightPhysicalFragmentChunk = ['PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb;', 'material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );', 'material.specularColor = specularFactor.rgb;'].join('\\n');\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar fragmentShader = shader.fragmentShader.replace('uniform float roughness;', 'uniform vec3 specular;').replace('uniform float metalness;', 'uniform float glossiness;').replace('#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk).replace('#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk).replace('#include <roughnessmap_fragment>', specularMapFragmentChunk).replace('#include <metalnessmap_fragment>', glossinessMapFragmentChunk).replace('#include <lights_physical_fragment>', lightPhysicalFragmentChunk);\n\n\t\t\t\t\t\t\t\t\t\t\t\tdelete uniforms.roughness;\n\t\t\t\t\t\t\t\t\t\t\t\tdelete uniforms.metalness;\n\t\t\t\t\t\t\t\t\t\t\t\tdelete uniforms.roughnessMap;\n\t\t\t\t\t\t\t\t\t\t\t\tdelete uniforms.metalnessMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.specular = { value: new THREE.Color().setHex(0x111111) };\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.glossiness = { value: 0.5 };\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.specularMap = { value: null };\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.glossinessMap = { value: null };\n\n\t\t\t\t\t\t\t\t\t\t\t\tparams.vertexShader = shader.vertexShader;\n\t\t\t\t\t\t\t\t\t\t\t\tparams.fragmentShader = fragmentShader;\n\t\t\t\t\t\t\t\t\t\t\t\tparams.uniforms = uniforms;\n\t\t\t\t\t\t\t\t\t\t\t\tparams.defines = { 'STANDARD': '' };\n\n\t\t\t\t\t\t\t\t\t\t\t\tparams.color = new THREE.Color(1.0, 1.0, 1.0);\n\t\t\t\t\t\t\t\t\t\t\t\tparams.opacity = 1.0;\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar pending = [];\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar array = pbrSpecularGlossiness.diffuseFactor;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams.color.fromArray(array);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams.opacity = array[3];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (pbrSpecularGlossiness.diffuseTexture !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpending.push(parser.assignTexture(params, 'map', pbrSpecularGlossiness.diffuseTexture.index));\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tparams.emissive = new THREE.Color(0.0, 0.0, 0.0);\n\t\t\t\t\t\t\t\t\t\t\t\tparams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;\n\t\t\t\t\t\t\t\t\t\t\t\tparams.specular = new THREE.Color(1.0, 1.0, 1.0);\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (Array.isArray(pbrSpecularGlossiness.specularFactor)) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams.specular.fromArray(pbrSpecularGlossiness.specularFactor);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (pbrSpecularGlossiness.specularGlossinessTexture !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar specGlossIndex = pbrSpecularGlossiness.specularGlossinessTexture.index;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpending.push(parser.assignTexture(params, 'glossinessMap', specGlossIndex));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpending.push(parser.assignTexture(params, 'specularMap', specGlossIndex));\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn Promise.all(pending);\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\tcreateMaterial: function createMaterial(params) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t// setup material properties based on MeshStandardMaterial for Specular-Glossiness\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar material = new THREE.ShaderMaterial({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefines: params.defines,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvertexShader: params.vertexShader,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfragmentShader: params.fragmentShader,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuniforms: params.uniforms,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfog: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlights: true,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\topacity: params.opacity,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttransparent: params.transparent\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.isGLTFSpecularGlossinessMaterial = true;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.color = params.color;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.map = params.map === undefined ? null : params.map;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.lightMap = null;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.lightMapIntensity = 1.0;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.aoMap = params.aoMap === undefined ? null : params.aoMap;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.aoMapIntensity = 1.0;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.emissive = params.emissive;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.emissiveIntensity = 1.0;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.emissiveMap = params.emissiveMap === undefined ? null : params.emissiveMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.bumpMap = params.bumpMap === undefined ? null : params.bumpMap;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.bumpScale = 1;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.normalMap = params.normalMap === undefined ? null : params.normalMap;\n\t\t\t\t\t\t\t\t\t\t\t\tif (params.normalScale) material.normalScale = params.normalScale;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.displacementMap = null;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.displacementScale = 1;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.displacementBias = 0;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.specularMap = params.specularMap === undefined ? null : params.specularMap;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.specular = params.specular;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.glossinessMap = params.glossinessMap === undefined ? null : params.glossinessMap;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.glossiness = params.glossiness;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.alphaMap = null;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.envMap = params.envMap === undefined ? null : params.envMap;\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.envMapIntensity = 1.0;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.refractionRatio = 0.98;\n\n\t\t\t\t\t\t\t\t\t\t\t\tmaterial.extensions.derivatives = true;\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn material;\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\t/**\r\n * Clones a GLTFSpecularGlossinessMaterial instance. The ShaderMaterial.copy() method can\r\n * copy only properties it knows about or inherits, and misses many properties that would\r\n * normally be defined by MeshStandardMaterial.\r\n *\r\n * This method allows GLTFSpecularGlossinessMaterials to be cloned in the process of\r\n * loading a glTF model, but cloning later (e.g. by the user) would require these changes\r\n * AND also updating `.onBeforeRender` on the parent mesh.\r\n *\r\n * @param {THREE.ShaderMaterial} source\r\n * @return {THREE.ShaderMaterial}\r\n */\n\t\t\t\t\t\t\t\t\tcloneMaterial: function cloneMaterial(source) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar target = source.clone();\n\n\t\t\t\t\t\t\t\t\t\t\t\ttarget.isGLTFSpecularGlossinessMaterial = true;\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar params = this.specularGlossinessParams;\n\n\t\t\t\t\t\t\t\t\t\t\t\tfor (var i = 0, il = params.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttarget[params[i]] = source[params[i]];\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\treturn target;\n\t\t\t\t\t\t\t\t\t},\n\n\t\t\t\t\t\t\t\t\t// Here's based on refreshUniformsCommon() and refreshUniformsStandard() in WebGLRenderer.\n\t\t\t\t\t\t\t\t\trefreshUniforms: function refreshUniforms(renderer, scene, camera, geometry, material, group) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (material.isGLTFSpecularGlossinessMaterial !== true) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar uniforms = material.uniforms;\n\t\t\t\t\t\t\t\t\t\t\t\tvar defines = material.defines;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity);\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.map.value = material.map;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.specularMap.value = material.specularMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t\t\t\t\t\t\t\t\t\t\t// uv repeat and offset setting priorities\n\t\t\t\t\t\t\t\t\t\t\t\t// 1. color map\n\t\t\t\t\t\t\t\t\t\t\t\t// 2. specular map\n\t\t\t\t\t\t\t\t\t\t\t\t// 3. normal map\n\t\t\t\t\t\t\t\t\t\t\t\t// 4. bump map\n\t\t\t\t\t\t\t\t\t\t\t\t// 5. alpha map\n\t\t\t\t\t\t\t\t\t\t\t\t// 6. emissive map\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar uvScaleMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (material.map) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.map;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.specularMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.specularMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.displacementMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.displacementMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.normalMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.normalMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.bumpMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.bumpMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.glossinessMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.glossinessMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.alphaMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.alphaMap;\n\t\t\t\t\t\t\t\t\t\t\t\t} else if (material.emissiveMap) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = material.emissiveMap;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (uvScaleMap !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// backwards compatibility\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (uvScaleMap.isWebGLRenderTarget) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.envMap.value = material.envMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.flipEnvMap.value = material.envMap && material.envMap.isCubeTexture ? -1 : 1;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.specular.value.copy(material.specular);\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.glossiness.value = material.glossiness;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.glossinessMap.value = material.glossinessMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\t\t\t\t\t\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (uniforms.glossinessMap.value !== null && defines.USE_GLOSSINESSMAP === undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefines.USE_GLOSSINESSMAP = '';\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// set USE_ROUGHNESSMAP to enable vUv\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefines.USE_ROUGHNESSMAP = '';\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (uniforms.glossinessMap.value === null && defines.USE_GLOSSINESSMAP !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelete defines.USE_GLOSSINESSMAP;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdelete defines.USE_ROUGHNESSMAP;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t};\n\t\t\t}\n\n\t\t\t/*********************************/\n\t\t\t/********** INTERPOLATION ********/\n\t\t\t/*********************************/\n\n\t\t\t// Spline Interpolation\n\t\t\t// Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation\n\t\t\tfunction GLTFCubicSplineInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\n\t\t\t\t\t\tTHREE.Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t\t\t}\n\n\t\t\tGLTFCubicSplineInterpolant.prototype = Object.create(THREE.Interpolant.prototype);\n\t\t\tGLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;\n\n\t\t\tGLTFCubicSplineInterpolant.prototype.interpolate_ = function (i1, t0, t, t1) {\n\n\t\t\t\t\t\tvar result = this.resultBuffer;\n\t\t\t\t\t\tvar values = this.sampleValues;\n\t\t\t\t\t\tvar stride = this.valueSize;\n\n\t\t\t\t\t\tvar stride2 = stride * 2;\n\t\t\t\t\t\tvar stride3 = stride * 3;\n\n\t\t\t\t\t\tvar td = t1 - t0;\n\n\t\t\t\t\t\tvar p = (t - t0) / td;\n\t\t\t\t\t\tvar pp = p * p;\n\t\t\t\t\t\tvar ppp = pp * p;\n\n\t\t\t\t\t\tvar offset1 = i1 * stride3;\n\t\t\t\t\t\tvar offset0 = offset1 - stride3;\n\n\t\t\t\t\t\tvar s0 = 2 * ppp - 3 * pp + 1;\n\t\t\t\t\t\tvar s1 = ppp - 2 * pp + p;\n\t\t\t\t\t\tvar s2 = -2 * ppp + 3 * pp;\n\t\t\t\t\t\tvar s3 = ppp - pp;\n\n\t\t\t\t\t\t// Layout of keyframe output values for CUBICSPLINE animations:\n\t\t\t\t\t\t// [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]\n\t\t\t\t\t\tfor (var i = 0; i !== stride; i++) {\n\n\t\t\t\t\t\t\t\t\tvar p0 = values[offset0 + i + stride]; // splineVertex_k\n\t\t\t\t\t\t\t\t\tvar m0 = values[offset0 + i + stride2] * td; // outTangent_k * (t_k+1 - t_k)\n\t\t\t\t\t\t\t\t\tvar p1 = values[offset1 + i + stride]; // splineVertex_k+1\n\t\t\t\t\t\t\t\t\tvar m1 = values[offset1 + i] * td; // inTangent_k+1 * (t_k+1 - t_k)\n\n\t\t\t\t\t\t\t\t\tresult[i] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn result;\n\t\t\t};\n\n\t\t\t/*********************************/\n\t\t\t/********** INTERNALS ************/\n\t\t\t/*********************************/\n\n\t\t\t/* CONSTANTS */\n\n\t\t\tvar WEBGL_CONSTANTS = {\n\t\t\t\t\t\tFLOAT: 5126,\n\t\t\t\t\t\t//FLOAT_MAT2: 35674,\n\t\t\t\t\t\tFLOAT_MAT3: 35675,\n\t\t\t\t\t\tFLOAT_MAT4: 35676,\n\t\t\t\t\t\tFLOAT_VEC2: 35664,\n\t\t\t\t\t\tFLOAT_VEC3: 35665,\n\t\t\t\t\t\tFLOAT_VEC4: 35666,\n\t\t\t\t\t\tLINEAR: 9729,\n\t\t\t\t\t\tREPEAT: 10497,\n\t\t\t\t\t\tSAMPLER_2D: 35678,\n\t\t\t\t\t\tPOINTS: 0,\n\t\t\t\t\t\tLINES: 1,\n\t\t\t\t\t\tLINE_LOOP: 2,\n\t\t\t\t\t\tLINE_STRIP: 3,\n\t\t\t\t\t\tTRIANGLES: 4,\n\t\t\t\t\t\tTRIANGLE_STRIP: 5,\n\t\t\t\t\t\tTRIANGLE_FAN: 6,\n\t\t\t\t\t\tUNSIGNED_BYTE: 5121,\n\t\t\t\t\t\tUNSIGNED_SHORT: 5123\n\t\t\t};\n\n\t\t\tvar WEBGL_TYPE = {\n\t\t\t\t\t\t5126: Number,\n\t\t\t\t\t\t//35674: THREE.Matrix2,\n\t\t\t\t\t\t35675: THREE.Matrix3,\n\t\t\t\t\t\t35676: THREE.Matrix4,\n\t\t\t\t\t\t35664: THREE.Vector2,\n\t\t\t\t\t\t35665: THREE.Vector3,\n\t\t\t\t\t\t35666: THREE.Vector4,\n\t\t\t\t\t\t35678: THREE.Texture\n\t\t\t};\n\n\t\t\tvar WEBGL_COMPONENT_TYPES = {\n\t\t\t\t\t\t5120: Int8Array,\n\t\t\t\t\t\t5121: Uint8Array,\n\t\t\t\t\t\t5122: Int16Array,\n\t\t\t\t\t\t5123: Uint16Array,\n\t\t\t\t\t\t5125: Uint32Array,\n\t\t\t\t\t\t5126: Float32Array\n\t\t\t};\n\n\t\t\tvar WEBGL_FILTERS = {\n\t\t\t\t\t\t9728: THREE.NearestFilter,\n\t\t\t\t\t\t9729: THREE.LinearFilter,\n\t\t\t\t\t\t9984: THREE.NearestMipMapNearestFilter,\n\t\t\t\t\t\t9985: THREE.LinearMipMapNearestFilter,\n\t\t\t\t\t\t9986: THREE.NearestMipMapLinearFilter,\n\t\t\t\t\t\t9987: THREE.LinearMipMapLinearFilter\n\t\t\t};\n\n\t\t\tvar WEBGL_WRAPPINGS = {\n\t\t\t\t\t\t33071: THREE.ClampToEdgeWrapping,\n\t\t\t\t\t\t33648: THREE.MirroredRepeatWrapping,\n\t\t\t\t\t\t10497: THREE.RepeatWrapping\n\t\t\t};\n\n\t\t\tvar WEBGL_TEXTURE_FORMATS = {\n\t\t\t\t\t\t6406: THREE.AlphaFormat,\n\t\t\t\t\t\t6407: THREE.RGBFormat,\n\t\t\t\t\t\t6408: THREE.RGBAFormat,\n\t\t\t\t\t\t6409: THREE.LuminanceFormat,\n\t\t\t\t\t\t6410: THREE.LuminanceAlphaFormat\n\t\t\t};\n\n\t\t\tvar WEBGL_TEXTURE_DATATYPES = {\n\t\t\t\t\t\t5121: THREE.UnsignedByteType,\n\t\t\t\t\t\t32819: THREE.UnsignedShort4444Type,\n\t\t\t\t\t\t32820: THREE.UnsignedShort5551Type,\n\t\t\t\t\t\t33635: THREE.UnsignedShort565Type\n\t\t\t};\n\n\t\t\tvar WEBGL_SIDES = {\n\t\t\t\t\t\t1028: THREE.BackSide, // Culling front\n\t\t\t\t\t\t1029: THREE.FrontSide // Culling back\n\t\t\t\t\t\t//1032: THREE.NoSide // Culling front and back, what to do?\n\t\t\t};\n\n\t\t\tvar WEBGL_DEPTH_FUNCS = {\n\t\t\t\t\t\t512: THREE.NeverDepth,\n\t\t\t\t\t\t513: THREE.LessDepth,\n\t\t\t\t\t\t514: THREE.EqualDepth,\n\t\t\t\t\t\t515: THREE.LessEqualDepth,\n\t\t\t\t\t\t516: THREE.GreaterEqualDepth,\n\t\t\t\t\t\t517: THREE.NotEqualDepth,\n\t\t\t\t\t\t518: THREE.GreaterEqualDepth,\n\t\t\t\t\t\t519: THREE.AlwaysDepth\n\t\t\t};\n\n\t\t\tvar WEBGL_BLEND_EQUATIONS = {\n\t\t\t\t\t\t32774: THREE.AddEquation,\n\t\t\t\t\t\t32778: THREE.SubtractEquation,\n\t\t\t\t\t\t32779: THREE.ReverseSubtractEquation\n\t\t\t};\n\n\t\t\tvar WEBGL_BLEND_FUNCS = {\n\t\t\t\t\t\t0: THREE.ZeroFactor,\n\t\t\t\t\t\t1: THREE.OneFactor,\n\t\t\t\t\t\t768: THREE.SrcColorFactor,\n\t\t\t\t\t\t769: THREE.OneMinusSrcColorFactor,\n\t\t\t\t\t\t770: THREE.SrcAlphaFactor,\n\t\t\t\t\t\t771: THREE.OneMinusSrcAlphaFactor,\n\t\t\t\t\t\t772: THREE.DstAlphaFactor,\n\t\t\t\t\t\t773: THREE.OneMinusDstAlphaFactor,\n\t\t\t\t\t\t774: THREE.DstColorFactor,\n\t\t\t\t\t\t775: THREE.OneMinusDstColorFactor,\n\t\t\t\t\t\t776: THREE.SrcAlphaSaturateFactor\n\t\t\t\t\t\t// The followings are not supported by Three.js yet\n\t\t\t\t\t\t//32769: CONSTANT_COLOR,\n\t\t\t\t\t\t//32770: ONE_MINUS_CONSTANT_COLOR,\n\t\t\t\t\t\t//32771: CONSTANT_ALPHA,\n\t\t\t\t\t\t//32772: ONE_MINUS_CONSTANT_COLOR\n\t\t\t};\n\n\t\t\tvar WEBGL_TYPE_SIZES = {\n\t\t\t\t\t\t'SCALAR': 1,\n\t\t\t\t\t\t'VEC2': 2,\n\t\t\t\t\t\t'VEC3': 3,\n\t\t\t\t\t\t'VEC4': 4,\n\t\t\t\t\t\t'MAT2': 4,\n\t\t\t\t\t\t'MAT3': 9,\n\t\t\t\t\t\t'MAT4': 16\n\t\t\t};\n\n\t\t\tvar ATTRIBUTES = {\n\t\t\t\t\t\tPOSITION: 'position',\n\t\t\t\t\t\tNORMAL: 'normal',\n\t\t\t\t\t\tTEXCOORD_0: 'uv',\n\t\t\t\t\t\tTEXCOORD0: 'uv', // deprecated\n\t\t\t\t\t\tTEXCOORD: 'uv', // deprecated\n\t\t\t\t\t\tTEXCOORD_1: 'uv2',\n\t\t\t\t\t\tCOLOR_0: 'color',\n\t\t\t\t\t\tCOLOR0: 'color', // deprecated\n\t\t\t\t\t\tCOLOR: 'color', // deprecated\n\t\t\t\t\t\tWEIGHTS_0: 'skinWeight',\n\t\t\t\t\t\tWEIGHT: 'skinWeight', // deprecated\n\t\t\t\t\t\tJOINTS_0: 'skinIndex',\n\t\t\t\t\t\tJOINT: 'skinIndex' // deprecated\n\t\t\t};\n\n\t\t\tvar PATH_PROPERTIES = {\n\t\t\t\t\t\tscale: 'scale',\n\t\t\t\t\t\ttranslation: 'position',\n\t\t\t\t\t\trotation: 'quaternion',\n\t\t\t\t\t\tweights: 'morphTargetInfluences'\n\t\t\t};\n\n\t\t\tvar INTERPOLATION = {\n\t\t\t\t\t\tCUBICSPLINE: THREE.InterpolateSmooth, // We use custom interpolation GLTFCubicSplineInterpolation for CUBICSPLINE.\n\t\t\t\t\t\t// KeyframeTrack.optimize() can't handle glTF Cubic Spline output values layout,\n\t\t\t\t\t\t// using THREE.InterpolateSmooth for KeyframeTrack instantiation to prevent optimization.\n\t\t\t\t\t\t// See KeyframeTrack.optimize() for the detail.\n\t\t\t\t\t\tLINEAR: THREE.InterpolateLinear,\n\t\t\t\t\t\tSTEP: THREE.InterpolateDiscrete\n\t\t\t};\n\n\t\t\tvar STATES_ENABLES = {\n\t\t\t\t\t\t2884: 'CULL_FACE',\n\t\t\t\t\t\t2929: 'DEPTH_TEST',\n\t\t\t\t\t\t3042: 'BLEND',\n\t\t\t\t\t\t3089: 'SCISSOR_TEST',\n\t\t\t\t\t\t32823: 'POLYGON_OFFSET_FILL',\n\t\t\t\t\t\t32926: 'SAMPLE_ALPHA_TO_COVERAGE'\n\t\t\t};\n\n\t\t\tvar ALPHA_MODES = {\n\t\t\t\t\t\tOPAQUE: 'OPAQUE',\n\t\t\t\t\t\tMASK: 'MASK',\n\t\t\t\t\t\tBLEND: 'BLEND'\n\t\t\t};\n\n\t\t\t/* UTILITY FUNCTIONS */\n\n\t\t\tfunction resolveURL(url, path) {\n\n\t\t\t\t\t\t// Invalid URL\n\t\t\t\t\t\tif (typeof url !== 'string' || url === '') return '';\n\n\t\t\t\t\t\t// Absolute URL http://,https://,//\n\t\t\t\t\t\tif (/^(https?:)?\\/\\//i.test(url)) return url;\n\n\t\t\t\t\t\t// Data URI\n\t\t\t\t\t\tif (/^data:.*,.*$/i.test(url)) return url;\n\n\t\t\t\t\t\t// Blob URL\n\t\t\t\t\t\tif (/^blob:.*$/i.test(url)) return url;\n\n\t\t\t\t\t\t// Relative URL\n\t\t\t\t\t\treturn path + url;\n\t\t\t}\n\n\t\t\t/**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material\r\n */\n\t\t\tfunction createDefaultMaterial() {\n\n\t\t\t\t\t\treturn new THREE.MeshStandardMaterial({\n\t\t\t\t\t\t\t\t\tcolor: 0xFFFFFF,\n\t\t\t\t\t\t\t\t\temissive: 0x000000,\n\t\t\t\t\t\t\t\t\tmetalness: 1,\n\t\t\t\t\t\t\t\t\troughness: 1,\n\t\t\t\t\t\t\t\t\ttransparent: false,\n\t\t\t\t\t\t\t\t\tdepthTest: true,\n\t\t\t\t\t\t\t\t\tside: THREE.FrontSide\n\t\t\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {\n\n\t\t\t\t\t\t// Add unknown glTF extensions to an object's userData.\n\n\t\t\t\t\t\tfor (var name in objectDef.extensions) {\n\n\t\t\t\t\t\t\t\t\tif (knownExtensions[name] === undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tobject.userData.gltfExtensions = object.userData.gltfExtensions || {};\n\t\t\t\t\t\t\t\t\t\t\t\tobject.userData.gltfExtensions[name] = objectDef.extensions[name];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets\r\n *\r\n * @param {THREE.BufferGeometry} geometry\r\n * @param {Array<GLTF.Target>} targets\r\n * @param {Array<THREE.BufferAttribute>} accessors\r\n */\n\t\t\tfunction addMorphTargets(geometry, targets, accessors) {\n\n\t\t\t\t\t\tvar hasMorphPosition = false;\n\t\t\t\t\t\tvar hasMorphNormal = false;\n\n\t\t\t\t\t\tfor (var i = 0, il = targets.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tvar target = targets[i];\n\n\t\t\t\t\t\t\t\t\tif (target.POSITION !== undefined) hasMorphPosition = true;\n\t\t\t\t\t\t\t\t\tif (target.NORMAL !== undefined) hasMorphNormal = true;\n\n\t\t\t\t\t\t\t\t\tif (hasMorphPosition && hasMorphNormal) break;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!hasMorphPosition && !hasMorphNormal) return;\n\n\t\t\t\t\t\tvar morphPositions = [];\n\t\t\t\t\t\tvar morphNormals = [];\n\n\t\t\t\t\t\tfor (var i = 0, il = targets.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tvar target = targets[i];\n\t\t\t\t\t\t\t\t\tvar attributeName = 'morphTarget' + i;\n\n\t\t\t\t\t\t\t\t\tif (hasMorphPosition) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t// Three.js morph position is absolute value. The formula is\n\t\t\t\t\t\t\t\t\t\t\t\t// basePosition\n\t\t\t\t\t\t\t\t\t\t\t\t// + weight0 * ( morphPosition0 - basePosition )\n\t\t\t\t\t\t\t\t\t\t\t\t// + weight1 * ( morphPosition1 - basePosition )\n\t\t\t\t\t\t\t\t\t\t\t\t// ...\n\t\t\t\t\t\t\t\t\t\t\t\t// while the glTF one is relative\n\t\t\t\t\t\t\t\t\t\t\t\t// basePosition\n\t\t\t\t\t\t\t\t\t\t\t\t// + weight0 * glTFmorphPosition0\n\t\t\t\t\t\t\t\t\t\t\t\t// + weight1 * glTFmorphPosition1\n\t\t\t\t\t\t\t\t\t\t\t\t// ...\n\t\t\t\t\t\t\t\t\t\t\t\t// then we need to convert from relative to absolute here.\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (target.POSITION !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t// Cloning not to pollute original accessor\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar positionAttribute = cloneBufferAttribute(accessors[target.POSITION]);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpositionAttribute.name = attributeName;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar position = geometry.attributes.position;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfor (var j = 0, jl = positionAttribute.count; j < jl; j++) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpositionAttribute.setXYZ(j, positionAttribute.getX(j) + position.getX(j), positionAttribute.getY(j) + position.getY(j), positionAttribute.getZ(j) + position.getZ(j));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpositionAttribute = geometry.attributes.position;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tmorphPositions.push(positionAttribute);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (hasMorphNormal) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t// see target.POSITION's comment\n\n\t\t\t\t\t\t\t\t\t\t\t\tvar normalAttribute;\n\n\t\t\t\t\t\t\t\t\t\t\t\tif (target.NORMAL !== undefined) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar normalAttribute = cloneBufferAttribute(accessors[target.NORMAL]);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnormalAttribute.name = attributeName;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvar normal = geometry.attributes.normal;\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfor (var j = 0, jl = normalAttribute.count; j < jl; j++) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnormalAttribute.setXYZ(j, normalAttribute.getX(j) + normal.getX(j), normalAttribute.getY(j) + normal.getY(j), normalAttribute.getZ(j) + normal.getZ(j));\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnormalAttribute = geometry.attributes.normal;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t\tmorphNormals.push(normalAttribute);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hasMorphPosition) geometry.morphAttributes.position = morphPositions;\n\t\t\t\t\t\tif (hasMorphNormal) geometry.morphAttributes.normal = morphNormals;\n\t\t\t}\n\n\t\t\t/**\r\n * @param {THREE.Mesh} mesh\r\n * @param {GLTF.Mesh} meshDef\r\n */\n\t\t\tfunction updateMorphTargets(mesh, meshDef) {\n\n\t\t\t\t\t\tmesh.updateMorphTargets();\n\n\t\t\t\t\t\tif (meshDef.weights !== undefined) {\n\n\t\t\t\t\t\t\t\t\tfor (var i = 0, il = meshDef.weights.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tmesh.morphTargetInfluences[i] = meshDef.weights[i];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// .extras has user-defined data, so check that .extras.targetNames is an array.\n\t\t\t\t\t\tif (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {\n\n\t\t\t\t\t\t\t\t\tvar targetNames = meshDef.extras.targetNames;\n\n\t\t\t\t\t\t\t\t\tif (mesh.morphTargetInfluences.length === targetNames.length) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tmesh.morphTargetDictionary = {};\n\n\t\t\t\t\t\t\t\t\t\t\t\tfor (var i = 0, il = targetNames.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tmesh.morphTargetDictionary[targetNames[i]] = i;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.warn('THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.');\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction isPrimitiveEqual(a, b) {\n\n\t\t\t\t\t\tif (a.indices !== b.indices) {\n\n\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn isObjectEqual(a.attributes, b.attributes);\n\t\t\t}\n\n\t\t\tfunction isObjectEqual(a, b) {\n\n\t\t\t\t\t\tif (Object.keys(a).length !== Object.keys(b).length) return false;\n\n\t\t\t\t\t\tfor (var key in a) {\n\n\t\t\t\t\t\t\t\t\tif (a[key] !== b[key]) return false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction isArrayEqual(a, b) {\n\n\t\t\t\t\t\tif (a.length !== b.length) return false;\n\n\t\t\t\t\t\tfor (var i = 0, il = a.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tif (a[i] !== b[i]) return false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tfunction getCachedGeometry(cache, newPrimitive) {\n\n\t\t\t\t\t\tfor (var i = 0, il = cache.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tvar cached = cache[i];\n\n\t\t\t\t\t\t\t\t\tif (isPrimitiveEqual(cached.primitive, newPrimitive)) return cached.promise;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tfunction getCachedCombinedGeometry(cache, geometries) {\n\n\t\t\t\t\t\tfor (var i = 0, il = cache.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tvar cached = cache[i];\n\n\t\t\t\t\t\t\t\t\tif (isArrayEqual(geometries, cached.baseGeometries)) return cached.geometry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tfunction getCachedMultiPassGeometry(cache, geometry, primitives) {\n\n\t\t\t\t\t\tfor (var i = 0, il = cache.length; i < il; i++) {\n\n\t\t\t\t\t\t\t\t\tvar cached = cache[i];\n\n\t\t\t\t\t\t\t\t\tif (geometry === cached.baseGeometry && isArrayEqual(primitives, cached.primitives)) return cached.geometry;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tfunction cloneBufferAttribute(attribute) {\n\n\t\t\t\t\t\tif (attribute.isInterleavedBufferAttribute) {\n\n\t\t\t\t\t\t\t\t\tvar count = attribute.count;\n\t\t\t\t\t\t\t\t\tvar itemSize = attribute.itemSize;\n\t\t\t\t\t\t\t\t\tvar array = attribute.array.slice(0, count * itemSize);\n\n\t\t\t\t\t\t\t\t\tfor (var i = 0; i < count; ++i) {\n\n\t\t\t\t\t\t\t\t\t\t\t\tarray[i] = attribute.getX(i);\n\t\t\t\t\t\t\t\t\t\t\t\tif (itemSize >= 2) array[i + 1] = attribute.getY(i);\n\t\t\t\t\t\t\t\t\t\t\t\tif (itemSize >= 3) array[i + 2] = attribute.getZ(i);\n\t\t\t\t\t\t\t\t\t\t\t\tif (itemSize >= 4) array[i + 3] = attribute.getW(i);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\treturn new THREE.BufferAttribute(array, itemSize, attribute.normalized);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn attribute.clone();\n\t\t\t}\n\n\t\t\t/**\r\n * Checks if we can build a single Mesh with MultiMaterial from multiple primitives.\r\n * Returns true if all primitives use the same attributes/morphAttributes/mode\r\n * and also have index. Otherwise returns false.\r\n *\r\n * @param {Array<GLTF.Primitive>} primitives\r\n * @return {Boolean}\r\n */\n\t\t\tfunction isMultiPassGeometry(primitives) {\n\n\t\t\t\t\t\tif (primitives.length < 2) return false;\n\n\t\t\t\t\t\tvar primitive0 = primitives[0];\n\t\t\t\t\t\tvar targets0 = primitive0.targets || [];\n\n\t\t\t\t\t\tif (primitive0.indices === undefined) return false;\n\n\t\t\t\t\t\tfo