ThreeJS-Webpack-ES6-Boilerp.../build/js/main.bundle.js.map

1 line
290 KiB
Plaintext

{"version":3,"sources":["webpack://threejs-es6-webpack-boilerplate/./src/js/data/config.js","webpack://threejs-es6-webpack-boilerplate/./src/js/utils/detector.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/renderer.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/camera.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/light.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/controls.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/material.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/helpers/stats.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/components/geometry.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/helpers/vertexNormalsHelper.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/helpers/meshHelper.js","webpack://threejs-es6-webpack-boilerplate/./src/js/utils/helpers.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/model/texture.js","webpack://threejs-es6-webpack-boilerplate/./src/js/utils/bufferGeometryUtils.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/loaders/GLTFLoader.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/model/model.js","webpack://threejs-es6-webpack-boilerplate/./src/js/utils/keyboard.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/managers/interaction.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/managers/datGUI.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app/main.js","webpack://threejs-es6-webpack-boilerplate/./src/js/app.js","webpack://threejs-es6-webpack-boilerplate/./src/js/utils/orbitControls.js"],"names":["isDev","isShowingStats","isLoaded","isTweening","isRotating","isMouseMoving","isMouseOver","maxAnisotropy","dpr","easing","TWEEN","duration","model","selected","initialTypes","type","models","path","scale","texture","imageFiles","name","image","mesh","enableHelper","wireframe","translucent","material","color","emissive","fog","near","camera","fov","far","aspect","posX","posY","posZ","controls","autoRotate","autoRotateSpeed","rotateSpeed","zoomSpeed","minDistance","maxDistance","minPolarAngle","Math","PI","maxPolarAngle","minAzimuthAngle","Infinity","maxAzimuthAngle","enableDamping","dampingFactor","enableZoom","target","x","y","z","ambientLight","enabled","directionalLight","intensity","shadow","helperEnabled","bias","mapWidth","mapHeight","top","right","bottom","left","pointLight","distance","hemiLight","groundColor","canvas","window","CanvasRenderingContext2D","webgl","document","createElement","WebGLRenderingContext","getContext","e","workers","Worker","fileapi","File","FileReader","FileList","Blob","getWebGLErrorMessage","element","id","style","fontFamily","fontSize","fontWeight","textAlign","background","padding","width","margin","this","innerHTML","join","addGetWebGLMessage","parameters","parent","undefined","body","appendChild","Renderer","scene","container","threeRenderer","THREE","antialias","setClearColor","setPixelRatio","devicePixelRatio","domElement","shadowMap","Config","capabilities","getMaxAnisotropy","updateSize","addEventListener","setSize","offsetWidth","offsetHeight","render","Camera","renderer","height","threeCamera","position","set","updateProjectionMatrix","Light","init","visible","castShadow","mapSize","directionalLightHelper","lightName","add","Controls","orbitControls","OrbitControls","threeControls","Material","basic","side","standard","shading","roughness","metalness","wire","rS","bS","glS","tS","Geometry","geo","widthSegments","heightSegments","radius","rotation","receiveShadow","Stats","start","tick","frame","end","update","BrowserStats","glStats","threeStats","rStats","CSSPath","userTimingAPI","values","caption","over","average","avgMs","fps","below","calls","raf","rstats","groups","fractions","base","steps","plugins","_v1","Vector3","_v2","_normalMatrix","Matrix3","_keys","VertexNormalsHelper","object","size","hex","nNormals","objGeometry","geometry","isGeometry","faces","length","isBufferGeometry","attributes","normal","count","BufferGeometry","positions","Float32BufferAttribute","setAttribute","LineSegments","LineBasicMaterial","toneMapped","matrixAutoUpdate","prototype","Object","create","constructor","idx","updateMatrixWorld","getNormalMatrix","matrixWorld","vertices","i","l","face","j","jl","vertexNormals","vertex","copy","applyMatrix4","applyMatrix3","normalize","multiplyScalar","setXYZ","objPos","objNorm","getX","getY","getZ","needsUpdate","MeshHelper","wireLine","depthTest","opacity","transparent","edges","edgesLine","vertexHelper","boxHelper","remove","Helpers","fn","threshhold","scope","last","deferTimer","context","now","Date","args","arguments","clearTimeout","setTimeout","apply","xhr","lengthComputable","percentComplete","loaded","total","console","log","round","error","value","replace","setHex","vertexColors","verticesNeedUpdate","normalsNeedUpdate","colorsNeedUpdate","materialKey","textures","key","Texture","loader","promiseArray","setPath","forEach","imageFile","push","Promise","resolve","reject","load","anisotropy","modelOBJ","logProgress","Error","then","keys","reason","BufferGeometryUtils","index","uv","indices","array","normals","uvs","nVertices","tangent","BufferAttribute","Float32Array","tangents","tan1","tan2","vA","vB","vC","uvA","Vector2","uvB","uvC","sdir","tdir","il","group","handleTriangle","w","t","test","tmp","tmp2","n","n2","handleVertex","a","b","c","fromArray","sub","r","isFinite","addScaledVector","v","dot","crossVectors","GLTFLoader","manager","Loader","dracoLoader","ddsLoader","GLTFRegistry","objects","get","removeAll","assign","url","onLoad","onProgress","onError","resourcePath","LoaderUtils","itemStart","_onError","itemError","itemEnd","FileLoader","setResponseType","crossOrigin","setWithCredentials","data","parse","gltf","setDRACOLoader","setDDSLoader","content","extensions","Uint8Array","BINARY_EXTENSION_HEADER_MAGIC","EXTENSIONS","KHR_BINARY_GLTF","GLTFBinaryExtension","json","JSON","asset","version","extensionsUsed","extensionName","extensionsRequired","KHR_LIGHTS_PUNCTUAL","GLTFLightsExtension","KHR_MATERIALS_CLEARCOAT","GLTFMaterialsClearcoatExtension","KHR_MATERIALS_UNLIT","GLTFMaterialsUnlitExtension","KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS","GLTFMaterialsPbrSpecularGlossinessExtension","KHR_DRACO_MESH_COMPRESSION","GLTFDracoMeshCompressionExtension","MSFT_TEXTURE_DDS","GLTFTextureDDSExtension","KHR_TEXTURE_TRANSFORM","GLTFTextureTransformExtension","KHR_MESH_QUANTIZATION","GLTFMeshQuantizationExtension","indexOf","warn","GLTFParser","extension","lightDefs","lights","loadLight","lightIndex","lightNode","lightDef","Color","range","DirectionalLight","PointLight","SpotLight","spot","innerConeAngle","outerConeAngle","angle","penumbra","decay","getMaterialType","MeshBasicMaterial","extendParams","materialParams","materialDef","parser","pending","metallicRoughness","pbrMetallicRoughness","Array","isArray","baseColorFactor","baseColorTexture","assignTexture","all","MeshPhysicalMaterial","clearcoatFactor","clearcoat","clearcoatTexture","clearcoatRoughnessFactor","clearcoatRoughness","clearcoatRoughnessTexture","clearcoatNormalTexture","clearcoatNormalScale","BINARY_EXTENSION_CHUNK_TYPES","headerView","DataView","header","magic","slice","getUint32","chunkView","chunkIndex","byteLength","chunkLength","chunkType","contentArray","byteOffset","preload","GLTFMeshStandardSGMaterial","params","MeshStandardMaterial","isGLTFSpecularGlossinessMaterial","specularMapParsFragmentChunk","glossinessMapParsFragmentChunk","specularMapFragmentChunk","glossinessMapFragmentChunk","lightPhysicalFragmentChunk","uniforms","specular","glossiness","specularMap","glossinessMap","_extraUniforms","onBeforeCompile","shader","uniformName","fragmentShader","defineProperties","defines","USE_GLOSSINESSMAP","USE_ROUGHNESSMAP","metalnessMap","roughnessMap","setValues","specularGlossinessParams","pbrSpecularGlossiness","diffuseFactor","diffuseTexture","glossinessFactor","specularFactor","specularGlossinessTexture","specGlossMapDef","createMaterial","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","TangentSpaceNormalMap","normalScale","displacementMap","displacementScale","displacementBias","alphaMap","envMap","envMapIntensity","refractionRatio","GLTFCubicSplineInterpolant","parameterPositions","sampleValues","sampleSize","resultBuffer","Interpolant","decodePrimitive","primitive","bufferViewIndex","bufferView","gltfAttributeMap","threeAttributeMap","attributeNormalizedMap","attributeTypeMap","attributeName","threeAttributeName","ATTRIBUTES","toLowerCase","accessorDef","accessors","componentType","WEBGL_COMPONENT_TYPES","normalized","getDependency","decodeDracoFile","attribute","extendTexture","transform","clone","offset","repeat","texCoord","source","copySampleValue_","result","valueSize","beforeStart_","afterEnd_","interpolate_","i1","t0","t1","stride","stride2","stride3","td","p","pp","ppp","offset1","offset0","s2","s3","s0","s1","p0","m0","p1","m1","WEBGL_CONSTANTS","5120","Int8Array","5121","5122","Int16Array","5123","Uint16Array","5125","Uint32Array","5126","WEBGL_FILTERS","9728","NearestFilter","9729","LinearFilter","9984","NearestMipmapNearestFilter","9985","LinearMipmapNearestFilter","9986","NearestMipmapLinearFilter","9987","LinearMipmapLinearFilter","WEBGL_WRAPPINGS","33071","ClampToEdgeWrapping","33648","MirroredRepeatWrapping","10497","RepeatWrapping","WEBGL_TYPE_SIZES","SCALAR","VEC2","VEC3","VEC4","MAT2","MAT3","MAT4","POSITION","NORMAL","TANGENT","TEXCOORD_0","TEXCOORD_1","COLOR_0","WEIGHTS_0","JOINTS_0","PATH_PROPERTIES","translation","weights","INTERPOLATION","CUBICSPLINE","LINEAR","InterpolateLinear","STEP","InterpolateDiscrete","ALPHA_MODES","MIME_TYPE_FORMATS","RGBAFormat","RGBFormat","resolveURL","addUnknownExtensionsToUserData","knownExtensions","objectDef","userData","gltfExtensions","assignExtrasToUserData","gltfDef","extras","updateMorphTargets","meshDef","morphTargetInfluences","targetNames","morphTargetDictionary","createAttributesKey","attributesKey","sort","options","cache","primitiveCache","textureLoader","TextureLoader","setCrossOrigin","fileLoader","addPrimitiveAttributes","primitiveDef","assignAttributeAccessor","accessorIndex","accessor","gltfAttributeName","setIndex","box","Box3","min","max","targets","maxDisplacement","vector","setX","abs","setY","setZ","expandByVector","boundingBox","sphere","Sphere","getCenter","center","distanceTo","boundingSphere","computeBounds","hasMorphPosition","hasMorphNormal","pendingPositionAccessors","pendingNormalAccessors","pendingAccessor","morphPositions","morphNormals","morphAttributes","morphTargetsRelative","addMorphTargets","toTrianglesDrawMode","drawMode","getIndex","getAttribute","numberOfTriangles","newIndices","TriangleFanDrawMode","newGeometry","markDefs","getDependencies","dependencies","scenes","animations","cameras","nodeDefs","nodes","skinDefs","skins","meshDefs","meshes","meshReferences","meshUses","skinIndex","skinLength","joints","isBone","nodeIndex","nodeLength","nodeDef","skin","isSkinnedMesh","cacheKey","dependency","loadScene","loadNode","loadMesh","loadAccessor","loadBufferView","loadBuffer","loadMaterial","loadTexture","loadSkin","loadAnimation","loadCamera","defs","def","bufferIndex","bufferDef","buffers","uri","bufferViewDef","bufferViews","buffer","sparse","pendingBufferViews","bufferAttribute","itemSize","TypedArray","elementBytes","BYTES_PER_ELEMENT","itemBytes","byteStride","ibSlice","floor","ibCacheKey","ib","InterleavedBuffer","InterleavedBufferAttribute","itemSizeIndices","TypedArrayIndices","byteOffsetIndices","byteOffsetValues","sparseIndices","sparseValues","setW","textureIndex","URL","self","webkitURL","textureDef","textureExtensions","sourceURI","images","isObjectURL","blob","mimeType","createObjectURL","getHandler","revokeObjectURL","flipY","format","sampler","samplers","magFilter","minFilter","wrapS","wrapT","mapName","mapDef","isCompressedTexture","assignFinalMaterial","useVertexTangents","useVertexColors","useFlatShading","useSkinning","useMorphTargets","useMorphNormals","isPoints","uuid","pointsMaterial","PointsMaterial","sizeAttenuation","isLine","lineMaterial","cachedMaterial","skinning","vertexTangents","flatShading","morphTargets","uv2","materialIndex","materialType","materials","materialExtensions","sgExtension","kmuExtension","metallicFactor","roughnessFactor","metallicRoughnessTexture","doubleSided","DoubleSide","alphaMode","depthWrite","alphaTest","alphaCutoff","normalTexture","occlusionTexture","strength","emissiveFactor","emissiveTexture","clearcoatExtension","encoding","sRGBEncoding","loadGeometries","primitives","createDracoPrimitive","dracoExtension","geometryPromise","mode","cached","promise","meshIndex","FrontSide","results","geometries","SkinnedMesh","Mesh","skinWeight","normalizeSkinWeights","TriangleStripDrawMode","Line","LineLoop","Points","Group","cameraIndex","cameraDef","PerspectiveCamera","MathUtils","yfov","aspectRatio","znear","zfar","OrthographicCamera","xmag","ymag","skinDef","skinEntry","inverseBindMatrices","animationIndex","animationDef","pendingNodes","pendingInputAccessors","pendingOutputAccessors","pendingSamplers","pendingTargets","channels","channel","node","input","output","inputAccessors","outputAccessors","tracks","inputAccessor","outputAccessor","TypedKeyframeTrack","updateMatrix","NumberKeyframeTrack","QuaternionKeyframeTrack","VectorKeyframeTrack","targetName","interpolation","traverse","isMesh","outputArray","scaled","track","createInterpolant","times","getValueSize","isInterpolantFactoryMethodGLTFCubicSpline","AnimationClip","instanceNum","o","light","Bone","Object3D","PropertyBinding","matrix","Matrix4","quaternion","buildNodeHierachy","nodeId","parentObject","pendingJoints","jointNodes","bones","boneInverses","jointNode","mat","bind","Skeleton","children","child","sceneIndex","sceneDef","nodeIds","Model","obj","ref","isLight","logError","UV","ALIAS","Keyboard","keyCodes","event","onKeyChange","onBlur","removeEventListener","prop","keyCode","keyDesc","split","pressed","toUpperCase","charCodeAt","aliases","aliasKeys","shiftKey","ctrlKey","altKey","metaKey","Interaction","timeout","keyboard","throttle","onMouseMove","onMouseLeave","onMouseOver","eventMatches","preventDefault","DatGUI","main","gui","dat","GUI","meshHelper","cameraFolder","addFolder","cameraFOVGui","onChange","enableRotate","onFinishChange","cameraAspectGui","addColor","cameraFogNearGui","density","controlsFolder","controlsAutoRotateSpeedGui","disable","unload","meshFolder","enable","ambientLightFolder","directionalLightFolder","directionalLightIntensityGui","directionalLightPositionXGui","directionalLightPositionYGui","directionalLightPositionZGui","shadowFolder","shadowNearGui","dispose","shadowFarGui","shadowTopGui","shadowRightGui","shadowBottomGui","shadowLeftGui","shadowBiasGui","pointLightFolder","pointLightIntensityGui","pointLightDistanceGui","pointLightPositionXGui","pointLightPositionYGui","pointLightPositionZGui","hemiLightFolder","hemiLightIntensityGui","hemiLightPositionXGui","hemiLightPositionYGui","hemiLightPositionZGui","destroy","Main","clock","place","make","stats","setUp","item","querySelector","display","requestAnimationFrame","Detector","getElementById","module","exports","MOUSE","OrbitConstraint","minZoom","maxZoom","theta","phi","quat","quatInverse","lastPosition","lastQuaternion","EPS","phiDelta","thetaDelta","panOffset","zoomChanged","getPolarAngle","getAzimuthalAngle","rotateLeft","rotateUp","panLeft","te","elements","panUp","pan","deltaX","deltaY","screenWidth","screenHeight","targetDistance","tan","dollyIn","dollyScale","zoom","dollyOut","Quaternion","setFromUnitVectors","up","inverse","applyQuaternion","atan2","sqrt","sin","cos","lookAt","distanceToSquared","constraint","defineProperty","enablePan","keyPanSpeed","enableKeys","LEFT","UP","RIGHT","BOTTOM","mouseButtons","ORBIT","ZOOM","MIDDLE","PAN","rotateStart","rotateEnd","rotateDelta","panStart","panEnd","panDelta","dollyStart","dollyEnd","dollyDelta","STATE","state","target0","position0","zoom0","changeEvent","startEvent","endEvent","clientWidth","clientHeight","getZoomScale","pow","onMouseDown","button","clientX","clientY","onMouseUp","dispatchEvent","subVectors","onMouseWheel","stopPropagation","delta","wheelDelta","detail","onKeyDown","touchstart","touches","pageX","pageY","dx","dy","touchmove","touchend","contextmenu","reset","EventDispatcher","noZoom","noRotate","noPan","noKeys","staticMoving","dynamicDampingFactor"],"mappings":"6JAGA,SACEA,OAAO,EACPC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,cAAe,EACfC,IAAK,EACLC,OAAQC,4BACRC,SAAU,IACVC,MAAO,CACLC,SAAU,EACVC,aAAc,CAAC,OAAQ,UACvBC,KAAM,QAERC,OAAQ,CACN,CACEC,KAAM,4BACNC,MAAO,GACPH,KAAM,QAER,CACEE,KAAM,8BACNC,MAAO,GACPH,KAAM,WAGVI,QAAS,CACPF,KAAM,qBACNG,WAAY,CACV,CAAEC,KAAM,KAAMC,MAAO,oBAGzBC,KAAM,CACJC,cAAc,EACdC,WAAW,EACXC,aAAa,EACbC,SAAU,CACRC,MAAO,SACPC,SAAU,WAGdC,IAAK,CACHF,MAAO,SACPG,KAAM,MAERC,OAAQ,CACNC,IAAK,GACLF,KAAM,EACNG,IAAK,IACLC,OAAQ,EACRC,KAAM,EACNC,KAAM,GACNC,KAAM,IAERC,SAAU,CACRC,YAAY,EACZC,iBAAkB,GAClBC,YAAa,GACbC,UAAW,GACXC,YAAa,IACbC,YAAa,IACbC,cAAeC,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T,KAAKg+B,WAGf97B,IAAK,SAAUqJ,GACbJ,QAAQyI,KAAK,4EACb5T,KAAKg+B,WAAazyB,IAItBq2B,OAAQ,CACNrxB,IAAK,WAEH,OADApF,QAAQyI,KAAK,+EACL5T,KAAKk+B,YAGfh8B,IAAK,SAAUqJ,GACbJ,QAAQyI,KAAK,8EACb5T,KAAKk+B,YAAc3yB,IAIvBs2B,aAAc,CACZtxB,IAAK,WAIH,OAHApF,QAAQyI,KACN,wFAEM5T,KAAK89B,WAAWlhC,eAG1BsF,IAAK,SAAUqJ,GACbJ,QAAQyI,KACN,uFAEF5T,KAAK89B,WAAWlhC,eAAiB2O,IAIrCu2B,qBAAsB,CACpBvxB,IAAK,WAIH,OAHApF,QAAQyI,KACN,4FAEK5T,KAAK89B,WAAWjhC,eAGzBqF,IAAK,SAAUqJ,GACbJ,QAAQyI,KACN,4FAEF5T,KAAK89B,WAAWjhC,cAAgB0O,MAK/BzI,K","file":"main.bundle.js","sourcesContent":["import TWEEN from '@tweenjs/tween.js';\r\n\r\n// This object contains the state of the app\r\nexport default {\r\n isDev: false,\r\n isShowingStats: true,\r\n isLoaded: false,\r\n isTweening: false,\r\n isRotating: true,\r\n isMouseMoving: false,\r\n isMouseOver: false,\r\n maxAnisotropy: 1,\r\n dpr: 1,\r\n easing: TWEEN.Easing.Quadratic.InOut,\r\n duration: 500,\r\n model: {\r\n selected: 0,\r\n initialTypes: ['gltf', 'object'],\r\n type: 'gltf'\r\n },\r\n models: [\r\n {\r\n path: './assets/models/duck.gltf',\r\n scale: 20,\r\n type: 'gltf'\r\n },\r\n {\r\n path: './assets/models/Teapot.json',\r\n scale: 20,\r\n type: 'object'\r\n }\r\n ],\r\n texture: {\r\n path: './assets/textures/',\r\n imageFiles: [\r\n { name: 'UV', image: 'UV_Grid_Sm.jpg' }\r\n ]\r\n },\r\n mesh: {\r\n enableHelper: true,\r\n wireframe: false,\r\n translucent: false,\r\n material: {\r\n color: 0xffffff,\r\n emissive: 0xffffff\r\n }\r\n },\r\n fog: {\r\n color: 0xffffff,\r\n near: 0.0008\r\n },\r\n camera: {\r\n fov: 40,\r\n near: 2,\r\n far: 1000,\r\n aspect: 1,\r\n posX: 0,\r\n posY: 30,\r\n posZ: 40\r\n },\r\n controls: {\r\n autoRotate: true,\r\n autoRotateSpeed: -0.5,\r\n rotateSpeed: 0.5,\r\n zoomSpeed: 0.8,\r\n minDistance: 200,\r\n maxDistance: 600,\r\n minPolarAngle: Math.PI / 5,\r\n maxPolarAngle: Math.PI / 2,\r\n minAzimuthAngle: -Infinity,\r\n maxAzimuthAngle: Infinity,\r\n enableDamping: true,\r\n dampingFactor: 0.5,\r\n enableZoom: true,\r\n target: {\r\n x: 0,\r\n y: 0,\r\n z: 0\r\n }\r\n },\r\n ambientLight: {\r\n enabled: true,\r\n color: 0x141414\r\n },\r\n directionalLight: {\r\n enabled: true,\r\n color: 0xf0f0f0,\r\n intensity: 0.4,\r\n x: -75,\r\n y: 280,\r\n z: 150\r\n },\r\n shadow: {\r\n enabled: true,\r\n helperEnabled: true,\r\n bias: 0,\r\n mapWidth: 2048,\r\n mapHeight: 2048,\r\n near: 250,\r\n far: 400,\r\n top: 100,\r\n right: 100,\r\n bottom: -100,\r\n left: -100\r\n },\r\n pointLight: {\r\n enabled: true,\r\n color: 0xffffff,\r\n intensity: 0.34,\r\n distance: 115,\r\n x: 0,\r\n y: 0,\r\n z: 0\r\n },\r\n hemiLight: {\r\n enabled: true,\r\n color: 0xc8c8c8,\r\n groundColor: 0xffffff,\r\n intensity: 0.55,\r\n x: 0,\r\n y: 0,\r\n z: 0\r\n }\r\n};\r\n","/**\r\n * @author alteredq / http://alteredqualia.com/\r\n * @author mr.doob / http://mrdoob.com/\r\n */\r\n\r\nexport default {\r\n canvas: !!window.CanvasRenderingContext2D,\r\n webgl: (function() {\r\n try {\r\n var canvas = document.createElement('canvas');\r\n\r\n return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));\r\n } catch(e) {\r\n return false;\r\n }\r\n })(),\r\n\r\n workers: !!window.Worker,\r\n fileapi: window.File && window.FileReader && window.FileList && window.Blob,\r\n\r\n getWebGLErrorMessage: function() {\r\n var element = document.createElement('div');\r\n element.id = 'webgl-error-message';\r\n element.style.fontFamily = 'monospace';\r\n element.style.fontSize = '13px';\r\n element.style.fontWeight = 'normal';\r\n element.style.textAlign = 'center';\r\n element.style.background = '#fff';\r\n element.style.color = '#000';\r\n element.style.padding = '1.5em';\r\n element.style.width = '400px';\r\n element.style.margin = '5em auto 0';\r\n\r\n if(!this.webgl) {\r\n element.innerHTML = window.WebGLRenderingContext ? [\r\n 'Your graphics card does not seem to support <a href=\"http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation\" style=\"color:#000000\">WebGL</a>.<br />',\r\n 'Find out how to get it <a href=\"http://get.webgl.org/\" style=\"color:#000000\">here</a>.'\r\n ].join('\\n') : [\r\n 'Your browser does not seem to support <a href=\"http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation\" style=\"color:#000000\">WebGL</a>.<br/>',\r\n 'Find out how to get it <a href=\"http://get.webgl.org/\" style=\"color:#000000\">here</a>.'\r\n ].join('\\n');\r\n }\r\n\r\n return element;\r\n },\r\n\r\n addGetWebGLMessage: function(parameters) {\r\n var parent, id, element;\r\n\r\n parameters = parameters || {};\r\n\r\n parent = parameters.parent !== undefined ? parameters.parent : document.body;\r\n id = parameters.id !== undefined ? parameters.id : 'oldie';\r\n\r\n element = this.getWebGLErrorMessage();\r\n element.id = id;\r\n\r\n parent.appendChild(element);\r\n }\r\n};\r\n","import * as THREE from 'three';\r\n\r\nimport Config from '../../data/config';\r\n\r\n// Main webGL renderer class\r\nexport default class Renderer {\r\n constructor(scene, container) {\r\n // Properties\r\n this.scene = scene;\r\n this.container = container;\r\n\r\n // Create WebGL renderer and set its antialias\r\n this.threeRenderer = new THREE.WebGLRenderer({antialias: true});\r\n\r\n // Set clear color to fog to enable fog or to hex color for no fog\r\n this.threeRenderer.setClearColor(scene.fog.color);\r\n this.threeRenderer.setPixelRatio(window.devicePixelRatio); // For retina\r\n\r\n // Appends canvas\r\n container.appendChild(this.threeRenderer.domElement);\r\n\r\n // Shadow map options\r\n this.threeRenderer.shadowMap.enabled = true;\r\n this.threeRenderer.shadowMap.type = THREE.PCFSoftShadowMap;\r\n\r\n // Get anisotropy for textures\r\n Config.maxAnisotropy = this.threeRenderer.capabilities.getMaxAnisotropy();\r\n\r\n // Initial size update set to canvas container\r\n this.updateSize();\r\n\r\n // Listeners\r\n document.addEventListener('DOMContentLoaded', () => this.updateSize(), false);\r\n window.addEventListener('resize', () => this.updateSize(), false);\r\n }\r\n\r\n updateSize() {\r\n this.threeRenderer.setSize(this.container.offsetWidth, this.container.offsetHeight);\r\n }\r\n\r\n render(scene, camera) {\r\n // Renders scene to canvas target\r\n this.threeRenderer.render(scene, camera);\r\n }\r\n}\r\n","import * as THREE from 'three';\r\n\r\nimport Config from '../../data/config';\r\n\r\n// Class that creates and updates the main camera\r\nexport default class Camera {\r\n constructor(renderer) {\r\n const width = renderer.domElement.width;\r\n const height = renderer.domElement.height;\r\n\r\n // Create and position a Perspective Camera\r\n this.threeCamera = new THREE.PerspectiveCamera(Config.camera.fov, width / height, Config.camera.near, Config.camera.far);\r\n this.threeCamera.position.set(Config.camera.posX, Config.camera.posY, Config.camera.posZ);\r\n\r\n // Initial sizing\r\n this.updateSize(renderer);\r\n \r\n // Listeners\r\n window.addEventListener('resize', () => this.updateSize(renderer), false);\r\n }\r\n\r\n updateSize(renderer) {\r\n // Update camera aspect ratio with window aspect ratio\r\n this.threeCamera.aspect = renderer.domElement.width / renderer.domElement.height;\r\n\r\n // Always call updateProjectionMatrix on camera change\r\n this.threeCamera.updateProjectionMatrix();\r\n }\r\n}\r\n","import * as THREE from 'three';\n\nimport Config from '../../data/config';\n\n// Sets up and places all lights in scene\nexport default class Light {\n constructor(scene) {\n this.scene = scene;\n\n this.init();\n }\n\n init() {\n // Ambient\n this.ambientLight = new THREE.AmbientLight(Config.ambientLight.color);\n this.ambientLight.visible = Config.ambientLight.enabled;\n\n // Point light\n this.pointLight = new THREE.PointLight(Config.pointLight.color, Config.pointLight.intensity, Config.pointLight.distance);\n this.pointLight.position.set(Config.pointLight.x, Config.pointLight.y, Config.pointLight.z);\n this.pointLight.visible = Config.pointLight.enabled;\n\n // Directional light\n this.directionalLight = new THREE.DirectionalLight(Config.directionalLight.color, Config.directionalLight.intensity);\n this.directionalLight.position.set(Config.directionalLight.x, Config.directionalLight.y, Config.directionalLight.z);\n this.directionalLight.visible = Config.directionalLight.enabled;\n\n // Shadow map\n this.directionalLight.castShadow = Config.shadow.enabled;\n this.directionalLight.shadow.bias = Config.shadow.bias;\n this.directionalLight.shadow.camera.near = Config.shadow.near;\n this.directionalLight.shadow.camera.far = Config.shadow.far;\n this.directionalLight.shadow.camera.left = Config.shadow.left;\n this.directionalLight.shadow.camera.right = Config.shadow.right;\n this.directionalLight.shadow.camera.top = Config.shadow.top;\n this.directionalLight.shadow.camera.bottom = Config.shadow.bottom;\n this.directionalLight.shadow.mapSize.width = Config.shadow.mapWidth;\n this.directionalLight.shadow.mapSize.height = Config.shadow.mapHeight;\n\n // Shadow camera helper\n if(Config.isDev) {\n this.directionalLightHelper = new THREE.CameraHelper(this.directionalLight.shadow.camera);\n this.directionalLightHelper.visible = Config.shadow.helperEnabled;\n }\n // Hemisphere light\n this.hemiLight = new THREE.HemisphereLight(Config.hemiLight.color, Config.hemiLight.groundColor, Config.hemiLight.intensity);\n this.hemiLight.position.set(Config.hemiLight.x, Config.hemiLight.y, Config.hemiLight.z);\n this.hemiLight.visible = Config.hemiLight.enabled;\n }\n\n place(lightName) {\n switch(lightName) {\n case 'ambient':\n this.scene.add(this.ambientLight);\n break;\n\n case 'directional':\n this.scene.add(this.directionalLight);\n if(Config.isDev) {\n this.scene.add(this.directionalLightHelper);\n }\n break;\n\n case 'point':\n this.scene.add(this.pointLight);\n break;\n\n case 'hemi':\n this.scene.add(this.hemiLight);\n break;\n }\n }\n}\n","import * as THREE from 'three';\n\nimport OrbitControls from '../../utils/orbitControls';\nimport Config from '../../data/config';\n\n// Controls based on orbit controls\nexport default class Controls {\n constructor(camera, container) {\n // Orbit controls first needs to pass in THREE to constructor\n const orbitControls = new OrbitControls(THREE);\n this.threeControls = new orbitControls(camera, container);\n\n this.init();\n }\n\n init() {\n this.threeControls.target.set(Config.controls.target.x, Config.controls.target.y, Config.controls.target.z);\n this.threeControls.autoRotate = Config.controls.autoRotate;\n this.threeControls.autoRotateSpeed = Config.controls.autoRotateSpeed;\n this.threeControls.rotateSpeed = Config.controls.rotateSpeed;\n this.threeControls.zoomSpeed = Config.controls.zoomSpeed;\n this.threeControls.minDistance = Config.controls.minDistance;\n this.threeControls.maxDistance = Config.controls.maxDistance;\n this.threeControls.minPolarAngle = Config.controls.minPolarAngle;\n this.threeControls.maxPolarAngle = Config.controls.maxPolarAngle;\n this.threeControls.enableDamping = Config.controls.enableDamping;\n this.threeControls.enableZoom = Config.controls.enableZoom;\n this.threeControls.dampingFactor = Config.controls.dampingFactor;\n }\n}\n","import * as THREE from 'three';\r\n\r\n// USe this class as a helper to set up some default materials\r\nexport default class Material {\r\n constructor(color) {\r\n this.basic = new THREE.MeshBasicMaterial({\r\n color,\r\n side: THREE.DoubleSide\r\n });\r\n\r\n this.standard = new THREE.MeshStandardMaterial({\r\n color,\r\n shading: THREE.FlatShading,\r\n roughness: 1,\r\n metalness: 0,\r\n side: THREE.DoubleSide\r\n });\r\n\r\n this.wire = new THREE.MeshBasicMaterial({wireframe: true});\r\n }\r\n}\r\n\r\n","// Local vars for rStats\r\nlet rS, bS, glS, tS;\r\n\r\nexport default class Stats {\r\n constructor(renderer) {\r\n this.renderer = renderer;\r\n }\r\n\r\n setUp() {\r\n bS = new BrowserStats();\r\n glS = new glStats();\r\n tS = new threeStats(this.renderer.threeRenderer);\r\n\r\n rS = new rStats({\r\n CSSPath: './css/',\r\n userTimingAPI: true,\r\n values: {\r\n frame: { caption: 'Total frame time (ms)', over: 16, average: true, avgMs: 100 },\r\n fps: { caption: 'Framerate (FPS)', below: 30 },\r\n calls: { caption: 'Calls (three.js)', over: 3000 },\r\n raf: { caption: 'Time since last rAF (ms)', average: true, avgMs: 100 },\r\n rstats: { caption: 'rStats update (ms)', average: true, avgMs: 100 },\r\n texture: { caption: 'GenTex', average: true, avgMs: 100 }\r\n },\r\n groups: [\r\n { caption: 'Framerate', values: ['fps', 'raf'] },\r\n { caption: 'Frame Budget', values: ['frame', 'texture', 'setup', 'render'] }\r\n ],\r\n fractions: [\r\n { base: 'frame', steps: ['texture', 'setup', 'render'] }\r\n ],\r\n plugins: [bS, tS]\r\n });\r\n }\r\n\r\n static start() {\r\n rS('frame').start();\r\n glS.start();\r\n\r\n rS('rAF').tick();\r\n rS('FPS').frame();\r\n\r\n rS('render').start();\r\n }\r\n\r\n static end() {\r\n rS('render').end(); // render finished\r\n rS('frame').end(); // frame finished\r\n\r\n // Local rStats update\r\n rS('rStats').start();\r\n rS().update();\r\n rS('rStats').end();\r\n }\r\n}\r\n","import * as THREE from 'three';\r\n\r\nimport Material from './material';\r\nimport Config from '../../data/config';\r\n\r\n// This helper class can be used to create and then place geometry in the scene\r\nexport default class Geometry {\r\n constructor(scene) {\r\n this.scene = scene;\r\n this.geo = null;\r\n }\r\n\r\n make(type) {\r\n if(type === 'plane') {\r\n return (width, height, widthSegments = 1, heightSegments = 1) => {\r\n this.geo = new THREE.PlaneGeometry(width, height, widthSegments, heightSegments);\r\n };\r\n }\r\n\r\n if(type === 'sphere') {\r\n return (radius, widthSegments = 32, heightSegments = 32) => {\r\n this.geo = new THREE.SphereGeometry(radius, widthSegments, heightSegments);\r\n };\r\n }\r\n }\r\n\r\n place(position, rotation) {\r\n const material = new Material(0xeeeeee).standard;\r\n const mesh = new THREE.Mesh(this.geo, material);\r\n\r\n // Use ES6 spread to set position and rotation from passed in array\r\n mesh.position.set(...position);\r\n mesh.rotation.set(...rotation);\r\n\r\n if(Config.shadow.enabled) {\r\n mesh.receiveShadow = true;\r\n }\r\n\r\n this.scene.add(mesh);\r\n }\r\n}\r\n","/**\r\n * @author mrdoob / http://mrdoob.com/\r\n * @author WestLangley / http://github.com/WestLangley\r\n */\r\n\r\nimport {\r\n BufferGeometry,\r\n Float32BufferAttribute,\r\n LineSegments,\r\n LineBasicMaterial,\r\n Matrix3,\r\n Vector3,\r\n} from 'three';\r\n\r\nconst _v1 = new Vector3();\r\nconst _v2 = new Vector3();\r\nconst _normalMatrix = new Matrix3();\r\nconst _keys = ['a', 'b', 'c'];\r\n\r\nfunction VertexNormalsHelper(object, size, hex) {\r\n this.object = object;\r\n this.size = size !== undefined ? size : 0.1;\r\n\r\n const color = hex !== undefined ? hex : 0xff0000;\r\n\r\n //\r\n\r\n let nNormals = 0;\r\n\r\n const objGeometry = this.object.geometry;\r\n\r\n if (objGeometry && objGeometry.isGeometry) {\r\n nNormals = objGeometry.faces.length * 3;\r\n } else if (objGeometry && objGeometry.isBufferGeometry) {\r\n nNormals = objGeometry.attributes.normal.count;\r\n }\r\n\r\n //\r\n\r\n const geometry = new BufferGeometry();\r\n const positions = new Float32BufferAttribute(nNormals * 2 * 3, 3);\r\n\r\n geometry.setAttribute('position', positions);\r\n\r\n LineSegments.call(this, geometry, new LineBasicMaterial({ color: color, toneMapped: false }));\r\n\r\n this.type = 'VertexNormalsHelper';\r\n\r\n //\r\n\r\n this.matrixAutoUpdate = false;\r\n\r\n this.update();\r\n}\r\n\r\nVertexNormalsHelper.prototype = Object.create(LineSegments.prototype);\r\nVertexNormalsHelper.prototype.constructor = VertexNormalsHelper;\r\n\r\nVertexNormalsHelper.prototype.update = function () {\r\n let idx;\r\n this.object.updateMatrixWorld(true);\r\n\r\n _normalMatrix.getNormalMatrix(this.object.matrixWorld);\r\n\r\n const matrixWorld = this.object.matrixWorld;\r\n const position = this.geometry.attributes.position;\r\n\r\n //\r\n\r\n const objGeometry = this.object.geometry;\r\n\r\n if (objGeometry && objGeometry.isGeometry) {\r\n const vertices = objGeometry.vertices;\r\n\r\n const faces = objGeometry.faces;\r\n\r\n idx = 0;\r\n\r\n for (let i = 0, l = faces.length; i < l; i++) {\r\n const face = faces[i];\r\n\r\n for (let j = 0, jl = face.vertexNormals.length; j < jl; j++) {\r\n const vertex = vertices[face[_keys[j]]];\r\n const normal = face.vertexNormals[j];\r\n\r\n _v1.copy(vertex).applyMatrix4(matrixWorld);\r\n _v2.copy(normal).applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1);\r\n\r\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z);\r\n\r\n idx = idx + 1;\r\n\r\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z);\r\n\r\n idx = idx + 1;\r\n }\r\n }\r\n } else if (objGeometry && objGeometry.isBufferGeometry) {\r\n const objPos = objGeometry.attributes.position;\r\n const objNorm = objGeometry.attributes.normal;\r\n\r\n idx = 0;\r\n\r\n // for simplicity, ignore index and drawcalls, and render every normal\r\n\r\n for (var j = 0, jl = objPos.count; j < jl; j++) {\r\n _v1.set(objPos.getX(j), objPos.getY(j), objPos.getZ(j)).applyMatrix4(matrixWorld);\r\n _v2.set(objNorm.getX(j), objNorm.getY(j), objNorm.getZ(j));\r\n _v2.applyMatrix3(_normalMatrix).normalize().multiplyScalar(this.size).add(_v1);\r\n\r\n position.setXYZ(idx, _v1.x, _v1.y, _v1.z);\r\n\r\n idx = idx + 1;\r\n\r\n position.setXYZ(idx, _v2.x, _v2.y, _v2.z);\r\n\r\n idx = idx + 1;\r\n }\r\n }\r\n\r\n position.needsUpdate = true;\r\n};\r\n\r\nexport { VertexNormalsHelper };\r\n","import * as THREE from 'three';\r\nimport { VertexNormalsHelper } from './vertexNormalsHelper';\r\n\r\n// Simple mesh helper that shows edges, wireframes, and face and vertex normals\r\nexport default class MeshHelper {\r\n constructor(scene, mesh) {\r\n this.mesh = mesh;\r\n this.scene = scene;\r\n\r\n const wireframe = new THREE.WireframeGeometry(this.mesh.geometry);\r\n this.wireLine = new THREE.LineSegments(wireframe);\r\n this.wireLine.material.depthTest = false;\r\n this.wireLine.material.opacity = 0.25;\r\n this.wireLine.material.transparent = true;\r\n\r\n const edges = new THREE.EdgesGeometry(this.mesh.geometry);\r\n this.edgesLine = new THREE.LineSegments(edges);\r\n this.edgesLine.material.depthTest = false;\r\n this.edgesLine.material.opacity = 0.25;\r\n this.edgesLine.material.transparent = true;\r\n\r\n this.vertexHelper = new VertexNormalsHelper(this.mesh, 2);\r\n this.boxHelper = new THREE.BoxHelper(this.mesh);\r\n }\r\n\r\n enable() {\r\n this.mesh.add(this.wireLine);\r\n this.mesh.add(this.edgesLine);\r\n\r\n this.scene.add(this.vertexHelper);\r\n this.scene.add(this.boxHelper);\r\n }\r\n\r\n disable() {\r\n this.mesh.remove(this.wireLine);\r\n this.mesh.remove(this.edgesLine);\r\n\r\n this.scene.remove(this.vertexHelper);\r\n this.scene.remove(this.boxHelper);\r\n }\r\n}\r\n","// Provides simple static functions that are used multiple times in the app\r\nexport default class Helpers {\r\n static throttle(fn, threshhold, scope) {\r\n threshhold || (threshhold = 250);\r\n let last, deferTimer;\r\n\r\n return function() {\r\n const context = scope || this;\r\n\r\n const now = +new Date,\r\n args = arguments;\r\n\r\n if(last && now < last + threshhold) {\r\n clearTimeout(deferTimer);\r\n deferTimer = setTimeout(function() {\r\n last = now;\r\n fn.apply(context, args);\r\n }, threshhold);\r\n }\r\n else {\r\n last = now;\r\n fn.apply(context, args);\r\n }\r\n };\r\n }\r\n\r\n static logProgress() {\r\n return function(xhr) {\r\n if(xhr.lengthComputable) {\r\n const percentComplete = xhr.loaded / xhr.total * 100;\r\n\r\n console.log(Math.round(percentComplete, 2) + '% downloaded');\r\n }\r\n }\r\n }\r\n\r\n static logError() {\r\n return function(xhr) {\r\n console.error(xhr);\r\n }\r\n }\r\n\r\n static handleColorChange(color) {\r\n return (value) => {\r\n if(typeof value === 'string') {\r\n value = value.replace('#', '0x');\r\n }\r\n\r\n color.setHex(value);\r\n };\r\n }\r\n\r\n static update(mesh) {\r\n this.needsUpdate(mesh.material, mesh.geometry);\r\n }\r\n\r\n static needsUpdate(material, geometry) {\r\n return function() {\r\n material.shading = +material.shading; //Ensure number\r\n material.vertexColors = +material.vertexColors; //Ensure number\r\n material.side = +material.side; //Ensure number\r\n material.needsUpdate = true;\r\n geometry.verticesNeedUpdate = true;\r\n geometry.normalsNeedUpdate = true;\r\n geometry.colorsNeedUpdate = true;\r\n };\r\n }\r\n\r\n static updateTexture(material, materialKey, textures) {\r\n return function(key) {\r\n material[materialKey] = textures[key];\r\n material.needsUpdate = true;\r\n };\r\n }\r\n}\r\n","import * as THREE from 'three';\n// Promise polyfill for IE\nimport { Promise } from 'es6-promise';\n\nimport Helpers from '../../utils/helpers';\nimport Config from '../../data/config';\n\n// This class preloads all textures in the imageFiles array in the Config via ES6 Promises.\n// Once all textures are done loading the model itself will be loaded after the Promise .then() callback.\n// Using promises to preload textures prevents issues when applying textures to materials\n// before the textures have loaded.\nexport default class Texture {\n constructor() {\n // Prop that will contain all loaded textures\n this.textures = {};\n }\n\n load() {\n const loader = new THREE.TextureLoader();\n const maxAnisotropy = Config.maxAnisotropy;\n const imageFiles = Config.texture.imageFiles;\n const promiseArray = [];\n\n loader.setPath(Config.texture.path);\n\n imageFiles.forEach(imageFile => {\n // Add an individual Promise for each image in array\n promiseArray.push(new Promise((resolve, reject) => {\n // Each Promise will attempt to load the image file\n loader.load(imageFile.image,\n // This gets called on load with the loaded texture\n texture => {\n texture.anisotropy = maxAnisotropy;\n\n // Resolve Promise with object of texture if it is instance of THREE.Texture\n const modelOBJ = {};\n modelOBJ[imageFile.name] = texture;\n if(modelOBJ[imageFile.name] instanceof THREE.Texture)\n resolve(modelOBJ);\n },\n Helpers.logProgress(),\n xhr => reject(new Error(xhr + 'An error occurred loading while loading ' + imageFile.image))\n )\n }));\n });\n\n // Iterate through all Promises in array and return another Promise when all have resolved or console log reason when any reject\n return Promise.all(promiseArray).then(textures => {\n // Set the textures prop object to have name be the resolved texture\n for(let i = 0; i < textures.length; i++) {\n this.textures[Object.keys(textures[i])[0]] = textures[i][Object.keys(textures[i])[0]];\n }\n }, reason => console.log(reason));\n }\n}\n","/**\r\n * @author mrdoob / http://mrdoob.com/\r\n */\r\n\r\nimport {\r\n BufferAttribute,\r\n BufferGeometry,\r\n InterleavedBuffer,\r\n InterleavedBufferAttribute,\r\n TriangleFanDrawMode,\r\n TriangleStripDrawMode,\r\n TrianglesDrawMode,\r\n Vector2,\r\n Vector3,\r\n} from 'three';\r\n\r\nvar BufferGeometryUtils = {\r\n computeTangents: function (geometry) {\r\n var index = geometry.index;\r\n var attributes = geometry.attributes;\r\n\r\n // based on http://www.terathon.com/code/tangent.html\r\n // (per vertex tangents)\r\n\r\n if (\r\n index === null ||\r\n attributes.position === undefined ||\r\n attributes.normal === undefined ||\r\n attributes.uv === undefined\r\n ) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .computeTangents() failed. Missing required attributes (index, position, normal or uv)'\r\n );\r\n return;\r\n }\r\n\r\n var indices = index.array;\r\n var positions = attributes.position.array;\r\n var normals = attributes.normal.array;\r\n var uvs = attributes.uv.array;\r\n\r\n var nVertices = positions.length / 3;\r\n\r\n if (attributes.tangent === undefined) {\r\n geometry.setAttribute('tangent', new BufferAttribute(new Float32Array(4 * nVertices), 4));\r\n }\r\n\r\n var tangents = attributes.tangent.array;\r\n\r\n var tan1 = [],\r\n tan2 = [];\r\n\r\n for (var i = 0; i < nVertices; i++) {\r\n tan1[i] = new Vector3();\r\n tan2[i] = new Vector3();\r\n }\r\n\r\n var vA = new Vector3(),\r\n vB = new Vector3(),\r\n vC = new Vector3(),\r\n uvA = new Vector2(),\r\n uvB = new Vector2(),\r\n uvC = new Vector2(),\r\n sdir = new Vector3(),\r\n tdir = new Vector3();\r\n\r\n function handleTriangle(a, b, c) {\r\n vA.fromArray(positions, a * 3);\r\n vB.fromArray(positions, b * 3);\r\n vC.fromArray(positions, c * 3);\r\n\r\n uvA.fromArray(uvs, a * 2);\r\n uvB.fromArray(uvs, b * 2);\r\n uvC.fromArray(uvs, c * 2);\r\n\r\n vB.sub(vA);\r\n vC.sub(vA);\r\n\r\n uvB.sub(uvA);\r\n uvC.sub(uvA);\r\n\r\n var r = 1.0 / (uvB.x * uvC.y - uvC.x * uvB.y);\r\n\r\n // silently ignore degenerate uv triangles having coincident or colinear vertices\r\n\r\n if (!isFinite(r)) return;\r\n\r\n sdir.copy(vB).multiplyScalar(uvC.y).addScaledVector(vC, -uvB.y).multiplyScalar(r);\r\n tdir.copy(vC).multiplyScalar(uvB.x).addScaledVector(vB, -uvC.x).multiplyScalar(r);\r\n\r\n tan1[a].add(sdir);\r\n tan1[b].add(sdir);\r\n tan1[c].add(sdir);\r\n\r\n tan2[a].add(tdir);\r\n tan2[b].add(tdir);\r\n tan2[c].add(tdir);\r\n }\r\n\r\n var groups = geometry.groups;\r\n\r\n if (groups.length === 0) {\r\n groups = [\r\n {\r\n start: 0,\r\n count: indices.length,\r\n },\r\n ];\r\n }\r\n\r\n for (var i = 0, il = groups.length; i < il; ++i) {\r\n var group = groups[i];\r\n\r\n var start = group.start;\r\n var count = group.count;\r\n\r\n for (var j = start, jl = start + count; j < jl; j += 3) {\r\n handleTriangle(indices[j + 0], indices[j + 1], indices[j + 2]);\r\n }\r\n }\r\n\r\n var tmp = new Vector3(),\r\n tmp2 = new Vector3();\r\n var n = new Vector3(),\r\n n2 = new Vector3();\r\n var w, t, test;\r\n\r\n function handleVertex(v) {\r\n n.fromArray(normals, v * 3);\r\n n2.copy(n);\r\n\r\n t = tan1[v];\r\n\r\n // Gram-Schmidt orthogonalize\r\n\r\n tmp.copy(t);\r\n tmp.sub(n.multiplyScalar(n.dot(t))).normalize();\r\n\r\n // Calculate handedness\r\n\r\n tmp2.crossVectors(n2, t);\r\n test = tmp2.dot(tan2[v]);\r\n w = test < 0.0 ? -1.0 : 1.0;\r\n\r\n tangents[v * 4] = tmp.x;\r\n tangents[v * 4 + 1] = tmp.y;\r\n tangents[v * 4 + 2] = tmp.z;\r\n tangents[v * 4 + 3] = w;\r\n }\r\n\r\n for (var i = 0, il = groups.length; i < il; ++i) {\r\n var group = groups[i];\r\n\r\n var start = group.start;\r\n var count = group.count;\r\n\r\n for (var j = start, jl = start + count; j < jl; j += 3) {\r\n handleVertex(indices[j + 0]);\r\n handleVertex(indices[j + 1]);\r\n handleVertex(indices[j + 2]);\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * @param {Array<BufferGeometry>} geometries\r\n * @param {Boolean} useGroups\r\n * @return {BufferGeometry}\r\n */\r\n mergeBufferGeometries: function (geometries, useGroups) {\r\n var isIndexed = geometries[0].index !== null;\r\n\r\n var attributesUsed = new Set(Object.keys(geometries[0].attributes));\r\n var morphAttributesUsed = new Set(Object.keys(geometries[0].morphAttributes));\r\n\r\n var attributes = {};\r\n var morphAttributes = {};\r\n\r\n var morphTargetsRelative = geometries[0].morphTargetsRelative;\r\n\r\n var mergedGeometry = new BufferGeometry();\r\n\r\n var offset = 0;\r\n\r\n for (var i = 0; i < geometries.length; ++i) {\r\n var geometry = geometries[i];\r\n var attributesCount = 0;\r\n\r\n // ensure that all geometries are indexed, or none\r\n\r\n if (isIndexed !== (geometry.index !== null)) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.'\r\n );\r\n return null;\r\n }\r\n\r\n // gather attributes, exit early if they're different\r\n\r\n for (var name in geometry.attributes) {\r\n if (!attributesUsed.has(name)) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. All geometries must have compatible attributes; make sure \"' +\r\n name +\r\n '\" attribute exists among all geometries, or in none of them.'\r\n );\r\n return null;\r\n }\r\n\r\n if (attributes[name] === undefined) attributes[name] = [];\r\n\r\n attributes[name].push(geometry.attributes[name]);\r\n\r\n attributesCount++;\r\n }\r\n\r\n // ensure geometries have the same number of attributes\r\n\r\n if (attributesCount !== attributesUsed.size) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. Make sure all geometries have the same number of attributes.'\r\n );\r\n return null;\r\n }\r\n\r\n // gather morph attributes, exit early if they're different\r\n\r\n if (morphTargetsRelative !== geometry.morphTargetsRelative) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. .morphTargetsRelative must be consistent throughout all geometries.'\r\n );\r\n return null;\r\n }\r\n\r\n for (var name in geometry.morphAttributes) {\r\n if (!morphAttributesUsed.has(name)) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. .morphAttributes must be consistent throughout all geometries.'\r\n );\r\n return null;\r\n }\r\n\r\n if (morphAttributes[name] === undefined) morphAttributes[name] = [];\r\n\r\n morphAttributes[name].push(geometry.morphAttributes[name]);\r\n }\r\n\r\n // gather .userData\r\n\r\n mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || [];\r\n mergedGeometry.userData.mergedUserData.push(geometry.userData);\r\n\r\n if (useGroups) {\r\n var count;\r\n\r\n if (isIndexed) {\r\n count = geometry.index.count;\r\n } else if (geometry.attributes.position !== undefined) {\r\n count = geometry.attributes.position.count;\r\n } else {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' +\r\n i +\r\n '. The geometry must have either an index or a position attribute'\r\n );\r\n return null;\r\n }\r\n\r\n mergedGeometry.addGroup(offset, count, i);\r\n\r\n offset += count;\r\n }\r\n }\r\n\r\n // merge indices\r\n\r\n if (isIndexed) {\r\n var indexOffset = 0;\r\n var mergedIndex = [];\r\n\r\n for (var i = 0; i < geometries.length; ++i) {\r\n var index = geometries[i].index;\r\n\r\n for (var j = 0; j < index.count; ++j) {\r\n mergedIndex.push(index.getX(j) + indexOffset);\r\n }\r\n\r\n indexOffset += geometries[i].attributes.position.count;\r\n }\r\n\r\n mergedGeometry.setIndex(mergedIndex);\r\n }\r\n\r\n // merge attributes\r\n\r\n for (var name in attributes) {\r\n var mergedAttribute = this.mergeBufferAttributes(attributes[name]);\r\n\r\n if (!mergedAttribute) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' +\r\n name +\r\n ' attribute.'\r\n );\r\n return null;\r\n }\r\n\r\n mergedGeometry.setAttribute(name, mergedAttribute);\r\n }\r\n\r\n // merge morph attributes\r\n\r\n for (var name in morphAttributes) {\r\n var numMorphTargets = morphAttributes[name][0].length;\r\n\r\n if (numMorphTargets === 0) break;\r\n\r\n mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};\r\n mergedGeometry.morphAttributes[name] = [];\r\n\r\n for (var i = 0; i < numMorphTargets; ++i) {\r\n var morphAttributesToMerge = [];\r\n\r\n for (var j = 0; j < morphAttributes[name].length; ++j) {\r\n morphAttributesToMerge.push(morphAttributes[name][j][i]);\r\n }\r\n\r\n var mergedMorphAttribute = this.mergeBufferAttributes(morphAttributesToMerge);\r\n\r\n if (!mergedMorphAttribute) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' +\r\n name +\r\n ' morphAttribute.'\r\n );\r\n return null;\r\n }\r\n\r\n mergedGeometry.morphAttributes[name].push(mergedMorphAttribute);\r\n }\r\n }\r\n\r\n return mergedGeometry;\r\n },\r\n\r\n /**\r\n * @param {Array<BufferAttribute>} attributes\r\n * @return {BufferAttribute}\r\n */\r\n mergeBufferAttributes: function (attributes) {\r\n var TypedArray;\r\n var itemSize;\r\n var normalized;\r\n var arrayLength = 0;\r\n\r\n for (var i = 0; i < attributes.length; ++i) {\r\n var attribute = attributes[i];\r\n\r\n if (attribute.isInterleavedBufferAttribute) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.'\r\n );\r\n return null;\r\n }\r\n\r\n if (TypedArray === undefined) TypedArray = attribute.array.constructor;\r\n if (TypedArray !== attribute.array.constructor) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.'\r\n );\r\n return null;\r\n }\r\n\r\n if (itemSize === undefined) itemSize = attribute.itemSize;\r\n if (itemSize !== attribute.itemSize) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.'\r\n );\r\n return null;\r\n }\r\n\r\n if (normalized === undefined) normalized = attribute.normalized;\r\n if (normalized !== attribute.normalized) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.'\r\n );\r\n return null;\r\n }\r\n\r\n arrayLength += attribute.array.length;\r\n }\r\n\r\n var array = new TypedArray(arrayLength);\r\n var offset = 0;\r\n\r\n for (var i = 0; i < attributes.length; ++i) {\r\n array.set(attributes[i].array, offset);\r\n\r\n offset += attributes[i].array.length;\r\n }\r\n\r\n return new BufferAttribute(array, itemSize, normalized);\r\n },\r\n\r\n /**\r\n * @param {Array<BufferAttribute>} attributes\r\n * @return {Array<InterleavedBufferAttribute>}\r\n */\r\n interleaveAttributes: function (attributes) {\r\n // Interleaves the provided attributes into an InterleavedBuffer and returns\r\n // a set of InterleavedBufferAttributes for each attribute\r\n var TypedArray;\r\n var arrayLength = 0;\r\n var stride = 0;\r\n\r\n // calculate the the length and type of the interleavedBuffer\r\n for (var i = 0, l = attributes.length; i < l; ++i) {\r\n var attribute = attributes[i];\r\n\r\n if (TypedArray === undefined) TypedArray = attribute.array.constructor;\r\n if (TypedArray !== attribute.array.constructor) {\r\n console.error('AttributeBuffers of different types cannot be interleaved');\r\n return null;\r\n }\r\n\r\n arrayLength += attribute.array.length;\r\n stride += attribute.itemSize;\r\n }\r\n\r\n // Create the set of buffer attributes\r\n var interleavedBuffer = new InterleavedBuffer(new TypedArray(arrayLength), stride);\r\n var offset = 0;\r\n var res = [];\r\n var getters = ['getX', 'getY', 'getZ', 'getW'];\r\n var setters = ['setX', 'setY', 'setZ', 'setW'];\r\n\r\n for (var j = 0, l = attributes.length; j < l; j++) {\r\n var attribute = attributes[j];\r\n var itemSize = attribute.itemSize;\r\n var count = attribute.count;\r\n var iba = new InterleavedBufferAttribute(\r\n interleavedBuffer,\r\n itemSize,\r\n offset,\r\n attribute.normalized\r\n );\r\n res.push(iba);\r\n\r\n offset += itemSize;\r\n\r\n // Move the data for each attribute into the new interleavedBuffer\r\n // at the appropriate offset\r\n for (var c = 0; c < count; c++) {\r\n for (var k = 0; k < itemSize; k++) {\r\n iba[setters[k]](c, attribute[getters[k]](c));\r\n }\r\n }\r\n }\r\n\r\n return res;\r\n },\r\n\r\n /**\r\n * @param {Array<BufferGeometry>} geometry\r\n * @return {number}\r\n */\r\n estimateBytesUsed: function (geometry) {\r\n // Return the estimated memory used by this geometry in bytes\r\n // Calculate using itemSize, count, and BYTES_PER_ELEMENT to account\r\n // for InterleavedBufferAttributes.\r\n var mem = 0;\r\n for (var name in geometry.attributes) {\r\n var attr = geometry.getAttribute(name);\r\n mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n var indices = geometry.getIndex();\r\n mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;\r\n return mem;\r\n },\r\n\r\n /**\r\n * @param {BufferGeometry} geometry\r\n * @param {number} tolerance\r\n * @return {BufferGeometry>}\r\n */\r\n mergeVertices: function (geometry, tolerance = 1e-4) {\r\n tolerance = Math.max(tolerance, Number.EPSILON);\r\n\r\n // Generate an index buffer if the geometry doesn't have one, or optimize it\r\n // if it's already available.\r\n var hashToIndex = {};\r\n var indices = geometry.getIndex();\r\n var positions = geometry.getAttribute('position');\r\n var vertexCount = indices ? indices.count : positions.count;\r\n\r\n // next value for triangle indices\r\n var nextIndex = 0;\r\n\r\n // attributes and new attribute arrays\r\n var attributeNames = Object.keys(geometry.attributes);\r\n var attrArrays = {};\r\n var morphAttrsArrays = {};\r\n var newIndices = [];\r\n var getters = ['getX', 'getY', 'getZ', 'getW'];\r\n\r\n // initialize the arrays\r\n for (var i = 0, l = attributeNames.length; i < l; i++) {\r\n var name = attributeNames[i];\r\n\r\n attrArrays[name] = [];\r\n\r\n var morphAttr = geometry.morphAttributes[name];\r\n if (morphAttr) {\r\n morphAttrsArrays[name] = new Array(morphAttr.length).fill().map(() => []);\r\n }\r\n }\r\n\r\n // convert the error tolerance to an amount of decimal places to truncate to\r\n var decimalShift = Math.log10(1 / tolerance);\r\n var shiftMultiplier = Math.pow(10, decimalShift);\r\n for (var i = 0; i < vertexCount; i++) {\r\n var index = indices ? indices.getX(i) : i;\r\n\r\n // Generate a hash for the vertex attributes at the current index 'i'\r\n var hash = '';\r\n for (var j = 0, l = attributeNames.length; j < l; j++) {\r\n var name = attributeNames[j];\r\n var attribute = geometry.getAttribute(name);\r\n var itemSize = attribute.itemSize;\r\n\r\n for (var k = 0; k < itemSize; k++) {\r\n // double tilde truncates the decimal value\r\n hash += `${~~(attribute[getters[k]](index) * shiftMultiplier)},`;\r\n }\r\n }\r\n\r\n // Add another reference to the vertex if it's already\r\n // used by another index\r\n if (hash in hashToIndex) {\r\n newIndices.push(hashToIndex[hash]);\r\n } else {\r\n // copy data to the new index in the attribute arrays\r\n for (var j = 0, l = attributeNames.length; j < l; j++) {\r\n var name = attributeNames[j];\r\n var attribute = geometry.getAttribute(name);\r\n var morphAttr = geometry.morphAttributes[name];\r\n var itemSize = attribute.itemSize;\r\n var newarray = attrArrays[name];\r\n var newMorphArrays = morphAttrsArrays[name];\r\n\r\n for (var k = 0; k < itemSize; k++) {\r\n var getterFunc = getters[k];\r\n newarray.push(attribute[getterFunc](index));\r\n\r\n if (morphAttr) {\r\n for (var m = 0, ml = morphAttr.length; m < ml; m++) {\r\n newMorphArrays[m].push(morphAttr[m][getterFunc](index));\r\n }\r\n }\r\n }\r\n }\r\n\r\n hashToIndex[hash] = nextIndex;\r\n newIndices.push(nextIndex);\r\n nextIndex++;\r\n }\r\n }\r\n\r\n // Generate typed arrays from new attribute arrays and update\r\n // the attributeBuffers\r\n const result = geometry.clone();\r\n for (var i = 0, l = attributeNames.length; i < l; i++) {\r\n var name = attributeNames[i];\r\n var oldAttribute = geometry.getAttribute(name);\r\n\r\n var buffer = new oldAttribute.array.constructor(attrArrays[name]);\r\n var attribute = new BufferAttribute(buffer, oldAttribute.itemSize, oldAttribute.normalized);\r\n\r\n result.setAttribute(name, attribute);\r\n\r\n // Update the attribute arrays\r\n if (name in morphAttrsArrays) {\r\n for (var j = 0; j < morphAttrsArrays[name].length; j++) {\r\n var oldMorphAttribute = geometry.morphAttributes[name][j];\r\n\r\n var buffer = new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]);\r\n var morphAttribute = new BufferAttribute(\r\n buffer,\r\n oldMorphAttribute.itemSize,\r\n oldMorphAttribute.normalized\r\n );\r\n result.morphAttributes[name][j] = morphAttribute;\r\n }\r\n }\r\n }\r\n\r\n // indices\r\n\r\n result.setIndex(newIndices);\r\n\r\n return result;\r\n },\r\n\r\n /**\r\n * @param {BufferGeometry} geometry\r\n * @param {number} drawMode\r\n * @return {BufferGeometry>}\r\n */\r\n toTrianglesDrawMode: function (geometry, drawMode) {\r\n if (drawMode === TrianglesDrawMode) {\r\n console.warn(\r\n 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.'\r\n );\r\n return geometry;\r\n }\r\n\r\n if (drawMode === TriangleFanDrawMode || drawMode === TriangleStripDrawMode) {\r\n var index = geometry.getIndex();\r\n\r\n // generate index if not present\r\n\r\n if (index === null) {\r\n var indices = [];\r\n\r\n var position = geometry.getAttribute('position');\r\n\r\n if (position !== undefined) {\r\n for (var i = 0; i < position.count; i++) {\r\n indices.push(i);\r\n }\r\n\r\n geometry.setIndex(indices);\r\n index = geometry.getIndex();\r\n } else {\r\n console.error(\r\n 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.'\r\n );\r\n return geometry;\r\n }\r\n }\r\n\r\n //\r\n\r\n var numberOfTriangles = index.count - 2;\r\n var newIndices = [];\r\n\r\n if (drawMode === TriangleFanDrawMode) {\r\n // gl.TRIANGLE_FAN\r\n\r\n for (var i = 1; i <= numberOfTriangles; i++) {\r\n newIndices.push(index.getX(0));\r\n newIndices.push(index.getX(i));\r\n newIndices.push(index.getX(i + 1));\r\n }\r\n } else {\r\n // gl.TRIANGLE_STRIP\r\n\r\n for (var i = 0; i < numberOfTriangles; i++) {\r\n if (i % 2 === 0) {\r\n newIndices.push(index.getX(i));\r\n newIndices.push(index.getX(i + 1));\r\n newIndices.push(index.getX(i + 2));\r\n } else {\r\n newIndices.push(index.getX(i + 2));\r\n newIndices.push(index.getX(i + 1));\r\n newIndices.push(index.getX(i));\r\n }\r\n }\r\n }\r\n\r\n if (newIndices.length / 3 !== numberOfTriangles) {\r\n console.error(\r\n 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.'\r\n );\r\n }\r\n\r\n // build final geometry\r\n\r\n var newGeometry = geometry.clone();\r\n newGeometry.setIndex(newIndices);\r\n newGeometry.clearGroups();\r\n\r\n return newGeometry;\r\n }\r\n\r\n console.error('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode);\r\n return geometry;\r\n },\r\n};\r\n\r\nexport { BufferGeometryUtils };\r\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 */\r\n\r\nimport {\r\n AnimationClip,\r\n Bone,\r\n Box3,\r\n BufferAttribute,\r\n BufferGeometry,\r\n ClampToEdgeWrapping,\r\n Color,\r\n DirectionalLight,\r\n DoubleSide,\r\n FileLoader,\r\n FrontSide,\r\n Group,\r\n InterleavedBuffer,\r\n InterleavedBufferAttribute,\r\n Interpolant,\r\n InterpolateDiscrete,\r\n InterpolateLinear,\r\n Line,\r\n LineBasicMaterial,\r\n LineLoop,\r\n LineSegments,\r\n LinearFilter,\r\n LinearMipmapLinearFilter,\r\n LinearMipmapNearestFilter,\r\n Loader,\r\n LoaderUtils,\r\n Material,\r\n MathUtils,\r\n Matrix4,\r\n Mesh,\r\n MeshBasicMaterial,\r\n MeshPhysicalMaterial,\r\n MeshStandardMaterial,\r\n MirroredRepeatWrapping,\r\n NearestFilter,\r\n NearestMipmapLinearFilter,\r\n NearestMipmapNearestFilter,\r\n NumberKeyframeTrack,\r\n Object3D,\r\n OrthographicCamera,\r\n PerspectiveCamera,\r\n PointLight,\r\n Points,\r\n PointsMaterial,\r\n PropertyBinding,\r\n QuaternionKeyframeTrack,\r\n RGBAFormat,\r\n RGBFormat,\r\n RepeatWrapping,\r\n Skeleton,\r\n SkinnedMesh,\r\n Sphere,\r\n SpotLight,\r\n TangentSpaceNormalMap,\r\n TextureLoader,\r\n TriangleFanDrawMode,\r\n TriangleStripDrawMode,\r\n Vector2,\r\n Vector3,\r\n VectorKeyframeTrack,\r\n sRGBEncoding\r\n} from 'three';\r\n\r\nconst GLTFLoader = (function () {\r\n function GLTFLoader(manager) {\r\n Loader.call(this, manager);\r\n\r\n this.dracoLoader = null;\r\n this.ddsLoader = null;\r\n }\r\n\r\n GLTFLoader.prototype = Object.assign(Object.create(Loader.prototype), {\r\n constructor: GLTFLoader,\r\n\r\n load: function (url, onLoad, onProgress, onError) {\r\n var scope = this;\r\n\r\n var resourcePath;\r\n\r\n if (this.resourcePath !== '') {\r\n resourcePath = this.resourcePath;\r\n } else if (this.path !== '') {\r\n resourcePath = this.path;\r\n } else {\r\n resourcePath = LoaderUtils.extractUrlBase(url);\r\n }\r\n\r\n // Tells the LoadingManager to track an extra item, which resolves after\r\n // the model is fully loaded. This means the count of items loaded will\r\n // be incorrect, but ensures manager.onLoad() does not fire early.\r\n scope.manager.itemStart(url);\r\n\r\n var _onError = function (e) {\r\n if (onError) {\r\n onError(e);\r\n } else {\r\n console.error(e);\r\n }\r\n\r\n scope.manager.itemError(url);\r\n scope.manager.itemEnd(url);\r\n };\r\n\r\n var loader = new FileLoader(scope.manager);\r\n\r\n loader.setPath(this.path);\r\n loader.setResponseType('arraybuffer');\r\n\r\n if (scope.crossOrigin === 'use-credentials') {\r\n loader.setWithCredentials(true);\r\n }\r\n\r\n loader.load(\r\n url,\r\n function (data) {\r\n try {\r\n scope.parse(\r\n data,\r\n resourcePath,\r\n function (gltf) {\r\n onLoad(gltf);\r\n\r\n scope.manager.itemEnd(url);\r\n },\r\n _onError\r\n );\r\n } catch (e) {\r\n _onError(e);\r\n }\r\n },\r\n onProgress,\r\n _onError\r\n );\r\n },\r\n\r\n setDRACOLoader: function (dracoLoader) {\r\n this.dracoLoader = dracoLoader;\r\n return this;\r\n },\r\n\r\n setDDSLoader: function (ddsLoader) {\r\n this.ddsLoader = ddsLoader;\r\n return this;\r\n },\r\n\r\n parse: function (data, path, onLoad, onError) {\r\n var content;\r\n var extensions = {};\r\n\r\n if (typeof data === 'string') {\r\n content = data;\r\n } else {\r\n var magic = LoaderUtils.decodeText(new Uint8Array(data, 0, 4));\r\n\r\n if (magic === BINARY_EXTENSION_HEADER_MAGIC) {\r\n try {\r\n extensions[EXTENSIONS.KHR_BINARY_GLTF] = new GLTFBinaryExtension(data);\r\n } catch (error) {\r\n if (onError) onError(error);\r\n return;\r\n }\r\n\r\n content = extensions[EXTENSIONS.KHR_BINARY_GLTF].content;\r\n } else {\r\n content = LoaderUtils.decodeText(new Uint8Array(data));\r\n }\r\n }\r\n\r\n var json = JSON.parse(content);\r\n\r\n if (json.asset === undefined || json.asset.version[0] < 2) {\r\n if (onError)\r\n onError(\r\n new Error('THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.')\r\n );\r\n return;\r\n }\r\n\r\n if (json.extensionsUsed) {\r\n for (var i = 0; i < json.extensionsUsed.length; ++i) {\r\n var extensionName = json.extensionsUsed[i];\r\n var extensionsRequired = json.extensionsRequired || [];\r\n\r\n switch (extensionName) {\r\n case EXTENSIONS.KHR_LIGHTS_PUNCTUAL:\r\n extensions[extensionName] = new GLTFLightsExtension(json);\r\n break;\r\n\r\n case EXTENSIONS.KHR_MATERIALS_CLEARCOAT:\r\n extensions[extensionName] = new GLTFMaterialsClearcoatExtension();\r\n break;\r\n\r\n case EXTENSIONS.KHR_MATERIALS_UNLIT:\r\n extensions[extensionName] = new GLTFMaterialsUnlitExtension();\r\n break;\r\n\r\n case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:\r\n extensions[extensionName] = new GLTFMaterialsPbrSpecularGlossinessExtension();\r\n break;\r\n\r\n case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:\r\n extensions[extensionName] = new GLTFDracoMeshCompressionExtension(\r\n json,\r\n this.dracoLoader\r\n );\r\n break;\r\n\r\n case EXTENSIONS.MSFT_TEXTURE_DDS:\r\n extensions[extensionName] = new GLTFTextureDDSExtension(this.ddsLoader);\r\n break;\r\n\r\n case EXTENSIONS.KHR_TEXTURE_TRANSFORM:\r\n extensions[extensionName] = new GLTFTextureTransformExtension();\r\n break;\r\n\r\n case EXTENSIONS.KHR_MESH_QUANTIZATION:\r\n extensions[extensionName] = new GLTFMeshQuantizationExtension();\r\n break;\r\n\r\n default:\r\n if (extensionsRequired.indexOf(extensionName) >= 0) {\r\n console.warn('THREE.GLTFLoader: Unknown extension \"' + extensionName + '\".');\r\n }\r\n }\r\n }\r\n }\r\n\r\n var parser = new GLTFParser(json, extensions, {\r\n path: path || this.resourcePath || '',\r\n crossOrigin: this.crossOrigin,\r\n manager: this.manager\r\n });\r\n\r\n parser.parse(onLoad, onError);\r\n },\r\n });\r\n\r\n /* GLTFREGISTRY */\r\n\r\n function GLTFRegistry() {\r\n var objects = {};\r\n\r\n return {\r\n get: function (key) {\r\n return objects[key];\r\n },\r\n\r\n add: function (key, object) {\r\n objects[key] = object;\r\n },\r\n\r\n remove: function (key) {\r\n delete objects[key];\r\n },\r\n\r\n removeAll: function () {\r\n objects = {};\r\n },\r\n };\r\n }\r\n\r\n /*********************************/\r\n /********** EXTENSIONS ***********/\r\n /*********************************/\r\n\r\n var EXTENSIONS = {\r\n KHR_BINARY_GLTF: 'KHR_binary_glTF',\r\n KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',\r\n KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',\r\n KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',\r\n KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',\r\n KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',\r\n KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',\r\n KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',\r\n MSFT_TEXTURE_DDS: 'MSFT_texture_dds'\r\n };\r\n\r\n /**\r\n * DDS Texture Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds\r\n *\r\n */\r\n function GLTFTextureDDSExtension(ddsLoader) {\r\n if (!ddsLoader) {\r\n throw new Error(\r\n 'THREE.GLTFLoader: Attempting to load .dds texture without importing DDSLoader'\r\n );\r\n }\r\n\r\n this.name = EXTENSIONS.MSFT_TEXTURE_DDS;\r\n this.ddsLoader = ddsLoader;\r\n }\r\n\r\n /**\r\n * Punctual Lights Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual\r\n */\r\n function GLTFLightsExtension(json) {\r\n this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;\r\n\r\n var extension = (json.extensions && json.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL]) || {};\r\n this.lightDefs = extension.lights || [];\r\n }\r\n\r\n GLTFLightsExtension.prototype.loadLight = function (lightIndex) {\r\n var lightDef = this.lightDefs[lightIndex];\r\n var lightNode;\r\n\r\n var color = new Color(0xffffff);\r\n if (lightDef.color !== undefined) color.fromArray(lightDef.color);\r\n\r\n var range = lightDef.range !== undefined ? lightDef.range : 0;\r\n\r\n switch (lightDef.type) {\r\n case 'directional':\r\n lightNode = new DirectionalLight(color);\r\n lightNode.target.position.set(0, 0, -1);\r\n lightNode.add(lightNode.target);\r\n break;\r\n\r\n case 'point':\r\n lightNode = new PointLight(color);\r\n lightNode.distance = range;\r\n break;\r\n\r\n case 'spot':\r\n lightNode = new SpotLight(color);\r\n lightNode.distance = range;\r\n // Handle spotlight properties.\r\n lightDef.spot = lightDef.spot || {};\r\n lightDef.spot.innerConeAngle =\r\n lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;\r\n lightDef.spot.outerConeAngle =\r\n lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;\r\n lightNode.angle = lightDef.spot.outerConeAngle;\r\n lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;\r\n lightNode.target.position.set(0, 0, -1);\r\n lightNode.add(lightNode.target);\r\n break;\r\n\r\n default:\r\n throw new Error('THREE.GLTFLoader: Unexpected light type, \"' + lightDef.type + '\".');\r\n }\r\n\r\n // Some lights (e.g. spot) default to a position other than the origin. Reset the position\r\n // here, because node-level parsing will only override position if explicitly specified.\r\n lightNode.position.set(0, 0, 0);\r\n\r\n lightNode.decay = 2;\r\n\r\n if (lightDef.intensity !== undefined) lightNode.intensity = lightDef.intensity;\r\n\r\n lightNode.name = lightDef.name || 'light_' + lightIndex;\r\n\r\n return Promise.resolve(lightNode);\r\n };\r\n\r\n /**\r\n * Unlit Materials Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit\r\n */\r\n function GLTFMaterialsUnlitExtension() {\r\n this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;\r\n }\r\n\r\n GLTFMaterialsUnlitExtension.prototype.getMaterialType = function () {\r\n return MeshBasicMaterial;\r\n };\r\n\r\n GLTFMaterialsUnlitExtension.prototype.extendParams = function (\r\n materialParams,\r\n materialDef,\r\n parser\r\n ) {\r\n var pending = [];\r\n\r\n materialParams.color = new Color(1.0, 1.0, 1.0);\r\n materialParams.opacity = 1.0;\r\n\r\n var metallicRoughness = materialDef.pbrMetallicRoughness;\r\n\r\n if (metallicRoughness) {\r\n if (Array.isArray(metallicRoughness.baseColorFactor)) {\r\n var array = metallicRoughness.baseColorFactor;\r\n\r\n materialParams.color.fromArray(array);\r\n materialParams.opacity = array[3];\r\n }\r\n\r\n if (metallicRoughness.baseColorTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture)\r\n );\r\n }\r\n }\r\n\r\n return Promise.all(pending);\r\n };\r\n\r\n /**\r\n * Clearcoat Materials Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat\r\n */\r\n function GLTFMaterialsClearcoatExtension() {\r\n this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;\r\n }\r\n\r\n GLTFMaterialsClearcoatExtension.prototype.getMaterialType = function () {\r\n return MeshPhysicalMaterial;\r\n };\r\n\r\n GLTFMaterialsClearcoatExtension.prototype.extendParams = function (\r\n materialParams,\r\n materialDef,\r\n parser\r\n ) {\r\n var pending = [];\r\n\r\n var extension = materialDef.extensions[this.name];\r\n\r\n if (extension.clearcoatFactor !== undefined) {\r\n materialParams.clearcoat = extension.clearcoatFactor;\r\n }\r\n\r\n if (extension.clearcoatTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(materialParams, 'clearcoatMap', extension.clearcoatTexture)\r\n );\r\n }\r\n\r\n if (extension.clearcoatRoughnessFactor !== undefined) {\r\n materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;\r\n }\r\n\r\n if (extension.clearcoatRoughnessTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(\r\n materialParams,\r\n 'clearcoatRoughnessMap',\r\n extension.clearcoatRoughnessTexture\r\n )\r\n );\r\n }\r\n\r\n if (extension.clearcoatNormalTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(\r\n materialParams,\r\n 'clearcoatNormalMap',\r\n extension.clearcoatNormalTexture\r\n )\r\n );\r\n\r\n if (extension.clearcoatNormalTexture.scale !== undefined) {\r\n var scale = extension.clearcoatNormalTexture.scale;\r\n\r\n materialParams.clearcoatNormalScale = new Vector2(scale, scale);\r\n }\r\n }\r\n\r\n return Promise.all(pending);\r\n };\r\n\r\n /* BINARY EXTENSION */\r\n var BINARY_EXTENSION_HEADER_MAGIC = 'glTF';\r\n var BINARY_EXTENSION_HEADER_LENGTH = 12;\r\n var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4e4f534a, BIN: 0x004e4942 };\r\n\r\n function GLTFBinaryExtension(data) {\r\n this.name = EXTENSIONS.KHR_BINARY_GLTF;\r\n this.content = null;\r\n this.body = null;\r\n\r\n var headerView = new DataView(data, 0, BINARY_EXTENSION_HEADER_LENGTH);\r\n\r\n this.header = {\r\n magic: LoaderUtils.decodeText(new Uint8Array(data.slice(0, 4))),\r\n version: headerView.getUint32(4, true),\r\n length: headerView.getUint32(8, true)\r\n };\r\n\r\n if (this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC) {\r\n throw new Error('THREE.GLTFLoader: Unsupported glTF-Binary header.');\r\n } else if (this.header.version < 2.0) {\r\n throw new Error('THREE.GLTFLoader: Legacy binary file detected.');\r\n }\r\n\r\n var chunkView = new DataView(data, BINARY_EXTENSION_HEADER_LENGTH);\r\n var chunkIndex = 0;\r\n\r\n while (chunkIndex < chunkView.byteLength) {\r\n var chunkLength = chunkView.getUint32(chunkIndex, true);\r\n chunkIndex += 4;\r\n\r\n var chunkType = chunkView.getUint32(chunkIndex, true);\r\n chunkIndex += 4;\r\n\r\n if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON) {\r\n var contentArray = new Uint8Array(\r\n data,\r\n BINARY_EXTENSION_HEADER_LENGTH + chunkIndex,\r\n chunkLength\r\n );\r\n this.content = LoaderUtils.decodeText(contentArray);\r\n } else if (chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN) {\r\n var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;\r\n this.body = data.slice(byteOffset, byteOffset + chunkLength);\r\n }\r\n\r\n // Clients must ignore chunks with unknown types.\r\n\r\n chunkIndex += chunkLength;\r\n }\r\n\r\n if (this.content === null) {\r\n throw new Error('THREE.GLTFLoader: JSON content not found.');\r\n }\r\n }\r\n\r\n /**\r\n * DRACO Mesh Compression Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression\r\n */\r\n function GLTFDracoMeshCompressionExtension(json, dracoLoader) {\r\n if (!dracoLoader) {\r\n throw new Error('THREE.GLTFLoader: No DRACOLoader instance provided.');\r\n }\r\n\r\n this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;\r\n this.json = json;\r\n this.dracoLoader = dracoLoader;\r\n this.dracoLoader.preload();\r\n }\r\n\r\n GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function (primitive, parser) {\r\n var json = this.json;\r\n var dracoLoader = this.dracoLoader;\r\n var bufferViewIndex = primitive.extensions[this.name].bufferView;\r\n var gltfAttributeMap = primitive.extensions[this.name].attributes;\r\n var threeAttributeMap = {};\r\n var attributeNormalizedMap = {};\r\n var attributeTypeMap = {};\r\n\r\n for (var attributeName in gltfAttributeMap) {\r\n var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();\r\n\r\n threeAttributeMap[threeAttributeName] = gltfAttributeMap[attributeName];\r\n }\r\n\r\n for (attributeName in primitive.attributes) {\r\n var threeAttributeName = ATTRIBUTES[attributeName] || attributeName.toLowerCase();\r\n\r\n if (gltfAttributeMap[attributeName] !== undefined) {\r\n var accessorDef = json.accessors[primitive.attributes[attributeName]];\r\n var componentType = WEBGL_COMPONENT_TYPES[accessorDef.componentType];\r\n\r\n attributeTypeMap[threeAttributeName] = componentType;\r\n attributeNormalizedMap[threeAttributeName] = accessorDef.normalized === true;\r\n }\r\n }\r\n\r\n return parser.getDependency('bufferView', bufferViewIndex).then(function (bufferView) {\r\n return new Promise(function (resolve) {\r\n dracoLoader.decodeDracoFile(\r\n bufferView,\r\n function (geometry) {\r\n for (var attributeName in geometry.attributes) {\r\n var attribute = geometry.attributes[attributeName];\r\n var normalized = attributeNormalizedMap[attributeName];\r\n\r\n if (normalized !== undefined) attribute.normalized = normalized;\r\n }\r\n\r\n resolve(geometry);\r\n },\r\n threeAttributeMap,\r\n attributeTypeMap\r\n );\r\n });\r\n });\r\n };\r\n\r\n /**\r\n * Texture Transform Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform\r\n */\r\n function GLTFTextureTransformExtension() {\r\n this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;\r\n }\r\n\r\n GLTFTextureTransformExtension.prototype.extendTexture = function (texture, transform) {\r\n texture = texture.clone();\r\n\r\n if (transform.offset !== undefined) {\r\n texture.offset.fromArray(transform.offset);\r\n }\r\n\r\n if (transform.rotation !== undefined) {\r\n texture.rotation = transform.rotation;\r\n }\r\n\r\n if (transform.scale !== undefined) {\r\n texture.repeat.fromArray(transform.scale);\r\n }\r\n\r\n if (transform.texCoord !== undefined) {\r\n console.warn(\r\n 'THREE.GLTFLoader: Custom UV sets in \"' + this.name + '\" extension not yet supported.'\r\n );\r\n }\r\n\r\n texture.needsUpdate = true;\r\n\r\n return texture;\r\n };\r\n\r\n /**\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 */\r\n\r\n /**\r\n * A sub class of StandardMaterial with some of the functionality\r\n * changed via the `onBeforeCompile` callback\r\n * @pailhead\r\n */\r\n\r\n function GLTFMeshStandardSGMaterial(params) {\r\n MeshStandardMaterial.call(this);\r\n\r\n this.isGLTFSpecularGlossinessMaterial = true;\r\n\r\n //various chunks that need replacing\r\n var specularMapParsFragmentChunk = [\r\n '#ifdef USE_SPECULARMAP',\r\n '\tuniform sampler2D specularMap;',\r\n '#endif',\r\n ].join('\\n');\r\n\r\n var glossinessMapParsFragmentChunk = [\r\n '#ifdef USE_GLOSSINESSMAP',\r\n '\tuniform sampler2D glossinessMap;',\r\n '#endif',\r\n ].join('\\n');\r\n\r\n var specularMapFragmentChunk = [\r\n 'vec3 specularFactor = specular;',\r\n '#ifdef USE_SPECULARMAP',\r\n '\tvec4 texelSpecular = texture2D( specularMap, vUv );',\r\n '\ttexelSpecular = sRGBToLinear( texelSpecular );',\r\n '\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',\r\n '\tspecularFactor *= texelSpecular.rgb;',\r\n '#endif',\r\n ].join('\\n');\r\n\r\n var glossinessMapFragmentChunk = [\r\n 'float glossinessFactor = glossiness;',\r\n '#ifdef USE_GLOSSINESSMAP',\r\n '\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );',\r\n '\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',\r\n '\tglossinessFactor *= texelGlossiness.a;',\r\n '#endif',\r\n ].join('\\n');\r\n\r\n var lightPhysicalFragmentChunk = [\r\n 'PhysicalMaterial material;',\r\n 'material.diffuseColor = diffuseColor.rgb;',\r\n 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',\r\n 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',\r\n 'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',\r\n 'material.specularRoughness += geometryRoughness;',\r\n 'material.specularRoughness = min( material.specularRoughness, 1.0 );',\r\n 'material.specularColor = specularFactor.rgb;',\r\n ].join('\\n');\r\n\r\n var uniforms = {\r\n specular: { value: new Color().setHex(0xffffff) },\r\n glossiness: { value: 1 },\r\n specularMap: { value: null },\r\n glossinessMap: { value: null },\r\n };\r\n\r\n this._extraUniforms = uniforms;\r\n\r\n // please see #14031 or #13198 for an alternate approach\r\n this.onBeforeCompile = function (shader) {\r\n for (var uniformName in uniforms) {\r\n shader.uniforms[uniformName] = uniforms[uniformName];\r\n }\r\n\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n 'uniform float roughness;',\r\n 'uniform vec3 specular;'\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n 'uniform float metalness;',\r\n 'uniform float glossiness;'\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n '#include <roughnessmap_pars_fragment>',\r\n specularMapParsFragmentChunk\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n '#include <metalnessmap_pars_fragment>',\r\n glossinessMapParsFragmentChunk\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n '#include <roughnessmap_fragment>',\r\n specularMapFragmentChunk\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n '#include <metalnessmap_fragment>',\r\n glossinessMapFragmentChunk\r\n );\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n '#include <lights_physical_fragment>',\r\n lightPhysicalFragmentChunk\r\n );\r\n };\r\n\r\n /*eslint-disable*/\r\n Object.defineProperties(this, {\r\n specular: {\r\n get: function () {\r\n return uniforms.specular.value;\r\n },\r\n set: function (v) {\r\n uniforms.specular.value = v;\r\n },\r\n },\r\n specularMap: {\r\n get: function () {\r\n return uniforms.specularMap.value;\r\n },\r\n set: function (v) {\r\n uniforms.specularMap.value = v;\r\n },\r\n },\r\n glossiness: {\r\n get: function () {\r\n return uniforms.glossiness.value;\r\n },\r\n set: function (v) {\r\n uniforms.glossiness.value = v;\r\n },\r\n },\r\n glossinessMap: {\r\n get: function () {\r\n return uniforms.glossinessMap.value;\r\n },\r\n set: function (v) {\r\n uniforms.glossinessMap.value = v;\r\n //how about something like this - @pailhead\r\n if (v) {\r\n this.defines.USE_GLOSSINESSMAP = '';\r\n // set USE_ROUGHNESSMAP to enable vUv\r\n this.defines.USE_ROUGHNESSMAP = '';\r\n } else {\r\n delete this.defines.USE_ROUGHNESSMAP;\r\n delete this.defines.USE_GLOSSINESSMAP;\r\n }\r\n },\r\n },\r\n });\r\n\r\n /*eslint-enable*/\r\n delete this.metalness;\r\n delete this.roughness;\r\n delete this.metalnessMap;\r\n delete this.roughnessMap;\r\n\r\n this.setValues(params);\r\n }\r\n\r\n GLTFMeshStandardSGMaterial.prototype = Object.create(MeshStandardMaterial.prototype);\r\n GLTFMeshStandardSGMaterial.prototype.constructor = GLTFMeshStandardSGMaterial;\r\n\r\n GLTFMeshStandardSGMaterial.prototype.copy = function (source) {\r\n MeshStandardMaterial.prototype.copy.call(this, source);\r\n this.specularMap = source.specularMap;\r\n this.specular.copy(source.specular);\r\n this.glossinessMap = source.glossinessMap;\r\n this.glossiness = source.glossiness;\r\n delete this.metalness;\r\n delete this.roughness;\r\n delete this.metalnessMap;\r\n delete this.roughnessMap;\r\n return this;\r\n };\r\n\r\n function GLTFMaterialsPbrSpecularGlossinessExtension() {\r\n return {\r\n name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,\r\n\r\n specularGlossinessParams: [\r\n 'color',\r\n 'map',\r\n 'lightMap',\r\n 'lightMapIntensity',\r\n 'aoMap',\r\n 'aoMapIntensity',\r\n 'emissive',\r\n 'emissiveIntensity',\r\n 'emissiveMap',\r\n 'bumpMap',\r\n 'bumpScale',\r\n 'normalMap',\r\n 'normalMapType',\r\n 'displacementMap',\r\n 'displacementScale',\r\n 'displacementBias',\r\n 'specularMap',\r\n 'specular',\r\n 'glossinessMap',\r\n 'glossiness',\r\n 'alphaMap',\r\n 'envMap',\r\n 'envMapIntensity',\r\n 'refractionRatio',\r\n ],\r\n\r\n getMaterialType: function () {\r\n return GLTFMeshStandardSGMaterial;\r\n },\r\n\r\n extendParams: function (materialParams, materialDef, parser) {\r\n var pbrSpecularGlossiness = materialDef.extensions[this.name];\r\n\r\n materialParams.color = new Color(1.0, 1.0, 1.0);\r\n materialParams.opacity = 1.0;\r\n\r\n var pending = [];\r\n\r\n if (Array.isArray(pbrSpecularGlossiness.diffuseFactor)) {\r\n var array = pbrSpecularGlossiness.diffuseFactor;\r\n\r\n materialParams.color.fromArray(array);\r\n materialParams.opacity = array[3];\r\n }\r\n\r\n if (pbrSpecularGlossiness.diffuseTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(materialParams, 'map', pbrSpecularGlossiness.diffuseTexture)\r\n );\r\n }\r\n\r\n materialParams.emissive = new Color(0.0, 0.0, 0.0);\r\n materialParams.glossiness =\r\n pbrSpecularGlossiness.glossinessFactor !== undefined\r\n ? pbrSpecularGlossiness.glossinessFactor\r\n : 1.0;\r\n materialParams.specular = new Color(1.0, 1.0, 1.0);\r\n\r\n if (Array.isArray(pbrSpecularGlossiness.specularFactor)) {\r\n materialParams.specular.fromArray(pbrSpecularGlossiness.specularFactor);\r\n }\r\n\r\n if (pbrSpecularGlossiness.specularGlossinessTexture !== undefined) {\r\n var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;\r\n pending.push(parser.assignTexture(materialParams, 'glossinessMap', specGlossMapDef));\r\n pending.push(parser.assignTexture(materialParams, 'specularMap', specGlossMapDef));\r\n }\r\n\r\n return Promise.all(pending);\r\n },\r\n\r\n createMaterial: function (materialParams) {\r\n var material = new GLTFMeshStandardSGMaterial(materialParams);\r\n material.fog = true;\r\n\r\n material.color = materialParams.color;\r\n\r\n material.map = materialParams.map === undefined ? null : materialParams.map;\r\n\r\n material.lightMap = null;\r\n material.lightMapIntensity = 1.0;\r\n\r\n material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;\r\n material.aoMapIntensity = 1.0;\r\n\r\n material.emissive = materialParams.emissive;\r\n material.emissiveIntensity = 1.0;\r\n material.emissiveMap =\r\n materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;\r\n\r\n material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;\r\n material.bumpScale = 1;\r\n\r\n material.normalMap =\r\n materialParams.normalMap === undefined ? null : materialParams.normalMap;\r\n material.normalMapType = TangentSpaceNormalMap;\r\n\r\n if (materialParams.normalScale) material.normalScale = materialParams.normalScale;\r\n\r\n material.displacementMap = null;\r\n material.displacementScale = 1;\r\n material.displacementBias = 0;\r\n\r\n material.specularMap =\r\n materialParams.specularMap === undefined ? null : materialParams.specularMap;\r\n material.specular = materialParams.specular;\r\n\r\n material.glossinessMap =\r\n materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;\r\n material.glossiness = materialParams.glossiness;\r\n\r\n material.alphaMap = null;\r\n\r\n material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;\r\n material.envMapIntensity = 1.0;\r\n\r\n material.refractionRatio = 0.98;\r\n\r\n return material;\r\n },\r\n };\r\n }\r\n\r\n /**\r\n * Mesh Quantization Extension\r\n *\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization\r\n */\r\n function GLTFMeshQuantizationExtension() {\r\n this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;\r\n }\r\n\r\n /*********************************/\r\n /********** INTERPOLATION ********/\r\n /*********************************/\r\n\r\n // Spline Interpolation\r\n // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation\r\n function GLTFCubicSplineInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\r\n Interpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\r\n }\r\n\r\n GLTFCubicSplineInterpolant.prototype = Object.create(Interpolant.prototype);\r\n GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;\r\n\r\n GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function (index) {\r\n // Copies a sample value to the result buffer. See description of glTF\r\n // CUBICSPLINE values layout in interpolate_() function below.\r\n\r\n var result = this.resultBuffer,\r\n values = this.sampleValues,\r\n valueSize = this.valueSize,\r\n offset = index * valueSize * 3 + valueSize;\r\n\r\n for (var i = 0; i !== valueSize; i++) {\r\n result[i] = values[offset + i];\r\n }\r\n\r\n return result;\r\n };\r\n\r\n GLTFCubicSplineInterpolant.prototype.beforeStart_ =\r\n GLTFCubicSplineInterpolant.prototype.copySampleValue_;\r\n\r\n GLTFCubicSplineInterpolant.prototype.afterEnd_ =\r\n GLTFCubicSplineInterpolant.prototype.copySampleValue_;\r\n\r\n GLTFCubicSplineInterpolant.prototype.interpolate_ = function (i1, t0, t, t1) {\r\n var result = this.resultBuffer;\r\n var values = this.sampleValues;\r\n var stride = this.valueSize;\r\n\r\n var stride2 = stride * 2;\r\n var stride3 = stride * 3;\r\n\r\n var td = t1 - t0;\r\n\r\n var p = (t - t0) / td;\r\n var pp = p * p;\r\n var ppp = pp * p;\r\n\r\n var offset1 = i1 * stride3;\r\n var offset0 = offset1 - stride3;\r\n\r\n var s2 = -2 * ppp + 3 * pp;\r\n var s3 = ppp - pp;\r\n var s0 = 1 - s2;\r\n var s1 = s3 - pp + p;\r\n\r\n // Layout of keyframe output values for CUBICSPLINE animations:\r\n // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]\r\n for (var i = 0; i !== stride; i++) {\r\n var p0 = values[offset0 + i + stride]; // splineVertex_k\r\n var m0 = values[offset0 + i + stride2] * td; // outTangent_k * (t_k+1 - t_k)\r\n var p1 = values[offset1 + i + stride]; // splineVertex_k+1\r\n var m1 = values[offset1 + i] * td; // inTangent_k+1 * (t_k+1 - t_k)\r\n\r\n result[i] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;\r\n }\r\n\r\n return result;\r\n };\r\n\r\n /*********************************/\r\n /********** INTERNALS ************/\r\n /*********************************/\r\n\r\n /* CONSTANTS */\r\n\r\n var WEBGL_CONSTANTS = {\r\n FLOAT: 5126,\r\n //FLOAT_MAT2: 35674,\r\n FLOAT_MAT3: 35675,\r\n FLOAT_MAT4: 35676,\r\n FLOAT_VEC2: 35664,\r\n FLOAT_VEC3: 35665,\r\n FLOAT_VEC4: 35666,\r\n LINEAR: 9729,\r\n REPEAT: 10497,\r\n SAMPLER_2D: 35678,\r\n POINTS: 0,\r\n LINES: 1,\r\n LINE_LOOP: 2,\r\n LINE_STRIP: 3,\r\n TRIANGLES: 4,\r\n TRIANGLE_STRIP: 5,\r\n TRIANGLE_FAN: 6,\r\n UNSIGNED_BYTE: 5121,\r\n UNSIGNED_SHORT: 5123,\r\n };\r\n\r\n var WEBGL_COMPONENT_TYPES = {\r\n 5120: Int8Array,\r\n 5121: Uint8Array,\r\n 5122: Int16Array,\r\n 5123: Uint16Array,\r\n 5125: Uint32Array,\r\n 5126: Float32Array,\r\n };\r\n\r\n var WEBGL_FILTERS = {\r\n 9728: NearestFilter,\r\n 9729: LinearFilter,\r\n 9984: NearestMipmapNearestFilter,\r\n 9985: LinearMipmapNearestFilter,\r\n 9986: NearestMipmapLinearFilter,\r\n 9987: LinearMipmapLinearFilter,\r\n };\r\n\r\n var WEBGL_WRAPPINGS = {\r\n 33071: ClampToEdgeWrapping,\r\n 33648: MirroredRepeatWrapping,\r\n 10497: RepeatWrapping,\r\n };\r\n\r\n var WEBGL_TYPE_SIZES = {\r\n SCALAR: 1,\r\n VEC2: 2,\r\n VEC3: 3,\r\n VEC4: 4,\r\n MAT2: 4,\r\n MAT3: 9,\r\n MAT4: 16,\r\n };\r\n\r\n var ATTRIBUTES = {\r\n POSITION: 'position',\r\n NORMAL: 'normal',\r\n TANGENT: 'tangent',\r\n TEXCOORD_0: 'uv',\r\n TEXCOORD_1: 'uv2',\r\n COLOR_0: 'color',\r\n WEIGHTS_0: 'skinWeight',\r\n JOINTS_0: 'skinIndex',\r\n };\r\n\r\n var PATH_PROPERTIES = {\r\n scale: 'scale',\r\n translation: 'position',\r\n rotation: 'quaternion',\r\n weights: 'morphTargetInfluences',\r\n };\r\n\r\n var INTERPOLATION = {\r\n CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each\r\n // keyframe track will be initialized with a default interpolation type, then modified.\r\n LINEAR: InterpolateLinear,\r\n STEP: InterpolateDiscrete,\r\n };\r\n\r\n var ALPHA_MODES = {\r\n OPAQUE: 'OPAQUE',\r\n MASK: 'MASK',\r\n BLEND: 'BLEND',\r\n };\r\n\r\n var MIME_TYPE_FORMATS = {\r\n 'image/png': RGBAFormat,\r\n 'image/jpeg': RGBFormat,\r\n };\r\n\r\n /* UTILITY FUNCTIONS */\r\n\r\n function resolveURL(url, path) {\r\n // Invalid URL\r\n if (typeof url !== 'string' || url === '') return '';\r\n\r\n // Host Relative URL\r\n if (/^https?:\\/\\//i.test(path) && /^\\//.test(url)) {\r\n // eslint-disable-next-line no-useless-escape\r\n path = path.replace(/(^https?:\\/\\/[^\\/]+).*/i, '$1');\r\n }\r\n\r\n // Absolute URL http://,https://,//\r\n if (/^(https?:)?\\/\\//i.test(url)) return url;\r\n\r\n // Data URI\r\n if (/^data:.*,.*$/i.test(url)) return url;\r\n\r\n // Blob URL\r\n if (/^blob:.*$/i.test(url)) return url;\r\n\r\n // Relative URL\r\n return path + url;\r\n }\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material\r\n */\r\n function createDefaultMaterial(cache) {\r\n if (cache['DefaultMaterial'] === undefined) {\r\n cache['DefaultMaterial'] = new MeshStandardMaterial({\r\n color: 0xffffff,\r\n emissive: 0x000000,\r\n metalness: 1,\r\n roughness: 1,\r\n transparent: false,\r\n depthTest: true,\r\n side: FrontSide,\r\n });\r\n }\r\n\r\n return cache['DefaultMaterial'];\r\n }\r\n\r\n function addUnknownExtensionsToUserData(knownExtensions, object, objectDef) {\r\n // Add unknown glTF extensions to an object's userData.\r\n\r\n for (var name in objectDef.extensions) {\r\n if (knownExtensions[name] === undefined) {\r\n object.userData.gltfExtensions = object.userData.gltfExtensions || {};\r\n object.userData.gltfExtensions[name] = objectDef.extensions[name];\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @param {Object3D|Material|BufferGeometry} object\r\n * @param {GLTF.definition} gltfDef\r\n */\r\n function assignExtrasToUserData(object, gltfDef) {\r\n if (gltfDef.extras !== undefined) {\r\n if (typeof gltfDef.extras === 'object') {\r\n Object.assign(object.userData, gltfDef.extras);\r\n } else {\r\n console.warn('THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets\r\n *\r\n * @param {BufferGeometry} geometry\r\n * @param {Array<GLTF.Target>} targets\r\n * @param {GLTFParser} parser\r\n * @return {Promise<BufferGeometry>}\r\n */\r\n function addMorphTargets(geometry, targets, parser) {\r\n var hasMorphPosition = false;\r\n var hasMorphNormal = false;\r\n\r\n for (var i = 0, il = targets.length; i < il; i++) {\r\n var target = targets[i];\r\n\r\n if (target.POSITION !== undefined) hasMorphPosition = true;\r\n if (target.NORMAL !== undefined) hasMorphNormal = true;\r\n\r\n if (hasMorphPosition && hasMorphNormal) break;\r\n }\r\n\r\n if (!hasMorphPosition && !hasMorphNormal) return Promise.resolve(geometry);\r\n\r\n var pendingPositionAccessors = [];\r\n var pendingNormalAccessors = [];\r\n\r\n for (var i = 0, il = targets.length; i < il; i++) {\r\n var target = targets[i];\r\n\r\n if (hasMorphPosition) {\r\n var pendingAccessor =\r\n target.POSITION !== undefined\r\n ? parser.getDependency('accessor', target.POSITION)\r\n : geometry.attributes.position;\r\n\r\n pendingPositionAccessors.push(pendingAccessor);\r\n }\r\n\r\n if (hasMorphNormal) {\r\n var pendingAccessor =\r\n target.NORMAL !== undefined\r\n ? parser.getDependency('accessor', target.NORMAL)\r\n : geometry.attributes.normal;\r\n\r\n pendingNormalAccessors.push(pendingAccessor);\r\n }\r\n }\r\n\r\n return Promise.all([\r\n Promise.all(pendingPositionAccessors),\r\n Promise.all(pendingNormalAccessors),\r\n ]).then(function (accessors) {\r\n var morphPositions = accessors[0];\r\n var morphNormals = accessors[1];\r\n\r\n if (hasMorphPosition) geometry.morphAttributes.position = morphPositions;\r\n if (hasMorphNormal) geometry.morphAttributes.normal = morphNormals;\r\n geometry.morphTargetsRelative = true;\r\n\r\n return geometry;\r\n });\r\n }\r\n\r\n /**\r\n * @param {Mesh} mesh\r\n * @param {GLTF.Mesh} meshDef\r\n */\r\n function updateMorphTargets(mesh, meshDef) {\r\n mesh.updateMorphTargets();\r\n\r\n if (meshDef.weights !== undefined) {\r\n for (var i = 0, il = meshDef.weights.length; i < il; i++) {\r\n mesh.morphTargetInfluences[i] = meshDef.weights[i];\r\n }\r\n }\r\n\r\n // .extras has user-defined data, so check that .extras.targetNames is an array.\r\n if (meshDef.extras && Array.isArray(meshDef.extras.targetNames)) {\r\n var targetNames = meshDef.extras.targetNames;\r\n\r\n if (mesh.morphTargetInfluences.length === targetNames.length) {\r\n mesh.morphTargetDictionary = {};\r\n\r\n for (var i = 0, il = targetNames.length; i < il; i++) {\r\n mesh.morphTargetDictionary[targetNames[i]] = i;\r\n }\r\n } else {\r\n console.warn('THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.');\r\n }\r\n }\r\n }\r\n\r\n function createPrimitiveKey(primitiveDef) {\r\n var dracoExtension =\r\n primitiveDef.extensions && primitiveDef.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];\r\n var geometryKey;\r\n\r\n if (dracoExtension) {\r\n geometryKey =\r\n 'draco:' +\r\n dracoExtension.bufferView +\r\n ':' +\r\n dracoExtension.indices +\r\n ':' +\r\n createAttributesKey(dracoExtension.attributes);\r\n } else {\r\n geometryKey =\r\n primitiveDef.indices +\r\n ':' +\r\n createAttributesKey(primitiveDef.attributes) +\r\n ':' +\r\n primitiveDef.mode;\r\n }\r\n\r\n return geometryKey;\r\n }\r\n\r\n function createAttributesKey(attributes) {\r\n var attributesKey = '';\r\n\r\n var keys = Object.keys(attributes).sort();\r\n\r\n for (var i = 0, il = keys.length; i < il; i++) {\r\n attributesKey += keys[i] + ':' + attributes[keys[i]] + ';';\r\n }\r\n\r\n return attributesKey;\r\n }\r\n\r\n /* GLTF PARSER */\r\n\r\n function GLTFParser(json, extensions, options) {\r\n this.json = json || {};\r\n this.extensions = extensions || {};\r\n this.options = options || {};\r\n\r\n // loader object cache\r\n this.cache = new GLTFRegistry();\r\n\r\n // BufferGeometry caching\r\n this.primitiveCache = {};\r\n\r\n this.textureLoader = new TextureLoader(this.options.manager);\r\n this.textureLoader.setCrossOrigin(this.options.crossOrigin);\r\n\r\n this.fileLoader = new FileLoader(this.options.manager);\r\n this.fileLoader.setResponseType('arraybuffer');\r\n\r\n if (this.options.crossOrigin === 'use-credentials') {\r\n this.fileLoader.setWithCredentials(true);\r\n }\r\n }\r\n\r\n GLTFParser.prototype.parse = function (onLoad, onError) {\r\n var parser = this;\r\n var json = this.json;\r\n var extensions = this.extensions;\r\n\r\n // Clear the loader cache\r\n this.cache.removeAll();\r\n\r\n // Mark the special nodes/meshes in json for efficient parse\r\n this.markDefs();\r\n\r\n Promise.all([\r\n this.getDependencies('scene'),\r\n this.getDependencies('animation'),\r\n this.getDependencies('camera'),\r\n ])\r\n .then(function (dependencies) {\r\n var result = {\r\n scene: dependencies[0][json.scene || 0],\r\n scenes: dependencies[0],\r\n animations: dependencies[1],\r\n cameras: dependencies[2],\r\n asset: json.asset,\r\n parser: parser,\r\n userData: {},\r\n };\r\n\r\n addUnknownExtensionsToUserData(extensions, result, json);\r\n\r\n assignExtrasToUserData(result, json);\r\n\r\n onLoad(result);\r\n })\r\n .catch(onError);\r\n };\r\n\r\n /**\r\n * Marks the special nodes/meshes in json for efficient parse.\r\n */\r\n GLTFParser.prototype.markDefs = function () {\r\n var nodeDefs = this.json.nodes || [];\r\n var skinDefs = this.json.skins || [];\r\n var meshDefs = this.json.meshes || [];\r\n\r\n var meshReferences = {};\r\n var meshUses = {};\r\n\r\n // Nothing in the node definition indicates whether it is a Bone or an\r\n // Object3D. Use the skins' joint references to mark bones.\r\n for (var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex++) {\r\n var joints = skinDefs[skinIndex].joints;\r\n\r\n for (var i = 0, il = joints.length; i < il; i++) {\r\n nodeDefs[joints[i]].isBone = true;\r\n }\r\n }\r\n\r\n // Meshes can (and should) be reused by multiple nodes in a glTF asset. To\r\n // avoid having more than one Mesh with the same name, count\r\n // references and rename instances below.\r\n //\r\n // Example: CesiumMilkTruck sample model reuses \"Wheel\" meshes.\r\n for (var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex++) {\r\n var nodeDef = nodeDefs[nodeIndex];\r\n\r\n if (nodeDef.mesh !== undefined) {\r\n if (meshReferences[nodeDef.mesh] === undefined) {\r\n meshReferences[nodeDef.mesh] = meshUses[nodeDef.mesh] = 0;\r\n }\r\n\r\n meshReferences[nodeDef.mesh]++;\r\n\r\n // Nothing in the mesh definition indicates whether it is\r\n // a SkinnedMesh or Mesh. Use the node's mesh reference\r\n // to mark SkinnedMesh if node has skin.\r\n if (nodeDef.skin !== undefined) {\r\n meshDefs[nodeDef.mesh].isSkinnedMesh = true;\r\n }\r\n }\r\n }\r\n\r\n this.json.meshReferences = meshReferences;\r\n this.json.meshUses = meshUses;\r\n };\r\n\r\n /**\r\n * Requests the specified dependency asynchronously, with caching.\r\n * @param {string} type\r\n * @param {number} index\r\n * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}\r\n */\r\n GLTFParser.prototype.getDependency = function (type, index) {\r\n var cacheKey = type + ':' + index;\r\n var dependency = this.cache.get(cacheKey);\r\n\r\n if (!dependency) {\r\n switch (type) {\r\n case 'scene':\r\n dependency = this.loadScene(index);\r\n break;\r\n\r\n case 'node':\r\n dependency = this.loadNode(index);\r\n break;\r\n\r\n case 'mesh':\r\n dependency = this.loadMesh(index);\r\n break;\r\n\r\n case 'accessor':\r\n dependency = this.loadAccessor(index);\r\n break;\r\n\r\n case 'bufferView':\r\n dependency = this.loadBufferView(index);\r\n break;\r\n\r\n case 'buffer':\r\n dependency = this.loadBuffer(index);\r\n break;\r\n\r\n case 'material':\r\n dependency = this.loadMaterial(index);\r\n break;\r\n\r\n case 'texture':\r\n dependency = this.loadTexture(index);\r\n break;\r\n\r\n case 'skin':\r\n dependency = this.loadSkin(index);\r\n break;\r\n\r\n case 'animation':\r\n dependency = this.loadAnimation(index);\r\n break;\r\n\r\n case 'camera':\r\n dependency = this.loadCamera(index);\r\n break;\r\n\r\n case 'light':\r\n dependency = this.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].loadLight(index);\r\n break;\r\n\r\n default:\r\n throw new Error('Unknown type: ' + type);\r\n }\r\n\r\n this.cache.add(cacheKey, dependency);\r\n }\r\n\r\n return dependency;\r\n };\r\n\r\n /**\r\n * Requests all dependencies of the specified type asynchronously, with caching.\r\n * @param {string} type\r\n * @return {Promise<Array<Object>>}\r\n */\r\n GLTFParser.prototype.getDependencies = function (type) {\r\n var dependencies = this.cache.get(type);\r\n\r\n if (!dependencies) {\r\n var parser = this;\r\n var defs = this.json[type + (type === 'mesh' ? 'es' : 's')] || [];\r\n\r\n dependencies = Promise.all(\r\n defs.map(function (def, index) {\r\n return parser.getDependency(type, index);\r\n })\r\n );\r\n\r\n this.cache.add(type, dependencies);\r\n }\r\n\r\n return dependencies;\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views\r\n * @param {number} bufferIndex\r\n * @return {Promise<ArrayBuffer>}\r\n */\r\n GLTFParser.prototype.loadBuffer = function (bufferIndex) {\r\n var bufferDef = this.json.buffers[bufferIndex];\r\n var loader = this.fileLoader;\r\n\r\n if (bufferDef.type && bufferDef.type !== 'arraybuffer') {\r\n throw new Error('THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.');\r\n }\r\n\r\n // If present, GLB container is required to be the first buffer.\r\n if (bufferDef.uri === undefined && bufferIndex === 0) {\r\n return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);\r\n }\r\n\r\n var options = this.options;\r\n\r\n return new Promise(function (resolve, reject) {\r\n loader.load(resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {\r\n reject(new Error('THREE.GLTFLoader: Failed to load buffer \"' + bufferDef.uri + '\".'));\r\n });\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views\r\n * @param {number} bufferViewIndex\r\n * @return {Promise<ArrayBuffer>}\r\n */\r\n GLTFParser.prototype.loadBufferView = function (bufferViewIndex) {\r\n var bufferViewDef = this.json.bufferViews[bufferViewIndex];\r\n\r\n return this.getDependency('buffer', bufferViewDef.buffer).then(function (buffer) {\r\n var byteLength = bufferViewDef.byteLength || 0;\r\n var byteOffset = bufferViewDef.byteOffset || 0;\r\n return buffer.slice(byteOffset, byteOffset + byteLength);\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors\r\n * @param {number} accessorIndex\r\n * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}\r\n */\r\n GLTFParser.prototype.loadAccessor = function (accessorIndex) {\r\n var parser = this;\r\n var json = this.json;\r\n\r\n var accessorDef = this.json.accessors[accessorIndex];\r\n\r\n if (accessorDef.bufferView === undefined && accessorDef.sparse === undefined) {\r\n // Ignore empty accessors, which may be used to declare runtime\r\n // information about attributes coming from another source (e.g. Draco\r\n // compression extension).\r\n return Promise.resolve(null);\r\n }\r\n\r\n var pendingBufferViews = [];\r\n\r\n if (accessorDef.bufferView !== undefined) {\r\n pendingBufferViews.push(this.getDependency('bufferView', accessorDef.bufferView));\r\n } else {\r\n pendingBufferViews.push(null);\r\n }\r\n\r\n if (accessorDef.sparse !== undefined) {\r\n pendingBufferViews.push(\r\n this.getDependency('bufferView', accessorDef.sparse.indices.bufferView)\r\n );\r\n pendingBufferViews.push(\r\n this.getDependency('bufferView', accessorDef.sparse.values.bufferView)\r\n );\r\n }\r\n\r\n return Promise.all(pendingBufferViews).then(function (bufferViews) {\r\n var bufferView = bufferViews[0];\r\n\r\n var itemSize = WEBGL_TYPE_SIZES[accessorDef.type];\r\n var TypedArray = WEBGL_COMPONENT_TYPES[accessorDef.componentType];\r\n\r\n // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.\r\n var elementBytes = TypedArray.BYTES_PER_ELEMENT;\r\n var itemBytes = elementBytes * itemSize;\r\n var byteOffset = accessorDef.byteOffset || 0;\r\n var byteStride =\r\n accessorDef.bufferView !== undefined\r\n ? json.bufferViews[accessorDef.bufferView].byteStride\r\n : undefined;\r\n var normalized = accessorDef.normalized === true;\r\n var array, bufferAttribute;\r\n\r\n // The buffer is not interleaved if the stride is the item size in bytes.\r\n if (byteStride && byteStride !== itemBytes) {\r\n // Each \"slice\" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer\r\n // This makes sure that IBA.count reflects accessor.count properly\r\n var ibSlice = Math.floor(byteOffset / byteStride);\r\n var ibCacheKey =\r\n 'InterleavedBuffer:' +\r\n accessorDef.bufferView +\r\n ':' +\r\n accessorDef.componentType +\r\n ':' +\r\n ibSlice +\r\n ':' +\r\n accessorDef.count;\r\n var ib = parser.cache.get(ibCacheKey);\r\n\r\n if (!ib) {\r\n array = new TypedArray(\r\n bufferView,\r\n ibSlice * byteStride,\r\n (accessorDef.count * byteStride) / elementBytes\r\n );\r\n\r\n // Integer parameters to IB/IBA are in array elements, not bytes.\r\n ib = new InterleavedBuffer(array, byteStride / elementBytes);\r\n\r\n parser.cache.add(ibCacheKey, ib);\r\n }\r\n\r\n bufferAttribute = new InterleavedBufferAttribute(\r\n ib,\r\n itemSize,\r\n (byteOffset % byteStride) / elementBytes,\r\n normalized\r\n );\r\n } else {\r\n if (bufferView === null) {\r\n array = new TypedArray(accessorDef.count * itemSize);\r\n } else {\r\n array = new TypedArray(bufferView, byteOffset, accessorDef.count * itemSize);\r\n }\r\n\r\n bufferAttribute = new BufferAttribute(array, itemSize, normalized);\r\n }\r\n\r\n // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors\r\n if (accessorDef.sparse !== undefined) {\r\n var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;\r\n var TypedArrayIndices = WEBGL_COMPONENT_TYPES[accessorDef.sparse.indices.componentType];\r\n\r\n var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;\r\n var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;\r\n\r\n var sparseIndices = new TypedArrayIndices(\r\n bufferViews[1],\r\n byteOffsetIndices,\r\n accessorDef.sparse.count * itemSizeIndices\r\n );\r\n var sparseValues = new TypedArray(\r\n bufferViews[2],\r\n byteOffsetValues,\r\n accessorDef.sparse.count * itemSize\r\n );\r\n\r\n if (bufferView !== null) {\r\n // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.\r\n bufferAttribute = new BufferAttribute(\r\n bufferAttribute.array.slice(),\r\n bufferAttribute.itemSize,\r\n bufferAttribute.normalized\r\n );\r\n }\r\n\r\n for (var i = 0, il = sparseIndices.length; i < il; i++) {\r\n var index = sparseIndices[i];\r\n\r\n bufferAttribute.setX(index, sparseValues[i * itemSize]);\r\n if (itemSize >= 2) bufferAttribute.setY(index, sparseValues[i * itemSize + 1]);\r\n if (itemSize >= 3) bufferAttribute.setZ(index, sparseValues[i * itemSize + 2]);\r\n if (itemSize >= 4) bufferAttribute.setW(index, sparseValues[i * itemSize + 3]);\r\n if (itemSize >= 5)\r\n throw new Error('THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.');\r\n }\r\n }\r\n\r\n return bufferAttribute;\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures\r\n * @param {number} textureIndex\r\n * @return {Promise<THREE.Texture>}\r\n */\r\n GLTFParser.prototype.loadTexture = function (textureIndex) {\r\n var parser = this;\r\n var json = this.json;\r\n var options = this.options;\r\n var textureLoader = this.textureLoader;\r\n\r\n var URL = self.URL || self.webkitURL;\r\n\r\n var textureDef = json.textures[textureIndex];\r\n\r\n var textureExtensions = textureDef.extensions || {};\r\n\r\n var source;\r\n\r\n if (textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS]) {\r\n source = json.images[textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS].source];\r\n } else {\r\n source = json.images[textureDef.source];\r\n }\r\n\r\n var sourceURI = source.uri;\r\n var isObjectURL = false;\r\n\r\n if (source.bufferView !== undefined) {\r\n // Load binary image data from bufferView, if provided.\r\n\r\n sourceURI = parser.getDependency('bufferView', source.bufferView).then(function (bufferView) {\r\n isObjectURL = true;\r\n var blob = new Blob([bufferView], { type: source.mimeType });\r\n sourceURI = URL.createObjectURL(blob);\r\n return sourceURI;\r\n });\r\n }\r\n\r\n return Promise.resolve(sourceURI)\r\n .then(function (sourceURI) {\r\n // Load Texture resource.\r\n\r\n var loader = options.manager.getHandler(sourceURI);\r\n\r\n if (!loader) {\r\n loader = textureExtensions[EXTENSIONS.MSFT_TEXTURE_DDS]\r\n ? parser.extensions[EXTENSIONS.MSFT_TEXTURE_DDS].ddsLoader\r\n : textureLoader;\r\n }\r\n\r\n return new Promise(function (resolve, reject) {\r\n loader.load(resolveURL(sourceURI, options.path), resolve, undefined, reject);\r\n });\r\n })\r\n .then(function (texture) {\r\n // Clean up resources and configure Texture.\r\n\r\n if (isObjectURL === true) {\r\n URL.revokeObjectURL(sourceURI);\r\n }\r\n\r\n texture.flipY = false;\r\n\r\n if (textureDef.name) texture.name = textureDef.name;\r\n\r\n // Ignore unknown mime types, like DDS files.\r\n if (source.mimeType in MIME_TYPE_FORMATS) {\r\n texture.format = MIME_TYPE_FORMATS[source.mimeType];\r\n }\r\n\r\n var samplers = json.samplers || {};\r\n var sampler = samplers[textureDef.sampler] || {};\r\n\r\n texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;\r\n texture.minFilter = WEBGL_FILTERS[sampler.minFilter] || LinearMipmapLinearFilter;\r\n texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;\r\n texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;\r\n\r\n return texture;\r\n });\r\n };\r\n\r\n /**\r\n * Asynchronously assigns a texture to the given material parameters.\r\n * @param {Object} materialParams\r\n * @param {string} mapName\r\n * @param {Object} mapDef\r\n * @return {Promise}\r\n */\r\n GLTFParser.prototype.assignTexture = function (materialParams, mapName, mapDef) {\r\n var parser = this;\r\n\r\n return this.getDependency('texture', mapDef.index).then(function (texture) {\r\n if (!texture.isCompressedTexture) {\r\n switch (mapName) {\r\n case 'aoMap':\r\n case 'emissiveMap':\r\n case 'metalnessMap':\r\n case 'normalMap':\r\n case 'roughnessMap':\r\n texture.format = RGBFormat;\r\n break;\r\n }\r\n }\r\n\r\n // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured\r\n // However, we will copy UV set 0 to UV set 1 on demand for aoMap\r\n if (\r\n mapDef.texCoord !== undefined &&\r\n mapDef.texCoord != 0 &&\r\n !(mapName === 'aoMap' && mapDef.texCoord == 1)\r\n ) {\r\n console.warn(\r\n 'THREE.GLTFLoader: Custom UV set ' +\r\n mapDef.texCoord +\r\n ' for texture ' +\r\n mapName +\r\n ' not yet supported.'\r\n );\r\n }\r\n\r\n if (parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]) {\r\n var transform =\r\n mapDef.extensions !== undefined\r\n ? mapDef.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]\r\n : undefined;\r\n\r\n if (transform) {\r\n texture = parser.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(\r\n texture,\r\n transform\r\n );\r\n }\r\n }\r\n\r\n materialParams[mapName] = texture;\r\n });\r\n };\r\n\r\n /**\r\n * Assigns final material to a Mesh, Line, or Points instance. The instance\r\n * already has a material (generated from the glTF material options alone)\r\n * but reuse of the same glTF material may require multiple threejs materials\r\n * to accomodate different primitive types, defines, etc. New materials will\r\n * be created if necessary, and reused from a cache.\r\n * @param {Object3D} mesh Mesh, Line, or Points instance.\r\n */\r\n GLTFParser.prototype.assignFinalMaterial = function (mesh) {\r\n var geometry = mesh.geometry;\r\n var material = mesh.material;\r\n\r\n var useVertexTangents = geometry.attributes.tangent !== undefined;\r\n var useVertexColors = geometry.attributes.color !== undefined;\r\n var useFlatShading = geometry.attributes.normal === undefined;\r\n var useSkinning = mesh.isSkinnedMesh === true;\r\n var useMorphTargets = Object.keys(geometry.morphAttributes).length > 0;\r\n var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== undefined;\r\n\r\n if (mesh.isPoints) {\r\n var cacheKey = 'PointsMaterial:' + material.uuid;\r\n\r\n var pointsMaterial = this.cache.get(cacheKey);\r\n\r\n if (!pointsMaterial) {\r\n pointsMaterial = new PointsMaterial();\r\n Material.prototype.copy.call(pointsMaterial, material);\r\n pointsMaterial.color.copy(material.color);\r\n pointsMaterial.map = material.map;\r\n pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px\r\n\r\n this.cache.add(cacheKey, pointsMaterial);\r\n }\r\n\r\n material = pointsMaterial;\r\n } else if (mesh.isLine) {\r\n var cacheKey = 'LineBasicMaterial:' + material.uuid;\r\n\r\n var lineMaterial = this.cache.get(cacheKey);\r\n\r\n if (!lineMaterial) {\r\n lineMaterial = new LineBasicMaterial();\r\n Material.prototype.copy.call(lineMaterial, material);\r\n lineMaterial.color.copy(material.color);\r\n\r\n this.cache.add(cacheKey, lineMaterial);\r\n }\r\n\r\n material = lineMaterial;\r\n }\r\n\r\n // Clone the material if it will be modified\r\n if (useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets) {\r\n var cacheKey = 'ClonedMaterial:' + material.uuid + ':';\r\n\r\n if (material.isGLTFSpecularGlossinessMaterial) cacheKey += 'specular-glossiness:';\r\n if (useSkinning) cacheKey += 'skinning:';\r\n if (useVertexTangents) cacheKey += 'vertex-tangents:';\r\n if (useVertexColors) cacheKey += 'vertex-colors:';\r\n if (useFlatShading) cacheKey += 'flat-shading:';\r\n if (useMorphTargets) cacheKey += 'morph-targets:';\r\n if (useMorphNormals) cacheKey += 'morph-normals:';\r\n\r\n var cachedMaterial = this.cache.get(cacheKey);\r\n\r\n if (!cachedMaterial) {\r\n cachedMaterial = material.clone();\r\n\r\n if (useSkinning) cachedMaterial.skinning = true;\r\n if (useVertexTangents) cachedMaterial.vertexTangents = true;\r\n if (useVertexColors) cachedMaterial.vertexColors = true;\r\n if (useFlatShading) cachedMaterial.flatShading = true;\r\n if (useMorphTargets) cachedMaterial.morphTargets = true;\r\n if (useMorphNormals) cachedMaterial.morphNormals = true;\r\n\r\n this.cache.add(cacheKey, cachedMaterial);\r\n }\r\n\r\n material = cachedMaterial;\r\n }\r\n\r\n // workarounds for mesh and geometry\r\n\r\n if (\r\n material.aoMap &&\r\n geometry.attributes.uv2 === undefined &&\r\n geometry.attributes.uv !== undefined\r\n ) {\r\n geometry.setAttribute('uv2', geometry.attributes.uv);\r\n }\r\n\r\n // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995\r\n if (material.normalScale && !useVertexTangents) {\r\n material.normalScale.y = -material.normalScale.y;\r\n }\r\n\r\n if (material.clearcoatNormalScale && !useVertexTangents) {\r\n material.clearcoatNormalScale.y = -material.clearcoatNormalScale.y;\r\n }\r\n\r\n mesh.material = material;\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials\r\n * @param {number} materialIndex\r\n * @return {Promise<Material>}\r\n */\r\n GLTFParser.prototype.loadMaterial = function (materialIndex) {\r\n var parser = this;\r\n var json = this.json;\r\n var extensions = this.extensions;\r\n var materialDef = json.materials[materialIndex];\r\n\r\n var materialType;\r\n var materialParams = {};\r\n var materialExtensions = materialDef.extensions || {};\r\n\r\n var pending = [];\r\n\r\n if (materialExtensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]) {\r\n var sgExtension = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];\r\n materialType = sgExtension.getMaterialType();\r\n pending.push(sgExtension.extendParams(materialParams, materialDef, parser));\r\n } else if (materialExtensions[EXTENSIONS.KHR_MATERIALS_UNLIT]) {\r\n var kmuExtension = extensions[EXTENSIONS.KHR_MATERIALS_UNLIT];\r\n materialType = kmuExtension.getMaterialType();\r\n pending.push(kmuExtension.extendParams(materialParams, materialDef, parser));\r\n } else {\r\n // Specification:\r\n // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material\r\n\r\n materialType = MeshStandardMaterial;\r\n\r\n var metallicRoughness = materialDef.pbrMetallicRoughness || {};\r\n\r\n materialParams.color = new Color(1.0, 1.0, 1.0);\r\n materialParams.opacity = 1.0;\r\n\r\n if (Array.isArray(metallicRoughness.baseColorFactor)) {\r\n var array = metallicRoughness.baseColorFactor;\r\n\r\n materialParams.color.fromArray(array);\r\n materialParams.opacity = array[3];\r\n }\r\n\r\n if (metallicRoughness.baseColorTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(materialParams, 'map', metallicRoughness.baseColorTexture)\r\n );\r\n }\r\n\r\n materialParams.metalness =\r\n metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;\r\n materialParams.roughness =\r\n metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;\r\n\r\n if (metallicRoughness.metallicRoughnessTexture !== undefined) {\r\n pending.push(\r\n parser.assignTexture(\r\n materialParams,\r\n 'metalnessMap',\r\n metallicRoughness.metallicRoughnessTexture\r\n )\r\n );\r\n pending.push(\r\n parser.assignTexture(\r\n materialParams,\r\n 'roughnessMap',\r\n metallicRoughness.metallicRoughnessTexture\r\n )\r\n );\r\n }\r\n }\r\n\r\n if (materialDef.doubleSided === true) {\r\n materialParams.side = DoubleSide;\r\n }\r\n\r\n var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;\r\n\r\n if (alphaMode === ALPHA_MODES.BLEND) {\r\n materialParams.transparent = true;\r\n\r\n // See: https://github.com/mrdoob/three.js/issues/17706\r\n materialParams.depthWrite = false;\r\n } else {\r\n materialParams.transparent = false;\r\n\r\n if (alphaMode === ALPHA_MODES.MASK) {\r\n materialParams.alphaTest =\r\n materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;\r\n }\r\n }\r\n\r\n if (materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial) {\r\n pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture));\r\n\r\n materialParams.normalScale = new Vector2(1, 1);\r\n\r\n if (materialDef.normalTexture.scale !== undefined) {\r\n materialParams.normalScale.set(\r\n materialDef.normalTexture.scale,\r\n materialDef.normalTexture.scale\r\n );\r\n }\r\n }\r\n\r\n if (materialDef.occlusionTexture !== undefined && materialType !== MeshBasicMaterial) {\r\n pending.push(parser.assignTexture(materialParams, 'aoMap', materialDef.occlusionTexture));\r\n\r\n if (materialDef.occlusionTexture.strength !== undefined) {\r\n materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;\r\n }\r\n }\r\n\r\n if (materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial) {\r\n materialParams.emissive = new Color().fromArray(materialDef.emissiveFactor);\r\n }\r\n\r\n if (materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial) {\r\n pending.push(\r\n parser.assignTexture(materialParams, 'emissiveMap', materialDef.emissiveTexture)\r\n );\r\n }\r\n\r\n if (materialExtensions[EXTENSIONS.KHR_MATERIALS_CLEARCOAT]) {\r\n var clearcoatExtension = extensions[EXTENSIONS.KHR_MATERIALS_CLEARCOAT];\r\n materialType = clearcoatExtension.getMaterialType();\r\n pending.push(\r\n clearcoatExtension.extendParams(materialParams, { extensions: materialExtensions }, parser)\r\n );\r\n }\r\n\r\n return Promise.all(pending).then(function () {\r\n var material;\r\n\r\n if (materialType === GLTFMeshStandardSGMaterial) {\r\n material = extensions[EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(\r\n materialParams\r\n );\r\n } else {\r\n material = new materialType(materialParams);\r\n }\r\n\r\n if (materialDef.name) material.name = materialDef.name;\r\n\r\n // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.\r\n if (material.map) material.map.encoding = sRGBEncoding;\r\n if (material.emissiveMap) material.emissiveMap.encoding = sRGBEncoding;\r\n\r\n assignExtrasToUserData(material, materialDef);\r\n\r\n if (materialDef.extensions) addUnknownExtensionsToUserData(extensions, material, materialDef);\r\n\r\n return material;\r\n });\r\n };\r\n\r\n /**\r\n * @param {BufferGeometry} geometry\r\n * @param {GLTF.Primitive} primitiveDef\r\n * @param {GLTFParser} parser\r\n */\r\n function computeBounds(geometry, primitiveDef, parser) {\r\n var attributes = primitiveDef.attributes;\r\n\r\n var box = new Box3();\r\n\r\n if (attributes.POSITION !== undefined) {\r\n var accessor = parser.json.accessors[attributes.POSITION];\r\n\r\n var min = accessor.min;\r\n var max = accessor.max;\r\n\r\n // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.\r\n\r\n if (min !== undefined && max !== undefined) {\r\n box.set(new Vector3(min[0], min[1], min[2]), new Vector3(max[0], max[1], max[2]));\r\n } else {\r\n console.warn('THREE.GLTFLoader: Missing min/max properties for accessor POSITION.');\r\n\r\n return;\r\n }\r\n } else {\r\n return;\r\n }\r\n\r\n var targets = primitiveDef.targets;\r\n\r\n if (targets !== undefined) {\r\n var maxDisplacement = new Vector3();\r\n var vector = new Vector3();\r\n\r\n for (var i = 0, il = targets.length; i < il; i++) {\r\n var target = targets[i];\r\n\r\n if (target.POSITION !== undefined) {\r\n var accessor = parser.json.accessors[target.POSITION];\r\n var min = accessor.min;\r\n var max = accessor.max;\r\n\r\n // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.\r\n\r\n if (min !== undefined && max !== undefined) {\r\n // we need to get max of absolute components because target weight is [-1,1]\r\n vector.setX(Math.max(Math.abs(min[0]), Math.abs(max[0])));\r\n vector.setY(Math.max(Math.abs(min[1]), Math.abs(max[1])));\r\n vector.setZ(Math.max(Math.abs(min[2]), Math.abs(max[2])));\r\n\r\n // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative\r\n // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets\r\n // are used to implement key-frame animations and as such only two are active at a time - this results in very large\r\n // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.\r\n maxDisplacement.max(vector);\r\n } else {\r\n console.warn('THREE.GLTFLoader: Missing min/max properties for accessor POSITION.');\r\n }\r\n }\r\n }\r\n\r\n // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.\r\n box.expandByVector(maxDisplacement);\r\n }\r\n\r\n geometry.boundingBox = box;\r\n\r\n var sphere = new Sphere();\r\n\r\n box.getCenter(sphere.center);\r\n sphere.radius = box.min.distanceTo(box.max) / 2;\r\n\r\n geometry.boundingSphere = sphere;\r\n }\r\n\r\n /**\r\n * @param {BufferGeometry} geometry\r\n * @param {GLTF.Primitive} primitiveDef\r\n * @param {GLTFParser} parser\r\n * @return {Promise<BufferGeometry>}\r\n */\r\n function addPrimitiveAttributes(geometry, primitiveDef, parser) {\r\n var attributes = primitiveDef.attributes;\r\n\r\n var pending = [];\r\n\r\n function assignAttributeAccessor(accessorIndex, attributeName) {\r\n return parser.getDependency('accessor', accessorIndex).then(function (accessor) {\r\n geometry.setAttribute(attributeName, accessor);\r\n });\r\n }\r\n\r\n for (var gltfAttributeName in attributes) {\r\n var threeAttributeName = ATTRIBUTES[gltfAttributeName] || gltfAttributeName.toLowerCase();\r\n\r\n // Skip attributes already provided by e.g. Draco extension.\r\n if (threeAttributeName in geometry.attributes) continue;\r\n\r\n pending.push(assignAttributeAccessor(attributes[gltfAttributeName], threeAttributeName));\r\n }\r\n\r\n if (primitiveDef.indices !== undefined && !geometry.index) {\r\n var accessor = parser\r\n .getDependency('accessor', primitiveDef.indices)\r\n .then(function (accessor) {\r\n geometry.setIndex(accessor);\r\n });\r\n\r\n pending.push(accessor);\r\n }\r\n\r\n assignExtrasToUserData(geometry, primitiveDef);\r\n\r\n computeBounds(geometry, primitiveDef, parser);\r\n\r\n return Promise.all(pending).then(function () {\r\n return primitiveDef.targets !== undefined\r\n ? addMorphTargets(geometry, primitiveDef.targets, parser)\r\n : geometry;\r\n });\r\n }\r\n\r\n /**\r\n * @param {BufferGeometry} geometry\r\n * @param {Number} drawMode\r\n * @return {BufferGeometry}\r\n */\r\n function toTrianglesDrawMode(geometry, drawMode) {\r\n var index = geometry.getIndex();\r\n\r\n // generate index if not present\r\n\r\n if (index === null) {\r\n var indices = [];\r\n\r\n var position = geometry.getAttribute('position');\r\n\r\n if (position !== undefined) {\r\n for (var i = 0; i < position.count; i++) {\r\n indices.push(i);\r\n }\r\n\r\n geometry.setIndex(indices);\r\n index = geometry.getIndex();\r\n } else {\r\n console.error(\r\n 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.'\r\n );\r\n return geometry;\r\n }\r\n }\r\n\r\n //\r\n\r\n var numberOfTriangles = index.count - 2;\r\n var newIndices = [];\r\n\r\n if (drawMode === TriangleFanDrawMode) {\r\n // gl.TRIANGLE_FAN\r\n\r\n for (var i = 1; i <= numberOfTriangles; i++) {\r\n newIndices.push(index.getX(0));\r\n newIndices.push(index.getX(i));\r\n newIndices.push(index.getX(i + 1));\r\n }\r\n } else {\r\n // gl.TRIANGLE_STRIP\r\n\r\n for (var i = 0; i < numberOfTriangles; i++) {\r\n if (i % 2 === 0) {\r\n newIndices.push(index.getX(i));\r\n newIndices.push(index.getX(i + 1));\r\n newIndices.push(index.getX(i + 2));\r\n } else {\r\n newIndices.push(index.getX(i + 2));\r\n newIndices.push(index.getX(i + 1));\r\n newIndices.push(index.getX(i));\r\n }\r\n }\r\n }\r\n\r\n if (newIndices.length / 3 !== numberOfTriangles) {\r\n console.error(\r\n 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.'\r\n );\r\n }\r\n\r\n // build final geometry\r\n\r\n var newGeometry = geometry.clone();\r\n newGeometry.setIndex(newIndices);\r\n\r\n return newGeometry;\r\n }\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry\r\n *\r\n * Creates BufferGeometries from primitives.\r\n *\r\n * @param {Array<GLTF.Primitive>} primitives\r\n * @return {Promise<Array<BufferGeometry>>}\r\n */\r\n GLTFParser.prototype.loadGeometries = function (primitives) {\r\n var parser = this;\r\n var extensions = this.extensions;\r\n var cache = this.primitiveCache;\r\n\r\n function createDracoPrimitive(primitive) {\r\n return extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]\r\n .decodePrimitive(primitive, parser)\r\n .then(function (geometry) {\r\n return addPrimitiveAttributes(geometry, primitive, parser);\r\n });\r\n }\r\n\r\n var pending = [];\r\n\r\n for (var i = 0, il = primitives.length; i < il; i++) {\r\n var primitive = primitives[i];\r\n var cacheKey = createPrimitiveKey(primitive);\r\n\r\n // See if we've already created this geometry\r\n var cached = cache[cacheKey];\r\n\r\n if (cached) {\r\n // Use the cached geometry if it exists\r\n pending.push(cached.promise);\r\n } else {\r\n var geometryPromise;\r\n\r\n if (primitive.extensions && primitive.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]) {\r\n // Use DRACO geometry if available\r\n geometryPromise = createDracoPrimitive(primitive);\r\n } else {\r\n // Otherwise create a new geometry\r\n geometryPromise = addPrimitiveAttributes(new BufferGeometry(), primitive, parser);\r\n }\r\n\r\n // Cache this geometry\r\n cache[cacheKey] = { primitive: primitive, promise: geometryPromise };\r\n\r\n pending.push(geometryPromise);\r\n }\r\n }\r\n\r\n return Promise.all(pending);\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes\r\n * @param {number} meshIndex\r\n * @return {Promise<Group|Mesh|SkinnedMesh>}\r\n */\r\n GLTFParser.prototype.loadMesh = function (meshIndex) {\r\n var parser = this;\r\n var json = this.json;\r\n\r\n var meshDef = json.meshes[meshIndex];\r\n var primitives = meshDef.primitives;\r\n\r\n var pending = [];\r\n\r\n for (var i = 0, il = primitives.length; i < il; i++) {\r\n var material =\r\n primitives[i].material === undefined\r\n ? createDefaultMaterial(this.cache)\r\n : this.getDependency('material', primitives[i].material);\r\n\r\n pending.push(material);\r\n }\r\n\r\n pending.push(parser.loadGeometries(primitives));\r\n\r\n return Promise.all(pending).then(function (results) {\r\n var materials = results.slice(0, results.length - 1);\r\n var geometries = results[results.length - 1];\r\n\r\n var meshes = [];\r\n\r\n for (var i = 0, il = geometries.length; i < il; i++) {\r\n var geometry = geometries[i];\r\n var primitive = primitives[i];\r\n\r\n // 1. create Mesh\r\n\r\n var mesh;\r\n\r\n var material = materials[i];\r\n\r\n if (\r\n primitive.mode === WEBGL_CONSTANTS.TRIANGLES ||\r\n primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ||\r\n primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ||\r\n primitive.mode === undefined\r\n ) {\r\n // .isSkinnedMesh isn't in glTF spec. See .markDefs()\r\n mesh =\r\n meshDef.isSkinnedMesh === true\r\n ? new SkinnedMesh(geometry, material)\r\n : new Mesh(geometry, material);\r\n\r\n if (mesh.isSkinnedMesh === true && !mesh.geometry.attributes.skinWeight.normalized) {\r\n // we normalize floating point skin weight array to fix malformed assets (see #15319)\r\n // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs\r\n mesh.normalizeSkinWeights();\r\n }\r\n\r\n if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP) {\r\n mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleStripDrawMode);\r\n } else if (primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN) {\r\n mesh.geometry = toTrianglesDrawMode(mesh.geometry, TriangleFanDrawMode);\r\n }\r\n } else if (primitive.mode === WEBGL_CONSTANTS.LINES) {\r\n mesh = new LineSegments(geometry, material);\r\n } else if (primitive.mode === WEBGL_CONSTANTS.LINE_STRIP) {\r\n mesh = new Line(geometry, material);\r\n } else if (primitive.mode === WEBGL_CONSTANTS.LINE_LOOP) {\r\n mesh = new LineLoop(geometry, material);\r\n } else if (primitive.mode === WEBGL_CONSTANTS.POINTS) {\r\n mesh = new Points(geometry, material);\r\n } else {\r\n throw new Error('THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode);\r\n }\r\n\r\n if (Object.keys(mesh.geometry.morphAttributes).length > 0) {\r\n updateMorphTargets(mesh, meshDef);\r\n }\r\n\r\n mesh.name = meshDef.name || 'mesh_' + meshIndex;\r\n\r\n if (geometries.length > 1) mesh.name += '_' + i;\r\n\r\n assignExtrasToUserData(mesh, meshDef);\r\n\r\n parser.assignFinalMaterial(mesh);\r\n\r\n meshes.push(mesh);\r\n }\r\n\r\n if (meshes.length === 1) {\r\n return meshes[0];\r\n }\r\n\r\n var group = new Group();\r\n\r\n for (var i = 0, il = meshes.length; i < il; i++) {\r\n group.add(meshes[i]);\r\n }\r\n\r\n return group;\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras\r\n * @param {number} cameraIndex\r\n * @return {Promise<THREE.Camera>}\r\n */\r\n GLTFParser.prototype.loadCamera = function (cameraIndex) {\r\n var camera;\r\n var cameraDef = this.json.cameras[cameraIndex];\r\n var params = cameraDef[cameraDef.type];\r\n\r\n if (!params) {\r\n console.warn('THREE.GLTFLoader: Missing camera parameters.');\r\n return;\r\n }\r\n\r\n if (cameraDef.type === 'perspective') {\r\n camera = new PerspectiveCamera(\r\n MathUtils.radToDeg(params.yfov),\r\n params.aspectRatio || 1,\r\n params.znear || 1,\r\n params.zfar || 2e6\r\n );\r\n } else if (cameraDef.type === 'orthographic') {\r\n camera = new OrthographicCamera(\r\n -params.xmag,\r\n params.xmag,\r\n params.ymag,\r\n -params.ymag,\r\n params.znear,\r\n params.zfar\r\n );\r\n }\r\n\r\n if (cameraDef.name) camera.name = cameraDef.name;\r\n\r\n assignExtrasToUserData(camera, cameraDef);\r\n\r\n return Promise.resolve(camera);\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins\r\n * @param {number} skinIndex\r\n * @return {Promise<Object>}\r\n */\r\n GLTFParser.prototype.loadSkin = function (skinIndex) {\r\n var skinDef = this.json.skins[skinIndex];\r\n\r\n var skinEntry = { joints: skinDef.joints };\r\n\r\n if (skinDef.inverseBindMatrices === undefined) {\r\n return Promise.resolve(skinEntry);\r\n }\r\n\r\n return this.getDependency('accessor', skinDef.inverseBindMatrices).then(function (accessor) {\r\n skinEntry.inverseBindMatrices = accessor;\r\n\r\n return skinEntry;\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations\r\n * @param {number} animationIndex\r\n * @return {Promise<AnimationClip>}\r\n */\r\n GLTFParser.prototype.loadAnimation = function (animationIndex) {\r\n var json = this.json;\r\n\r\n var animationDef = json.animations[animationIndex];\r\n\r\n var pendingNodes = [];\r\n var pendingInputAccessors = [];\r\n var pendingOutputAccessors = [];\r\n var pendingSamplers = [];\r\n var pendingTargets = [];\r\n\r\n for (var i = 0, il = animationDef.channels.length; i < il; i++) {\r\n var channel = animationDef.channels[i];\r\n var sampler = animationDef.samplers[channel.sampler];\r\n var target = channel.target;\r\n var name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.\r\n var input =\r\n animationDef.parameters !== undefined\r\n ? animationDef.parameters[sampler.input]\r\n : sampler.input;\r\n var output =\r\n animationDef.parameters !== undefined\r\n ? animationDef.parameters[sampler.output]\r\n : sampler.output;\r\n\r\n pendingNodes.push(this.getDependency('node', name));\r\n pendingInputAccessors.push(this.getDependency('accessor', input));\r\n pendingOutputAccessors.push(this.getDependency('accessor', output));\r\n pendingSamplers.push(sampler);\r\n pendingTargets.push(target);\r\n }\r\n\r\n return Promise.all([\r\n Promise.all(pendingNodes),\r\n Promise.all(pendingInputAccessors),\r\n Promise.all(pendingOutputAccessors),\r\n Promise.all(pendingSamplers),\r\n Promise.all(pendingTargets),\r\n ]).then(function (dependencies) {\r\n var nodes = dependencies[0];\r\n var inputAccessors = dependencies[1];\r\n var outputAccessors = dependencies[2];\r\n var samplers = dependencies[3];\r\n var targets = dependencies[4];\r\n\r\n var tracks = [];\r\n\r\n for (var i = 0, il = nodes.length; i < il; i++) {\r\n var node = nodes[i];\r\n var inputAccessor = inputAccessors[i];\r\n var outputAccessor = outputAccessors[i];\r\n var sampler = samplers[i];\r\n var target = targets[i];\r\n\r\n if (node === undefined) continue;\r\n\r\n node.updateMatrix();\r\n node.matrixAutoUpdate = true;\r\n\r\n var TypedKeyframeTrack;\r\n\r\n switch (PATH_PROPERTIES[target.path]) {\r\n case PATH_PROPERTIES.weights:\r\n TypedKeyframeTrack = NumberKeyframeTrack;\r\n break;\r\n\r\n case PATH_PROPERTIES.rotation:\r\n TypedKeyframeTrack = QuaternionKeyframeTrack;\r\n break;\r\n\r\n case PATH_PROPERTIES.position:\r\n case PATH_PROPERTIES.scale:\r\n default:\r\n TypedKeyframeTrack = VectorKeyframeTrack;\r\n break;\r\n }\r\n\r\n var targetName = node.name ? node.name : node.uuid;\r\n\r\n var interpolation =\r\n sampler.interpolation !== undefined\r\n ? INTERPOLATION[sampler.interpolation]\r\n : InterpolateLinear;\r\n\r\n var targetNames = [];\r\n\r\n if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {\r\n // Node may be a Group (glTF mesh with several primitives) or a Mesh.\r\n node.traverse(function (object) {\r\n if (object.isMesh === true && object.morphTargetInfluences) {\r\n targetNames.push(object.name ? object.name : object.uuid);\r\n }\r\n });\r\n } else {\r\n targetNames.push(targetName);\r\n }\r\n\r\n var outputArray = outputAccessor.array;\r\n\r\n if (outputAccessor.normalized) {\r\n var scale;\r\n\r\n if (outputArray.constructor === Int8Array) {\r\n scale = 1 / 127;\r\n } else if (outputArray.constructor === Uint8Array) {\r\n scale = 1 / 255;\r\n } else if (outputArray.constructor == Int16Array) {\r\n scale = 1 / 32767;\r\n } else if (outputArray.constructor === Uint16Array) {\r\n scale = 1 / 65535;\r\n } else {\r\n throw new Error('THREE.GLTFLoader: Unsupported output accessor component type.');\r\n }\r\n\r\n var scaled = new Float32Array(outputArray.length);\r\n\r\n for (var j = 0, jl = outputArray.length; j < jl; j++) {\r\n scaled[j] = outputArray[j] * scale;\r\n }\r\n\r\n outputArray = scaled;\r\n }\r\n\r\n for (var j = 0, jl = targetNames.length; j < jl; j++) {\r\n var track = new TypedKeyframeTrack(\r\n targetNames[j] + '.' + PATH_PROPERTIES[target.path],\r\n inputAccessor.array,\r\n outputArray,\r\n interpolation\r\n );\r\n\r\n // Override interpolation with custom factory method.\r\n if (sampler.interpolation === 'CUBICSPLINE') {\r\n track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline(result) {\r\n // A CUBICSPLINE keyframe in glTF has three output values for each input value,\r\n // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()\r\n // must be divided by three to get the interpolant's sampleSize argument.\r\n\r\n return new GLTFCubicSplineInterpolant(\r\n this.times,\r\n this.values,\r\n this.getValueSize() / 3,\r\n result\r\n );\r\n };\r\n\r\n // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.\r\n track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;\r\n }\r\n\r\n tracks.push(track);\r\n }\r\n }\r\n\r\n var name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;\r\n\r\n return new AnimationClip(name, undefined, tracks);\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy\r\n * @param {number} nodeIndex\r\n * @return {Promise<Object3D>}\r\n */\r\n GLTFParser.prototype.loadNode = function (nodeIndex) {\r\n var json = this.json;\r\n var extensions = this.extensions;\r\n var parser = this;\r\n\r\n var meshReferences = json.meshReferences;\r\n var meshUses = json.meshUses;\r\n\r\n var nodeDef = json.nodes[nodeIndex];\r\n\r\n return (function () {\r\n var pending = [];\r\n\r\n if (nodeDef.mesh !== undefined) {\r\n pending.push(\r\n parser.getDependency('mesh', nodeDef.mesh).then(function (mesh) {\r\n var node;\r\n\r\n if (meshReferences[nodeDef.mesh] > 1) {\r\n var instanceNum = meshUses[nodeDef.mesh]++;\r\n\r\n node = mesh.clone();\r\n node.name += '_instance_' + instanceNum;\r\n } else {\r\n node = mesh;\r\n }\r\n\r\n // if weights are provided on the node, override weights on the mesh.\r\n if (nodeDef.weights !== undefined) {\r\n node.traverse(function (o) {\r\n if (!o.isMesh) return;\r\n\r\n for (var i = 0, il = nodeDef.weights.length; i < il; i++) {\r\n o.morphTargetInfluences[i] = nodeDef.weights[i];\r\n }\r\n });\r\n }\r\n\r\n return node;\r\n })\r\n );\r\n }\r\n\r\n if (nodeDef.camera !== undefined) {\r\n pending.push(parser.getDependency('camera', nodeDef.camera));\r\n }\r\n\r\n if (\r\n nodeDef.extensions &&\r\n nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL] &&\r\n nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light !== undefined\r\n ) {\r\n pending.push(\r\n parser.getDependency('light', nodeDef.extensions[EXTENSIONS.KHR_LIGHTS_PUNCTUAL].light)\r\n );\r\n }\r\n\r\n return Promise.all(pending);\r\n })().then(function (objects) {\r\n var node;\r\n\r\n // .isBone isn't in glTF spec. See .markDefs\r\n if (nodeDef.isBone === true) {\r\n node = new Bone();\r\n } else if (objects.length > 1) {\r\n node = new Group();\r\n } else if (objects.length === 1) {\r\n node = objects[0];\r\n } else {\r\n node = new Object3D();\r\n }\r\n\r\n if (node !== objects[0]) {\r\n for (var i = 0, il = objects.length; i < il; i++) {\r\n node.add(objects[i]);\r\n }\r\n }\r\n\r\n if (nodeDef.name) {\r\n node.userData.name = nodeDef.name;\r\n node.name = PropertyBinding.sanitizeNodeName(nodeDef.name);\r\n }\r\n\r\n assignExtrasToUserData(node, nodeDef);\r\n\r\n if (nodeDef.extensions) addUnknownExtensionsToUserData(extensions, node, nodeDef);\r\n\r\n if (nodeDef.matrix !== undefined) {\r\n var matrix = new Matrix4();\r\n matrix.fromArray(nodeDef.matrix);\r\n node.applyMatrix4(matrix);\r\n } else {\r\n if (nodeDef.translation !== undefined) {\r\n node.position.fromArray(nodeDef.translation);\r\n }\r\n\r\n if (nodeDef.rotation !== undefined) {\r\n node.quaternion.fromArray(nodeDef.rotation);\r\n }\r\n\r\n if (nodeDef.scale !== undefined) {\r\n node.scale.fromArray(nodeDef.scale);\r\n }\r\n }\r\n\r\n return node;\r\n });\r\n };\r\n\r\n /**\r\n * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes\r\n * @param {number} sceneIndex\r\n * @return {Promise<Group>}\r\n */\r\n GLTFParser.prototype.loadScene = (function () {\r\n // scene node hierachy builder\r\n\r\n function buildNodeHierachy(nodeId, parentObject, json, parser) {\r\n var nodeDef = json.nodes[nodeId];\r\n\r\n return parser\r\n .getDependency('node', nodeId)\r\n .then(function (node) {\r\n if (nodeDef.skin === undefined) return node;\r\n\r\n // build skeleton here as well\r\n\r\n var skinEntry;\r\n\r\n return parser\r\n .getDependency('skin', nodeDef.skin)\r\n .then(function (skin) {\r\n skinEntry = skin;\r\n\r\n var pendingJoints = [];\r\n\r\n for (var i = 0, il = skinEntry.joints.length; i < il; i++) {\r\n pendingJoints.push(parser.getDependency('node', skinEntry.joints[i]));\r\n }\r\n\r\n return Promise.all(pendingJoints);\r\n })\r\n .then(function (jointNodes) {\r\n node.traverse(function (mesh) {\r\n if (!mesh.isMesh) return;\r\n\r\n var bones = [];\r\n var boneInverses = [];\r\n\r\n for (var j = 0, jl = jointNodes.length; j < jl; j++) {\r\n var jointNode = jointNodes[j];\r\n\r\n if (jointNode) {\r\n bones.push(jointNode);\r\n\r\n var mat = new Matrix4();\r\n\r\n if (skinEntry.inverseBindMatrices !== undefined) {\r\n mat.fromArray(skinEntry.inverseBindMatrices.array, j * 16);\r\n }\r\n\r\n boneInverses.push(mat);\r\n } else {\r\n console.warn(\r\n 'THREE.GLTFLoader: Joint \"%s\" could not be found.',\r\n skinEntry.joints[j]\r\n );\r\n }\r\n }\r\n\r\n mesh.bind(new Skeleton(bones, boneInverses), mesh.matrixWorld);\r\n });\r\n\r\n return node;\r\n });\r\n })\r\n .then(function (node) {\r\n // build node hierachy\r\n\r\n parentObject.add(node);\r\n\r\n var pending = [];\r\n\r\n if (nodeDef.children) {\r\n var children = nodeDef.children;\r\n\r\n for (var i = 0, il = children.length; i < il; i++) {\r\n var child = children[i];\r\n pending.push(buildNodeHierachy(child, node, json, parser));\r\n }\r\n }\r\n\r\n return Promise.all(pending);\r\n });\r\n }\r\n\r\n return function loadScene(sceneIndex) {\r\n var json = this.json;\r\n var extensions = this.extensions;\r\n var sceneDef = this.json.scenes[sceneIndex];\r\n var parser = this;\r\n\r\n // Loader returns Group, not Scene.\r\n // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172\r\n var scene = new Group();\r\n if (sceneDef.name) scene.name = sceneDef.name;\r\n\r\n assignExtrasToUserData(scene, sceneDef);\r\n\r\n if (sceneDef.extensions) addUnknownExtensionsToUserData(extensions, scene, sceneDef);\r\n\r\n var nodeIds = sceneDef.nodes || [];\r\n\r\n var pending = [];\r\n\r\n for (var i = 0, il = nodeIds.length; i < il; i++) {\r\n pending.push(buildNodeHierachy(nodeIds[i], scene, json, parser));\r\n }\r\n\r\n return Promise.all(pending).then(function () {\r\n return scene;\r\n });\r\n };\r\n })();\r\n\r\n return GLTFLoader;\r\n})();\r\n\r\nexport { GLTFLoader };\r\n","import * as THREE from 'three';\r\n\r\nimport Material from '../components/material';\r\nimport Helpers from '../../utils/helpers';\r\nimport { BufferGeometryUtils } from '../../utils/bufferGeometryUtils';\r\nimport { GLTFLoader } from '../loaders/GLTFLoader';\r\nimport Config from '../../data/config';\r\n\r\n// Loads in a single object from the config file\r\nexport default class Model {\r\n constructor(scene, manager, textures) {\r\n this.scene = scene;\r\n this.textures = textures;\r\n this.manager = manager;\r\n\r\n this.obj = null;\r\n this.ref = null;\r\n }\r\n\r\n load(type) {\r\n // Manager is passed in to loader to determine when loading done in main\r\n\r\n switch (type) {\r\n case 'gltf':\r\n // Load model with selected loader\r\n new GLTFLoader(this.manager).load(\r\n Config.models[Config.model.selected].path,\r\n (gltf) => {\r\n const scene = gltf.scene;\r\n let mesh;\r\n\r\n if (Config.shadow.enabled) {\r\n scene.traverse(function(node) {\r\n if (node.isMesh || node.isLight) node.castShadow = true;\r\n if (node.isMesh) {\r\n node.material.wireframe = Config.mesh.wireframe;\r\n mesh = node;\r\n }\r\n });\r\n }\r\n\r\n this.obj = mesh;\r\n\r\n BufferGeometryUtils.computeTangents(mesh.geometry);\r\n\r\n var group = new THREE.Group();\r\n group.scale.multiplyScalar(0.25);\r\n this.scene.add( group );\r\n\r\n this.ref = group;\r\n\r\n // To make sure that the matrixWorld is up to date for the boxhelpers\r\n group.updateMatrixWorld(true);\r\n group.add(mesh);\r\n\r\n // Add to scene\r\n this.scene.add(scene);\r\n },\r\n Helpers.logProgress(),\r\n Helpers.logError()\r\n );\r\n break;\r\n\r\n case 'object':\r\n // Load model with ObjectLoader\r\n new THREE.ObjectLoader(this.manager).load(\r\n Config.models[Config.model.selected].path,\r\n obj => {\r\n obj.traverse(child => {\r\n if(child instanceof THREE.Mesh) {\r\n // Create material for mesh and set its map to texture by name from preloaded textures\r\n const material = new Material(0xffffff).standard;\r\n material.map = this.textures.UV;\r\n child.material = material;\r\n\r\n // Set to cast and receive shadow if enabled\r\n if(Config.shadow.enabled) {\r\n child.receiveShadow = true;\r\n child.castShadow = true;\r\n }\r\n }\r\n });\r\n\r\n // Set prop to obj so it can be accessed from outside the class\r\n this.obj = obj;\r\n this.ref = obj;\r\n\r\n obj.scale.multiplyScalar(Config.models[Config.model.selected].scale);\r\n this.scene.add(obj);\r\n },\r\n Helpers.logProgress(),\r\n Helpers.logError()\r\n );\r\n break;\r\n }\r\n }\r\n\r\n unload() {\r\n this.scene.remove(this.ref);\r\n }\r\n}\r\n","const ALIAS = {\r\n 'left'\t\t: 37,\r\n 'up'\t\t : 38,\r\n 'right'\t\t: 39,\r\n 'down'\t\t: 40,\r\n 'space'\t\t: 32,\r\n 'tab'\t\t : 9,\r\n 'escape'\t: 27\r\n};\r\n\r\nexport default class Keyboard {\r\n constructor(domElement) {\r\n this.domElement = domElement || document;\r\n this.keyCodes = {};\r\n\r\n // bind keyEvents\r\n this.domElement.addEventListener('keydown', (event) => this.onKeyChange(event), false);\r\n this.domElement.addEventListener('keyup', (event) => this.onKeyChange(event), false);\r\n\r\n // bind window blur\r\n window.addEventListener('blur', () => this.onBlur, false);\r\n }\r\n\r\n destroy() {\r\n this.domElement.removeEventListener('keydown', (event) => this.onKeyChange(event), false);\r\n this.domElement.removeEventListener('keyup', (event) => this.onKeyChange(event), false);\r\n\r\n // unbind window blur event\r\n window.removeEventListener('blur', () => this.onBlur, false);\r\n }\r\n\r\n onBlur() {\r\n for(const prop in this.keyCodes)\r\n this.keyCodes[prop] = false;\r\n }\r\n\r\n onKeyChange(event) {\r\n // log to debug\r\n //console.log('onKeyChange', event, event.keyCode, event.shiftKey, event.ctrlKey, event.altKey, event.metaKey)\r\n\r\n // update this.keyCodes\r\n const keyCode = event.keyCode;\r\n this.keyCodes[keyCode] = event.type === 'keydown';\r\n }\r\n\r\n pressed(keyDesc) {\r\n const keys = keyDesc.split('+');\r\n for(let i = 0; i < keys.length; i++) {\r\n const key = keys[i];\r\n let pressed = false;\r\n if(Object.keys(ALIAS).indexOf(key) != -1) {\r\n pressed = this.keyCodes[ALIAS[key]];\r\n } else {\r\n pressed = this.keyCodes[key.toUpperCase().charCodeAt(0)];\r\n }\r\n if(!pressed)\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n eventMatches(event, keyDesc) {\r\n const aliases = ALIAS;\r\n const aliasKeys = Object.keys(aliases);\r\n const keys = keyDesc.split('+');\r\n // log to debug\r\n // console.log('eventMatches', event, event.keyCode, event.shiftKey, event.ctrlKey, event.altKey, event.metaKey)\r\n for(let i = 0; i < keys.length; i++) {\r\n const key = keys[i];\r\n let pressed = false;\r\n if(key === 'shift') {\r\n pressed = event.shiftKey ? true : false;\r\n } else if(key === 'ctrl') {\r\n pressed = event.ctrlKey ? true : false;\r\n } else if(key === 'alt') {\r\n pressed = event.altKey ? true : false;\r\n } else if(key === 'meta') {\r\n pressed = event.metaKey ? true : false;\r\n } else if(aliasKeys.indexOf(key) !== -1) {\r\n pressed = event.keyCode === aliases[key];\r\n } else if(event.keyCode === key.toUpperCase().charCodeAt(0)) {\r\n pressed = true;\r\n }\r\n if(!pressed)\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n}\r\n","import Keyboard from '../../utils/keyboard';\nimport Helpers from '../../utils/helpers';\nimport Config from '../../data/config';\n\n// Manages all input interactions\nexport default class Interaction {\n constructor(renderer, scene, camera, controls) {\n // Properties\n this.renderer = renderer;\n this.scene = scene;\n this.camera = camera;\n this.controls = controls;\n\n this.timeout = null;\n\n // Instantiate keyboard helper\n this.keyboard = new Keyboard();\n\n // Listeners\n // Mouse events\n this.renderer.domElement.addEventListener('mousemove', (event) => Helpers.throttle(this.onMouseMove(event), 250), false);\n this.renderer.domElement.addEventListener('mouseleave', (event) => this.onMouseLeave(event), false);\n this.renderer.domElement.addEventListener('mouseover', (event) => this.onMouseOver(event), false);\n\n // Keyboard events\n this.keyboard.domElement.addEventListener('keydown', (event) => {\n // Only once\n if(event.repeat) {\n return;\n }\n\n if(this.keyboard.eventMatches(event, 'escape')) {\n console.log('Escape pressed');\n }\n });\n }\n\n onMouseOver(event) {\n event.preventDefault();\n\n Config.isMouseOver = true;\n }\n\n onMouseLeave(event) {\n event.preventDefault();\n\n Config.isMouseOver = false;\n }\n\n onMouseMove(event) {\n event.preventDefault();\n\n clearTimeout(this.timeout);\n\n this.timeout = setTimeout(function() {\n Config.isMouseMoving = false;\n }, 200);\n\n Config.isMouseMoving = true;\n }\n}\n","import Config from '../../data/config';\r\n\r\n// Manages all dat.GUI interactions\r\nexport default class DatGUI {\r\n constructor(main) {\r\n this.gui = new dat.GUI();\r\n\r\n this.camera = main.camera.threeCamera;\r\n this.controls = main.controls.threeControls;\r\n this.light = main.light;\r\n this.scene = main.scene;\r\n\r\n this.model = null;\r\n this.meshHelper = null;\r\n }\r\n\r\n load(main, mesh) {\r\n /* Global */\r\n //this.gui.close();\r\n\r\n this.model = main.model;\r\n this.meshHelper = main.meshHelper;\r\n\r\n /* Camera */\r\n const cameraFolder = this.gui.addFolder('Camera');\r\n const cameraFOVGui = cameraFolder.add(Config.camera, 'fov', 0, 180).name('Camera FOV');\r\n cameraFOVGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.camera.fov = value;\r\n });\r\n cameraFOVGui.onFinishChange(() => {\r\n this.camera.updateProjectionMatrix();\r\n\r\n this.controls.enableRotate = true;\r\n });\r\n const cameraAspectGui = cameraFolder.add(Config.camera, 'aspect', 0, 4).name('Camera Aspect');\r\n cameraAspectGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.camera.aspect = value;\r\n });\r\n cameraAspectGui.onFinishChange(() => {\r\n this.camera.updateProjectionMatrix();\r\n\r\n this.controls.enableRotate = true;\r\n });\r\n const cameraFogColorGui = cameraFolder.addColor(Config.fog, 'color').name('Fog Color');\r\n cameraFogColorGui.onChange((value) => {\r\n this.scene.fog.color.setHex(value);\r\n });\r\n const cameraFogNearGui = cameraFolder.add(Config.fog, 'near', 0.000, 0.010).name('Fog Near');\r\n cameraFogNearGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.scene.fog.density = value;\r\n });\r\n cameraFogNearGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n\r\n\r\n /* Controls */\r\n const controlsFolder = this.gui.addFolder('Controls');\r\n controlsFolder.add(Config.controls, 'autoRotate').name('Auto Rotate').onChange((value) => {\r\n this.controls.autoRotate = value;\r\n });\r\n const controlsAutoRotateSpeedGui = controlsFolder.add(Config.controls, 'autoRotateSpeed', -1, 1).name('Rotation Speed');\r\n controlsAutoRotateSpeedGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n this.controls.autoRotateSpeed = value;\r\n });\r\n controlsAutoRotateSpeedGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n\r\n\r\n /* Model */\r\n const modelFolder = this.gui.addFolder('Model');\r\n modelFolder.add(Config.model, 'type', [...Config.model.initialTypes]).name('Select Model').onChange((value) => {\r\n if (value) {\r\n if (Config.mesh.enableHelper)\r\n this.meshHelper.disable();\r\n\r\n Config.model.selected = Config.model.initialTypes.indexOf(value);\r\n this.unload();\r\n this.model.unload();\r\n this.model.load(value);\r\n }\r\n });\r\n\r\n /* Mesh */\r\n const meshFolder = this.gui.addFolder('Mesh');\r\n meshFolder.add(Config.mesh, 'enableHelper', true).name('Enable Helpers').onChange((value) => {\r\n if(value) {\r\n this.meshHelper.enable();\r\n } else {\r\n this.meshHelper.disable();\r\n }\r\n });\r\n meshFolder.add(Config.mesh, 'translucent', true).name('Translucent').onChange((value) => {\r\n if(value) {\r\n mesh.material.transparent = true;\r\n mesh.material.opacity = 0.5;\r\n } else {\r\n mesh.material.opacity = 1.0;\r\n }\r\n });\r\n meshFolder.add(Config.mesh, 'wireframe', true).name('Wireframe').onChange((value) => {\r\n mesh.material.wireframe = value;\r\n });\r\n\r\n\r\n /* Lights */\r\n // Ambient Light\r\n const ambientLightFolder = this.gui.addFolder('Ambient Light');\r\n ambientLightFolder.add(Config.ambientLight, 'enabled').name('Enabled').onChange((value) => {\r\n this.light.ambientLight.visible = value;\r\n });\r\n ambientLightFolder.addColor(Config.ambientLight, 'color').name('Color').onChange((value) => {\r\n this.light.ambientLight.color.setHex(value);\r\n });\r\n\r\n\r\n // Directional Light\r\n const directionalLightFolder = this.gui.addFolder('Directional Light');\r\n directionalLightFolder.add(Config.directionalLight, 'enabled').name('Enabled').onChange((value) => {\r\n this.light.directionalLight.visible = value;\r\n });\r\n directionalLightFolder.addColor(Config.directionalLight, 'color').name('Color').onChange((value) => {\r\n this.light.directionalLight.color.setHex(value);\r\n });\r\n const directionalLightIntensityGui = directionalLightFolder.add(Config.directionalLight, 'intensity', 0, 2).name('Intensity');\r\n directionalLightIntensityGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.intensity = value;\r\n });\r\n directionalLightIntensityGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const directionalLightPositionXGui = directionalLightFolder.add(Config.directionalLight, 'x', -1000, 1000).name('Position X');\r\n directionalLightPositionXGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.position.x = value;\r\n });\r\n directionalLightPositionXGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const directionalLightPositionYGui = directionalLightFolder.add(Config.directionalLight, 'y', -1000, 1000).name('Position Y');\r\n directionalLightPositionYGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.position.y = value;\r\n });\r\n directionalLightPositionYGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const directionalLightPositionZGui = directionalLightFolder.add(Config.directionalLight, 'z', -1000, 1000).name('Position Z');\r\n directionalLightPositionZGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.position.z = value;\r\n });\r\n directionalLightPositionZGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n\r\n // Shadow Map\r\n const shadowFolder = this.gui.addFolder('Shadow Map');\r\n shadowFolder.add(Config.shadow, 'enabled').name('Enabled').onChange((value) => {\r\n this.light.directionalLight.castShadow = value;\r\n });\r\n shadowFolder.add(Config.shadow, 'helperEnabled').name('Helper Enabled').onChange((value) => {\r\n this.light.directionalLightHelper.visible = value;\r\n });\r\n const shadowNearGui = shadowFolder.add(Config.shadow, 'near', 0, 400).name('Near');\r\n shadowNearGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.near = value;\r\n });\r\n shadowNearGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowFarGui = shadowFolder.add(Config.shadow, 'far', 0, 1200).name('Far');\r\n shadowFarGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.far = value;\r\n });\r\n shadowFarGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowTopGui = shadowFolder.add(Config.shadow, 'top', -400, 400).name('Top');\r\n shadowTopGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.top = value;\r\n });\r\n shadowTopGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowRightGui = shadowFolder.add(Config.shadow, 'right', -400, 400).name('Right');\r\n shadowRightGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.right = value;\r\n });\r\n shadowRightGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowBottomGui = shadowFolder.add(Config.shadow, 'bottom', -400, 400).name('Bottom');\r\n shadowBottomGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.bottom = value;\r\n });\r\n shadowBottomGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowLeftGui = shadowFolder.add(Config.shadow, 'left', -400, 400).name('Left');\r\n shadowLeftGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.camera.left = value;\r\n });\r\n shadowLeftGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n const shadowBiasGui = shadowFolder.add(Config.shadow, 'bias', -0.000010, 1).name('Bias');\r\n shadowBiasGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.directionalLight.shadow.bias = value;\r\n });\r\n shadowBiasGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n this.light.directionalLight.shadow.map.dispose();\r\n this.light.directionalLight.shadow.map = null;\r\n this.light.directionalLightHelper.update();\r\n });\r\n\r\n\r\n // Point Light\r\n const pointLightFolder = this.gui.addFolder('Point Light');\r\n pointLightFolder.add(Config.pointLight, 'enabled').name('Enabled').onChange((value) => {\r\n this.light.pointLight.visible = value;\r\n });\r\n pointLightFolder.addColor(Config.pointLight, 'color').name('Color').onChange((value) => {\r\n this.light.pointLight.color.setHex(value);\r\n });\r\n const pointLightIntensityGui = pointLightFolder.add(Config.pointLight, 'intensity', 0, 2).name('Intensity');\r\n pointLightIntensityGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.pointLight.intensity = value;\r\n });\r\n pointLightIntensityGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const pointLightDistanceGui = pointLightFolder.add(Config.pointLight, 'distance', 0, 1000).name('Distance');\r\n pointLightDistanceGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.pointLight.distance = value;\r\n });\r\n pointLightDistanceGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const pointLightPositionXGui = pointLightFolder.add(Config.pointLight, 'x', -1000, 1000).name('Position X');\r\n pointLightPositionXGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.pointLight.position.x = value;\r\n });\r\n pointLightPositionXGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const pointLightPositionYGui = pointLightFolder.add(Config.pointLight, 'y', -1000, 1000).name('Position Y');\r\n pointLightPositionYGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.pointLight.position.y = value;\r\n });\r\n pointLightPositionYGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const pointLightPositionZGui = pointLightFolder.add(Config.pointLight, 'z', -1000, 1000).name('Position Z');\r\n pointLightPositionZGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.pointLight.position.z = value;\r\n });\r\n pointLightPositionZGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n\r\n\r\n // Hemi Light\r\n const hemiLightFolder = this.gui.addFolder('Hemi Light');\r\n hemiLightFolder.add(Config.hemiLight, 'enabled').name('Enabled').onChange((value) => {\r\n this.light.hemiLight.visible = value;\r\n });\r\n hemiLightFolder.addColor(Config.hemiLight, 'color').name('Color').onChange((value) => {\r\n this.light.hemiLight.color.setHex(value);\r\n });\r\n hemiLightFolder.addColor(Config.hemiLight, 'groundColor').name('ground Color').onChange((value) => {\r\n this.light.hemiLight.groundColor.setHex(value);\r\n });\r\n const hemiLightIntensityGui = hemiLightFolder.add(Config.hemiLight, 'intensity', 0, 2).name('Intensity');\r\n hemiLightIntensityGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.hemiLight.intensity = value;\r\n });\r\n hemiLightIntensityGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const hemiLightPositionXGui = hemiLightFolder.add(Config.hemiLight, 'x', -1000, 1000).name('Position X');\r\n hemiLightPositionXGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.hemiLight.position.x = value;\r\n });\r\n hemiLightPositionXGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const hemiLightPositionYGui = hemiLightFolder.add(Config.hemiLight, 'y', -500, 1000).name('Position Y');\r\n hemiLightPositionYGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.hemiLight.position.y = value;\r\n });\r\n hemiLightPositionYGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n const hemiLightPositionZGui = hemiLightFolder.add(Config.hemiLight, 'z', -1000, 1000).name('Position Z');\r\n hemiLightPositionZGui.onChange((value) => {\r\n this.controls.enableRotate = false;\r\n\r\n this.light.hemiLight.position.z = value;\r\n });\r\n hemiLightPositionZGui.onFinishChange(() => {\r\n this.controls.enableRotate = true;\r\n });\r\n }\r\n\r\n unload() {\r\n this.gui.destroy();\r\n this.gui = new dat.GUI();\r\n }\r\n}\r\n","// Global imports -\r\nimport * as THREE from 'three';\r\nimport TWEEN from '@tweenjs/tween.js';\r\n\r\n// Local imports -\r\n// Components\r\nimport Renderer from './components/renderer';\r\nimport Camera from './components/camera';\r\nimport Light from './components/light';\r\nimport Controls from './components/controls';\r\nimport Geometry from './components/geometry';\r\n\r\n// Helpers\r\nimport Stats from './helpers/stats';\r\nimport MeshHelper from './helpers/meshHelper';\r\n\r\n// Model\r\nimport Texture from './model/texture';\r\nimport Model from './model/model';\r\n\r\n// Managers\r\nimport Interaction from './managers/interaction';\r\nimport DatGUI from './managers/datGUI';\r\n\r\n// data\r\nimport Config from './../data/config';\r\n// -- End of imports\r\n\r\n// This class instantiates and ties all of the components together, starts the loading process and renders the main loop\r\nexport default class Main {\r\n constructor(container) {\r\n // Set container property to container element\r\n this.container = container;\r\n\r\n // Start Three clock\r\n this.clock = new THREE.Clock();\r\n\r\n // Main scene creation\r\n this.scene = new THREE.Scene();\r\n this.scene.fog = new THREE.FogExp2(Config.fog.color, Config.fog.near);\r\n\r\n // Get Device Pixel Ratio first for retina\r\n if(window.devicePixelRatio) {\r\n Config.dpr = window.devicePixelRatio;\r\n }\r\n\r\n // Main renderer constructor\r\n this.renderer = new Renderer(this.scene, container);\r\n\r\n // Components instantiations\r\n this.camera = new Camera(this.renderer.threeRenderer);\r\n this.controls = new Controls(this.camera.threeCamera, container);\r\n this.light = new Light(this.scene);\r\n\r\n // Create and place lights in scene\r\n const lights = ['ambient', 'directional', 'point', 'hemi'];\r\n lights.forEach((light) => this.light.place(light));\r\n\r\n // Create and place geo in scene\r\n this.geometry = new Geometry(this.scene);\r\n this.geometry.make('plane')(150, 150, 10, 10);\r\n this.geometry.place([0, -20, 0], [Math.PI / 2, 0, 0]);\r\n\r\n // Set up rStats if dev environment\r\n if(Config.isDev && Config.isShowingStats) {\r\n this.stats = new Stats(this.renderer);\r\n this.stats.setUp();\r\n }\r\n\r\n // Set up gui\r\n if (Config.isDev) {\r\n this.gui = new DatGUI(this)\r\n }\r\n\r\n // Instantiate texture class\r\n this.texture = new Texture();\r\n\r\n // Start loading the textures and then go on to load the model after the texture Promises have resolved\r\n this.texture.load().then(() => {\r\n this.manager = new THREE.LoadingManager();\r\n\r\n // Textures loaded, load model\r\n this.model = new Model(this.scene, this.manager, this.texture.textures);\r\n this.model.load(Config.models[Config.model.selected].type);\r\n\r\n // onProgress callback\r\n this.manager.onProgress = (item, loaded, total) => {\r\n console.log(`${item}: ${loaded} ${total}`);\r\n };\r\n\r\n // All loaders done now\r\n this.manager.onLoad = () => {\r\n // Set up interaction manager with the app now that the model is finished loading\r\n new Interaction(this.renderer.threeRenderer, this.scene, this.camera.threeCamera, this.controls.threeControls);\r\n\r\n // Add dat.GUI controls if dev\r\n if(Config.isDev) {\r\n this.meshHelper = new MeshHelper(this.scene, this.model.obj);\r\n if (Config.mesh.enableHelper) this.meshHelper.enable();\r\n\r\n this.gui.load(this, this.model.obj);\r\n }\r\n\r\n // Everything is now fully loaded\r\n Config.isLoaded = true;\r\n this.container.querySelector('#loading').style.display = 'none';\r\n };\r\n });\r\n\r\n // Start render which does not wait for model fully loaded\r\n this.render();\r\n }\r\n\r\n render() {\r\n // Render rStats if Dev\r\n if(Config.isDev && Config.isShowingStats) {\r\n Stats.start();\r\n }\r\n\r\n // Call render function and pass in created scene and camera\r\n this.renderer.render(this.scene, this.camera.threeCamera);\r\n\r\n // rStats has finished determining render call now\r\n if(Config.isDev && Config.isShowingStats) {\r\n Stats.end();\r\n }\r\n\r\n // Delta time is sometimes needed for certain updates\r\n //const delta = this.clock.getDelta();\r\n\r\n // Call any vendor or module frame updates here\r\n TWEEN.update();\r\n this.controls.threeControls.update();\r\n\r\n // RAF\r\n requestAnimationFrame(this.render.bind(this)); // Bind the main class instead of window object\r\n }\r\n}\r\n","import Config from './data/config';\r\nimport Detector from './utils/detector';\r\nimport Main from './app/main';\r\n\r\n// Styles\r\nimport './../css/app.scss';\r\n\r\n// Check environment and set the Config helper\r\nif(__ENV__ === 'dev') {\r\n console.log('----- RUNNING IN DEV ENVIRONMENT! -----');\r\n\r\n Config.isDev = true;\r\n}\r\n\r\nfunction init() {\r\n // Check for webGL capabilities\r\n if(!Detector.webgl) {\r\n Detector.addGetWebGLMessage();\r\n } else {\r\n const container = document.getElementById('appContainer');\r\n new Main(container);\r\n }\r\n}\r\n\r\ninit();\r\n","module.exports = function (THREE) {\r\n var MOUSE = THREE.MOUSE;\r\n if (!MOUSE) MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };\r\n\r\n /**\r\n * @author qiao / https://github.com/qiao\r\n * @author mrdoob / http://mrdoob.com\r\n * @author alteredq / http://alteredqualia.com/\r\n * @author WestLangley / http://github.com/WestLangley\r\n * @author erich666 / http://erichaines.com\r\n */\r\n /*global THREE, console */\r\n\r\n function OrbitConstraint(object) {\r\n this.object = object;\r\n\r\n // \"target\" sets the location of focus, where the object orbits around\r\n // and where it pans with respect to.\r\n this.target = new THREE.Vector3();\r\n\r\n // Limits to how far you can dolly in and out ( PerspectiveCamera only )\r\n this.minDistance = 0;\r\n this.maxDistance = Infinity;\r\n\r\n // Limits to how far you can zoom in and out ( OrthographicCamera only )\r\n this.minZoom = 0;\r\n this.maxZoom = Infinity;\r\n\r\n // How far you can orbit vertically, upper and lower limits.\r\n // Range is 0 to Math.PI radians.\r\n this.minPolarAngle = 0; // radians\r\n this.maxPolarAngle = Math.PI; // radians\r\n\r\n // How far you can orbit horizontally, upper and lower limits.\r\n // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].\r\n this.minAzimuthAngle = -Infinity; // radians\r\n this.maxAzimuthAngle = Infinity; // radians\r\n\r\n // Set to true to enable damping (inertia)\r\n // If damping is enabled, you must call controls.update() in your animation loop\r\n this.enableDamping = false;\r\n this.dampingFactor = 0.25;\r\n\r\n ////////////\r\n // internals\r\n\r\n var scope = this;\r\n\r\n var EPS = 0.000001;\r\n\r\n // Current position in spherical coordinate system.\r\n var theta;\r\n var phi;\r\n\r\n // Pending changes\r\n var phiDelta = 0;\r\n var thetaDelta = 0;\r\n var scale = 1;\r\n var panOffset = new THREE.Vector3();\r\n var zoomChanged = false;\r\n\r\n // API\r\n\r\n this.getPolarAngle = function () {\r\n return phi;\r\n };\r\n\r\n this.getAzimuthalAngle = function () {\r\n return theta;\r\n };\r\n\r\n this.rotateLeft = function (angle) {\r\n thetaDelta -= angle;\r\n };\r\n\r\n this.rotateUp = function (angle) {\r\n phiDelta -= angle;\r\n };\r\n\r\n // pass in distance in world space to move left\r\n this.panLeft = (function () {\r\n var v = new THREE.Vector3();\r\n\r\n return function panLeft(distance) {\r\n var te = this.object.matrix.elements;\r\n\r\n // get X column of matrix\r\n v.set(te[0], te[1], te[2]);\r\n v.multiplyScalar(-distance);\r\n\r\n panOffset.add(v);\r\n };\r\n })();\r\n\r\n // pass in distance in world space to move up\r\n this.panUp = (function () {\r\n var v = new THREE.Vector3();\r\n\r\n return function panUp(distance) {\r\n var te = this.object.matrix.elements;\r\n\r\n // get Y column of matrix\r\n v.set(te[4], te[5], te[6]);\r\n v.multiplyScalar(distance);\r\n\r\n panOffset.add(v);\r\n };\r\n })();\r\n\r\n // pass in x,y of change desired in pixel space,\r\n // right and down are positive\r\n this.pan = function (deltaX, deltaY, screenWidth, screenHeight) {\r\n if (scope.object instanceof THREE.PerspectiveCamera) {\r\n // perspective\r\n var position = scope.object.position;\r\n var offset = position.clone().sub(scope.target);\r\n var targetDistance = offset.length();\r\n\r\n // half of the fov is center to top of screen\r\n targetDistance *= Math.tan(((scope.object.fov / 2) * Math.PI) / 180.0);\r\n\r\n // we actually don't use screenWidth, since perspective camera is fixed to screen height\r\n scope.panLeft((2 * deltaX * targetDistance) / screenHeight);\r\n scope.panUp((2 * deltaY * targetDistance) / screenHeight);\r\n } else if (scope.object instanceof THREE.OrthographicCamera) {\r\n // orthographic\r\n scope.panLeft((deltaX * (scope.object.right - scope.object.left)) / screenWidth);\r\n scope.panUp((deltaY * (scope.object.top - scope.object.bottom)) / screenHeight);\r\n } else {\r\n // camera neither orthographic or perspective\r\n console.warn(\r\n 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.'\r\n );\r\n }\r\n };\r\n\r\n this.dollyIn = function (dollyScale) {\r\n if (scope.object instanceof THREE.PerspectiveCamera) {\r\n scale /= dollyScale;\r\n } else if (scope.object instanceof THREE.OrthographicCamera) {\r\n scope.object.zoom = Math.max(\r\n this.minZoom,\r\n Math.min(this.maxZoom, this.object.zoom * dollyScale)\r\n );\r\n scope.object.updateProjectionMatrix();\r\n zoomChanged = true;\r\n } else {\r\n console.warn(\r\n 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.'\r\n );\r\n }\r\n };\r\n\r\n this.dollyOut = function (dollyScale) {\r\n if (scope.object instanceof THREE.PerspectiveCamera) {\r\n scale *= dollyScale;\r\n } else if (scope.object instanceof THREE.OrthographicCamera) {\r\n scope.object.zoom = Math.max(\r\n this.minZoom,\r\n Math.min(this.maxZoom, this.object.zoom / dollyScale)\r\n );\r\n scope.object.updateProjectionMatrix();\r\n zoomChanged = true;\r\n } else {\r\n console.warn(\r\n 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.'\r\n );\r\n }\r\n };\r\n\r\n this.update = (function () {\r\n var offset = new THREE.Vector3();\r\n\r\n // so camera.up is the orbit axis\r\n var quat = new THREE.Quaternion().setFromUnitVectors(object.up, new THREE.Vector3(0, 1, 0));\r\n var quatInverse = quat.clone().inverse();\r\n\r\n var lastPosition = new THREE.Vector3();\r\n var lastQuaternion = new THREE.Quaternion();\r\n\r\n return function () {\r\n var position = this.object.position;\r\n\r\n offset.copy(position).sub(this.target);\r\n\r\n // rotate offset to \"y-axis-is-up\" space\r\n offset.applyQuaternion(quat);\r\n\r\n // angle from z-axis around y-axis\r\n\r\n theta = Math.atan2(offset.x, offset.z);\r\n\r\n // angle from y-axis\r\n\r\n phi = Math.atan2(Math.sqrt(offset.x * offset.x + offset.z * offset.z), offset.y);\r\n\r\n theta += thetaDelta;\r\n phi += phiDelta;\r\n\r\n // restrict theta to be between desired limits\r\n theta = Math.max(this.minAzimuthAngle, Math.min(this.maxAzimuthAngle, theta));\r\n\r\n // restrict phi to be between desired limits\r\n phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, phi));\r\n\r\n // restrict phi to be betwee EPS and PI-EPS\r\n phi = Math.max(EPS, Math.min(Math.PI - EPS, phi));\r\n\r\n var radius = offset.length() * scale;\r\n\r\n // restrict radius to be between desired limits\r\n radius = Math.max(this.minDistance, Math.min(this.maxDistance, radius));\r\n\r\n // move target to panned location\r\n this.target.add(panOffset);\r\n\r\n offset.x = radius * Math.sin(phi) * Math.sin(theta);\r\n offset.y = radius * Math.cos(phi);\r\n offset.z = radius * Math.sin(phi) * Math.cos(theta);\r\n\r\n // rotate offset back to \"camera-up-vector-is-up\" space\r\n offset.applyQuaternion(quatInverse);\r\n\r\n position.copy(this.target).add(offset);\r\n\r\n this.object.lookAt(this.target);\r\n\r\n if (this.enableDamping === true) {\r\n thetaDelta *= 1 - this.dampingFactor;\r\n phiDelta *= 1 - this.dampingFactor;\r\n } else {\r\n thetaDelta = 0;\r\n phiDelta = 0;\r\n }\r\n\r\n scale = 1;\r\n panOffset.set(0, 0, 0);\r\n\r\n // update condition is:\r\n // min(camera displacement, camera rotation in radians)^2 > EPS\r\n // using small-angle approximation cos(x/2) = 1 - x^2 / 8\r\n\r\n if (\r\n zoomChanged ||\r\n lastPosition.distanceToSquared(this.object.position) > EPS ||\r\n 8 * (1 - lastQuaternion.dot(this.object.quaternion)) > EPS\r\n ) {\r\n lastPosition.copy(this.object.position);\r\n lastQuaternion.copy(this.object.quaternion);\r\n zoomChanged = false;\r\n\r\n return true;\r\n }\r\n\r\n return false;\r\n };\r\n })();\r\n }\r\n\r\n // This set of controls performs orbiting, dollying (zooming), and panning. It maintains\r\n // the \"up\" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is\r\n // supported.\r\n //\r\n // Orbit - left mouse / touch: one finger move\r\n // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish\r\n // Pan - right mouse, or arrow keys / touch: three finter swipe\r\n\r\n function OrbitControls(object, domElement) {\r\n var constraint = new OrbitConstraint(object);\r\n\r\n this.domElement = domElement !== undefined ? domElement : document;\r\n\r\n // API\r\n\r\n Object.defineProperty(this, 'constraint', {\r\n get: function () {\r\n return constraint;\r\n },\r\n });\r\n\r\n this.getPolarAngle = function () {\r\n return constraint.getPolarAngle();\r\n };\r\n\r\n this.getAzimuthalAngle = function () {\r\n return constraint.getAzimuthalAngle();\r\n };\r\n\r\n // Set to false to disable this control\r\n this.enabled = true;\r\n\r\n // center is old, deprecated; use \"target\" instead\r\n this.center = this.target;\r\n\r\n // This option actually enables dollying in and out; left as \"zoom\" for\r\n // backwards compatibility.\r\n // Set to false to disable zooming\r\n this.enableZoom = true;\r\n this.zoomSpeed = 1.0;\r\n\r\n // Set to false to disable rotating\r\n this.enableRotate = true;\r\n this.rotateSpeed = 1.0;\r\n\r\n // Set to false to disable panning\r\n this.enablePan = true;\r\n this.keyPanSpeed = 7.0; // pixels moved per arrow key push\r\n\r\n // Set to true to automatically rotate around the target\r\n // If auto-rotate is enabled, you must call controls.update() in your animation loop\r\n this.autoRotate = false;\r\n this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60\r\n\r\n // Set to false to disable use of the keys\r\n this.enableKeys = true;\r\n\r\n // The four arrow keys\r\n this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };\r\n\r\n // Mouse buttons\r\n this.mouseButtons = {\r\n ORBIT: THREE.MOUSE.LEFT,\r\n ZOOM: THREE.MOUSE.MIDDLE,\r\n PAN: THREE.MOUSE.RIGHT,\r\n };\r\n\r\n ////////////\r\n // internals\r\n\r\n var scope = this;\r\n\r\n var rotateStart = new THREE.Vector2();\r\n var rotateEnd = new THREE.Vector2();\r\n var rotateDelta = new THREE.Vector2();\r\n\r\n var panStart = new THREE.Vector2();\r\n var panEnd = new THREE.Vector2();\r\n var panDelta = new THREE.Vector2();\r\n\r\n var dollyStart = new THREE.Vector2();\r\n var dollyEnd = new THREE.Vector2();\r\n var dollyDelta = new THREE.Vector2();\r\n\r\n var STATE = {\r\n NONE: -1,\r\n ROTATE: 0,\r\n DOLLY: 1,\r\n PAN: 2,\r\n TOUCH_ROTATE: 3,\r\n TOUCH_DOLLY: 4,\r\n TOUCH_PAN: 5,\r\n };\r\n\r\n var state = STATE.NONE;\r\n\r\n // for reset\r\n\r\n this.target0 = this.target.clone();\r\n this.position0 = this.object.position.clone();\r\n this.zoom0 = this.object.zoom;\r\n\r\n // events\r\n\r\n var changeEvent = { type: 'change' };\r\n var startEvent = { type: 'start' };\r\n var endEvent = { type: 'end' };\r\n\r\n // pass in x,y of change desired in pixel space,\r\n // right and down are positive\r\n function pan(deltaX, deltaY) {\r\n var element = scope.domElement === document ? scope.domElement.body : scope.domElement;\r\n\r\n constraint.pan(deltaX, deltaY, element.clientWidth, element.clientHeight);\r\n }\r\n\r\n this.update = function () {\r\n if (this.autoRotate && state === STATE.NONE) {\r\n constraint.rotateLeft(getAutoRotationAngle());\r\n }\r\n\r\n if (constraint.update() === true) {\r\n this.dispatchEvent(changeEvent);\r\n }\r\n };\r\n\r\n this.reset = function () {\r\n state = STATE.NONE;\r\n\r\n this.target.copy(this.target0);\r\n this.object.position.copy(this.position0);\r\n this.object.zoom = this.zoom0;\r\n\r\n this.object.updateProjectionMatrix();\r\n this.dispatchEvent(changeEvent);\r\n\r\n this.update();\r\n };\r\n\r\n function getAutoRotationAngle() {\r\n return ((2 * Math.PI) / 60 / 60) * scope.autoRotateSpeed;\r\n }\r\n\r\n function getZoomScale() {\r\n return Math.pow(0.95, scope.zoomSpeed);\r\n }\r\n\r\n function onMouseDown(event) {\r\n if (scope.enabled === false) return;\r\n\r\n event.preventDefault();\r\n\r\n if (event.button === scope.mouseButtons.ORBIT) {\r\n if (scope.enableRotate === false) return;\r\n\r\n state = STATE.ROTATE;\r\n\r\n rotateStart.set(event.clientX, event.clientY);\r\n } else if (event.button === scope.mouseButtons.ZOOM) {\r\n if (scope.enableZoom === false) return;\r\n\r\n state = STATE.DOLLY;\r\n\r\n dollyStart.set(event.clientX, event.clientY);\r\n } else if (event.button === scope.mouseButtons.PAN) {\r\n if (scope.enablePan === false) return;\r\n\r\n state = STATE.PAN;\r\n\r\n panStart.set(event.clientX, event.clientY);\r\n }\r\n\r\n if (state !== STATE.NONE) {\r\n document.addEventListener('mousemove', onMouseMove, false);\r\n document.addEventListener('mouseup', onMouseUp, false);\r\n scope.dispatchEvent(startEvent);\r\n }\r\n }\r\n\r\n function onMouseMove(event) {\r\n if (scope.enabled === false) return;\r\n\r\n event.preventDefault();\r\n\r\n var element = scope.domElement === document ? scope.domElement.body : scope.domElement;\r\n\r\n if (state === STATE.ROTATE) {\r\n if (scope.enableRotate === false) return;\r\n\r\n rotateEnd.set(event.clientX, event.clientY);\r\n rotateDelta.subVectors(rotateEnd, rotateStart);\r\n\r\n // rotating across whole screen goes 360 degrees around\r\n constraint.rotateLeft(\r\n ((2 * Math.PI * rotateDelta.x) / element.clientWidth) * scope.rotateSpeed\r\n );\r\n\r\n // rotating up and down along whole screen attempts to go 360, but limited to 180\r\n constraint.rotateUp(\r\n ((2 * Math.PI * rotateDelta.y) / element.clientHeight) * scope.rotateSpeed\r\n );\r\n\r\n rotateStart.copy(rotateEnd);\r\n } else if (state === STATE.DOLLY) {\r\n if (scope.enableZoom === false) return;\r\n\r\n dollyEnd.set(event.clientX, event.clientY);\r\n dollyDelta.subVectors(dollyEnd, dollyStart);\r\n\r\n if (dollyDelta.y > 0) {\r\n constraint.dollyIn(getZoomScale());\r\n } else if (dollyDelta.y < 0) {\r\n constraint.dollyOut(getZoomScale());\r\n }\r\n\r\n dollyStart.copy(dollyEnd);\r\n } else if (state === STATE.PAN) {\r\n if (scope.enablePan === false) return;\r\n\r\n panEnd.set(event.clientX, event.clientY);\r\n panDelta.subVectors(panEnd, panStart);\r\n\r\n pan(panDelta.x, panDelta.y);\r\n\r\n panStart.copy(panEnd);\r\n }\r\n\r\n if (state !== STATE.NONE) scope.update();\r\n }\r\n\r\n function onMouseUp(/* event */) {\r\n if (scope.enabled === false) return;\r\n\r\n document.removeEventListener('mousemove', onMouseMove, false);\r\n document.removeEventListener('mouseup', onMouseUp, false);\r\n scope.dispatchEvent(endEvent);\r\n state = STATE.NONE;\r\n }\r\n\r\n function onMouseWheel(event) {\r\n if (scope.enabled === false || scope.enableZoom === false || state !== STATE.NONE) return;\r\n\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n var delta = 0;\r\n\r\n if (event.wheelDelta !== undefined) {\r\n // WebKit / Opera / Explorer 9\r\n\r\n delta = event.wheelDelta;\r\n } else if (event.detail !== undefined) {\r\n // Firefox\r\n\r\n delta = -event.detail;\r\n }\r\n\r\n if (delta > 0) {\r\n constraint.dollyOut(getZoomScale());\r\n } else if (delta < 0) {\r\n constraint.dollyIn(getZoomScale());\r\n }\r\n\r\n scope.update();\r\n scope.dispatchEvent(startEvent);\r\n scope.dispatchEvent(endEvent);\r\n }\r\n\r\n function onKeyDown(event) {\r\n if (scope.enabled === false || scope.enableKeys === false || scope.enablePan === false)\r\n return;\r\n\r\n switch (event.keyCode) {\r\n case scope.keys.UP:\r\n pan(0, scope.keyPanSpeed);\r\n scope.update();\r\n break;\r\n\r\n case scope.keys.BOTTOM:\r\n pan(0, -scope.keyPanSpeed);\r\n scope.update();\r\n break;\r\n\r\n case scope.keys.LEFT:\r\n pan(scope.keyPanSpeed, 0);\r\n scope.update();\r\n break;\r\n\r\n case scope.keys.RIGHT:\r\n pan(-scope.keyPanSpeed, 0);\r\n scope.update();\r\n break;\r\n }\r\n }\r\n\r\n function touchstart(event) {\r\n if (scope.enabled === false) return;\r\n\r\n switch (event.touches.length) {\r\n case 1: // one-fingered touch: rotate\r\n if (scope.enableRotate === false) return;\r\n\r\n state = STATE.TOUCH_ROTATE;\r\n\r\n rotateStart.set(event.touches[0].pageX, event.touches[0].pageY);\r\n break;\r\n\r\n case 2: // two-fingered touch: dolly\r\n if (scope.enableZoom === false) return;\r\n\r\n state = STATE.TOUCH_DOLLY;\r\n\r\n var dx = event.touches[0].pageX - event.touches[1].pageX;\r\n var dy = event.touches[0].pageY - event.touches[1].pageY;\r\n var distance = Math.sqrt(dx * dx + dy * dy);\r\n dollyStart.set(0, distance);\r\n break;\r\n\r\n case 3: // three-fingered touch: pan\r\n if (scope.enablePan === false) return;\r\n\r\n state = STATE.TOUCH_PAN;\r\n\r\n panStart.set(event.touches[0].pageX, event.touches[0].pageY);\r\n break;\r\n\r\n default:\r\n state = STATE.NONE;\r\n }\r\n\r\n if (state !== STATE.NONE) scope.dispatchEvent(startEvent);\r\n }\r\n\r\n function touchmove(event) {\r\n if (scope.enabled === false) return;\r\n\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n var element = scope.domElement === document ? scope.domElement.body : scope.domElement;\r\n\r\n switch (event.touches.length) {\r\n case 1: // one-fingered touch: rotate\r\n if (scope.enableRotate === false) return;\r\n if (state !== STATE.TOUCH_ROTATE) return;\r\n\r\n rotateEnd.set(event.touches[0].pageX, event.touches[0].pageY);\r\n rotateDelta.subVectors(rotateEnd, rotateStart);\r\n\r\n // rotating across whole screen goes 360 degrees around\r\n constraint.rotateLeft(\r\n ((2 * Math.PI * rotateDelta.x) / element.clientWidth) * scope.rotateSpeed\r\n );\r\n // rotating up and down along whole screen attempts to go 360, but limited to 180\r\n constraint.rotateUp(\r\n ((2 * Math.PI * rotateDelta.y) / element.clientHeight) * scope.rotateSpeed\r\n );\r\n\r\n rotateStart.copy(rotateEnd);\r\n\r\n scope.update();\r\n break;\r\n\r\n case 2: // two-fingered touch: dolly\r\n if (scope.enableZoom === false) return;\r\n if (state !== STATE.TOUCH_DOLLY) return;\r\n\r\n var dx = event.touches[0].pageX - event.touches[1].pageX;\r\n var dy = event.touches[0].pageY - event.touches[1].pageY;\r\n var distance = Math.sqrt(dx * dx + dy * dy);\r\n\r\n dollyEnd.set(0, distance);\r\n dollyDelta.subVectors(dollyEnd, dollyStart);\r\n\r\n if (dollyDelta.y > 0) {\r\n constraint.dollyOut(getZoomScale());\r\n } else if (dollyDelta.y < 0) {\r\n constraint.dollyIn(getZoomScale());\r\n }\r\n\r\n dollyStart.copy(dollyEnd);\r\n\r\n scope.update();\r\n break;\r\n\r\n case 3: // three-fingered touch: pan\r\n if (scope.enablePan === false) return;\r\n if (state !== STATE.TOUCH_PAN) return;\r\n\r\n panEnd.set(event.touches[0].pageX, event.touches[0].pageY);\r\n panDelta.subVectors(panEnd, panStart);\r\n\r\n pan(panDelta.x, panDelta.y);\r\n\r\n panStart.copy(panEnd);\r\n\r\n scope.update();\r\n break;\r\n\r\n default:\r\n state = STATE.NONE;\r\n }\r\n }\r\n\r\n function touchend(/* event */) {\r\n if (scope.enabled === false) return;\r\n\r\n scope.dispatchEvent(endEvent);\r\n state = STATE.NONE;\r\n }\r\n\r\n function contextmenu(event) {\r\n event.preventDefault();\r\n }\r\n\r\n this.dispose = function () {\r\n this.domElement.removeEventListener('contextmenu', contextmenu, false);\r\n this.domElement.removeEventListener('mousedown', onMouseDown, false);\r\n this.domElement.removeEventListener('mousewheel', onMouseWheel, false);\r\n this.domElement.removeEventListener('MozMousePixelScroll', onMouseWheel, false); // firefox\r\n\r\n this.domElement.removeEventListener('touchstart', touchstart, false);\r\n this.domElement.removeEventListener('touchend', touchend, false);\r\n this.domElement.removeEventListener('touchmove', touchmove, false);\r\n\r\n document.removeEventListener('mousemove', onMouseMove, false);\r\n document.removeEventListener('mouseup', onMouseUp, false);\r\n\r\n window.removeEventListener('keydown', onKeyDown, false);\r\n };\r\n\r\n this.domElement.addEventListener('contextmenu', contextmenu, false);\r\n\r\n this.domElement.addEventListener('mousedown', onMouseDown, false);\r\n this.domElement.addEventListener('mousewheel', onMouseWheel, false);\r\n this.domElement.addEventListener('MozMousePixelScroll', onMouseWheel, false); // firefox\r\n\r\n this.domElement.addEventListener('touchstart', touchstart, false);\r\n this.domElement.addEventListener('touchend', touchend, false);\r\n this.domElement.addEventListener('touchmove', touchmove, false);\r\n\r\n window.addEventListener('keydown', onKeyDown, false);\r\n\r\n // force an update at start\r\n this.update();\r\n }\r\n\r\n OrbitControls.prototype = Object.create(THREE.EventDispatcher.prototype);\r\n OrbitControls.prototype.constructor = OrbitControls;\r\n\r\n Object.defineProperties(OrbitControls.prototype, {\r\n object: {\r\n get: function () {\r\n return this.constraint.object;\r\n },\r\n },\r\n\r\n target: {\r\n get: function () {\r\n return this.constraint.target;\r\n },\r\n\r\n set: function (value) {\r\n console.warn('THREE.OrbitControls: target is now immutable. Use target.set() instead.');\r\n this.constraint.target.copy(value);\r\n },\r\n },\r\n\r\n minDistance: {\r\n get: function () {\r\n return this.constraint.minDistance;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.minDistance = value;\r\n },\r\n },\r\n\r\n maxDistance: {\r\n get: function () {\r\n return this.constraint.maxDistance;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.maxDistance = value;\r\n },\r\n },\r\n\r\n minZoom: {\r\n get: function () {\r\n return this.constraint.minZoom;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.minZoom = value;\r\n },\r\n },\r\n\r\n maxZoom: {\r\n get: function () {\r\n return this.constraint.maxZoom;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.maxZoom = value;\r\n },\r\n },\r\n\r\n minPolarAngle: {\r\n get: function () {\r\n return this.constraint.minPolarAngle;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.minPolarAngle = value;\r\n },\r\n },\r\n\r\n maxPolarAngle: {\r\n get: function () {\r\n return this.constraint.maxPolarAngle;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.maxPolarAngle = value;\r\n },\r\n },\r\n\r\n minAzimuthAngle: {\r\n get: function () {\r\n return this.constraint.minAzimuthAngle;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.minAzimuthAngle = value;\r\n },\r\n },\r\n\r\n maxAzimuthAngle: {\r\n get: function () {\r\n return this.constraint.maxAzimuthAngle;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.maxAzimuthAngle = value;\r\n },\r\n },\r\n\r\n enableDamping: {\r\n get: function () {\r\n return this.constraint.enableDamping;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.enableDamping = value;\r\n },\r\n },\r\n\r\n dampingFactor: {\r\n get: function () {\r\n return this.constraint.dampingFactor;\r\n },\r\n\r\n set: function (value) {\r\n this.constraint.dampingFactor = value;\r\n },\r\n },\r\n\r\n // backward compatibility\r\n\r\n noZoom: {\r\n get: function () {\r\n console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.');\r\n return !this.enableZoom;\r\n },\r\n\r\n set: function (value) {\r\n console.warn('THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.');\r\n this.enableZoom = !value;\r\n },\r\n },\r\n\r\n noRotate: {\r\n get: function () {\r\n console.warn(\r\n 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.'\r\n );\r\n return !this.enableRotate;\r\n },\r\n\r\n set: function (value) {\r\n console.warn(\r\n 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.'\r\n );\r\n this.enableRotate = !value;\r\n },\r\n },\r\n\r\n noPan: {\r\n get: function () {\r\n console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.');\r\n return !this.enablePan;\r\n },\r\n\r\n set: function (value) {\r\n console.warn('THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.');\r\n this.enablePan = !value;\r\n },\r\n },\r\n\r\n noKeys: {\r\n get: function () {\r\n console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.');\r\n return !this.enableKeys;\r\n },\r\n\r\n set: function (value) {\r\n console.warn('THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.');\r\n this.enableKeys = !value;\r\n },\r\n },\r\n\r\n staticMoving: {\r\n get: function () {\r\n console.warn(\r\n 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.'\r\n );\r\n return !this.constraint.enableDamping;\r\n },\r\n\r\n set: function (value) {\r\n console.warn(\r\n 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.'\r\n );\r\n this.constraint.enableDamping = !value;\r\n },\r\n },\r\n\r\n dynamicDampingFactor: {\r\n get: function () {\r\n console.warn(\r\n 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.'\r\n );\r\n return this.constraint.dampingFactor;\r\n },\r\n\r\n set: function (value) {\r\n console.warn(\r\n 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.'\r\n );\r\n this.constraint.dampingFactor = value;\r\n },\r\n },\r\n });\r\n\r\n return OrbitControls;\r\n};\r\n"],"sourceRoot":""}