blob: 2907d72681c7deb3ddb30ae31334e06bd1feab87 [file] [log] [blame]
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./node_modules/gl-matrix/src/gl-matrix/common.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat2d.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat3.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/mat4.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/quat.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/quat2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec2.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec3.js","webpack:///./node_modules/gl-matrix/src/gl-matrix/vec4.js","webpack:///./src/core/material.js","webpack:///./src/core/node.js","webpack:///./src/core/primitive.js","webpack:///./src/core/program.js","webpack:///./src/core/ray.js","webpack:///./src/core/renderer.js","webpack:///./src/core/texture.js","webpack:///./src/cottontail.js","webpack:///./src/geometry/box-builder.js","webpack:///./src/geometry/primitive-stream.js","webpack:///./src/loaders/gltf2.js","webpack:///./src/materials/pbr.js","webpack:///./src/math/gl-matrix.js","webpack:///./src/nodes/bounds-renderer.js","webpack:///./src/nodes/button.js","webpack:///./src/nodes/cube-sea.js","webpack:///./src/nodes/drop-shadow.js","webpack:///./src/nodes/gltf2.js","webpack:///./src/nodes/input-renderer.js","webpack:///./src/nodes/seven-segment-text.js","webpack:///./src/nodes/skybox.js","webpack:///./src/nodes/stats-viewer.js","webpack:///./src/nodes/video.js","webpack:///./src/scenes/scene.js","webpack:///./src/util/fallback-helper.js","webpack:///./src/util/query-args.js"],"names":["stateToBlendFunc","GL","WebGLRenderingContext","CAP","CULL_FACE","BLEND","DEPTH_TEST","STENCIL_TEST","COLOR_MASK","DEPTH_MASK","STENCIL_MASK","MAT_STATE","CAPS_RANGE","BLEND_SRC_SHIFT","BLEND_SRC_RANGE","BLEND_DST_SHIFT","BLEND_DST_RANGE","BLEND_FUNC_RANGE","DEPTH_FUNC_SHIFT","DEPTH_FUNC_RANGE","RENDER_ORDER","OPAQUE","SKY","TRANSPARENT","ADDITIVE","DEFAULT","state","mask","shift","value","SRC_COLOR","MaterialState","_state","blendFuncSrc","SRC_ALPHA","blendFuncDst","ONE_MINUS_SRC_ALPHA","depthFunc","LESS","NEVER","MaterialSampler","uniformName","_uniformName","_texture","MaterialUniform","defaultValue","length","_value","_length","Array","Material","renderOrder","_samplers","_uniforms","sampler","push","uniform","renderPrimitive","DEFAULT_TRANSLATION","Float32Array","DEFAULT_ROTATION","DEFAULT_SCALE","tmpRayMatrix","create","Node","name","children","parent","visible","selectable","_matrix","_dirtyTRS","_translation","_rotation","_scale","_dirtyWorldMatrix","_worldMatrix","_activeFrameId","_hoverFrameId","_renderPrimitives","_renderer","_selectHandler","renderer","clearRenderPrimitives","onRendererChanged","child","_setRenderer","cloneNode","copy","waitForComplete","then","primitive","addRenderPrimitive","addNode","clone","frameId","markActive","removeNode","i","indexOf","splice","setMatrixDirty","fromRotationTranslationScale","childPromises","Promise","all","_instances","index","ray","localRay","_min","invert","worldMatrix","multiply","transformMatrix","intersection","intersectsAABB","_max","transformMat4","_hitTestSelectableNode","origin","fromValues","x","y","z","node","distance","result","childResult","hitTest","timestamp","frameDelta","onUpdate","_update","_updateLocalMatrix","mul","PrimitiveAttribute","buffer","componentCount","componentType","stride","byteOffset","normalized","Primitive","attributes","elementCount","mode","indexBuffer","indexByteOffset","indexType","min","max","Program","gl","vertSrc","fragSrc","attribMap","defines","_gl","program","createProgram","attrib","_firstUse","_nextUseCallbacks","definesString","define","_vertShader","createShader","VERTEX_SHADER","attachShader","shaderSource","compileShader","_fragShader","FRAGMENT_SHADER","attribName","bindAttribLocation","linkProgram","callback","getProgramParameter","LINK_STATUS","getShaderParameter","COMPILE_STATUS","console","error","getShaderInfoLog","getProgramInfoLog","deleteProgram","attribCount","ACTIVE_ATTRIBUTES","attribInfo","getActiveAttrib","getAttribLocation","uniformCount","ACTIVE_UNIFORMS","uniformInfo","getActiveUniform","replace","getUniformLocation","deleteShader","useProgram","normalMat","RAY_INTERSECTION_OFFSET","Ray","matrix","_dir","fromMat4","transformMat3","dir","r","bounds","tmin","sign","inv_dir","tmax","tymin","tymax","tzmin","tzmax","t","Math","intersectionPoint","scale","add","normalize","createWebGLContext","ATTRIB","POSITION","NORMAL","TANGENT","TEXCOORD_0","TEXCOORD_1","COLOR_0","ATTRIB_MASK","DEF_LIGHT_DIR","DEF_LIGHT_COLOR","PRECISION_REGEX","RegExp","VERTEX_SHADER_SINGLE_ENTRY","VERTEX_SHADER_MULTI_ENTRY","FRAGMENT_SHADER_ENTRY","isPowerOfTwo","n","glAttribs","alpha","webglCanvas","document","createElement","contextTypes","webgl2","context","contextType","getContext","webglType","RenderView","projectionMatrix","viewMatrix","viewport","eye","_eye","_eyeIndex","RenderBuffer","target","usage","_target","_usage","_buffer","_promise","resolve","RenderPrimitiveAttribute","primitiveAttribute","_attrib_index","_componentCount","_componentType","_stride","_byteOffset","_normalized","RenderPrimitiveAttributeBuffer","_attributes","RenderPrimitive","_material","setPrimitive","_mode","_elementCount","_vao","_complete","_attributeBuffers","_attributeMask","attribute","renderAttribute","foundBuffer","attributeBuffer","_indexBuffer","_indexByteOffset","_indexType","material","reject","completionPromises","_samplerDictionary","_uniform_dictionary","RenderTexture","texture","_activeCallback","inverseMatrix","setCap","glEnum","cap","prevState","change","enable","disable","RenderMaterialSampler","materialSampler","_renderTexture","_getRenderTexture","_index","RenderMaterialUniform","materialUniform","_uniform","RenderMaterial","_program","_completeForActiveFrame","renderSampler","renderUniform","_firstBind","_renderOrder","activeTexture","TEXTURE0","bindTexture","TEXTURE_2D","uniform1fv","uniform2fv","uniform3fv","uniform4fv","otherState","Renderer","_frameId","_programCache","_textureCache","_cameraPositions","_vaoExt","getExtension","fragHighPrecision","getShaderPrecisionFormat","HIGH_FLOAT","_defaultFragPrecision","precision","_depthMaskNeedsReset","_colorMaskNeedsReset","_globalLightColor","_globalLightDir","data","STATIC_DRAW","glBuffer","createBuffer","renderBuffer","bindBuffer","bufferData","byteLength","offset","bufferSubData","updateRenderBuffer","_getMaterialProgram","renderMaterial","setRenderMaterial","meshNode","createRenderPrimitive","views","rootNode","vp","width","height","cameraPosition","set","renderPrimitives","_drawRenderPrimitiveSet","bindVertexArrayOES","depthMask","colorMask","attribMask","use","LIGHT_DIRECTION","LIGHT_COLOR","uniformMatrix4fv","PROJECTION_MATRIX","VIEW_MATRIX","CAMERA_POSITION","uniform1i","EYE_INDEX","eyeIndex","_bindMaterialState","bind","createVertexArrayOES","_bindPrimitive","view","instance","MODEL_MATRIX","drawElements","drawArrays","key","textureKey","Error","textureHandle","createTexture","renderTexture","texImage2D","format","_type","_data","_setSamplerParameters","UNSIGNED_BYTE","source","_video","addEventListener","paused","waiting","powerOfTwo","mipmap","generateMipmap","minFilter","LINEAR_MIPMAP_LINEAR","LINEAR","wrapS","REPEAT","CLAMP_TO_EDGE","wrapT","texParameteri","TEXTURE_MAG_FILTER","magFilter","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","materialName","vertexSource","fragmentSource","getProgramDefines","_getProgramKey","multiview","fullVertexSource","precisionMatch","match","fragPrecisionHeader","fullFragmentSource","onNextUse","enableVertexAttribArray","disableVertexAttribArray","ARRAY_BUFFER","vertexAttribPointer","ELEMENT_ARRAY_BUFFER","prevMaterial","_capsDiff","colorMaskChange","depthMaskChange","stencilMaskChange","stencilMask","_blendDiff","blendFunc","_depthFuncDiff","TextureSampler","Texture","RGBA","ImageTexture","img","_img","_imgBitmap","src","complete","naturalWidth","_finishImage","window","createImageBitmap","imgBitmap","UrlTexture","url","Image","BlobTexture","blob","URL","createObjectURL","VideoTexture","video","readyState","videoWidth","videoHeight","nextDataTextureIndex","DataTexture","type","_width","_height","_format","_key","ColorTexture","g","b","a","colorData","Uint8Array","PrimitiveStream","BoxBuilder","PbrMaterial","mat4","mat3","vec3","vec4","quat","BoundsRenderer","ButtonNode","DropShadowNode","CubeSeaNode","Gltf2Node","SkyboxNode","VideoNode","WebXRView","Scene","FallbackHelper","QueryArgs","stream","primitiveStream","w","h","d","wh","hh","dh","cx","cy","cz","startGeometry","idx","nextVertexIndex","pushTriangle","pushVertex","endGeometry","center","size","hs","pushBox","tempVec3","options","_vertices","_indices","_geometryStarted","_vertexOffset","_vertexIndex","_highIndex","_flipWinding","_invertNormals","_transform","_normalTransform","u","v","nx","ny","nz","idxA","idxB","idxC","vertexBuffer","createRenderBuffer","Uint16Array","attribs","FLOAT","setIndexBuffer","setBounds","GeometryBuilderBase","_stream","finishPrimitive","clear","GLB_MAGIC","CHUNK_TYPE","JSON","BIN","isAbsoluteUri","uri","absRegEx","location","protocol","isDataUri","dataRegEx","resolveUri","baseUrl","getComponentCount","Gltf2Loader","fetch","response","lastIndexOf","substring","endsWith","json","loadFromJson","arrayBuffer","loadFromBinary","headerView","DataView","magic","getUint32","version","chunks","chunkOffset","chunkHeaderView","chunkLength","chunkType","slice","decoder","TextDecoder","jsonString","decode","parse","binaryChunk","asset","minVersion","buffers","Gltf2Resource","bufferViews","bufferView","Gltf2BufferView","images","image","textures","glTexture","getTexture","textureInfo","materials","glMaterial","pbr","pbrMetallicRoughness","baseColorFactor","baseColor","baseColorTexture","metallicRoughnessFactor","metallicFactor","roughnessFactor","metallicRoughness","metallicRoughnessTexture","normal","normalTexture","occlusion","occlusionTexture","occlusionStrength","strength","emissiveFactor","emissive","emissiveTexture","alphaMode","blend","cullFace","doubleSided","accessors","meshes","mesh","glMesh","Gltf2Mesh","primitives","accessor","count","glAttribute","byteStride","glPrimitive","indices","sceneNode","scene","scenes","nodes","nodeId","processNodes","glNode","translation","rotation","_viewPromise","_renderBuffer","dataView","_dataPromise","base64String","binaryArray","from","atob","c","charCodeAt","Blob","mimeType","VERTEX_SOURCE","EPIC_PBR_FUNCTIONS","FRAGMENT_SOURCE","defineSampler","defineUniform","programDefines","glMatrix","mat2","mat2d","quat2","vec2","BoundsMaterial","ONE","depthTest","_stageBounds","stageBounds","verts","pointCount","geometry","point","BUTTON_SIZE","BUTTON_CORNER_RADIUS","BUTTON_CORNER_SEGMENTS","BUTTON_ICON_SIZE","BUTTON_LAYER_DISTANCE","BUTTON_COLOR","BUTTON_ALPHA","BUTTON_HOVER_COLOR","BUTTON_HOVER_ALPHA","BUTTON_HOVER_SCALE","BUTTON_HOVER_TRANSITION_TIME_MS","ButtonMaterial","ButtonIconMaterial","icon","iconTexture","_iconTexture","_hovered","_hoverT","hd","ihs","segments","rad","PI","cos","sin","section","floor","buttonPrimitive","_buttonRenderPrimitive","iconPrimitive","iconMaterial","_iconRenderPrimitive","hoverAmount","uniforms","_updateHoverState","samplers","CubeSeaMaterial","heavy","heavyGpu","cubeCount","cubeScale","halfOnly","autoRotate","imageUrl","_renderPrimitive","boxBuilder","pushCube","heroPrimitive","heroNode","createMesh","rebuildCubes","cubeSeaNode","halfGrid","pos","cubeSeaPrimitive","fromRotation","SHADOW_SEGMENTS","SHADOW_GROUND_OFFSET","SHADOW_CENTER_ALPHA","SHADOW_INNER_ALPHA","SHADOW_OUTER_ALPHA","SHADOW_INNER_RADIUS","SHADOW_OUTER_RADIUS","DropShadowMaterial","LEQUAL","segRad","shadowPrimitive","_shadowRenderPrimitive","gltfLoaderMap","WeakMap","_url","_resolver","_rejecter","loader","get","_ensurePromise","loadFromUrl","catch","err","LASER_TEXTURE_DATA","LASER_LENGTH","LASER_DIAMETER","LASER_FADE_END","LASER_FADE_POINT","LASER_DEFAULT_COLOR","CURSOR_RADIUS","CURSOR_SHADOW_RADIUS","CURSOR_SHADOW_INNER_LUMINANCE","CURSOR_SHADOW_OUTER_LUMINANCE","CURSOR_SHADOW_INNER_OPACITY","CURSOR_SHADOW_OUTER_OPACITY","CURSOR_OPACITY","CURSOR_SEGMENTS","CURSOR_DEFAULT_COLOR","CURSOR_DEFAULT_HIDDEN_COLOR","DEFAULT_RESET_OPTIONS","controllers","lasers","cursors","LaserMaterial","laser","laserColor","CURSOR_VERTEX_SHADER","CURSOR_FRAGMENT_SHADER","CursorMaterial","cursorColor","CursorHiddenMaterial","GEQUAL","InputRenderer","_maxInputElements","_controllers","_controllerNode","_controllerNodeHandedness","_lasers","_cursors","_activeControllers","_activeLasers","_activeCursors","controllerNode","handedness","gripMatrix","controller","targetRay","_createLaserMesh","cursorPos","_createCursorMesh","cursor","lr","ll","laserVerts","laserIndices","laserVertexBuffer","laserIndexBuffer","laserIndexCount","laserAttribs","laserPrimitive","laserMaterial","laserRenderPrimitive","cursorVerts","cursorIndices","indexOffset","cursorVertexBuffer","cursorIndexBuffer","cursorIndexCount","cursorAttribs","cursorPrimitive","cursorMaterial","cursorHiddenMaterial","cursorRenderPrimitive","cursorHiddenRenderPrimitive","TEXT_KERNING","SevenSegmentMaterial","SevenSegmentText","_text","_charNodes","clearNodes","vertices","segmentIndices","thickness","defineSegment","id","left","top","right","bottom","characters","defineCharacter","character","segment","vertexAttribs","_charPrimitives","char","charDef","text","charPrimitive","SkyboxMaterial","texCoordScaleOffset","_displayMode","displayMode","_rotationY","rotationY","latSegments","lonSegments","theta","sinTheta","cosTheta","idxOffsetA","idxOffsetB","j","phi","SEGMENTS","MAX_FPS","StatsMaterial","segmentToX","fpsToY","fpsToRGB","now","performance","Date","StatsViewer","_performanceMonitoring","_startTime","_prevFrameTime","_prevGraphUpdateTime","_frames","_fpsAverage","_fpsMin","_fpsStep","_lastSegment","_fpsVertexBuffer","_fpsRenderPrimitive","_fpsNode","_sevenSegmentNode","fpsVerts","fpsIndices","addBGSquare","DYNAMIC_DRAW","fpsIndexBuffer","fpsAttribs","fpsPrimitive","time","frameFps","intervalTime","round","_updateGraph","log","valueLow","valueHigh","color","y0","y1","updateVerts","VideoMaterial","_video_texture","pose","layer","getViewMatrix","getViewport","_timestamp","_frameDelta","_statsStanding","_stats","_statsEnabled","enableStats","_inputRenderer","_resetInputEndFrame","_lastTimestamp","_hoverFrame","_hoveredNodes","frame","frameOfRef","session","getInputSources","inputSources","newHoveredNodes","lastHoverFrame","inputSource","inputPose","getInputPose","inputRenderer","addController","targetRayMode","addLaserPointer","hitResult","addCursor","onHoverStart","cursorDistance","direction","hoverNode","onHoverEnd","handleSelectPointer","handleSelect","fromEuler","drawViewArray","xrFrame","baseLayer","bindFramebuffer","FRAMEBUFFER","framebuffer","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","drawViews","prevTimestamp","begin","reset","end","LOOK_SPEED","_emulateStage","lookYaw","lookPitch","identity","onResize","canvas","offsetWidth","devicePixelRatio","offsetHeight","perspective","drawingBufferWidth","drawingBufferHeight","lastTouchX","lastTouchY","ev","touches","pageX","pageY","onLook","buttons","movementX","movementY","preventDefault","boundOnFrame","onFrame","requestAnimationFrame","yaw","pitch","updateView","startFrame","draw","endFrame","rotateX","rotateY","translate","urlArgs","onhashchange","ensureArgsCached","query","search","hash","vars","split","pair","toLowerCase","decodeURIComponent","lcaseName","parseInt","parseFloat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;;;;;ACnEA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC7DA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChbA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjdA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAU,KAAK;AACf,UAAU,KAAK;AACf;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,UAAU,KAAK;AACf,UAAU,KAAK;AACf;AACA,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAIA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC5vBA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,YAAY,WAAW,WAAW;AAClC;AACA;AACA;AACA;;AAEA,YAAY,WAAW,YAAY;AACnC;AACA;AACA;AACA;;AAEA,aAAa,YAAY,YAAY;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,eAAe,YAAY,YAAY;AACvC,eAAe,YAAY,YAAY;AACvC,eAAe,YAAY,aAAa;;AAExC,iBAAiB,cAAc,cAAc;AAC7C,iBAAiB,cAAc,cAAc;AAC7C,iBAAiB,cAAc,eAAe;;AAE9C;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,2EAAyC,aAAa;;AAEtD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,aAAa,YAAY,YAAY;AACrC,aAAa,YAAY,YAAY;AACrC,aAAa,YAAY,aAAa;;AAEtC;AACA,sBAAsB,yBAAyB;AAC/C,0BAA0B,qBAAqB;AAC/C,0BAA0B,yBAAyB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA,2EAAyC,aAAa;;AAEtD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9rDA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,KAAK;AACjB,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,oCAAoC;AACpC;AACA,sBAAsB;AACtB;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,EAAE;AACb,WAAW,EAAE;AACb,WAAW,EAAE;AACb,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjnBD;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACA;;AAEA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,YAAY,KAAK;AACjB,YAAY,MAAM;AAClB,YAAY,KAAK;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,MAAM;AACjB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC11BA;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,MAAM;AACjB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB;AACpB;AACA,oBAAoB;AACpB;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvkBD;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB,iBAAiB;AACrC;AACA,oBAAoB,iBAAiB;AACrC;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClxBD;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB,aAAa,KAAK;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,KAAK;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,aAAa,OAAO;AACpB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,KAAK;AAChB,WAAW,KAAK;AAChB,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,MAAM;AACjB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,SAAS;AACpB,WAAW,OAAO;AAClB,aAAa,MAAM;AACnB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;;AAEA,mBAAmB,OAAO;AAC1B,oBAAoB,iBAAiB,iBAAiB;AACtD;AACA,oBAAoB,iBAAiB,iBAAiB;AACtD;;AAEA;AACA;AACA,CAAC;;;;;;;;;;;;;;;;;;;;;QC/hBeA,gB,GAAAA,gB;;;;AA9DhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMC,KAAKC,qBAAX,C,CAAkC;;AAE3B,IAAMC,oBAAM;AACjB;AACAC,aAAW,KAFM;AAGjBC,SAAO,KAHU;AAIjBC,cAAY,KAJK;AAKjBC,gBAAc,KALG;AAMjBC,cAAY,KANK;AAOjBC,cA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,KAAK,CAAL,CAAnB,CAAjC;AACD;AACF;AACF;;IAEYngB,S,WAAAA,S;;;;;;;8BACMjc,I,EAAMpB,Y,EAAc;AACnCk9B;AACA,UAAIS,YAAYv8B,KAAKq8B,WAAL,EAAhB;AACA,UAAIE,aAAaX,OAAjB,EAA0B;AACxB,eAAOA,QAAQW,SAAR,CAAP;AACD;AACD,aAAO39B,YAAP;AACD;;;2BAEaoB,I,EAAMpB,Y,EAAc;AAChCk9B;AACA,UAAIS,YAAYv8B,KAAKq8B,WAAL,EAAhB;AACA,UAAIE,aAAaX,OAAjB,EAA0B;AACxB,eAAOY,SAASZ,QAAQW,SAAR,CAAT,EAA6B,EAA7B,CAAP;AACD;AACD,aAAO39B,YAAP;AACD;;;6BAEeoB,I,EAAMpB,Y,EAAc;AAClCk9B;AACA,UAAIS,YAAYv8B,KAAKq8B,WAAL,EAAhB;AACA,UAAIE,aAAaX,OAAjB,EAA0B;AACxB,eAAOa,WAAWb,QAAQW,SAAR,CAAX,CAAP;AACD;AACD,aAAO39B,YAAP;AACD;;;4BAEcoB,I,EAAMpB,Y,EAAc;AACjCk9B;AACA,UAAIS,YAAYv8B,KAAKq8B,WAAL,EAAhB;AACA,UAAIE,aAAaX,OAAjB,EAA0B;AACxB,eAAOY,SAASZ,QAAQW,SAAR,CAAT,EAA6B,EAA7B,KAAoC,CAA3C;AACD;AACD,aAAO39B,YAAP;AACD","file":"cottontail.debug.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/cottontail.js\");\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\n/**\r\n * Common utilities\r\n * @module glMatrix\r\n */\r\n\r\n// Configuration Constants\r\nexport const EPSILON = 0.000001;\r\nexport let ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;\r\nexport const RANDOM = Math.random;\r\n\r\n/**\r\n * Sets the type of array used when creating new vectors and matrices\r\n *\r\n * @param {Type} type Array type, such as Float32Array or Array\r\n */\r\nexport function setMatrixArrayType(type) {\r\n ARRAY_TYPE = type;\r\n}\r\n\r\nconst degree = Math.PI / 180;\r\n\r\n/**\r\n * Convert Degree To Radian\r\n *\r\n * @param {Number} a Angle in Degrees\r\n */\r\nexport function toRadian(a) {\r\n return a * degree;\r\n}\r\n\r\n/**\r\n * Tests whether or not the arguments have approximately the same value, within an absolute\r\n * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less\r\n * than or equal to 1.0, and a relative tolerance is used for larger values)\r\n *\r\n * @param {Number} a The first number to test.\r\n * @param {Number} b The second number to test.\r\n * @returns {Boolean} True if the numbers are approximately equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n return Math.abs(a - b) <= EPSILON*Math.max(1.0, Math.abs(a), Math.abs(b));\r\n}\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\"\r\n\r\n/**\r\n * 2x2 Matrix\r\n * @module mat2\r\n */\r\n\r\n/**\r\n * Creates a new identity mat2\r\n *\r\n * @returns {mat2} a new 2x2 matrix\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new mat2 initialized with values from an existing matrix\r\n *\r\n * @param {mat2} a matrix to clone\r\n * @returns {mat2} a new 2x2 matrix\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one mat2 to another\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the source matrix\r\n * @returns {mat2} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set a mat2 to the identity matrix\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @returns {mat2} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Create a new mat2 with the given values\r\n *\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\r\n * @returns {mat2} out A new 2x2 matrix\r\n */\r\nexport function fromValues(m00, m01, m10, m11) {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m10;\r\n out[3] = m11;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a mat2 to the given values\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 2)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 3)\r\n * @returns {mat2} out\r\n */\r\nexport function set(out, m00, m01, m10, m11) {\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m10;\r\n out[3] = m11;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transpose the values of a mat2\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the source matrix\r\n * @returns {mat2} out\r\n */\r\nexport function transpose(out, a) {\r\n // If we are transposing ourselves we can skip a few steps but have to cache\r\n // some values\r\n if (out === a) {\r\n let a1 = a[1];\r\n out[1] = a[2];\r\n out[2] = a1;\r\n } else {\r\n out[0] = a[0];\r\n out[1] = a[2];\r\n out[2] = a[1];\r\n out[3] = a[3];\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Inverts a mat2\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the source matrix\r\n * @returns {mat2} out\r\n */\r\nexport function invert(out, a) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n\r\n // Calculate the determinant\r\n let det = a0 * a3 - a2 * a1;\r\n\r\n if (!det) {\r\n return null;\r\n }\r\n det = 1.0 / det;\r\n\r\n out[0] = a3 * det;\r\n out[1] = -a1 * det;\r\n out[2] = -a2 * det;\r\n out[3] = a0 * det;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the adjugate of a mat2\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the source matrix\r\n * @returns {mat2} out\r\n */\r\nexport function adjoint(out, a) {\r\n // Caching this value is nessecary if out == a\r\n let a0 = a[0];\r\n out[0] = a[3];\r\n out[1] = -a[1];\r\n out[2] = -a[2];\r\n out[3] = a0;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the determinant of a mat2\r\n *\r\n * @param {mat2} a the source matrix\r\n * @returns {Number} determinant of a\r\n */\r\nexport function determinant(a) {\r\n return a[0] * a[3] - a[2] * a[1];\r\n}\r\n\r\n/**\r\n * Multiplies two mat2's\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the first operand\r\n * @param {mat2} b the second operand\r\n * @returns {mat2} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\r\n out[0] = a0 * b0 + a2 * b1;\r\n out[1] = a1 * b0 + a3 * b1;\r\n out[2] = a0 * b2 + a2 * b3;\r\n out[3] = a1 * b2 + a3 * b3;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a mat2 by the given angle\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat2} out\r\n */\r\nexport function rotate(out, a, rad) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n out[0] = a0 * c + a2 * s;\r\n out[1] = a1 * c + a3 * s;\r\n out[2] = a0 * -s + a2 * c;\r\n out[3] = a1 * -s + a3 * c;\r\n return out;\r\n}\r\n\r\n/**\r\n * Scales the mat2 by the dimensions in the given vec2\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the matrix to rotate\r\n * @param {vec2} v the vec2 to scale the matrix by\r\n * @returns {mat2} out\r\n **/\r\nexport function scale(out, a, v) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let v0 = v[0], v1 = v[1];\r\n out[0] = a0 * v0;\r\n out[1] = a1 * v0;\r\n out[2] = a2 * v1;\r\n out[3] = a3 * v1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a given angle\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat2.identity(dest);\r\n * mat2.rotate(dest, dest, rad);\r\n *\r\n * @param {mat2} out mat2 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat2} out\r\n */\r\nexport function fromRotation(out, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n out[0] = c;\r\n out[1] = s;\r\n out[2] = -s;\r\n out[3] = c;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector scaling\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat2.identity(dest);\r\n * mat2.scale(dest, dest, vec);\r\n *\r\n * @param {mat2} out mat2 receiving operation result\r\n * @param {vec2} v Scaling vector\r\n * @returns {mat2} out\r\n */\r\nexport function fromScaling(out, v) {\r\n out[0] = v[0];\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = v[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a mat2\r\n *\r\n * @param {mat2} a matrix to represent as a string\r\n * @returns {String} string representation of the matrix\r\n */\r\nexport function str(a) {\r\n return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\r\n}\r\n\r\n/**\r\n * Returns Frobenius norm of a mat2\r\n *\r\n * @param {mat2} a the matrix to calculate Frobenius norm of\r\n * @returns {Number} Frobenius norm\r\n */\r\nexport function frob(a) {\r\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2)))\r\n}\r\n\r\n/**\r\n * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix\r\n * @param {mat2} L the lower triangular matrix\r\n * @param {mat2} D the diagonal matrix\r\n * @param {mat2} U the upper triangular matrix\r\n * @param {mat2} a the input matrix to factorize\r\n */\r\n\r\nexport function LDU(L, D, U, a) {\r\n L[2] = a[2]/a[0];\r\n U[0] = a[0];\r\n U[1] = a[1];\r\n U[3] = a[3] - L[2] * U[1];\r\n return [L, D, U];\r\n}\r\n\r\n/**\r\n * Adds two mat2's\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the first operand\r\n * @param {mat2} b the second operand\r\n * @returns {mat2} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts matrix b from matrix a\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the first operand\r\n * @param {mat2} b the second operand\r\n * @returns {mat2} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n out[3] = a[3] - b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {mat2} a The first matrix.\r\n * @param {mat2} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have approximately the same elements in the same position.\r\n *\r\n * @param {mat2} a The first matrix.\r\n * @param {mat2} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)));\r\n}\r\n\r\n/**\r\n * Multiply each element of the matrix by a scalar.\r\n *\r\n * @param {mat2} out the receiving matrix\r\n * @param {mat2} a the matrix to scale\r\n * @param {Number} b amount to scale the matrix's elements by\r\n * @returns {mat2} out\r\n */\r\nexport function multiplyScalar(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two mat2's after multiplying each element of the second operand by a scalar value.\r\n *\r\n * @param {mat2} out the receiving vector\r\n * @param {mat2} a the first operand\r\n * @param {mat2} b the second operand\r\n * @param {Number} scale the amount to scale b's elements by before adding\r\n * @returns {mat2} out\r\n */\r\nexport function multiplyScalarAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n out[3] = a[3] + (b[3] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Alias for {@link mat2.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link mat2.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * 2x3 Matrix\r\n * @module mat2d\r\n *\r\n * @description\r\n * A mat2d contains six elements defined as:\r\n * <pre>\r\n * [a, c, tx,\r\n * b, d, ty]\r\n * </pre>\r\n * This is a short form for the 3x3 matrix:\r\n * <pre>\r\n * [a, c, tx,\r\n * b, d, ty,\r\n * 0, 0, 1]\r\n * </pre>\r\n * The last row is ignored so the array is shorter and operations are faster.\r\n */\r\n\r\n/**\r\n * Creates a new identity mat2d\r\n *\r\n * @returns {mat2d} a new 2x3 matrix\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(6);\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n out[4] = 0;\r\n out[5] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new mat2d initialized with values from an existing matrix\r\n *\r\n * @param {mat2d} a matrix to clone\r\n * @returns {mat2d} a new 2x3 matrix\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(6);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one mat2d to another\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the source matrix\r\n * @returns {mat2d} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set a mat2d to the identity matrix\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @returns {mat2d} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n out[4] = 0;\r\n out[5] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Create a new mat2d with the given values\r\n *\r\n * @param {Number} a Component A (index 0)\r\n * @param {Number} b Component B (index 1)\r\n * @param {Number} c Component C (index 2)\r\n * @param {Number} d Component D (index 3)\r\n * @param {Number} tx Component TX (index 4)\r\n * @param {Number} ty Component TY (index 5)\r\n * @returns {mat2d} A new mat2d\r\n */\r\nexport function fromValues(a, b, c, d, tx, ty) {\r\n let out = new glMatrix.ARRAY_TYPE(6);\r\n out[0] = a;\r\n out[1] = b;\r\n out[2] = c;\r\n out[3] = d;\r\n out[4] = tx;\r\n out[5] = ty;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a mat2d to the given values\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {Number} a Component A (index 0)\r\n * @param {Number} b Component B (index 1)\r\n * @param {Number} c Component C (index 2)\r\n * @param {Number} d Component D (index 3)\r\n * @param {Number} tx Component TX (index 4)\r\n * @param {Number} ty Component TY (index 5)\r\n * @returns {mat2d} out\r\n */\r\nexport function set(out, a, b, c, d, tx, ty) {\r\n out[0] = a;\r\n out[1] = b;\r\n out[2] = c;\r\n out[3] = d;\r\n out[4] = tx;\r\n out[5] = ty;\r\n return out;\r\n}\r\n\r\n/**\r\n * Inverts a mat2d\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the source matrix\r\n * @returns {mat2d} out\r\n */\r\nexport function invert(out, a) {\r\n let aa = a[0], ab = a[1], ac = a[2], ad = a[3];\r\n let atx = a[4], aty = a[5];\r\n\r\n let det = aa * ad - ab * ac;\r\n if(!det){\r\n return null;\r\n }\r\n det = 1.0 / det;\r\n\r\n out[0] = ad * det;\r\n out[1] = -ab * det;\r\n out[2] = -ac * det;\r\n out[3] = aa * det;\r\n out[4] = (ac * aty - ad * atx) * det;\r\n out[5] = (ab * atx - aa * aty) * det;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the determinant of a mat2d\r\n *\r\n * @param {mat2d} a the source matrix\r\n * @returns {Number} determinant of a\r\n */\r\nexport function determinant(a) {\r\n return a[0] * a[3] - a[1] * a[2];\r\n}\r\n\r\n/**\r\n * Multiplies two mat2d's\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the first operand\r\n * @param {mat2d} b the second operand\r\n * @returns {mat2d} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];\r\n out[0] = a0 * b0 + a2 * b1;\r\n out[1] = a1 * b0 + a3 * b1;\r\n out[2] = a0 * b2 + a2 * b3;\r\n out[3] = a1 * b2 + a3 * b3;\r\n out[4] = a0 * b4 + a2 * b5 + a4;\r\n out[5] = a1 * b4 + a3 * b5 + a5;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a mat2d by the given angle\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat2d} out\r\n */\r\nexport function rotate(out, a, rad) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n out[0] = a0 * c + a2 * s;\r\n out[1] = a1 * c + a3 * s;\r\n out[2] = a0 * -s + a2 * c;\r\n out[3] = a1 * -s + a3 * c;\r\n out[4] = a4;\r\n out[5] = a5;\r\n return out;\r\n}\r\n\r\n/**\r\n * Scales the mat2d by the dimensions in the given vec2\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the matrix to translate\r\n * @param {vec2} v the vec2 to scale the matrix by\r\n * @returns {mat2d} out\r\n **/\r\nexport function scale(out, a, v) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\r\n let v0 = v[0], v1 = v[1];\r\n out[0] = a0 * v0;\r\n out[1] = a1 * v0;\r\n out[2] = a2 * v1;\r\n out[3] = a3 * v1;\r\n out[4] = a4;\r\n out[5] = a5;\r\n return out;\r\n}\r\n\r\n/**\r\n * Translates the mat2d by the dimensions in the given vec2\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the matrix to translate\r\n * @param {vec2} v the vec2 to translate the matrix by\r\n * @returns {mat2d} out\r\n **/\r\nexport function translate(out, a, v) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\r\n let v0 = v[0], v1 = v[1];\r\n out[0] = a0;\r\n out[1] = a1;\r\n out[2] = a2;\r\n out[3] = a3;\r\n out[4] = a0 * v0 + a2 * v1 + a4;\r\n out[5] = a1 * v0 + a3 * v1 + a5;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a given angle\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat2d.identity(dest);\r\n * mat2d.rotate(dest, dest, rad);\r\n *\r\n * @param {mat2d} out mat2d receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat2d} out\r\n */\r\nexport function fromRotation(out, rad) {\r\n let s = Math.sin(rad), c = Math.cos(rad);\r\n out[0] = c;\r\n out[1] = s;\r\n out[2] = -s;\r\n out[3] = c;\r\n out[4] = 0;\r\n out[5] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector scaling\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat2d.identity(dest);\r\n * mat2d.scale(dest, dest, vec);\r\n *\r\n * @param {mat2d} out mat2d receiving operation result\r\n * @param {vec2} v Scaling vector\r\n * @returns {mat2d} out\r\n */\r\nexport function fromScaling(out, v) {\r\n out[0] = v[0];\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = v[1];\r\n out[4] = 0;\r\n out[5] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector translation\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat2d.identity(dest);\r\n * mat2d.translate(dest, dest, vec);\r\n *\r\n * @param {mat2d} out mat2d receiving operation result\r\n * @param {vec2} v Translation vector\r\n * @returns {mat2d} out\r\n */\r\nexport function fromTranslation(out, v) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n out[4] = v[0];\r\n out[5] = v[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a mat2d\r\n *\r\n * @param {mat2d} a matrix to represent as a string\r\n * @returns {String} string representation of the matrix\r\n */\r\nexport function str(a) {\r\n return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +\r\n a[3] + ', ' + a[4] + ', ' + a[5] + ')';\r\n}\r\n\r\n/**\r\n * Returns Frobenius norm of a mat2d\r\n *\r\n * @param {mat2d} a the matrix to calculate Frobenius norm of\r\n * @returns {Number} Frobenius norm\r\n */\r\nexport function frob(a) {\r\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1))\r\n}\r\n\r\n/**\r\n * Adds two mat2d's\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the first operand\r\n * @param {mat2d} b the second operand\r\n * @returns {mat2d} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n out[4] = a[4] + b[4];\r\n out[5] = a[5] + b[5];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts matrix b from matrix a\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the first operand\r\n * @param {mat2d} b the second operand\r\n * @returns {mat2d} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n out[3] = a[3] - b[3];\r\n out[4] = a[4] - b[4];\r\n out[5] = a[5] - b[5];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiply each element of the matrix by a scalar.\r\n *\r\n * @param {mat2d} out the receiving matrix\r\n * @param {mat2d} a the matrix to scale\r\n * @param {Number} b amount to scale the matrix's elements by\r\n * @returns {mat2d} out\r\n */\r\nexport function multiplyScalar(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n out[4] = a[4] * b;\r\n out[5] = a[5] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two mat2d's after multiplying each element of the second operand by a scalar value.\r\n *\r\n * @param {mat2d} out the receiving vector\r\n * @param {mat2d} a the first operand\r\n * @param {mat2d} b the second operand\r\n * @param {Number} scale the amount to scale b's elements by before adding\r\n * @returns {mat2d} out\r\n */\r\nexport function multiplyScalarAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n out[3] = a[3] + (b[3] * scale);\r\n out[4] = a[4] + (b[4] * scale);\r\n out[5] = a[5] + (b[5] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {mat2d} a The first matrix.\r\n * @param {mat2d} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5];\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have approximately the same elements in the same position.\r\n *\r\n * @param {mat2d} a The first matrix.\r\n * @param {mat2d} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\r\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\r\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)));\r\n}\r\n\r\n/**\r\n * Alias for {@link mat2d.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link mat2d.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * 3x3 Matrix\r\n * @module mat3\r\n */\r\n\r\n/**\r\n * Creates a new identity mat3\r\n *\r\n * @returns {mat3} a new 3x3 matrix\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(9);\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 1;\r\n out[5] = 0;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Copies the upper-left 3x3 values into the given mat3.\r\n *\r\n * @param {mat3} out the receiving 3x3 matrix\r\n * @param {mat4} a the source 4x4 matrix\r\n * @returns {mat3} out\r\n */\r\nexport function fromMat4(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[4];\r\n out[4] = a[5];\r\n out[5] = a[6];\r\n out[6] = a[8];\r\n out[7] = a[9];\r\n out[8] = a[10];\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new mat3 initialized with values from an existing matrix\r\n *\r\n * @param {mat3} a matrix to clone\r\n * @returns {mat3} a new 3x3 matrix\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(9);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[8] = a[8];\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one mat3 to another\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the source matrix\r\n * @returns {mat3} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[8] = a[8];\r\n return out;\r\n}\r\n\r\n/**\r\n * Create a new mat3 with the given values\r\n *\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\r\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\r\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\r\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\r\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\r\n * @returns {mat3} A new mat3\r\n */\r\nexport function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {\r\n let out = new glMatrix.ARRAY_TYPE(9);\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m02;\r\n out[3] = m10;\r\n out[4] = m11;\r\n out[5] = m12;\r\n out[6] = m20;\r\n out[7] = m21;\r\n out[8] = m22;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a mat3 to the given values\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 3)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 4)\r\n * @param {Number} m12 Component in column 1, row 2 position (index 5)\r\n * @param {Number} m20 Component in column 2, row 0 position (index 6)\r\n * @param {Number} m21 Component in column 2, row 1 position (index 7)\r\n * @param {Number} m22 Component in column 2, row 2 position (index 8)\r\n * @returns {mat3} out\r\n */\r\nexport function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m02;\r\n out[3] = m10;\r\n out[4] = m11;\r\n out[5] = m12;\r\n out[6] = m20;\r\n out[7] = m21;\r\n out[8] = m22;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set a mat3 to the identity matrix\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @returns {mat3} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 1;\r\n out[5] = 0;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transpose the values of a mat3\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the source matrix\r\n * @returns {mat3} out\r\n */\r\nexport function transpose(out, a) {\r\n // If we are transposing ourselves we can skip a few steps but have to cache some values\r\n if (out === a) {\r\n let a01 = a[1], a02 = a[2], a12 = a[5];\r\n out[1] = a[3];\r\n out[2] = a[6];\r\n out[3] = a01;\r\n out[5] = a[7];\r\n out[6] = a02;\r\n out[7] = a12;\r\n } else {\r\n out[0] = a[0];\r\n out[1] = a[3];\r\n out[2] = a[6];\r\n out[3] = a[1];\r\n out[4] = a[4];\r\n out[5] = a[7];\r\n out[6] = a[2];\r\n out[7] = a[5];\r\n out[8] = a[8];\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Inverts a mat3\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the source matrix\r\n * @returns {mat3} out\r\n */\r\nexport function invert(out, a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2];\r\n let a10 = a[3], a11 = a[4], a12 = a[5];\r\n let a20 = a[6], a21 = a[7], a22 = a[8];\r\n\r\n let b01 = a22 * a11 - a12 * a21;\r\n let b11 = -a22 * a10 + a12 * a20;\r\n let b21 = a21 * a10 - a11 * a20;\r\n\r\n // Calculate the determinant\r\n let det = a00 * b01 + a01 * b11 + a02 * b21;\r\n\r\n if (!det) {\r\n return null;\r\n }\r\n det = 1.0 / det;\r\n\r\n out[0] = b01 * det;\r\n out[1] = (-a22 * a01 + a02 * a21) * det;\r\n out[2] = (a12 * a01 - a02 * a11) * det;\r\n out[3] = b11 * det;\r\n out[4] = (a22 * a00 - a02 * a20) * det;\r\n out[5] = (-a12 * a00 + a02 * a10) * det;\r\n out[6] = b21 * det;\r\n out[7] = (-a21 * a00 + a01 * a20) * det;\r\n out[8] = (a11 * a00 - a01 * a10) * det;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the adjugate of a mat3\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the source matrix\r\n * @returns {mat3} out\r\n */\r\nexport function adjoint(out, a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2];\r\n let a10 = a[3], a11 = a[4], a12 = a[5];\r\n let a20 = a[6], a21 = a[7], a22 = a[8];\r\n\r\n out[0] = (a11 * a22 - a12 * a21);\r\n out[1] = (a02 * a21 - a01 * a22);\r\n out[2] = (a01 * a12 - a02 * a11);\r\n out[3] = (a12 * a20 - a10 * a22);\r\n out[4] = (a00 * a22 - a02 * a20);\r\n out[5] = (a02 * a10 - a00 * a12);\r\n out[6] = (a10 * a21 - a11 * a20);\r\n out[7] = (a01 * a20 - a00 * a21);\r\n out[8] = (a00 * a11 - a01 * a10);\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the determinant of a mat3\r\n *\r\n * @param {mat3} a the source matrix\r\n * @returns {Number} determinant of a\r\n */\r\nexport function determinant(a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2];\r\n let a10 = a[3], a11 = a[4], a12 = a[5];\r\n let a20 = a[6], a21 = a[7], a22 = a[8];\r\n\r\n return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);\r\n}\r\n\r\n/**\r\n * Multiplies two mat3's\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the first operand\r\n * @param {mat3} b the second operand\r\n * @returns {mat3} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2];\r\n let a10 = a[3], a11 = a[4], a12 = a[5];\r\n let a20 = a[6], a21 = a[7], a22 = a[8];\r\n\r\n let b00 = b[0], b01 = b[1], b02 = b[2];\r\n let b10 = b[3], b11 = b[4], b12 = b[5];\r\n let b20 = b[6], b21 = b[7], b22 = b[8];\r\n\r\n out[0] = b00 * a00 + b01 * a10 + b02 * a20;\r\n out[1] = b00 * a01 + b01 * a11 + b02 * a21;\r\n out[2] = b00 * a02 + b01 * a12 + b02 * a22;\r\n\r\n out[3] = b10 * a00 + b11 * a10 + b12 * a20;\r\n out[4] = b10 * a01 + b11 * a11 + b12 * a21;\r\n out[5] = b10 * a02 + b11 * a12 + b12 * a22;\r\n\r\n out[6] = b20 * a00 + b21 * a10 + b22 * a20;\r\n out[7] = b20 * a01 + b21 * a11 + b22 * a21;\r\n out[8] = b20 * a02 + b21 * a12 + b22 * a22;\r\n return out;\r\n}\r\n\r\n/**\r\n * Translate a mat3 by the given vector\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the matrix to translate\r\n * @param {vec2} v vector to translate by\r\n * @returns {mat3} out\r\n */\r\nexport function translate(out, a, v) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2],\r\n a10 = a[3], a11 = a[4], a12 = a[5],\r\n a20 = a[6], a21 = a[7], a22 = a[8],\r\n x = v[0], y = v[1];\r\n\r\n out[0] = a00;\r\n out[1] = a01;\r\n out[2] = a02;\r\n\r\n out[3] = a10;\r\n out[4] = a11;\r\n out[5] = a12;\r\n\r\n out[6] = x * a00 + y * a10 + a20;\r\n out[7] = x * a01 + y * a11 + a21;\r\n out[8] = x * a02 + y * a12 + a22;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a mat3 by the given angle\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat3} out\r\n */\r\nexport function rotate(out, a, rad) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2],\r\n a10 = a[3], a11 = a[4], a12 = a[5],\r\n a20 = a[6], a21 = a[7], a22 = a[8],\r\n\r\n s = Math.sin(rad),\r\n c = Math.cos(rad);\r\n\r\n out[0] = c * a00 + s * a10;\r\n out[1] = c * a01 + s * a11;\r\n out[2] = c * a02 + s * a12;\r\n\r\n out[3] = c * a10 - s * a00;\r\n out[4] = c * a11 - s * a01;\r\n out[5] = c * a12 - s * a02;\r\n\r\n out[6] = a20;\r\n out[7] = a21;\r\n out[8] = a22;\r\n return out;\r\n};\r\n\r\n/**\r\n * Scales the mat3 by the dimensions in the given vec2\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the matrix to rotate\r\n * @param {vec2} v the vec2 to scale the matrix by\r\n * @returns {mat3} out\r\n **/\r\nexport function scale(out, a, v) {\r\n let x = v[0], y = v[1];\r\n\r\n out[0] = x * a[0];\r\n out[1] = x * a[1];\r\n out[2] = x * a[2];\r\n\r\n out[3] = y * a[3];\r\n out[4] = y * a[4];\r\n out[5] = y * a[5];\r\n\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[8] = a[8];\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector translation\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat3.identity(dest);\r\n * mat3.translate(dest, dest, vec);\r\n *\r\n * @param {mat3} out mat3 receiving operation result\r\n * @param {vec2} v Translation vector\r\n * @returns {mat3} out\r\n */\r\nexport function fromTranslation(out, v) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 1;\r\n out[5] = 0;\r\n out[6] = v[0];\r\n out[7] = v[1];\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a given angle\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat3.identity(dest);\r\n * mat3.rotate(dest, dest, rad);\r\n *\r\n * @param {mat3} out mat3 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat3} out\r\n */\r\nexport function fromRotation(out, rad) {\r\n let s = Math.sin(rad), c = Math.cos(rad);\r\n\r\n out[0] = c;\r\n out[1] = s;\r\n out[2] = 0;\r\n\r\n out[3] = -s;\r\n out[4] = c;\r\n out[5] = 0;\r\n\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector scaling\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat3.identity(dest);\r\n * mat3.scale(dest, dest, vec);\r\n *\r\n * @param {mat3} out mat3 receiving operation result\r\n * @param {vec2} v Scaling vector\r\n * @returns {mat3} out\r\n */\r\nexport function fromScaling(out, v) {\r\n out[0] = v[0];\r\n out[1] = 0;\r\n out[2] = 0;\r\n\r\n out[3] = 0;\r\n out[4] = v[1];\r\n out[5] = 0;\r\n\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Copies the values from a mat2d into a mat3\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat2d} a the matrix to copy\r\n * @returns {mat3} out\r\n **/\r\nexport function fromMat2d(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = 0;\r\n\r\n out[3] = a[2];\r\n out[4] = a[3];\r\n out[5] = 0;\r\n\r\n out[6] = a[4];\r\n out[7] = a[5];\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n* Calculates a 3x3 matrix from the given quaternion\r\n*\r\n* @param {mat3} out mat3 receiving operation result\r\n* @param {quat} q Quaternion to create matrix from\r\n*\r\n* @returns {mat3} out\r\n*/\r\nexport function fromQuat(out, q) {\r\n let x = q[0], y = q[1], z = q[2], w = q[3];\r\n let x2 = x + x;\r\n let y2 = y + y;\r\n let z2 = z + z;\r\n\r\n let xx = x * x2;\r\n let yx = y * x2;\r\n let yy = y * y2;\r\n let zx = z * x2;\r\n let zy = z * y2;\r\n let zz = z * z2;\r\n let wx = w * x2;\r\n let wy = w * y2;\r\n let wz = w * z2;\r\n\r\n out[0] = 1 - yy - zz;\r\n out[3] = yx - wz;\r\n out[6] = zx + wy;\r\n\r\n out[1] = yx + wz;\r\n out[4] = 1 - xx - zz;\r\n out[7] = zy - wx;\r\n\r\n out[2] = zx - wy;\r\n out[5] = zy + wx;\r\n out[8] = 1 - xx - yy;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix\r\n*\r\n* @param {mat3} out mat3 receiving operation result\r\n* @param {mat4} a Mat4 to derive the normal matrix from\r\n*\r\n* @returns {mat3} out\r\n*/\r\nexport function normalFromMat4(out, a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\r\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\r\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\r\n\r\n let b00 = a00 * a11 - a01 * a10;\r\n let b01 = a00 * a12 - a02 * a10;\r\n let b02 = a00 * a13 - a03 * a10;\r\n let b03 = a01 * a12 - a02 * a11;\r\n let b04 = a01 * a13 - a03 * a11;\r\n let b05 = a02 * a13 - a03 * a12;\r\n let b06 = a20 * a31 - a21 * a30;\r\n let b07 = a20 * a32 - a22 * a30;\r\n let b08 = a20 * a33 - a23 * a30;\r\n let b09 = a21 * a32 - a22 * a31;\r\n let b10 = a21 * a33 - a23 * a31;\r\n let b11 = a22 * a33 - a23 * a32;\r\n\r\n // Calculate the determinant\r\n let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\r\n\r\n if (!det) {\r\n return null;\r\n }\r\n det = 1.0 / det;\r\n\r\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\r\n out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\r\n out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\r\n\r\n out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\r\n out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\r\n out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\r\n\r\n out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\r\n out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\r\n out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a 2D projection matrix with the given bounds\r\n *\r\n * @param {mat3} out mat3 frustum matrix will be written into\r\n * @param {number} width Width of your gl context\r\n * @param {number} height Height of gl context\r\n * @returns {mat3} out\r\n */\r\nexport function projection(out, width, height) {\r\n out[0] = 2 / width;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = -2 / height;\r\n out[5] = 0;\r\n out[6] = -1;\r\n out[7] = 1;\r\n out[8] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a mat3\r\n *\r\n * @param {mat3} a matrix to represent as a string\r\n * @returns {String} string representation of the matrix\r\n */\r\nexport function str(a) {\r\n return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +\r\n a[3] + ', ' + a[4] + ', ' + a[5] + ', ' +\r\n a[6] + ', ' + a[7] + ', ' + a[8] + ')';\r\n}\r\n\r\n/**\r\n * Returns Frobenius norm of a mat3\r\n *\r\n * @param {mat3} a the matrix to calculate Frobenius norm of\r\n * @returns {Number} Frobenius norm\r\n */\r\nexport function frob(a) {\r\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2)))\r\n}\r\n\r\n/**\r\n * Adds two mat3's\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the first operand\r\n * @param {mat3} b the second operand\r\n * @returns {mat3} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n out[4] = a[4] + b[4];\r\n out[5] = a[5] + b[5];\r\n out[6] = a[6] + b[6];\r\n out[7] = a[7] + b[7];\r\n out[8] = a[8] + b[8];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts matrix b from matrix a\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the first operand\r\n * @param {mat3} b the second operand\r\n * @returns {mat3} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n out[3] = a[3] - b[3];\r\n out[4] = a[4] - b[4];\r\n out[5] = a[5] - b[5];\r\n out[6] = a[6] - b[6];\r\n out[7] = a[7] - b[7];\r\n out[8] = a[8] - b[8];\r\n return out;\r\n}\r\n\r\n\r\n\r\n/**\r\n * Multiply each element of the matrix by a scalar.\r\n *\r\n * @param {mat3} out the receiving matrix\r\n * @param {mat3} a the matrix to scale\r\n * @param {Number} b amount to scale the matrix's elements by\r\n * @returns {mat3} out\r\n */\r\nexport function multiplyScalar(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n out[4] = a[4] * b;\r\n out[5] = a[5] * b;\r\n out[6] = a[6] * b;\r\n out[7] = a[7] * b;\r\n out[8] = a[8] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two mat3's after multiplying each element of the second operand by a scalar value.\r\n *\r\n * @param {mat3} out the receiving vector\r\n * @param {mat3} a the first operand\r\n * @param {mat3} b the second operand\r\n * @param {Number} scale the amount to scale b's elements by before adding\r\n * @returns {mat3} out\r\n */\r\nexport function multiplyScalarAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n out[3] = a[3] + (b[3] * scale);\r\n out[4] = a[4] + (b[4] * scale);\r\n out[5] = a[5] + (b[5] * scale);\r\n out[6] = a[6] + (b[6] * scale);\r\n out[7] = a[7] + (b[7] * scale);\r\n out[8] = a[8] + (b[8] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {mat3} a The first matrix.\r\n * @param {mat3} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] &&\r\n a[3] === b[3] && a[4] === b[4] && a[5] === b[5] &&\r\n a[6] === b[6] && a[7] === b[7] && a[8] === b[8];\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have approximately the same elements in the same position.\r\n *\r\n * @param {mat3} a The first matrix.\r\n * @param {mat3} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\r\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\r\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\r\n Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\r\n Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) &&\r\n Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8)));\r\n}\r\n\r\n/**\r\n * Alias for {@link mat3.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link mat3.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * @class 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.\r\n * @name mat4\r\n */\r\n\r\n/**\r\n * Creates a new identity mat4\r\n *\r\n * @returns {mat4} a new 4x4 matrix\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(16);\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = 1;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = 1;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new mat4 initialized with values from an existing matrix\r\n *\r\n * @param {mat4} a matrix to clone\r\n * @returns {mat4} a new 4x4 matrix\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(16);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[8] = a[8];\r\n out[9] = a[9];\r\n out[10] = a[10];\r\n out[11] = a[11];\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one mat4 to another\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the source matrix\r\n * @returns {mat4} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[8] = a[8];\r\n out[9] = a[9];\r\n out[10] = a[10];\r\n out[11] = a[11];\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n return out;\r\n}\r\n\r\n/**\r\n * Create a new mat4 with the given values\r\n *\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\r\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\r\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\r\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\r\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\r\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\r\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\r\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\r\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\r\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\r\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\r\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\r\n * @returns {mat4} A new mat4\r\n */\r\nexport function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\r\n let out = new glMatrix.ARRAY_TYPE(16);\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m02;\r\n out[3] = m03;\r\n out[4] = m10;\r\n out[5] = m11;\r\n out[6] = m12;\r\n out[7] = m13;\r\n out[8] = m20;\r\n out[9] = m21;\r\n out[10] = m22;\r\n out[11] = m23;\r\n out[12] = m30;\r\n out[13] = m31;\r\n out[14] = m32;\r\n out[15] = m33;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a mat4 to the given values\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {Number} m00 Component in column 0, row 0 position (index 0)\r\n * @param {Number} m01 Component in column 0, row 1 position (index 1)\r\n * @param {Number} m02 Component in column 0, row 2 position (index 2)\r\n * @param {Number} m03 Component in column 0, row 3 position (index 3)\r\n * @param {Number} m10 Component in column 1, row 0 position (index 4)\r\n * @param {Number} m11 Component in column 1, row 1 position (index 5)\r\n * @param {Number} m12 Component in column 1, row 2 position (index 6)\r\n * @param {Number} m13 Component in column 1, row 3 position (index 7)\r\n * @param {Number} m20 Component in column 2, row 0 position (index 8)\r\n * @param {Number} m21 Component in column 2, row 1 position (index 9)\r\n * @param {Number} m22 Component in column 2, row 2 position (index 10)\r\n * @param {Number} m23 Component in column 2, row 3 position (index 11)\r\n * @param {Number} m30 Component in column 3, row 0 position (index 12)\r\n * @param {Number} m31 Component in column 3, row 1 position (index 13)\r\n * @param {Number} m32 Component in column 3, row 2 position (index 14)\r\n * @param {Number} m33 Component in column 3, row 3 position (index 15)\r\n * @returns {mat4} out\r\n */\r\nexport function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {\r\n out[0] = m00;\r\n out[1] = m01;\r\n out[2] = m02;\r\n out[3] = m03;\r\n out[4] = m10;\r\n out[5] = m11;\r\n out[6] = m12;\r\n out[7] = m13;\r\n out[8] = m20;\r\n out[9] = m21;\r\n out[10] = m22;\r\n out[11] = m23;\r\n out[12] = m30;\r\n out[13] = m31;\r\n out[14] = m32;\r\n out[15] = m33;\r\n return out;\r\n}\r\n\r\n\r\n/**\r\n * Set a mat4 to the identity matrix\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @returns {mat4} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = 1;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = 1;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transpose the values of a mat4\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the source matrix\r\n * @returns {mat4} out\r\n */\r\nexport function transpose(out, a) {\r\n // If we are transposing ourselves we can skip a few steps but have to cache some values\r\n if (out === a) {\r\n let a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a12 = a[6], a13 = a[7];\r\n let a23 = a[11];\r\n\r\n out[1] = a[4];\r\n out[2] = a[8];\r\n out[3] = a[12];\r\n out[4] = a01;\r\n out[6] = a[9];\r\n out[7] = a[13];\r\n out[8] = a02;\r\n out[9] = a12;\r\n out[11] = a[14];\r\n out[12] = a03;\r\n out[13] = a13;\r\n out[14] = a23;\r\n } else {\r\n out[0] = a[0];\r\n out[1] = a[4];\r\n out[2] = a[8];\r\n out[3] = a[12];\r\n out[4] = a[1];\r\n out[5] = a[5];\r\n out[6] = a[9];\r\n out[7] = a[13];\r\n out[8] = a[2];\r\n out[9] = a[6];\r\n out[10] = a[10];\r\n out[11] = a[14];\r\n out[12] = a[3];\r\n out[13] = a[7];\r\n out[14] = a[11];\r\n out[15] = a[15];\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Inverts a mat4\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the source matrix\r\n * @returns {mat4} out\r\n */\r\nexport function invert(out, a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\r\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\r\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\r\n\r\n let b00 = a00 * a11 - a01 * a10;\r\n let b01 = a00 * a12 - a02 * a10;\r\n let b02 = a00 * a13 - a03 * a10;\r\n let b03 = a01 * a12 - a02 * a11;\r\n let b04 = a01 * a13 - a03 * a11;\r\n let b05 = a02 * a13 - a03 * a12;\r\n let b06 = a20 * a31 - a21 * a30;\r\n let b07 = a20 * a32 - a22 * a30;\r\n let b08 = a20 * a33 - a23 * a30;\r\n let b09 = a21 * a32 - a22 * a31;\r\n let b10 = a21 * a33 - a23 * a31;\r\n let b11 = a22 * a33 - a23 * a32;\r\n\r\n // Calculate the determinant\r\n let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\r\n\r\n if (!det) {\r\n return null;\r\n }\r\n det = 1.0 / det;\r\n\r\n out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\r\n out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\r\n out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\r\n out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\r\n out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\r\n out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\r\n out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\r\n out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\r\n out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\r\n out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\r\n out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\r\n out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\r\n out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\r\n out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\r\n out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\r\n out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the adjugate of a mat4\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the source matrix\r\n * @returns {mat4} out\r\n */\r\nexport function adjoint(out, a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\r\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\r\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\r\n\r\n out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22));\r\n out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\r\n out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12));\r\n out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\r\n out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\r\n out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22));\r\n out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\r\n out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12));\r\n out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21));\r\n out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\r\n out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11));\r\n out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\r\n out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\r\n out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21));\r\n out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\r\n out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11));\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the determinant of a mat4\r\n *\r\n * @param {mat4} a the source matrix\r\n * @returns {Number} determinant of a\r\n */\r\nexport function determinant(a) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\r\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\r\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\r\n\r\n let b00 = a00 * a11 - a01 * a10;\r\n let b01 = a00 * a12 - a02 * a10;\r\n let b02 = a00 * a13 - a03 * a10;\r\n let b03 = a01 * a12 - a02 * a11;\r\n let b04 = a01 * a13 - a03 * a11;\r\n let b05 = a02 * a13 - a03 * a12;\r\n let b06 = a20 * a31 - a21 * a30;\r\n let b07 = a20 * a32 - a22 * a30;\r\n let b08 = a20 * a33 - a23 * a30;\r\n let b09 = a21 * a32 - a22 * a31;\r\n let b10 = a21 * a33 - a23 * a31;\r\n let b11 = a22 * a33 - a23 * a32;\r\n\r\n // Calculate the determinant\r\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\r\n}\r\n\r\n/**\r\n * Multiplies two mat4s\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the first operand\r\n * @param {mat4} b the second operand\r\n * @returns {mat4} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];\r\n let a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];\r\n let a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];\r\n let a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];\r\n\r\n // Cache only the current line of the second matrix\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\r\n out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\r\n out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\r\n out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\r\n out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\r\n\r\n b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7];\r\n out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\r\n out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\r\n out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\r\n out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\r\n\r\n b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11];\r\n out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\r\n out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\r\n out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\r\n out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\r\n\r\n b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15];\r\n out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;\r\n out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;\r\n out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;\r\n out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;\r\n return out;\r\n}\r\n\r\n/**\r\n * Translate a mat4 by the given vector\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to translate\r\n * @param {vec3} v vector to translate by\r\n * @returns {mat4} out\r\n */\r\nexport function translate(out, a, v) {\r\n let x = v[0], y = v[1], z = v[2];\r\n let a00, a01, a02, a03;\r\n let a10, a11, a12, a13;\r\n let a20, a21, a22, a23;\r\n\r\n if (a === out) {\r\n out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\r\n out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\r\n out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\r\n out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\r\n } else {\r\n a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];\r\n a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];\r\n a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];\r\n\r\n out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03;\r\n out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13;\r\n out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23;\r\n\r\n out[12] = a00 * x + a10 * y + a20 * z + a[12];\r\n out[13] = a01 * x + a11 * y + a21 * z + a[13];\r\n out[14] = a02 * x + a12 * y + a22 * z + a[14];\r\n out[15] = a03 * x + a13 * y + a23 * z + a[15];\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Scales the mat4 by the dimensions in the given vec3 not using vectorization\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to scale\r\n * @param {vec3} v the vec3 to scale the matrix by\r\n * @returns {mat4} out\r\n **/\r\nexport function scale(out, a, v) {\r\n let x = v[0], y = v[1], z = v[2];\r\n\r\n out[0] = a[0] * x;\r\n out[1] = a[1] * x;\r\n out[2] = a[2] * x;\r\n out[3] = a[3] * x;\r\n out[4] = a[4] * y;\r\n out[5] = a[5] * y;\r\n out[6] = a[6] * y;\r\n out[7] = a[7] * y;\r\n out[8] = a[8] * z;\r\n out[9] = a[9] * z;\r\n out[10] = a[10] * z;\r\n out[11] = a[11] * z;\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a mat4 by the given angle around the given axis\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @param {vec3} axis the axis to rotate around\r\n * @returns {mat4} out\r\n */\r\nexport function rotate(out, a, rad, axis) {\r\n let x = axis[0], y = axis[1], z = axis[2];\r\n let len = Math.sqrt(x * x + y * y + z * z);\r\n let s, c, t;\r\n let a00, a01, a02, a03;\r\n let a10, a11, a12, a13;\r\n let a20, a21, a22, a23;\r\n let b00, b01, b02;\r\n let b10, b11, b12;\r\n let b20, b21, b22;\r\n\r\n if (Math.abs(len) < glMatrix.EPSILON) { return null; }\r\n\r\n len = 1 / len;\r\n x *= len;\r\n y *= len;\r\n z *= len;\r\n\r\n s = Math.sin(rad);\r\n c = Math.cos(rad);\r\n t = 1 - c;\r\n\r\n a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];\r\n a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];\r\n a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];\r\n\r\n // Construct the elements of the rotation matrix\r\n b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s;\r\n b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s;\r\n b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c;\r\n\r\n // Perform rotation-specific matrix multiplication\r\n out[0] = a00 * b00 + a10 * b01 + a20 * b02;\r\n out[1] = a01 * b00 + a11 * b01 + a21 * b02;\r\n out[2] = a02 * b00 + a12 * b01 + a22 * b02;\r\n out[3] = a03 * b00 + a13 * b01 + a23 * b02;\r\n out[4] = a00 * b10 + a10 * b11 + a20 * b12;\r\n out[5] = a01 * b10 + a11 * b11 + a21 * b12;\r\n out[6] = a02 * b10 + a12 * b11 + a22 * b12;\r\n out[7] = a03 * b10 + a13 * b11 + a23 * b12;\r\n out[8] = a00 * b20 + a10 * b21 + a20 * b22;\r\n out[9] = a01 * b20 + a11 * b21 + a21 * b22;\r\n out[10] = a02 * b20 + a12 * b21 + a22 * b22;\r\n out[11] = a03 * b20 + a13 * b21 + a23 * b22;\r\n\r\n if (a !== out) { // If the source and destination differ, copy the unchanged last row\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a matrix by the given angle around the X axis\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function rotateX(out, a, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n let a10 = a[4];\r\n let a11 = a[5];\r\n let a12 = a[6];\r\n let a13 = a[7];\r\n let a20 = a[8];\r\n let a21 = a[9];\r\n let a22 = a[10];\r\n let a23 = a[11];\r\n\r\n if (a !== out) { // If the source and destination differ, copy the unchanged rows\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n }\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[4] = a10 * c + a20 * s;\r\n out[5] = a11 * c + a21 * s;\r\n out[6] = a12 * c + a22 * s;\r\n out[7] = a13 * c + a23 * s;\r\n out[8] = a20 * c - a10 * s;\r\n out[9] = a21 * c - a11 * s;\r\n out[10] = a22 * c - a12 * s;\r\n out[11] = a23 * c - a13 * s;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a matrix by the given angle around the Y axis\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function rotateY(out, a, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n let a00 = a[0];\r\n let a01 = a[1];\r\n let a02 = a[2];\r\n let a03 = a[3];\r\n let a20 = a[8];\r\n let a21 = a[9];\r\n let a22 = a[10];\r\n let a23 = a[11];\r\n\r\n if (a !== out) { // If the source and destination differ, copy the unchanged rows\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n }\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[0] = a00 * c - a20 * s;\r\n out[1] = a01 * c - a21 * s;\r\n out[2] = a02 * c - a22 * s;\r\n out[3] = a03 * c - a23 * s;\r\n out[8] = a00 * s + a20 * c;\r\n out[9] = a01 * s + a21 * c;\r\n out[10] = a02 * s + a22 * c;\r\n out[11] = a03 * s + a23 * c;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a matrix by the given angle around the Z axis\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to rotate\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function rotateZ(out, a, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n let a00 = a[0];\r\n let a01 = a[1];\r\n let a02 = a[2];\r\n let a03 = a[3];\r\n let a10 = a[4];\r\n let a11 = a[5];\r\n let a12 = a[6];\r\n let a13 = a[7];\r\n\r\n if (a !== out) { // If the source and destination differ, copy the unchanged last row\r\n out[8] = a[8];\r\n out[9] = a[9];\r\n out[10] = a[10];\r\n out[11] = a[11];\r\n out[12] = a[12];\r\n out[13] = a[13];\r\n out[14] = a[14];\r\n out[15] = a[15];\r\n }\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[0] = a00 * c + a10 * s;\r\n out[1] = a01 * c + a11 * s;\r\n out[2] = a02 * c + a12 * s;\r\n out[3] = a03 * c + a13 * s;\r\n out[4] = a10 * c - a00 * s;\r\n out[5] = a11 * c - a01 * s;\r\n out[6] = a12 * c - a02 * s;\r\n out[7] = a13 * c - a03 * s;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector translation\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.translate(dest, dest, vec);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {vec3} v Translation vector\r\n * @returns {mat4} out\r\n */\r\nexport function fromTranslation(out, v) {\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = 1;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = 1;\r\n out[11] = 0;\r\n out[12] = v[0];\r\n out[13] = v[1];\r\n out[14] = v[2];\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a vector scaling\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.scale(dest, dest, vec);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {vec3} v Scaling vector\r\n * @returns {mat4} out\r\n */\r\nexport function fromScaling(out, v) {\r\n out[0] = v[0];\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = v[1];\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = v[2];\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a given angle around a given axis\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.rotate(dest, dest, rad, axis);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @param {vec3} axis the axis to rotate around\r\n * @returns {mat4} out\r\n */\r\nexport function fromRotation(out, rad, axis) {\r\n let x = axis[0], y = axis[1], z = axis[2];\r\n let len = Math.sqrt(x * x + y * y + z * z);\r\n let s, c, t;\r\n\r\n if (Math.abs(len) < glMatrix.EPSILON) { return null; }\r\n\r\n len = 1 / len;\r\n x *= len;\r\n y *= len;\r\n z *= len;\r\n\r\n s = Math.sin(rad);\r\n c = Math.cos(rad);\r\n t = 1 - c;\r\n\r\n // Perform rotation-specific matrix multiplication\r\n out[0] = x * x * t + c;\r\n out[1] = y * x * t + z * s;\r\n out[2] = z * x * t - y * s;\r\n out[3] = 0;\r\n out[4] = x * y * t - z * s;\r\n out[5] = y * y * t + c;\r\n out[6] = z * y * t + x * s;\r\n out[7] = 0;\r\n out[8] = x * z * t + y * s;\r\n out[9] = y * z * t - x * s;\r\n out[10] = z * z * t + c;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from the given angle around the X axis\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.rotateX(dest, dest, rad);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function fromXRotation(out, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[0] = 1;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = c;\r\n out[6] = s;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = -s;\r\n out[10] = c;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from the given angle around the Y axis\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.rotateY(dest, dest, rad);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function fromYRotation(out, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[0] = c;\r\n out[1] = 0;\r\n out[2] = -s;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = 1;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = s;\r\n out[9] = 0;\r\n out[10] = c;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from the given angle around the Z axis\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.rotateZ(dest, dest, rad);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {Number} rad the angle to rotate the matrix by\r\n * @returns {mat4} out\r\n */\r\nexport function fromZRotation(out, rad) {\r\n let s = Math.sin(rad);\r\n let c = Math.cos(rad);\r\n\r\n // Perform axis-specific matrix multiplication\r\n out[0] = c;\r\n out[1] = s;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = -s;\r\n out[5] = c;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = 1;\r\n out[11] = 0;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a quaternion rotation and vector translation\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.translate(dest, vec);\r\n * let quatMat = mat4.create();\r\n * quat4.toMat4(quat, quatMat);\r\n * mat4.multiply(dest, quatMat);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {quat4} q Rotation quaternion\r\n * @param {vec3} v Translation vector\r\n * @returns {mat4} out\r\n */\r\nexport function fromRotationTranslation(out, q, v) {\r\n // Quaternion math\r\n let x = q[0], y = q[1], z = q[2], w = q[3];\r\n let x2 = x + x;\r\n let y2 = y + y;\r\n let z2 = z + z;\r\n\r\n let xx = x * x2;\r\n let xy = x * y2;\r\n let xz = x * z2;\r\n let yy = y * y2;\r\n let yz = y * z2;\r\n let zz = z * z2;\r\n let wx = w * x2;\r\n let wy = w * y2;\r\n let wz = w * z2;\r\n\r\n out[0] = 1 - (yy + zz);\r\n out[1] = xy + wz;\r\n out[2] = xz - wy;\r\n out[3] = 0;\r\n out[4] = xy - wz;\r\n out[5] = 1 - (xx + zz);\r\n out[6] = yz + wx;\r\n out[7] = 0;\r\n out[8] = xz + wy;\r\n out[9] = yz - wx;\r\n out[10] = 1 - (xx + yy);\r\n out[11] = 0;\r\n out[12] = v[0];\r\n out[13] = v[1];\r\n out[14] = v[2];\r\n out[15] = 1;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new mat4 from a dual quat.\r\n *\r\n * @param {mat4} out Matrix\r\n * @param {quat2} a Dual Quaternion\r\n * @returns {mat4} mat4 receiving operation result\r\n */\r\nexport function fromQuat2(out, a) {\r\n let translation = new glMatrix.ARRAY_TYPE(3);\r\n let bx = -a[0], by = -a[1], bz = -a[2], bw = a[3],\r\n ax = a[4], ay = a[5], az = a[6], aw = a[7];\r\n \r\n let magnitude = bx * bx + by * by + bz * bz + bw * bw;\r\n //Only scale if it makes sense\r\n if (magnitude > 0) {\r\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;\r\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;\r\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;\r\n } else {\r\n translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\r\n translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\r\n translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\r\n }\r\n fromRotationTranslation(out, a, translation);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the translation vector component of a transformation\r\n * matrix. If a matrix is built with fromRotationTranslation,\r\n * the returned vector will be the same as the translation vector\r\n * originally supplied.\r\n * @param {vec3} out Vector to receive translation component\r\n * @param {mat4} mat Matrix to be decomposed (input)\r\n * @return {vec3} out\r\n */\r\nexport function getTranslation(out, mat) {\r\n out[0] = mat[12];\r\n out[1] = mat[13];\r\n out[2] = mat[14];\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the scaling factor component of a transformation\r\n * matrix. If a matrix is built with fromRotationTranslationScale\r\n * with a normalized Quaternion paramter, the returned vector will be\r\n * the same as the scaling vector\r\n * originally supplied.\r\n * @param {vec3} out Vector to receive scaling factor component\r\n * @param {mat4} mat Matrix to be decomposed (input)\r\n * @return {vec3} out\r\n */\r\nexport function getScaling(out, mat) {\r\n let m11 = mat[0];\r\n let m12 = mat[1];\r\n let m13 = mat[2];\r\n let m21 = mat[4];\r\n let m22 = mat[5];\r\n let m23 = mat[6];\r\n let m31 = mat[8];\r\n let m32 = mat[9];\r\n let m33 = mat[10];\r\n\r\n out[0] = Math.sqrt(m11 * m11 + m12 * m12 + m13 * m13);\r\n out[1] = Math.sqrt(m21 * m21 + m22 * m22 + m23 * m23);\r\n out[2] = Math.sqrt(m31 * m31 + m32 * m32 + m33 * m33);\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a quaternion representing the rotational component\r\n * of a transformation matrix. If a matrix is built with\r\n * fromRotationTranslation, the returned quaternion will be the\r\n * same as the quaternion originally supplied.\r\n * @param {quat} out Quaternion to receive the rotation component\r\n * @param {mat4} mat Matrix to be decomposed (input)\r\n * @return {quat} out\r\n */\r\nexport function getRotation(out, mat) {\r\n // Algorithm taken from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\r\n let trace = mat[0] + mat[5] + mat[10];\r\n let S = 0;\r\n\r\n if (trace > 0) {\r\n S = Math.sqrt(trace + 1.0) * 2;\r\n out[3] = 0.25 * S;\r\n out[0] = (mat[6] - mat[9]) / S;\r\n out[1] = (mat[8] - mat[2]) / S;\r\n out[2] = (mat[1] - mat[4]) / S;\r\n } else if ((mat[0] > mat[5]) && (mat[0] > mat[10])) {\r\n S = Math.sqrt(1.0 + mat[0] - mat[5] - mat[10]) * 2;\r\n out[3] = (mat[6] - mat[9]) / S;\r\n out[0] = 0.25 * S;\r\n out[1] = (mat[1] + mat[4]) / S;\r\n out[2] = (mat[8] + mat[2]) / S;\r\n } else if (mat[5] > mat[10]) {\r\n S = Math.sqrt(1.0 + mat[5] - mat[0] - mat[10]) * 2;\r\n out[3] = (mat[8] - mat[2]) / S;\r\n out[0] = (mat[1] + mat[4]) / S;\r\n out[1] = 0.25 * S;\r\n out[2] = (mat[6] + mat[9]) / S;\r\n } else {\r\n S = Math.sqrt(1.0 + mat[10] - mat[0] - mat[5]) * 2;\r\n out[3] = (mat[1] - mat[4]) / S;\r\n out[0] = (mat[8] + mat[2]) / S;\r\n out[1] = (mat[6] + mat[9]) / S;\r\n out[2] = 0.25 * S;\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a quaternion rotation, vector translation and vector scale\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.translate(dest, vec);\r\n * let quatMat = mat4.create();\r\n * quat4.toMat4(quat, quatMat);\r\n * mat4.multiply(dest, quatMat);\r\n * mat4.scale(dest, scale)\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {quat4} q Rotation quaternion\r\n * @param {vec3} v Translation vector\r\n * @param {vec3} s Scaling vector\r\n * @returns {mat4} out\r\n */\r\nexport function fromRotationTranslationScale(out, q, v, s) {\r\n // Quaternion math\r\n let x = q[0], y = q[1], z = q[2], w = q[3];\r\n let x2 = x + x;\r\n let y2 = y + y;\r\n let z2 = z + z;\r\n\r\n let xx = x * x2;\r\n let xy = x * y2;\r\n let xz = x * z2;\r\n let yy = y * y2;\r\n let yz = y * z2;\r\n let zz = z * z2;\r\n let wx = w * x2;\r\n let wy = w * y2;\r\n let wz = w * z2;\r\n let sx = s[0];\r\n let sy = s[1];\r\n let sz = s[2];\r\n\r\n out[0] = (1 - (yy + zz)) * sx;\r\n out[1] = (xy + wz) * sx;\r\n out[2] = (xz - wy) * sx;\r\n out[3] = 0;\r\n out[4] = (xy - wz) * sy;\r\n out[5] = (1 - (xx + zz)) * sy;\r\n out[6] = (yz + wx) * sy;\r\n out[7] = 0;\r\n out[8] = (xz + wy) * sz;\r\n out[9] = (yz - wx) * sz;\r\n out[10] = (1 - (xx + yy)) * sz;\r\n out[11] = 0;\r\n out[12] = v[0];\r\n out[13] = v[1];\r\n out[14] = v[2];\r\n out[15] = 1;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin\r\n * This is equivalent to (but much faster than):\r\n *\r\n * mat4.identity(dest);\r\n * mat4.translate(dest, vec);\r\n * mat4.translate(dest, origin);\r\n * let quatMat = mat4.create();\r\n * quat4.toMat4(quat, quatMat);\r\n * mat4.multiply(dest, quatMat);\r\n * mat4.scale(dest, scale)\r\n * mat4.translate(dest, negativeOrigin);\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {quat4} q Rotation quaternion\r\n * @param {vec3} v Translation vector\r\n * @param {vec3} s Scaling vector\r\n * @param {vec3} o The origin vector around which to scale and rotate\r\n * @returns {mat4} out\r\n */\r\nexport function fromRotationTranslationScaleOrigin(out, q, v, s, o) {\r\n // Quaternion math\r\n let x = q[0], y = q[1], z = q[2], w = q[3];\r\n let x2 = x + x;\r\n let y2 = y + y;\r\n let z2 = z + z;\r\n\r\n let xx = x * x2;\r\n let xy = x * y2;\r\n let xz = x * z2;\r\n let yy = y * y2;\r\n let yz = y * z2;\r\n let zz = z * z2;\r\n let wx = w * x2;\r\n let wy = w * y2;\r\n let wz = w * z2;\r\n\r\n let sx = s[0];\r\n let sy = s[1];\r\n let sz = s[2];\r\n\r\n let ox = o[0];\r\n let oy = o[1];\r\n let oz = o[2];\r\n\r\n let out0 = (1 - (yy + zz)) * sx;\r\n let out1 = (xy + wz) * sx;\r\n let out2 = (xz - wy) * sx;\r\n let out4 = (xy - wz) * sy;\r\n let out5 = (1 - (xx + zz)) * sy;\r\n let out6 = (yz + wx) * sy;\r\n let out8 = (xz + wy) * sz;\r\n let out9 = (yz - wx) * sz;\r\n let out10 = (1 - (xx + yy)) * sz;\r\n\r\n out[0] = out0;\r\n out[1] = out1;\r\n out[2] = out2;\r\n out[3] = 0;\r\n out[4] = out4;\r\n out[5] = out5;\r\n out[6] = out6;\r\n out[7] = 0;\r\n out[8] = out8;\r\n out[9] = out9;\r\n out[10] = out10;\r\n out[11] = 0;\r\n out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);\r\n out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);\r\n out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);\r\n out[15] = 1;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates a 4x4 matrix from the given quaternion\r\n *\r\n * @param {mat4} out mat4 receiving operation result\r\n * @param {quat} q Quaternion to create matrix from\r\n *\r\n * @returns {mat4} out\r\n */\r\nexport function fromQuat(out, q) {\r\n let x = q[0], y = q[1], z = q[2], w = q[3];\r\n let x2 = x + x;\r\n let y2 = y + y;\r\n let z2 = z + z;\r\n\r\n let xx = x * x2;\r\n let yx = y * x2;\r\n let yy = y * y2;\r\n let zx = z * x2;\r\n let zy = z * y2;\r\n let zz = z * z2;\r\n let wx = w * x2;\r\n let wy = w * y2;\r\n let wz = w * z2;\r\n\r\n out[0] = 1 - yy - zz;\r\n out[1] = yx + wz;\r\n out[2] = zx - wy;\r\n out[3] = 0;\r\n\r\n out[4] = yx - wz;\r\n out[5] = 1 - xx - zz;\r\n out[6] = zy + wx;\r\n out[7] = 0;\r\n\r\n out[8] = zx + wy;\r\n out[9] = zy - wx;\r\n out[10] = 1 - xx - yy;\r\n out[11] = 0;\r\n\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = 0;\r\n out[15] = 1;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a frustum matrix with the given bounds\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {Number} left Left bound of the frustum\r\n * @param {Number} right Right bound of the frustum\r\n * @param {Number} bottom Bottom bound of the frustum\r\n * @param {Number} top Top bound of the frustum\r\n * @param {Number} near Near bound of the frustum\r\n * @param {Number} far Far bound of the frustum\r\n * @returns {mat4} out\r\n */\r\nexport function frustum(out, left, right, bottom, top, near, far) {\r\n let rl = 1 / (right - left);\r\n let tb = 1 / (top - bottom);\r\n let nf = 1 / (near - far);\r\n out[0] = (near * 2) * rl;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = (near * 2) * tb;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = (right + left) * rl;\r\n out[9] = (top + bottom) * tb;\r\n out[10] = (far + near) * nf;\r\n out[11] = -1;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = (far * near * 2) * nf;\r\n out[15] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a perspective projection matrix with the given bounds\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {number} fovy Vertical field of view in radians\r\n * @param {number} aspect Aspect ratio. typically viewport width/height\r\n * @param {number} near Near bound of the frustum\r\n * @param {number} far Far bound of the frustum\r\n * @returns {mat4} out\r\n */\r\nexport function perspective(out, fovy, aspect, near, far) {\r\n let f = 1.0 / Math.tan(fovy / 2);\r\n let nf = 1 / (near - far);\r\n out[0] = f / aspect;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = f;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = (far + near) * nf;\r\n out[11] = -1;\r\n out[12] = 0;\r\n out[13] = 0;\r\n out[14] = (2 * far * near) * nf;\r\n out[15] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a perspective projection matrix with the given field of view.\r\n * This is primarily useful for generating projection matrices to be used\r\n * with the still experiemental WebVR API.\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees\r\n * @param {number} near Near bound of the frustum\r\n * @param {number} far Far bound of the frustum\r\n * @returns {mat4} out\r\n */\r\nexport function perspectiveFromFieldOfView(out, fov, near, far) {\r\n let upTan = Math.tan(fov.upDegrees * Math.PI/180.0);\r\n let downTan = Math.tan(fov.downDegrees * Math.PI/180.0);\r\n let leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0);\r\n let rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0);\r\n let xScale = 2.0 / (leftTan + rightTan);\r\n let yScale = 2.0 / (upTan + downTan);\r\n\r\n out[0] = xScale;\r\n out[1] = 0.0;\r\n out[2] = 0.0;\r\n out[3] = 0.0;\r\n out[4] = 0.0;\r\n out[5] = yScale;\r\n out[6] = 0.0;\r\n out[7] = 0.0;\r\n out[8] = -((leftTan - rightTan) * xScale * 0.5);\r\n out[9] = ((upTan - downTan) * yScale * 0.5);\r\n out[10] = far / (near - far);\r\n out[11] = -1.0;\r\n out[12] = 0.0;\r\n out[13] = 0.0;\r\n out[14] = (far * near) / (near - far);\r\n out[15] = 0.0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a orthogonal projection matrix with the given bounds\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {number} left Left bound of the frustum\r\n * @param {number} right Right bound of the frustum\r\n * @param {number} bottom Bottom bound of the frustum\r\n * @param {number} top Top bound of the frustum\r\n * @param {number} near Near bound of the frustum\r\n * @param {number} far Far bound of the frustum\r\n * @returns {mat4} out\r\n */\r\nexport function ortho(out, left, right, bottom, top, near, far) {\r\n let lr = 1 / (left - right);\r\n let bt = 1 / (bottom - top);\r\n let nf = 1 / (near - far);\r\n out[0] = -2 * lr;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n out[4] = 0;\r\n out[5] = -2 * bt;\r\n out[6] = 0;\r\n out[7] = 0;\r\n out[8] = 0;\r\n out[9] = 0;\r\n out[10] = 2 * nf;\r\n out[11] = 0;\r\n out[12] = (left + right) * lr;\r\n out[13] = (top + bottom) * bt;\r\n out[14] = (far + near) * nf;\r\n out[15] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a look-at matrix with the given eye position, focal point, and up axis. \r\n * If you want a matrix that actually makes an object look at another object, you should use targetTo instead.\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {vec3} eye Position of the viewer\r\n * @param {vec3} center Point the viewer is looking at\r\n * @param {vec3} up vec3 pointing up\r\n * @returns {mat4} out\r\n */\r\nexport function lookAt(out, eye, center, up) {\r\n let x0, x1, x2, y0, y1, y2, z0, z1, z2, len;\r\n let eyex = eye[0];\r\n let eyey = eye[1];\r\n let eyez = eye[2];\r\n let upx = up[0];\r\n let upy = up[1];\r\n let upz = up[2];\r\n let centerx = center[0];\r\n let centery = center[1];\r\n let centerz = center[2];\r\n\r\n if (Math.abs(eyex - centerx) < glMatrix.EPSILON &&\r\n Math.abs(eyey - centery) < glMatrix.EPSILON &&\r\n Math.abs(eyez - centerz) < glMatrix.EPSILON) {\r\n return identity(out);\r\n }\r\n\r\n z0 = eyex - centerx;\r\n z1 = eyey - centery;\r\n z2 = eyez - centerz;\r\n\r\n len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);\r\n z0 *= len;\r\n z1 *= len;\r\n z2 *= len;\r\n\r\n x0 = upy * z2 - upz * z1;\r\n x1 = upz * z0 - upx * z2;\r\n x2 = upx * z1 - upy * z0;\r\n len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);\r\n if (!len) {\r\n x0 = 0;\r\n x1 = 0;\r\n x2 = 0;\r\n } else {\r\n len = 1 / len;\r\n x0 *= len;\r\n x1 *= len;\r\n x2 *= len;\r\n }\r\n\r\n y0 = z1 * x2 - z2 * x1;\r\n y1 = z2 * x0 - z0 * x2;\r\n y2 = z0 * x1 - z1 * x0;\r\n\r\n len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);\r\n if (!len) {\r\n y0 = 0;\r\n y1 = 0;\r\n y2 = 0;\r\n } else {\r\n len = 1 / len;\r\n y0 *= len;\r\n y1 *= len;\r\n y2 *= len;\r\n }\r\n\r\n out[0] = x0;\r\n out[1] = y0;\r\n out[2] = z0;\r\n out[3] = 0;\r\n out[4] = x1;\r\n out[5] = y1;\r\n out[6] = z1;\r\n out[7] = 0;\r\n out[8] = x2;\r\n out[9] = y2;\r\n out[10] = z2;\r\n out[11] = 0;\r\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\r\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\r\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\r\n out[15] = 1;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a matrix that makes something look at something else.\r\n *\r\n * @param {mat4} out mat4 frustum matrix will be written into\r\n * @param {vec3} eye Position of the viewer\r\n * @param {vec3} center Point the viewer is looking at\r\n * @param {vec3} up vec3 pointing up\r\n * @returns {mat4} out\r\n */\r\nexport function targetTo(out, eye, target, up) {\r\n let eyex = eye[0],\r\n eyey = eye[1],\r\n eyez = eye[2],\r\n upx = up[0],\r\n upy = up[1],\r\n upz = up[2];\r\n\r\n let z0 = eyex - target[0],\r\n z1 = eyey - target[1],\r\n z2 = eyez - target[2];\r\n\r\n let len = z0*z0 + z1*z1 + z2*z2;\r\n if (len > 0) {\r\n len = 1 / Math.sqrt(len);\r\n z0 *= len;\r\n z1 *= len;\r\n z2 *= len;\r\n }\r\n\r\n let x0 = upy * z2 - upz * z1,\r\n x1 = upz * z0 - upx * z2,\r\n x2 = upx * z1 - upy * z0;\r\n\r\n len = x0*x0 + x1*x1 + x2*x2;\r\n if (len > 0) {\r\n len = 1 / Math.sqrt(len);\r\n x0 *= len;\r\n x1 *= len;\r\n x2 *= len;\r\n }\r\n\r\n out[0] = x0;\r\n out[1] = x1;\r\n out[2] = x2;\r\n out[3] = 0;\r\n out[4] = z1 * x2 - z2 * x1;\r\n out[5] = z2 * x0 - z0 * x2;\r\n out[6] = z0 * x1 - z1 * x0;\r\n out[7] = 0;\r\n out[8] = z0;\r\n out[9] = z1;\r\n out[10] = z2;\r\n out[11] = 0;\r\n out[12] = eyex;\r\n out[13] = eyey;\r\n out[14] = eyez;\r\n out[15] = 1;\r\n return out;\r\n};\r\n\r\n/**\r\n * Returns a string representation of a mat4\r\n *\r\n * @param {mat4} a matrix to represent as a string\r\n * @returns {String} string representation of the matrix\r\n */\r\nexport function str(a) {\r\n return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' +\r\n a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' +\r\n a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' +\r\n a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')';\r\n}\r\n\r\n/**\r\n * Returns Frobenius norm of a mat4\r\n *\r\n * @param {mat4} a the matrix to calculate Frobenius norm of\r\n * @returns {Number} Frobenius norm\r\n */\r\nexport function frob(a) {\r\n return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2) ))\r\n}\r\n\r\n/**\r\n * Adds two mat4's\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the first operand\r\n * @param {mat4} b the second operand\r\n * @returns {mat4} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n out[4] = a[4] + b[4];\r\n out[5] = a[5] + b[5];\r\n out[6] = a[6] + b[6];\r\n out[7] = a[7] + b[7];\r\n out[8] = a[8] + b[8];\r\n out[9] = a[9] + b[9];\r\n out[10] = a[10] + b[10];\r\n out[11] = a[11] + b[11];\r\n out[12] = a[12] + b[12];\r\n out[13] = a[13] + b[13];\r\n out[14] = a[14] + b[14];\r\n out[15] = a[15] + b[15];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts matrix b from matrix a\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the first operand\r\n * @param {mat4} b the second operand\r\n * @returns {mat4} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n out[3] = a[3] - b[3];\r\n out[4] = a[4] - b[4];\r\n out[5] = a[5] - b[5];\r\n out[6] = a[6] - b[6];\r\n out[7] = a[7] - b[7];\r\n out[8] = a[8] - b[8];\r\n out[9] = a[9] - b[9];\r\n out[10] = a[10] - b[10];\r\n out[11] = a[11] - b[11];\r\n out[12] = a[12] - b[12];\r\n out[13] = a[13] - b[13];\r\n out[14] = a[14] - b[14];\r\n out[15] = a[15] - b[15];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiply each element of the matrix by a scalar.\r\n *\r\n * @param {mat4} out the receiving matrix\r\n * @param {mat4} a the matrix to scale\r\n * @param {Number} b amount to scale the matrix's elements by\r\n * @returns {mat4} out\r\n */\r\nexport function multiplyScalar(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n out[4] = a[4] * b;\r\n out[5] = a[5] * b;\r\n out[6] = a[6] * b;\r\n out[7] = a[7] * b;\r\n out[8] = a[8] * b;\r\n out[9] = a[9] * b;\r\n out[10] = a[10] * b;\r\n out[11] = a[11] * b;\r\n out[12] = a[12] * b;\r\n out[13] = a[13] * b;\r\n out[14] = a[14] * b;\r\n out[15] = a[15] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two mat4's after multiplying each element of the second operand by a scalar value.\r\n *\r\n * @param {mat4} out the receiving vector\r\n * @param {mat4} a the first operand\r\n * @param {mat4} b the second operand\r\n * @param {Number} scale the amount to scale b's elements by before adding\r\n * @returns {mat4} out\r\n */\r\nexport function multiplyScalarAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n out[3] = a[3] + (b[3] * scale);\r\n out[4] = a[4] + (b[4] * scale);\r\n out[5] = a[5] + (b[5] * scale);\r\n out[6] = a[6] + (b[6] * scale);\r\n out[7] = a[7] + (b[7] * scale);\r\n out[8] = a[8] + (b[8] * scale);\r\n out[9] = a[9] + (b[9] * scale);\r\n out[10] = a[10] + (b[10] * scale);\r\n out[11] = a[11] + (b[11] * scale);\r\n out[12] = a[12] + (b[12] * scale);\r\n out[13] = a[13] + (b[13] * scale);\r\n out[14] = a[14] + (b[14] * scale);\r\n out[15] = a[15] + (b[15] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {mat4} a The first matrix.\r\n * @param {mat4} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] &&\r\n a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] &&\r\n a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] &&\r\n a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];\r\n}\r\n\r\n/**\r\n * Returns whether or not the matrices have approximately the same elements in the same position.\r\n *\r\n * @param {mat4} a The first matrix.\r\n * @param {mat4} b The second matrix.\r\n * @returns {Boolean} True if the matrices are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7];\r\n let a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11];\r\n let a12 = a[12], a13 = a[13], a14 = a[14], a15 = a[15];\r\n\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\r\n let b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7];\r\n let b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11];\r\n let b12 = b[12], b13 = b[13], b14 = b[14], b15 = b[15];\r\n\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\r\n Math.abs(a4 - b4) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\r\n Math.abs(a5 - b5) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\r\n Math.abs(a6 - b6) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\r\n Math.abs(a7 - b7) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a7), Math.abs(b7)) &&\r\n Math.abs(a8 - b8) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a8), Math.abs(b8)) &&\r\n Math.abs(a9 - b9) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a9), Math.abs(b9)) &&\r\n Math.abs(a10 - b10) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a10), Math.abs(b10)) &&\r\n Math.abs(a11 - b11) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a11), Math.abs(b11)) &&\r\n Math.abs(a12 - b12) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a12), Math.abs(b12)) &&\r\n Math.abs(a13 - b13) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a13), Math.abs(b13)) &&\r\n Math.abs(a14 - b14) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a14), Math.abs(b14)) &&\r\n Math.abs(a15 - b15) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a15), Math.abs(b15)));\r\n}\r\n\r\n/**\r\n * Alias for {@link mat4.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link mat4.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\"\r\nimport * as mat3 from \"./mat3.js\"\r\nimport * as vec3 from \"./vec3.js\"\r\nimport * as vec4 from \"./vec4.js\"\r\n\r\n/**\r\n * Quaternion\r\n * @module quat\r\n */\r\n\r\n/**\r\n * Creates a new identity quat\r\n *\r\n * @returns {quat} a new quaternion\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set a quat to the identity quaternion\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @returns {quat} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n return out;\r\n}\r\n\r\n/**\r\n * Sets a quat from the given angle and rotation axis,\r\n * then returns it.\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {vec3} axis the axis around which to rotate\r\n * @param {Number} rad the angle in radians\r\n * @returns {quat} out\r\n **/\r\nexport function setAxisAngle(out, axis, rad) {\r\n rad = rad * 0.5;\r\n let s = Math.sin(rad);\r\n out[0] = s * axis[0];\r\n out[1] = s * axis[1];\r\n out[2] = s * axis[2];\r\n out[3] = Math.cos(rad);\r\n return out;\r\n}\r\n\r\n/**\r\n * Gets the rotation axis and angle for a given\r\n * quaternion. If a quaternion is created with\r\n * setAxisAngle, this method will return the same\r\n * values as providied in the original parameter list\r\n * OR functionally equivalent values.\r\n * Example: The quaternion formed by axis [0, 0, 1] and\r\n * angle -90 is the same as the quaternion formed by\r\n * [0, 0, 1] and 270. This method favors the latter.\r\n * @param {vec3} out_axis Vector receiving the axis of rotation\r\n * @param {quat} q Quaternion to be decomposed\r\n * @return {Number} Angle, in radians, of the rotation\r\n */\r\nexport function getAxisAngle(out_axis, q) {\r\n let rad = Math.acos(q[3]) * 2.0;\r\n let s = Math.sin(rad / 2.0);\r\n if (s != 0.0) {\r\n out_axis[0] = q[0] / s;\r\n out_axis[1] = q[1] / s;\r\n out_axis[2] = q[2] / s;\r\n } else {\r\n // If s is zero, return any axis (no rotation - axis does not matter)\r\n out_axis[0] = 1;\r\n out_axis[1] = 0;\r\n out_axis[2] = 0;\r\n }\r\n return rad;\r\n}\r\n\r\n/**\r\n * Multiplies two quat's\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @returns {quat} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\r\n let bx = b[0], by = b[1], bz = b[2], bw = b[3];\r\n\r\n out[0] = ax * bw + aw * bx + ay * bz - az * by;\r\n out[1] = ay * bw + aw * by + az * bx - ax * bz;\r\n out[2] = az * bw + aw * bz + ax * by - ay * bx;\r\n out[3] = aw * bw - ax * bx - ay * by - az * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a quaternion by the given angle about the X axis\r\n *\r\n * @param {quat} out quat receiving operation result\r\n * @param {quat} a quat to rotate\r\n * @param {number} rad angle (in radians) to rotate\r\n * @returns {quat} out\r\n */\r\nexport function rotateX(out, a, rad) {\r\n rad *= 0.5;\r\n\r\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\r\n let bx = Math.sin(rad), bw = Math.cos(rad);\r\n\r\n out[0] = ax * bw + aw * bx;\r\n out[1] = ay * bw + az * bx;\r\n out[2] = az * bw - ay * bx;\r\n out[3] = aw * bw - ax * bx;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a quaternion by the given angle about the Y axis\r\n *\r\n * @param {quat} out quat receiving operation result\r\n * @param {quat} a quat to rotate\r\n * @param {number} rad angle (in radians) to rotate\r\n * @returns {quat} out\r\n */\r\nexport function rotateY(out, a, rad) {\r\n rad *= 0.5;\r\n\r\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\r\n let by = Math.sin(rad), bw = Math.cos(rad);\r\n\r\n out[0] = ax * bw - az * by;\r\n out[1] = ay * bw + aw * by;\r\n out[2] = az * bw + ax * by;\r\n out[3] = aw * bw - ay * by;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a quaternion by the given angle about the Z axis\r\n *\r\n * @param {quat} out quat receiving operation result\r\n * @param {quat} a quat to rotate\r\n * @param {number} rad angle (in radians) to rotate\r\n * @returns {quat} out\r\n */\r\nexport function rotateZ(out, a, rad) {\r\n rad *= 0.5;\r\n\r\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\r\n let bz = Math.sin(rad), bw = Math.cos(rad);\r\n\r\n out[0] = ax * bw + ay * bz;\r\n out[1] = ay * bw - ax * bz;\r\n out[2] = az * bw + aw * bz;\r\n out[3] = aw * bw - az * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the W component of a quat from the X, Y, and Z components.\r\n * Assumes that quaternion is 1 unit in length.\r\n * Any existing W component will be ignored.\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a quat to calculate W component of\r\n * @returns {quat} out\r\n */\r\nexport function calculateW(out, a) {\r\n let x = a[0], y = a[1], z = a[2];\r\n\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));\r\n return out;\r\n}\r\n\r\n/**\r\n * Performs a spherical linear interpolation between two quat\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {quat} out\r\n */\r\nexport function slerp(out, a, b, t) {\r\n // benchmarks:\r\n // http://jsperf.com/quaternion-slerp-implementations\r\n let ax = a[0], ay = a[1], az = a[2], aw = a[3];\r\n let bx = b[0], by = b[1], bz = b[2], bw = b[3];\r\n\r\n let omega, cosom, sinom, scale0, scale1;\r\n\r\n // calc cosine\r\n cosom = ax * bx + ay * by + az * bz + aw * bw;\r\n // adjust signs (if necessary)\r\n if ( cosom < 0.0 ) {\r\n cosom = -cosom;\r\n bx = - bx;\r\n by = - by;\r\n bz = - bz;\r\n bw = - bw;\r\n }\r\n // calculate coefficients\r\n if ( (1.0 - cosom) > 0.000001 ) {\r\n // standard case (slerp)\r\n omega = Math.acos(cosom);\r\n sinom = Math.sin(omega);\r\n scale0 = Math.sin((1.0 - t) * omega) / sinom;\r\n scale1 = Math.sin(t * omega) / sinom;\r\n } else {\r\n // \"from\" and \"to\" quaternions are very close\r\n // ... so we can do a linear interpolation\r\n scale0 = 1.0 - t;\r\n scale1 = t;\r\n }\r\n // calculate final values\r\n out[0] = scale0 * ax + scale1 * bx;\r\n out[1] = scale0 * ay + scale1 * by;\r\n out[2] = scale0 * az + scale1 * bz;\r\n out[3] = scale0 * aw + scale1 * bw;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the inverse of a quat\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a quat to calculate inverse of\r\n * @returns {quat} out\r\n */\r\nexport function invert(out, a) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let dot = a0*a0 + a1*a1 + a2*a2 + a3*a3;\r\n let invDot = dot ? 1.0/dot : 0;\r\n\r\n // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0\r\n\r\n out[0] = -a0*invDot;\r\n out[1] = -a1*invDot;\r\n out[2] = -a2*invDot;\r\n out[3] = a3*invDot;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the conjugate of a quat\r\n * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a quat to calculate conjugate of\r\n * @returns {quat} out\r\n */\r\nexport function conjugate(out, a) {\r\n out[0] = -a[0];\r\n out[1] = -a[1];\r\n out[2] = -a[2];\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from the given 3x3 rotation matrix.\r\n *\r\n * NOTE: The resultant quaternion is not normalized, so you should be sure\r\n * to renormalize the quaternion yourself where necessary.\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {mat3} m rotation matrix\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport function fromMat3(out, m) {\r\n // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes\r\n // article \"Quaternion Calculus and Fast Animation\".\r\n let fTrace = m[0] + m[4] + m[8];\r\n let fRoot;\r\n\r\n if ( fTrace > 0.0 ) {\r\n // |w| > 1/2, may as well choose w > 1/2\r\n fRoot = Math.sqrt(fTrace + 1.0); // 2w\r\n out[3] = 0.5 * fRoot;\r\n fRoot = 0.5/fRoot; // 1/(4w)\r\n out[0] = (m[5]-m[7])*fRoot;\r\n out[1] = (m[6]-m[2])*fRoot;\r\n out[2] = (m[1]-m[3])*fRoot;\r\n } else {\r\n // |w| <= 1/2\r\n let i = 0;\r\n if ( m[4] > m[0] )\r\n i = 1;\r\n if ( m[8] > m[i*3+i] )\r\n i = 2;\r\n let j = (i+1)%3;\r\n let k = (i+2)%3;\r\n\r\n fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0);\r\n out[i] = 0.5 * fRoot;\r\n fRoot = 0.5 / fRoot;\r\n out[3] = (m[j*3+k] - m[k*3+j]) * fRoot;\r\n out[j] = (m[j*3+i] + m[i*3+j]) * fRoot;\r\n out[k] = (m[k*3+i] + m[i*3+k]) * fRoot;\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a quaternion from the given euler angle x, y, z.\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {x} Angle to rotate around X axis in degrees.\r\n * @param {y} Angle to rotate around Y axis in degrees.\r\n * @param {z} Angle to rotate around Z axis in degrees.\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport function fromEuler(out, x, y, z) {\r\n let halfToRad = 0.5 * Math.PI / 180.0;\r\n x *= halfToRad;\r\n y *= halfToRad;\r\n z *= halfToRad;\r\n\r\n let sx = Math.sin(x);\r\n let cx = Math.cos(x);\r\n let sy = Math.sin(y);\r\n let cy = Math.cos(y);\r\n let sz = Math.sin(z);\r\n let cz = Math.cos(z);\r\n\r\n out[0] = sx * cy * cz - cx * sy * sz;\r\n out[1] = cx * sy * cz + sx * cy * sz;\r\n out[2] = cx * cy * sz - sx * sy * cz;\r\n out[3] = cx * cy * cz + sx * sy * sz;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a quatenion\r\n *\r\n * @param {quat} a vector to represent as a string\r\n * @returns {String} string representation of the vector\r\n */\r\nexport function str(a) {\r\n return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\r\n}\r\n\r\n/**\r\n * Creates a new quat initialized with values from an existing quaternion\r\n *\r\n * @param {quat} a quaternion to clone\r\n * @returns {quat} a new quaternion\r\n * @function\r\n */\r\nexport const clone = vec4.clone;\r\n\r\n/**\r\n * Creates a new quat initialized with the given values\r\n *\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @param {Number} w W component\r\n * @returns {quat} a new quaternion\r\n * @function\r\n */\r\nexport const fromValues = vec4.fromValues;\r\n\r\n/**\r\n * Copy the values from one quat to another\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the source quaternion\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const copy = vec4.copy;\r\n\r\n/**\r\n * Set the components of a quat to the given values\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @param {Number} w W component\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const set = vec4.set;\r\n\r\n/**\r\n * Adds two quat's\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const add = vec4.add;\r\n\r\n/**\r\n * Alias for {@link quat.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Scales a quat by a scalar number\r\n *\r\n * @param {quat} out the receiving vector\r\n * @param {quat} a the vector to scale\r\n * @param {Number} b amount to scale the vector by\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const scale = vec4.scale;\r\n\r\n/**\r\n * Calculates the dot product of two quat's\r\n *\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @returns {Number} dot product of a and b\r\n * @function\r\n */\r\nexport const dot = vec4.dot;\r\n\r\n/**\r\n * Performs a linear interpolation between two quat's\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const lerp = vec4.lerp;\r\n\r\n/**\r\n * Calculates the length of a quat\r\n *\r\n * @param {quat} a vector to calculate length of\r\n * @returns {Number} length of a\r\n */\r\nexport const length = vec4.length;\r\n\r\n/**\r\n * Alias for {@link quat.length}\r\n * @function\r\n */\r\nexport const len = length;\r\n\r\n/**\r\n * Calculates the squared length of a quat\r\n *\r\n * @param {quat} a vector to calculate squared length of\r\n * @returns {Number} squared length of a\r\n * @function\r\n */\r\nexport const squaredLength = vec4.squaredLength;\r\n\r\n/**\r\n * Alias for {@link quat.squaredLength}\r\n * @function\r\n */\r\nexport const sqrLen = squaredLength;\r\n\r\n/**\r\n * Normalize a quat\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a quaternion to normalize\r\n * @returns {quat} out\r\n * @function\r\n */\r\nexport const normalize = vec4.normalize;\r\n\r\n/**\r\n * Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {quat} a The first quaternion.\r\n * @param {quat} b The second quaternion.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport const exactEquals = vec4.exactEquals;\r\n\r\n/**\r\n * Returns whether or not the quaternions have approximately the same elements in the same position.\r\n *\r\n * @param {quat} a The first vector.\r\n * @param {quat} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport const equals = vec4.equals;\r\n\r\n/**\r\n * Sets a quaternion to represent the shortest rotation from one\r\n * vector to another.\r\n *\r\n * Both vectors are assumed to be unit length.\r\n *\r\n * @param {quat} out the receiving quaternion.\r\n * @param {vec3} a the initial vector\r\n * @param {vec3} b the destination vector\r\n * @returns {quat} out\r\n */\r\nexport const rotationTo = (function() {\r\n let tmpvec3 = vec3.create();\r\n let xUnitVec3 = vec3.fromValues(1,0,0);\r\n let yUnitVec3 = vec3.fromValues(0,1,0);\r\n\r\n return function(out, a, b) {\r\n let dot = vec3.dot(a, b);\r\n if (dot < -0.999999) {\r\n vec3.cross(tmpvec3, xUnitVec3, a);\r\n if (vec3.len(tmpvec3) < 0.000001)\r\n vec3.cross(tmpvec3, yUnitVec3, a);\r\n vec3.normalize(tmpvec3, tmpvec3);\r\n setAxisAngle(out, tmpvec3, Math.PI);\r\n return out;\r\n } else if (dot > 0.999999) {\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n return out;\r\n } else {\r\n vec3.cross(tmpvec3, a, b);\r\n out[0] = tmpvec3[0];\r\n out[1] = tmpvec3[1];\r\n out[2] = tmpvec3[2];\r\n out[3] = 1 + dot;\r\n return normalize(out, out);\r\n }\r\n };\r\n})();\r\n\r\n/**\r\n * Performs a spherical linear interpolation with two control points\r\n *\r\n * @param {quat} out the receiving quaternion\r\n * @param {quat} a the first operand\r\n * @param {quat} b the second operand\r\n * @param {quat} c the third operand\r\n * @param {quat} d the fourth operand\r\n * @param {Number} t interpolation amount\r\n * @returns {quat} out\r\n */\r\nexport const sqlerp = (function () {\r\n let temp1 = create();\r\n let temp2 = create();\r\n\r\n return function (out, a, b, c, d, t) {\r\n slerp(temp1, a, d, t);\r\n slerp(temp2, b, c, t);\r\n slerp(out, temp1, temp2, 2 * t * (1 - t));\r\n\r\n return out;\r\n };\r\n}());\r\n\r\n/**\r\n * Sets the specified quaternion with values corresponding to the given\r\n * axes. Each axis is a vec3 and is expected to be unit length and\r\n * perpendicular to all other specified axes.\r\n *\r\n * @param {vec3} view the vector representing the viewing direction\r\n * @param {vec3} right the vector representing the local \"right\" direction\r\n * @param {vec3} up the vector representing the local \"up\" direction\r\n * @returns {quat} out\r\n */\r\nexport const setAxes = (function() {\r\n let matr = mat3.create();\r\n\r\n return function(out, view, right, up) {\r\n matr[0] = right[0];\r\n matr[3] = right[1];\r\n matr[6] = right[2];\r\n\r\n matr[1] = up[0];\r\n matr[4] = up[1];\r\n matr[7] = up[2];\r\n\r\n matr[2] = -view[0];\r\n matr[5] = -view[1];\r\n matr[8] = -view[2];\r\n\r\n return normalize(out, fromMat3(out, matr));\r\n };\r\n})();\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\n\r\nimport * as glMatrix from \"./common.js\";\r\nimport * as quat from \"./quat.js\";\r\nimport * as mat4 from \"./mat4.js\";\r\n\r\n/**\r\n * Dual Quaternion<br>\r\n * Format: [real, dual]<br>\r\n * Quaternion format: XYZW<br>\r\n * Make sure to have normalized dual quaternions, otherwise the functions may not work as intended.<br>\r\n * @module quat2\r\n */\r\n\r\n\r\n/**\r\n * Creates a new identity dual quat\r\n *\r\n * @returns {quat2} a new dual quaternion [real -> rotation, dual -> translation]\r\n */\r\nexport function create() {\r\n let dq = new glMatrix.ARRAY_TYPE(8);\r\n dq[0] = 0;\r\n dq[1] = 0;\r\n dq[2] = 0;\r\n dq[3] = 1;\r\n dq[4] = 0;\r\n dq[5] = 0;\r\n dq[6] = 0;\r\n dq[7] = 0;\r\n return dq;\r\n}\r\n\r\n/**\r\n * Creates a new quat initialized with values from an existing quaternion\r\n *\r\n * @param {quat2} a dual quaternion to clone\r\n * @returns {quat2} new dual quaternion\r\n * @function\r\n */\r\nexport function clone(a) {\r\n let dq = new glMatrix.ARRAY_TYPE(8);\r\n dq[0] = a[0];\r\n dq[1] = a[1];\r\n dq[2] = a[2];\r\n dq[3] = a[3];\r\n dq[4] = a[4];\r\n dq[5] = a[5];\r\n dq[6] = a[6];\r\n dq[7] = a[7];\r\n return dq;\r\n}\r\n\r\n/**\r\n * Creates a new dual quat initialized with the given values\r\n *\r\n * @param {Number} x1 X component\r\n * @param {Number} y1 Y component\r\n * @param {Number} z1 Z component\r\n * @param {Number} w1 W component\r\n * @param {Number} x2 X component\r\n * @param {Number} y2 Y component\r\n * @param {Number} z2 Z component\r\n * @param {Number} w2 W component\r\n * @returns {quat2} new dual quaternion\r\n * @function\r\n */\r\nexport function fromValues(x1, y1, z1, w1, x2, y2, z2, w2) {\r\n let dq = new glMatrix.ARRAY_TYPE(8);\r\n dq[0] = x1;\r\n dq[1] = y1;\r\n dq[2] = z1;\r\n dq[3] = w1;\r\n dq[4] = x2;\r\n dq[5] = y2;\r\n dq[6] = z2;\r\n dq[7] = w2;\r\n return dq;\r\n}\r\n\r\n/**\r\n * Creates a new dual quat from the given values (quat and translation)\r\n *\r\n * @param {Number} x1 X component\r\n * @param {Number} y1 Y component\r\n * @param {Number} z1 Z component\r\n * @param {Number} w1 W component\r\n * @param {Number} x2 X component (translation)\r\n * @param {Number} y2 Y component (translation)\r\n * @param {Number} z2 Z component (translation)\r\n * @returns {quat2} new dual quaternion\r\n * @function\r\n */\r\nexport function fromRotationTranslationValues(x1, y1, z1, w1, x2, y2, z2) {\r\n let dq = new glMatrix.ARRAY_TYPE(8);\r\n dq[0] = x1;\r\n dq[1] = y1;\r\n dq[2] = z1;\r\n dq[3] = w1;\r\n let ax = x2 * 0.5,\r\n ay = y2 * 0.5,\r\n az = z2 * 0.5;\r\n dq[4] = ax * w1 + ay * z1 - az * y1;\r\n dq[5] = ay * w1 + az * x1 - ax * z1;\r\n dq[6] = az * w1 + ax * y1 - ay * x1;\r\n dq[7] = -ax * x1 - ay * y1 - az * z1;\r\n return dq;\r\n}\r\n\r\n/**\r\n * Creates a dual quat from a quaternion and a translation\r\n *\r\n * @param {quat2} dual quaternion receiving operation result\r\n * @param {quat} q quaternion\r\n * @param {vec3} t tranlation vector\r\n * @returns {quat2} dual quaternion receiving operation result\r\n * @function\r\n */\r\nexport function fromRotationTranslation(out, q, t) {\r\n let ax = t[0] * 0.5,\r\n ay = t[1] * 0.5,\r\n az = t[2] * 0.5,\r\n bx = q[0],\r\n by = q[1],\r\n bz = q[2],\r\n bw = q[3];\r\n out[0] = bx;\r\n out[1] = by;\r\n out[2] = bz;\r\n out[3] = bw;\r\n out[4] = ax * bw + ay * bz - az * by;\r\n out[5] = ay * bw + az * bx - ax * bz;\r\n out[6] = az * bw + ax * by - ay * bx;\r\n out[7] = -ax * bx - ay * by - az * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a dual quat from a translation\r\n *\r\n * @param {quat2} dual quaternion receiving operation result\r\n * @param {vec3} t translation vector\r\n * @returns {quat2} dual quaternion receiving operation result\r\n * @function\r\n */\r\nexport function fromTranslation(out, t) {\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n out[4] = t[0] * 0.5;\r\n out[5] = t[1] * 0.5;\r\n out[6] = t[2] * 0.5;\r\n out[7] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a dual quat from a quaternion\r\n *\r\n * @param {quat2} dual quaternion receiving operation result\r\n * @param {quat} q the quaternion\r\n * @returns {quat2} dual quaternion receiving operation result\r\n * @function\r\n */\r\nexport function fromRotation(out, q) {\r\n out[0] = q[0];\r\n out[1] = q[1];\r\n out[2] = q[2];\r\n out[3] = q[3];\r\n out[4] = 0;\r\n out[5] = 0;\r\n out[6] = 0;\r\n out[7] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new dual quat from a matrix (4x4)\r\n * \r\n * @param {quat2} out the dual quaternion\r\n * @param {mat4} a the matrix\r\n * @returns {quat2} dual quat receiving operation result\r\n * @function\r\n */\r\nexport function fromMat4(out, a) {\r\n //TODO Optimize this \r\n let outer = quat.create();\r\n mat4.getRotation(outer, a);\r\n let t = new glMatrix.ARRAY_TYPE(3);\r\n mat4.getTranslation(t, a);\r\n fromRotationTranslation(out, outer, t);\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one dual quat to another\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the source dual quaternion\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n out[4] = a[4];\r\n out[5] = a[5];\r\n out[6] = a[6];\r\n out[7] = a[7];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set a dual quat to the identity dual quaternion\r\n *\r\n * @param {quat2} out the receiving quaternion\r\n * @returns {quat2} out\r\n */\r\nexport function identity(out) {\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 1;\r\n out[4] = 0;\r\n out[5] = 0;\r\n out[6] = 0;\r\n out[7] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a dual quat to the given values\r\n *\r\n * @param {quat2} out the receiving quaternion\r\n * @param {Number} x1 X component\r\n * @param {Number} y1 Y component\r\n * @param {Number} z1 Z component\r\n * @param {Number} w1 W component\r\n * @param {Number} x2 X component\r\n * @param {Number} y2 Y component\r\n * @param {Number} z2 Z component\r\n * @param {Number} w2 W component\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function set(out, x1, y1, z1, w1, x2, y2, z2, w2) {\r\n out[0] = x1;\r\n out[1] = y1;\r\n out[2] = z1;\r\n out[3] = w1;\r\n\r\n out[4] = x2;\r\n out[5] = y2;\r\n out[6] = z2;\r\n out[7] = w2;\r\n return out;\r\n}\r\n\r\n/**\r\n * Gets the real part of a dual quat\r\n * @param {quat} out real part\r\n * @param {quat2} a Dual Quaternion\r\n * @return {quat} real part\r\n */\r\nexport const getReal = quat.copy;\r\n\r\n/**\r\n * Gets the dual part of a dual quat\r\n * @param {quat} out dual part\r\n * @param {quat2} a Dual Quaternion\r\n * @return {quat} dual part\r\n */\r\nexport function getDual(out, a) {\r\n out[0] = a[4];\r\n out[1] = a[5];\r\n out[2] = a[6];\r\n out[3] = a[7];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the real component of a dual quat to the given quaternion\r\n *\r\n * @param {quat2} out the receiving quaternion\r\n * @param {quat} q a quaternion representing the real part\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport const setReal = quat.copy;\r\n\r\n/**\r\n * Set the dual component of a dual quat to the given quaternion\r\n *\r\n * @param {quat2} out the receiving quaternion\r\n * @param {quat} q a quaternion representing the dual part\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function setDual(out, q) {\r\n out[4] = q[0];\r\n out[5] = q[1];\r\n out[6] = q[2];\r\n out[7] = q[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Gets the translation of a normalized dual quat\r\n * @param {vec3} out translation\r\n * @param {quat2} a Dual Quaternion to be decomposed\r\n * @return {vec3} translation\r\n */\r\nexport function getTranslation(out, a) {\r\n let ax = a[4],\r\n ay = a[5],\r\n az = a[6],\r\n aw = a[7],\r\n bx = -a[0],\r\n by = -a[1],\r\n bz = -a[2],\r\n bw = a[3];\r\n out[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;\r\n out[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;\r\n out[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;\r\n return out;\r\n}\r\n\r\n/**\r\n * Translates a dual quat by the given vector\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to translate\r\n * @param {vec3} v vector to translate by\r\n * @returns {quat2} out\r\n */\r\nexport function translate(out, a, v) {\r\n let ax1 = a[0],\r\n ay1 = a[1],\r\n az1 = a[2],\r\n aw1 = a[3],\r\n bx1 = v[0] * 0.5,\r\n by1 = v[1] * 0.5,\r\n bz1 = v[2] * 0.5,\r\n ax2 = a[4],\r\n ay2 = a[5],\r\n az2 = a[6],\r\n aw2 = a[7];\r\n out[0] = ax1;\r\n out[1] = ay1;\r\n out[2] = az1;\r\n out[3] = aw1;\r\n out[4] = aw1 * bx1 + ay1 * bz1 - az1 * by1 + ax2;\r\n out[5] = aw1 * by1 + az1 * bx1 - ax1 * bz1 + ay2;\r\n out[6] = aw1 * bz1 + ax1 * by1 - ay1 * bx1 + az2;\r\n out[7] = -ax1 * bx1 - ay1 * by1 - az1 * bz1 + aw2;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat around the X axis\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @param {number} rad how far should the rotation be\r\n * @returns {quat2} out\r\n */\r\nexport function rotateX(out, a, rad) {\r\n let bx = -a[0],\r\n by = -a[1],\r\n bz = -a[2],\r\n bw = a[3],\r\n ax = a[4],\r\n ay = a[5],\r\n az = a[6],\r\n aw = a[7],\r\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\r\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\r\n az1 = az * bw + aw * bz + ax * by - ay * bx,\r\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\r\n quat.rotateX(out, a, rad);\r\n bx = out[0];\r\n by = out[1];\r\n bz = out[2];\r\n bw = out[3];\r\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\r\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\r\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\r\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat around the Y axis\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @param {number} rad how far should the rotation be\r\n * @returns {quat2} out\r\n */\r\nexport function rotateY(out, a, rad) {\r\n let bx = -a[0],\r\n by = -a[1],\r\n bz = -a[2],\r\n bw = a[3],\r\n ax = a[4],\r\n ay = a[5],\r\n az = a[6],\r\n aw = a[7],\r\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\r\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\r\n az1 = az * bw + aw * bz + ax * by - ay * bx,\r\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\r\n quat.rotateY(out, a, rad);\r\n bx = out[0];\r\n by = out[1];\r\n bz = out[2];\r\n bw = out[3];\r\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\r\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\r\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\r\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat around the Z axis\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @param {number} rad how far should the rotation be\r\n * @returns {quat2} out\r\n */\r\nexport function rotateZ(out, a, rad) {\r\n let bx = -a[0],\r\n by = -a[1],\r\n bz = -a[2],\r\n bw = a[3],\r\n ax = a[4],\r\n ay = a[5],\r\n az = a[6],\r\n aw = a[7],\r\n ax1 = ax * bw + aw * bx + ay * bz - az * by,\r\n ay1 = ay * bw + aw * by + az * bx - ax * bz,\r\n az1 = az * bw + aw * bz + ax * by - ay * bx,\r\n aw1 = aw * bw - ax * bx - ay * by - az * bz;\r\n quat.rotateZ(out, a, rad);\r\n bx = out[0];\r\n by = out[1];\r\n bz = out[2];\r\n bw = out[3];\r\n out[4] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\r\n out[5] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\r\n out[6] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\r\n out[7] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat by a given quaternion (a * q)\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @param {quat} q quaternion to rotate by\r\n * @returns {quat2} out\r\n */\r\nexport function rotateByQuatAppend(out, a, q) {\r\n let qx = q[0],\r\n qy = q[1],\r\n qz = q[2],\r\n qw = q[3],\r\n ax = a[0],\r\n ay = a[1],\r\n az = a[2],\r\n aw = a[3];\r\n\r\n out[0] = ax * qw + aw * qx + ay * qz - az * qy;\r\n out[1] = ay * qw + aw * qy + az * qx - ax * qz;\r\n out[2] = az * qw + aw * qz + ax * qy - ay * qx;\r\n out[3] = aw * qw - ax * qx - ay * qy - az * qz;\r\n ax = a[4];\r\n ay = a[5];\r\n az = a[6];\r\n aw = a[7];\r\n out[4] = ax * qw + aw * qx + ay * qz - az * qy;\r\n out[5] = ay * qw + aw * qy + az * qx - ax * qz;\r\n out[6] = az * qw + aw * qz + ax * qy - ay * qx;\r\n out[7] = aw * qw - ax * qx - ay * qy - az * qz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat by a given quaternion (q * a)\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat} q quaternion to rotate by\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @returns {quat2} out\r\n */\r\nexport function rotateByQuatPrepend(out, q, a) {\r\n let qx = q[0],\r\n qy = q[1],\r\n qz = q[2],\r\n qw = q[3],\r\n bx = a[0],\r\n by = a[1],\r\n bz = a[2],\r\n bw = a[3];\r\n\r\n out[0] = qx * bw + qw * bx + qy * bz - qz * by;\r\n out[1] = qy * bw + qw * by + qz * bx - qx * bz;\r\n out[2] = qz * bw + qw * bz + qx * by - qy * bx;\r\n out[3] = qw * bw - qx * bx - qy * by - qz * bz;\r\n bx = a[4];\r\n by = a[5];\r\n bz = a[6];\r\n bw = a[7];\r\n out[4] = qx * bw + qw * bx + qy * bz - qz * by;\r\n out[5] = qy * bw + qw * by + qz * bx - qx * bz;\r\n out[6] = qz * bw + qw * bz + qx * by - qy * bx;\r\n out[7] = qw * bw - qx * bx - qy * by - qz * bz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotates a dual quat around a given axis. Does the normalisation automatically\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the dual quaternion to rotate\r\n * @param {vec3} axis the axis to rotate around\r\n * @param {Number} rad how far the rotation should be\r\n * @returns {quat2} out\r\n */\r\nexport function rotateAroundAxis(out, a, axis, rad) {\r\n //Special case for rad = 0\r\n if (Math.abs(rad) < glMatrix.EPSILON) {\r\n return copy(out, a);\r\n }\r\n let axisLength = Math.sqrt(axis[0] * axis[0] + axis[1] * axis[1] + axis[2] * axis[2]);\r\n\r\n rad = rad * 0.5;\r\n let s = Math.sin(rad);\r\n let bx = s * axis[0] / axisLength;\r\n let by = s * axis[1] / axisLength;\r\n let bz = s * axis[2] / axisLength;\r\n let bw = Math.cos(rad);\r\n\r\n let ax1 = a[0],\r\n ay1 = a[1],\r\n az1 = a[2],\r\n aw1 = a[3];\r\n out[0] = ax1 * bw + aw1 * bx + ay1 * bz - az1 * by;\r\n out[1] = ay1 * bw + aw1 * by + az1 * bx - ax1 * bz;\r\n out[2] = az1 * bw + aw1 * bz + ax1 * by - ay1 * bx;\r\n out[3] = aw1 * bw - ax1 * bx - ay1 * by - az1 * bz;\r\n\r\n let ax = a[4],\r\n ay = a[5],\r\n az = a[6],\r\n aw = a[7];\r\n out[4] = ax * bw + aw * bx + ay * bz - az * by;\r\n out[5] = ay * bw + aw * by + az * bx - ax * bz;\r\n out[6] = az * bw + aw * bz + ax * by - ay * bx;\r\n out[7] = aw * bw - ax * bx - ay * by - az * bz;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two dual quat's\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the first operand\r\n * @param {quat2} b the second operand\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n out[4] = a[4] + b[4];\r\n out[5] = a[5] + b[5];\r\n out[6] = a[6] + b[6];\r\n out[7] = a[7] + b[7];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiplies two dual quat's\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a the first operand\r\n * @param {quat2} b the second operand\r\n * @returns {quat2} out\r\n */\r\nexport function multiply(out, a, b) {\r\n let ax0 = a[0],\r\n ay0 = a[1],\r\n az0 = a[2],\r\n aw0 = a[3],\r\n bx1 = b[4],\r\n by1 = b[5],\r\n bz1 = b[6],\r\n bw1 = b[7],\r\n ax1 = a[4],\r\n ay1 = a[5],\r\n az1 = a[6],\r\n aw1 = a[7],\r\n bx0 = b[0],\r\n by0 = b[1],\r\n bz0 = b[2],\r\n bw0 = b[3];\r\n out[0] = ax0 * bw0 + aw0 * bx0 + ay0 * bz0 - az0 * by0;\r\n out[1] = ay0 * bw0 + aw0 * by0 + az0 * bx0 - ax0 * bz0;\r\n out[2] = az0 * bw0 + aw0 * bz0 + ax0 * by0 - ay0 * bx0;\r\n out[3] = aw0 * bw0 - ax0 * bx0 - ay0 * by0 - az0 * bz0;\r\n out[4] = ax0 * bw1 + aw0 * bx1 + ay0 * bz1 - az0 * by1 + ax1 * bw0 + aw1 * bx0 + ay1 * bz0 - az1 * by0;\r\n out[5] = ay0 * bw1 + aw0 * by1 + az0 * bx1 - ax0 * bz1 + ay1 * bw0 + aw1 * by0 + az1 * bx0 - ax1 * bz0;\r\n out[6] = az0 * bw1 + aw0 * bz1 + ax0 * by1 - ay0 * bx1 + az1 * bw0 + aw1 * bz0 + ax1 * by0 - ay1 * bx0;\r\n out[7] = aw0 * bw1 - ax0 * bx1 - ay0 * by1 - az0 * bz1 + aw1 * bw0 - ax1 * bx0 - ay1 * by0 - az1 * bz0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Alias for {@link quat2.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Scales a dual quat by a scalar number\r\n *\r\n * @param {quat2} out the receiving dual quat\r\n * @param {quat2} a the dual quat to scale\r\n * @param {Number} b amount to scale the dual quat by\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function scale(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n out[4] = a[4] * b;\r\n out[5] = a[5] * b;\r\n out[6] = a[6] * b;\r\n out[7] = a[7] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the dot product of two dual quat's (The dot product of the real parts)\r\n *\r\n * @param {quat2} a the first operand\r\n * @param {quat2} b the second operand\r\n * @returns {Number} dot product of a and b\r\n * @function\r\n */\r\nexport const dot = quat.dot;\r\n\r\n/**\r\n * Performs a linear interpolation between two dual quats's\r\n * NOTE: The resulting dual quaternions won't always be normalized (The error is most noticeable when t = 0.5)\r\n *\r\n * @param {quat2} out the receiving dual quat\r\n * @param {quat2} a the first operand\r\n * @param {quat2} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {quat2} out\r\n */\r\nexport function lerp(out, a, b, t) {\r\n let mt = 1 - t;\r\n if (dot(a, b) < 0) t = -t;\r\n\r\n out[0] = a[0] * mt + b[0] * t;\r\n out[1] = a[1] * mt + b[1] * t;\r\n out[2] = a[2] * mt + b[2] * t;\r\n out[3] = a[3] * mt + b[3] * t;\r\n out[4] = a[4] * mt + b[4] * t;\r\n out[5] = a[5] * mt + b[5] * t;\r\n out[6] = a[6] * mt + b[6] * t;\r\n out[7] = a[7] * mt + b[7] * t;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the inverse of a dual quat. If they are normalized, conjugate is cheaper\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a dual quat to calculate inverse of\r\n * @returns {quat2} out\r\n */\r\nexport function invert(out, a) {\r\n let sqlen = squaredLength(a);\r\n out[0] = -a[0] / sqlen;\r\n out[1] = -a[1] / sqlen;\r\n out[2] = -a[2] / sqlen;\r\n out[3] = a[3] / sqlen;\r\n out[4] = -a[4] / sqlen;\r\n out[5] = -a[5] / sqlen;\r\n out[6] = -a[6] / sqlen;\r\n out[7] = a[7] / sqlen;\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the conjugate of a dual quat\r\n * If the dual quaternion is normalized, this function is faster than quat2.inverse and produces the same result.\r\n *\r\n * @param {quat2} out the receiving quaternion\r\n * @param {quat2} a quat to calculate conjugate of\r\n * @returns {quat2} out\r\n */\r\nexport function conjugate(out, a) {\r\n out[0] = -a[0];\r\n out[1] = -a[1];\r\n out[2] = -a[2];\r\n out[3] = a[3];\r\n out[4] = -a[4];\r\n out[5] = -a[5];\r\n out[6] = -a[6];\r\n out[7] = a[7];\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the length of a dual quat\r\n *\r\n * @param {quat2} a dual quat to calculate length of\r\n * @returns {Number} length of a\r\n * @function\r\n */\r\nexport const length = quat.length;\r\n\r\n/**\r\n * Alias for {@link quat2.length}\r\n * @function\r\n */\r\nexport const len = length;\r\n\r\n/**\r\n * Calculates the squared length of a dual quat\r\n *\r\n * @param {quat2} a dual quat to calculate squared length of\r\n * @returns {Number} squared length of a\r\n * @function\r\n */\r\nexport const squaredLength = quat.squaredLength;\r\n\r\n/**\r\n * Alias for {@link quat2.squaredLength}\r\n * @function\r\n */\r\nexport const sqrLen = squaredLength;\r\n\r\n/**\r\n * Normalize a dual quat\r\n *\r\n * @param {quat2} out the receiving dual quaternion\r\n * @param {quat2} a dual quaternion to normalize\r\n * @returns {quat2} out\r\n * @function\r\n */\r\nexport function normalize(out, a) {\r\n let magnitude = squaredLength(a);\r\n if (magnitude > 0) {\r\n magnitude = Math.sqrt(magnitude);\r\n out[0] = a[0] / magnitude;\r\n out[1] = a[1] / magnitude;\r\n out[2] = a[2] / magnitude;\r\n out[3] = a[3] / magnitude;\r\n out[4] = a[4] / magnitude;\r\n out[5] = a[5] / magnitude;\r\n out[6] = a[6] / magnitude;\r\n out[7] = a[7] / magnitude;\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a dual quatenion\r\n *\r\n * @param {quat2} a dual quaternion to represent as a string\r\n * @returns {String} string representation of the dual quat\r\n */\r\nexport function str(a) {\r\n return 'quat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' +\r\n a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ')';\r\n}\r\n\r\n/**\r\n * Returns whether or not the dual quaternions have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {quat2} a the first dual quaternion.\r\n * @param {quat2} b the second dual quaternion.\r\n * @returns {Boolean} true if the dual quaternions are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] &&\r\n a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7];\r\n}\r\n\r\n/**\r\n * Returns whether or not the dual quaternions have approximately the same elements in the same position.\r\n *\r\n * @param {quat2} a the first dual quat.\r\n * @param {quat2} b the second dual quat.\r\n * @returns {Boolean} true if the dual quats are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0],\r\n a1 = a[1],\r\n a2 = a[2],\r\n a3 = a[3],\r\n a4 = a[4],\r\n a5 = a[5],\r\n a6 = a[6],\r\n a7 = a[7];\r\n let b0 = b[0],\r\n b1 = b[1],\r\n b2 = b[2],\r\n b3 = b[3],\r\n b4 = b[4],\r\n b5 = b[5],\r\n b6 = b[6],\r\n b7 = b[7];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&\r\n Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&\r\n Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&\r\n Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&\r\n Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)));\r\n}\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * 2 Dimensional Vector\r\n * @module vec2\r\n */\r\n\r\n/**\r\n * Creates a new, empty vec2\r\n *\r\n * @returns {vec2} a new 2D vector\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(2);\r\n out[0] = 0;\r\n out[1] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new vec2 initialized with values from an existing vector\r\n *\r\n * @param {vec2} a vector to clone\r\n * @returns {vec2} a new 2D vector\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(2);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new vec2 initialized with the given values\r\n *\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @returns {vec2} a new 2D vector\r\n */\r\nexport function fromValues(x, y) {\r\n let out = new glMatrix.ARRAY_TYPE(2);\r\n out[0] = x;\r\n out[1] = y;\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one vec2 to another\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the source vector\r\n * @returns {vec2} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a vec2 to the given values\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @returns {vec2} out\r\n */\r\nexport function set(out, x, y) {\r\n out[0] = x;\r\n out[1] = y;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts vector b from vector a\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiplies two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function multiply(out, a, b) {\r\n out[0] = a[0] * b[0];\r\n out[1] = a[1] * b[1];\r\n return out;\r\n};\r\n\r\n/**\r\n * Divides two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function divide(out, a, b) {\r\n out[0] = a[0] / b[0];\r\n out[1] = a[1] / b[1];\r\n return out;\r\n};\r\n\r\n/**\r\n * Math.ceil the components of a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to ceil\r\n * @returns {vec2} out\r\n */\r\nexport function ceil(out, a) {\r\n out[0] = Math.ceil(a[0]);\r\n out[1] = Math.ceil(a[1]);\r\n return out;\r\n};\r\n\r\n/**\r\n * Math.floor the components of a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to floor\r\n * @returns {vec2} out\r\n */\r\nexport function floor(out, a) {\r\n out[0] = Math.floor(a[0]);\r\n out[1] = Math.floor(a[1]);\r\n return out;\r\n};\r\n\r\n/**\r\n * Returns the minimum of two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function min(out, a, b) {\r\n out[0] = Math.min(a[0], b[0]);\r\n out[1] = Math.min(a[1], b[1]);\r\n return out;\r\n};\r\n\r\n/**\r\n * Returns the maximum of two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec2} out\r\n */\r\nexport function max(out, a, b) {\r\n out[0] = Math.max(a[0], b[0]);\r\n out[1] = Math.max(a[1], b[1]);\r\n return out;\r\n};\r\n\r\n/**\r\n * Math.round the components of a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to round\r\n * @returns {vec2} out\r\n */\r\nexport function round (out, a) {\r\n out[0] = Math.round(a[0]);\r\n out[1] = Math.round(a[1]);\r\n return out;\r\n};\r\n\r\n/**\r\n * Scales a vec2 by a scalar number\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the vector to scale\r\n * @param {Number} b amount to scale the vector by\r\n * @returns {vec2} out\r\n */\r\nexport function scale(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n return out;\r\n};\r\n\r\n/**\r\n * Adds two vec2's after scaling the second operand by a scalar value\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @param {Number} scale the amount to scale b by before adding\r\n * @returns {vec2} out\r\n */\r\nexport function scaleAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n return out;\r\n};\r\n\r\n/**\r\n * Calculates the euclidian distance between two vec2's\r\n *\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {Number} distance between a and b\r\n */\r\nexport function distance(a, b) {\r\n var x = b[0] - a[0],\r\n y = b[1] - a[1];\r\n return Math.sqrt(x*x + y*y);\r\n};\r\n\r\n/**\r\n * Calculates the squared euclidian distance between two vec2's\r\n *\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {Number} squared distance between a and b\r\n */\r\nexport function squaredDistance(a, b) {\r\n var x = b[0] - a[0],\r\n y = b[1] - a[1];\r\n return x*x + y*y;\r\n};\r\n\r\n/**\r\n * Calculates the length of a vec2\r\n *\r\n * @param {vec2} a vector to calculate length of\r\n * @returns {Number} length of a\r\n */\r\nexport function length(a) {\r\n var x = a[0],\r\n y = a[1];\r\n return Math.sqrt(x*x + y*y);\r\n};\r\n\r\n/**\r\n * Calculates the squared length of a vec2\r\n *\r\n * @param {vec2} a vector to calculate squared length of\r\n * @returns {Number} squared length of a\r\n */\r\nexport function squaredLength (a) {\r\n var x = a[0],\r\n y = a[1];\r\n return x*x + y*y;\r\n};\r\n\r\n/**\r\n * Negates the components of a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to negate\r\n * @returns {vec2} out\r\n */\r\nexport function negate(out, a) {\r\n out[0] = -a[0];\r\n out[1] = -a[1];\r\n return out;\r\n};\r\n\r\n/**\r\n * Returns the inverse of the components of a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to invert\r\n * @returns {vec2} out\r\n */\r\nexport function inverse(out, a) {\r\n out[0] = 1.0 / a[0];\r\n out[1] = 1.0 / a[1];\r\n return out;\r\n};\r\n\r\n/**\r\n * Normalize a vec2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a vector to normalize\r\n * @returns {vec2} out\r\n */\r\nexport function normalize(out, a) {\r\n var x = a[0],\r\n y = a[1];\r\n var len = x*x + y*y;\r\n if (len > 0) {\r\n //TODO: evaluate use of glm_invsqrt here?\r\n len = 1 / Math.sqrt(len);\r\n out[0] = a[0] * len;\r\n out[1] = a[1] * len;\r\n }\r\n return out;\r\n};\r\n\r\n/**\r\n * Calculates the dot product of two vec2's\r\n *\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {Number} dot product of a and b\r\n */\r\nexport function dot(a, b) {\r\n return a[0] * b[0] + a[1] * b[1];\r\n};\r\n\r\n/**\r\n * Computes the cross product of two vec2's\r\n * Note that the cross product must by definition produce a 3D vector\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function cross(out, a, b) {\r\n var z = a[0] * b[1] - a[1] * b[0];\r\n out[0] = out[1] = 0;\r\n out[2] = z;\r\n return out;\r\n};\r\n\r\n/**\r\n * Performs a linear interpolation between two vec2's\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the first operand\r\n * @param {vec2} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {vec2} out\r\n */\r\nexport function lerp(out, a, b, t) {\r\n var ax = a[0],\r\n ay = a[1];\r\n out[0] = ax + t * (b[0] - ax);\r\n out[1] = ay + t * (b[1] - ay);\r\n return out;\r\n};\r\n\r\n/**\r\n * Generates a random vector with the given scale\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\r\n * @returns {vec2} out\r\n */\r\nexport function random(out, scale) {\r\n scale = scale || 1.0;\r\n var r = glMatrix.RANDOM() * 2.0 * Math.PI;\r\n out[0] = Math.cos(r) * scale;\r\n out[1] = Math.sin(r) * scale;\r\n return out;\r\n};\r\n\r\n/**\r\n * Transforms the vec2 with a mat2\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the vector to transform\r\n * @param {mat2} m matrix to transform with\r\n * @returns {vec2} out\r\n */\r\nexport function transformMat2(out, a, m) {\r\n var x = a[0],\r\n y = a[1];\r\n out[0] = m[0] * x + m[2] * y;\r\n out[1] = m[1] * x + m[3] * y;\r\n return out;\r\n};\r\n\r\n/**\r\n * Transforms the vec2 with a mat2d\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the vector to transform\r\n * @param {mat2d} m matrix to transform with\r\n * @returns {vec2} out\r\n */\r\nexport function transformMat2d(out, a, m) {\r\n var x = a[0],\r\n y = a[1];\r\n out[0] = m[0] * x + m[2] * y + m[4];\r\n out[1] = m[1] * x + m[3] * y + m[5];\r\n return out;\r\n};\r\n\r\n/**\r\n * Transforms the vec2 with a mat3\r\n * 3rd vector component is implicitly '1'\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the vector to transform\r\n * @param {mat3} m matrix to transform with\r\n * @returns {vec2} out\r\n */\r\nexport function transformMat3(out, a, m) {\r\n var x = a[0],\r\n y = a[1];\r\n out[0] = m[0] * x + m[3] * y + m[6];\r\n out[1] = m[1] * x + m[4] * y + m[7];\r\n return out;\r\n};\r\n\r\n/**\r\n * Transforms the vec2 with a mat4\r\n * 3rd vector component is implicitly '0'\r\n * 4th vector component is implicitly '1'\r\n *\r\n * @param {vec2} out the receiving vector\r\n * @param {vec2} a the vector to transform\r\n * @param {mat4} m matrix to transform with\r\n * @returns {vec2} out\r\n */\r\nexport function transformMat4(out, a, m) {\r\n let x = a[0];\r\n let y = a[1];\r\n out[0] = m[0] * x + m[4] * y + m[12];\r\n out[1] = m[1] * x + m[5] * y + m[13];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a vector\r\n *\r\n * @param {vec2} a vector to represent as a string\r\n * @returns {String} string representation of the vector\r\n */\r\nexport function str(a) {\r\n return 'vec2(' + a[0] + ', ' + a[1] + ')';\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)\r\n *\r\n * @param {vec2} a The first vector.\r\n * @param {vec2} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1];\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors have approximately the same elements in the same position.\r\n *\r\n * @param {vec2} a The first vector.\r\n * @param {vec2} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1];\r\n let b0 = b[0], b1 = b[1];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)));\r\n}\r\n\r\n/**\r\n * Alias for {@link vec2.length}\r\n * @function\r\n */\r\nexport const len = length;\r\n\r\n/**\r\n * Alias for {@link vec2.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n\r\n/**\r\n * Alias for {@link vec2.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link vec2.divide}\r\n * @function\r\n */\r\nexport const div = divide;\r\n\r\n/**\r\n * Alias for {@link vec2.distance}\r\n * @function\r\n */\r\nexport const dist = distance;\r\n\r\n/**\r\n * Alias for {@link vec2.squaredDistance}\r\n * @function\r\n */\r\nexport const sqrDist = squaredDistance;\r\n\r\n/**\r\n * Alias for {@link vec2.squaredLength}\r\n * @function\r\n */\r\nexport const sqrLen = squaredLength;\r\n\r\n/**\r\n * Perform some operation over an array of vec2s.\r\n *\r\n * @param {Array} a the array of vectors to iterate over\r\n * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed\r\n * @param {Number} offset Number of elements to skip at the beginning of the array\r\n * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array\r\n * @param {Function} fn Function to call for each vector in the array\r\n * @param {Object} [arg] additional argument to pass to fn\r\n * @returns {Array} a\r\n * @function\r\n */\r\nexport const forEach = (function() {\r\n let vec = create();\r\n\r\n return function(a, stride, offset, count, fn, arg) {\r\n let i, l;\r\n if(!stride) {\r\n stride = 2;\r\n }\r\n\r\n if(!offset) {\r\n offset = 0;\r\n }\r\n\r\n if(count) {\r\n l = Math.min((count * stride) + offset, a.length);\r\n } else {\r\n l = a.length;\r\n }\r\n\r\n for(i = offset; i < l; i += stride) {\r\n vec[0] = a[i]; vec[1] = a[i+1];\r\n fn(vec, vec, arg);\r\n a[i] = vec[0]; a[i+1] = vec[1];\r\n }\r\n\r\n return a;\r\n };\r\n})();\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * 3 Dimensional Vector\r\n * @module vec3\r\n */\r\n\r\n/**\r\n * Creates a new, empty vec3\r\n *\r\n * @returns {vec3} a new 3D vector\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(3);\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new vec3 initialized with values from an existing vector\r\n *\r\n * @param {vec3} a vector to clone\r\n * @returns {vec3} a new 3D vector\r\n */\r\nexport function clone(a) {\r\n var out = new glMatrix.ARRAY_TYPE(3);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the length of a vec3\r\n *\r\n * @param {vec3} a vector to calculate length of\r\n * @returns {Number} length of a\r\n */\r\nexport function length(a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n return Math.sqrt(x*x + y*y + z*z);\r\n}\r\n\r\n/**\r\n * Creates a new vec3 initialized with the given values\r\n *\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @returns {vec3} a new 3D vector\r\n */\r\nexport function fromValues(x, y, z) {\r\n let out = new glMatrix.ARRAY_TYPE(3);\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one vec3 to another\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the source vector\r\n * @returns {vec3} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a vec3 to the given values\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @returns {vec3} out\r\n */\r\nexport function set(out, x, y, z) {\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts vector b from vector a\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiplies two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function multiply(out, a, b) {\r\n out[0] = a[0] * b[0];\r\n out[1] = a[1] * b[1];\r\n out[2] = a[2] * b[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Divides two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function divide(out, a, b) {\r\n out[0] = a[0] / b[0];\r\n out[1] = a[1] / b[1];\r\n out[2] = a[2] / b[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.ceil the components of a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to ceil\r\n * @returns {vec3} out\r\n */\r\nexport function ceil(out, a) {\r\n out[0] = Math.ceil(a[0]);\r\n out[1] = Math.ceil(a[1]);\r\n out[2] = Math.ceil(a[2]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.floor the components of a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to floor\r\n * @returns {vec3} out\r\n */\r\nexport function floor(out, a) {\r\n out[0] = Math.floor(a[0]);\r\n out[1] = Math.floor(a[1]);\r\n out[2] = Math.floor(a[2]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the minimum of two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function min(out, a, b) {\r\n out[0] = Math.min(a[0], b[0]);\r\n out[1] = Math.min(a[1], b[1]);\r\n out[2] = Math.min(a[2], b[2]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the maximum of two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function max(out, a, b) {\r\n out[0] = Math.max(a[0], b[0]);\r\n out[1] = Math.max(a[1], b[1]);\r\n out[2] = Math.max(a[2], b[2]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.round the components of a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to round\r\n * @returns {vec3} out\r\n */\r\nexport function round(out, a) {\r\n out[0] = Math.round(a[0]);\r\n out[1] = Math.round(a[1]);\r\n out[2] = Math.round(a[2]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Scales a vec3 by a scalar number\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the vector to scale\r\n * @param {Number} b amount to scale the vector by\r\n * @returns {vec3} out\r\n */\r\nexport function scale(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two vec3's after scaling the second operand by a scalar value\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @param {Number} scale the amount to scale b by before adding\r\n * @returns {vec3} out\r\n */\r\nexport function scaleAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the euclidian distance between two vec3's\r\n *\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {Number} distance between a and b\r\n */\r\nexport function distance(a, b) {\r\n let x = b[0] - a[0];\r\n let y = b[1] - a[1];\r\n let z = b[2] - a[2];\r\n return Math.sqrt(x*x + y*y + z*z);\r\n}\r\n\r\n/**\r\n * Calculates the squared euclidian distance between two vec3's\r\n *\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {Number} squared distance between a and b\r\n */\r\nexport function squaredDistance(a, b) {\r\n let x = b[0] - a[0];\r\n let y = b[1] - a[1];\r\n let z = b[2] - a[2];\r\n return x*x + y*y + z*z;\r\n}\r\n\r\n/**\r\n * Calculates the squared length of a vec3\r\n *\r\n * @param {vec3} a vector to calculate squared length of\r\n * @returns {Number} squared length of a\r\n */\r\nexport function squaredLength(a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n return x*x + y*y + z*z;\r\n}\r\n\r\n/**\r\n * Negates the components of a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to negate\r\n * @returns {vec3} out\r\n */\r\nexport function negate(out, a) {\r\n out[0] = -a[0];\r\n out[1] = -a[1];\r\n out[2] = -a[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the inverse of the components of a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to invert\r\n * @returns {vec3} out\r\n */\r\nexport function inverse(out, a) {\r\n out[0] = 1.0 / a[0];\r\n out[1] = 1.0 / a[1];\r\n out[2] = 1.0 / a[2];\r\n return out;\r\n}\r\n\r\n/**\r\n * Normalize a vec3\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a vector to normalize\r\n * @returns {vec3} out\r\n */\r\nexport function normalize(out, a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n let len = x*x + y*y + z*z;\r\n if (len > 0) {\r\n //TODO: evaluate use of glm_invsqrt here?\r\n len = 1 / Math.sqrt(len);\r\n out[0] = a[0] * len;\r\n out[1] = a[1] * len;\r\n out[2] = a[2] * len;\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the dot product of two vec3's\r\n *\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {Number} dot product of a and b\r\n */\r\nexport function dot(a, b) {\r\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\r\n}\r\n\r\n/**\r\n * Computes the cross product of two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @returns {vec3} out\r\n */\r\nexport function cross(out, a, b) {\r\n let ax = a[0], ay = a[1], az = a[2];\r\n let bx = b[0], by = b[1], bz = b[2];\r\n\r\n out[0] = ay * bz - az * by;\r\n out[1] = az * bx - ax * bz;\r\n out[2] = ax * by - ay * bx;\r\n return out;\r\n}\r\n\r\n/**\r\n * Performs a linear interpolation between two vec3's\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {vec3} out\r\n */\r\nexport function lerp(out, a, b, t) {\r\n let ax = a[0];\r\n let ay = a[1];\r\n let az = a[2];\r\n out[0] = ax + t * (b[0] - ax);\r\n out[1] = ay + t * (b[1] - ay);\r\n out[2] = az + t * (b[2] - az);\r\n return out;\r\n}\r\n\r\n/**\r\n * Performs a hermite interpolation with two control points\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @param {vec3} c the third operand\r\n * @param {vec3} d the fourth operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {vec3} out\r\n */\r\nexport function hermite(out, a, b, c, d, t) {\r\n let factorTimes2 = t * t;\r\n let factor1 = factorTimes2 * (2 * t - 3) + 1;\r\n let factor2 = factorTimes2 * (t - 2) + t;\r\n let factor3 = factorTimes2 * (t - 1);\r\n let factor4 = factorTimes2 * (3 - 2 * t);\r\n\r\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\r\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\r\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Performs a bezier interpolation with two control points\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the first operand\r\n * @param {vec3} b the second operand\r\n * @param {vec3} c the third operand\r\n * @param {vec3} d the fourth operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {vec3} out\r\n */\r\nexport function bezier(out, a, b, c, d, t) {\r\n let inverseFactor = 1 - t;\r\n let inverseFactorTimesTwo = inverseFactor * inverseFactor;\r\n let factorTimes2 = t * t;\r\n let factor1 = inverseFactorTimesTwo * inverseFactor;\r\n let factor2 = 3 * t * inverseFactorTimesTwo;\r\n let factor3 = 3 * factorTimes2 * inverseFactor;\r\n let factor4 = factorTimes2 * t;\r\n\r\n out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;\r\n out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;\r\n out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a random vector with the given scale\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\r\n * @returns {vec3} out\r\n */\r\nexport function random(out, scale) {\r\n scale = scale || 1.0;\r\n\r\n let r = glMatrix.RANDOM() * 2.0 * Math.PI;\r\n let z = (glMatrix.RANDOM() * 2.0) - 1.0;\r\n let zScale = Math.sqrt(1.0-z*z) * scale;\r\n\r\n out[0] = Math.cos(r) * zScale;\r\n out[1] = Math.sin(r) * zScale;\r\n out[2] = z * scale;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transforms the vec3 with a mat4.\r\n * 4th vector component is implicitly '1'\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the vector to transform\r\n * @param {mat4} m matrix to transform with\r\n * @returns {vec3} out\r\n */\r\nexport function transformMat4(out, a, m) {\r\n let x = a[0], y = a[1], z = a[2];\r\n let w = m[3] * x + m[7] * y + m[11] * z + m[15];\r\n w = w || 1.0;\r\n out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;\r\n out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;\r\n out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transforms the vec3 with a mat3.\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the vector to transform\r\n * @param {mat3} m the 3x3 matrix to transform with\r\n * @returns {vec3} out\r\n */\r\nexport function transformMat3(out, a, m) {\r\n let x = a[0], y = a[1], z = a[2];\r\n out[0] = x * m[0] + y * m[3] + z * m[6];\r\n out[1] = x * m[1] + y * m[4] + z * m[7];\r\n out[2] = x * m[2] + y * m[5] + z * m[8];\r\n return out;\r\n}\r\n\r\n/**\r\n * Transforms the vec3 with a quat\r\n * Can also be used for dual quaternions. (Multiply it with the real part)\r\n *\r\n * @param {vec3} out the receiving vector\r\n * @param {vec3} a the vector to transform\r\n * @param {quat} q quaternion to transform with\r\n * @returns {vec3} out\r\n */\r\nexport function transformQuat(out, a, q) {\r\n // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed\r\n let qx = q[0], qy = q[1], qz = q[2], qw = q[3];\r\n let x = a[0], y = a[1], z = a[2];\r\n // var qvec = [qx, qy, qz];\r\n // var uv = vec3.cross([], qvec, a);\r\n let uvx = qy * z - qz * y,\r\n uvy = qz * x - qx * z,\r\n uvz = qx * y - qy * x;\r\n // var uuv = vec3.cross([], qvec, uv);\r\n let uuvx = qy * uvz - qz * uvy,\r\n uuvy = qz * uvx - qx * uvz,\r\n uuvz = qx * uvy - qy * uvx;\r\n // vec3.scale(uv, uv, 2 * w);\r\n let w2 = qw * 2;\r\n uvx *= w2;\r\n uvy *= w2;\r\n uvz *= w2;\r\n // vec3.scale(uuv, uuv, 2);\r\n uuvx *= 2;\r\n uuvy *= 2;\r\n uuvz *= 2;\r\n // return vec3.add(out, a, vec3.add(out, uv, uuv));\r\n out[0] = x + uvx + uuvx;\r\n out[1] = y + uvy + uuvy;\r\n out[2] = z + uvz + uuvz;\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotate a 3D vector around the x-axis\r\n * @param {vec3} out The receiving vec3\r\n * @param {vec3} a The vec3 point to rotate\r\n * @param {vec3} b The origin of the rotation\r\n * @param {Number} c The angle of rotation\r\n * @returns {vec3} out\r\n */\r\nexport function rotateX(out, a, b, c){\r\n let p = [], r=[];\r\n //Translate point to the origin\r\n p[0] = a[0] - b[0];\r\n p[1] = a[1] - b[1];\r\n p[2] = a[2] - b[2];\r\n\r\n //perform rotation\r\n r[0] = p[0];\r\n r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c);\r\n r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c);\r\n\r\n //translate to correct position\r\n out[0] = r[0] + b[0];\r\n out[1] = r[1] + b[1];\r\n out[2] = r[2] + b[2];\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotate a 3D vector around the y-axis\r\n * @param {vec3} out The receiving vec3\r\n * @param {vec3} a The vec3 point to rotate\r\n * @param {vec3} b The origin of the rotation\r\n * @param {Number} c The angle of rotation\r\n * @returns {vec3} out\r\n */\r\nexport function rotateY(out, a, b, c){\r\n let p = [], r=[];\r\n //Translate point to the origin\r\n p[0] = a[0] - b[0];\r\n p[1] = a[1] - b[1];\r\n p[2] = a[2] - b[2];\r\n\r\n //perform rotation\r\n r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c);\r\n r[1] = p[1];\r\n r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c);\r\n\r\n //translate to correct position\r\n out[0] = r[0] + b[0];\r\n out[1] = r[1] + b[1];\r\n out[2] = r[2] + b[2];\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Rotate a 3D vector around the z-axis\r\n * @param {vec3} out The receiving vec3\r\n * @param {vec3} a The vec3 point to rotate\r\n * @param {vec3} b The origin of the rotation\r\n * @param {Number} c The angle of rotation\r\n * @returns {vec3} out\r\n */\r\nexport function rotateZ(out, a, b, c){\r\n let p = [], r=[];\r\n //Translate point to the origin\r\n p[0] = a[0] - b[0];\r\n p[1] = a[1] - b[1];\r\n p[2] = a[2] - b[2];\r\n\r\n //perform rotation\r\n r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c);\r\n r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c);\r\n r[2] = p[2];\r\n\r\n //translate to correct position\r\n out[0] = r[0] + b[0];\r\n out[1] = r[1] + b[1];\r\n out[2] = r[2] + b[2];\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Get the angle between two 3D vectors\r\n * @param {vec3} a The first operand\r\n * @param {vec3} b The second operand\r\n * @returns {Number} The angle in radians\r\n */\r\nexport function angle(a, b) {\r\n let tempA = fromValues(a[0], a[1], a[2]);\r\n let tempB = fromValues(b[0], b[1], b[2]);\r\n\r\n normalize(tempA, tempA);\r\n normalize(tempB, tempB);\r\n\r\n let cosine = dot(tempA, tempB);\r\n\r\n if(cosine > 1.0) {\r\n return 0;\r\n }\r\n else if(cosine < -1.0) {\r\n return Math.PI;\r\n } else {\r\n return Math.acos(cosine);\r\n }\r\n}\r\n\r\n/**\r\n * Returns a string representation of a vector\r\n *\r\n * @param {vec3} a vector to represent as a string\r\n * @returns {String} string representation of the vector\r\n */\r\nexport function str(a) {\r\n return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {vec3} a The first vector.\r\n * @param {vec3} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors have approximately the same elements in the same position.\r\n *\r\n * @param {vec3} a The first vector.\r\n * @param {vec3} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2];\r\n let b0 = b[0], b1 = b[1], b2 = b[2];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)));\r\n}\r\n\r\n/**\r\n * Alias for {@link vec3.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n\r\n/**\r\n * Alias for {@link vec3.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link vec3.divide}\r\n * @function\r\n */\r\nexport const div = divide;\r\n\r\n/**\r\n * Alias for {@link vec3.distance}\r\n * @function\r\n */\r\nexport const dist = distance;\r\n\r\n/**\r\n * Alias for {@link vec3.squaredDistance}\r\n * @function\r\n */\r\nexport const sqrDist = squaredDistance;\r\n\r\n/**\r\n * Alias for {@link vec3.length}\r\n * @function\r\n */\r\nexport const len = length;\r\n\r\n/**\r\n * Alias for {@link vec3.squaredLength}\r\n * @function\r\n */\r\nexport const sqrLen = squaredLength;\r\n\r\n/**\r\n * Perform some operation over an array of vec3s.\r\n *\r\n * @param {Array} a the array of vectors to iterate over\r\n * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed\r\n * @param {Number} offset Number of elements to skip at the beginning of the array\r\n * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array\r\n * @param {Function} fn Function to call for each vector in the array\r\n * @param {Object} [arg] additional argument to pass to fn\r\n * @returns {Array} a\r\n * @function\r\n */\r\nexport const forEach = (function() {\r\n let vec = create();\r\n\r\n return function(a, stride, offset, count, fn, arg) {\r\n let i, l;\r\n if(!stride) {\r\n stride = 3;\r\n }\r\n\r\n if(!offset) {\r\n offset = 0;\r\n }\r\n\r\n if(count) {\r\n l = Math.min((count * stride) + offset, a.length);\r\n } else {\r\n l = a.length;\r\n }\r\n\r\n for(i = offset; i < l; i += stride) {\r\n vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2];\r\n fn(vec, vec, arg);\r\n a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2];\r\n }\r\n\r\n return a;\r\n };\r\n})();\r\n","/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE. */\r\n\r\nimport * as glMatrix from \"./common.js\";\r\n\r\n/**\r\n * 4 Dimensional Vector\r\n * @module vec4\r\n */\r\n\r\n/**\r\n * Creates a new, empty vec4\r\n *\r\n * @returns {vec4} a new 4D vector\r\n */\r\nexport function create() {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = 0;\r\n out[1] = 0;\r\n out[2] = 0;\r\n out[3] = 0;\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new vec4 initialized with values from an existing vector\r\n *\r\n * @param {vec4} a vector to clone\r\n * @returns {vec4} a new 4D vector\r\n */\r\nexport function clone(a) {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Creates a new vec4 initialized with the given values\r\n *\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @param {Number} w W component\r\n * @returns {vec4} a new 4D vector\r\n */\r\nexport function fromValues(x, y, z, w) {\r\n let out = new glMatrix.ARRAY_TYPE(4);\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n out[3] = w;\r\n return out;\r\n}\r\n\r\n/**\r\n * Copy the values from one vec4 to another\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the source vector\r\n * @returns {vec4} out\r\n */\r\nexport function copy(out, a) {\r\n out[0] = a[0];\r\n out[1] = a[1];\r\n out[2] = a[2];\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Set the components of a vec4 to the given values\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {Number} x X component\r\n * @param {Number} y Y component\r\n * @param {Number} z Z component\r\n * @param {Number} w W component\r\n * @returns {vec4} out\r\n */\r\nexport function set(out, x, y, z, w) {\r\n out[0] = x;\r\n out[1] = y;\r\n out[2] = z;\r\n out[3] = w;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function add(out, a, b) {\r\n out[0] = a[0] + b[0];\r\n out[1] = a[1] + b[1];\r\n out[2] = a[2] + b[2];\r\n out[3] = a[3] + b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Subtracts vector b from vector a\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function subtract(out, a, b) {\r\n out[0] = a[0] - b[0];\r\n out[1] = a[1] - b[1];\r\n out[2] = a[2] - b[2];\r\n out[3] = a[3] - b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Multiplies two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function multiply(out, a, b) {\r\n out[0] = a[0] * b[0];\r\n out[1] = a[1] * b[1];\r\n out[2] = a[2] * b[2];\r\n out[3] = a[3] * b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Divides two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function divide(out, a, b) {\r\n out[0] = a[0] / b[0];\r\n out[1] = a[1] / b[1];\r\n out[2] = a[2] / b[2];\r\n out[3] = a[3] / b[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.ceil the components of a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to ceil\r\n * @returns {vec4} out\r\n */\r\nexport function ceil(out, a) {\r\n out[0] = Math.ceil(a[0]);\r\n out[1] = Math.ceil(a[1]);\r\n out[2] = Math.ceil(a[2]);\r\n out[3] = Math.ceil(a[3]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.floor the components of a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to floor\r\n * @returns {vec4} out\r\n */\r\nexport function floor(out, a) {\r\n out[0] = Math.floor(a[0]);\r\n out[1] = Math.floor(a[1]);\r\n out[2] = Math.floor(a[2]);\r\n out[3] = Math.floor(a[3]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the minimum of two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function min(out, a, b) {\r\n out[0] = Math.min(a[0], b[0]);\r\n out[1] = Math.min(a[1], b[1]);\r\n out[2] = Math.min(a[2], b[2]);\r\n out[3] = Math.min(a[3], b[3]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the maximum of two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {vec4} out\r\n */\r\nexport function max(out, a, b) {\r\n out[0] = Math.max(a[0], b[0]);\r\n out[1] = Math.max(a[1], b[1]);\r\n out[2] = Math.max(a[2], b[2]);\r\n out[3] = Math.max(a[3], b[3]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Math.round the components of a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to round\r\n * @returns {vec4} out\r\n */\r\nexport function round(out, a) {\r\n out[0] = Math.round(a[0]);\r\n out[1] = Math.round(a[1]);\r\n out[2] = Math.round(a[2]);\r\n out[3] = Math.round(a[3]);\r\n return out;\r\n}\r\n\r\n/**\r\n * Scales a vec4 by a scalar number\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the vector to scale\r\n * @param {Number} b amount to scale the vector by\r\n * @returns {vec4} out\r\n */\r\nexport function scale(out, a, b) {\r\n out[0] = a[0] * b;\r\n out[1] = a[1] * b;\r\n out[2] = a[2] * b;\r\n out[3] = a[3] * b;\r\n return out;\r\n}\r\n\r\n/**\r\n * Adds two vec4's after scaling the second operand by a scalar value\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @param {Number} scale the amount to scale b by before adding\r\n * @returns {vec4} out\r\n */\r\nexport function scaleAndAdd(out, a, b, scale) {\r\n out[0] = a[0] + (b[0] * scale);\r\n out[1] = a[1] + (b[1] * scale);\r\n out[2] = a[2] + (b[2] * scale);\r\n out[3] = a[3] + (b[3] * scale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the euclidian distance between two vec4's\r\n *\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {Number} distance between a and b\r\n */\r\nexport function distance(a, b) {\r\n let x = b[0] - a[0];\r\n let y = b[1] - a[1];\r\n let z = b[2] - a[2];\r\n let w = b[3] - a[3];\r\n return Math.sqrt(x*x + y*y + z*z + w*w);\r\n}\r\n\r\n/**\r\n * Calculates the squared euclidian distance between two vec4's\r\n *\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {Number} squared distance between a and b\r\n */\r\nexport function squaredDistance(a, b) {\r\n let x = b[0] - a[0];\r\n let y = b[1] - a[1];\r\n let z = b[2] - a[2];\r\n let w = b[3] - a[3];\r\n return x*x + y*y + z*z + w*w;\r\n}\r\n\r\n/**\r\n * Calculates the length of a vec4\r\n *\r\n * @param {vec4} a vector to calculate length of\r\n * @returns {Number} length of a\r\n */\r\nexport function length(a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n let w = a[3];\r\n return Math.sqrt(x*x + y*y + z*z + w*w);\r\n}\r\n\r\n/**\r\n * Calculates the squared length of a vec4\r\n *\r\n * @param {vec4} a vector to calculate squared length of\r\n * @returns {Number} squared length of a\r\n */\r\nexport function squaredLength(a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n let w = a[3];\r\n return x*x + y*y + z*z + w*w;\r\n}\r\n\r\n/**\r\n * Negates the components of a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to negate\r\n * @returns {vec4} out\r\n */\r\nexport function negate(out, a) {\r\n out[0] = -a[0];\r\n out[1] = -a[1];\r\n out[2] = -a[2];\r\n out[3] = -a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns the inverse of the components of a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to invert\r\n * @returns {vec4} out\r\n */\r\nexport function inverse(out, a) {\r\n out[0] = 1.0 / a[0];\r\n out[1] = 1.0 / a[1];\r\n out[2] = 1.0 / a[2];\r\n out[3] = 1.0 / a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Normalize a vec4\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a vector to normalize\r\n * @returns {vec4} out\r\n */\r\nexport function normalize(out, a) {\r\n let x = a[0];\r\n let y = a[1];\r\n let z = a[2];\r\n let w = a[3];\r\n let len = x*x + y*y + z*z + w*w;\r\n if (len > 0) {\r\n len = 1 / Math.sqrt(len);\r\n out[0] = x * len;\r\n out[1] = y * len;\r\n out[2] = z * len;\r\n out[3] = w * len;\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Calculates the dot product of two vec4's\r\n *\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @returns {Number} dot product of a and b\r\n */\r\nexport function dot(a, b) {\r\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];\r\n}\r\n\r\n/**\r\n * Performs a linear interpolation between two vec4's\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the first operand\r\n * @param {vec4} b the second operand\r\n * @param {Number} t interpolation amount between the two inputs\r\n * @returns {vec4} out\r\n */\r\nexport function lerp(out, a, b, t) {\r\n let ax = a[0];\r\n let ay = a[1];\r\n let az = a[2];\r\n let aw = a[3];\r\n out[0] = ax + t * (b[0] - ax);\r\n out[1] = ay + t * (b[1] - ay);\r\n out[2] = az + t * (b[2] - az);\r\n out[3] = aw + t * (b[3] - aw);\r\n return out;\r\n}\r\n\r\n/**\r\n * Generates a random vector with the given scale\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned\r\n * @returns {vec4} out\r\n */\r\nexport function random(out, vectorScale) {\r\n vectorScale = vectorScale || 1.0;\r\n\r\n //TODO: This is a pretty awful way of doing this. Find something better.\r\n out[0] = glMatrix.RANDOM();\r\n out[1] = glMatrix.RANDOM();\r\n out[2] = glMatrix.RANDOM();\r\n out[3] = glMatrix.RANDOM();\r\n normalize(out, out);\r\n scale(out, out, vectorScale);\r\n return out;\r\n}\r\n\r\n/**\r\n * Transforms the vec4 with a mat4.\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the vector to transform\r\n * @param {mat4} m matrix to transform with\r\n * @returns {vec4} out\r\n */\r\nexport function transformMat4(out, a, m) {\r\n let x = a[0], y = a[1], z = a[2], w = a[3];\r\n out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;\r\n out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;\r\n out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;\r\n out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;\r\n return out;\r\n}\r\n\r\n/**\r\n * Transforms the vec4 with a quat\r\n *\r\n * @param {vec4} out the receiving vector\r\n * @param {vec4} a the vector to transform\r\n * @param {quat} q quaternion to transform with\r\n * @returns {vec4} out\r\n */\r\nexport function transformQuat(out, a, q) {\r\n let x = a[0], y = a[1], z = a[2];\r\n let qx = q[0], qy = q[1], qz = q[2], qw = q[3];\r\n\r\n // calculate quat * vec\r\n let ix = qw * x + qy * z - qz * y;\r\n let iy = qw * y + qz * x - qx * z;\r\n let iz = qw * z + qx * y - qy * x;\r\n let iw = -qx * x - qy * y - qz * z;\r\n\r\n // calculate result * inverse quat\r\n out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;\r\n out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;\r\n out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;\r\n out[3] = a[3];\r\n return out;\r\n}\r\n\r\n/**\r\n * Returns a string representation of a vector\r\n *\r\n * @param {vec4} a vector to represent as a string\r\n * @returns {String} string representation of the vector\r\n */\r\nexport function str(a) {\r\n return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)\r\n *\r\n * @param {vec4} a The first vector.\r\n * @param {vec4} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function exactEquals(a, b) {\r\n return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];\r\n}\r\n\r\n/**\r\n * Returns whether or not the vectors have approximately the same elements in the same position.\r\n *\r\n * @param {vec4} a The first vector.\r\n * @param {vec4} b The second vector.\r\n * @returns {Boolean} True if the vectors are equal, false otherwise.\r\n */\r\nexport function equals(a, b) {\r\n let a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];\r\n let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];\r\n return (Math.abs(a0 - b0) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&\r\n Math.abs(a1 - b1) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&\r\n Math.abs(a2 - b2) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&\r\n Math.abs(a3 - b3) <= glMatrix.EPSILON*Math.max(1.0, Math.abs(a3), Math.abs(b3)));\r\n}\r\n\r\n/**\r\n * Alias for {@link vec4.subtract}\r\n * @function\r\n */\r\nexport const sub = subtract;\r\n\r\n/**\r\n * Alias for {@link vec4.multiply}\r\n * @function\r\n */\r\nexport const mul = multiply;\r\n\r\n/**\r\n * Alias for {@link vec4.divide}\r\n * @function\r\n */\r\nexport const div = divide;\r\n\r\n/**\r\n * Alias for {@link vec4.distance}\r\n * @function\r\n */\r\nexport const dist = distance;\r\n\r\n/**\r\n * Alias for {@link vec4.squaredDistance}\r\n * @function\r\n */\r\nexport const sqrDist = squaredDistance;\r\n\r\n/**\r\n * Alias for {@link vec4.length}\r\n * @function\r\n */\r\nexport const len = length;\r\n\r\n/**\r\n * Alias for {@link vec4.squaredLength}\r\n * @function\r\n */\r\nexport const sqrLen = squaredLength;\r\n\r\n/**\r\n * Perform some operation over an array of vec4s.\r\n *\r\n * @param {Array} a the array of vectors to iterate over\r\n * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed\r\n * @param {Number} offset Number of elements to skip at the beginning of the array\r\n * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array\r\n * @param {Function} fn Function to call for each vector in the array\r\n * @param {Object} [arg] additional argument to pass to fn\r\n * @returns {Array} a\r\n * @function\r\n */\r\nexport const forEach = (function() {\r\n let vec = create();\r\n\r\n return function(a, stride, offset, count, fn, arg) {\r\n let i, l;\r\n if(!stride) {\r\n stride = 4;\r\n }\r\n\r\n if(!offset) {\r\n offset = 0;\r\n }\r\n\r\n if(count) {\r\n l = Math.min((count * stride) + offset, a.length);\r\n } else {\r\n l = a.length;\r\n }\r\n\r\n for(i = offset; i < l; i += stride) {\r\n vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3];\r\n fn(vec, vec, arg);\r\n a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3];\r\n }\r\n\r\n return a;\r\n };\r\n})();\r\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst GL = WebGLRenderingContext; // For enums\n\nexport const CAP = {\n // Enable caps\n CULL_FACE: 0x001,\n BLEND: 0x002,\n DEPTH_TEST: 0x004,\n STENCIL_TEST: 0x008,\n COLOR_MASK: 0x010,\n DEPTH_MASK: 0x020,\n STENCIL_MASK: 0x040,\n};\n\nexport const MAT_STATE = {\n CAPS_RANGE: 0x000000FF,\n BLEND_SRC_SHIFT: 8,\n BLEND_SRC_RANGE: 0x00000F00,\n BLEND_DST_SHIFT: 12,\n BLEND_DST_RANGE: 0x0000F000,\n BLEND_FUNC_RANGE: 0x0000FF00,\n DEPTH_FUNC_SHIFT: 16,\n DEPTH_FUNC_RANGE: 0x000F0000,\n};\n\nexport const RENDER_ORDER = {\n // Render opaque objects first.\n OPAQUE: 0,\n\n // Render the sky after all opaque object to save fill rate.\n SKY: 1,\n\n // Render transparent objects next so that the opaqe objects show through.\n TRANSPARENT: 2,\n\n // Finally render purely additive effects like pointer rays so that they\n // can render without depth mask.\n ADDITIVE: 3,\n\n // Render order will be picked based on the material properties.\n DEFAULT: 4,\n};\n\nexport function stateToBlendFunc(state, mask, shift) {\n let value = (state & mask) >> shift;\n switch (value) {\n case 0:\n case 1:\n return value;\n default:\n return (value - 2) + GL.SRC_COLOR;\n }\n}\n\nexport class MaterialState {\n constructor() {\n this._state = CAP.CULL_FACE |\n CAP.DEPTH_TEST |\n CAP.COLOR_MASK |\n CAP.DEPTH_MASK;\n\n // Use a fairly commonly desired blend func as the default.\n this.blendFuncSrc = GL.SRC_ALPHA;\n this.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA;\n\n this.depthFunc = GL.LESS;\n }\n\n get cullFace() {\n return !!(this._state & CAP.CULL_FACE);\n }\n set cullFace(value) {\n if (value) {\n this._state |= CAP.CULL_FACE;\n } else {\n this._state &= ~CAP.CULL_FACE;\n }\n }\n\n get blend() {\n return !!(this._state & CAP.BLEND);\n }\n set blend(value) {\n if (value) {\n this._state |= CAP.BLEND;\n } else {\n this._state &= ~CAP.BLEND;\n }\n }\n\n get depthTest() {\n return !!(this._state & CAP.DEPTH_TEST);\n }\n set depthTest(value) {\n if (value) {\n this._state |= CAP.DEPTH_TEST;\n } else {\n this._state &= ~CAP.DEPTH_TEST;\n }\n }\n\n get stencilTest() {\n return !!(this._state & CAP.STENCIL_TEST);\n }\n set stencilTest(value) {\n if (value) {\n this._state |= CAP.STENCIL_TEST;\n } else {\n this._state &= ~CAP.STENCIL_TEST;\n }\n }\n\n get colorMask() {\n return !!(this._state & CAP.COLOR_MASK);\n }\n set colorMask(value) {\n if (value) {\n this._state |= CAP.COLOR_MASK;\n } else {\n this._state &= ~CAP.COLOR_MASK;\n }\n }\n\n get depthMask() {\n return !!(this._state & CAP.DEPTH_MASK);\n }\n set depthMask(value) {\n if (value) {\n this._state |= CAP.DEPTH_MASK;\n } else {\n this._state &= ~CAP.DEPTH_MASK;\n }\n }\n\n get depthFunc() {\n return ((this._state & MAT_STATE.DEPTH_FUNC_RANGE) >> MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER;\n }\n set depthFunc(value) {\n value = value - GL.NEVER;\n this._state &= ~MAT_STATE.DEPTH_FUNC_RANGE;\n this._state |= (value << MAT_STATE.DEPTH_FUNC_SHIFT);\n }\n\n get stencilMask() {\n return !!(this._state & CAP.STENCIL_MASK);\n }\n set stencilMask(value) {\n if (value) {\n this._state |= CAP.STENCIL_MASK;\n } else {\n this._state &= ~CAP.STENCIL_MASK;\n }\n }\n\n get blendFuncSrc() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_SRC_RANGE, MAT_STATE.BLEND_SRC_SHIFT);\n }\n set blendFuncSrc(value) {\n switch (value) {\n case 0:\n case 1:\n break;\n default:\n value = (value - GL.SRC_COLOR) + 2;\n }\n this._state &= ~MAT_STATE.BLEND_SRC_RANGE;\n this._state |= (value << MAT_STATE.BLEND_SRC_SHIFT);\n }\n\n get blendFuncDst() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_DST_RANGE, MAT_STATE.BLEND_DST_SHIFT);\n }\n set blendFuncDst(value) {\n switch (value) {\n case 0:\n case 1:\n break;\n default:\n value = (value - GL.SRC_COLOR) + 2;\n }\n this._state &= ~MAT_STATE.BLEND_DST_RANGE;\n this._state |= (value << MAT_STATE.BLEND_DST_SHIFT);\n }\n}\n\nclass MaterialSampler {\n constructor(uniformName) {\n this._uniformName = uniformName;\n this._texture = null;\n }\n\n get texture() {\n return this._texture;\n }\n\n set texture(value) {\n this._texture = value;\n }\n}\n\nclass MaterialUniform {\n constructor(uniformName, defaultValue, length) {\n this._uniformName = uniformName;\n this._value = defaultValue;\n this._length = length;\n if (!this._length) {\n if (defaultValue instanceof Array) {\n this._length = defaultValue.length;\n } else {\n this._length = 1;\n }\n }\n }\n\n get value() {\n return this._value;\n }\n\n set value(value) {\n this._value = value;\n }\n}\n\nexport class Material {\n constructor() {\n this.state = new MaterialState;\n this.renderOrder = RENDER_ORDER.DEFAULT;\n this._samplers = [];\n this._uniforms = [];\n }\n\n defineSampler(uniformName) {\n let sampler = new MaterialSampler(uniformName);\n this._samplers.push(sampler);\n return sampler;\n }\n\n defineUniform(uniformName, defaultValue=null, length=0) {\n let uniform = new MaterialUniform(uniformName, defaultValue, length);\n this._uniforms.push(uniform);\n return uniform;\n }\n\n get materialName() {\n return null;\n }\n\n get vertexSource() {\n return null;\n }\n\n get fragmentSource() {\n return null;\n }\n\n getProgramDefines(renderPrimitive) {\n return {};\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Ray} from './ray.js';\nimport {mat4, vec3, quat} from '../math/gl-matrix.js';\n\nconst DEFAULT_TRANSLATION = new Float32Array([0, 0, 0]);\nconst DEFAULT_ROTATION = new Float32Array([0, 0, 0, 1]);\nconst DEFAULT_SCALE = new Float32Array([1, 1, 1]);\n\nlet tmpRayMatrix = mat4.create();\n\nexport class Node {\n constructor() {\n this.name = null; // Only for debugging\n this.children = [];\n this.parent = null;\n this.visible = true;\n this.selectable = false;\n\n this._matrix = null;\n\n this._dirtyTRS = false;\n this._translation = null;\n this._rotation = null;\n this._scale = null;\n\n this._dirtyWorldMatrix = false;\n this._worldMatrix = null;\n\n this._activeFrameId = -1;\n this._hoverFrameId = -1;\n this._renderPrimitives = null;\n this._renderer = null;\n\n this._selectHandler = null;\n }\n\n _setRenderer(renderer) {\n if (this._renderer == renderer) {\n return;\n }\n\n if (this._renderer) {\n // Changing the renderer removes any previously attached renderPrimitives\n // from a different renderer.\n this.clearRenderPrimitives();\n }\n\n this._renderer = renderer;\n if (renderer) {\n this.onRendererChanged(renderer);\n\n for (let child of this.children) {\n child._setRenderer(renderer);\n }\n }\n }\n\n onRendererChanged(renderer) {\n // Override in other node types to respond to changes in the renderer.\n }\n\n // Create a clone of this node and all of it's children. Does not duplicate\n // RenderPrimitives, the cloned nodes will be treated as new instances of the\n // geometry.\n clone() {\n let cloneNode = new Node();\n cloneNode.name = this.name;\n cloneNode.visible = this.visible;\n cloneNode._renderer = this._renderer;\n\n cloneNode._dirtyTRS = this._dirtyTRS;\n\n if (this._translation) {\n cloneNode._translation = vec3.create();\n vec3.copy(cloneNode._translation, this._translation);\n }\n\n if (this._rotation) {\n cloneNode._rotation = quat.create();\n quat.copy(cloneNode._rotation, this._rotation);\n }\n\n if (this._scale) {\n cloneNode._scale = vec3.create();\n vec3.copy(cloneNode._scale, this._scale);\n }\n\n // Only copy the matrices if they're not already dirty.\n if (!cloneNode._dirtyTRS && this._matrix) {\n cloneNode._matrix = mat4.create();\n mat4.copy(cloneNode._matrix, this._matrix);\n }\n\n cloneNode._dirtyWorldMatrix = this._dirtyWorldMatrix;\n if (!cloneNode._dirtyWorldMatrix && this._worldMatrix) {\n cloneNode._worldMatrix = mat4.create();\n mat4.copy(cloneNode._worldMatrix, this._worldMatrix);\n }\n\n this.waitForComplete().then(() => {\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n cloneNode.addRenderPrimitive(primitive);\n }\n }\n\n for (let child of this.children) {\n cloneNode.addNode(child.clone());\n }\n });\n\n return cloneNode;\n }\n\n markActive(frameId) {\n if (this.visible && this._renderPrimitives) {\n this._activeFrameId = frameId;\n for (let primitive of this._renderPrimitives) {\n primitive.markActive(frameId);\n }\n }\n\n for (let child of this.children) {\n if (child.visible) {\n child.markActive(frameId);\n }\n }\n }\n\n addNode(value) {\n if (!value || value.parent == this) {\n return;\n }\n\n if (value.parent) {\n value.parent.removeNode(value);\n }\n value.parent = this;\n\n this.children.push(value);\n\n if (this._renderer) {\n value._setRenderer(this._renderer);\n }\n }\n\n removeNode(value) {\n let i = this.children.indexOf(value);\n if (i > -1) {\n this.children.splice(i, 1);\n value.parent = null;\n }\n }\n\n clearNodes() {\n for (let child of this.children) {\n child.parent = null;\n }\n this.children = [];\n }\n\n setMatrixDirty() {\n if (!this._dirtyWorldMatrix) {\n this._dirtyWorldMatrix = true;\n for (let child of this.children) {\n child.setMatrixDirty();\n }\n }\n }\n\n _updateLocalMatrix() {\n if (!this._matrix) {\n this._matrix = mat4.create();\n }\n\n if (this._dirtyTRS) {\n this._dirtyTRS = false;\n mat4.fromRotationTranslationScale(\n this._matrix,\n this._rotation || DEFAULT_ROTATION,\n this._translation || DEFAULT_TRANSLATION,\n this._scale || DEFAULT_SCALE);\n }\n\n return this._matrix;\n }\n\n set matrix(value) {\n if (value) {\n if (!this._matrix) {\n this._matrix = mat4.create();\n }\n mat4.copy(this._matrix, value);\n } else {\n this._matrix = null;\n }\n this.setMatrixDirty();\n this._dirtyTRS = false;\n this._translation = null;\n this._rotation = null;\n this._scale = null;\n }\n\n get matrix() {\n this.setMatrixDirty();\n\n return this._updateLocalMatrix();\n }\n\n get worldMatrix() {\n if (!this._worldMatrix) {\n this._dirtyWorldMatrix = true;\n this._worldMatrix = mat4.create();\n }\n\n if (this._dirtyWorldMatrix || this._dirtyTRS) {\n if (this.parent) {\n // TODO: Some optimizations that could be done here if the node matrix\n // is an identity matrix.\n mat4.mul(this._worldMatrix, this.parent.worldMatrix, this._updateLocalMatrix());\n } else {\n mat4.copy(this._worldMatrix, this._updateLocalMatrix());\n }\n this._dirtyWorldMatrix = false;\n }\n\n return this._worldMatrix;\n }\n\n // TODO: Decompose matrix when fetching these?\n set translation(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._translation = value;\n }\n\n get translation() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._translation) {\n this._translation = vec3.clone(DEFAULT_TRANSLATION);\n }\n return this._translation;\n }\n\n set rotation(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._rotation = value;\n }\n\n get rotation() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._rotation) {\n this._rotation = quat.clone(DEFAULT_ROTATION);\n }\n return this._rotation;\n }\n\n set scale(value) {\n if (value != null) {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n }\n this._scale = value;\n }\n\n get scale() {\n this._dirtyTRS = true;\n this.setMatrixDirty();\n if (!this._scale) {\n this._scale = vec3.clone(DEFAULT_SCALE);\n }\n return this._scale;\n }\n\n waitForComplete() {\n let childPromises = [];\n for (let child of this.children) {\n childPromises.push(child.waitForComplete());\n }\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n childPromises.push(primitive.waitForComplete());\n }\n }\n return Promise.all(childPromises).then(() => this);\n }\n\n get renderPrimitives() {\n return this._renderPrimitives;\n }\n\n addRenderPrimitive(primitive) {\n if (!this._renderPrimitives) {\n this._renderPrimitives = [primitive];\n } else {\n this._renderPrimitives.push(primitive);\n }\n primitive._instances.push(this);\n }\n\n removeRenderPrimitive(primitive) {\n if (!this._renderPrimitives) {\n return;\n }\n\n let index = this._renderPrimitives._instances.indexOf(primitive);\n if (index > -1) {\n this._renderPrimitives._instances.splice(index, 1);\n\n index = primitive._instances.indexOf(this);\n if (index > -1) {\n primitive._instances.splice(index, 1);\n }\n\n if (!this._renderPrimitives.length) {\n this._renderPrimitives = null;\n }\n }\n }\n\n clearRenderPrimitives() {\n if (this._renderPrimitives) {\n for (let primitive of this._renderPrimitives) {\n let index = primitive._instances.indexOf(this);\n if (index > -1) {\n primitive._instances.splice(index, 1);\n }\n }\n this._renderPrimitives = null;\n }\n }\n\n _hitTestSelectableNode(ray) {\n if (this._renderPrimitives) {\n let localRay = null;\n for (let primitive of this._renderPrimitives) {\n if (primitive._min) {\n if (!localRay) {\n mat4.invert(tmpRayMatrix, this.worldMatrix);\n mat4.multiply(tmpRayMatrix, tmpRayMatrix, ray.transformMatrix);\n localRay = new Ray(tmpRayMatrix);\n }\n let intersection = localRay.intersectsAABB(primitive._min, primitive._max);\n if (intersection) {\n vec3.transformMat4(intersection, intersection, this.worldMatrix);\n return intersection;\n }\n }\n }\n }\n for (let child of this.children) {\n let intersection = child._hitTestSelectableNode(ray);\n if (intersection) {\n return intersection;\n }\n }\n return null;\n }\n\n hitTest(ray) {\n if (this.selectable && this.visible) {\n let intersection = this._hitTestSelectableNode(ray);\n\n if (intersection) {\n let origin = vec3.fromValues(ray.origin.x, ray.origin.y, ray.origin.z);\n return {\n node: this,\n intersection: intersection,\n distance: vec3.distance(origin, intersection),\n };\n }\n return null;\n }\n\n let result = null;\n for (let child of this.children) {\n let childResult = child.hitTest(ray);\n if (childResult) {\n if (!result || result.distance > childResult.distance) {\n result = childResult;\n }\n }\n }\n return result;\n }\n\n onSelect(value) {\n this._selectHandler = value;\n }\n\n get selectHandler() {\n return this._selectHandler;\n }\n\n // Called when a selectable node is selected.\n handleSelect() {\n if (this._selectHandler) {\n this._selectHandler();\n }\n }\n\n // Called when a selectable element is pointed at.\n onHoverStart() {\n\n }\n\n // Called when a selectable element is no longer pointed at.\n onHoverEnd() {\n\n }\n\n _update(timestamp, frameDelta) {\n this.onUpdate(timestamp, frameDelta);\n\n for (let child of this.children) {\n child._update(timestamp, frameDelta);\n }\n }\n\n // Called every frame so that the nodes can animate themselves\n onUpdate(timestamp, frameDelta) {\n\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {vec3} from '../math/gl-matrix.js';\n\nexport class PrimitiveAttribute {\n constructor(name, buffer, componentCount, componentType, stride, byteOffset) {\n this.name = name;\n this.buffer = buffer;\n this.componentCount = componentCount || 3;\n this.componentType = componentType || 5126; // gl.FLOAT;\n this.stride = stride || 0;\n this.byteOffset = byteOffset || 0;\n this.normalized = false;\n }\n}\n\nexport class Primitive {\n constructor(attributes, elementCount, mode) {\n this.attributes = attributes || [];\n this.elementCount = elementCount || 0;\n this.mode = mode || 4; // gl.TRIANGLES;\n this.indexBuffer = null;\n this.indexByteOffset = 0;\n this.indexType = 0;\n this._min = null;\n this._max = null;\n }\n\n setIndexBuffer(indexBuffer, byteOffset, indexType) {\n this.indexBuffer = indexBuffer;\n this.indexByteOffset = byteOffset || 0;\n this.indexType = indexType || 5123; // gl.UNSIGNED_SHORT;\n }\n\n setBounds(min, max) {\n this._min = vec3.clone(min);\n this._max = vec3.clone(max);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nexport class Program {\n constructor(gl, vertSrc, fragSrc, attribMap, defines) {\n this._gl = gl;\n this.program = gl.createProgram();\n this.attrib = null;\n this.uniform = null;\n this.defines = {};\n\n this._firstUse = true;\n this._nextUseCallbacks = [];\n\n let definesString = '';\n if (defines) {\n for (let define in defines) {\n this.defines[define] = defines[define];\n definesString += `#define ${define} ${defines[define]}\\n`;\n }\n }\n\n this._vertShader = gl.createShader(gl.VERTEX_SHADER);\n gl.attachShader(this.program, this._vertShader);\n gl.shaderSource(this._vertShader, definesString + vertSrc);\n gl.compileShader(this._vertShader);\n\n this._fragShader = gl.createShader(gl.FRAGMENT_SHADER);\n gl.attachShader(this.program, this._fragShader);\n gl.shaderSource(this._fragShader, definesString + fragSrc);\n gl.compileShader(this._fragShader);\n\n if (attribMap) {\n this.attrib = {};\n for (let attribName in attribMap) {\n gl.bindAttribLocation(this.program, attribMap[attribName], attribName);\n this.attrib[attribName] = attribMap[attribName];\n }\n }\n\n gl.linkProgram(this.program);\n }\n\n onNextUse(callback) {\n this._nextUseCallbacks.push(callback);\n }\n\n use() {\n let gl = this._gl;\n\n // If this is the first time the program has been used do all the error checking and\n // attrib/uniform querying needed.\n if (this._firstUse) {\n this._firstUse = false;\n if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {\n if (!gl.getShaderParameter(this._vertShader, gl.COMPILE_STATUS)) {\n console.error('Vertex shader compile error: ' + gl.getShaderInfoLog(this._vertShader));\n } else if (!gl.getShaderParameter(this._fragShader, gl.COMPILE_STATUS)) {\n console.error('Fragment shader compile error: ' + gl.getShaderInfoLog(this._fragShader));\n } else {\n console.error('Program link error: ' + gl.getProgramInfoLog(this.program));\n }\n gl.deleteProgram(this.program);\n this.program = null;\n } else {\n if (!this.attrib) {\n this.attrib = {};\n let attribCount = gl.getProgramParameter(this.program, gl.ACTIVE_ATTRIBUTES);\n for (let i = 0; i < attribCount; i++) {\n let attribInfo = gl.getActiveAttrib(this.program, i);\n this.attrib[attribInfo.name] = gl.getAttribLocation(this.program, attribInfo.name);\n }\n }\n\n this.uniform = {};\n let uniformCount = gl.getProgramParameter(this.program, gl.ACTIVE_UNIFORMS);\n let uniformName = '';\n for (let i = 0; i < uniformCount; i++) {\n let uniformInfo = gl.getActiveUniform(this.program, i);\n uniformName = uniformInfo.name.replace('[0]', '');\n this.uniform[uniformName] = gl.getUniformLocation(this.program, uniformName);\n }\n }\n gl.deleteShader(this._vertShader);\n gl.deleteShader(this._fragShader);\n }\n\n gl.useProgram(this.program);\n\n if (this._nextUseCallbacks.length) {\n for (let callback of this._nextUseCallbacks) {\n callback(this);\n }\n this._nextUseCallbacks = [];\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {mat3, vec3} from '../math/gl-matrix.js';\n\nlet normalMat = mat3.create();\n\nconst RAY_INTERSECTION_OFFSET = 0.02;\n\nexport class Ray {\n constructor(matrix = null) {\n this.origin = vec3.create();\n\n this._dir = vec3.create();\n this._dir[2] = -1.0;\n\n if (matrix) {\n vec3.transformMat4(this.origin, this.origin, matrix);\n mat3.fromMat4(normalMat, matrix);\n vec3.transformMat3(this._dir, this._dir, normalMat);\n }\n\n // To force the inverse and sign calculations.\n this.dir = this._dir;\n }\n\n get dir() {\n return this._dir;\n }\n\n set dir(value) {\n this._dir = vec3.copy(this._dir, value);\n vec3.normalize(this._dir, this._dir);\n\n this.inv_dir = vec3.fromValues(\n 1.0 / this._dir[0],\n 1.0 / this._dir[1],\n 1.0 / this._dir[2]);\n\n this.sign = [\n (this.inv_dir[0] < 0) ? 1 : 0,\n (this.inv_dir[1] < 0) ? 1 : 0,\n (this.inv_dir[2] < 0) ? 1 : 0,\n ];\n }\n\n // Borrowed from:\n // eslint-disable-next-line max-len\n // https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection\n intersectsAABB(min, max) {\n let r = this;\n\n let bounds = [min, max];\n\n let tmin = (bounds[r.sign[0]][0] - r.origin[0]) * r.inv_dir[0];\n let tmax = (bounds[1-r.sign[0]][0] - r.origin[0]) * r.inv_dir[0];\n let tymin = (bounds[r.sign[1]][1] - r.origin[1]) * r.inv_dir[1];\n let tymax = (bounds[1-r.sign[1]][1] - r.origin[1]) * r.inv_dir[1];\n\n if ((tmin > tymax) || (tymin > tmax)) {\n return null;\n }\n if (tymin > tmin) {\n tmin = tymin;\n }\n if (tymax < tmax) {\n tmax = tymax;\n }\n\n let tzmin = (bounds[r.sign[2]][2] - r.origin[2]) * r.inv_dir[2];\n let tzmax = (bounds[1-r.sign[2]][2] - r.origin[2]) * r.inv_dir[2];\n\n if ((tmin > tzmax) || (tzmin > tmax)) {\n return null;\n }\n if (tzmin > tmin) {\n tmin = tzmin;\n }\n if (tzmax < tmax) {\n tmax = tzmax;\n }\n\n let t = -1;\n if (tmin > 0 && tmax > 0) {\n t = Math.min(tmin, tmax);\n } else if (tmin > 0) {\n t = tmin;\n } else if (tmax > 0) {\n t = tmax;\n } else {\n // Intersection is behind the ray origin.\n return null;\n }\n\n // Push ray intersection point back along the ray a bit so that cursors\n // don't accidentally intersect with the hit surface.\n t -= RAY_INTERSECTION_OFFSET;\n\n // Return the point where the ray first intersected with the AABB.\n let intersectionPoint = vec3.clone(this._dir);\n vec3.scale(intersectionPoint, intersectionPoint, t);\n vec3.add(intersectionPoint, intersectionPoint, this.origin);\n return intersectionPoint;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {CAP, MAT_STATE, RENDER_ORDER, stateToBlendFunc} from './material.js';\nimport {Node} from './node.js';\nimport {Program} from './program.js';\nimport {DataTexture, VideoTexture} from './texture.js';\nimport {mat4, vec3} from '../math/gl-matrix.js';\n\nexport const ATTRIB = {\n POSITION: 1,\n NORMAL: 2,\n TANGENT: 3,\n TEXCOORD_0: 4,\n TEXCOORD_1: 5,\n COLOR_0: 6,\n};\n\nexport const ATTRIB_MASK = {\n POSITION: 0x0001,\n NORMAL: 0x0002,\n TANGENT: 0x0004,\n TEXCOORD_0: 0x0008,\n TEXCOORD_1: 0x0010,\n COLOR_0: 0x0020,\n};\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst DEF_LIGHT_DIR = new Float32Array([-0.1, -1.0, -0.2]);\nconst DEF_LIGHT_COLOR = new Float32Array([3.0, 3.0, 3.0]);\n\nconst PRECISION_REGEX = new RegExp('precision (lowp|mediump|highp) float;');\n\nconst VERTEX_SHADER_SINGLE_ENTRY = `\nuniform mat4 PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX;\n\nvoid main() {\n gl_Position = vertex_main(PROJECTION_MATRIX, VIEW_MATRIX, MODEL_MATRIX);\n}\n`;\n\nconst VERTEX_SHADER_MULTI_ENTRY = `\n#ERROR Multiview rendering is not implemented\nvoid main() {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n}\n`;\n\nconst FRAGMENT_SHADER_ENTRY = `\nvoid main() {\n gl_FragColor = fragment_main();\n}\n`;\n\nfunction isPowerOfTwo(n) {\n return (n & (n - 1)) === 0;\n}\n\n// Creates a WebGL context and initializes it with some common default state.\nexport function createWebGLContext(glAttribs) {\n glAttribs = glAttribs || {alpha: false};\n\n let webglCanvas = document.createElement('canvas');\n let contextTypes = glAttribs.webgl2 ? ['webgl2'] : ['webgl', 'experimental-webgl'];\n let context = null;\n\n for (let contextType of contextTypes) {\n context = webglCanvas.getContext(contextType, glAttribs);\n if (context) {\n break;\n }\n }\n\n if (!context) {\n let webglType = (glAttribs.webgl2 ? 'WebGL 2' : 'WebGL');\n console.error('This browser does not support ' + webglType + '.');\n return null;\n }\n\n return context;\n}\n\nexport class RenderView {\n constructor(projectionMatrix, viewMatrix, viewport = null, eye = 'left') {\n this.projectionMatrix = projectionMatrix;\n this.viewMatrix = viewMatrix;\n this.viewport = viewport;\n // If an eye isn't given the left eye is assumed.\n this._eye = eye;\n this._eyeIndex = (eye == 'left' ? 0 : 1);\n }\n\n get eye() {\n return this._eye;\n }\n\n set eye(value) {\n this._eye = value;\n this._eyeIndex = (value == 'left' ? 0 : 1);\n }\n\n get eyeIndex() {\n return this._eyeIndex;\n }\n}\n\nclass RenderBuffer {\n constructor(target, usage, buffer, length = 0) {\n this._target = target;\n this._usage = usage;\n this._length = length;\n if (buffer instanceof Promise) {\n this._buffer = null;\n this._promise = buffer.then((buffer) => {\n this._buffer = buffer;\n return this;\n });\n } else {\n this._buffer = buffer;\n this._promise = Promise.resolve(this);\n }\n }\n\n waitForComplete() {\n return this._promise;\n }\n}\n\nclass RenderPrimitiveAttribute {\n constructor(primitiveAttribute) {\n this._attrib_index = ATTRIB[primitiveAttribute.name];\n this._componentCount = primitiveAttribute.componentCount;\n this._componentType = primitiveAttribute.componentType;\n this._stride = primitiveAttribute.stride;\n this._byteOffset = primitiveAttribute.byteOffset;\n this._normalized = primitiveAttribute.normalized;\n }\n}\n\nclass RenderPrimitiveAttributeBuffer {\n constructor(buffer) {\n this._buffer = buffer;\n this._attributes = [];\n }\n}\n\nclass RenderPrimitive {\n constructor(primitive) {\n this._activeFrameId = 0;\n this._instances = [];\n this._material = null;\n\n this.setPrimitive(primitive);\n }\n\n setPrimitive(primitive) {\n this._mode = primitive.mode;\n this._elementCount = primitive.elementCount;\n this._promise = null;\n this._vao = null;\n this._complete = false;\n this._attributeBuffers = [];\n this._attributeMask = 0;\n\n for (let attribute of primitive.attributes) {\n this._attributeMask |= ATTRIB_MASK[attribute.name];\n let renderAttribute = new RenderPrimitiveAttribute(attribute);\n let foundBuffer = false;\n for (let attributeBuffer of this._attributeBuffers) {\n if (attributeBuffer._buffer == attribute.buffer) {\n attributeBuffer._attributes.push(renderAttribute);\n foundBuffer = true;\n break;\n }\n }\n if (!foundBuffer) {\n let attributeBuffer = new RenderPrimitiveAttributeBuffer(attribute.buffer);\n attributeBuffer._attributes.push(renderAttribute);\n this._attributeBuffers.push(attributeBuffer);\n }\n }\n\n this._indexBuffer = null;\n this._indexByteOffset = 0;\n this._indexType = 0;\n\n if (primitive.indexBuffer) {\n this._indexByteOffset = primitive.indexByteOffset;\n this._indexType = primitive.indexType;\n this._indexBuffer = primitive.indexBuffer;\n }\n\n if (primitive._min) {\n this._min = vec3.clone(primitive._min);\n this._max = vec3.clone(primitive._max);\n } else {\n this._min = null;\n this._max = null;\n }\n\n if (this._material != null) {\n this.waitForComplete(); // To flip the _complete flag.\n }\n }\n\n setRenderMaterial(material) {\n this._material = material;\n this._promise = null;\n this._complete = false;\n\n if (this._material != null) {\n this.waitForComplete(); // To flip the _complete flag.\n }\n }\n\n markActive(frameId) {\n if (this._complete && this._activeFrameId != frameId) {\n if (this._material) {\n if (!this._material.markActive(frameId)) {\n return;\n }\n }\n this._activeFrameId = frameId;\n }\n }\n\n get samplers() {\n return this._material._samplerDictionary;\n }\n\n get uniforms() {\n return this._material._uniform_dictionary;\n }\n\n waitForComplete() {\n if (!this._promise) {\n if (!this._material) {\n return Promise.reject('RenderPrimitive does not have a material');\n }\n\n let completionPromises = [];\n\n for (let attributeBuffer of this._attributeBuffers) {\n if (!attributeBuffer._buffer._buffer) {\n completionPromises.push(attributeBuffer._buffer._promise);\n }\n }\n\n if (this._indexBuffer && !this._indexBuffer._buffer) {\n completionPromises.push(this._indexBuffer._promise);\n }\n\n this._promise = Promise.all(completionPromises).then(() => {\n this._complete = true;\n return this;\n });\n }\n return this._promise;\n }\n}\n\nexport class RenderTexture {\n constructor(texture) {\n this._texture = texture;\n this._complete = false;\n this._activeFrameId = 0;\n this._activeCallback = null;\n }\n\n markActive(frameId) {\n if (this._activeCallback && this._activeFrameId != frameId) {\n this._activeFrameId = frameId;\n this._activeCallback(this);\n }\n }\n}\n\nconst inverseMatrix = mat4.create();\n\nfunction setCap(gl, glEnum, cap, prevState, state) {\n let change = (state & cap) - (prevState & cap);\n if (!change) {\n return;\n }\n\n if (change > 0) {\n gl.enable(glEnum);\n } else {\n gl.disable(glEnum);\n }\n}\n\nclass RenderMaterialSampler {\n constructor(renderer, materialSampler, index) {\n this._renderer = renderer;\n this._uniformName = materialSampler._uniformName;\n this._renderTexture = renderer._getRenderTexture(materialSampler._texture);\n this._index = index;\n }\n\n set texture(value) {\n this._renderTexture = this._renderer._getRenderTexture(value);\n }\n}\n\nclass RenderMaterialUniform {\n constructor(materialUniform) {\n this._uniformName = materialUniform._uniformName;\n this._uniform = null;\n this._length = materialUniform._length;\n if (materialUniform._value instanceof Array) {\n this._value = new Float32Array(materialUniform._value);\n } else {\n this._value = new Float32Array([materialUniform._value]);\n }\n }\n\n set value(value) {\n if (this._value.length == 1) {\n this._value[0] = value;\n } else {\n for (let i = 0; i < this._value.length; ++i) {\n this._value[i] = value[i];\n }\n }\n }\n}\n\nclass RenderMaterial {\n constructor(renderer, material, program) {\n this._program = program;\n this._state = material.state._state;\n this._activeFrameId = 0;\n this._completeForActiveFrame = false;\n\n this._samplerDictionary = {};\n this._samplers = [];\n for (let i = 0; i < material._samplers.length; ++i) {\n let renderSampler = new RenderMaterialSampler(renderer, material._samplers[i], i);\n this._samplers.push(renderSampler);\n this._samplerDictionary[renderSampler._uniformName] = renderSampler;\n }\n\n this._uniform_dictionary = {};\n this._uniforms = [];\n for (let uniform of material._uniforms) {\n let renderUniform = new RenderMaterialUniform(uniform);\n this._uniforms.push(renderUniform);\n this._uniform_dictionary[renderUniform._uniformName] = renderUniform;\n }\n\n this._firstBind = true;\n\n this._renderOrder = material.renderOrder;\n if (this._renderOrder == RENDER_ORDER.DEFAULT) {\n if (this._state & CAP.BLEND) {\n this._renderOrder = RENDER_ORDER.TRANSPARENT;\n } else {\n this._renderOrder = RENDER_ORDER.OPAQUE;\n }\n }\n }\n\n bind(gl) {\n // First time we do a binding, cache the uniform locations and remove\n // unused uniforms from the list.\n if (this._firstBind) {\n for (let i = 0; i < this._samplers.length;) {\n let sampler = this._samplers[i];\n if (!this._program.uniform[sampler._uniformName]) {\n this._samplers.splice(i, 1);\n continue;\n }\n ++i;\n }\n\n for (let i = 0; i < this._uniforms.length;) {\n let uniform = this._uniforms[i];\n uniform._uniform = this._program.uniform[uniform._uniformName];\n if (!uniform._uniform) {\n this._uniforms.splice(i, 1);\n continue;\n }\n ++i;\n }\n this._firstBind = false;\n }\n\n for (let sampler of this._samplers) {\n gl.activeTexture(gl.TEXTURE0 + sampler._index);\n if (sampler._renderTexture && sampler._renderTexture._complete) {\n gl.bindTexture(gl.TEXTURE_2D, sampler._renderTexture._texture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, null);\n }\n }\n\n for (let uniform of this._uniforms) {\n switch (uniform._length) {\n case 1: gl.uniform1fv(uniform._uniform, uniform._value); break;\n case 2: gl.uniform2fv(uniform._uniform, uniform._value); break;\n case 3: gl.uniform3fv(uniform._uniform, uniform._value); break;\n case 4: gl.uniform4fv(uniform._uniform, uniform._value); break;\n }\n }\n }\n\n markActive(frameId) {\n if (this._activeFrameId != frameId) {\n this._activeFrameId = frameId;\n this._completeForActiveFrame = true;\n for (let i = 0; i < this._samplers.length; ++i) {\n let sampler = this._samplers[i];\n if (sampler._renderTexture) {\n if (!sampler._renderTexture._complete) {\n this._completeForActiveFrame = false;\n break;\n }\n sampler._renderTexture.markActive(frameId);\n }\n }\n }\n return this._completeForActiveFrame;\n }\n\n // Material State fetchers\n get cullFace() {\n return !!(this._state & CAP.CULL_FACE);\n }\n get blend() {\n return !!(this._state & CAP.BLEND);\n }\n get depthTest() {\n return !!(this._state & CAP.DEPTH_TEST);\n }\n get stencilTest() {\n return !!(this._state & CAP.STENCIL_TEST);\n }\n get colorMask() {\n return !!(this._state & CAP.COLOR_MASK);\n }\n get depthMask() {\n return !!(this._state & CAP.DEPTH_MASK);\n }\n get stencilMask() {\n return !!(this._state & CAP.STENCIL_MASK);\n }\n get depthFunc() {\n return ((this._state & MAT_STATE.DEPTH_FUNC_RANGE) >> MAT_STATE.DEPTH_FUNC_SHIFT) + GL.NEVER;\n }\n get blendFuncSrc() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_SRC_RANGE, MAT_STATE.BLEND_SRC_SHIFT);\n }\n get blendFuncDst() {\n return stateToBlendFunc(this._state, MAT_STATE.BLEND_DST_RANGE, MAT_STATE.BLEND_DST_SHIFT);\n }\n\n // Only really for use from the renderer\n _capsDiff(otherState) {\n return (otherState & MAT_STATE.CAPS_RANGE) ^ (this._state & MAT_STATE.CAPS_RANGE);\n }\n\n _blendDiff(otherState) {\n if (!(this._state & CAP.BLEND)) {\n return 0;\n }\n return (otherState & MAT_STATE.BLEND_FUNC_RANGE) ^ (this._state & MAT_STATE.BLEND_FUNC_RANGE);\n }\n\n _depthFuncDiff(otherState) {\n if (!(this._state & CAP.DEPTH_TEST)) {\n return 0;\n }\n return (otherState & MAT_STATE.DEPTH_FUNC_RANGE) ^ (this._state & MAT_STATE.DEPTH_FUNC_RANGE);\n }\n}\n\nexport class Renderer {\n constructor(gl) {\n this._gl = gl || createWebGLContext();\n this._frameId = 0;\n this._programCache = {};\n this._textureCache = {};\n this._renderPrimitives = Array(RENDER_ORDER.DEFAULT);\n this._cameraPositions = [];\n\n this._vaoExt = gl.getExtension('OES_vertex_array_object');\n\n let fragHighPrecision = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);\n this._defaultFragPrecision = fragHighPrecision.precision > 0 ? 'highp' : 'mediump';\n\n this._depthMaskNeedsReset = false;\n this._colorMaskNeedsReset = false;\n\n this._globalLightColor = vec3.clone(DEF_LIGHT_COLOR);\n this._globalLightDir = vec3.clone(DEF_LIGHT_DIR);\n }\n\n get gl() {\n return this._gl;\n }\n\n set globalLightColor(value) {\n vec3.copy(this._globalLightColor, value);\n }\n\n get globalLightColor() {\n return vec3.clone(this._globalLightColor);\n }\n\n set globalLightDir(value) {\n vec3.copy(this._globalLightDir, value);\n }\n\n get globalLightDir() {\n return vec3.clone(this._globalLightDir);\n }\n\n createRenderBuffer(target, data, usage = GL.STATIC_DRAW) {\n let gl = this._gl;\n let glBuffer = gl.createBuffer();\n\n if (data instanceof Promise) {\n let renderBuffer = new RenderBuffer(target, usage, data.then((data) => {\n gl.bindBuffer(target, glBuffer);\n gl.bufferData(target, data, usage);\n renderBuffer._length = data.byteLength;\n return glBuffer;\n }));\n return renderBuffer;\n } else {\n gl.bindBuffer(target, glBuffer);\n gl.bufferData(target, data, usage);\n return new RenderBuffer(target, usage, glBuffer, data.byteLength);\n }\n }\n\n updateRenderBuffer(buffer, data, offset = 0) {\n if (buffer._buffer) {\n let gl = this._gl;\n gl.bindBuffer(buffer._target, buffer._buffer);\n if (offset == 0 && buffer._length == data.byteLength) {\n gl.bufferData(buffer._target, data, buffer._usage);\n } else {\n gl.bufferSubData(buffer._target, offset, data);\n }\n } else {\n buffer.waitForComplete().then((buffer) => {\n this.updateRenderBuffer(buffer, data, offset);\n });\n }\n }\n\n createRenderPrimitive(primitive, material) {\n let renderPrimitive = new RenderPrimitive(primitive);\n\n let program = this._getMaterialProgram(material, renderPrimitive);\n let renderMaterial = new RenderMaterial(this, material, program);\n renderPrimitive.setRenderMaterial(renderMaterial);\n\n if (!this._renderPrimitives[renderMaterial._renderOrder]) {\n this._renderPrimitives[renderMaterial._renderOrder] = [];\n }\n\n this._renderPrimitives[renderMaterial._renderOrder].push(renderPrimitive);\n\n return renderPrimitive;\n }\n\n createMesh(primitive, material) {\n let meshNode = new Node();\n meshNode.addRenderPrimitive(this.createRenderPrimitive(primitive, material));\n return meshNode;\n }\n\n drawViews(views, rootNode) {\n if (!rootNode) {\n return;\n }\n\n let gl = this._gl;\n this._frameId++;\n\n rootNode.markActive(this._frameId);\n\n // If there's only one view then flip the algorithm a bit so that we're only\n // setting the viewport once.\n if (views.length == 1 && views[0].viewport) {\n let vp = views[0].viewport;\n this._gl.viewport(vp.x, vp.y, vp.width, vp.height);\n }\n\n // Get the positions of the 'camera' for each view matrix.\n for (let i = 0; i < views.length; ++i) {\n mat4.invert(inverseMatrix, views[i].viewMatrix);\n\n if (this._cameraPositions.length <= i) {\n this._cameraPositions.push(vec3.create());\n }\n let cameraPosition = this._cameraPositions[i];\n vec3.set(cameraPosition, 0, 0, 0);\n vec3.transformMat4(cameraPosition, cameraPosition, inverseMatrix);\n }\n\n // Draw each set of render primitives in order\n for (let renderPrimitives of this._renderPrimitives) {\n if (renderPrimitives && renderPrimitives.length) {\n this._drawRenderPrimitiveSet(views, renderPrimitives);\n }\n }\n\n if (this._vaoExt) {\n this._vaoExt.bindVertexArrayOES(null);\n }\n\n if (this._depthMaskNeedsReset) {\n gl.depthMask(true);\n }\n if (this._colorMaskNeedsReset) {\n gl.colorMask(true, true, true, true);\n }\n }\n\n _drawRenderPrimitiveSet(views, renderPrimitives) {\n let gl = this._gl;\n let program = null;\n let material = null;\n let attribMask = 0;\n\n // Loop through every primitive known to the renderer.\n for (let primitive of renderPrimitives) {\n // Skip over those that haven't been marked as active for this frame.\n if (primitive._activeFrameId != this._frameId) {\n continue;\n }\n\n // Bind the primitive material's program if it's different than the one we\n // were using for the previous primitive.\n // TODO: The ording of this could be more efficient.\n if (program != primitive._material._program) {\n program = primitive._material._program;\n program.use();\n\n if (program.uniform.LIGHT_DIRECTION) {\n gl.uniform3fv(program.uniform.LIGHT_DIRECTION, this._globalLightDir);\n }\n\n if (program.uniform.LIGHT_COLOR) {\n gl.uniform3fv(program.uniform.LIGHT_COLOR, this._globalLightColor);\n }\n\n if (views.length == 1) {\n gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, views[0].projectionMatrix);\n gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, views[0].viewMatrix);\n gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[0]);\n gl.uniform1i(program.uniform.EYE_INDEX, views[0].eyeIndex);\n }\n }\n\n if (material != primitive._material) {\n this._bindMaterialState(primitive._material, material);\n primitive._material.bind(gl, program, material);\n material = primitive._material;\n }\n\n if (this._vaoExt) {\n if (primitive._vao) {\n this._vaoExt.bindVertexArrayOES(primitive._vao);\n } else {\n primitive._vao = this._vaoExt.createVertexArrayOES();\n this._vaoExt.bindVertexArrayOES(primitive._vao);\n this._bindPrimitive(primitive);\n }\n } else {\n this._bindPrimitive(primitive, attribMask);\n attribMask = primitive._attributeMask;\n }\n\n for (let i = 0; i < views.length; ++i) {\n let view = views[i];\n if (views.length > 1) {\n if (view.viewport) {\n let vp = view.viewport;\n gl.viewport(vp.x, vp.y, vp.width, vp.height);\n }\n gl.uniformMatrix4fv(program.uniform.PROJECTION_MATRIX, false, view.projectionMatrix);\n gl.uniformMatrix4fv(program.uniform.VIEW_MATRIX, false, view.viewMatrix);\n gl.uniform3fv(program.uniform.CAMERA_POSITION, this._cameraPositions[i]);\n gl.uniform1i(program.uniform.EYE_INDEX, view.eyeIndex);\n }\n\n for (let instance of primitive._instances) {\n if (instance._activeFrameId != this._frameId) {\n continue;\n }\n\n gl.uniformMatrix4fv(program.uniform.MODEL_MATRIX, false, instance.worldMatrix);\n\n if (primitive._indexBuffer) {\n gl.drawElements(primitive._mode, primitive._elementCount,\n primitive._indexType, primitive._indexByteOffset);\n } else {\n gl.drawArrays(primitive._mode, 0, primitive._elementCount);\n }\n }\n }\n }\n }\n\n _getRenderTexture(texture) {\n if (!texture) {\n return null;\n }\n\n let key = texture.textureKey;\n if (!key) {\n throw new Error('Texure does not have a valid key');\n }\n\n if (key in this._textureCache) {\n return this._textureCache[key];\n } else {\n let gl = this._gl;\n let textureHandle = gl.createTexture();\n\n let renderTexture = new RenderTexture(textureHandle);\n this._textureCache[key] = renderTexture;\n\n if (texture instanceof DataTexture) {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.width, texture.height,\n 0, texture.format, texture._type, texture._data);\n this._setSamplerParameters(texture);\n renderTexture._complete = true;\n } else {\n texture.waitForComplete().then(() => {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source);\n this._setSamplerParameters(texture);\n renderTexture._complete = true;\n\n if (texture instanceof VideoTexture) {\n // Once the video starts playing, set a callback to update it's\n // contents each frame.\n texture._video.addEventListener('playing', () => {\n renderTexture._activeCallback = () => {\n if (!texture._video.paused && !texture._video.waiting) {\n gl.bindTexture(gl.TEXTURE_2D, textureHandle);\n gl.texImage2D(gl.TEXTURE_2D, 0, texture.format, texture.format, gl.UNSIGNED_BYTE, texture.source);\n }\n };\n });\n }\n });\n }\n\n return renderTexture;\n }\n }\n\n _setSamplerParameters(texture) {\n let gl = this._gl;\n\n let sampler = texture.sampler;\n let powerOfTwo = isPowerOfTwo(texture.width) && isPowerOfTwo(texture.height);\n let mipmap = powerOfTwo && texture.mipmap;\n if (mipmap) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n\n let minFilter = sampler.minFilter || (mipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);\n let wrapS = sampler.wrapS || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE);\n let wrapT = sampler.wrapT || (powerOfTwo ? gl.REPEAT : gl.CLAMP_TO_EDGE);\n\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, sampler.magFilter || gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT);\n }\n\n _getProgramKey(name, defines) {\n let key = `${name}:`;\n\n for (let define in defines) {\n key += `${define}=${defines[define]},`;\n }\n\n return key;\n }\n\n _getMaterialProgram(material, renderPrimitive) {\n let materialName = material.materialName;\n let vertexSource = material.vertexSource;\n let fragmentSource = material.fragmentSource;\n\n // These should always be defined for every material\n if (materialName == null) {\n throw new Error('Material does not have a name');\n }\n if (vertexSource == null) {\n throw new Error(`Material \"${materialName}\" does not have a vertex source`);\n }\n if (fragmentSource == null) {\n throw new Error(`Material \"${materialName}\" does not have a fragment source`);\n }\n\n let defines = material.getProgramDefines(renderPrimitive);\n let key = this._getProgramKey(materialName, defines);\n\n if (key in this._programCache) {\n return this._programCache[key];\n } else {\n let multiview = false; // Handle this dynamically later\n let fullVertexSource = vertexSource;\n fullVertexSource += multiview ? VERTEX_SHADER_MULTI_ENTRY :\n VERTEX_SHADER_SINGLE_ENTRY;\n\n let precisionMatch = fragmentSource.match(PRECISION_REGEX);\n let fragPrecisionHeader = precisionMatch ? '' : `precision ${this._defaultFragPrecision} float;\\n`;\n\n let fullFragmentSource = fragPrecisionHeader + fragmentSource;\n fullFragmentSource += FRAGMENT_SHADER_ENTRY;\n\n let program = new Program(this._gl, fullVertexSource, fullFragmentSource, ATTRIB, defines);\n this._programCache[key] = program;\n\n program.onNextUse((program) => {\n // Bind the samplers to the right texture index. This is constant for\n // the lifetime of the program.\n for (let i = 0; i < material._samplers.length; ++i) {\n let sampler = material._samplers[i];\n let uniform = program.uniform[sampler._uniformName];\n if (uniform) {\n this._gl.uniform1i(uniform, i);\n }\n }\n });\n\n return program;\n }\n }\n\n _bindPrimitive(primitive, attribMask) {\n let gl = this._gl;\n\n // If the active attributes have changed then update the active set.\n if (attribMask != primitive._attributeMask) {\n for (let attrib in ATTRIB) {\n if (primitive._attributeMask & ATTRIB_MASK[attrib]) {\n gl.enableVertexAttribArray(ATTRIB[attrib]);\n } else {\n gl.disableVertexAttribArray(ATTRIB[attrib]);\n }\n }\n }\n\n // Bind the primitive attributes and indices.\n for (let attributeBuffer of primitive._attributeBuffers) {\n gl.bindBuffer(gl.ARRAY_BUFFER, attributeBuffer._buffer._buffer);\n for (let attrib of attributeBuffer._attributes) {\n gl.vertexAttribPointer(\n attrib._attrib_index, attrib._componentCount, attrib._componentType,\n attrib._normalized, attrib._stride, attrib._byteOffset);\n }\n }\n\n if (primitive._indexBuffer) {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, primitive._indexBuffer._buffer);\n } else {\n gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n }\n }\n\n _bindMaterialState(material, prevMaterial = null) {\n let gl = this._gl;\n\n let state = material._state;\n let prevState = prevMaterial ? prevMaterial._state : ~state;\n\n // Return early if both materials use identical state\n if (state == prevState) {\n return;\n }\n\n // Any caps bits changed?\n if (material._capsDiff(prevState)) {\n setCap(gl, gl.CULL_FACE, CAP.CULL_FACE, prevState, state);\n setCap(gl, gl.BLEND, CAP.BLEND, prevState, state);\n setCap(gl, gl.DEPTH_TEST, CAP.DEPTH_TEST, prevState, state);\n setCap(gl, gl.STENCIL_TEST, CAP.STENCIL_TEST, prevState, state);\n\n let colorMaskChange = (state & CAP.COLOR_MASK) - (prevState & CAP.COLOR_MASK);\n if (colorMaskChange) {\n let mask = colorMaskChange > 1;\n this._colorMaskNeedsReset = !mask;\n gl.colorMask(mask, mask, mask, mask);\n }\n\n let depthMaskChange = (state & CAP.DEPTH_MASK) - (prevState & CAP.DEPTH_MASK);\n if (depthMaskChange) {\n this._depthMaskNeedsReset = !(depthMaskChange > 1);\n gl.depthMask(depthMaskChange > 1);\n }\n\n let stencilMaskChange = (state & CAP.STENCIL_MASK) - (prevState & CAP.STENCIL_MASK);\n if (stencilMaskChange) {\n gl.stencilMask(stencilMaskChange > 1);\n }\n }\n\n // Blending enabled and blend func changed?\n if (material._blendDiff(prevState)) {\n gl.blendFunc(material.blendFuncSrc, material.blendFuncDst);\n }\n\n // Depth testing enabled and depth func changed?\n if (material._depthFuncDiff(prevState)) {\n gl.depthFunc(material.depthFunc);\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst GL = WebGLRenderingContext; // For enums\n\nexport class TextureSampler {\n constructor() {\n this.minFilter = null;\n this.magFilter = null;\n this.wrapS = null;\n this.wrapT = null;\n }\n}\n\nexport class Texture {\n constructor() {\n this.sampler = new TextureSampler();\n this.mipmap = true;\n // TODO: Anisotropy\n }\n\n get format() {\n return GL.RGBA;\n }\n\n get width() {\n return 0;\n }\n\n get height() {\n return 0;\n }\n\n get textureKey() {\n return null;\n }\n}\n\nexport class ImageTexture extends Texture {\n constructor(img) {\n super();\n\n this._img = img;\n this._imgBitmap = null;\n\n if (img.src && img.complete) {\n if (img.naturalWidth) {\n this._promise = this._finishImage();\n } else {\n this._promise = Promise.reject('Image provided had failed to load.');\n }\n } else {\n this._promise = new Promise((resolve, reject) => {\n img.addEventListener('load', () => resolve(this._finishImage()));\n img.addEventListener('error', reject);\n });\n }\n }\n\n _finishImage() {\n if (window.createImageBitmap) {\n return window.createImageBitmap(this._img).then((imgBitmap) => {\n this._imgBitmap = imgBitmap;\n return Promise.resolve(this);\n });\n }\n return Promise.resolve(this);\n }\n\n get format() {\n // TODO: Can be RGB in some cases.\n return GL.RGBA;\n }\n\n get width() {\n return this._img.width;\n }\n\n get height() {\n return this._img.height;\n }\n\n waitForComplete() {\n return this._promise;\n }\n\n get textureKey() {\n return this._img.src;\n }\n\n get source() {\n return this._imgBitmap || this._img;\n }\n}\n\nexport class UrlTexture extends ImageTexture {\n constructor(url) {\n let img = new Image();\n super(img);\n img.src = url;\n }\n}\n\nexport class BlobTexture extends ImageTexture {\n constructor(blob) {\n let img = new Image();\n super(img);\n img.src = window.URL.createObjectURL(blob);\n }\n}\n\nexport class VideoTexture extends Texture {\n constructor(video) {\n super();\n\n this._video = video;\n\n if (video.readyState >= 2) {\n this._promise = Promise.resolve(this);\n } else if (video.error) {\n this._promise = Promise.reject(video.error);\n } else {\n this._promise = new Promise((resolve, reject) => {\n video.addEventListener('loadeddata', () => resolve(this));\n video.addEventListener('error', reject);\n });\n }\n }\n\n get format() {\n // TODO: Can be RGB in some cases.\n return GL.RGBA;\n }\n\n get width() {\n return this._video.videoWidth;\n }\n\n get height() {\n return this._video.videoHeight;\n }\n\n waitForComplete() {\n return this._promise;\n }\n\n get textureKey() {\n return this._video.src;\n }\n\n get source() {\n return this._video;\n }\n}\n\nlet nextDataTextureIndex = 0;\n\nexport class DataTexture extends Texture {\n constructor(data, width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE) {\n super();\n\n this._data = data;\n this._width = width;\n this._height = height;\n this._format = format;\n this._type = type;\n this._key = `DATA_${nextDataTextureIndex}`;\n nextDataTextureIndex++;\n }\n\n get format() {\n return this._format;\n }\n\n get width() {\n return this._width;\n }\n\n get height() {\n return this._height;\n }\n\n get textureKey() {\n return this._key;\n }\n}\n\nexport class ColorTexture extends DataTexture {\n constructor(r, g, b, a) {\n let colorData = new Uint8Array([r*255.0, g*255.0, b*255.0, a*255.0]);\n super(colorData, 1, 1);\n\n this.mipmap = false;\n this._key = `COLOR_${colorData[0]}_${colorData[1]}_${colorData[2]}_${colorData[3]}`;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nexport {Node} from './core/node.js';\nexport {Renderer, createWebGLContext} from './core/renderer.js';\nexport {UrlTexture} from './core/texture.js';\n\nexport {PrimitiveStream} from './geometry/primitive-stream.js';\nexport {BoxBuilder} from './geometry/box-builder.js';\n\nexport {PbrMaterial} from './materials/pbr.js';\n\nexport {mat4, mat3, vec3, vec4, quat} from './math/gl-matrix.js';\n\nexport {BoundsRenderer} from './nodes/bounds-renderer.js';\nexport {ButtonNode} from './nodes/button.js';\nexport {DropShadowNode} from './nodes/drop-shadow.js';\nexport {CubeSeaNode} from './nodes/cube-sea.js';\nexport {Gltf2Node} from './nodes/gltf2.js';\nexport {SkyboxNode} from './nodes/skybox.js';\nexport {VideoNode} from './nodes/video.js';\n\nexport {WebXRView, Scene} from './scenes/scene.js';\n\nexport {FallbackHelper} from './util/fallback-helper.js';\nexport {QueryArgs} from './util/query-args.js';\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {GeometryBuilderBase} from './primitive-stream.js';\n\nexport class BoxBuilder extends GeometryBuilderBase {\n pushBox(min, max) {\n let stream = this.primitiveStream;\n\n let w = max[0] - min[0];\n let h = max[1] - min[1];\n let d = max[2] - min[2];\n\n let wh = w * 0.5;\n let hh = h * 0.5;\n let dh = d * 0.5;\n\n let cx = min[0] + wh;\n let cy = min[1] + hh;\n let cz = min[2] + dh;\n\n stream.startGeometry();\n\n // Bottom\n let idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n // X Y Z U V NX NY NZ\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, 0.0, -1.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 0.0, -1.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 1.0, 0.0, 0.0, -1.0, 0.0);\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 0.0, 0.0, 0.0, -1.0, 0.0);\n\n // Top\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, 0.0, 1.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 0.0, 1.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 1.0, 1.0, 0.0, 1.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 0.0, 1.0, 0.0, 1.0, 0.0);\n\n // Left\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 1.0, 0.0, -1.0, 0.0, 0.0);\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 1.0, 1.0, -1.0, 0.0, 0.0);\n\n // Right\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 0.0, 0.0, 1.0, 0.0, 0.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 0.0, 1.0, 1.0, 0.0, 0.0);\n\n // Back\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+2, idx+1);\n stream.pushTriangle(idx, idx+3, idx+2);\n\n stream.pushVertex(-wh+cx, -hh+cy, -dh+cz, 1.0, 1.0, 0.0, 0.0, -1.0);\n stream.pushVertex(+wh+cx, -hh+cy, -dh+cz, 0.0, 1.0, 0.0, 0.0, -1.0);\n stream.pushVertex(+wh+cx, +hh+cy, -dh+cz, 0.0, 0.0, 0.0, 0.0, -1.0);\n stream.pushVertex(-wh+cx, +hh+cy, -dh+cz, 1.0, 0.0, 0.0, 0.0, -1.0);\n\n // Front\n idx = stream.nextVertexIndex;\n stream.pushTriangle(idx, idx+1, idx+2);\n stream.pushTriangle(idx, idx+2, idx+3);\n\n stream.pushVertex(-wh+cx, -hh+cy, +dh+cz, 0.0, 1.0, 0.0, 0.0, 1.0);\n stream.pushVertex(+wh+cx, -hh+cy, +dh+cz, 1.0, 1.0, 0.0, 0.0, 1.0);\n stream.pushVertex(+wh+cx, +hh+cy, +dh+cz, 1.0, 0.0, 0.0, 0.0, 1.0);\n stream.pushVertex(-wh+cx, +hh+cy, +dh+cz, 0.0, 0.0, 0.0, 0.0, 1.0);\n\n stream.endGeometry();\n }\n\n pushCube(center = [0, 0, 0], size = 1.0) {\n let hs = size * 0.5;\n this.pushBox([center[0] - hs, center[1] - hs, center[2] - hs],\n [center[0] + hs, center[1] + hs, center[2] + hs]);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {mat3, vec3} from '../math/gl-matrix.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst tempVec3 = vec3.create();\n\nexport class PrimitiveStream {\n constructor(options) {\n this._vertices = [];\n this._indices = [];\n\n this._geometryStarted = false;\n\n this._vertexOffset = 0;\n this._vertexIndex = 0;\n this._highIndex = 0;\n\n this._flipWinding = false;\n this._invertNormals = false;\n this._transform = null;\n this._normalTransform = null;\n this._min = null;\n this._max = null;\n }\n\n set flipWinding(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change flipWinding before ending the current geometry.`);\n }\n this._flipWinding = value;\n }\n\n get flipWinding() {\n this._flipWinding;\n }\n\n set invertNormals(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change invertNormals before ending the current geometry.`);\n }\n this._invertNormals = value;\n }\n\n get invertNormals() {\n this._invertNormals;\n }\n\n set transform(value) {\n if (this._geometryStarted) {\n throw new Error(`Cannot change transform before ending the current geometry.`);\n }\n this._transform = value;\n if (this._transform) {\n if (!this._normalTransform) {\n this._normalTransform = mat3.create();\n }\n mat3.fromMat4(this._normalTransform, this._transform);\n }\n }\n\n get transform() {\n this._transform;\n }\n\n startGeometry() {\n if (this._geometryStarted) {\n throw new Error(`Attempted to start a new geometry before the previous one was ended.`);\n }\n\n this._geometryStarted = true;\n this._vertexIndex = 0;\n this._highIndex = 0;\n }\n\n endGeometry() {\n if (!this._geometryStarted) {\n throw new Error(`Attempted to end a geometry before one was started.`);\n }\n\n if (this._highIndex >= this._vertexIndex) {\n throw new Error(`Geometry contains indices that are out of bounds.\n (Contains an index of ${this._highIndex} when the vertex count is ${this._vertexIndex})`);\n }\n\n this._geometryStarted = false;\n this._vertexOffset += this._vertexIndex;\n\n // TODO: Anything else need to be done to finish processing here?\n }\n\n pushVertex(x, y, z, u = 0, v = 0, nx = 0, ny = 0, nz = 1) {\n if (!this._geometryStarted) {\n throw new Error(`Cannot push vertices before calling startGeometry().`);\n }\n\n // Transform the incoming vertex if we have a transformation matrix\n if (this._transform) {\n tempVec3[0] = x;\n tempVec3[1] = y;\n tempVec3[2] = z;\n vec3.transformMat4(tempVec3, tempVec3, this._transform);\n x = tempVec3[0];\n y = tempVec3[1];\n z = tempVec3[2];\n\n tempVec3[0] = nx;\n tempVec3[1] = ny;\n tempVec3[2] = nz;\n vec3.transformMat3(tempVec3, tempVec3, this._normalTransform);\n nx = tempVec3[0];\n ny = tempVec3[1];\n nz = tempVec3[2];\n }\n\n if (this._invertNormals) {\n nx *= -1.0;\n ny *= -1.0;\n nz *= -1.0;\n }\n\n this._vertices.push(x, y, z, u, v, nx, ny, nz);\n\n if (this._min) {\n this._min[0] = Math.min(this._min[0], x);\n this._min[1] = Math.min(this._min[1], y);\n this._min[2] = Math.min(this._min[2], z);\n this._max[0] = Math.max(this._max[0], x);\n this._max[1] = Math.max(this._max[1], y);\n this._max[2] = Math.max(this._max[2], z);\n } else {\n this._min = vec3.fromValues(x, y, z);\n this._max = vec3.fromValues(x, y, z);\n }\n\n return this._vertexIndex++;\n }\n\n get nextVertexIndex() {\n return this._vertexIndex;\n }\n\n pushTriangle(idxA, idxB, idxC) {\n if (!this._geometryStarted) {\n throw new Error(`Cannot push triangles before calling startGeometry().`);\n }\n\n this._highIndex = Math.max(this._highIndex, idxA, idxB, idxC);\n\n idxA += this._vertexOffset;\n idxB += this._vertexOffset;\n idxC += this._vertexOffset;\n\n if (this._flipWinding) {\n this._indices.push(idxC, idxB, idxA);\n } else {\n this._indices.push(idxA, idxB, idxC);\n }\n }\n\n clear() {\n if (this._geometryStarted) {\n throw new Error(`Cannot clear before ending the current geometry.`);\n }\n\n this._vertices = [];\n this._indices = [];\n this._vertexOffset = 0;\n this._min = null;\n this._max = null;\n }\n\n finishPrimitive(renderer) {\n if (!this._vertexOffset) {\n throw new Error(`Attempted to call finishPrimitive() before creating any geometry.`);\n }\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(this._vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(this._indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 32, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 32, 12),\n new PrimitiveAttribute('NORMAL', vertexBuffer, 3, GL.FLOAT, 32, 20),\n ];\n\n let primitive = new Primitive(attribs, this._indices.length);\n primitive.setIndexBuffer(indexBuffer);\n primitive.setBounds(this._min, this._max);\n\n return primitive;\n }\n}\n\nexport class GeometryBuilderBase {\n constructor(primitiveStream) {\n if (primitiveStream) {\n this._stream = primitiveStream;\n } else {\n this._stream = new PrimitiveStream();\n }\n }\n\n set primitiveStream(value) {\n this._stream = value;\n }\n\n get primitiveStream() {\n return this._stream;\n }\n\n finishPrimitive(renderer) {\n return this._stream.finishPrimitive(renderer);\n }\n\n clear() {\n this._stream.clear();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {PbrMaterial} from '../materials/pbr.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {ImageTexture, ColorTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst GLB_MAGIC = 0x46546C67;\nconst CHUNK_TYPE = {\n JSON: 0x4E4F534A,\n BIN: 0x004E4942,\n};\n\nfunction isAbsoluteUri(uri) {\n let absRegEx = new RegExp('^'+window.location.protocol, 'i');\n return !!uri.match(absRegEx);\n}\n\nfunction isDataUri(uri) {\n let dataRegEx = /^data:/;\n return !!uri.match(dataRegEx);\n}\n\nfunction resolveUri(uri, baseUrl) {\n if (isAbsoluteUri(uri) || isDataUri(uri)) {\n return uri;\n }\n return baseUrl + uri;\n}\n\nfunction getComponentCount(type) {\n switch (type) {\n case 'SCALAR': return 1;\n case 'VEC2': return 2;\n case 'VEC3': return 3;\n case 'VEC4': return 4;\n default: return 0;\n }\n}\n\n/**\n * Gltf2SceneLoader\n * Loads glTF 2.0 scenes into a renderable node tree.\n */\n\nexport class Gltf2Loader {\n constructor(renderer) {\n this.renderer = renderer;\n this._gl = renderer._gl;\n }\n\n loadFromUrl(url) {\n return fetch(url)\n .then((response) => {\n let i = url.lastIndexOf('/');\n let baseUrl = (i !== 0) ? url.substring(0, i + 1) : '';\n\n if (url.endsWith('.gltf')) {\n return response.json().then((json) => {\n return this.loadFromJson(json, baseUrl);\n });\n } else if (url.endsWith('.glb')) {\n return response.arrayBuffer().then((arrayBuffer) => {\n return this.loadFromBinary(arrayBuffer, baseUrl);\n });\n } else {\n throw new Error('Unrecognized file extension');\n }\n });\n }\n\n loadFromBinary(arrayBuffer, baseUrl) {\n let headerView = new DataView(arrayBuffer, 0, 12);\n let magic = headerView.getUint32(0, true);\n let version = headerView.getUint32(4, true);\n let length = headerView.getUint32(8, true);\n\n if (magic != GLB_MAGIC) {\n throw new Error('Invalid magic string in binary header.');\n }\n\n if (version != 2) {\n throw new Error('Incompatible version in binary header.');\n }\n\n let chunks = {};\n let chunkOffset = 12;\n while (chunkOffset < length) {\n let chunkHeaderView = new DataView(arrayBuffer, chunkOffset, 8);\n let chunkLength = chunkHeaderView.getUint32(0, true);\n let chunkType = chunkHeaderView.getUint32(4, true);\n chunks[chunkType] = arrayBuffer.slice(chunkOffset + 8, chunkOffset + 8 + chunkLength);\n chunkOffset += chunkLength + 8;\n }\n\n if (!chunks[CHUNK_TYPE.JSON]) {\n throw new Error('File contained no json chunk.');\n }\n\n let decoder = new TextDecoder('utf-8');\n let jsonString = decoder.decode(chunks[CHUNK_TYPE.JSON]);\n let json = JSON.parse(jsonString);\n return this.loadFromJson(json, baseUrl, chunks[CHUNK_TYPE.BIN]);\n }\n\n loadFromJson(json, baseUrl, binaryChunk) {\n if (!json.asset) {\n throw new Error('Missing asset description.');\n }\n\n if (json.asset.minVersion != '2.0' && json.asset.version != '2.0') {\n throw new Error('Incompatible asset version.');\n }\n\n let buffers = [];\n if (binaryChunk) {\n buffers[0] = new Gltf2Resource({}, baseUrl, binaryChunk);\n } else {\n for (let buffer of json.buffers) {\n buffers.push(new Gltf2Resource(buffer, baseUrl));\n }\n }\n\n let bufferViews = [];\n for (let bufferView of json.bufferViews) {\n bufferViews.push(new Gltf2BufferView(bufferView, buffers));\n }\n\n let images = [];\n if (json.images) {\n for (let image of json.images) {\n images.push(new Gltf2Resource(image, baseUrl));\n }\n }\n\n let textures = [];\n if (json.textures) {\n for (let texture of json.textures) {\n let image = images[texture.source];\n let glTexture = image.texture(bufferViews);\n if (texture.sampler) {\n let sampler = sampler[texture.sampler];\n glTexture.sampler.minFilter = sampler.minFilter;\n glTexture.sampler.magFilter = sampler.magFilter;\n glTexture.sampler.wrapS = sampler.wrapS;\n glTexture.sampler.wrapT = sampler.wrapT;\n }\n textures.push(glTexture);\n }\n }\n\n function getTexture(textureInfo) {\n if (!textureInfo) {\n return null;\n }\n return textures[textureInfo.index];\n }\n\n let materials = [];\n if (json.materials) {\n for (let material of json.materials) {\n let glMaterial = new PbrMaterial();\n let pbr = material.pbrMetallicRoughness || {};\n\n glMaterial.baseColorFactor.value = pbr.baseColorFactor || [1, 1, 1, 1];\n glMaterial.baseColor.texture = getTexture(pbr.baseColorTexture);\n glMaterial.metallicRoughnessFactor.value = [\n pbr.metallicFactor || 1.0,\n pbr.roughnessFactor || 1.0,\n ];\n glMaterial.metallicRoughness.texture = getTexture(pbr.metallicRoughnessTexture);\n glMaterial.normal.texture = getTexture(json.normalTexture);\n glMaterial.occlusion.texture = getTexture(json.occlusionTexture);\n glMaterial.occlusionStrength.value = (json.occlusionTexture && json.occlusionTexture.strength) ?\n json.occlusionTexture.strength : 1.0;\n glMaterial.emissiveFactor.value = material.emissiveFactor || [0, 0, 0];\n glMaterial.emissive.texture = getTexture(json.emissiveTexture);\n if (!glMaterial.emissive.texture && json.emissiveFactor) {\n glMaterial.emissive.texture = new ColorTexture(1.0, 1.0, 1.0, 1.0);\n }\n\n switch (material.alphaMode) {\n case 'BLEND':\n glMaterial.state.blend = true;\n break;\n case 'MASK':\n // Not really supported.\n glMaterial.state.blend = true;\n break;\n default: // Includes 'OPAQUE'\n glMaterial.state.blend = false;\n }\n\n // glMaterial.alpha_mode = material.alphaMode;\n // glMaterial.alpha_cutoff = material.alphaCutoff;\n glMaterial.state.cullFace = !(material.doubleSided);\n\n materials.push(glMaterial);\n }\n }\n\n let accessors = json.accessors;\n\n let meshes = [];\n for (let mesh of json.meshes) {\n let glMesh = new Gltf2Mesh();\n meshes.push(glMesh);\n\n for (let primitive of mesh.primitives) {\n let material = null;\n if ('material' in primitive) {\n material = materials[primitive.material];\n } else {\n // Create a \"default\" material if the primitive has none.\n material = new PbrMaterial();\n }\n\n let attributes = [];\n let elementCount = 0;\n /* let glPrimitive = new Gltf2Primitive(primitive, material);\n glMesh.primitives.push(glPrimitive); */\n\n let min = null;\n let max = null;\n\n for (let name in primitive.attributes) {\n let accessor = accessors[primitive.attributes[name]];\n let bufferView = bufferViews[accessor.bufferView];\n elementCount = accessor.count;\n\n let glAttribute = new PrimitiveAttribute(\n name,\n bufferView.renderBuffer(this.renderer, GL.ARRAY_BUFFER),\n getComponentCount(accessor.type),\n accessor.componentType,\n bufferView.byteStride || 0,\n accessor.byteOffset || 0\n );\n glAttribute.normalized = accessor.normalized || false;\n\n if (name == 'POSITION') {\n min = accessor.min;\n max = accessor.max;\n }\n\n attributes.push(glAttribute);\n }\n\n let glPrimitive = new Primitive(attributes, elementCount, primitive.mode);\n\n if ('indices' in primitive) {\n let accessor = accessors[primitive.indices];\n let bufferView = bufferViews[accessor.bufferView];\n\n glPrimitive.setIndexBuffer(\n bufferView.renderBuffer(this.renderer, GL.ELEMENT_ARRAY_BUFFER),\n accessor.byteOffset || 0,\n accessor.componentType\n );\n glPrimitive.indexType = accessor.componentType;\n glPrimitive.indexByteOffset = accessor.byteOffset || 0;\n glPrimitive.elementCount = accessor.count;\n }\n\n if (min && max) {\n glPrimitive.setBounds(min, max);\n }\n\n // After all the attributes have been processed, get a program that is\n // appropriate for both the material and the primitive attributes.\n glMesh.primitives.push(\n this.renderer.createRenderPrimitive(glPrimitive, material));\n }\n }\n\n let sceneNode = new Node();\n let scene = json.scenes[json.scene];\n for (let nodeId of scene.nodes) {\n let node = json.nodes[nodeId];\n sceneNode.addNode(\n this.processNodes(node, json.nodes, meshes));\n }\n\n return sceneNode;\n }\n\n processNodes(node, nodes, meshes) {\n let glNode = new Node();\n glNode.name = node.name;\n\n if ('mesh' in node) {\n let mesh = meshes[node.mesh];\n for (let primitive of mesh.primitives) {\n glNode.addRenderPrimitive(primitive);\n }\n }\n\n if (node.matrix) {\n glNode.matrix = new Float32Array(node.matrix);\n } else if (node.translation || node.rotation || node.scale) {\n if (node.translation) {\n glNode.translation = new Float32Array(node.translation);\n }\n\n if (node.rotation) {\n glNode.rotation = new Float32Array(node.rotation);\n }\n\n if (node.scale) {\n glNode.scale = new Float32Array(node.scale);\n }\n }\n\n if (node.children) {\n for (let nodeId of node.children) {\n let node = nodes[nodeId];\n glNode.addNode(this.processNodes(node, nodes, meshes));\n }\n }\n\n return glNode;\n }\n}\n\nclass Gltf2Mesh {\n constructor() {\n this.primitives = [];\n }\n}\n\nclass Gltf2BufferView {\n constructor(json, buffers) {\n this.buffer = buffers[json.buffer];\n this.byteOffset = json.byteOffset || 0;\n this.byteLength = json.byteLength || null;\n this.byteStride = json.byteStride;\n\n this._viewPromise = null;\n this._renderBuffer = null;\n }\n\n dataView() {\n if (!this._viewPromise) {\n this._viewPromise = this.buffer.arrayBuffer().then((arrayBuffer) => {\n return new DataView(arrayBuffer, this.byteOffset, this.byteLength);\n });\n }\n return this._viewPromise;\n }\n\n renderBuffer(renderer, target) {\n if (!this._renderBuffer) {\n this._renderBuffer = renderer.createRenderBuffer(target, this.dataView());\n }\n return this._renderBuffer;\n }\n}\n\nclass Gltf2Resource {\n constructor(json, baseUrl, arrayBuffer) {\n this.json = json;\n this.baseUrl = baseUrl;\n\n this._dataPromise = null;\n this._texture = null;\n if (arrayBuffer) {\n this._dataPromise = Promise.resolve(arrayBuffer);\n }\n }\n\n arrayBuffer() {\n if (!this._dataPromise) {\n if (isDataUri(this.json.uri)) {\n let base64String = this.json.uri.replace('data:application/octet-stream;base64,', '');\n let binaryArray = Uint8Array.from(atob(base64String), (c) => c.charCodeAt(0));\n this._dataPromise = Promise.resolve(binaryArray.buffer);\n return this._dataPromise;\n }\n\n this._dataPromise = fetch(resolveUri(this.json.uri, this.baseUrl))\n .then((response) => response.arrayBuffer());\n }\n return this._dataPromise;\n }\n\n texture(bufferViews) {\n if (!this._texture) {\n let img = new Image();\n this._texture = new ImageTexture(img);\n\n if (this.json.uri) {\n if (isDataUri(this.json.uri)) {\n img.src = this.json.uri;\n } else {\n img.src = `${this.baseUrl}${this.json.uri}`;\n }\n } else {\n let view = bufferViews[this.json.bufferView];\n view.dataView().then((dataView) => {\n let blob = new Blob([dataView], {type: this.json.mimeType});\n img.src = window.URL.createObjectURL(blob);\n });\n }\n }\n return this._texture;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {ATTRIB_MASK} from '../core/renderer.js';\n\nconst VERTEX_SOURCE = `\nattribute vec3 POSITION, NORMAL;\nattribute vec2 TEXCOORD_0, TEXCOORD_1;\n\nuniform vec3 CAMERA_POSITION;\nuniform vec3 LIGHT_DIRECTION;\n\nvarying vec3 vLight; // Vector from vertex to light.\nvarying vec3 vView; // Vector from vertex to camera.\nvarying vec2 vTex;\n\n#ifdef USE_NORMAL_MAP\nattribute vec4 TANGENT;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_VERTEX_COLOR\nattribute vec4 COLOR_0;\nvarying vec4 vCol;\n#endif\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 n = normalize(vec3(model * vec4(NORMAL, 0.0)));\n#ifdef USE_NORMAL_MAP\n vec3 t = normalize(vec3(model * vec4(TANGENT.xyz, 0.0)));\n vec3 b = cross(n, t) * TANGENT.w;\n vTBN = mat3(t, b, n);\n#else\n vNorm = n;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n vCol = COLOR_0;\n#endif\n\n vTex = TEXCOORD_0;\n vec4 mPos = model * vec4(POSITION, 1.0);\n vLight = -LIGHT_DIRECTION;\n vView = CAMERA_POSITION - mPos.xyz;\n return proj * view * mPos;\n}`;\n\n// These equations are borrowed with love from this docs from Epic because I\n// just don't have anything novel to bring to the PBR scene.\n// http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\nconst EPIC_PBR_FUNCTIONS = `\nvec3 lambertDiffuse(vec3 cDiff) {\n return cDiff / M_PI;\n}\n\nfloat specD(float a, float nDotH) {\n float aSqr = a * a;\n float f = ((nDotH * nDotH) * (aSqr - 1.0) + 1.0);\n return aSqr / (M_PI * f * f);\n}\n\nfloat specG(float roughness, float nDotL, float nDotV) {\n float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\n float gl = nDotL / (nDotL * (1.0 - k) + k);\n float gv = nDotV / (nDotV * (1.0 - k) + k);\n return gl * gv;\n}\n\nvec3 specF(float vDotH, vec3 F0) {\n float exponent = (-5.55473 * vDotH - 6.98316) * vDotH;\n float base = 2.0;\n return F0 + (1.0 - F0) * pow(base, exponent);\n}`;\n\nconst FRAGMENT_SOURCE = `\n#define M_PI 3.14159265\n\nuniform vec4 baseColorFactor;\n#ifdef USE_BASE_COLOR_MAP\nuniform sampler2D baseColorTex;\n#endif\n\nvarying vec3 vLight;\nvarying vec3 vView;\nvarying vec2 vTex;\n\n#ifdef USE_VERTEX_COLOR\nvarying vec4 vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\nuniform sampler2D normalTex;\nvarying mat3 vTBN;\n#else\nvarying vec3 vNorm;\n#endif\n\n#ifdef USE_METAL_ROUGH_MAP\nuniform sampler2D metallicRoughnessTex;\n#endif\nuniform vec2 metallicRoughnessFactor;\n\n#ifdef USE_OCCLUSION\nuniform sampler2D occlusionTex;\nuniform float occlusionStrength;\n#endif\n\n#ifdef USE_EMISSIVE_TEXTURE\nuniform sampler2D emissiveTex;\n#endif\nuniform vec3 emissiveFactor;\n\nuniform vec3 LIGHT_COLOR;\n\nconst vec3 dielectricSpec = vec3(0.04);\nconst vec3 black = vec3(0.0);\n\n${EPIC_PBR_FUNCTIONS}\n\nvec4 fragment_main() {\n#ifdef USE_BASE_COLOR_MAP\n vec4 baseColor = texture2D(baseColorTex, vTex) * baseColorFactor;\n#else\n vec4 baseColor = baseColorFactor;\n#endif\n\n#ifdef USE_VERTEX_COLOR\n baseColor *= vCol;\n#endif\n\n#ifdef USE_NORMAL_MAP\n vec3 n = texture2D(normalTex, vTex).rgb;\n n = normalize(vTBN * (2.0 * n - 1.0));\n#else\n vec3 n = normalize(vNorm);\n#endif\n\n#ifdef FULLY_ROUGH\n float metallic = 0.0;\n#else\n float metallic = metallicRoughnessFactor.x;\n#endif\n\n float roughness = metallicRoughnessFactor.y;\n\n#ifdef USE_METAL_ROUGH_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessTex, vTex);\n metallic *= metallicRoughness.b;\n roughness *= metallicRoughness.g;\n#endif\n \n vec3 l = normalize(vLight);\n vec3 v = normalize(vView);\n vec3 h = normalize(l+v);\n\n float nDotL = clamp(dot(n, l), 0.001, 1.0);\n float nDotV = abs(dot(n, v)) + 0.001;\n float nDotH = max(dot(n, h), 0.0);\n float vDotH = max(dot(v, h), 0.0);\n\n // From GLTF Spec\n vec3 cDiff = mix(baseColor.rgb * (1.0 - dielectricSpec.r), black, metallic); // Diffuse color\n vec3 F0 = mix(dielectricSpec, baseColor.rgb, metallic); // Specular color\n float a = roughness * roughness;\n\n#ifdef FULLY_ROUGH\n vec3 specular = F0 * 0.45;\n#else\n vec3 F = specF(vDotH, F0);\n float D = specD(a, nDotH);\n float G = specG(roughness, nDotL, nDotV);\n vec3 specular = (D * F * G) / (4.0 * nDotL * nDotV);\n#endif\n float halfLambert = dot(n, l) * 0.5 + 0.5;\n halfLambert *= halfLambert;\n\n vec3 color = (halfLambert * LIGHT_COLOR * lambertDiffuse(cDiff)) + specular;\n\n#ifdef USE_OCCLUSION\n float occlusion = texture2D(occlusionTex, vTex).r;\n color = mix(color, color * occlusion, occlusionStrength);\n#endif\n \n vec3 emissive = emissiveFactor;\n#ifdef USE_EMISSIVE_TEXTURE\n emissive *= texture2D(emissiveTex, vTex).rgb;\n#endif\n color += emissive;\n\n // gamma correction\n //color = pow(color, vec3(1.0/2.2));\n\n return vec4(color, baseColor.a);\n}`;\n\nexport class PbrMaterial extends Material {\n constructor() {\n super();\n\n this.baseColor = this.defineSampler('baseColorTex');\n this.metallicRoughness = this.defineSampler('metallicRoughnessTex');\n this.normal = this.defineSampler('normalTex');\n this.occlusion = this.defineSampler('occlusionTex');\n this.emissive = this.defineSampler('emissiveTex');\n\n this.baseColorFactor = this.defineUniform('baseColorFactor', [1.0, 1.0, 1.0, 1.0]);\n this.metallicRoughnessFactor = this.defineUniform('metallicRoughnessFactor', [1.0, 1.0]);\n this.occlusionStrength = this.defineUniform('occlusionStrength', 1.0);\n this.emissiveFactor = this.defineUniform('emissiveFactor', [0, 0, 0]);\n }\n\n get materialName() {\n return 'PBR';\n }\n\n get vertexSource() {\n return VERTEX_SOURCE;\n }\n\n get fragmentSource() {\n return FRAGMENT_SOURCE;\n }\n\n getProgramDefines(renderPrimitive) {\n let programDefines = {};\n\n if (renderPrimitive._attributeMask & ATTRIB_MASK.COLOR_0) {\n programDefines['USE_VERTEX_COLOR'] = 1;\n }\n\n if (renderPrimitive._attributeMask & ATTRIB_MASK.TEXCOORD_0) {\n if (this.baseColor.texture) {\n programDefines['USE_BASE_COLOR_MAP'] = 1;\n }\n\n if (this.normal.texture && (renderPrimitive._attributeMask & ATTRIB_MASK.TANGENT)) {\n programDefines['USE_NORMAL_MAP'] = 1;\n }\n\n if (this.metallicRoughness.texture) {\n programDefines['USE_METAL_ROUGH_MAP'] = 1;\n }\n\n if (this.occlusion.texture) {\n programDefines['USE_OCCLUSION'] = 1;\n }\n\n if (this.emissive.texture) {\n programDefines['USE_EMISSIVE_TEXTURE'] = 1;\n }\n }\n\n if ((!this.metallicRoughness.texture ||\n !(renderPrimitive._attributeMask & ATTRIB_MASK.TEXCOORD_0)) &&\n this.metallicRoughnessFactor.value[1] == 1.0) {\n programDefines['FULLY_ROUGH'] = 1;\n }\n\n return programDefines;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport * as glMatrix from '../../node_modules/gl-matrix/src/gl-matrix/common.js';\nimport * as mat2 from '../../node_modules/gl-matrix/src/gl-matrix/mat2.js';\nimport * as mat2d from '../../node_modules/gl-matrix/src/gl-matrix/mat2d.js';\nimport * as mat3 from '../../node_modules/gl-matrix/src/gl-matrix/mat3.js';\nimport * as mat4 from '../../node_modules/gl-matrix/src/gl-matrix/mat4.js';\nimport * as quat from '../../node_modules/gl-matrix/src/gl-matrix/quat.js';\nimport * as quat2 from '../../node_modules/gl-matrix/src/gl-matrix/quat2.js';\nimport * as vec2 from '../../node_modules/gl-matrix/src/gl-matrix/vec2.js';\nimport * as vec3 from '../../node_modules/gl-matrix/src/gl-matrix/vec3.js';\nimport * as vec4 from '../../node_modules/gl-matrix/src/gl-matrix/vec4.js';\n\nexport {\n glMatrix,\n mat2,\n mat2d,\n mat3,\n mat4,\n quat,\n quat2,\n vec2,\n vec3,\n vec4,\n};\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nThis file renders a passed in XRStageBounds object and attempts\nto render geometry on the floor to indicate where the bounds is.\nXRStageBounds' `geometry` is a series of XRStageBoundsPoints (in\nclockwise-order) with `x` and `z` properties for each.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass BoundsMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n this.state.blendFuncSrc = GL.SRC_ALPHA;\n this.state.blendFuncDst = GL.ONE;\n this.state.depthTest = false;\n }\n\n get materialName() {\n return 'BOUNDS_RENDERER';\n }\n\n get vertexSource() {\n return `\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n\n vec4 fragment_main() {\n return vec4(0.0, 1.0, 0.0, 0.3);\n }`;\n }\n}\n\nexport class BoundsRenderer extends Node {\n constructor() {\n super();\n\n this._stageBounds = null;\n }\n\n onRendererChanged(renderer) {\n this.stageBounds = this._stageBounds;\n }\n\n get stageBounds() {\n return this._stageBounds;\n }\n\n set stageBounds(stageBounds) {\n if (this._stageBounds) {\n this.clearRenderPrimitives();\n }\n this._stageBounds = stageBounds;\n if (!stageBounds || stageBounds.length === 0 || !this._renderer) {\n return;\n }\n\n let verts = [];\n let indices = [];\n\n // Tessellate the bounding points from XRStageBounds and connect\n // each point to a neighbor and 0,0,0.\n const pointCount = stageBounds.geometry.length;\n for (let i = 0; i < pointCount; i++) {\n const point = stageBounds.geometry[i];\n verts.push(point.x, 0, point.z);\n indices.push(i, i === 0 ? pointCount - 1 : i - 1, pointCount);\n }\n // Center point\n verts.push(0, 0, 0);\n\n let vertexBuffer = this._renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(verts));\n let indexBuffer = this._renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 12, 0),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let renderPrimitive = this._renderer.createRenderPrimitive(primitive, new BoundsMaterial());\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {PrimitiveStream} from '../geometry/primitive-stream.js';\n\nconst BUTTON_SIZE = 0.1;\nconst BUTTON_CORNER_RADIUS = 0.025;\nconst BUTTON_CORNER_SEGMENTS = 8;\nconst BUTTON_ICON_SIZE = 0.07;\nconst BUTTON_LAYER_DISTANCE = 0.005;\nconst BUTTON_COLOR = 0.75;\nconst BUTTON_ALPHA = 0.85;\nconst BUTTON_HOVER_COLOR = 0.9;\nconst BUTTON_HOVER_ALPHA = 1.0;\nconst BUTTON_HOVER_SCALE = 1.1;\nconst BUTTON_HOVER_TRANSITION_TIME_MS = 200;\n\nclass ButtonMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n\n this.defineUniform('hoverAmount', 0);\n }\n\n get materialName() {\n return 'BUTTON_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n\n uniform float hoverAmount;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n float scale = mix(1.0, ${BUTTON_HOVER_SCALE}, hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform float hoverAmount;\n\n const vec4 default_color = vec4(${BUTTON_COLOR}, ${BUTTON_COLOR}, ${BUTTON_COLOR}, ${BUTTON_ALPHA});\n const vec4 hover_color = vec4(${BUTTON_HOVER_COLOR}, ${BUTTON_HOVER_COLOR},\n ${BUTTON_HOVER_COLOR}, ${BUTTON_HOVER_ALPHA});\n\n vec4 fragment_main() {\n return mix(default_color, hover_color, hoverAmount);\n }`;\n }\n}\n\nclass ButtonIconMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n\n this.defineUniform('hoverAmount', 0);\n this.icon = this.defineSampler('icon');\n }\n\n get materialName() {\n return 'BUTTON_ICON_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n uniform float hoverAmount;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n float scale = mix(1.0, ${BUTTON_HOVER_SCALE}, hoverAmount);\n vec4 pos = vec4(POSITION.x * scale, POSITION.y * scale, POSITION.z * (scale + (hoverAmount * 0.2)), 1.0);\n return proj * view * model * pos;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D icon;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(icon, vTexCoord);\n }`;\n }\n}\n\nexport class ButtonNode extends Node {\n constructor(iconTexture, callback) {\n super();\n\n // All buttons are selectable by default.\n this.selectable = true;\n\n this._selectHandler = callback;\n this._iconTexture = iconTexture;\n this._hovered = false;\n this._hoverT = 0;\n }\n\n get iconTexture() {\n return this._iconTexture;\n }\n\n set iconTexture(value) {\n if (this._iconTexture == value) {\n return;\n }\n\n this._iconTexture = value;\n this._iconRenderPrimitive.samplers.icon.texture = value;\n }\n\n onRendererChanged(renderer) {\n let stream = new PrimitiveStream();\n\n let hd = BUTTON_LAYER_DISTANCE * 0.5;\n\n // Build a rounded rect for the background.\n let hs = BUTTON_SIZE * 0.5;\n let ihs = hs - BUTTON_CORNER_RADIUS;\n stream.startGeometry();\n\n // Rounded corners and sides\n let segments = BUTTON_CORNER_SEGMENTS * 4;\n for (let i = 0; i < segments; ++i) {\n let rad = i * ((Math.PI * 2.0) / segments);\n let x = Math.cos(rad) * BUTTON_CORNER_RADIUS;\n let y = Math.sin(rad) * BUTTON_CORNER_RADIUS;\n let section = Math.floor(i / BUTTON_CORNER_SEGMENTS);\n switch (section) {\n case 0:\n x += ihs;\n y += ihs;\n break;\n case 1:\n x -= ihs;\n y += ihs;\n break;\n case 2:\n x -= ihs;\n y -= ihs;\n break;\n case 3:\n x += ihs;\n y -= ihs;\n break;\n }\n\n stream.pushVertex(x, y, -hd, 0, 0, 0, 0, 1);\n\n if (i > 1) {\n stream.pushTriangle(0, i-1, i);\n }\n }\n\n stream.endGeometry();\n\n let buttonPrimitive = stream.finishPrimitive(renderer);\n this._buttonRenderPrimitive = renderer.createRenderPrimitive(buttonPrimitive, new ButtonMaterial());\n this.addRenderPrimitive(this._buttonRenderPrimitive);\n\n // Build a simple textured quad for the foreground.\n hs = BUTTON_ICON_SIZE * 0.5;\n stream.clear();\n stream.startGeometry();\n\n stream.pushVertex(-hs, hs, hd, 0, 0, 0, 0, 1);\n stream.pushVertex(-hs, -hs, hd, 0, 1, 0, 0, 1);\n stream.pushVertex(hs, -hs, hd, 1, 1, 0, 0, 1);\n stream.pushVertex(hs, hs, hd, 1, 0, 0, 0, 1);\n\n stream.pushTriangle(0, 1, 2);\n stream.pushTriangle(0, 2, 3);\n\n stream.endGeometry();\n\n let iconPrimitive = stream.finishPrimitive(renderer);\n let iconMaterial = new ButtonIconMaterial();\n iconMaterial.icon.texture = this._iconTexture;\n this._iconRenderPrimitive = renderer.createRenderPrimitive(iconPrimitive, iconMaterial);\n this.addRenderPrimitive(this._iconRenderPrimitive);\n }\n\n onHoverStart() {\n this._hovered = true;\n }\n\n onHoverEnd() {\n this._hovered = false;\n }\n\n _updateHoverState() {\n let t = this._hoverT / BUTTON_HOVER_TRANSITION_TIME_MS;\n // Cubic Ease In/Out\n // TODO: Get a better animation system\n let hoverAmount = t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1;\n this._buttonRenderPrimitive.uniforms.hoverAmount.value = hoverAmount;\n this._iconRenderPrimitive.uniforms.hoverAmount.value = hoverAmount;\n }\n\n onUpdate(timestamp, frameDelta) {\n if (this._hovered && this._hoverT < BUTTON_HOVER_TRANSITION_TIME_MS) {\n this._hoverT = Math.min(BUTTON_HOVER_TRANSITION_TIME_MS, this._hoverT + frameDelta);\n this._updateHoverState();\n } else if (!this._hovered && this._hoverT > 0) {\n this._hoverT = Math.max(0.0, this._hoverT - frameDelta);\n this._updateHoverState();\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {UrlTexture} from '../core/texture.js';\nimport {BoxBuilder} from '../geometry/box-builder.js';\nimport {mat4} from '../math/gl-matrix.js';\n\nclass CubeSeaMaterial extends Material {\n constructor(heavy = false) {\n super();\n\n this.heavy = heavy;\n\n this.baseColor = this.defineSampler('baseColor');\n }\n\n get materialName() {\n return 'CUBE_SEA';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n attribute vec3 NORMAL;\n\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n const vec3 lightDir = vec3(0.75, 0.5, 1.0);\n const vec3 ambientColor = vec3(0.5, 0.5, 0.5);\n const vec3 lightColor = vec3(0.75, 0.75, 0.75);\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec3 normalRotated = vec3(model * vec4(NORMAL, 0.0));\n float lightFactor = max(dot(normalize(lightDir), normalRotated), 0.0);\n vLight = ambientColor + (lightColor * lightFactor);\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n if (!this.heavy) {\n return `\n precision mediump float;\n uniform sampler2D baseColor;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec4 fragment_main() {\n return vec4(vLight, 1.0) * texture2D(baseColor, vTexCoord);\n }`;\n } else {\n // Used when we want to stress the GPU a bit more.\n // Stolen with love from https://www.clicktorelease.com/code/codevember-2016/4/\n return `\n precision mediump float;\n\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n varying vec3 vLight;\n\n vec2 dimensions = vec2(64, 64);\n float seed = 0.42;\n\n vec2 hash( vec2 p ) {\n p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));\n return fract(sin(p)*18.5453);\n }\n\n vec3 hash3( vec2 p ) {\n vec3 q = vec3( dot(p,vec2(127.1,311.7)),\n dot(p,vec2(269.5,183.3)),\n dot(p,vec2(419.2,371.9)) );\n return fract(sin(q)*43758.5453);\n }\n\n float iqnoise( in vec2 x, float u, float v ) {\n vec2 p = floor(x);\n vec2 f = fract(x);\n float k = 1.0+63.0*pow(1.0-v,4.0);\n float va = 0.0;\n float wt = 0.0;\n for( int j=-2; j<=2; j++ )\n for( int i=-2; i<=2; i++ ) {\n vec2 g = vec2( float(i),float(j) );\n vec3 o = hash3( p + g )*vec3(u,u,1.0);\n vec2 r = g - f + o.xy;\n float d = dot(r,r);\n float ww = pow( 1.0-smoothstep(0.0,1.414,sqrt(d)), k );\n va += o.z*ww;\n wt += ww;\n }\n return va/wt;\n }\n\n // return distance, and cell id\n vec2 voronoi( in vec2 x ) {\n vec2 n = floor( x );\n vec2 f = fract( x );\n vec3 m = vec3( 8.0 );\n for( int j=-1; j<=1; j++ )\n for( int i=-1; i<=1; i++ ) {\n vec2 g = vec2( float(i), float(j) );\n vec2 o = hash( n + g );\n vec2 r = g - f + (0.5+0.5*sin(seed+6.2831*o));\n float d = dot( r, r );\n if( d<m.x )\n m = vec3( d, o );\n }\n return vec2( sqrt(m.x), m.y+m.z );\n }\n\n vec4 fragment_main() {\n vec2 uv = ( vTexCoord );\n uv *= vec2( 10., 10. );\n uv += seed;\n vec2 p = 0.5 - 0.5*sin( 0.*vec2(1.01,1.71) );\n\n vec2 c = voronoi( uv );\n vec3 col = vec3( c.y / 2. );\n\n float f = iqnoise( 1. * uv + c.y, p.x, p.y );\n col *= 1.0 + .25 * vec3( f );\n\n return vec4(vLight, 1.0) * texture2D(diffuse, vTexCoord) * vec4( col, 1. );\n }`;\n }\n }\n}\n\nexport class CubeSeaNode extends Node {\n constructor(options = {}) {\n super();\n\n // Test variables\n // If true, use a very heavyweight shader to stress the GPU.\n this.heavyGpu = !!options.heavyGpu;\n\n // Number and size of the static cubes. Warning, large values\n // don't render right due to overflow of the int16 indices.\n this.cubeCount = options.cubeCount || (this.heavyGpu ? 12 : 10);\n this.cubeScale = options.cubeScale || 1.0;\n\n // Draw only half the world cubes. Helps test variable render cost\n // when combined with heavyGpu.\n this.halfOnly = !!options.halfOnly;\n\n // Automatically spin the world cubes. Intended for automated testing,\n // not recommended for viewing in a headset.\n this.autoRotate = !!options.autoRotate;\n\n this._texture = new UrlTexture(options.imageUrl || 'media/textures/cube-sea.png');\n\n this._material = new CubeSeaMaterial(this.heavyGpu);\n this._material.baseColor.texture = this._texture;\n\n this._renderPrimitive = null;\n }\n\n onRendererChanged(renderer) {\n this._renderPrimitive = null;\n\n let boxBuilder = new BoxBuilder();\n\n // Build the spinning \"hero\" cubes\n boxBuilder.pushCube([0, 0.25, -0.8], 0.1);\n boxBuilder.pushCube([0.8, 0.25, 0], 0.1);\n boxBuilder.pushCube([0, 0.25, 0.8], 0.1);\n boxBuilder.pushCube([-0.8, 0.25, 0], 0.1);\n\n let heroPrimitive = boxBuilder.finishPrimitive(renderer);\n\n this.heroNode = renderer.createMesh(heroPrimitive, this._material);\n\n this.rebuildCubes(boxBuilder);\n\n this.cubeSeaNode = new Node();\n this.cubeSeaNode.addRenderPrimitive(this._renderPrimitive);\n\n this.addNode(this.cubeSeaNode);\n this.addNode(this.heroNode);\n\n return this.waitForComplete();\n }\n\n rebuildCubes(boxBuilder) {\n if (!this._renderer) {\n return;\n }\n\n if (!boxBuilder) {\n boxBuilder = new BoxBuilder();\n } else {\n boxBuilder.clear();\n }\n\n let size = 0.4 * this.cubeScale;\n\n // Build the cube sea\n let halfGrid = this.cubeCount * 0.5;\n for (let x = 0; x < this.cubeCount; ++x) {\n for (let y = 0; y < this.cubeCount; ++y) {\n for (let z = 0; z < this.cubeCount; ++z) {\n let pos = [x - halfGrid, y - halfGrid, z - halfGrid];\n // Only draw cubes on one side. Useful for testing variable render\n // cost that depends on view direction.\n if (this.halfOnly && pos[0] < 0) {\n continue;\n }\n\n // Don't place a cube in the center of the grid.\n if (pos[0] == 0 && pos[1] == 0 && pos[2] == 0) {\n continue;\n }\n\n boxBuilder.pushCube(pos, size);\n }\n }\n }\n\n if (this.cubeCount > 12) {\n // Each cube has 6 sides with 2 triangles and 3 indices per triangle, so\n // the total number of indices needed is cubeCount^3 * 36. This exceeds\n // the short index range past 12 cubes.\n boxBuilder.indexType = 5125; // gl.UNSIGNED_INT\n }\n let cubeSeaPrimitive = boxBuilder.finishPrimitive(this._renderer);\n\n if (!this._renderPrimitive) {\n this._renderPrimitive = this._renderer.createRenderPrimitive(cubeSeaPrimitive, this._material);\n } else {\n this._renderPrimitive.setPrimitive(cubeSeaPrimitive);\n }\n }\n\n onUpdate(timestamp, frameDelta) {\n if (this.autoRotate) {\n mat4.fromRotation(this.cubeSeaNode.matrix, timestamp / 500, [0, -1, 0]);\n }\n mat4.fromRotation(this.heroNode.matrix, timestamp / 2000, [0, 1, 0]);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {PrimitiveStream} from '../geometry/primitive-stream.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nconst SHADOW_SEGMENTS = 32;\nconst SHADOW_GROUND_OFFSET = 0.01;\nconst SHADOW_CENTER_ALPHA = 0.7;\nconst SHADOW_INNER_ALPHA = 0.3;\nconst SHADOW_OUTER_ALPHA = 0.0;\nconst SHADOW_INNER_RADIUS = 0.6;\nconst SHADOW_OUTER_RADIUS = 1.0;\n\nclass DropShadowMaterial extends Material {\n constructor() {\n super();\n\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.blendFuncDst = GL.ONE_MINUS_SRC_ALPHA;\n this.state.depthFunc = GL.LEQUAL;\n this.state.depthMask = false;\n }\n\n get materialName() {\n return 'DROP_SHADOW_MATERIAL';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying float vShadow;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vShadow = TEXCOORD_0.x;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n varying float vShadow;\n\n vec4 fragment_main() {\n return vec4(0.0, 0.0, 0.0, vShadow);\n }`;\n }\n}\n\nexport class DropShadowNode extends Node {\n constructor(iconTexture, callback) {\n super();\n }\n\n onRendererChanged(renderer) {\n let stream = new PrimitiveStream();\n\n stream.startGeometry();\n\n // Shadow center\n stream.pushVertex(0, SHADOW_GROUND_OFFSET, 0, SHADOW_CENTER_ALPHA);\n\n let segRad = ((Math.PI * 2.0) / SHADOW_SEGMENTS);\n\n let idx;\n for (let i = 0; i < SHADOW_SEGMENTS; ++i) {\n idx = stream.nextVertexIndex;\n\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n stream.pushVertex(x * SHADOW_INNER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_INNER_RADIUS, SHADOW_INNER_ALPHA);\n stream.pushVertex(x * SHADOW_OUTER_RADIUS, SHADOW_GROUND_OFFSET, y * SHADOW_OUTER_RADIUS, SHADOW_OUTER_ALPHA);\n\n if (i > 0) {\n // Inner circle\n stream.pushTriangle(0, idx, idx-2);\n\n // Outer circle\n stream.pushTriangle(idx, idx+1, idx-1);\n stream.pushTriangle(idx, idx-1, idx-2);\n }\n }\n\n stream.pushTriangle(0, 1, idx);\n\n stream.pushTriangle(1, 2, idx+1);\n stream.pushTriangle(1, idx+1, idx);\n\n stream.endGeometry();\n\n let shadowPrimitive = stream.finishPrimitive(renderer);\n this._shadowRenderPrimitive = renderer.createRenderPrimitive(shadowPrimitive, new DropShadowMaterial());\n this.addRenderPrimitive(this._shadowRenderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Node} from '../core/node.js';\nimport {Gltf2Loader} from '../loaders/gltf2.js';\n\n// Using a weak map here allows us to cache a loader per-renderer without\n// modifying the renderer object or leaking memory when it's garbage collected.\nlet gltfLoaderMap = new WeakMap();\n\nexport class Gltf2Node extends Node {\n constructor(options) {\n super();\n this._url = options.url;\n\n this._promise = null;\n this._resolver = null;\n this._rejecter = null;\n }\n\n onRendererChanged(renderer) {\n let loader = gltfLoaderMap.get(renderer);\n if (!loader) {\n loader = new Gltf2Loader(renderer);\n gltfLoaderMap.set(renderer, loader);\n }\n\n // Do we have a previously resolved promise? If so clear it.\n if (!this._resolver && this._promise) {\n this._promise = null;\n }\n\n this._ensurePromise();\n\n loader.loadFromUrl(this._url).then((sceneNode) => {\n this.addNode(sceneNode);\n this._resolver(sceneNode.waitForComplete());\n this._resolver = null;\n this._rejecter = null;\n }).catch((err) => {\n this._rejecter(err);\n this._resolver = null;\n this._rejecter = null;\n });\n }\n\n _ensurePromise() {\n if (!this._promise) {\n this._promise = new Promise((resolve, reject) => {\n this._resolver = resolve;\n this._rejecter = reject;\n });\n }\n return this._promise;\n }\n\n waitForComplete() {\n return this._ensurePromise();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {Material, RENDER_ORDER} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {DataTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\n// Laser texture data, 48x1 RGBA (not premultiplied alpha). This represents a\n// \"cross section\" of the laser beam with a bright core and a feathered edge.\n// Borrowed from Chromium source code.\nconst LASER_TEXTURE_DATA = new Uint8Array([\n0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x02, 0xbf, 0xbf, 0xbf, 0x04, 0xcc, 0xcc, 0xcc, 0x05,\n0xdb, 0xdb, 0xdb, 0x07, 0xcc, 0xcc, 0xcc, 0x0a, 0xd8, 0xd8, 0xd8, 0x0d, 0xd2, 0xd2, 0xd2, 0x11,\n0xce, 0xce, 0xce, 0x15, 0xce, 0xce, 0xce, 0x1a, 0xce, 0xce, 0xce, 0x1f, 0xcd, 0xcd, 0xcd, 0x24,\n0xc8, 0xc8, 0xc8, 0x2a, 0xc9, 0xc9, 0xc9, 0x2f, 0xc9, 0xc9, 0xc9, 0x34, 0xc9, 0xc9, 0xc9, 0x39,\n0xc9, 0xc9, 0xc9, 0x3d, 0xc8, 0xc8, 0xc8, 0x41, 0xcb, 0xcb, 0xcb, 0x44, 0xee, 0xee, 0xee, 0x87,\n0xfa, 0xfa, 0xfa, 0xc8, 0xf9, 0xf9, 0xf9, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xfa, 0xfa, 0xfa, 0xc9,\n0xfa, 0xfa, 0xfa, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xf9, 0xf9, 0xf9, 0xc9, 0xfa, 0xfa, 0xfa, 0xc8,\n0xee, 0xee, 0xee, 0x87, 0xcb, 0xcb, 0xcb, 0x44, 0xc8, 0xc8, 0xc8, 0x41, 0xc9, 0xc9, 0xc9, 0x3d,\n0xc9, 0xc9, 0xc9, 0x39, 0xc9, 0xc9, 0xc9, 0x34, 0xc9, 0xc9, 0xc9, 0x2f, 0xc8, 0xc8, 0xc8, 0x2a,\n0xcd, 0xcd, 0xcd, 0x24, 0xce, 0xce, 0xce, 0x1f, 0xce, 0xce, 0xce, 0x1a, 0xce, 0xce, 0xce, 0x15,\n0xd2, 0xd2, 0xd2, 0x11, 0xd8, 0xd8, 0xd8, 0x0d, 0xcc, 0xcc, 0xcc, 0x0a, 0xdb, 0xdb, 0xdb, 0x07,\n0xcc, 0xcc, 0xcc, 0x05, 0xbf, 0xbf, 0xbf, 0x04, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x01,\n]);\n\nconst LASER_LENGTH = 1.0;\nconst LASER_DIAMETER = 0.01;\nconst LASER_FADE_END = 0.535;\nconst LASER_FADE_POINT = 0.5335;\nconst LASER_DEFAULT_COLOR = [1.0, 1.0, 1.0, 0.25];\n\nconst CURSOR_RADIUS = 0.004;\nconst CURSOR_SHADOW_RADIUS = 0.007;\nconst CURSOR_SHADOW_INNER_LUMINANCE = 0.5;\nconst CURSOR_SHADOW_OUTER_LUMINANCE = 0.0;\nconst CURSOR_SHADOW_INNER_OPACITY = 0.75;\nconst CURSOR_SHADOW_OUTER_OPACITY = 0.0;\nconst CURSOR_OPACITY = 0.9;\nconst CURSOR_SEGMENTS = 16;\nconst CURSOR_DEFAULT_COLOR = [1.0, 1.0, 1.0, 1.0];\nconst CURSOR_DEFAULT_HIDDEN_COLOR = [0.5, 0.5, 0.5, 0.25];\n\nconst DEFAULT_RESET_OPTIONS = {\n controllers: true,\n lasers: true,\n cursors: true,\n};\n\nclass LaserMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.blendFuncDst = GL.ONE;\n this.state.depthMask = false;\n\n this.laser = this.defineSampler('diffuse');\n this.laser.texture = new DataTexture(LASER_TEXTURE_DATA, 48, 1);\n this.laserColor = this.defineUniform('laserColor', LASER_DEFAULT_COLOR);\n }\n\n get materialName() {\n return 'INPUT_LASER';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vTexCoord = TEXCOORD_0;\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n\n uniform vec4 laserColor;\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n const float fadePoint = ${LASER_FADE_POINT};\n const float fadeEnd = ${LASER_FADE_END};\n\n vec4 fragment_main() {\n vec2 uv = vTexCoord;\n float front_fade_factor = 1.0 - clamp(1.0 - (uv.y - fadePoint) / (1.0 - fadePoint), 0.0, 1.0);\n float back_fade_factor = clamp((uv.y - fadePoint) / (fadeEnd - fadePoint), 0.0, 1.0);\n vec4 color = laserColor * texture2D(diffuse, vTexCoord);\n float opacity = color.a * front_fade_factor * back_fade_factor;\n return vec4(color.rgb * opacity, opacity);\n }`;\n }\n}\n\nconst CURSOR_VERTEX_SHADER = `\nattribute vec4 POSITION;\n\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vLuminance = POSITION.z;\n vOpacity = POSITION.w;\n\n // Billboarded, constant size vertex transform.\n vec4 screenPos = proj * view * model * vec4(0.0, 0.0, 0.0, 1.0);\n screenPos /= screenPos.w;\n screenPos.xy += POSITION.xy;\n return screenPos;\n}`;\n\nconst CURSOR_FRAGMENT_SHADER = `\nprecision mediump float;\n\nuniform vec4 cursorColor;\nvarying float vLuminance;\nvarying float vOpacity;\n\nvec4 fragment_main() {\n vec3 color = cursorColor.rgb * vLuminance;\n float opacity = cursorColor.a * vOpacity;\n return vec4(color * opacity, opacity);\n}`;\n\n// Cursors are drawn as billboards that always face the camera and are rendered\n// as a fixed size no matter how far away they are.\nclass CursorMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.depthMask = false;\n\n this.cursorColor = this.defineUniform('cursorColor', CURSOR_DEFAULT_COLOR);\n }\n\n get materialName() {\n return 'INPUT_CURSOR';\n }\n\n get vertexSource() {\n return CURSOR_VERTEX_SHADER;\n }\n\n get fragmentSource() {\n return CURSOR_FRAGMENT_SHADER;\n }\n}\n\nclass CursorHiddenMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.ADDITIVE;\n this.state.cullFace = false;\n this.state.blend = true;\n this.state.blendFuncSrc = GL.ONE;\n this.state.depthFunc = GL.GEQUAL;\n this.state.depthMask = false;\n\n this.cursorColor = this.defineUniform('cursorColor', CURSOR_DEFAULT_HIDDEN_COLOR);\n }\n\n // TODO: Rename to \"program_name\"\n get materialName() {\n return 'INPUT_CURSOR_2';\n }\n\n get vertexSource() {\n return CURSOR_VERTEX_SHADER;\n }\n\n get fragmentSource() {\n return CURSOR_FRAGMENT_SHADER;\n }\n}\n\nexport class InputRenderer extends Node {\n constructor() {\n super();\n\n this._maxInputElements = 32;\n\n this._controllers = [];\n this._controllerNode = null;\n this._controllerNodeHandedness = null;\n this._lasers = null;\n this._cursors = null;\n\n this._activeControllers = 0;\n this._activeLasers = 0;\n this._activeCursors = 0;\n }\n\n onRendererChanged(renderer) {\n this._controllers = [];\n this._controllerNode = null;\n this._controllerNodeHandedness = null;\n this._lasers = null;\n this._cursors = null;\n\n this._activeControllers = 0;\n this._activeLasers = 0;\n this._activeCursors = 0;\n }\n\n setControllerMesh(controllerNode, handedness = 'right') {\n this._controllerNode = controllerNode;\n this._controllerNode.visible = false;\n // FIXME: Temporary fix to initialize for cloning.\n this.addNode(this._controllerNode);\n this._controllerNodeHandedness = handedness;\n }\n\n addController(gripMatrix) {\n if (!this._controllerNode) {\n return;\n }\n\n let controller = null;\n if (this._activeControllers < this._controllers.length) {\n controller = this._controllers[this._activeControllers];\n } else {\n controller = this._controllerNode.clone();\n this.addNode(controller);\n this._controllers.push(controller);\n }\n this._activeControllers = (this._activeControllers + 1) % this._maxInputElements;\n\n controller.matrix = gripMatrix;\n controller.visible = true;\n }\n\n addLaserPointer(targetRay) {\n // Create the laser pointer mesh if needed.\n if (!this._lasers && this._renderer) {\n this._lasers = [this._createLaserMesh()];\n this.addNode(this._lasers[0]);\n }\n\n let laser = null;\n if (this._activeLasers < this._lasers.length) {\n laser = this._lasers[this._activeLasers];\n } else {\n laser = this._lasers[0].clone();\n this.addNode(laser);\n this._lasers.push(laser);\n }\n this._activeLasers = (this._activeLasers + 1) % this._maxInputElements;\n\n laser.matrix = targetRay.transformMatrix;\n laser.visible = true;\n }\n\n addCursor(cursorPos) {\n // Create the cursor mesh if needed.\n if (!this._cursors && this._renderer) {\n this._cursors = [this._createCursorMesh()];\n this.addNode(this._cursors[0]);\n }\n\n let cursor = null;\n if (this._activeCursors < this._cursors.length) {\n cursor = this._cursors[this._activeCursors];\n } else {\n cursor = this._cursors[0].clone();\n this.addNode(cursor);\n this._cursors.push(cursor);\n }\n this._activeCursors = (this._activeCursors + 1) % this._maxInputElements;\n\n cursor.translation = cursorPos;\n cursor.visible = true;\n }\n\n reset(options) {\n if (!options) {\n options = DEFAULT_RESET_OPTIONS;\n }\n if (this._controllers && options.controllers) {\n for (let controller of this._controllers) {\n controller.visible = false;\n }\n this._activeControllers = 0;\n }\n if (this._lasers && options.lasers) {\n for (let laser of this._lasers) {\n laser.visible = false;\n }\n this._activeLasers = 0;\n }\n if (this._cursors && options.cursors) {\n for (let cursor of this._cursors) {\n cursor.visible = false;\n }\n this._activeCursors = 0;\n }\n }\n\n _createLaserMesh() {\n let gl = this._renderer._gl;\n\n let lr = LASER_DIAMETER * 0.5;\n let ll = LASER_LENGTH;\n\n // Laser is rendered as cross-shaped beam\n let laserVerts = [\n // X Y Z U V\n 0.0, lr, 0.0, 0.0, 1.0,\n 0.0, lr, -ll, 0.0, 0.0,\n 0.0, -lr, 0.0, 1.0, 1.0,\n 0.0, -lr, -ll, 1.0, 0.0,\n\n lr, 0.0, 0.0, 0.0, 1.0,\n lr, 0.0, -ll, 0.0, 0.0,\n -lr, 0.0, 0.0, 1.0, 1.0,\n -lr, 0.0, -ll, 1.0, 0.0,\n\n 0.0, -lr, 0.0, 0.0, 1.0,\n 0.0, -lr, -ll, 0.0, 0.0,\n 0.0, lr, 0.0, 1.0, 1.0,\n 0.0, lr, -ll, 1.0, 0.0,\n\n -lr, 0.0, 0.0, 0.0, 1.0,\n -lr, 0.0, -ll, 0.0, 0.0,\n lr, 0.0, 0.0, 1.0, 1.0,\n lr, 0.0, -ll, 1.0, 0.0,\n ];\n let laserIndices = [\n 0, 1, 2, 1, 3, 2,\n 4, 5, 6, 5, 7, 6,\n 8, 9, 10, 9, 11, 10,\n 12, 13, 14, 13, 15, 14,\n ];\n\n let laserVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(laserVerts));\n let laserIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(laserIndices));\n\n let laserIndexCount = laserIndices.length;\n\n let laserAttribs = [\n new PrimitiveAttribute('POSITION', laserVertexBuffer, 3, gl.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', laserVertexBuffer, 2, gl.FLOAT, 20, 12),\n ];\n\n let laserPrimitive = new Primitive(laserAttribs, laserIndexCount);\n laserPrimitive.setIndexBuffer(laserIndexBuffer);\n\n let laserMaterial = new LaserMaterial();\n\n let laserRenderPrimitive = this._renderer.createRenderPrimitive(laserPrimitive, laserMaterial);\n let meshNode = new Node();\n meshNode.addRenderPrimitive(laserRenderPrimitive);\n return meshNode;\n }\n\n _createCursorMesh() {\n let gl = this._renderer._gl;\n\n // Cursor is a circular white dot with a dark \"shadow\" skirt around the edge\n // that fades from black to transparent as it moves out from the center.\n // Cursor verts are packed as [X, Y, Luminance, Opacity]\n let cursorVerts = [];\n let cursorIndices = [];\n\n let segRad = (2.0 * Math.PI) / CURSOR_SEGMENTS;\n\n // Cursor center\n for (let i = 0; i < CURSOR_SEGMENTS; ++i) {\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n cursorVerts.push(x * CURSOR_RADIUS, y * CURSOR_RADIUS, 1.0, CURSOR_OPACITY);\n\n if (i > 1) {\n cursorIndices.push(0, i-1, i);\n }\n }\n\n let indexOffset = CURSOR_SEGMENTS;\n\n // Cursor Skirt\n for (let i = 0; i < CURSOR_SEGMENTS; ++i) {\n let rad = i * segRad;\n let x = Math.cos(rad);\n let y = Math.sin(rad);\n cursorVerts.push(x * CURSOR_RADIUS, y * CURSOR_RADIUS,\n CURSOR_SHADOW_INNER_LUMINANCE, CURSOR_SHADOW_INNER_OPACITY);\n cursorVerts.push(x * CURSOR_SHADOW_RADIUS, y * CURSOR_SHADOW_RADIUS,\n CURSOR_SHADOW_OUTER_LUMINANCE, CURSOR_SHADOW_OUTER_OPACITY);\n\n if (i > 0) {\n let idx = indexOffset + (i * 2);\n cursorIndices.push(idx-2, idx-1, idx);\n cursorIndices.push(idx-1, idx+1, idx);\n }\n }\n\n let idx = indexOffset + (CURSOR_SEGMENTS * 2);\n cursorIndices.push(idx-2, idx-1, indexOffset);\n cursorIndices.push(idx-1, indexOffset+1, indexOffset);\n\n let cursorVertexBuffer = this._renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(cursorVerts));\n let cursorIndexBuffer = this._renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(cursorIndices));\n\n let cursorIndexCount = cursorIndices.length;\n\n let cursorAttribs = [\n new PrimitiveAttribute('POSITION', cursorVertexBuffer, 4, gl.FLOAT, 16, 0),\n ];\n\n let cursorPrimitive = new Primitive(cursorAttribs, cursorIndexCount);\n cursorPrimitive.setIndexBuffer(cursorIndexBuffer);\n\n let cursorMaterial = new CursorMaterial();\n let cursorHiddenMaterial = new CursorHiddenMaterial();\n\n // Cursor renders two parts: The bright opaque cursor for areas where it's\n // not obscured and a more transparent, darker version for areas where it's\n // behind another object.\n let cursorRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorMaterial);\n let cursorHiddenRenderPrimitive = this._renderer.createRenderPrimitive(cursorPrimitive, cursorHiddenMaterial);\n let meshNode = new Node();\n meshNode.addRenderPrimitive(cursorRenderPrimitive);\n meshNode.addRenderPrimitive(cursorHiddenRenderPrimitive);\n return meshNode;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nRenders simple text using a seven-segment LED style pattern. Only really good\nfor numbers and a limited number of other characters.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\n\nconst TEXT_KERNING = 2.0;\n\nclass SevenSegmentMaterial extends Material {\n get materialName() {\n return 'SEVEN_SEGMENT_TEXT';\n }\n\n get vertexSource() {\n return `\n attribute vec2 POSITION;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n return proj * view * model * vec4(POSITION, 0.0, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n const vec4 color = vec4(0.0, 1.0, 0.0, 1.0);\n\n vec4 fragment_main() {\n return color;\n }`;\n }\n}\n\nexport class SevenSegmentText extends Node {\n constructor() {\n super();\n\n this._text = '';\n this._charNodes = [];\n }\n\n onRendererChanged(renderer) {\n this.clearNodes();\n this._charNodes = [];\n\n let vertices = [];\n let segmentIndices = {};\n let indices = [];\n\n const width = 0.5;\n const thickness = 0.25;\n\n function defineSegment(id, left, top, right, bottom) {\n let idx = vertices.length / 2;\n vertices.push(\n left, top,\n right, top,\n right, bottom,\n left, bottom);\n\n segmentIndices[id] = [\n idx, idx+2, idx+1,\n idx, idx+3, idx+2,\n ];\n }\n\n let characters = {};\n function defineCharacter(c, segments) {\n let character = {\n character: c,\n offset: indices.length * 2,\n count: 0,\n };\n\n for (let i = 0; i < segments.length; ++i) {\n let idx = segments[i];\n let segment = segmentIndices[idx];\n character.count += segment.length;\n indices.push(...segment);\n }\n\n characters[c] = character;\n }\n\n /* Segment layout is as follows:\n\n |-0-|\n 3 4\n |-1-|\n 5 6\n |-2-|\n\n */\n\n defineSegment(0, -1, 1, width, 1-thickness);\n defineSegment(1, -1, thickness*0.5, width, -thickness*0.5);\n defineSegment(2, -1, -1+thickness, width, -1);\n defineSegment(3, -1, 1, -1+thickness, -thickness*0.5);\n defineSegment(4, width-thickness, 1, width, -thickness*0.5);\n defineSegment(5, -1, thickness*0.5, -1+thickness, -1);\n defineSegment(6, width-thickness, thickness*0.5, width, -1);\n\n\n defineCharacter('0', [0, 2, 3, 4, 5, 6]);\n defineCharacter('1', [4, 6]);\n defineCharacter('2', [0, 1, 2, 4, 5]);\n defineCharacter('3', [0, 1, 2, 4, 6]);\n defineCharacter('4', [1, 3, 4, 6]);\n defineCharacter('5', [0, 1, 2, 3, 6]);\n defineCharacter('6', [0, 1, 2, 3, 5, 6]);\n defineCharacter('7', [0, 4, 6]);\n defineCharacter('8', [0, 1, 2, 3, 4, 5, 6]);\n defineCharacter('9', [0, 1, 2, 3, 4, 6]);\n defineCharacter('A', [0, 1, 3, 4, 5, 6]);\n defineCharacter('B', [1, 2, 3, 5, 6]);\n defineCharacter('C', [0, 2, 3, 5]);\n defineCharacter('D', [1, 2, 4, 5, 6]);\n defineCharacter('E', [0, 1, 2, 4, 6]);\n defineCharacter('F', [0, 1, 3, 5]);\n defineCharacter('P', [0, 1, 3, 4, 5]);\n defineCharacter('-', [1]);\n defineCharacter(' ', []);\n defineCharacter('_', [2]); // Used for undefined characters\n\n let gl = renderer.gl;\n let vertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let vertexAttribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 2, gl.FLOAT, 8, 0),\n ];\n\n let primitive = new Primitive(vertexAttribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let material = new SevenSegmentMaterial();\n\n this._charPrimitives = {};\n for (let char in characters) {\n let charDef = characters[char];\n primitive.elementCount = charDef.count;\n primitive.indexByteOffset = charDef.offset;\n this._charPrimitives[char] = renderer.createRenderPrimitive(primitive, material);\n }\n\n this.text = this._text;\n }\n\n get text() {\n return this._text;\n }\n\n set text(value) {\n this._text = value;\n\n let i = 0;\n let charPrimitive = null;\n for (; i < value.length; ++i) {\n if (value[i] in this._charPrimitives) {\n charPrimitive = this._charPrimitives[value[i]];\n } else {\n charPrimitive = this._charPrimitives['_'];\n }\n\n if (this._charNodes.length <= i) {\n let node = new Node();\n node.addRenderPrimitive(charPrimitive);\n let offset = i * TEXT_KERNING;\n node.translation = [offset, 0, 0];\n this._charNodes.push(node);\n this.addNode(node);\n } else {\n // This is sort of an abuse of how these things are expected to work,\n // but it's the cheapest thing I could think of that didn't break the\n // world.\n this._charNodes[i].clearRenderPrimitives();\n this._charNodes[i].addRenderPrimitive(charPrimitive);\n this._charNodes[i].visible = true;\n }\n }\n\n // If there's any nodes left over make them invisible\n for (; i < this._charNodes.length; ++i) {\n this._charNodes[i].visible = false;\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nNode for displaying 360 equirect images as a skybox.\n*/\n\nimport {Material, RENDER_ORDER} from '../core/material.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {Node} from '../core/node.js';\nimport {UrlTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass SkyboxMaterial extends Material {\n constructor() {\n super();\n this.renderOrder = RENDER_ORDER.SKY;\n this.state.depthFunc = GL.LEQUAL;\n this.state.depthMask = false;\n\n this.image = this.defineSampler('diffuse');\n\n this.texCoordScaleOffset = this.defineUniform('texCoordScaleOffset',\n [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0], 4);\n }\n\n get materialName() {\n return 'SKYBOX';\n }\n\n get vertexSource() {\n return `\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n // Drop the translation portion of the view matrix\n view[3].xyz = vec3(0.0, 0.0, 0.0);\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n\n // Returning the W component for both Z and W forces the geometry depth to\n // the far plane. When combined with a depth func of LEQUAL this makes the\n // sky write to any depth fragment that has not been written to yet.\n return out_vec.xyww;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }`;\n }\n}\n\nexport class SkyboxNode extends Node {\n constructor(options) {\n super();\n\n this._url = options.url;\n this._displayMode = options.displayMode || 'mono';\n this._rotationY = options.rotationY || 0;\n }\n\n onRendererChanged(renderer) {\n let vertices = [];\n let indices = [];\n\n let latSegments = 40;\n let lonSegments = 40;\n\n // Create the vertices/indices\n for (let i=0; i <= latSegments; ++i) {\n let theta = i * Math.PI / latSegments;\n let sinTheta = Math.sin(theta);\n let cosTheta = Math.cos(theta);\n\n let idxOffsetA = i * (lonSegments+1);\n let idxOffsetB = (i+1) * (lonSegments+1);\n\n for (let j=0; j <= lonSegments; ++j) {\n let phi = (j * 2 * Math.PI / lonSegments) + this._rotationY;\n let x = Math.sin(phi) * sinTheta;\n let y = cosTheta;\n let z = -Math.cos(phi) * sinTheta;\n let u = (j / lonSegments);\n let v = (i / latSegments);\n\n // Vertex shader will force the geometry to the far plane, so the\n // radius of the sphere is immaterial.\n vertices.push(x, y, z, u, v);\n\n if (i < latSegments && j < lonSegments) {\n let idxA = idxOffsetA+j;\n let idxB = idxOffsetB+j;\n\n indices.push(idxA, idxB, idxA+1,\n idxB, idxB+1, idxA+1);\n }\n }\n }\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n\n let material = new SkyboxMaterial();\n material.image.texture = new UrlTexture(this._url);\n\n switch (this._displayMode) {\n case 'mono':\n material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0];\n break;\n case 'stereoTopBottom':\n material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0,\n 1.0, 0.5, 0.0, 0.5];\n break;\n case 'stereoLeftRight':\n material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0,\n 0.5, 1.0, 0.5, 0.0];\n break;\n }\n\n let renderPrimitive = renderer.createRenderPrimitive(primitive, material);\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nHeavily inspired by Mr. Doobs stats.js, this FPS counter is rendered completely\nwith WebGL, allowing it to be shown in cases where overlaid HTML elements aren't\nusable (like WebXR), or if you want the FPS counter to be rendered as part of\nyour scene.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Node} from '../core/node.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {SevenSegmentText} from './seven-segment-text.js';\n\nconst SEGMENTS = 30;\nconst MAX_FPS = 90;\n\nclass StatsMaterial extends Material {\n get materialName() {\n return 'STATS_VIEWER';\n }\n\n get vertexSource() {\n return `\n attribute vec3 POSITION;\n attribute vec3 COLOR_0;\n varying vec4 vColor;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vColor = vec4(COLOR_0, 1.0);\n return proj * view * model * vec4(POSITION, 1.0);\n }`;\n }\n\n get fragmentSource() {\n return `\n precision mediump float;\n varying vec4 vColor;\n\n vec4 fragment_main() {\n return vColor;\n }`;\n }\n}\n\nfunction segmentToX(i) {\n return ((0.9/SEGMENTS) * i) - 0.45;\n}\n\nfunction fpsToY(value) {\n return (Math.min(value, MAX_FPS) * (0.7 / MAX_FPS)) - 0.45;\n}\n\nfunction fpsToRGB(value) {\n return {\n r: Math.max(0.0, Math.min(1.0, 1.0 - (value/60))),\n g: Math.max(0.0, Math.min(1.0, ((value-15)/(MAX_FPS-15)))),\n b: Math.max(0.0, Math.min(1.0, ((value-15)/(MAX_FPS-15)))),\n };\n}\n\nlet now = (window.performance && performance.now) ? performance.now.bind(performance) : Date.now;\n\nexport class StatsViewer extends Node {\n constructor() {\n super();\n\n this._performanceMonitoring = false;\n\n this._startTime = now();\n this._prevFrameTime = this._startTime;\n this._prevGraphUpdateTime = this._startTime;\n this._frames = 0;\n this._fpsAverage = 0;\n this._fpsMin = 0;\n this._fpsStep = this._performanceMonitoring ? 1000 : 250;\n this._lastSegment = 0;\n\n this._fpsVertexBuffer = null;\n this._fpsRenderPrimitive = null;\n this._fpsNode = null;\n\n this._sevenSegmentNode = new SevenSegmentText();\n // Hard coded because it doesn't change:\n // Scale by 0.075 in X and Y\n // Translate into upper left corner w/ z = 0.02\n this._sevenSegmentNode.matrix = new Float32Array([\n 0.075, 0, 0, 0,\n 0, 0.075, 0, 0,\n 0, 0, 1, 0,\n -0.3625, 0.3625, 0.02, 1,\n ]);\n }\n\n onRendererChanged(renderer) {\n this.clearNodes();\n\n let gl = renderer.gl;\n\n let fpsVerts = [];\n let fpsIndices = [];\n\n // Graph geometry\n for (let i = 0; i < SEGMENTS; ++i) {\n // Bar top\n fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n fpsVerts.push(segmentToX(i+1), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n\n // Bar bottom\n fpsVerts.push(segmentToX(i), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n fpsVerts.push(segmentToX(i+1), fpsToY(0), 0.02, 0.0, 1.0, 1.0);\n\n let idx = i * 4;\n fpsIndices.push(idx, idx+3, idx+1,\n idx+3, idx, idx+2);\n }\n\n function addBGSquare(left, bottom, right, top, z, r, g, b) {\n let idx = fpsVerts.length / 6;\n\n fpsVerts.push(left, bottom, z, r, g, b);\n fpsVerts.push(right, top, z, r, g, b);\n fpsVerts.push(left, top, z, r, g, b);\n fpsVerts.push(right, bottom, z, r, g, b);\n\n fpsIndices.push(idx, idx+1, idx+2,\n idx, idx+3, idx+1);\n }\n\n // Panel Background\n addBGSquare(-0.5, -0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.125);\n\n // FPS Background\n addBGSquare(-0.45, -0.45, 0.45, 0.25, 0.01, 0.0, 0.0, 0.4);\n\n // 30 FPS line\n addBGSquare(-0.45, fpsToY(30), 0.45, fpsToY(32), 0.015, 0.5, 0.0, 0.5);\n\n // 60 FPS line\n addBGSquare(-0.45, fpsToY(60), 0.45, fpsToY(62), 0.015, 0.2, 0.0, 0.75);\n\n this._fpsVertexBuffer = renderer.createRenderBuffer(gl.ARRAY_BUFFER, new Float32Array(fpsVerts), gl.DYNAMIC_DRAW);\n let fpsIndexBuffer = renderer.createRenderBuffer(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(fpsIndices));\n\n let fpsAttribs = [\n new PrimitiveAttribute('POSITION', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 0),\n new PrimitiveAttribute('COLOR_0', this._fpsVertexBuffer, 3, gl.FLOAT, 24, 12),\n ];\n\n let fpsPrimitive = new Primitive(fpsAttribs, fpsIndices.length);\n fpsPrimitive.setIndexBuffer(fpsIndexBuffer);\n fpsPrimitive.setBounds([-0.5, -0.5, 0.0], [0.5, 0.5, 0.015]);\n\n this._fpsRenderPrimitive = renderer.createRenderPrimitive(fpsPrimitive, new StatsMaterial());\n this._fpsNode = new Node();\n this._fpsNode.addRenderPrimitive(this._fpsRenderPrimitive);\n\n this.addNode(this._fpsNode);\n this.addNode(this._sevenSegmentNode);\n }\n\n get performanceMonitoring() {\n return this._performanceMonitoring;\n }\n\n set performanceMonitoring(value) {\n this._performanceMonitoring = value;\n this._fpsStep = value ? 1000 : 250;\n }\n\n begin() {\n this._startTime = now();\n }\n\n end() {\n let time = now();\n\n let frameFps = 1000 / (time - this._prevFrameTime);\n this._prevFrameTime = time;\n this._fpsMin = this._frames ? Math.min(this._fpsMin, frameFps) : frameFps;\n this._frames++;\n\n if (time > this._prevGraphUpdateTime + this._fpsStep) {\n let intervalTime = time - this._prevGraphUpdateTime;\n this._fpsAverage = Math.round(1000 / (intervalTime / this._frames));\n\n // Draw both average and minimum FPS for this period\n // so that dropped frames are more clearly visible.\n this._updateGraph(this._fpsMin, this._fpsAverage);\n if (this._performanceMonitoring) {\n console.log(`Average FPS: ${this._fpsAverage} Min FPS: ${this._fpsMin}`);\n }\n\n this._prevGraphUpdateTime = time;\n this._frames = 0;\n this._fpsMin = 0;\n }\n }\n\n _updateGraph(valueLow, valueHigh) {\n let color = fpsToRGB(valueLow);\n // Draw a range from the low to high value. Artificially widen the\n // range a bit to ensure that near-equal values still remain\n // visible - the logic here should match that used by the\n // \"60 FPS line\" setup below. Hitting 60fps consistently will\n // keep the top half of the 60fps background line visible.\n let y0 = fpsToY(valueLow - 1);\n let y1 = fpsToY(valueHigh + 1);\n\n // Update the current segment with the new FPS value\n let updateVerts = [\n segmentToX(this._lastSegment), y1, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), y1, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment), y0, 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), y0, 0.02, color.r, color.g, color.b,\n ];\n\n // Re-shape the next segment into the green \"progress\" line\n color.r = 0.2;\n color.g = 1.0;\n color.b = 0.2;\n\n if (this._lastSegment == SEGMENTS - 1) {\n // If we're updating the last segment we need to do two bufferSubDatas\n // to update the segment and turn the first segment into the progress line.\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts),\n this._lastSegment * 24 * 4);\n updateVerts = [\n segmentToX(0), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(0), fpsToY(0), 0.02, color.r, color.g, color.b,\n segmentToX(.25), fpsToY(0), 0.02, color.r, color.g, color.b,\n ];\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts), 0);\n } else {\n updateVerts.push(\n segmentToX(this._lastSegment+1), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1.25), fpsToY(MAX_FPS), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1), fpsToY(0), 0.02, color.r, color.g, color.b,\n segmentToX(this._lastSegment+1.25), fpsToY(0), 0.02, color.r, color.g, color.b\n );\n this._renderer.updateRenderBuffer(this._fpsVertexBuffer, new Float32Array(updateVerts),\n this._lastSegment * 24 * 4);\n }\n\n this._lastSegment = (this._lastSegment+1) % SEGMENTS;\n\n this._sevenSegmentNode.text = `${this._fpsAverage} FP5`;\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nNode for displaying 2D or stereo videos on a quad.\n*/\n\nimport {Material} from '../core/material.js';\nimport {Primitive, PrimitiveAttribute} from '../core/primitive.js';\nimport {Node} from '../core/node.js';\nimport {VideoTexture} from '../core/texture.js';\n\nconst GL = WebGLRenderingContext; // For enums\n\nclass VideoMaterial extends Material {\n constructor() {\n super();\n\n this.image = this.defineSampler('diffuse');\n\n this.texCoordScaleOffset = this.defineUniform('texCoordScaleOffset',\n [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0], 4);\n }\n\n get materialName() {\n return 'VIDEO_PLAYER';\n }\n\n get vertexSource() {\n return `\n uniform int EYE_INDEX;\n uniform vec4 texCoordScaleOffset[2];\n attribute vec3 POSITION;\n attribute vec2 TEXCOORD_0;\n varying vec2 vTexCoord;\n\n vec4 vertex_main(mat4 proj, mat4 view, mat4 model) {\n vec4 scaleOffset = texCoordScaleOffset[EYE_INDEX];\n vTexCoord = (TEXCOORD_0 * scaleOffset.xy) + scaleOffset.zw;\n vec4 out_vec = proj * view * model * vec4(POSITION, 1.0);\n return out_vec;\n }`;\n }\n\n get fragmentSource() {\n return `\n uniform sampler2D diffuse;\n varying vec2 vTexCoord;\n\n vec4 fragment_main() {\n return texture2D(diffuse, vTexCoord);\n }`;\n }\n}\n\nexport class VideoNode extends Node {\n constructor(options) {\n super();\n\n this._video = options.video;\n this._displayMode = options.displayMode || 'mono';\n\n this._video_texture = new VideoTexture(this._video);\n }\n\n get aspectRatio() {\n let width = this._video.videoWidth;\n let height = this._video.videoHeight;\n\n switch (this._displayMode) {\n case 'stereoTopBottom': height *= 0.5; break;\n case 'stereoLeftRight': width *= 0.5; break;\n }\n\n if (!height || !width) {\n return 1;\n }\n\n return width / height;\n }\n\n onRendererChanged(renderer) {\n let vertices = [\n -1.0, 1.0, 0.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 1.0, 0.0,\n 1.0, -1.0, 0.0, 1.0, 1.0,\n -1.0, -1.0, 0.0, 0.0, 1.0,\n ];\n let indices = [\n 0, 2, 1,\n 0, 3, 2,\n ];\n\n let vertexBuffer = renderer.createRenderBuffer(GL.ARRAY_BUFFER, new Float32Array(vertices));\n let indexBuffer = renderer.createRenderBuffer(GL.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices));\n\n let attribs = [\n new PrimitiveAttribute('POSITION', vertexBuffer, 3, GL.FLOAT, 20, 0),\n new PrimitiveAttribute('TEXCOORD_0', vertexBuffer, 2, GL.FLOAT, 20, 12),\n ];\n\n let primitive = new Primitive(attribs, indices.length);\n primitive.setIndexBuffer(indexBuffer);\n primitive.setBounds([-1.0, -1.0, 0.0], [1.0, 1.0, 0.015]);\n\n let material = new VideoMaterial();\n material.image.texture = this._video_texture;\n\n switch (this._displayMode) {\n case 'mono':\n material.texCoordScaleOffset.value = [1.0, 1.0, 0.0, 0.0,\n 1.0, 1.0, 0.0, 0.0];\n break;\n case 'stereoTopBottom':\n material.texCoordScaleOffset.value = [1.0, 0.5, 0.0, 0.0,\n 1.0, 0.5, 0.0, 0.5];\n break;\n case 'stereoLeftRight':\n material.texCoordScaleOffset.value = [0.5, 1.0, 0.0, 0.0,\n 0.5, 1.0, 0.5, 0.0];\n break;\n }\n\n let renderPrimitive = renderer.createRenderPrimitive(primitive, material);\n this.addRenderPrimitive(renderPrimitive);\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {RenderView} from '../core/renderer.js';\nimport {InputRenderer} from '../nodes/input-renderer.js';\nimport {StatsViewer} from '../nodes/stats-viewer.js';\nimport {Node} from '../core/node.js';\nimport {vec3, quat} from '../math/gl-matrix.js';\n\nexport class WebXRView extends RenderView {\n constructor(view, pose, layer) {\n super(\n view ? view.projectionMatrix : null,\n (pose && view) ? pose.getViewMatrix(view) : null,\n (layer && view) ? layer.getViewport(view) : null,\n view ? view.eye : 'left'\n );\n }\n}\n\nexport class Scene extends Node {\n constructor() {\n super();\n\n this._timestamp = -1;\n this._frameDelta = 0;\n this._statsStanding = false;\n this._stats = null;\n this._statsEnabled = false;\n this.enableStats(true); // Ensure the stats are added correctly by default.\n\n this._inputRenderer = null;\n this._resetInputEndFrame = true;\n\n this._lastTimestamp = 0;\n\n this._hoverFrame = 0;\n this._hoveredNodes = [];\n\n this.clear = true;\n }\n\n setRenderer(renderer) {\n this._setRenderer(renderer);\n }\n\n loseRenderer() {\n if (this._renderer) {\n this._stats = null;\n this._renderer = null;\n this._inputRenderer = null;\n }\n }\n\n get inputRenderer() {\n if (!this._inputRenderer) {\n this._inputRenderer = new InputRenderer();\n this.addNode(this._inputRenderer);\n }\n return this._inputRenderer;\n }\n\n // Helper function that automatically adds the appropriate visual elements for\n // all input sources.\n updateInputSources(frame, frameOfRef) {\n // FIXME: Check for the existence of the API first. This check should be\n // removed once the input API is part of the official spec.\n if (!frame.session.getInputSources) {\n return;\n }\n\n let inputSources = frame.session.getInputSources();\n\n let newHoveredNodes = [];\n let lastHoverFrame = this._hoverFrame;\n this._hoverFrame++;\n\n for (let inputSource of inputSources) {\n let inputPose = frame.getInputPose(inputSource, frameOfRef);\n\n if (!inputPose) {\n continue;\n }\n\n // Any time that we have a grip matrix, we'll render a controller.\n if (inputPose.gripMatrix) {\n this.inputRenderer.addController(inputPose.gripMatrix);\n }\n\n if (inputPose.targetRay) {\n if (inputSource.targetRayMode == 'tracked-pointer') {\n // If we have a pointer matrix and the pointer origin is the users\n // hand (as opposed to their head or the screen) use it to render\n // a ray coming out of the input device to indicate the pointer\n // direction.\n this.inputRenderer.addLaserPointer(inputPose.targetRay);\n }\n\n // If we have a pointer matrix we can also use it to render a cursor\n // for both handheld and gaze-based input sources.\n\n // Check and see if the pointer is pointing at any selectable objects.\n let hitResult = this.hitTest(inputPose.targetRay);\n\n if (hitResult) {\n // Render a cursor at the intersection point.\n this.inputRenderer.addCursor(hitResult.intersection);\n\n if (hitResult.node._hoverFrameId != lastHoverFrame) {\n hitResult.node.onHoverStart();\n }\n hitResult.node._hoverFrameId = this._hoverFrame;\n newHoveredNodes.push(hitResult.node);\n } else {\n // Statically render the cursor 1 meters down the ray since we didn't\n // hit anything selectable.\n let cursorDistance = 1.0;\n let cursorPos = vec3.fromValues(\n inputPose.targetRay.origin.x,\n inputPose.targetRay.origin.y,\n inputPose.targetRay.origin.z\n );\n vec3.add(cursorPos, cursorPos, [\n inputPose.targetRay.direction.x * cursorDistance,\n inputPose.targetRay.direction.y * cursorDistance,\n inputPose.targetRay.direction.z * cursorDistance,\n ]);\n // let cursorPos = vec3.fromValues(0, 0, -1.0);\n // vec3.transformMat4(cursorPos, cursorPos, inputPose.targetRay);\n this.inputRenderer.addCursor(cursorPos);\n }\n }\n }\n\n for (let hoverNode of this._hoveredNodes) {\n if (hoverNode._hoverFrameId != this._hoverFrame) {\n hoverNode.onHoverEnd();\n }\n }\n\n this._hoveredNodes = newHoveredNodes;\n }\n\n handleSelect(inputSource, frame, frameOfRef) {\n let inputPose = frame.getInputPose(inputSource, frameOfRef);\n\n if (!inputPose) {\n return;\n }\n\n this.handleSelectPointer(inputPose.targetRay);\n }\n\n handleSelectPointer(targetRay) {\n if (targetRay) {\n // Check and see if the pointer is pointing at any selectable objects.\n let hitResult = this.hitTest(targetRay);\n\n if (hitResult) {\n // Render a cursor at the intersection point.\n hitResult.node.handleSelect();\n }\n }\n }\n\n enableStats(enable) {\n if (enable == this._statsEnabled) {\n return;\n }\n\n this._statsEnabled = enable;\n\n if (enable) {\n this._stats = new StatsViewer();\n this._stats.selectable = true;\n this.addNode(this._stats);\n\n if (this._statsStanding) {\n this._stats.translation = [0, 1.4, -0.75];\n } else {\n this._stats.translation = [0, -0.3, -0.5];\n }\n this._stats.scale = [0.3, 0.3, 0.3];\n quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0);\n } else if (!enable) {\n if (this._stats) {\n this.removeNode(this._stats);\n this._stats = null;\n }\n }\n }\n\n standingStats(enable) {\n this._statsStanding = enable;\n if (this._stats) {\n if (this._statsStanding) {\n this._stats.translation = [0, 1.4, -0.75];\n } else {\n this._stats.translation = [0, -0.3, -0.5];\n }\n this._stats.scale = [0.3, 0.3, 0.3];\n quat.fromEuler(this._stats.rotation, -45.0, 0.0, 0.0);\n }\n }\n\n draw(projectionMatrix, viewMatrix, eye) {\n let view = new RenderView();\n view.projectionMatrix = projectionMatrix;\n view.viewMatrix = viewMatrix;\n if (eye) {\n view.eye = eye;\n }\n\n this.drawViewArray([view]);\n }\n\n /** Draws the scene into the base layer of the XRFrame's session */\n drawXRFrame(xrFrame, pose) {\n if (!this._renderer || !pose) {\n return;\n }\n\n let gl = this._renderer.gl;\n let session = xrFrame.session;\n // Assumed to be a XRWebGLLayer for now.\n let layer = session.baseLayer;\n\n if (!gl) {\n return;\n }\n\n gl.bindFramebuffer(gl.FRAMEBUFFER, layer.framebuffer);\n\n if (this.clear) {\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n }\n\n let views = [];\n for (let view of xrFrame.views) {\n views.push(new WebXRView(view, pose, layer));\n }\n\n this.drawViewArray(views);\n }\n\n drawViewArray(views) {\n // Don't draw when we don't have a valid context\n if (!this._renderer) {\n return;\n }\n\n this._renderer.drawViews(views, this);\n }\n\n startFrame() {\n let prevTimestamp = this._timestamp;\n this._timestamp = performance.now();\n if (this._stats) {\n this._stats.begin();\n }\n\n if (prevTimestamp >= 0) {\n this._frameDelta = this._timestamp - prevTimestamp;\n } else {\n this._frameDelta = 0;\n }\n\n this._update(this._timestamp, this._frameDelta);\n\n return this._frameDelta;\n }\n\n endFrame() {\n if (this._inputRenderer && this._resetInputEndFrame) {\n this._inputRenderer.reset();\n }\n\n if (this._stats) {\n this._stats.end();\n }\n }\n\n // Override to load scene resources on construction or context restore.\n onLoadScene(renderer) {\n return Promise.resolve();\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport {mat4} from '../math/gl-matrix.js';\n\nconst LOOK_SPEED = 0.0025;\n\nexport class FallbackHelper {\n constructor(scene, gl) {\n this.scene = scene;\n this.gl = gl;\n this._emulateStage = false;\n\n this.lookYaw = 0;\n this.lookPitch = 0;\n\n this.viewMatrix = mat4.create();\n\n let projectionMatrix = mat4.create();\n this.projectionMatrix = projectionMatrix;\n\n // Using a simple identity matrix for the view.\n mat4.identity(this.viewMatrix);\n\n // We need to track the canvas size in order to resize the WebGL\n // backbuffer width and height, as well as update the projection matrix\n // and adjust the viewport.\n function onResize() {\n gl.canvas.width = gl.canvas.offsetWidth * window.devicePixelRatio;\n gl.canvas.height = gl.canvas.offsetHeight * window.devicePixelRatio;\n mat4.perspective(projectionMatrix, Math.PI*0.4,\n gl.canvas.width/gl.canvas.height,\n 0.1, 1000.0);\n gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);\n }\n window.addEventListener('resize', onResize);\n onResize();\n\n // Upding the view matrix with touch or mouse events.\n let canvas = gl.canvas;\n let lastTouchX = 0;\n let lastTouchY = 0;\n canvas.addEventListener('touchstart', (ev) => {\n if (ev.touches.length == 2) {\n lastTouchX = ev.touches[1].pageX;\n lastTouchY = ev.touches[1].pageY;\n }\n });\n canvas.addEventListener('touchmove', (ev) => {\n // Rotate the view when two fingers are being used.\n if (ev.touches.length == 2) {\n this.onLook(ev.touches[1].pageX - lastTouchX, ev.touches[1].pageY - lastTouchY);\n lastTouchX = ev.touches[1].pageX;\n lastTouchY = ev.touches[1].pageY;\n }\n });\n canvas.addEventListener('mousemove', (ev) => {\n // Only rotate when the right button is pressed.\n if (ev.buttons & 2) {\n this.onLook(ev.movementX, ev.movementY);\n }\n });\n canvas.addEventListener('contextmenu', (ev) => {\n // Prevent context menus on the canvas so that we can use right click to rotate.\n ev.preventDefault();\n });\n\n this.boundOnFrame = this.onFrame.bind(this);\n window.requestAnimationFrame(this.boundOnFrame);\n }\n\n onLook(yaw, pitch) {\n this.lookYaw += yaw * LOOK_SPEED;\n this.lookPitch += pitch * LOOK_SPEED;\n\n // Clamp pitch rotation beyond looking straight up or down.\n if (this.lookPitch < -Math.PI*0.5) {\n this.lookPitch = -Math.PI*0.5;\n }\n if (this.lookPitch > Math.PI*0.5) {\n this.lookPitch = Math.PI*0.5;\n }\n\n this.updateView();\n }\n\n onFrame(t) {\n let gl = this.gl;\n window.requestAnimationFrame(this.boundOnFrame);\n\n this.scene.startFrame();\n\n // We can skip setting the framebuffer and viewport every frame, because\n // it won't change from frame to frame and we're updating the viewport\n // only when we resize for efficency.\n gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);\n\n // We're drawing with our own projection and view matrix now, and we\n // don't have a list of view to loop through, but otherwise all of the\n // WebGL drawing logic is exactly the same.\n this.scene.draw(this.projectionMatrix, this.viewMatrix);\n\n this.scene.endFrame();\n }\n\n get emulateStage() {\n return this._emulateStage;\n }\n\n set emulateStage(value) {\n this._emulateStage = value;\n this.updateView();\n }\n\n updateView() {\n mat4.identity(this.viewMatrix);\n\n mat4.rotateX(this.viewMatrix, this.viewMatrix, -this.lookPitch);\n mat4.rotateY(this.viewMatrix, this.viewMatrix, -this.lookYaw);\n\n // If we're emulating a stage frame of reference we'll need to move the view\n // matrix roughly a meter and a half up in the air.\n if (this._emulateStage) {\n mat4.translate(this.viewMatrix, this.viewMatrix, [0, -1.6, 0]);\n }\n }\n}\n","// Copyright 2018 The Immersive Web Community Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\n/*\nProvides a simple way to get values from the query string if they're present\nand use a default value if not. Not strictly a \"WebGL\" utility, but I use it\nfrequently enough for debugging that I wanted to include it here.\n\nExample:\nFor the URL http://example.com/index.html?particleCount=1000\n\nQueryArgs.getInt(\"particleCount\", 100); // URL overrides, returns 1000\nQueryArgs.getInt(\"particleSize\", 10); // Not in URL, returns default of 10\n*/\n\nlet urlArgs = null;\nwindow.onhashchange = function() {\n // Force re-parsing on next access\n urlArgs = null;\n};\n\nfunction ensureArgsCached() {\n if (!urlArgs) {\n urlArgs = {};\n let query = window.location.search.substring(1) || window.location.hash.substring(1);\n let vars = query.split('&');\n for (let i = 0; i < vars.length; i++) {\n let pair = vars[i].split('=');\n urlArgs[pair[0].toLowerCase()] = decodeURIComponent(pair[1]);\n }\n }\n}\n\nexport class QueryArgs {\n static getString(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return urlArgs[lcaseName];\n }\n return defaultValue;\n }\n\n static getInt(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseInt(urlArgs[lcaseName], 10);\n }\n return defaultValue;\n }\n\n static getFloat(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseFloat(urlArgs[lcaseName]);\n }\n return defaultValue;\n }\n\n static getBool(name, defaultValue) {\n ensureArgsCached();\n let lcaseName = name.toLowerCase();\n if (lcaseName in urlArgs) {\n return parseInt(urlArgs[lcaseName], 10) != 0;\n }\n return defaultValue;\n }\n}\n"],"sourceRoot":""}