diff --git a/VERSION-FILE b/VERSION-FILE index e063769f..d060da1f 100644 --- a/VERSION-FILE +++ b/VERSION-FILE @@ -1,6 +1,6 @@ -version: 0.0.4-26-g5494-mod +version: 0.0.4-36-g02e83-mod branch: develop - - - - +b7ae3580f181870ce024ccc0f6c5e4d94b4cb17699deacd65778b8f3da3533d0 ./build/glboost.js +b7ae3580f181870ce024ccc0f6c5e4d94b4cb17699deacd65778b8f3da3533d0 ./build/glboost.js +37162b15ddb1511766b6fc46eec9129b3d6b3f91090bfe271e28f7abc1f7d199 ./build/glboost.min.js +2f3c64bc176cbd2b87bdb0fdb040fbdbfd7f385eab477e96a75507e2b09ce81f ./build/glboost.min.js.map diff --git a/build/glboost.js b/build/glboost.js index 137938b9..e5e8497b 100644 --- a/build/glboost.js +++ b/build/glboost.js @@ -20984,4 +20984,4 @@ return mat4( }))); -(0,eval)('this').GLBoost.VERSION='version: 0.0.4-26-g5494-mod branch: develop'; +(0,eval)('this').GLBoost.VERSION='version: 0.0.4-36-g02e83-mod branch: develop'; diff --git a/build/glboost.min.js b/build/glboost.min.js index 65462e30..827c20fe 100644 --- a/build/glboost.min.js +++ b/build/glboost.min.js @@ -1,3 +1,3 @@ (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory():typeof define==="function"&&define.amd?define(factory):factory()})(this,function(){"use strict";var global=(0,eval)("this");(function(global){global.GLBoost=typeof global.GLBoost!=="undefined"?global.GLBoost:{};const GLBoost=global.GLBoost;if(typeof define==="function"&&define.amd){define(function(){return GLBoost})}else if(typeof exports==="object"){module.exports=GLBoost;global.GLBoost=GLBoost}else{global.GLBoost=GLBoost}(function(){GLBoost.GLBOOST_CONSTANT_NAMES=[];GLBoost.GLBOOST_CONSTANT_VALUES=[];let c={count:0,__existedConstants:[],define:function(constantName,glConstantValue,aliasName){let value=null;if(glConstantValue!==void 0){value=glConstantValue;this.__existedConstants.push(glConstantValue)}else{const checkUnique=()=>{let result=true;for(let existValue of this.__existedConstants){if(this.count===existValue){result=false}}return result};for(;checkUnique()===false;this.count++){}value=this.count}GLBoost[constantName]=value;GLBoost.GLBOOST_CONSTANT_NAMES[value]=constantName;GLBoost.GLBOOST_CONSTANT_VALUES[value]=typeof aliasName!=="undefined"?aliasName:constantName;this.count++}};c.define("ACTIVE_ATTRIBUTES",35721);c.define("ACTIVE_ATTRIBUTE_MAX_LENGTH",35722);c.define("ACTIVE_TEXTURE",34016);c.define("ACTIVE_UNIFORMS",35718);c.define("ACTIVE_UNIFORM_MAX_LENGTH",35719);c.define("ALIASED_LINE_WIDTH_RANGE",33902);c.define("ALIASED_POINT_SIZE_RANGE",33901);c.define("ALPHA",6406);c.define("ALPHA_BITS",3413);c.define("ALWAYS",519);c.define("ARRAY_BUFFER",34962);c.define("ARRAY_BUFFER_BINDING",34964);c.define("ATTACHED_SHADERS",35717);c.define("BACK",1029);c.define("BLEND",3042);c.define("BLEND_COLOR",32773);c.define("BLEND_DST_ALPHA",32970);c.define("BLEND_DST_RGB",32968);c.define("BLEND_EQUATION",32777);c.define("BLEND_EQUATION_ALPHA",34877);c.define("BLEND_EQUATION_RGB",32777);c.define("BLEND_SRC_ALPHA",32971);c.define("BLEND_SRC_RGB",32969);c.define("BLUE_BITS",3412);c.define("BOOL",35670);c.define("BOOL_VEC2",35671);c.define("BOOL_VEC3",35672);c.define("BOOL_VEC4",35673);c.define("BROWSER_DEFAULT_WEBGL",37444);c.define("BUFFER_SIZE",34660);c.define("BUFFER_USAGE",34661);c.define("BYTE",5120);c.define("CCW",2305);c.define("CLAMP_TO_EDGE",33071);c.define("COLOR_ATTACHMENT0",36064);c.define("COLOR_BUFFER_BIT",16384);c.define("COLOR_CLEAR_VALUE",3106);c.define("COLOR_WRITEMASK",3107);c.define("COMPILE_STATUS",35713);c.define("COMPRESSED_TEXTURE_FORMATS",34467);c.define("CONSTANT_ALPHA",32771);c.define("CONSTANT_COLOR",32769);c.define("CONTEXT_LOST_WEBGL",37442);c.define("CULL_FACE",2884);c.define("CULL_FACE_MODE",2885);c.define("CURRENT_PROGRAM",35725);c.define("CURRENT_VERTEX_ATTRIB",34342);c.define("CW",2304);c.define("DECR",7683);c.define("DECR_WRAP",34056);c.define("DELETE_STATUS",35712);c.define("DEPTH_ATTACHMENT",36096);c.define("DEPTH_BITS",3414);c.define("DEPTH_BUFFER_BIT",256);c.define("DEPTH_CLEAR_VALUE",2931);c.define("DEPTH_COMPONENT",6402);c.define("DEPTH_COMPONENT16",33189);c.define("DEPTH_FUNC",2932);c.define("DEPTH_RANGE",2928);c.define("DEPTH_STENCIL",34041);c.define("DEPTH_STENCIL_ATTACHMENT",33306);c.define("DEPTH_TEST",2929);c.define("DEPTH_WRITEMASK",2930);c.define("DITHER",3024);c.define("DONT_CARE",4352);c.define("DST_ALPHA",772);c.define("DST_COLOR",774);c.define("DYNAMIC_DRAW",35048);c.define("ELEMENT_ARRAY_BUFFER",34963);c.define("ELEMENT_ARRAY_BUFFER_BINDING",34965);c.define("EQUAL",514);c.define("FASTEST",4353);c.define("FLOAT",5126);c.define("FLOAT_MAT2",35674);c.define("FLOAT_MAT3",35675);c.define("FLOAT_MAT4",35676);c.define("FLOAT_VEC2",35664);c.define("FLOAT_VEC3",35665);c.define("FLOAT_VEC4",35666);c.define("FRAGMENT_SHADER",35632);c.define("FRAMEBUFFER",36160);c.define("FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",36049);c.define("FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",36048);c.define("FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",36051);c.define("FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",36050);c.define("FRAMEBUFFER_BINDING",36006);c.define("FRAMEBUFFER_COMPLETE",36053);c.define("FRAMEBUFFER_INCOMPLETE_ATTACHMENT",36054);c.define("FRAMEBUFFER_INCOMPLETE_DIMENSIONS",36057);c.define("FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",36055);c.define("FRAMEBUFFER_UNSUPPORTED",36061);c.define("FRONT",1028);c.define("FRONT_AND_BACK",1032);c.define("FRONT_FACE",2886);c.define("FUNC_ADD",32774);c.define("FUNC_REVERSE_SUBTRACT",32779);c.define("FUNC_SUBTRACT",32778);c.define("GENERATE_MIPMAP_HINT",33170);c.define("GEQUAL",518);c.define("GREATER",516);c.define("GREEN_BITS",3411);c.define("HIGH_FLOAT",36338);c.define("HIGH_INT",36341);c.define("INCR",7682);c.define("INCR_WRAP",34055);c.define("INFO_LOG_LENGTH",35716);c.define("INT",5124);c.define("INT_VEC2",35667);c.define("INT_VEC3",35668);c.define("INT_VEC4",35669);c.define("INVALID_ENUM",1280);c.define("INVALID_FRAMEBUFFER_OPERATION",1286);c.define("INVALID_OPERATION",1282);c.define("INVALID_VALUE",1281);c.define("INVERT",5386);c.define("KEEP",7680);c.define("LEQUAL",515);c.define("LESS",513);c.define("LINEAR",9729);c.define("LINEAR_MIPMAP_LINEAR",9987);c.define("LINEAR_MIPMAP_NEAREST",9985);c.define("LINES",1);c.define("LINE_LOOP",2);c.define("LINE_STRIP",3);c.define("LINE_WIDTH",2849);c.define("LINK_STATUS",35714);c.define("LOW_FLOAT",36336);c.define("LOW_INT",36339);c.define("LUMINANCE",6409);c.define("LUMINANCE_ALPHA",6410);c.define("MAX_COMBINED_TEXTURE_IMAGE_UNITS",35661);c.define("MAX_CUBE_MAP_TEXTURE_SIZE",34076);c.define("MAX_FRAGMENT_UNIFORM_VECTORS",36349);c.define("MAX_RENDERBUFFER_SIZE",34024);c.define("MAX_TEXTURE_IMAGE_UNITS",34930);c.define("MAX_TEXTURE_SIZE",3379);c.define("MAX_VARYING_VECTORS",36348);c.define("MAX_VERTEX_ATTRIBS",34921);c.define("MAX_VERTEX_TEXTURE_IMAGE_UNITS",35660);c.define("MAX_VERTEX_UNIFORM_VECTORS",36347);c.define("MAX_VIEWPORT_DIMS",3386);c.define("MEDIUM_FLOAT",36337);c.define("MEDIUM_INT",36340);c.define("MIRRORED_REPEAT",33648);c.define("NEAREST",9728);c.define("NEAREST_MIPMAP_LINEAR",9986);c.define("NEAREST_MIPMAP_NEAREST",9984);c.define("NEVER",512);c.define("NICEST",4354);c.define("NONE",0);c.define("NOTEQUAL",517);c.define("NO_ERROR",0);c.define("NUM_COMPRESSED_TEXTURE_FORMATS",34466);c.define("ONE",1);c.define("ONE_MINUS_CONSTANT_ALPHA",32772);c.define("ONE_MINUS_CONSTANT_COLOR",32770);c.define("ONE_MINUS_DST_ALPHA",773);c.define("ONE_MINUS_DST_COLOR",775);c.define("ONE_MINUS_SRC_ALPHA",771);c.define("ONE_MINUS_SRC_COLOR",769);c.define("OUT_OF_MEMORY",1285);c.define("PACK_ALIGNMENT",3333);c.define("POINTS",0);c.define("POLYGON_OFFSET_FACTOR",32824);c.define("POLYGON_OFFSET_FILL",32823);c.define("POLYGON_OFFSET_UNITS",10752);c.define("RED_BITS",3410);c.define("RENDERBUFFER",36161);c.define("RENDERBUFFER_ALPHA_SIZE",36179);c.define("RENDERBUFFER_BINDING",36007);c.define("RENDERBUFFER_BLUE_SIZE",36178);c.define("RENDERBUFFER_DEPTH_SIZE",36180);c.define("RENDERBUFFER_GREEN_SIZE",36177);c.define("RENDERBUFFER_HEIGHT",36163);c.define("RENDERBUFFER_INTERNAL_FORMAT",36164);c.define("RENDERBUFFER_RED_SIZE",36176);c.define("RENDERBUFFER_STENCIL_SIZE",36181);c.define("RENDERBUFFER_WIDTH",36162);c.define("RENDERER",7937);c.define("REPEAT",10497);c.define("REPLACE",7681);c.define("RGB",6407);c.define("RGB5_A1",32855);c.define("RGB565",36194);c.define("RGBA",6408);c.define("RGBA4",32854);c.define("SAMPLER_2D",35678);c.define("SAMPLER_CUBE",35680);c.define("SAMPLES",32937);c.define("SAMPLE_ALPHA_TO_COVERAGE",32926);c.define("SAMPLE_BUFFERS",32936);c.define("SAMPLE_COVERAGE",32928);c.define("SAMPLE_COVERAGE_INVERT",32939);c.define("SAMPLE_COVERAGE_VALUE",32938);c.define("SCISSOR_BOX",3088);c.define("SCISSOR_TEST",3089);c.define("SHADER_COMPILER",36346);c.define("SHADER_SOURCE_LENGTH",35720);c.define("SHADER_TYPE",35663);c.define("SHADING_LANGUAGE_VERSION",35724);c.define("SHORT",5122);c.define("SRC_ALPHA",770);c.define("SRC_ALPHA_SATURATE",776);c.define("SRC_COLOR",768);c.define("STATIC_DRAW",35044);c.define("STENCIL_ATTACHMENT",36128);c.define("STENCIL_BACK_FAIL",34817);c.define("STENCIL_BACK_FUNC",34816);c.define("STENCIL_BACK_PASS_DEPTH_FAIL",34818);c.define("STENCIL_BACK_PASS_DEPTH_PASS",34819);c.define("STENCIL_BACK_REF",36003);c.define("STENCIL_BACK_VALUE_MASK",36004);c.define("STENCIL_BACK_WRITEMASK",36005);c.define("STENCIL_BITS",3415);c.define("STENCIL_BUFFER_BIT",1024);c.define("STENCIL_CLEAR_VALUE",2961);c.define("STENCIL_FAIL",2964);c.define("STENCIL_FUNC",2962);c.define("STENCIL_INDEX",6401);c.define("STENCIL_INDEX8",36168);c.define("STENCIL_PASS_DEPTH_FAIL",2965);c.define("STENCIL_PASS_DEPTH_PASS",2966);c.define("STENCIL_REF",2967);c.define("STENCIL_TEST",2960);c.define("STENCIL_VALUE_MASK",2963);c.define("STENCIL_WRITEMASK",2968);c.define("STREAM_DRAW",35040);c.define("SUBPIXEL_BITS",3408);c.define("TEXTURE",5890);c.define("TEXTURE0",33984);c.define("TEXTURE1",33985);c.define("TEXTURE2",33986);c.define("TEXTURE3",33987);c.define("TEXTURE4",33988);c.define("TEXTURE5",33989);c.define("TEXTURE6",33990);c.define("TEXTURE7",33991);c.define("TEXTURE8",33992);c.define("TEXTURE9",33993);c.define("TEXTURE10",33994);c.define("TEXTURE11",33995);c.define("TEXTURE12",33996);c.define("TEXTURE13",33997);c.define("TEXTURE14",33998);c.define("TEXTURE15",33999);c.define("TEXTURE16",34e3);c.define("TEXTURE17",34001);c.define("TEXTURE18",34002);c.define("TEXTURE19",34003);c.define("TEXTURE20",34004);c.define("TEXTURE21",34005);c.define("TEXTURE22",34006);c.define("TEXTURE23",34007);c.define("TEXTURE24",34008);c.define("TEXTURE25",34009);c.define("TEXTURE26",34010);c.define("TEXTURE27",34011);c.define("TEXTURE28",34012);c.define("TEXTURE29",34013);c.define("TEXTURE30",34014);c.define("TEXTURE31",34015);c.define("TEXTURE_2D",3553);c.define("TEXTURE_BINDING_2D",32873);c.define("TEXTURE_BINDING_CUBE_MAP",34068);c.define("TEXTURE_CUBE_MAP",34067);c.define("TEXTURE_CUBE_MAP_NEGATIVE_X",34070);c.define("TEXTURE_CUBE_MAP_NEGATIVE_Y",34072);c.define("TEXTURE_CUBE_MAP_NEGATIVE_Z",34074);c.define("TEXTURE_CUBE_MAP_POSITIVE_X",34069);c.define("TEXTURE_CUBE_MAP_POSITIVE_Y",34071);c.define("TEXTURE_CUBE_MAP_POSITIVE_Z",34073);c.define("TEXTURE_MAG_FILTER",10240);c.define("TEXTURE_MIN_FILTER",10241);c.define("TEXTURE_WRAP_S",10242);c.define("TEXTURE_WRAP_T",10243);c.define("TRIANGLES",4);c.define("TRIANGLE_FAN",6);c.define("TRIANGLE_STRIP",5);c.define("UNPACK_ALIGNMENT",3317);c.define("UNPACK_COLORSPACE_CONVERSION_WEBGL",37443);c.define("UNPACK_FLIP_Y_WEBGL",37440);c.define("UNPACK_PREMULTIPLY_ALPHA_WEBGL",37441);c.define("UNSIGNED_BYTE",5121);c.define("UNSIGNED_INT",5125);c.define("UNSIGNED_SHORT",5123);c.define("UNSIGNED_SHORT_4_4_4_4",32819);c.define("UNSIGNED_SHORT_5_5_5_1",32820);c.define("UNSIGNED_SHORT_5_6_5",33635);c.define("VALIDATE_STATUS",35715);c.define("VENDOR",7936);c.define("VERSION",7938);c.define("VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",34975);c.define("VERTEX_ATTRIB_ARRAY_ENABLED",34338);c.define("VERTEX_ATTRIB_ARRAY_NORMALIZED",34922);c.define("VERTEX_ATTRIB_ARRAY_POINTER",34373);c.define("VERTEX_ATTRIB_ARRAY_SIZE",34339);c.define("VERTEX_ATTRIB_ARRAY_STRIDE",34340);c.define("VERTEX_ATTRIB_ARRAY_TYPE",34341);c.define("VERTEX_SHADER",35633);c.define("VIEWPORT",2978);c.define("ZERO",0);c.define("POSITION",void 0,"position");c.define("COLOR",void 0,"color");c.define("NORMAL",void 0,"normal");c.define("TEXCOORD",void 0,"texcoord");c.define("TANGENT",void 0,"tangent");c.define("JOINT",void 0,"joint");c.define("WEIGHT",void 0,"weight");c.define("BLENDTARGET1",void 0,"shapetarget_1");c.define("BLENDTARGET2",void 0,"shapetarget_2");c.define("BLENDTARGET3",void 0,"shapetarget_3");c.define("BLENDTARGET4",void 0,"shapetarget_4");c.define("BLENDTARGET5",void 0,"shapetarget_5");c.define("BLENDTARGET6",void 0,"shapetarget_6");c.define("BLENDTARGET7",void 0,"shapetarget_7");c.define("BLENDTARGET8",void 0,"shapetarget_8");c.define("BLENDTARGET9",void 0,"shapetarget_9");c.define("BLENDTARGET10",void 0,"shapetarget_10");c.define("INTERPOLATION_LINEAR");c.define("INTERPOLATION_STEP");c.define("INTERPOLATION_CUBICSPLINE");c.define("RADIAN",void 0,"radian");c.define("DEGREE",void 0,"degree");c.define("TEXTURE_PURPOSE_DIFFUSE",void 0,"diffuse");c.define("TEXTURE_PURPOSE_NORMAL",void 0,"normal");c.define("QUERY_TYPE_INSTANCE_NAME");c.define("QUERY_TYPE_USER_FLAVOR_NAME");c.define("QUERY_TYPE_INSTANCE_NAME_WITH_USER_FLAVOR");c.define("QUERY_FORMAT_STRING");c.define("QUERY_FORMAT_REGEXP");c.define("WORLD_MATRIX");c.define("SHADER_PARAMETER_TYPE_OBJECT");c.define("SHADER_PARAMETER_TYPE_MATERIAL");c.define("SHADER_PARAMETER_TYPE_LIGHT");c.define("SHADER_PARAMETER_TYPE_JOINTSET");c.define("SHADER_PARAMETER_TYPE_MORPH");c.define("GLOBAL_STATES_USAGE_DO_NOTHING");c.define("GLOBAL_STATES_USAGE_IGNORE");c.define("GLOBAL_STATES_USAGE_INCLUSIVE");c.define("GLOBAL_STATES_USAGE_EXCLUSIVE");c.define("LOG_GENERAL");c.define("LOG_SHADER_CODE");c.define("LOG_GLBOOST_OBJECT_LIFECYCLE");c.define("LOG_GL_RESOURCE_LIFECYCLE");c.define("LOG_GL_ERROR");c.define("LOG_OMISSION_PROCESSING")})();GLBoost.isThisGLVersion_2=function(gl){if(typeof WebGL2RenderingContext==="undefined"){return false}return gl instanceof WebGL2RenderingContext};GLBoost.getNameOfGLBoostConstant=function(glboostConstant){return GLBoost.GLBOOST_CONSTANT_NAMES[glboostConstant]};GLBoost.getValueOfGLBoostConstant=function(glboostConstant){return GLBoost.GLBOOST_CONSTANT_VALUES[glboostConstant]}})(global);var GLBoost$1=global.GLBoost;class MiscUtil{constructor(){}static isDefinedAndTrue(value){return!!(typeof value!=="undefined"&&value)}static getTheValueOrAlternative(value,alternativeIfTheValueIsNullOrUndefined){if(typeof value!=="undefined"&&value!=null){return value}else{return alternativeIfTheValueIsNullOrUndefined}}static isJavaScriptObjectType(type,obj){var clas=Object.prototype.toString.call(obj).slice(8,-1);return obj!==undefined&&obj!==null&&clas===type}static consoleLog(logType,text){if(GLBoost$1.VALUE_CONSOLE_OUT_FOR_DEBUGGING&&GLBoost$1.valueOfGLBoostConstants[logType]){console.log(text)}}}GLBoost$1["MiscUtil"]=MiscUtil;class GLContextImpl{constructor(canvas,parent,initParameter){if(this.constructor===GLContextImpl){throw new TypeError("Cannot construct GLContextImpl instances directly")}if(!(parent instanceof GLContext)){throw new Error("This concrete class can only be instantiated from the 'GLContext' class.")}if(canvas===void 0){throw new Error("Failed to create WebGL Context due to no canvas object.")}this._canvas=canvas}init(glVersionString,ContextType,initParameter={antialias:true,premultipliedAlpha:true},gl){if(gl){this._gl=gl}else{let gl=this._canvas.getContext(glVersionString,initParameter);if(!gl){gl=this._canvas.getContext("experimental-"+glVersionString);if(!gl){throw new Error("This platform doesn't support WebGL.")}}if(!gl instanceof ContextType){throw new Error("Unexpected rendering context.")}this._gl=gl}}get gl(){return this._gl}set gl(gl){this._gl=gl}get canvas(){return this._canvas}}class GLContextWebGL1Impl extends GLContextImpl{constructor(canvas,parent,initParameter,gl){super(canvas,parent,initParameter);if(gl){super.init("webgl",null,initParameter,gl)}else{super.init("webgl",WebGLRenderingContext,initParameter,gl)}}}class GLContextWebGL2Impl extends GLContextImpl{constructor(canvas,parent,initParameter,gl){super(canvas,parent,initParameter);super.init("webgl2",WebGL2RenderingContext,initParameter,gl)}}class GLExtensionsManager{constructor(glContext){var gl=glContext.gl;if(GLBoost$1.VALUE_WEBGL_ONE_USE_EXTENSIONS){this._extVAO=gl.getExtension("OES_vertex_array_object");this._extDBs=gl.getExtension("WEBGL_draw_buffers");this._extTFA=gl.getExtension("EXT_texture_filter_anisotropic")||gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||gl.getExtension("MOZ_EXT_texture_filter_anisotropic");this._extEIUI=gl.getExtension("OES_element_index_uint");this._extDepthTex=gl.getExtension("WEBGL_depth_texture");this._extStdDerivatives=gl.getExtension("OES_standard_derivatives");this._extTFL=gl.getExtension("OES_texture_float_linear")}GLExtensionsManager._instances[glContext.belongingCanvasId]=this;this._glContext=glContext}static getInstance(glContext){if(GLExtensionsManager._instances[glContext.belongingCanvasId]){return GLExtensionsManager._instances[glContext.belongingCanvasId]}return new GLExtensionsManager(glContext)}get extVAO(){return this._extVAO}get extDBs(){return this._extDBs}get extTFA(){return this._extTFA}get extDepthTex(){return this._extDepthTex}createVertexArray(gl){if(GLBoost$1.isThisGLVersion_2(gl)){return gl.createVertexArray()}else if(this._extVAO){return this._extVAO.createVertexArrayOES()}else{return null}this._glContext.checkGLError()}bindVertexArray(gl,vao){if(GLBoost$1.isThisGLVersion_2(gl)){gl.bindVertexArray(vao);return true}else if(this._extVAO){this._extVAO.bindVertexArrayOES(vao);return true}else{return false}this._glContext.checkGLError()}drawBuffers(gl,buffers){let buffer=buffers;if(GLBoost$1.isThisGLVersion_2(gl)){gl.drawBuffers(buffers);buffer=buffer[0]}else if(this._extDBs){this.extDBs.drawBuffersWEBGL(buffers);buffer=buffer[0]}if(buffer===gl.NONE){gl.colorMask(false,false,false,false)}else{gl.colorMask(true,true,true,true)}this._glContext.checkGLError()}readBuffer(gl,buffers){let buffer=buffers;if(GLBoost$1.isThisGLVersion_2(gl)){buffer=buffer[0]}else if(this._extDBs){buffer=buffer[0]}gl.readBuffer(buffer);this._glContext.checkGLError()}colorAttachiment(gl,index){return this._extDBs?this._extDBs[`COLOR_ATTACHMENT${index}_WEBGL`]:gl[`COLOR_ATTACHMENT${index}`]}elementIndexBitSizeGLConstant(gl){if(GLBoost$1.isThisGLVersion_2(gl)||this._extEIUI){return gl.UNSIGNED_INT}else{return gl.UNSIGNED_SHORT}}elementIndexByteSizeNumber(gl){if(GLBoost$1.isThisGLVersion_2(gl)||this._extEIUI){return 4}else{return 2}}createUintArrayForElementIndex(gl,array){if(GLBoost$1.isThisGLVersion_2(gl)||this._extEIUI){return new Uint32Array(array)}else{return new Uint16Array(array)}}}GLExtensionsManager._instances=new Object;GLBoost$1["GLExtensionsManager"]=GLExtensionsManager;let singleton=Symbol();class L_GLBoostMonitor{constructor(enforcer){if(enforcer!==L_GLBoostMonitor._singletonEnforcer||!(this instanceof L_GLBoostMonitor)){throw new Error("This is a Singleton class. get the instance using 'getInstance' static method.")}this._glBoostObjects={};this._glResources=[];L_GLBoostMonitor._singletonEnforcer=Symbol()}static getInstance(){if(!this[singleton]){this[singleton]=new L_GLBoostMonitor(L_GLBoostMonitor._singletonEnforcer)}return this[singleton]}registerGLBoostObject(glBoostObject){this._glBoostObjects[glBoostObject.toString()]=glBoostObject;MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"GLBoost Resource: "+glBoostObject.toString()+" ("+glBoostObject.belongingCanvasId+") was created.")}deregisterGLBoostObject(glBoostObject){delete this._glBoostObjects[glBoostObject.toString()];MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"GLBoost Resource: "+glBoostObject.toString()+" ("+glBoostObject.belongingCanvasId+") was ready for discard.")}getGLBoostObjects(partOfGlBoostObjectClassName){let glBoostObjects=[];for(let instanceName in this._glBoostObjects){if(instanceName.indexOf(partOfGlBoostObjectClassName)>0){glBoostObjects.push(this._glBoostObjects[instanceName])}}return glBoostObjects}getGLBoostObjectWhichHasThisObjectId(objectId){for(let instanceName in this._glBoostObjects){if(this._glBoostObjects[instanceName].objectIndex===objectId){return this._glBoostObjects[instanceName]}}return null}printGLBoostObjects(){var objects=this._glBoostObjects;MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"========== GLBoost Object Lists [begin] ==========");for(var key in objects){if(objects.hasOwnProperty(key)){MiscUtil.consoleLog(key+"("+objects[key].belongingCanvasId+")")}}MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"========== GLBoost Object Lists [end] ==========")}printGLBoostObjectsOrderByName(){var objects=this._glBoostObjects;var objectArray=[];for(var key in objects){if(objects.hasOwnProperty(key)){objectArray.push(objects[key])}}objectArray.sort(function(a,b){if(ab)return 1;return 0});MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"========== GLBoost Object Lists [begin] ==========");objectArray.forEach(object=>{MiscUtil.consoleLog(object.toString()+" ("+object.belongingCanvasId+")")});MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"========== GLBoost Object Lists [end] ==========")}registerWebGLResource(glBoostObject,glResource){var glResourceName=glResource.constructor.name;this._glResources.push([glBoostObject,glResource]);MiscUtil.consoleLog(GLBoost$1.LOG_GL_RESOURCE_LIFECYCLE,"WebGL Resource: "+glResourceName+" was created by "+glBoostObject.toString()+" ("+glBoostObject.belongingCanvasId+").")}deregisterWebGLResource(glBoostObject,glResource){var glResourceName=glResource.constructor.name;this._glResources.forEach((glResource,i)=>{if(glResource[0]===glBoostObject&&glResource[1].constructor.name===glResourceName){this._glResources.splice(i,1)}});MiscUtil.consoleLog(GLBoost$1.LOG_GL_RESOURCE_LIFECYCLE,"WebGL Resource: "+glResourceName+" was deleted by "+glBoostObject.toString()+" ("+glBoostObject.belongingCanvasId+").")}getWebGLResources(webglResourceName){let webglResources=this._glResources.filter(glResourceArray=>{if(glResourceArray[1].constructor.name===webglResourceName){return true}else{return false}});return webglResources}printWebGLResources(){var glResources=this._glResources;glResources.sort(function(a,b){if(a[0]b[0])return 1;return 0});MiscUtil.consoleLog(GLBoost$1.LOG_GL_RESOURCE_LIFECYCLE,"========== WebGL Resource Lists [begin] ==========");glResources.forEach((glResource,i)=>{MiscUtil.consoleLog(i+1+": "+glResource[0].toString()+" ("+glResource[0].belongingCanvasId+") created "+glResource[1])});MiscUtil.consoleLog(GLBoost$1.LOG_GL_RESOURCE_LIFECYCLE,"========== WebGL Resource Lists [end] ==========")}printHierarchy(){var glBoostObjects=this._glBoostObjects;var scenes=[];for(var key in glBoostObjects){if(glBoostObjects.hasOwnProperty(key)){if(key.match(/Scene/)){scenes.push(glBoostObjects[key])}}}function putWhiteSpace(level){var str="";for(var i=0;i{var outputText=function searchRecursively(element,level){var outputText="";outputText+=putWhiteSpace(level)+element.toString()+" ("+element.belongingCanvasId+")\n";if(typeof element.getChildren==="undefined"){return outputText}var children=element.getChildren();children.forEach(child=>{outputText+=searchRecursively(child,level+1)});return outputText+="\n"}(scene,0);outputText=outputText.replace(/\n+/g,"\n");MiscUtil.consoleLog(outputText)});MiscUtil.consoleLog(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,"========== GLBoost Objects Hierarchy of Scenes [end] ==========")}}GLBoost$1["L_GLBoostMonitor"]=L_GLBoostMonitor;class GLContext{constructor(canvas,initParameter,gl,width,height){if(typeof gl!=="undefined"&&gl!==null){this.impl=new GLContextWebGL1Impl(canvas,initParameter,this,gl);this._canvasWidth=width;this._canvasHeight=height;GLContext._instances["nocanvas"]=this}else{if(GLContext._instances[canvas.id]instanceof GLContext){return GLContext._instances[canvas.id]}if(GLBoost$1.VALUE_TARGET_WEBGL_VERSION===1){this.impl=new GLContextWebGL1Impl(canvas,this,initParameter)}else if(GLBoost$1.VALUE_TARGET_WEBGL_VERSION===2){this.impl=new GLContextWebGL2Impl(canvas,this,initParameter)}GLContext._instances[canvas.id]=this;this._canvasWidth=canvas.width;this._canvasHeight=canvas.height}this._monitor=L_GLBoostMonitor.getInstance();this._glslProgramsLatestUsageCount=0}static getInstance(canvas,initParameter,gl,width,height){if(typeof canvas==="string"){canvas=window.document.querySelector(canvas)}return new GLContext(canvas,initParameter,gl,width,height)}get gl(){return this.impl.gl}set gl(gl){this.impl.gl=gl}get belongingCanvasId(){if(this.impl.canvas){return this.impl.canvas.id}else{return"nocanvas"}}get canvas(){return this.impl.canvas}checkGLError(){if(GLBoost$1.VALUE_CONSOLE_OUT_FOR_DEBUGGING===false){return}if(GLBoost$1.valueOfGLBoostConstants[GLBoost$1.LOG_GL_ERROR]===false){return}let gl=this.impl.gl;let errorCode=gl.getError();if(errorCode!==0){let errorTypes=["INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL"];let errorMessages=["An unacceptable value has been specified for an enumerated argument. The command is ignored and the error flag is set.","A numeric argument is out of range. The command is ignored and the error flag is set.","The specified command is not allowed for the current state. The command is ignored and the error flag is set.","The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.","Not enough memory is left to execute the command.","If the WebGL context is lost, this error is returned on the first call to getError. Afterwards and until the context has been restored, it returns gl.NO_ERROR."];errorTypes.forEach((errorType,i)=>{if(gl[errorType]===errorCode){MiscUtil.consoleLog(GLBoost$1.LOG_GL_ERROR,"WebGL Error: gl."+errorCode+"\n"+"Meaning:"+errorMessages[i])}})}}createVertexArray(glBoostObject){var gl=this.gl;var glem=GLExtensionsManager.getInstance(this);var glResource=glem.createVertexArray(gl);if(glResource){this._monitor.registerWebGLResource(glBoostObject,glResource)}this.checkGLError();return glResource}createBuffer(glBoostObject){var glResource=this.gl.createBuffer();this._monitor.registerWebGLResource(glBoostObject,glResource);this.checkGLError();return glResource}createFramebuffer(glBoostObject){var glResource=this.gl.createFramebuffer();this._monitor.registerWebGLResource(glBoostObject,glResource);this.checkGLError();return glResource}deleteFramebuffer(glBoostObject,frameBuffer){this._monitor.deregisterWebGLResource(glBoostObject,frameBuffer);this.gl.deleteFramebuffer(frameBuffer);this.checkGLError();frameBuffer=null}createRenderbuffer(glBoostObject){var glResource=this.gl.createRenderbuffer();this._monitor.registerWebGLResource(glBoostObject,glResource);this.checkGLError();return glResource}deleteRenderbuffer(glBoostObject,renderBuffer){this._monitor.deregisterWebGLResource(glBoostObject,renderBuffer);this.gl.deleteRenderbuffer(renderBuffer);this.checkGLError();renderBuffer=null}createShader(glBoostObject,shaderType){var glResource=this.gl.createShader(shaderType);this._monitor.registerWebGLResource(glBoostObject,glResource);this.checkGLError();return glResource}deleteShader(glBoostObject,shader){this._monitor.deregisterWebGLResource(glBoostObject,shader);this.gl.deleteShader(shader);this.checkGLError();shader=null}createProgram(glBoostObject){var glResource=this.gl.createProgram();this._monitor.registerWebGLResource(glBoostObject,glResource);this.checkGLError();return glResource}useProgram(program){this.gl.useProgram(program);this._currentProgramInuse=program;this.checkGLError();this._glslProgramsLatestUsageCount++}deleteProgram(glBoostObject,program){this._monitor.deregisterWebGLResource(glBoostObject,program);this.gl.deleteProgram(program);this.checkGLError()}deleteAllPrograms(){let programObjs=this._monitor.getWebGLResources("WebGLProgram");for(let programObj of programObjs){this.deleteProgram(programObj[0],programObj[1])}}getUniformLocation(glslProgram,uniformVariableName){let uniformLocation=this.gl.getUniformLocation(glslProgram,uniformVariableName);this.checkGLError();if(uniformLocation){uniformLocation.glslProgram=glslProgram;uniformLocation.glslProgramUsageCountWhenLastSet=-1}return uniformLocation}_setUniformValues(uniformFuncStr,args,forceUpdate){let uniformLocation=args[0];if(!uniformLocation){MiscUtil.consoleLog(GLBoost$1.LOG_OMISSION_PROCESSING,"LOG_OMISSION_PROCESSING: gl.uniformXXX call has been omitted since the uniformLocation is falsy (undefined or something)");return}if(this._currentProgramInuse.createdAt!==uniformLocation.glslProgram.createdAt){return}if(uniformLocation.glslProgramUsageCountWhenLastSet{let array=GLBoostObject["_"+typeName+"ExistArray"];for(let i=0;i{let array=GLBoostObject["_"+typeName+"ExistArray"];delete array[this["_"+typeName+"Index"]];this["_"+typeName+"Index"]=-1};if(this.className.indexOf("Mesh")!==-1){deleteIndex("object");if(this.className.indexOf("SkeltalMesh")!==-1){deleteIndex("jointSet")}}else if(this.className.indexOf("Light")!==-1){deleteIndex("light")}else if(this.className.indexOf("Material")!==-1){deleteIndex("material")}}_setName(){if(typeof GLBoostObject.classInfoDic[this.constructor.name]==="undefined"){GLBoostObject.classInfoDic[this.constructor.name]={}}GLBoostObject.classInfoDic[this.constructor.name]._instanceCount=typeof GLBoostObject.classInfoDic[this.constructor.name]._instanceCount==="undefined"?0:GLBoostObject.classInfoDic[this.constructor.name]._instanceCount+1;this._instanceName=this.constructor.name+"_"+GLBoostObject.classInfoDic[this.constructor.name]._instanceCount}toString(){return this._instanceName}get classUniqueNumber(){return this._classUniqueNumber}get className(){return this.constructor.name}get instanceName(){return this._instanceName}get belongingCanvasId(){return this._glBoostContext.belongingCanvasId}set userFlavorName(name){this._userFlavorName=name}get userFlavorName(){return this._userFlavorName}get instanceNameWithUserFlavor(){return this._instanceName+"__"+this._userFlavorName}readyForDiscard(){if(this._toRegister){this._glBoostMonitor.deregisterGLBoostObject(this)}this.tearDownExistIndexAndArray();this._readyForDiscard=true}get isReadyForDiscard(){return this._readyForDiscard}_copy(instance){instance._userFlavorName=this._userFlavorName}get objectIndex(){return this._objectIndex}}GLBoostObject.classInfoDic={};GLBoostObject._objectExistArray=[];GLBoostObject._materialExistArray=[];GLBoostObject._lightExistArray=[];GLBoostObject._jointSetExistArray=[];GLBoostObject._morphExistArray=[];GLBoost$1["GLBoostObject"]=GLBoostObject;class Vector2{constructor(x,y){if(ArrayBuffer.isView(x)){this.v=x;return}else{this.v=new Float32Array(2)}this.x=x;this.y=y}clone(){return new Vector2(this.x,this.y)}multiply(val){this.x*=val;this.y*=val;return this}static multiply(vec2,val){return new Vector2(vec2.x*val,vec2.y*val)}get x(){return this.v[0]}set x(x){this.v[0]=x}get y(){return this.v[1]}set y(y){this.v[1]=y}get raw(){return this.v}}GLBoost$1["Vector2"]=Vector2;class Vector4{constructor(x,y,z,w){if(ArrayBuffer.isView(x)){this.v=x;return}else{this.v=new Float32Array(4)}this.x=x;this.y=y;this.z=z;this.w=w}isEqual(vec){if(this.x===vec.x&&this.y===vec.y&&this.z===vec.z&&this.w===vec.w){return true}else{return false}}clone(){return new Vector4(this.x,this.y,this.z,this.w)}static zero(){return new Vector4(0,0,0,1)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}normalize(){var length=this.length();this.divide(length);return this}static normalize(vec4){var length=vec4.length();var newVec=new Vector4(vec4.x,vec4.y,vec4.z,vec4.w);newVec.divide(length);return newVec}toVector3(){return new Vector3(this.x,this.y,this.z)}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;this.w+=v.w;return this}static add(lv,rv){return new Vector4(lv.x+rv.x,lv.y+rv.y,lv.z+rv.z,lv.z+rv.z)}addWithOutW(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}subtract(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;this.w-=v.w;return this}static subtract(lv,rv){return new Vector4(lv.x-rv.x,lv.y-rv.y,lv.z-rv.z,lv.w-rv.w)}static addWithOutW(lv,rv){return new Vector4(lv.x+rv.x,lv.y+rv.y,lv.z+rv.z,lv.z)}multiply(val){this.x*=val;this.y*=val;this.z*=val;this.w*=val;return this}multiplyVector(vec){this.x*=vec.x;this.y*=vec.y;this.z*=vec.z;this.w*=vec.w;return this}static multiply(vec4,val){return new Vector4(vec4.x*val,vec4.y*val,vec4.z*val,vec4.w*val)}static multiplyVector(vec4,vec){return new Vector4(vec4.x*vec.x,vec4.y*vec.y,vec4.z*vec.z,vec4.w*vec.w)}divide(val){if(val!==0){this.x/=val;this.y/=val;this.z/=val;this.w/=val}else{console.warn("0 division occured!");this.x=Infinity;this.y=Infinity;this.z=Infinity;this.w=Infinity}return this}static divide(vec4,val){if(val!==0){return new Vector4(vec4.x/val,vec4.y/val,vec4.z/val,vec4.w/val)}else{console.warn("0 division occured!");return new Vector4(Infinity,Infinity,Infinity,Infinity)}}divideVector(vec4){this.x/=vec4.x;this.y/=vec4.y;this.z/=vec4.z;this.w/=vec4.w;return this}static divideVector(lvec4,rvec4){return new Vector4(lvec4.x/rvec4.x,lvec4.y/rvec4.y,lvec4.z/rvec4.z,lvec4.w/rvec4.w)}toString(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}get x(){return this.v[0]}set x(x){this.v[0]=x}get y(){return this.v[1]}set y(y){this.v[1]=y}get z(){return this.v[2]}set z(z){this.v[2]=z}get w(){return this.v[3]}set w(w){this.v[3]=w}get raw(){return this.v}}GLBoost$1["Vector4"]=Vector4;class Vector3{constructor(x,y,z){if(ArrayBuffer.isView(x)){this.v=x;return}else{this.v=new Float32Array(3)}this.x=x;this.y=y;this.z=z}isEqual(vec){if(this.x===vec.x&&this.y===vec.y&&this.z===vec.z){return true}else{return false}}static zero(){return new Vector3(0,0,0)}clone(){return new Vector3(this.x,this.y,this.z)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthSquared(){return this.x*this.x+this.y*this.y+this.z*this.z}static lengthSquared(vec3){return vec3.x*vec3.x+vec3.y*vec3.y+vec3.z*vec3.z}lengthTo(vec3){var deltaX=vec3.x-this.x;var deltaY=vec3.y-this.y;var deltaZ=vec3.z-this.z;return Math.sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ)}static lengthBtw(lhv,rhv){var deltaX=rhv.x-lhv.x;var deltaY=rhv.y-lhv.y;var deltaZ=rhv.z-lhv.z;return Math.sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ)}dotProduct(vec3){return this.x*vec3.x+this.y*vec3.y+this.z*vec3.z}static dotProduct(lv,rv){return lv.x*rv.x+lv.y*rv.y+lv.z*rv.z}cross(v){var x=this.y*v.z-this.z*v.y;var y=this.z*v.x-this.x*v.z;var z=this.x*v.y-this.y*v.x;this.x=x;this.y=y;this.z=z;return this}static cross(lv,rv){var x=lv.y*rv.z-lv.z*rv.y;var y=lv.z*rv.x-lv.x*rv.z;var z=lv.x*rv.y-lv.y*rv.x;return new Vector3(x,y,z)}normalize(){var length=this.length();this.divide(length);return this}static normalize(vec3){var length=vec3.length();var newVec=new Vector3(vec3.x,vec3.y,vec3.z);newVec.divide(length);return newVec}add(v){this.x+=v.x;this.y+=v.y;this.z+=v.z;return this}static add(lv,rv){return new Vector3(lv.x+rv.x,lv.y+rv.y,lv.z+rv.z)}subtract(v){this.x-=v.x;this.y-=v.y;this.z-=v.z;return this}static subtract(lv,rv){return new Vector3(lv.x-rv.x,lv.y-rv.y,lv.z-rv.z)}divide(val){if(val!==0){this.x/=val;this.y/=val;this.z/=val}else{console.warn("0 division occured!");this.x=Infinity;this.y=Infinity;this.z=Infinity}return this}static divide(vec3,val){if(val!==0){return new Vector3(vec3.x/val,vec3.y/val,vec3.z/val)}else{console.warn("0 division occured!");return new Vector3(Infinity,Infinity,Infinity)}}multiply(val){this.x*=val;this.y*=val;this.z*=val;return this}multiplyVector(vec){this.x*=vec.x;this.y*=vec.y;this.z*=vec.z;return this}static multiply(vec3,val){return new Vector3(vec3.x*val,vec3.y*val,vec3.z*val)}static multiplyVector(vec3,vec){return new Vector3(vec3.x*vec.x,vec3.y*vec.y,vec3.z*vec.z)}static angleOfVectors(lhv,rhv){let cos_sita=Vector3.dotProduct(lhv,rhv)/(lhv.length()*rhv.length());let sita=Math.acos(cos_sita);if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){sita=MathUtil.radianToDegree(sita)}return sita}divideVector(vec3){this.x/=vec3.x;this.y/=vec3.y;this.z/=vec3.z;return this}static divideVector(lvec3,rvec3){return new Vector3(lvec3.x/rvec3.x,lvec3.y/rvec3.y,lvec3.z/rvec3.z)}toVector4(){return new Vector4(this.x,this.y,this.z,1)}toString(){return"("+this.x+", "+this.y+", "+this.z+")"}get x(){return this.v[0]}set x(x){this.v[0]=x}get y(){return this.v[1]}set y(y){this.v[1]=y}get z(){return this.v[2]}set z(z){this.v[2]=z}get raw(){return this.v}}GLBoost$1["Vector3"]=Vector3;class Matrix33{constructor(m,isColumnMajor=false,shaderParameterType=void 0,shaderParameterEntityIndex=void 0,shaderParameterName=void 0){this.m=new Float32Array(9);if(arguments.length>=9){if(isColumnMajor===true){let m=arguments;this.setComponents(m[0],m[3],m[6],m[1],m[4],m[7],m[2],m[5],m[8])}else{this.setComponents.apply(this,arguments)}}else if(Array.isArray(m)){if(isColumnMajor===true){this.setComponents(m[0],m[3],m[6],m[1],m[4],m[7],m[2],m[5],m[8])}else{this.setComponents.apply(this,m)}}else if(m instanceof Float32Array){if(isColumnMajor===true){this.setComponents(m[0],m[3],m[6],m[1],m[4],m[7],m[2],m[5],m[8])}else{this.setComponents.apply(this,m)}}else{this.identity()}}setComponents(m00,m01,m02,m10,m11,m12,m20,m21,m22){this.m00=m00;this.m01=m01;this.m02=m02;this.m10=m10;this.m11=m11;this.m12=m12;this.m20=m20;this.m21=m21;this.m22=m22;return this}identity(){this.setComponents(1,0,0,0,1,0,0,0,1);return this}static identity(){return new Matrix33(1,0,0,0,1,0,0,0,1)}clone(){return new Matrix33(this.m[0],this.m[3],this.m[6],this.m[1],this.m[4],this.m[7],this.m[2],this.m[5],this.m[8])}rotateX(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return this.setComponents(1,0,0,0,cos,-sin,0,sin,cos)}static rotateX(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix33(1,0,0,0,cos,-sin,0,sin,cos)}rotateY(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);this.setComponents(cos,0,sin,0,1,0,-sin,0,cos);return this}static rotateY(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix33(cos,0,sin,0,1,0,-sin,0,cos)}rotateZ(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return this.setComponents(cos,-sin,0,sin,cos,0,0,0,1)}static rotateZ(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix33(cos,-sin,0,sin,cos,0,0,0,1)}static rotateXYZ(x,y,z){return Matrix33.rotateZ(z).multiply(Matrix33.rotateY(y).multiply(Matrix33.rotateX(x)))}static rotate(vec3){return Matrix33.rotateZ(vec3.z).multiply(Matrix33.rotateY(vec3.y).multiply(Matrix33.rotateX(vec3.x)))}scale(vec){return this.setComponents(vec.x,0,0,0,vec.y,0,0,0,vec.z)}static scale(vec){return new Matrix33(vec.x,0,0,0,vec.y,0,0,0,vec.z)}zero(){this.setComponents(0,0,0,0,0,0,0,0,0);return this}static zero(){return new Matrix33(0,0,0,0,0,0,0,0,0)}flatten(){return this.m}flattenAsArray(){return[this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8]]}_swap(l,r){this.m[r]=[this.m[l],this.m[l]=this.m[r]][0]}transpose(){this._swap(1,3);this._swap(2,6);this._swap(5,8);return this}static transpose(mat){var mat_t=new Matrix33(mat.m00,mat.m10,mat.m20,mat.m01,mat.m11,mat.m21,mat.m02,mat.m12,mat.m22);return mat_t}multiplyVector(vec){var x=this.m00*vec.x+this.m01*vec.y+this.m02*vec.z;var y=this.m10*vec.x+this.m11*vec.y+this.m12*vec.z;var z=this.m20*vec.x+this.m21*vec.y+this.m22*vec.z;return new Vector3(x,y,z)}multiply(mat){var m00=this.m00*mat.m00+this.m01*mat.m10+this.m02*mat.m20;var m01=this.m00*mat.m01+this.m01*mat.m11+this.m02*mat.m21;var m02=this.m00*mat.m02+this.m01*mat.m12+this.m02*mat.m22;var m10=this.m10*mat.m00+this.m11*mat.m10+this.m12*mat.m20;var m11=this.m10*mat.m01+this.m11*mat.m11+this.m12*mat.m21;var m12=this.m10*mat.m02+this.m11*mat.m12+this.m12*mat.m22;var m20=this.m20*mat.m00+this.m21*mat.m10+this.m22*mat.m20;var m21=this.m20*mat.m01+this.m21*mat.m11+this.m22*mat.m21;var m22=this.m20*mat.m02+this.m21*mat.m12+this.m22*mat.m22;return this.setComponents(m00,m01,m02,m10,m11,m12,m20,m21,m22)}static multiply(l_m,r_m){var m00=l_m.m00*r_m.m00+l_m.m01*r_m.m10+l_m.m02*r_m.m20;var m10=l_m.m10*r_m.m00+l_m.m11*r_m.m10+l_m.m12*r_m.m20;var m20=l_m.m20*r_m.m00+l_m.m21*r_m.m10+l_m.m22*r_m.m20;var m01=l_m.m00*r_m.m01+l_m.m01*r_m.m11+l_m.m02*r_m.m21;var m11=l_m.m10*r_m.m01+l_m.m11*r_m.m11+l_m.m12*r_m.m21;var m21=l_m.m20*r_m.m01+l_m.m21*r_m.m11+l_m.m22*r_m.m21;var m02=l_m.m00*r_m.m02+l_m.m01*r_m.m12+l_m.m02*r_m.m22;var m12=l_m.m10*r_m.m02+l_m.m11*r_m.m12+l_m.m12*r_m.m22;var m22=l_m.m20*r_m.m02+l_m.m21*r_m.m12+l_m.m22*r_m.m22;return new Matrix33(m00,m01,m02,m10,m11,m12,m20,m21,m22)}determinant(){return this.m00*this.m11*this.m22+this.m10*this.m21*this.m02+this.m20*this.m01*this.m12-this.m00*this.m21*this.m12-this.m20*this.m11*this.m02-this.m10*this.m01*this.m22}static determinant(mat){return mat.m00*mat.m11*mat.m22+mat.m10*mat.m21*mat.m02+mat.m20*mat.m01*mat.m12-mat.m00*mat.m21*mat.m12-mat.m20*mat.m11*mat.m02-mat.m10*mat.m01*mat.m22}invert(){var det=this.determinant();var m00=(this.m11*this.m22-this.m12*this.m21)/det;var m01=(this.m02*this.m21-this.m01*this.m22)/det;var m02=(this.m01*this.m12-this.m02*this.m11)/det;var m10=(this.m12*this.m20-this.m10*this.m22)/det;var m11=(this.m00*this.m22-this.m02*this.m20)/det;var m12=(this.m02*this.m10-this.m00*this.m12)/det;var m20=(this.m10*this.m21-this.m11*this.m20)/det;var m21=(this.m01*this.m20-this.m00*this.m21)/det;var m22=(this.m00*this.m11-this.m01*this.m10)/det;return this.setComponents(m00,m01,m02,m10,m11,m12,m20,m21,m22)}static invert(mat){var det=mat.determinant();var m00=(mat.m11*mat.m22-mat.m12*mat.m21)/det;var m01=(mat.m02*mat.m21-mat.m01*mat.m22)/det;var m02=(mat.m01*mat.m12-mat.m02*mat.m11)/det;var m10=(mat.m12*mat.m20-mat.m10*mat.m22)/det;var m11=(mat.m00*mat.m22-mat.m02*mat.m20)/det;var m12=(mat.m02*mat.m10-mat.m00*mat.m12)/det;var m20=(mat.m10*mat.m21-mat.m11*mat.m20)/det;var m21=(mat.m01*mat.m20-mat.m00*mat.m21)/det;var m22=(mat.m00*mat.m11-mat.m01*mat.m10)/det;return new Matrix33(m00,m01,m02,m10,m11,m12,m20,m21,m22)}set m00(val){this.m[0]=val}get m00(){return this.m[0]}set m10(val){this.m[1]=val}get m10(){return this.m[1]}set m20(val){this.m[2]=val}get m20(){return this.m[2]}set m01(val){this.m[3]=val}get m01(){return this.m[3]}set m11(val){this.m[4]=val}get m11(){return this.m[4]}set m21(val){this.m[5]=val}get m21(){return this.m[5]}set m02(val){this.m[6]=val}get m02(){return this.m[6]}set m12(val){this.m[7]=val}get m12(){return this.m[7]}set m22(val){this.m[8]=val}get m22(){return this.m[8]}toString(){return this.m00+" "+this.m01+" "+this.m02+"\n"+this.m10+" "+this.m11+" "+this.m12+"\n"+this.m20+" "+this.m21+" "+this.m22+"\n"}nearZeroToZero(value){if(Math.abs(value)<1e-5){value=0}else if(.99999=16){this.m=new Float32Array(16);if(isColumnMajor===true){let m=arguments;this.setComponents(m[0],m[4],m[8],m[12],m[1],m[5],m[9],m[13],m[2],m[6],m[10],m[14],m[3],m[7],m[11],m[15])}else{this.setComponents.apply(this,arguments)}}else if(Array.isArray(m)){this.m=new Float32Array(16);if(isColumnMajor===true){this.setComponents(m[0],m[4],m[8],m[12],m[1],m[5],m[9],m[13],m[2],m[6],m[10],m[14],m[3],m[7],m[11],m[15])}else{this.setComponents.apply(this,m)}}else if(m instanceof Float32Array){this.m=new Float32Array(16);if(notCopyFloat32Array){this.m=m}else{this.m=new Float32Array(16);if(isColumnMajor===true){this.setComponents(m[0],m[4],m[8],m[12],m[1],m[5],m[9],m[13],m[2],m[6],m[10],m[14],m[3],m[7],m[11],m[15])}else{this.setComponents.apply(this,m)}}}else{this.m=new Float32Array(16);this.identity()}}setComponents(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33){this.m00=m00;this.m01=m01;this.m02=m02;this.m03=m03;this.m10=m10;this.m11=m11;this.m12=m12;this.m13=m13;this.m20=m20;this.m21=m21;this.m22=m22;this.m23=m23;this.m30=m30;this.m31=m31;this.m32=m32;this.m33=m33;return this}copyComponents(mat4){this.setComponents.apply(this,mat4.m)}clone(){return new Matrix44$2(this.m[0],this.m[4],this.m[8],this.m[12],this.m[1],this.m[5],this.m[9],this.m[13],this.m[2],this.m[6],this.m[10],this.m[14],this.m[3],this.m[7],this.m[11],this.m[15])}identity(){this.setComponents(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this}static identity(){return new Matrix44$2(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}translate(vec){return this.setComponents(1,0,0,vec.x,0,1,0,vec.y,0,0,1,vec.z,0,0,0,1)}putTranslate(vec){this.m03=vec.x;this.m13=vec.y;this.m23=vec.z}getTranslate(){return new Vector3(this.m03,this.m13,this.m23)}static translate(vec){return new Matrix44$2(1,0,0,vec.x,0,1,0,vec.y,0,0,1,vec.z,0,0,0,1)}scale(vec){return this.setComponents(vec.x,0,0,0,0,vec.y,0,0,0,0,vec.z,0,0,0,0,1)}static scale(vec){return new Matrix44$2(vec.x,0,0,0,0,vec.y,0,0,0,0,vec.z,0,0,0,0,1)}addScale(vec){this.m00*=vec.x;this.m11*=vec.y;this.m22*=vec.z;return this}rotateX(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return this.setComponents(1,0,0,0,0,cos,-sin,0,0,sin,cos,0,0,0,0,1)}static rotateX(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix44$2(1,0,0,0,0,cos,-sin,0,0,sin,cos,0,0,0,0,1)}rotateY(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return this.setComponents(cos,0,sin,0,0,1,0,0,-sin,0,cos,0,0,0,0,1)}static rotateY(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix44$2(cos,0,sin,0,0,1,0,0,-sin,0,cos,0,0,0,0,1)}rotateZ(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return this.setComponents(cos,-sin,0,0,sin,cos,0,0,0,0,1,0,0,0,0,1)}static rotateZ(angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var cos=Math.cos(radian);var sin=Math.sin(radian);return new Matrix44$2(cos,-sin,0,0,sin,cos,0,0,0,0,1,0,0,0,0,1)}static rotateXYZ(x,y,z){return Matrix33.rotateZ(z).multiply(Matrix33.rotateY(y).multiply(Matrix33.rotateX(x))).toMatrix44()}toEulerAngles(){let rotate=null;if(Math.abs(this.m20)!=1){let y=-Math.asin(this.m20);let x=Math.atan2(this.m21/Math.cos(y),this.m22/Math.cos(y));let z=Math.atan2(this.m10/Math.cos(y),this.m00/Math.cos(y));rotate=new Vector3(x,y,z)}else if(this.m20===-1){rotate=new Vector3(Math.atan2(this.m01,this.m02),Math.PI/2,0)}else{rotate=new Vector3(Math.atan2(-this.m01,-this.m02),-Math.PI/2,0)}return rotate}zero(){this.setComponents(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return this}static zero(){return new Matrix44$2(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}flatten(){return this.m}flattenAsArray(){return[this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15]]}_swap(l,r){this.m[r]=[this.m[l],this.m[l]=this.m[r]][0]}transpose(){this._swap(1,4);this._swap(2,8);this._swap(3,12);this._swap(6,9);this._swap(7,13);this._swap(11,14);return this}static transpose(mat){var mat_t=new Matrix44$2(mat.m00,mat.m10,mat.m20,mat.m30,mat.m01,mat.m11,mat.m21,mat.m31,mat.m02,mat.m12,mat.m22,mat.m32,mat.m03,mat.m13,mat.m23,mat.m33);return mat_t}multiplyVector(vec){var x=this.m00*vec.x+this.m01*vec.y+this.m02*vec.z+this.m03*vec.w;var y=this.m10*vec.x+this.m11*vec.y+this.m12*vec.z+this.m13*vec.w;var z=this.m20*vec.x+this.m21*vec.y+this.m22*vec.z+this.m23*vec.w;var w=this.m30*vec.x+this.m31*vec.y+this.m32*vec.z+this.m33*vec.w;return new Vector4(x,y,z,w)}multiply(mat){var m00=this.m00*mat.m00+this.m01*mat.m10+this.m02*mat.m20+this.m03*mat.m30;var m01=this.m00*mat.m01+this.m01*mat.m11+this.m02*mat.m21+this.m03*mat.m31;var m02=this.m00*mat.m02+this.m01*mat.m12+this.m02*mat.m22+this.m03*mat.m32;var m03=this.m00*mat.m03+this.m01*mat.m13+this.m02*mat.m23+this.m03*mat.m33;var m10=this.m10*mat.m00+this.m11*mat.m10+this.m12*mat.m20+this.m13*mat.m30;var m11=this.m10*mat.m01+this.m11*mat.m11+this.m12*mat.m21+this.m13*mat.m31;var m12=this.m10*mat.m02+this.m11*mat.m12+this.m12*mat.m22+this.m13*mat.m32;var m13=this.m10*mat.m03+this.m11*mat.m13+this.m12*mat.m23+this.m13*mat.m33;var m20=this.m20*mat.m00+this.m21*mat.m10+this.m22*mat.m20+this.m23*mat.m30;var m21=this.m20*mat.m01+this.m21*mat.m11+this.m22*mat.m21+this.m23*mat.m31;var m22=this.m20*mat.m02+this.m21*mat.m12+this.m22*mat.m22+this.m23*mat.m32;var m23=this.m20*mat.m03+this.m21*mat.m13+this.m22*mat.m23+this.m23*mat.m33;var m30=this.m30*mat.m00+this.m31*mat.m10+this.m32*mat.m20+this.m33*mat.m30;var m31=this.m30*mat.m01+this.m31*mat.m11+this.m32*mat.m21+this.m33*mat.m31;var m32=this.m30*mat.m02+this.m31*mat.m12+this.m32*mat.m22+this.m33*mat.m32;var m33=this.m30*mat.m03+this.m31*mat.m13+this.m32*mat.m23+this.m33*mat.m33;return this.setComponents(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33)}multiplyByLeft(mat){var m00=mat.m00*this.m00+mat.m01*this.m10+mat.m02*this.m20+mat.m03*this.m30;var m01=mat.m00*this.m01+mat.m01*this.m11+mat.m02*this.m21+mat.m03*this.m31;var m02=mat.m00*this.m02+mat.m01*this.m12+mat.m02*this.m22+mat.m03*this.m32;var m03=mat.m00*this.m03+mat.m01*this.m13+mat.m02*this.m23+mat.m03*this.m33;var m10=mat.m10*this.m00+mat.m11*this.m10+mat.m12*this.m20+mat.m13*this.m30;var m11=mat.m10*this.m01+mat.m11*this.m11+mat.m12*this.m21+mat.m13*this.m31;var m12=mat.m10*this.m02+mat.m11*this.m12+mat.m12*this.m22+mat.m13*this.m32;var m13=mat.m10*this.m03+mat.m11*this.m13+mat.m12*this.m23+mat.m13*this.m33;var m20=mat.m20*this.m00+mat.m21*this.m10+mat.m22*this.m20+mat.m23*this.m30;var m21=mat.m20*this.m01+mat.m21*this.m11+mat.m22*this.m21+mat.m23*this.m31;var m22=mat.m20*this.m02+mat.m21*this.m12+mat.m22*this.m22+mat.m23*this.m32;var m23=mat.m20*this.m03+mat.m21*this.m13+mat.m22*this.m23+mat.m23*this.m33;var m30=mat.m30*this.m00+mat.m31*this.m10+mat.m32*this.m20+mat.m33*this.m30;var m31=mat.m30*this.m01+mat.m31*this.m11+mat.m32*this.m21+mat.m33*this.m31;var m32=mat.m30*this.m02+mat.m31*this.m12+mat.m32*this.m22+mat.m33*this.m32;var m33=mat.m30*this.m03+mat.m31*this.m13+mat.m32*this.m23+mat.m33*this.m33;return this.setComponents(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33)}static multiply(l_m,r_m){var m00=l_m.m00*r_m.m00+l_m.m01*r_m.m10+l_m.m02*r_m.m20+l_m.m03*r_m.m30;var m10=l_m.m10*r_m.m00+l_m.m11*r_m.m10+l_m.m12*r_m.m20+l_m.m13*r_m.m30;var m20=l_m.m20*r_m.m00+l_m.m21*r_m.m10+l_m.m22*r_m.m20+l_m.m23*r_m.m30;var m30=l_m.m30*r_m.m00+l_m.m31*r_m.m10+l_m.m32*r_m.m20+l_m.m33*r_m.m30;var m01=l_m.m00*r_m.m01+l_m.m01*r_m.m11+l_m.m02*r_m.m21+l_m.m03*r_m.m31;var m11=l_m.m10*r_m.m01+l_m.m11*r_m.m11+l_m.m12*r_m.m21+l_m.m13*r_m.m31;var m21=l_m.m20*r_m.m01+l_m.m21*r_m.m11+l_m.m22*r_m.m21+l_m.m23*r_m.m31;var m31=l_m.m30*r_m.m01+l_m.m31*r_m.m11+l_m.m32*r_m.m21+l_m.m33*r_m.m31;var m02=l_m.m00*r_m.m02+l_m.m01*r_m.m12+l_m.m02*r_m.m22+l_m.m03*r_m.m32;var m12=l_m.m10*r_m.m02+l_m.m11*r_m.m12+l_m.m12*r_m.m22+l_m.m13*r_m.m32;var m22=l_m.m20*r_m.m02+l_m.m21*r_m.m12+l_m.m22*r_m.m22+l_m.m23*r_m.m32;var m32=l_m.m30*r_m.m02+l_m.m31*r_m.m12+l_m.m32*r_m.m22+l_m.m33*r_m.m32;var m03=l_m.m00*r_m.m03+l_m.m01*r_m.m13+l_m.m02*r_m.m23+l_m.m03*r_m.m33;var m13=l_m.m10*r_m.m03+l_m.m11*r_m.m13+l_m.m12*r_m.m23+l_m.m13*r_m.m33;var m23=l_m.m20*r_m.m03+l_m.m21*r_m.m13+l_m.m22*r_m.m23+l_m.m23*r_m.m33;var m33=l_m.m30*r_m.m03+l_m.m31*r_m.m13+l_m.m32*r_m.m23+l_m.m33*r_m.m33;return new Matrix44$2(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33)}toMatrix33(){return new Matrix33(this.m00,this.m01,this.m02,this.m10,this.m11,this.m12,this.m20,this.m21,this.m22)}static toMatrix33(mat){return new Matrix33(mat.m00,mat.m01,mat.m02,mat.m10,mat.m11,mat.m12,mat.m20,mat.m21,mat.m22)}determinant(){return this.m00*this.m11*this.m22*this.m33+this.m00*this.m12*this.m23*this.m31+this.m00*this.m13*this.m21*this.m32+this.m01*this.m10*this.m23*this.m32+this.m01*this.m12*this.m20*this.m33+this.m01*this.m13*this.m22*this.m30+this.m02*this.m10*this.m21*this.m33+this.m02*this.m11*this.m23*this.m30+this.m02*this.m13*this.m20*this.m31+this.m03*this.m10*this.m22*this.m31+this.m03*this.m11*this.m20*this.m32+this.m03*this.m12*this.m21*this.m30-this.m00*this.m11*this.m23*this.m32-this.m00*this.m12*this.m21*this.m33-this.m00*this.m13*this.m22*this.m31-this.m01*this.m10*this.m22*this.m33-this.m01*this.m12*this.m23*this.m30-this.m01*this.m13*this.m20*this.m32-this.m02*this.m10*this.m23*this.m31-this.m02*this.m11*this.m20*this.m33-this.m02*this.m13*this.m21*this.m30-this.m03*this.m10*this.m21*this.m32-this.m03*this.m11*this.m22*this.m30-this.m03*this.m12*this.m20*this.m31}static determinant(mat){return mat.m00*mat.m11*mat.m22*mat.m33+mat.m00*mat.m12*mat.m23*mat.m31+mat.m00*mat.m13*mat.m21*mat.m32+mat.m01*mat.m10*mat.m23*mat.m32+mat.m01*mat.m12*mat.m20*mat.m33+mat.m01*mat.m13*mat.m22*mat.m30+mat.m02*mat.m10*mat.m21*mat.m33+mat.m02*mat.m11*mat.m23*mat.m30+mat.m02*mat.m13*mat.m20*mat.m31+mat.m03*mat.m10*mat.m22*mat.m31+mat.m03*mat.m11*mat.m20*mat.m32+mat.m03*mat.m12*mat.m21*mat.m30-mat.m00*mat.m11*mat.m23*mat.m32-mat.m00*mat.m12*mat.m21*mat.m33-mat.m00*mat.m13*mat.m22*mat.m31-mat.m01*mat.m10*mat.m22*mat.m33-mat.m01*mat.m12*mat.m23*mat.m30-mat.m01*mat.m13*mat.m20*mat.m32-mat.m02*mat.m10*mat.m23*mat.m31-mat.m02*mat.m11*mat.m20*mat.m33-mat.m02*mat.m13*mat.m21*mat.m30-mat.m03*mat.m10*mat.m21*mat.m32-mat.m03*mat.m11*mat.m22*mat.m30-mat.m03*mat.m12*mat.m20*mat.m31}invert(){var det=this.determinant();var m00=(this.m11*this.m22*this.m33+this.m12*this.m23*this.m31+this.m13*this.m21*this.m32-this.m11*this.m23*this.m32-this.m12*this.m21*this.m33-this.m13*this.m22*this.m31)/det;var m01=(this.m01*this.m23*this.m32+this.m02*this.m21*this.m33+this.m03*this.m22*this.m31-this.m01*this.m22*this.m33-this.m02*this.m23*this.m31-this.m03*this.m21*this.m32)/det;var m02=(this.m01*this.m12*this.m33+this.m02*this.m13*this.m31+this.m03*this.m11*this.m32-this.m01*this.m13*this.m32-this.m02*this.m11*this.m33-this.m03*this.m12*this.m31)/det;var m03=(this.m01*this.m13*this.m22+this.m02*this.m11*this.m23+this.m03*this.m12*this.m21-this.m01*this.m12*this.m23-this.m02*this.m13*this.m21-this.m03*this.m11*this.m22)/det;var m10=(this.m10*this.m23*this.m32+this.m12*this.m20*this.m33+this.m13*this.m22*this.m30-this.m10*this.m22*this.m33-this.m12*this.m23*this.m30-this.m13*this.m20*this.m32)/det;var m11=(this.m00*this.m22*this.m33+this.m02*this.m23*this.m30+this.m03*this.m20*this.m32-this.m00*this.m23*this.m32-this.m02*this.m20*this.m33-this.m03*this.m22*this.m30)/det;var m12=(this.m00*this.m13*this.m32+this.m02*this.m10*this.m33+this.m03*this.m12*this.m30-this.m00*this.m12*this.m33-this.m02*this.m13*this.m30-this.m03*this.m10*this.m32)/det;var m13=(this.m00*this.m12*this.m23+this.m02*this.m13*this.m20+this.m03*this.m10*this.m22-this.m00*this.m13*this.m22-this.m02*this.m10*this.m23-this.m03*this.m12*this.m20)/det;var m20=(this.m10*this.m21*this.m33+this.m11*this.m23*this.m30+this.m13*this.m20*this.m31-this.m10*this.m23*this.m31-this.m11*this.m20*this.m33-this.m13*this.m21*this.m30)/det;var m21=(this.m00*this.m23*this.m31+this.m01*this.m20*this.m33+this.m03*this.m21*this.m30-this.m00*this.m21*this.m33-this.m01*this.m23*this.m30-this.m03*this.m20*this.m31)/det;var m22=(this.m00*this.m11*this.m33+this.m01*this.m13*this.m30+this.m03*this.m10*this.m31-this.m00*this.m13*this.m31-this.m01*this.m10*this.m33-this.m03*this.m11*this.m30)/det;var m23=(this.m00*this.m13*this.m21+this.m01*this.m10*this.m23+this.m03*this.m11*this.m20-this.m00*this.m11*this.m23-this.m01*this.m13*this.m20-this.m03*this.m10*this.m21)/det;var m30=(this.m10*this.m22*this.m31+this.m11*this.m20*this.m32+this.m12*this.m21*this.m30-this.m10*this.m21*this.m32-this.m11*this.m22*this.m30-this.m12*this.m20*this.m31)/det;var m31=(this.m00*this.m21*this.m32+this.m01*this.m22*this.m30+this.m02*this.m20*this.m31-this.m00*this.m22*this.m31-this.m01*this.m20*this.m32-this.m02*this.m21*this.m30)/det;var m32=(this.m00*this.m12*this.m31+this.m01*this.m10*this.m32+this.m02*this.m11*this.m30-this.m00*this.m11*this.m32-this.m01*this.m12*this.m30-this.m02*this.m10*this.m31)/det;var m33=(this.m00*this.m11*this.m22+this.m01*this.m12*this.m20+this.m02*this.m10*this.m21-this.m00*this.m12*this.m21-this.m01*this.m10*this.m22-this.m02*this.m11*this.m20)/det;return this.setComponents(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33)}static invert(mat){var det=mat.determinant();var m00=(mat.m11*mat.m22*mat.m33+mat.m12*mat.m23*mat.m31+mat.m13*mat.m21*mat.m32-mat.m11*mat.m23*mat.m32-mat.m12*mat.m21*mat.m33-mat.m13*mat.m22*mat.m31)/det;var m01=(mat.m01*mat.m23*mat.m32+mat.m02*mat.m21*mat.m33+mat.m03*mat.m22*mat.m31-mat.m01*mat.m22*mat.m33-mat.m02*mat.m23*mat.m31-mat.m03*mat.m21*mat.m32)/det;var m02=(mat.m01*mat.m12*mat.m33+mat.m02*mat.m13*mat.m31+mat.m03*mat.m11*mat.m32-mat.m01*mat.m13*mat.m32-mat.m02*mat.m11*mat.m33-mat.m03*mat.m12*mat.m31)/det;var m03=(mat.m01*mat.m13*mat.m22+mat.m02*mat.m11*mat.m23+mat.m03*mat.m12*mat.m21-mat.m01*mat.m12*mat.m23-mat.m02*mat.m13*mat.m21-mat.m03*mat.m11*mat.m22)/det;var m10=(mat.m10*mat.m23*mat.m32+mat.m12*mat.m20*mat.m33+mat.m13*mat.m22*mat.m30-mat.m10*mat.m22*mat.m33-mat.m12*mat.m23*mat.m30-mat.m13*mat.m20*mat.m32)/det;var m11=(mat.m00*mat.m22*mat.m33+mat.m02*mat.m23*mat.m30+mat.m03*mat.m20*mat.m32-mat.m00*mat.m23*mat.m32-mat.m02*mat.m20*mat.m33-mat.m03*mat.m22*mat.m30)/det;var m12=(mat.m00*mat.m13*mat.m32+mat.m02*mat.m10*mat.m33+mat.m03*mat.m12*mat.m30-mat.m00*mat.m12*mat.m33-mat.m02*mat.m13*mat.m30-mat.m03*mat.m10*mat.m32)/det;var m13=(mat.m00*mat.m12*mat.m23+mat.m02*mat.m13*mat.m20+mat.m03*mat.m10*mat.m22-mat.m00*mat.m13*mat.m22-mat.m02*mat.m10*mat.m23-mat.m03*mat.m12*mat.m20)/det;var m20=(mat.m10*mat.m21*mat.m33+mat.m11*mat.m23*mat.m30+mat.m13*mat.m20*mat.m31-mat.m10*mat.m23*mat.m31-mat.m11*mat.m20*mat.m33-mat.m13*mat.m21*mat.m30)/det;var m21=(mat.m00*mat.m23*mat.m31+mat.m01*mat.m20*mat.m33+mat.m03*mat.m21*mat.m30-mat.m00*mat.m21*mat.m33-mat.m01*mat.m23*mat.m30-mat.m03*mat.m20*mat.m31)/det;var m22=(mat.m00*mat.m11*mat.m33+mat.m01*mat.m13*mat.m30+mat.m03*mat.m10*mat.m31-mat.m00*mat.m13*mat.m31-mat.m01*mat.m10*mat.m33-mat.m03*mat.m11*mat.m30)/det;var m23=(mat.m00*mat.m13*mat.m21+mat.m01*mat.m10*mat.m23+mat.m03*mat.m11*mat.m20-mat.m00*mat.m11*mat.m23-mat.m01*mat.m13*mat.m20-mat.m03*mat.m10*mat.m21)/det;var m30=(mat.m10*mat.m22*mat.m31+mat.m11*mat.m20*mat.m32+mat.m12*mat.m21*mat.m30-mat.m10*mat.m21*mat.m32-mat.m11*mat.m22*mat.m30-mat.m12*mat.m20*mat.m31)/det;var m31=(mat.m00*mat.m21*mat.m32+mat.m01*mat.m22*mat.m30+mat.m02*mat.m20*mat.m31-mat.m00*mat.m22*mat.m31-mat.m01*mat.m20*mat.m32-mat.m02*mat.m21*mat.m30)/det;var m32=(mat.m00*mat.m12*mat.m31+mat.m01*mat.m10*mat.m32+mat.m02*mat.m11*mat.m30-mat.m00*mat.m11*mat.m32-mat.m01*mat.m12*mat.m30-mat.m02*mat.m10*mat.m31)/det;var m33=(mat.m00*mat.m11*mat.m22+mat.m01*mat.m12*mat.m20+mat.m02*mat.m10*mat.m21-mat.m00*mat.m12*mat.m21-mat.m01*mat.m10*mat.m22-mat.m02*mat.m11*mat.m20)/det;return new Matrix44$2(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33)}set m00(val){this.m[0]=val}get m00(){return this.m[0]}set m10(val){this.m[1]=val}get m10(){return this.m[1]}set m20(val){this.m[2]=val}get m20(){return this.m[2]}set m30(val){this.m[3]=val}get m30(){return this.m[3]}set m01(val){this.m[4]=val}get m01(){return this.m[4]}set m11(val){this.m[5]=val}get m11(){return this.m[5]}set m21(val){this.m[6]=val}get m21(){return this.m[6]}set m31(val){this.m[7]=val}get m31(){return this.m[7]}set m02(val){this.m[8]=val}get m02(){return this.m[8]}set m12(val){this.m[9]=val}get m12(){return this.m[9]}set m22(val){this.m[10]=val}get m22(){return this.m[10]}set m32(val){this.m[11]=val}get m32(){return this.m[11]}set m03(val){this.m[12]=val}get m03(){return this.m[12]}set m13(val){this.m[13]=val}get m13(){return this.m[13]}set m23(val){this.m[14]=val}get m23(){return this.m[14]}set m33(val){this.m[15]=val}get m33(){return this.m[15]}toString(){return this.m00+" "+this.m01+" "+this.m02+" "+this.m03+" \n"+this.m10+" "+this.m11+" "+this.m12+" "+this.m13+" \n"+this.m20+" "+this.m21+" "+this.m22+" "+this.m23+" \n"+this.m30+" "+this.m31+" "+this.m32+" "+this.m33+" \n"}nearZeroToZero(value){if(Math.abs(value)<1e-5){value=0}else if(.999991){qr=.999}else if(qr<-1){qr=-.999}let ph=Math.acos(qr);let s2;if(qr<0&&ph>Math.PI/2){qr=-lhq.w*rhq.w-lhq.x*rhq.x-lhq.y*rhq.y-lhq.z*rhq.z;ph=Math.acos(qr);s2=-1*Math.sin(ph*ratio)/Math.sin(ph)}else{s2=Math.sin(ph*ratio)/Math.sin(ph)}let s1=Math.sin(ph*(1-ratio))/Math.sin(ph);q.x=lhq.x*s1+rhq.x*s2;q.y=lhq.y*s1+rhq.y*s2;q.z=lhq.z*s1+rhq.z*s2;q.w=lhq.w*s1+rhq.w*s2;return q}}get rotationMatrix(){var sx=this.x*this.x;var sy=this.y*this.y;var sz=this.z*this.z;var cx=this.y*this.z;var cy=this.x*this.z;var cz=this.x*this.y;var wx=this.w*this.x;var wy=this.w*this.y;var wz=this.w*this.z;return new Matrix44$2(1-2*(sy+sz),2*(cz-wz),2*(cy+wy),0,2*(cz+wz),1-2*(sx+sz),2*(cx-wx),0,2*(cy-wy),2*(cx+wx),1-2*(sx+sy),0,0,0,0,1)}get rotationMatrix33(){var sx=this.x*this.x;var sy=this.y*this.y;var sz=this.z*this.z;var cx=this.y*this.z;var cy=this.x*this.z;var cz=this.x*this.y;var wx=this.w*this.x;var wy=this.w*this.y;var wz=this.w*this.z;return new Matrix33(1-2*(sy+sz),2*(cz-wz),2*(cy+wy),2*(cz+wz),1-2*(sx+sz),2*(cx-wx),2*(cy-wy),2*(cx+wx),1-2*(sx+sy))}axisAngle(axisVec3,angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var halfAngle=.5*radian;var sin=Math.sin(halfAngle);var axis=Vector3.normalize(axisVec3);this.w=Math.cos(halfAngle);this.x=sin*axis.x;this.y=sin*axis.y;this.z=sin*axis.z;return this}static axisAngle(axisVec3,angle){var radian=0;if(GLBoost$1["VALUE_ANGLE_UNIT"]===GLBoost$1.DEGREE){radian=MathUtil.degreeToRadian(angle)}else{radian=angle}var halfAngle=.5*radian;var sin=Math.sin(halfAngle);var axis=Vector3.normalize(axisVec3);return new Quaternion(sin*axis.x,sin*axis.y,sin*axis.z,Math.cos(halfAngle))}add(q){this.x+=q.x;this.y+=q.y;this.z+=q.z;this.w+=q.w;return this}multiply(q){let result=new Quaternion(0,0,0,1);result.w=this.w*q.w-this.x*q.x-this.y*q.y-this.z*q.z;result.x=this.w*q.x+this.x*q.w+this.y*q.z-this.z*q.y;result.y=this.w*q.y+this.y*q.w+this.x*q.z-this.z*q.x;result.z=this.w*q.z+this.z*q.w+this.x*q.y-this.y*q.x;this.x=result.x;this.y=result.y;this.z=result.z;this.w=result.w;return this}static multiply(q1,q2){let result=new Quaternion(0,0,0,1);result.w=q1.w*q2.w-q1.x*q2.x-q1.y*q2.y-q1.z*q2.z;result.x=q1.w*q2.x+q1.x*q2.w+q1.y*q2.z-q1.z*q2.y;result.y=q1.w*q2.y+q1.y*q2.w+q1.x*q2.z-q1.z*q2.x;result.z=q1.w*q2.z+q1.z*q2.w+q1.x*q2.y-q1.y*q2.x;return result}static fromMatrix(m){let q=new Quaternion;let tr=m.m00+m.m11+m.m22;if(tr>0){let S=.5/Math.sqrt(tr+1);q.w=.25/S;q.x=(m.m21-m.m12)*S;q.y=(m.m02-m.m20)*S;q.z=(m.m10-m.m01)*S}else if(m.m00>m.m11&&m.m00>m.m22){let S=Math.sqrt(1+m.m00-m.m11-m.m22)*2;q.w=(m.m21-m.m12)/S;q.x=.25*S;q.y=(m.m01+m.m10)/S;q.z=(m.m02+m.m20)/S}else if(m.m11>m.m22){let S=Math.sqrt(1+m.m11-m.m00-m.m22)*2;q.w=(m.m02-m.m20)/S;q.x=(m.m01+m.m10)/S;q.y=.25*S;q.z=(m.m12+m.m21)/S}else{let S=Math.sqrt(1+m.m22-m.m00-m.m11)*2;q.w=(m.m10-m.m01)/S;q.x=(m.m02+m.m20)/S;q.y=(m.m12+m.m21)/S;q.z=.25*S}return q}static fromPosition(vec3){let q=new Quaternion(vec3.x,vec3.y,vec3.z,0);return q}at(i){switch(i%4){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w}}setAt(i,val){switch(i%4){case 0:this.x=val;break;case 1:this.y=val;break;case 2:this.z=val;break;case 3:this.w=val;break}}normalize(){let norm=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);this.x/=norm;this.y/=norm;this.z/=norm;this.w/=norm;return this}toString(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}GLBoost$1["Quaternion"]=Quaternion;class MathUtil{constructor(){}static radianToDegree(rad){return rad*180/Math.PI}static degreeToRadian(deg){return deg*Math.PI/180}static arrayToVector(element){if(Array.isArray(element)){if(typeof element[3]!=="undefined"){return new Vector4(element[0],element[1],element[2],element[3])}else if(typeof element[2]!=="undefined"){return new Vector3(element[0],element[1],element[2])}else{return new Vector2(element[0],element[1])}}else{return element}}static makeSubArray(array,componentN){if(componentN===4){return[array[0],array[1],array[2],array[3]]}else if(componentN===3){return[array[0],array[1],array[2]]}else if(componentN===2){return[array[0],array[1]]}else{return array[0]}}static vectorToArray(element){if(element instanceof Vector2){return[element.x,element.y]}else if(element instanceof Vector3){return[element.x,element.y,element.z]}else if(element instanceof Vector4||element instanceof Quaternion){return[element.x,element.y,element.z,element.w]}else{return element}}static compomentNumberOfVector(element){if(element instanceof Vector2){return 2}else if(element instanceof Vector3){return 3}else if(element instanceof Vector4||element instanceof Quaternion){return 4}else if(Array.isArray(element)){return element.length}else{return 0}}static packNormalizedVec4ToVec2(x,y,z,w,criteria){let v0=0;let v1=0;x=(x+1)/2;y=(y+1)/2;z=(z+1)/2;w=(w+1)/2;let ir=Math.floor(x*(criteria-1));let ig=Math.floor(y*(criteria-1));let irg=ir*criteria+ig;v0=irg/criteria;let ib=Math.floor(z*(criteria-1));let ia=Math.floor(w*(criteria-1));let iba=ib*criteria+ia;v1=iba/criteria;return[v0,v1]}static unProject(windowPosVec3,inversePVMat44,viewportVec4,zNear,zFar){const input=new Vector4((windowPosVec3.x-viewportVec4.x)/viewportVec4.z*2-1,(windowPosVec3.y-viewportVec4.y)/viewportVec4.w*2-1,2*windowPosVec3.z-1,1);const PVMat44=inversePVMat44;const out=PVMat44.multiplyVector(input);if(out.w===0){console.warn("Zero division!")}const output=out.multiply(1/out.w).toVector3();return output}}GLBoost$1["MathUtil"]=MathUtil;class AnimationUtil{constructor(){}static lerp(start,end,ratio,componentN){if(componentN===1){return start*(1-ratio)+end*ratio}else{if(start instanceof Quaternion){return Quaternion.qlerp(start,end,ratio)}else{return start.multiply(1-ratio).add(end.multiply(ratio))}}}static interpolate(inputArray,outputArray,input,componentN,method=GLBoost$1.INTERPOLATION_LINEAR){if(inputlatestInputValue){latestInputValue=inputLatestValueAtThisAttribute}}return latestInputValue}setCurrentAnimationValue(inputName,inputValue){this._setDirtyToAnimatedElement(inputName);this._currentAnimationInputValues[inputName]=inputValue}removeCurrentAnimationValue(inputName){delete this._currentAnimationInputValues[inputName]}setActiveAnimationLine(lineName){this._activeAnimationLineName=lineName}set translate(vec){if(this._translate.isEqual(vec)){return}this._translate=vec.clone();if(this._is_trs_matrix_updated);this._is_trs_matrix_updated=false;this._is_translate_updated=true;this._needUpdate()}getTranslateNotAnimated(){if(this._is_translate_updated){return this._translate.clone()}else if(this._is_trs_matrix_updated){this._translate.x=this._matrix.m03;this._translate.y=this._matrix.m13;this._translate.z=this._matrix.m23;this._is_translate_updated=true}return this._translate.clone()}get translate(){return this.getTranslateAtOrStatic(this._activeAnimationLineName,this._getCurrentAnimationInputValue(this._activeAnimationLineName))}getTranslateAt(lineName,inputValue){let value=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"translate");if(value!==null){this._translate=value;this._is_translate_updated=true;this._is_trs_matrix_updated=false}return value}getTranslateAtOrStatic(lineName,inputValue){let value=this.getTranslateAt(lineName,inputValue);if(value===null){return this.getTranslateNotAnimated()}return value}set rotate(vec){if(this._rotate.isEqual(vec)){return}this._rotate=vec.clone();this._is_trs_matrix_updated=false;this._is_quaternion_updated=false;this._is_euler_angles_updated=true;this._needUpdate()}get rotate(){return this.getRotateAtOrStatic(this._activeAnimationLineName,this._getCurrentAnimationInputValue(this._activeAnimationLineName))}getRotateAt(lineName,inputValue){let value=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"rotate");if(value!==null){this._rotate=value;this._is_euler_angles_updated=true}return value}getRotateAtOrStatic(lineName,inputValue){let value=null;if(this._activeAnimationLineName){value=this.getRotateAt(this._activeAnimationLineName,inputValue)}if(value===null){return this.getRotateNotAnimated()}return value}getRotateNotAnimated(){if(this._is_euler_angles_updated){return this._rotate.clone()}else if(this._is_trs_matrix_updated){this._rotate=this._matrix.toEulerAngles()}else if(this._is_quaternion_updated){this._rotate=this._quaternion.rotationMatrix.toEulerAngles()}this._is_euler_angles_updated=true;return this._rotate.clone()}set scale(vec){if(this._scale.isEqual(vec)){return}this._scale=vec.clone();if(this._is_trs_matrix_updated);this._is_trs_matrix_updated=false;this._is_scale_updated=true;this._needUpdate()}get scale(){return this.getScaleAtOrStatic(this._activeAnimationLineName,this._getCurrentAnimationInputValue(this._activeAnimationLineName))}getScaleAt(lineName,inputValue){let value=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"scale");if(value!==null){this._scale=value.clone();this._is_scale_updated=true;this._is_trs_matrix_updated=false}return value}getScaleAtOrStatic(lineName,inputValue){let value=this.getScaleAt(lineName,inputValue);if(value===null){return this.getScaleNotAnimated()}return value}getScaleNotAnimated(){if(this._is_scale_updated){return this._scale.clone()}else if(this._is_trs_matrix_updated){let m=this._matrix;this._scale.x=Math.sqrt(m.m00*m.m00+m.m01*m.m01+m.m02*m.m02);this._scale.y=Math.sqrt(m.m10*m.m10+m.m11*m.m11+m.m12*m.m12);this._scale.z=Math.sqrt(m.m20*m.m20+m.m21*m.m21+m.m22*m.m22);this._is_scale_updated=true}return this._scale.clone()}set matrix(mat){this._matrix=mat.clone();this._is_trs_matrix_updated=true;this._is_scale_updated=false;this._is_translate_updated=false;this._is_quaternion_updated=false;this._is_euler_angles_updated=false;this._needUpdate()}get matrix(){let input=void 0;if(this._activeAnimationLineName!==null){input=this._getCurrentAnimationInputValue(this._activeAnimationLineName)}let value=this.getMatrixAtOrStatic(this._activeAnimationLineName,input);return value}getMatrixAt(lineName,inputValue){let value=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"matrix");if(value!==null){this._translate=value;this._is_translate_updated=true}return value}getMatrixNotAnimated(){if(this._is_trs_matrix_updated){return this._matrix.clone()}let rotationMatrix=Matrix44$2.identity();rotationMatrix=this.getQuaternionNotAnimated().rotationMatrix;let scale=this.getScaleNotAnimated();this._matrix=Matrix44$2.multiply(rotationMatrix,Matrix44$2.scale(scale));let translateVec=this.getTranslateNotAnimated();this._matrix.m03=translateVec.x;this._matrix.m13=translateVec.y;this._matrix.m23=translateVec.z;this._is_trs_matrix_updated=true;return this._matrix.clone()}get transformMatrix(){let input=void 0;if(this._activeAnimationLineName!==null){input=this._getCurrentAnimationInputValue(this._activeAnimationLineName)}const matrix=this.getMatrixAtOrStatic(this._activeAnimationLineName,input);return matrix}isTrsMatrixNeeded(lineName,inputValue){let result=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"translate")===null&&this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"rotate")===null&&this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"quaternion")===null&&this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"scale")===null;return result}getMatrixAtOrStatic(lineName,inputValue){let input=inputValue;if(this.isTrsMatrixNeeded(lineName,inputValue)&&this._is_trs_matrix_updated){return this.getMatrixNotAnimated()}else{let rotationMatrix=Matrix44$2.identity();let quaternion=this.getQuaternionAtOrStatic(lineName,input);rotationMatrix=quaternion.rotationMatrix;let scale=this.getScaleAtOrStatic(lineName,input);this._matrix=Matrix44$2.multiply(rotationMatrix,Matrix44$2.scale(scale));let translateVec=this.getTranslateAtOrStatic(lineName,input);this._matrix.m03=translateVec.x;this._matrix.m13=translateVec.y;this._matrix.m23=translateVec.z;return this._matrix.clone()}this._is_trs_matrix_updated=true}set quaternion(quat){if(this._quaternion.isEqual(quat)){return}this._quaternion=quat.clone();this._is_trs_matrix_updated=false;this._is_euler_angles_updated=false;this._is_quaternion_updated=true;this._needUpdate()}get quaternion(){return this.getQuaternionAtOrStatic(this._activeAnimationLineName,this._getCurrentAnimationInputValue(this._activeAnimationLineName))}getQuaternionAt(lineName,inputValue){let value=this._getAnimatedTransformValue(inputValue,this._animationLine[lineName],"quaternion");if(value!==null){this._quaternion=value;this._is_quaternion_updated=true;this._is_trs_matrix_updated=false}return value}getQuaternionAtOrStatic(lineName,inputValue){let value=this.getQuaternionAt(lineName,inputValue);if(value===null){return this.getQuaternionNotAnimated()}return value}getQuaternionNotAnimated(){let value=null;if(this._is_quaternion_updated){return this._quaternion}else if(!this._is_quaternion_updated){if(this._is_trs_matrix_updated){value=Quaternion.fromMatrix(this._matrix)}else if(this._is_euler_angles_updated){value=Quaternion.fromMatrix(Matrix44$2.rotateXYZ(this._rotate.x,this._rotate.y,this._rotate.z))}else{console.log("jojjeoe")}this._quaternion=value;this._is_quaternion_updated=true}return this._quaternion}get inverseTransformMatrix(){if(!this._is_inverse_trs_matrix_updated){this._invMatrix=this.transformMatrix.invert();this._is_inverse_trs_matrix_updated=true}return this._invMatrix.clone()}get normalMatrix(){return Matrix44$2.invert(this.transformMatrix).transpose().toMatrix33()}_copy(instance){super._copy(instance);instance._translate=this._translate.clone();instance._scale=this._scale.clone();instance._rotate=this._rotate.clone();instance._quaternion=this._quaternion.clone();instance._matrix=this._matrix.clone();instance._animationLine={};for(let lineName in this._animationLine){instance._animationLine[lineName]={};for(let attributeName in this._animationLine[lineName]){instance._animationLine[lineName][attributeName]={};instance._animationLine[lineName][attributeName].input=this._animationLine[lineName][attributeName].input.concat();let instanceOutput=[];let thisOutput=this._animationLine[lineName][attributeName].output;for(let i=0;i>>8^x}return(crc^-1)>>>0}}Hash._crc32table="00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".split(" ");class SkeletalShaderSource{VSDefine_SkeletalShaderSource(in_,out_,f,lights,material,extraData){var shaderText="";shaderText+=`${in_} vec4 aVertex_joint;\n`;shaderText+=`${in_} vec4 aVertex_weight;\n`;if(!GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL){shaderText+="uniform mat4 skinTransformMatrices["+extraData.jointN+"];\n"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL===1){shaderText+="uniform vec4 quatArray["+extraData.jointN+"];\n";shaderText+="uniform vec4 transArray["+extraData.jointN+"];\n"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL>1){shaderText+="uniform vec4 quatTranslationArray["+extraData.jointN+"];\n";shaderText+="uniform vec3 translationScale;\n"}return shaderText}VSMethodDefine_SkeletalShaderSource(f,lights,material,extraData){let shaderText="";shaderText+=`\n mat3 toNormalMatrix(mat4 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];\n \n float b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32;\n \n float determinantVal = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n \n return mat3(\n a11 * b11 - a12 * b10 + a13 * b09, a12 * b08 - a10 * b11 - a13 * b07, a10 * b10 - a11 * b08 + a13 * b06,\n a02 * b10 - a01 * b11 - a03 * b09, a00 * b11 - a02 * b08 + a03 * b07, a01 * b08 - a00 * b10 - a03 * b06,\n a31 * b05 - a32 * b04 + a33 * b03, a32 * b02 - a30 * b05 - a33 * b01, a30 * b04 - a31 * b02 + a33 * b00) / determinantVal;\n }\n\n mat4 transposeMatrix(mat4 m) {\n return mat4(m[0][0], m[1][0], m[2][0], m[3][0],\n m[0][1], m[1][1], m[2][1], m[3][1],\n m[0][2], m[1][2], m[2][2], m[3][2],\n m[0][3], m[1][3], m[2][3], m[3][3]);\n }\n\n mat4 createMatrixFromQuaternionTransform( vec4 quaternion, vec3 translation ) {\n vec4 q = quaternion;\n vec3 t = translation;\n\n float sx = q.x * q.x;\n float sy = q.y * q.y;\n float sz = q.z * q.z;\n float cx = q.y * q.z;\n float cy = q.x * q.z;\n float cz = q.x * q.y;\n float wx = q.w * q.x;\n float wy = q.w * q.y;\n float wz = q.w * q.z;\n\n \n return mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz + wz), 2.0 * (cy - wy), 0.0,\n 2.0 * (cz - wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx + wx), 0.0,\n 2.0 * (cy + wy), 2.0 * (cx - wx), 1.0 - 2.0 * (sx + sy), 0.0,\n t.x, t.y, t.z, 1.0\n );\n /*\n return mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz + wz), 2.0 * (cy - wy), t.x,\n 2.0 * (cz - wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx + wx), t.y,\n 2.0 * (cy + wy), 2.0 * (cx - wx), 1.0 - 2.0 * (sx + sy), t.z,\n 0.0, 0.0, 0.0, 1.0\n );\n\n return mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz - wz), 2.0 * (cy + wy), 0.0,\n 2.0 * (cz + wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx - wx), 0.0,\n 2.0 * (cy - wy), 2.0 * (cx + wx), 1.0 - 2.0 * (sx + sy), 0.0,\n t.x, t.y, t.z, 1.0\n );\n\n return mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz - wz), 2.0 * (cy + wy), t.x,\n 2.0 * (cz + wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx - wx), t.y,\n 2.0 * (cy - wy), 2.0 * (cx + wx), 1.0 - 2.0 * (sx + sy), t.z,\n 0.0, 0.0, 0.0, 1.0\n );\n */\n }\n\n mat4 createMatrixFromQuaternionTransformUniformScale( vec4 quaternion, vec4 translationUniformScale ) {\n vec4 q = quaternion;\n vec3 t = translationUniformScale.xyz;\n float scale = translationUniformScale.w;\n\n float sx = q.x * q.x;\n float sy = q.y * q.y;\n float sz = q.z * q.z;\n float cx = q.y * q.z;\n float cy = q.x * q.z;\n float cz = q.x * q.y;\n float wx = q.w * q.x;\n float wy = q.w * q.y;\n float wz = q.w * q.z;\n\n \n mat4 mat = mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz + wz), 2.0 * (cy - wy), 0.0,\n 2.0 * (cz - wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx + wx), 0.0,\n 2.0 * (cy + wy), 2.0 * (cx - wx), 1.0 - 2.0 * (sx + sy), 0.0,\n t.x, t.y, t.z, 1.0\n );\n /*\n mat4 mat = mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz + wz), 2.0 * (cy - wy), t.x,\n 2.0 * (cz - wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx + wx), t.y,\n 2.0 * (cy + wy), 2.0 * (cx - wx), 1.0 - 2.0 * (sx + sy), t.z,\n 0.0, 0.0, 0.0, 1.0\n );\n\n mat4 mat = mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz - wz), 2.0 * (cy + wy), 0.0,\n 2.0 * (cz + wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx - wx), 0.0,\n 2.0 * (cy - wy), 2.0 * (cx + wx), 1.0 - 2.0 * (sx + sy), 0.0,\n t.x, t.y, t.z, 1.0\n);\n\n mat4 mat = mat4(\n 1.0 - 2.0 * (sy + sz), 2.0 * (cz - wz), 2.0 * (cy + wy), t.x,\n 2.0 * (cz + wz), 1.0 - 2.0 * (sx + sz), 2.0 * (cx - wx), t.y,\n 2.0 * (cy - wy), 2.0 * (cx + wx), 1.0 - 2.0 * (sx + sy), t.z,\n 0.0, 0.0, 0.0, 1.0\n );\n */\n\n mat4 uniformScaleMat = mat4(\n scale, 0.0, 0.0, 0.0,\n 0.0, scale, 0.0, 0.0,\n 0.0, 0.0, scale, 0.0,\n 0.0, 0.0, 0.0, 1.0\n );\n \n// mat[0][0] *= scale;\n// mat[0][1] *= scale;\n// mat[0][2] *= scale;\n// mat[1][0] *= scale;\n// mat[1][1] *= scale;\n// mat[1][2] *= scale;\n// mat[2][0] *= scale;\n// mat[2][1] *= scale;\n// mat[2][2] *= scale;\n \n return mat*uniformScaleMat;\n}\n\n/*\n mat4 createMatrixFromQuaternionTransform( vec4 quaternion, vec3 translation ) {\n vec4 q = quaternion;\n vec3 t = translation;\n float x = q.x;\n float y = q.y;\n float z = q.z;\n float w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float yx = y * x2;\n float yy = y * y2;\n float zx = z * x2;\n float zy = z * y2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float m_0 = 1.0 - yy - zz;\n float m_3 = yx - wz;\n float m_6 = zx + wy;\n float m_1 = yx + wz;\n float m_4 = 1.0 - xx - zz;\n float m_7 = zy - wx;\n float m_2 = zx - wy;\n float m_5 = zy + wx;\n float m_8 = 1.0 - xx - yy;\n\n return mat4(\n m_0, m_3, m_6, 0.0,\n m_1, m_4, m_7, 0.0,\n m_2, m_5, m_8, 0.0,\n t.x, t.y, t.z, 0.0\n );\n\n return mat4(\n m_0, m_3, m_6, t.x,\n m_1, m_4, m_7, t.y,\n m_2, m_5, m_8, t.z,\n 0.0, 0.0, 0.0, 0.0\n );\n\n \n return mat4(\n m_0, m_1, m_2, 0.0,\n m_3, m_4, m_5, 0.0,\n m_6, m_7, m_8, 0.0,\n t.x, t.y, t.z, 0.0\n );\n\nreturn mat4(\n m_0, m_1, m_2, t.x,\n m_3, m_4, m_5, t.y,\n m_6, m_7, m_8, t.z,\n 0.0, 0.0, 0.0, 0.0\n);\n\n }\n */\n\n vec4 unpackedVec2ToNormalizedVec4(vec2 vec_xy, float criteria){\n\n float r;\n float g;\n float b;\n float a;\n \n float ix = floor(vec_xy.x * criteria);\n float v1x = ix / criteria;\n float v1y = ix - floor(v1x) * criteria;\n \n r = ( v1x + 1.0 ) / (criteria-1.0);\n g = ( v1y + 1.0 ) / (criteria-1.0);\n \n float iy = floor( vec_xy.y * criteria);\n float v2x = iy / criteria;\n float v2y = iy - floor(v2x) * criteria;\n \n b = ( v2x + 1.0 ) / (criteria-1.0);\n a = ( v2y + 1.0 ) / (criteria-1.0);\n \n r -= 1.0/criteria;\n g -= 1.0/criteria;\n b -= 1.0/criteria;\n a -= 1.0/criteria;\n \n r = r*2.0-1.0;\n g = g*2.0-1.0;\n b = b*2.0-1.0;\n a = a*2.0-1.0;\n \n return vec4(r, g, b, a);\n }\n `;return shaderText}VSPreProcess_SkeletalShaderSource(existCamera_f,f,lights,material,extraData){let shaderText="";shaderText+="vec4 weightVec = aVertex_weight;\n";if(!GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL){shaderText+="mat4 skinMat = weightVec.x * skinTransformMatrices[int(aVertex_joint.x)];\n";shaderText+="skinMat += weightVec.y * skinTransformMatrices[int(aVertex_joint.y)];\n";shaderText+="skinMat += weightVec.z * skinTransformMatrices[int(aVertex_joint.z)];\n";shaderText+="skinMat += weightVec.w * skinTransformMatrices[int(aVertex_joint.w)];\n"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL===1){shaderText+="mat4 skinMat = weightVec.x * createMatrixFromQuaternionTransformUniformScale(quatArray[int(aVertex_joint.x)], transArray[int(aVertex_joint.x)]);\n";shaderText+="skinMat += weightVec.y * createMatrixFromQuaternionTransformUniformScale(quatArray[int(aVertex_joint.y)], transArray[int(aVertex_joint.y)]);\n";shaderText+="skinMat += weightVec.z * createMatrixFromQuaternionTransformUniformScale(quatArray[int(aVertex_joint.z)], transArray[int(aVertex_joint.z)]);\n";shaderText+="skinMat += weightVec.w * createMatrixFromQuaternionTransformUniformScale(quatArray[int(aVertex_joint.w)], transArray[int(aVertex_joint.w)]);\n"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL>1){shaderText+=`vec2 criteria = vec2(4096.0, 4096.0);\n`;shaderText+=`mat4 skinMat = weightVec.x * createMatrixFromQuaternionTransform(\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.x)].xy, criteria.x),\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.x)].zw, criteria.y).xyz*translationScale);\n`;shaderText+=`skinMat += weightVec.y * createMatrixFromQuaternionTransform(\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.y)].xy, criteria.x),\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.y)].zw, criteria.y).xyz*translationScale);\n`;shaderText+=`skinMat += weightVec.z * createMatrixFromQuaternionTransform(\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.z)].xy, criteria.x),\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.z)].zw, criteria.y).xyz*translationScale);\n`;shaderText+=`skinMat += weightVec.w * createMatrixFromQuaternionTransform(\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.w)].xy, criteria.x),\n unpackedVec2ToNormalizedVec4(quatTranslationArray[int(aVertex_joint.w)].zw, criteria.y).xyz*translationScale);\n`}shaderText+="position_world = skinMat * position_local;\n";if(Shader._exist(f,GLBoost$1.NORMAL)){shaderText+="mat3 normalMatrix = toNormalMatrix(skinMat);\n";shaderText+="normal_world = normalize(normalMatrix * normal_local);\n";if(Shader._exist(f,GLBoost$1.TANGENT)){shaderText+="tangent_world = normalize(normalMatrix * tangent_local);\n"}}shaderText+="isSkinning = true;\n";return shaderText}prepare_SkeletalShaderSource(gl,shaderProgram,expression,vertexAttribs,existCamera_f,lights,material,extraData){let vertexAttribsAsResult=[];vertexAttribs.forEach(attribName=>{if(attribName==="joint"||attribName==="weight"){vertexAttribsAsResult.push(attribName);shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName])}});if(!GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL){let skinTransformMatricesUniformLocation=this._glContext.getUniformLocation(shaderProgram,"skinTransformMatrices");material.setUniform(shaderProgram,"uniform_skinTransformMatrices",skinTransformMatricesUniformLocation);material._semanticsDic["JOINTMATRIX"]="skinTransformMatrices"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL===1){let quatArrayUniformLocation=this._glContext.getUniformLocation(shaderProgram,"quatArray");material.setUniform(shaderProgram,"uniform_quatArray",quatArrayUniformLocation);material._semanticsDic["JOINT_QUATERNION"]="quatArray";let transArrayUniformLocation=this._glContext.getUniformLocation(shaderProgram,"transArray");material.setUniform(shaderProgram,"uniform_transArray",transArrayUniformLocation);material._semanticsDic["JOINT_TRANSLATION"]="transArray"}else if(GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL>1){let quatArrayUniformLocation=this._glContext.getUniformLocation(shaderProgram,"quatTranslationArray");material.setUniform(shaderProgram,"uniform_quatTranslationArray",quatArrayUniformLocation);material._semanticsDic["JOINT_QUATTRANSLATION"]="quatTranslationArray";let transArrayUniformLocation=this._glContext.getUniformLocation(shaderProgram,"translationScale");material.setUniform(shaderProgram,"uniform_translationScale",transArrayUniformLocation)}return vertexAttribsAsResult}}class VertexWorldShaderSource{VSDefine_VertexWorldShaderSource(in_,out_,f,lights,material,extraData){let shaderText="";if(Shader._exist(f,GLBoost.NORMAL)){shaderText+=`${in_} vec3 aVertex_normal;\n`;shaderText+=`${out_} vec3 v_normal_world;\n`;if(Shader._exist(f,GLBoost.TANGENT)){shaderText+=`${in_} vec3 aVertex_tangent;\n`;if(material.getTextureFromPurpose(GLBoost.TEXTURE_PURPOSE_NORMAL)){shaderText+=`${out_} vec3 v_tangent_world;\n`;shaderText+=`${out_} vec3 v_binormal_world;\n`}}}shaderText+="uniform mat4 worldMatrix;\n";shaderText+="uniform mat4 viewMatrix;\n";shaderText+="uniform mat4 projectionMatrix;\n";shaderText+="uniform mat3 normalMatrix;\n";shaderText+=` uniform highp ivec2 objectIds;\n`;shaderText+=`${out_} vec3 v_position_world;\n`;return shaderText}VSPreProcess_VertexWorldShaderSource(existCamera_f,f,lights,material,extraData){var shaderText="";shaderText+=" vec4 position_world;\n";shaderText+=" vec3 normal_world;\n";shaderText+=" vec3 tangent_world;\n";return shaderText}VSTransform_VertexWorldShaderSource(existCamera_f,f,lights,material,extraData){var shaderText="";shaderText+=" if (!isSkinning) {\n";shaderText+=" position_world = worldMatrix * position_local;\n";if(Shader._exist(f,GLBoost.NORMAL)){shaderText+=" normal_world = normalMatrix * normal_local;\n"}shaderText+=" }\n";shaderText+=" mat4 pvwMatrix = projectionMatrix * viewMatrix * worldMatrix;\n";shaderText+=" v_position_world = position_world.xyz;\n";let normalTexture=material.getTextureFromPurpose(GLBoost.TEXTURE_PURPOSE_NORMAL);if(Shader._exist(f,GLBoost.NORMAL)){shaderText+=" v_normal_world = normal_world;\n";if(Shader._exist(f,GLBoost.TANGENT)&&!material.isFlatShading&&normalTexture){{shaderText+=" if (!isSkinning) {\n";shaderText+=" tangent_world = normalMatrix * tangent_local;\n";shaderText+=" }\n"}shaderText+=" v_binormal_world = cross(normal_world, tangent_world);\n";shaderText+=" v_tangent_world = cross(v_binormal_world, normal_world);\n"}}shaderText+=" gl_Position = pvwMatrix * position_local;\n";return shaderText}FSDefine_VertexWorldShaderSource(in_,f,lights,material,extraData){let shaderText="";shaderText+=`uniform highp ivec2 objectIds;\n`;shaderText+=`uniform vec3 viewPosition_world;\n`;let lightNumExceptAmbient=lights.filter(light=>{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform vec4 lightDiffuse[${lightNumExceptAmbient}];\n`;shaderText+=`uniform vec3 lightSpotInfo[${lightNumExceptAmbient}];\n`;shaderText+=`uniform vec3 lightPosition_world[${lightNumExceptAmbient}];\n`;shaderText+=`uniform vec3 lightDirection_world[${lightNumExceptAmbient}];\n`}if(Shader._exist(f,GLBoost.NORMAL)){shaderText+=`${in_} vec3 v_normal_world;\n`;if(Shader._exist(f,GLBoost.TANGENT)&&material.getTextureFromPurpose(GLBoost.TEXTURE_PURPOSE_NORMAL)){shaderText+=`${in_} vec3 v_tangent_world;\n`;shaderText+=`${in_} vec3 v_binormal_world;\n`}}shaderText+=`${in_} vec3 v_position_world;\n`;return shaderText}FSShade_VertexWorldShaderSource(f,gl,lights){var shaderText="";return shaderText}prepare_VertexWorldShaderSource(gl,shaderProgram,expression,vertexAttribs,existCamera_f,lights,material,extraData){var vertexAttribsAsResult=[];vertexAttribs.forEach(attribName=>{if(attribName==="position"||attribName==="normal"||attribName==="tangent"){shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);if(shaderProgram["vertexAttribute_"+attribName]!==-1){gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName]);vertexAttribsAsResult.push(attribName)}}});material.setUniform(shaderProgram,"uniform_objectIds",this._glContext.getUniformLocation(shaderProgram,"objectIds"));material.setUniform(shaderProgram,"uniform_worldMatrix",this._glContext.getUniformLocation(shaderProgram,"worldMatrix"));material._semanticsDic["WORLD"]="worldMatrix";material.setUniform(shaderProgram,"uniform_normalMatrix",this._glContext.getUniformLocation(shaderProgram,"normalMatrix"));material._semanticsDic["MODELVIEWINVERSETRANSPOSE"]="normalMatrix";if(existCamera_f){material.setUniform(shaderProgram,"uniform_viewMatrix",this._glContext.getUniformLocation(shaderProgram,"viewMatrix"));material._semanticsDic["VIEW"]="viewMatrix";material.setUniform(shaderProgram,"uniform_projectionMatrix",this._glContext.getUniformLocation(shaderProgram,"projectionMatrix"));material._semanticsDic["PROJECTION"]="projectionMatrix"}material.setUniform(shaderProgram,"uniform_viewPosition",this._glContext.getUniformLocation(shaderProgram,"viewPosition_world"));for(let i=0;i=100){splitter=": "}shaderTextWithLineNumber+=lineIndex+splitter+shaderTextLines[i]+"\n"}return shaderTextWithLineNumber}_getVertexShaderString(gl,functions,existCamera_f,lights,material,extraData){var f=functions;var shaderText="";var in_=Shader._in_onVert(gl);var out_=Shader._out_onVert(gl);shaderText=Shader._glslVer(gl);shaderText+="precision highp float;\n";shaderText+=`${in_} vec3 aVertex_position;\n`;let vsDefineShaderText="";this._classNamesOfVSDefine.forEach(className=>{var method=this["VSDefine_"+className];if(method){vsDefineShaderText+="// VSDefine_"+className+" //\n";vsDefineShaderText+=method.bind(this,in_,out_,f,lights,material,extraData)()}});shaderText+=this._removeDuplicatedLine(vsDefineShaderText);this._classNamesOfVSMethodDefine.forEach(className=>{var method=this["VSMethodDefine_"+className];if(method){shaderText+="// VSMethodDefine_"+className+" //\n";shaderText+=method.bind(this,existCamera_f,f,lights,material,extraData)()}});shaderText+="void main(void) {\n";shaderText+="vec4 position_local = vec4(aVertex_position, 1.0);\n";if(Shader._exist(f,GLBoost$1.NORMAL)){shaderText+="vec3 normal_local = aVertex_normal;\n";if(Shader._exist(f,GLBoost$1.TANGENT)){shaderText+="vec3 tangent_local = aVertex_tangent;\n"}}shaderText+="bool isSkinning = false;\n";this._classNamesOfVSPreProcess.forEach(className=>{var method=this["VSPreProcess_"+className];if(method){shaderText+="// VSPreProcess_"+className+" //\n";shaderText+=method.bind(this,existCamera_f,f,lights,material,extraData)()}});this._classNamesOfVSTransform.forEach(className=>{var method=this["VSTransform_"+className];if(method){shaderText+="// VSTransform_"+className+" //\n";shaderText+=method.bind(this,existCamera_f,f,lights,material,extraData)()}});shaderText+="}";return shaderText}_getFragmentShaderString(gl,functions,lights,material,extraData){var f=functions;var shaderText="";var in_=Shader._in_onFrag(gl);shaderText+=Shader._glslVer(gl);var maxDrawBuffers=this._getMaxDrawBuffers();if(maxDrawBuffers>1){shaderText+=Shader._glsl1DrawBufferExt(gl)}shaderText+=Shader._glsl1StdDerivativeExt(gl);shaderText+="precision highp float;\n";for(let i=0;i{var method=this["FSDefine_"+className];if(method){fsDefineShaderText+="// FSDefine_"+className+" //\n";fsDefineShaderText+=method.bind(this,in_,f,lights,material,extraData)()}});shaderText+=this._removeDuplicatedLine(fsDefineShaderText);this._classNamesOfFSMethodDefine.forEach(className=>{var method=this["FSMethodDefine_"+className];if(method){shaderText+="// FSMethodDefine_"+className+" //\n";shaderText+=method.bind(this,in_,f,lights,material,extraData)()}});shaderText+="void main(void) {\n";this._classNamesOfFSShade.forEach(className=>{var method=this["FSShade_"+className];if(method){shaderText+="// FSShade_"+className+" //\n";shaderText+=method.bind(this,f,gl,lights,material,extraData)()}});this._classNamesOfFSPostEffect.forEach(className=>{let method=this["FSPostEffect_"+className];if(method){shaderText+="// FSPostEffect_"+className+" //\n";shaderText+=method.bind(this,f,gl,lights,material,extraData)()}});this._classNamesOfFSFinalize.forEach(className=>{let method=this["FSFinalize_"+className];if(method){shaderText+="// FSFinalize_"+className+" //\n";shaderText+=method.bind(this,f,gl,lights,material,extraData)()}});if(maxDrawBuffers>1){for(let i=0;i{var method=this["prepare_"+className];if(method){var verAttirbs=method.bind(this,gl,shaderProgram,expression,vertexAttribs,existCamera_f,lights,material,extraData,canvas)();temp=temp.concat(verAttirbs)}});let set=new Set(temp);let vertexAttribsAsResult=[];for(let elem of set){vertexAttribsAsResult.push(elem)}return vertexAttribsAsResult}get dirty(){return this._dirty}set dirty(flg){this._dirty=flg}setUniforms(gl,glslProgram,scene,material,camera,mesh,lights){}setUniformsAsTearDown(gl,glslProgram,scene,material,camera,mesh,lights){}_getShader(gl,theSource,type){var shader;if(type=="x-shader/x-fragment"){shader=this._glContext.createShader(this,gl.FRAGMENT_SHADER)}else if(type=="x-shader/x-vertex"){shader=this._glContext.createShader(this,gl.VERTEX_SHADER)}else{shader=null}gl.shaderSource(shader,theSource);gl.compileShader(shader);if(!gl.getShaderParameter(shader,gl.COMPILE_STATUS)){console.error("An error occurred compiling the shaders: "+gl.getShaderInfoLog(shader));console.error(gl.getShaderInfoLog(shader));shader=null}return shader}_initShaders(gl,vertexShaderStr,fragmentShaderStr){let vertexShaderStrWithLineNumber=this._addLineNumber(vertexShaderStr);let fragmentShaderStrWithLineNumber=this._addLineNumber(fragmentShaderStr);MiscUtil.consoleLog(GLBoost$1.LOG_SHADER_CODE,"Vertex Shader:");MiscUtil.consoleLog(GLBoost$1.LOG_SHADER_CODE,vertexShaderStrWithLineNumber);MiscUtil.consoleLog(GLBoost$1.LOG_SHADER_CODE,"Fragment Shader:");MiscUtil.consoleLog(GLBoost$1.LOG_SHADER_CODE,fragmentShaderStrWithLineNumber);var vertexShader=this._getShader(gl,vertexShaderStr,"x-shader/x-vertex");var fragmentShader=this._getShader(gl,fragmentShaderStr,"x-shader/x-fragment");if(vertexShader===null||fragmentShader===null){return null}var shaderProgram=this._glContext.createProgram(this);gl.attachShader(shaderProgram,vertexShader);gl.attachShader(shaderProgram,fragmentShader);gl.linkProgram(shaderProgram);this._glContext.deleteShader(this,vertexShader);this._glContext.deleteShader(this,fragmentShader);if(!gl.getProgramParameter(shaderProgram,gl.LINK_STATUS)){console.error("Unable to initialize the shader program: "+gl.getProgramInfoLog(shaderProgram));console.error(gl.getProgramInfoLog(shaderProgram))}this._glContext.useProgram(shaderProgram);shaderProgram.vertexShaderSource=vertexShaderStrWithLineNumber;shaderProgram.fragmentShaderSource=fragmentShaderStrWithLineNumber;return shaderProgram}getShaderProgram(expression,vertexAttribs,existCamera_f,lights_,material,extraData={}){var gl=this._glContext.gl;var canvasId=this._glContext.belongingCanvasId;let programToReturn=null;let lights=null;do{lights=this.getDefaultPointLightIfNotExist(lights_);lights=lights.filter(light=>{return!light.isTypeAmbient()});var vertexShaderText=this._getVertexShaderString(gl,vertexAttribs,existCamera_f,lights,material,extraData);var fragmentShaderText=this._getFragmentShaderString(gl,vertexAttribs,lights,material,extraData);var baseText=vertexShaderText+"\n###SPLIT###\n"+fragmentShaderText;var hash=Hash.toCRC32(baseText);if(!Shader._shaderHashTable[canvasId]){Shader._shaderHashTable[canvasId]={}}var hashTable=Shader._shaderHashTable[canvasId];if(hash in hashTable){if(hashTable[hash].code===baseText){programToReturn=hashTable[hash].program}else{for(let i=0;i0){indexStr=hash+"_"+hashTable[hash].collisionN}else{indexStr=hash}MiscUtil.consoleLog(GLBoost$1.LOG_SHADER_CODE,"ShaderInstance: "+material.shaderInstance+" ShaderHashId: "+indexStr);programToReturn=this._initShaders(gl,vertexShaderText,fragmentShaderText);if(programToReturn!==null){programToReturn.createdAt=performance.now();programToReturn.hashId=indexStr;programToReturn.glslProgramsSelfUsageCount=-1;hashTable[indexStr]={code:baseText,program:programToReturn,collisionN:0};Shader._shaderHashTable[canvasId]=hashTable}else if(this.className==="SkeletalShader"){GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL++;console.log("GLBoost.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL was changed to : "+GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL)}}}while(programToReturn===null&&this.className==="SkeletalShader"&&GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL<3);this._glslProgram=programToReturn;material._semanticsDic={_glslProgram:programToReturn};material.uniformTextureSamplerDic={};programToReturn._material=material;programToReturn.optimizedVertexAttribs=this._prepareAssetsForShaders(gl,programToReturn,expression,vertexAttribs,existCamera_f,lights,material,extraData);return programToReturn}static _createShaderInstance(glBoostContext,shaderClass){let shaderInstance=new shaderClass(glBoostContext,VertexWorldShaderSource);return shaderInstance}getDefaultPointLightIfNotExist(lights){if(lights.length===0){if(Shader._defaultLight===null){Shader._defaultLight=this._glBoostContext.createPointLight(GLBoost$1.VALUE_DEFAULT_POINTLIGHT_INTENSITY)}return[Shader._defaultLight]}else{return lights}}static _exist(functions,glboostConstantForAttributeType){let attribute=GLBoost$1.getValueOfGLBoostConstant(glboostConstantForAttributeType);return functions.indexOf(attribute)>=0}_getMaxDrawBuffers(){var gl=this._glContext.gl;var isWebGL2=Shader.isThisGLVersion_2(gl);if(isWebGL2){return gl.getParameter(gl.MAX_DRAW_BUFFERS)}var glem=GLExtensionsManager.getInstance(this._glContext);if(glem.extDBs){return gl.getParameter(glem.extDBs.MAX_DRAW_BUFFERS_WEBGL)}else{return 1}}static isThisGLVersion_2(gl){if(typeof WebGL2RenderingContext==="undefined"){return false}return gl instanceof WebGL2RenderingContext}static _glslVer(gl){return GLBoost$1.isThisGLVersion_2(gl)?"#version 300 es\n":""}static _glsl1DrawBufferExt(gl){return!GLBoost$1.isThisGLVersion_2(gl)?"#extension GL_EXT_draw_buffers : require\n":""}static _glsl1StdDerivativeExt(gl){return!GLBoost$1.isThisGLVersion_2(gl)?"#extension GL_OES_standard_derivatives : require\n":""}static _in_onVert(gl){return GLBoost$1.isThisGLVersion_2(gl)?"in":"attribute"}static _out_onVert(gl){return GLBoost$1.isThisGLVersion_2(gl)?"out":"varying"}static _in_onFrag(gl){return GLBoost$1.isThisGLVersion_2(gl)?"in":"varying"}static _texture_func(gl){return GLBoost$1.isThisGLVersion_2(gl)?"texture":"texture2D"}static _textureProj_func(gl){return GLBoost$1.isThisGLVersion_2(gl)?"shadowProj":"texture2DProj"}static _generateLightStr(i){let shaderText="";shaderText+=` vec3 lightDirection = lightDirection_world[${i}];\n`;shaderText+=` if (0.4 < lightSpotInfo[${i}].x) {\n`;shaderText+=` lightDirection = normalize(lightPosition_world[${i}] - v_position_world.xyz);\n`;shaderText+=` }\n`;shaderText+=` float spotEffect = 1.0;\n`;shaderText+=` if (lightSpotInfo[${i}].x > 0.8) {\n`;shaderText+=` spotEffect = dot(lightDirection_world[${i}], lightDirection);\n`;shaderText+=` if (spotEffect > lightSpotInfo[${i}].y) {\n`;shaderText+=` spotEffect = pow(spotEffect, lightSpotInfo[${i}].z);\n`;shaderText+=` } else {\n`;shaderText+=` spotEffect = 0.0;\n`;shaderText+=` }\n`;shaderText+=` }\n`;return shaderText}static _generateShadowingStr(gl,i,isShadowEnabledAsTexture){let shadowingText="";shadowingText+=`float visibilityForShadow = 0.75;\n`;shadowingText+=`float visibility = 1.0;\n`;shadowingText+=`float visibilitySpecular = 1.0;\n`;shadowingText+=`if (isShadowCasting[${i}] == 1) {// ${i}\n`;shadowingText+=`vec4 shadowCoord_i = shadowCoord[${i}];\n`;shadowingText+=`shadowCoord_i.z -= depthBias;\n`;if(GLBoost$1.isThisGLVersion_2(gl)){if(isShadowEnabledAsTexture){shadowingText+=`visibilitySpecular = textureProj(uDepthTexture[${i}], shadowCoord_i);\n`;shadowingText+=`visibility = visibilitySpecular + visibilityForShadow;\n`}}else{if(isShadowEnabledAsTexture){shadowingText+=`float depth = texture2DProj(uDepthTexture[${i}], shadowCoord_i).r;\n`;shadowingText+=`if (depth < shadowCoord_i.z) {\n`;shadowingText+=` visibility = visibilityForShadow;\n`;shadowingText+=` visibilitySpecular = 0.0;\n`;shadowingText+=`}\n`}}shadowingText+=`}\n`;return shadowingText}static _getNormalStr(gl,material,f){let shaderText="";let normalTexture=material.getTextureFromPurpose(GLBoost$1.TEXTURE_PURPOSE_NORMAL);if(!normalTexture&&Shader._exist(f,GLBoost$1.NORMAL)){shaderText+=" vec3 normal = normalize(v_normal_world);\n";shaderText+=" vec3 normal_world = normal;\n"}else if(material.isFlatShading||!Shader._exist(f,GLBoost$1.NORMAL)){if(!GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL){shaderText+=" vec3 dx = dFdx(v_position_world);\n";shaderText+=" vec3 dy = dFdy(v_position_world);\n";shaderText+=" vec3 normal = normalize(cross(dx, dy));\n";shaderText+=" vec3 normal_world = normal;\n"}}else if(normalTexture&&Shader._exist(f,GLBoost$1.TANGENT)){let textureFunc=Shader._texture_func(gl);shaderText+=` vec3 normal = ${textureFunc}(uNormalTexture, texcoord).xyz*2.0 - 1.0;\n`;shaderText+=` vec3 tangent_world = normalize(v_tangent_world);\n`;shaderText+=` vec3 binormal_world = normalize(v_binormal_world);\n`;shaderText+=` vec3 normal_world = normalize(v_normal_world);\n`;shaderText+=` mat3 tbnMat_tangent_to_world = mat3(\n tangent_world.x, tangent_world.y, tangent_world.z,\n binormal_world.x, binormal_world.y, binormal_world.z,\n normal_world.x, normal_world.y, normal_world.z\n );\n`;shaderText+=` normal = normalize(tbnMat_tangent_to_world * normal);\n`;shaderText+=` normal_world = normal;\n`}return shaderText}_multiplyAlphaToColorOfTexel(gl){var gl=this._glContext.gl;let shaderText="";let textureFunc=Shader._texture_func(gl);shaderText+=`vec4 multiplyAlphaToColorOfTexel(sampler2D texture, vec2 texcoord, int toMultiplyAlphaFlag) {\n`;shaderText+=` vec4 texel = ${textureFunc}(texture, texcoord);\n`;shaderText+=` if (toMultiplyAlphaFlag == 1) {\n`;shaderText+=` texel.rgb *= texel.a;\n`;shaderText+=` }\n`;shaderText+=` return texel;\n`;shaderText+=`}\n`;return shaderText}_sampler2DShadow_func(){var gl=this._glContext.gl;return GLBoost$1.isThisGLVersion_2(gl)?"sampler2DShadow":"sampler2D"}static _set_outColor_onFrag(gl,i){return GLBoost$1.isThisGLVersion_2(gl)?`layout(location = ${i}) out vec4 rt${i};\n`:`vec4 rt${i};\n`}static _set_glFragColor_inGLVer1(gl){return!GLBoost$1.isThisGLVersion_2(gl)?" gl_FragColor = rt0;\n":""}static _set_glFragData_inGLVer1(gl,i){return!GLBoost$1.isThisGLVersion_2(gl)?` gl_FragData[${i}] = rt${i};\n`:""}static trySettingMatrix44ToUniform(gl,hashIdOfGLSLProgram,material,semanticsDir,semantics,matrixArray){if(typeof semanticsDir[semantics]==="undefined"){return}if(typeof semanticsDir[semantics]==="string"){gl.uniformMatrix4fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+semanticsDir[semantics]),false,matrixArray);return}semanticsDir[semantics].forEach(uniformName=>{gl.uniformMatrix4fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+uniformName),false,matrixArray)})}static trySettingMatrix33ToUniform(gl,hashIdOfGLSLProgram,material,semanticsDir,semantics,matrixArray){if(typeof semanticsDir[semantics]==="undefined"){return}if(typeof semanticsDir[semantics]==="string"){gl.uniformMatrix3fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+semanticsDir[semantics]),false,matrixArray);return}semanticsDir[semantics].forEach(uniformName=>{gl.uniformMatrix3fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+uniformName),false,matrixArray)})}static trySettingVec4ArrayToUniform(gl,hashIdOfGLSLProgram,material,semanticsDir,semantics,vecArray){if(typeof semanticsDir[semantics]==="undefined"){return}if(typeof semanticsDir[semantics]==="string"){gl.uniform4fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+semanticsDir[semantics]),vecArray);return}semanticsDir[semantics].forEach(uniformName=>{gl.uniform4fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+uniformName),vecArray)})}static trySettingVec3ArrayToUniform(gl,hashIdOfGLSLProgram,material,semanticsDir,semantics,vecArray){if(typeof semanticsDir[semantics]==="undefined"){return}if(typeof semanticsDir[semantics]==="string"){gl.uniform3fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+semanticsDir[semantics]),vecArray);return}semanticsDir[semantics].forEach(uniformName=>{gl.uniform3fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+uniformName),vecArray)})}static trySettingVec2ArrayToUniform(gl,hashIdOfGLSLProgram,material,semanticsDir,semantics,vecArray){if(typeof semanticsDir[semantics]==="undefined"){return}if(typeof semanticsDir[semantics]==="string"){gl.uniform2fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+semanticsDir[semantics]),vecArray);return}semanticsDir[semantics].forEach(uniformName=>{gl.uniform2fv(material.getUniform(hashIdOfGLSLProgram,"uniform_"+uniformName),vecArray)})}get glslProgram(){return this._glslProgram}readyForDiscard(){if(this._glslProgram){this._glContext.deleteProgram(this,this._glslProgram)}super.readyForDiscard()}getShaderParameter(material,parameterName,defaultValue){if(typeof this[parameterName]!=="undefined"){return this[parameterName]}else if(typeof material.shaderParameters[parameterName]!=="undefined"){return material.shaderParameters[parameterName]}return defaultValue}}Shader._instances=new Object;Shader._shaderHashTable={};Shader._defaultLight=null;let singleton$1=Symbol();let singletonEnforcer=Symbol();class DrawKickerLocal{constructor(enforcer){if(enforcer!==singletonEnforcer){throw new Error("This is a Singleton class. get the instance using 'getInstance' static method.")}this._glslProgram=null}static getInstance(){if(!this[singleton$1]){this[singleton$1]=new DrawKickerLocal(singletonEnforcer)}return this[singleton$1]}draw(gl,glem,expression,mesh,materials,camera,lights,lightsExceptAmbient,scene,vertices,vaoDic,vboDic,iboArrayDic,geometry,geometryName,primitiveType,vertexN,renderPassIndex){var isVAOBound=false;if(DrawKickerLocal._lastGeometry!==geometryName){isVAOBound=glem.bindVertexArray(gl,vaoDic[geometryName])}for(let i=0;i{let textureSamplerDic=material.uniformTextureSamplerDic[uniformName];let textureName=textureSamplerDic.textureName;let textureUnitIndex=textureSamplerDic.textureUnitIndex;isTextureProcessDone=material[methodName](textureName,textureUnitIndex)})}return isTextureProcessDone}_setupOtherTextures(lights){for(let i=0;i0){shaderText+=`uniform vec4 lightPosition[${lights.length}];\n`;shaderText+=`uniform vec4 lightDiffuse[${lights.length}];\n`}if(Shader._exist(f,GLBoost.NORMAL)){shaderText+=`${in_} vec3 v_normal;\n`}shaderText+=`${in_} vec4 position;\n`;return shaderText}prepare_VertexLocalShaderSource(gl,shaderProgram,expression,vertexAttribs,existCamera_f,lights,material,extraData){var vertexAttribsAsResult=[];vertexAttribs.forEach(attribName=>{if(attribName==="position"||attribName==="normal"){shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName]);vertexAttribsAsResult.push(attribName)}});if(existCamera_f){material.setUniform(shaderProgram,"uniform_modelViewProjectionMatrix",this._glContext.getUniformLocation(shaderProgram,"modelViewProjectionMatrix"));material._semanticsDic["MODELVIEWPROJECTION"]="modelViewProjectionMatrix"}for(let i=0;i{shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,this._attributes[attribName]);if(shaderProgram["vertexAttribute_"+attribName]>=0){gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName]);vertexAttribsAsResult.push(attribName)}});let textureCount=0;this._glContext.useProgram(shaderProgram);for(let uniformName in this._uniforms){if(this._uniforms[uniformName]==="TEXTURE"){material.uniformTextureSamplerDic[uniformName]={};let textureUniformLocation=this._glContext.getUniformLocation(shaderProgram,uniformName);if(textureUniformLocation<0){continue}material.uniformTextureSamplerDic[uniformName].textureName=this._textureNames[uniformName];material.uniformTextureSamplerDic[uniformName].textureUnitIndex=textureCount;this._glContext.uniform1i(textureUniformLocation,textureCount,true);textureCount++}switch(this._uniforms[uniformName]){case"WORLD":case"VIEW":case"MODELVIEW":case"MODELVIEWINVERSETRANSPOSE":case"PROJECTION":case"JOINTMATRIX":material.setUniform(shaderProgram,"uniform_"+uniformName,this._glContext.getUniformLocation(shaderProgram,uniformName));case"TEXTURE":material.addSemanticsDic(this._uniforms[uniformName],uniformName);continue}material.setUniform(shaderProgram,"uniform_"+uniformName,this._glContext.getUniformLocation(shaderProgram,uniformName))}return vertexAttribsAsResult}get attributes(){return this._attributes}setUniforms(gl,glslProgram,expression,material,camera,mesh,lights){super.setUniforms(gl,glslProgram,expression,material,camera,mesh,lights);for(let uniformName in this._uniforms){let value=this._uniforms[uniformName];if(typeof value==="number"){this._glContext.uniform1f(material.getUniform(glslProgram,"uniform_"+uniformName),value,true)}else if(value instanceof Vector2){this._glContext.uniform2f(material.getUniform(glslProgram,"uniform_"+uniformName),value.x,value.y,true)}else if(value instanceof Vector3){this._glContext.uniform3f(material.getUniform(glslProgram,"uniform_"+uniformName),value.x,value.y,value.z,true)}else if(value instanceof Vector4){this._glContext.uniform4f(material.getUniform(glslProgram,"uniform_"+uniformName),value.x,value.y,value.z,value.w,true)}}for(let parameterName in material.shaderParameters){let value=material.shaderParameters[parameterName];if(typeof value==="number"){this._glContext.uniform1f(material.getUniform(glslProgram,"uniform_"+parameterName),value,true)}else if(value instanceof Vector2){this._glContext.uniform2f(material.getUniform(glslProgram,"uniform_"+parameterName),value.x,value.y,true)}else if(value instanceof Vector3){this._glContext.uniform3f(material.getUniform(glslProgram,"uniform_"+parameterName),value.x,value.y,value.z,true)}else if(value instanceof Vector4){this._glContext.uniform4f(material.getUniform(glslProgram,"uniform_"+parameterName),value.x,value.y,value.z,value.w,true)}}}}GLBoost["FreeShader"]=FreeShader;class Geometry extends GLBoostObject{constructor(glBoostContext){super(glBoostContext);this._materials=[];this._vertexN=0;this._vertices=null;this._indicesArray=null;this._indexStartOffsetArray=[];this._performanceHint=null;this._defaultMaterial=null;this._vertexData=[];this._extraDataForShader={};this._vboObj={};this._AABB=new AABB;this._drawKicker=DrawKickerWorld.getInstance();if(this._drawKicker instanceof DrawKickerWorld);else if(this._drawKicker instanceof DrawKickerLocal);}static _allVertexAttribs(vertices){var attribNameArray=[];for(var attribName in vertices){if(attribName!=="components"&&attribName!=="componentBytes"&&attribName!=="componentType"){attribNameArray.push(attribName)}}return attribNameArray}_checkAndSetVertexComponentNumber(allVertexAttribs){allVertexAttribs.forEach(attribName=>{let element=this._vertices[attribName][0];let componentN=MathUtil.compomentNumberOfVector(element);if(componentN===0){return}if(typeof this._vertices.components==="undefined"){this._vertices.components={}}if(typeof this._vertices.componentType==="undefined"){this._vertices.componentType={}}this._vertices.components[attribName]=componentN;this._vertices.componentType[attribName]=5126})}_calcBaryCentricCoord(vertexNum,positionElementNumPerVertex){this._vertices.barycentricCoord=new Float32Array(vertexNum*positionElementNumPerVertex);this._vertices.components.barycentricCoord=3;this._vertices.componentType.barycentricCoord=5126;if(!this._indicesArray){for(let i=0;i{if(attribName==="barycentricCoord"){return}if(attribName==="tangent"){return}if(typeof this._vertices[attribName].buffer!=="undefined"){return}let vertexAttribArray=[];this._vertices[attribName].forEach((elem,index)=>{let element=this._vertices[attribName][index];Array.prototype.push.apply(vertexAttribArray,MathUtil.vectorToArray(element))});this._vertices[attribName]=vertexAttribArray});if(this._vertices.texcoord){this._calcTangent(vertexNum,positionElementNumPerVertex,texcoordElementNumPerVertex,primitiveType)}this._calcArenbergInverseMatrices(primitiveType);allVertexAttribs.forEach(attribName=>{if(typeof this._vertices[attribName].buffer==="undefined"){this._vertices[attribName]=new Float32Array(this._vertices[attribName])}});for(let i=0;i{let element=vertices[attribName][index];Array.prototype.push.apply(vertexAttribArray,MathUtil.vectorToArray(element));if(attribName==="position"&&!(skipUpdateAABB===true)){let componentN=this._vertices.components[attribName];this._AABB.addPositionWithArray(vertexAttribArray,index*componentN)}this._vertices[attribName]=vertexAttribArray})}if(!(skipUpdateAABB===true)){this._AABB.updateAllInfo()}for(let attribName in vertices){if(this._vboObj[attribName]){let float32AryVertexData=new Float32Array(this._vertices[attribName]);gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName]);gl.bufferSubData(gl.ARRAY_BUFFER,0,float32AryVertexData);gl.bindBuffer(gl.ARRAY_BUFFER,null)}else{return false}}return true}setUpVertexAttribs(gl,glslProgram,allVertexAttribs){var optimizedVertexAttribs=glslProgram.optimizedVertexAttribs;allVertexAttribs.forEach(attribName=>{if(optimizedVertexAttribs.indexOf(attribName)!=-1){gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName]);gl.vertexAttribPointer(glslProgram["vertexAttribute_"+attribName],this._vertices.components[attribName],this._vertices.componentType[attribName],false,0,0)}})}setUpEnableVertexAttribArrays(gl,glslProgram,allVertexAttribs){var optimizedVertexAttribs=glslProgram.optimizedVertexAttribs;allVertexAttribs.forEach(attribName=>{if(optimizedVertexAttribs.indexOf(attribName)!=-1){gl.enableVertexAttribArray(glslProgram["vertexAttribute_"+attribName])}})}setUpDisableAllVertexAttribArrays(gl,glslProgram){for(let i=0;i<8;i++){gl.disableVertexAttribArray(i)}}setUpDisableVertexAttribArrays(gl,glslProgram,allVertexAttribs){var optimizedVertexAttribs=glslProgram.optimizedVertexAttribs;allVertexAttribs.forEach(attribName=>{if(optimizedVertexAttribs.indexOf(attribName)!=-1){gl.disableVertexAttribArray(glslProgram["vertexAttribute_"+attribName])}})}_getVAO(){return Geometry._vaoDic[this.toString()]}_getAllVertexAttribs(){return Geometry._allVertexAttribs(this._vertices)}prepareGLSLProgram(expression,material,index,existCamera_f,lights,doSetupVertexAttribs=true,shaderClass=void 0,argShaderInstance=void 0){let gl=this._glContext.gl;let vertices=this._vertices;let _optimizedVertexAttribs=Geometry._allVertexAttribs(vertices,material);let shaderInstance=null;if(argShaderInstance){shaderInstance=argShaderInstance}else{if(shaderClass){shaderInstance=Shader._createShaderInstance(this._glBoostContext,shaderClass)}else{shaderInstance=Shader._createShaderInstance(this._glBoostContext,material.shaderClass)}}let glslProgram=shaderInstance.getShaderProgram(expression,_optimizedVertexAttribs,existCamera_f,lights,material,this._extraDataForShader);return shaderInstance}_setVertexNtoSingleMaterial(material,index){if(this._indicesArray&&this._indicesArray.length>0){material.setVertexN(this,this._indicesArray[index].length)}else{material.setVertexN(this,this._vertexN)}}_getAppropriateMaterials(mesh){let materials=null;if(this._materials.length>0){materials=this._materials}else if(mesh.material){materials=[mesh.material]}else{mesh.material=this._glBoostContext._defaultMaterial;materials=[mesh.material]}return materials}getIndexStartOffsetArrayAtMaterial(i){return this._indexStartOffsetArray[i]}prepareToRender(expression,existCamera_f,lights,meshMaterial,mesh,shaderClass=void 0,argMaterials=void 0){var vertices=this._vertices;var gl=this._glContext.gl;var glem=GLExtensionsManager.getInstance(this._glContext);this._vertexN=vertices.position.length/vertices.components.position;var allVertexAttribs=Geometry._allVertexAttribs(vertices);if(Geometry._vaoDic[this.toString()]);else{var vao=this._glContext.createVertexArray(this);Geometry._vaoDic[this.toString()]=vao}glem.bindVertexArray(gl,Geometry._vaoDic[this.toString()]);let doAfter=false;allVertexAttribs.forEach(attribName=>{if(this._vboObj[attribName]){gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName])}else{let vbo=this._glContext.createBuffer(this);this._vboObj[attribName]=vbo;gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName]);gl.bufferData(gl.ARRAY_BUFFER,this._vertices[attribName],this._performanceHint);doAfter=true}});if(doAfter){if(Geometry._iboArrayDic[this.toString()]){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,Geometry._iboArrayDic[this.toString()])}else{if(this._indicesArray){let indices=[];for(let i=0;i{let thisLength=this._vertices[attribName].length;let allGeomLength=0;geometrys.forEach(geometry=>{allGeomLength+=geometry._vertices[attribName].length});typedArrayDic[attribName]=new Float32Array(thisLength+allGeomLength)});let lastThisLengthDic={};allVertexAttribs.forEach(attribName=>{lastThisLengthDic[attribName]=0});geometrys.forEach((geometry,index)=>{let typedSubArrayDic={};allVertexAttribs.forEach(attribName=>{let typedArray=typedArrayDic[attribName];if(index===0){lastThisLengthDic[attribName]=geometrys[index]._vertices[attribName].length}let end=typeof geometrys[index+1]!=="undefined"?lastThisLengthDic[attribName]+geometrys[index+1]._vertices[attribName].length:void 0;typedSubArrayDic[attribName]=typedArray.subarray(0,end);lastThisLengthDic[attribName]=end});this.mergeInner(geometry,typedSubArrayDic,index===0)})}else{let geometry=geometrys;let typedArrayDic={};let allVertexAttribs=Geometry._allVertexAttribs(this._vertices);allVertexAttribs.forEach(attribName=>{let thisLength=this._vertices[attribName].length;let geomLength=geometry._vertices[attribName].length;typedArrayDic[attribName]=new Float32Array(thisLength+geomLength)});this.mergeInner(geometry,typedArrayDic)}}mergeInner(geometry,typedArrayDic,isFirst=false){let gl=this._glContext.gl;let baseLen=this._vertices.position.length/this._vertices.components.position;if(this===geometry){console.assert("don't merge same geometry!")}let allVertexAttribs=Geometry._allVertexAttribs(this._vertices);allVertexAttribs.forEach(attribName=>{let thisLength=this._vertices[attribName].length;let geomLength=geometry._vertices[attribName].length;let float32array=typedArrayDic[attribName];if(isFirst){float32array.set(this._vertices[attribName],0)}float32array.set(geometry._vertices[attribName],thisLength);this._vertices[attribName]=float32array;if(typeof this._vboObj[attribName]!=="undefined"){gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName]);gl.bufferData(gl.ARRAY_BUFFER,this._vertices[attribName],this._performanceHint);gl.bindBuffer(gl.ARRAY_BUFFER,null)}});let geometryIndicesN=geometry._indicesArray.length;for(let i=0;i{let thisLength=this._vertices[attribName].length;let allGeomLength=0;geometrys.forEach(geometry=>{allGeomLength+=geometry._vertices[attribName].length});typedArrayDic[attribName]=new Float32Array(thisLength+allGeomLength)});let lastThisLengthDic={};allVertexAttribs.forEach(attribName=>{lastThisLengthDic[attribName]=0});geometrys.forEach((geometry,index)=>{let typedSubArrayDic={};allVertexAttribs.forEach(attribName=>{let typedArray=typedArrayDic[attribName];if(index===0){lastThisLengthDic[attribName]=geometrys[index]._vertices[attribName].length}let end=typeof geometrys[index+1]!=="undefined"?lastThisLengthDic[attribName]+geometrys[index+1]._vertices[attribName].length:void 0;typedSubArrayDic[attribName]=typedArray.subarray(0,end);lastThisLengthDic[attribName]=end});this.mergeHarderInner(geometry,typedSubArrayDic,index===0)})}else{let geometry=geometrys;let typedArrayDic={};let allVertexAttribs=Geometry._allVertexAttribs(this._vertices);allVertexAttribs.forEach(attribName=>{let thisLength=this._vertices[attribName].length;let geomLength=geometry._vertices[attribName].length;typedArrayDic[attribName]=new Float32Array(thisLength+geomLength)});this.mergeHarderInner(geometry,typedArrayDic)}}mergeHarderInner(geometry,typedArrayDic,isFirst=false){let gl=this._glContext.gl;let baseLen=this._vertices.position.length/this._vertices.components.position;if(this===geometry){console.assert("don't merge same geometry!")}let allVertexAttribs=Geometry._allVertexAttribs(this._vertices);allVertexAttribs.forEach(attribName=>{let thisLength=this._vertices[attribName].length;let geomLength=geometry._vertices[attribName].length;let float32array=typedArrayDic[attribName];if(isFirst){float32array.set(this._vertices[attribName],0)}float32array.set(geometry._vertices[attribName],thisLength);this._vertices[attribName]=float32array;if(typeof this._vboObj[attribName]!=="undefined"){gl.bindBuffer(gl.ARRAY_BUFFER,this._vboObj[attribName]);gl.bufferData(gl.ARRAY_BUFFER,this._vertices[attribName],this._performanceHint);gl.bindBuffer(gl.ARRAY_BUFFER,null)}});for(let i=0;i{if(material.isTransparent()){isTransparent=true}});return isTransparent}get AABB(){return this._AABB}get rawAABB(){return this._AABB}isIndexed(){return!!Geometry._iboArrayDic[this.toString()]}getTriangleCount(mesh){let gl=this._glContext.gl;let materials=this._getAppropriateMaterials(mesh);let count=0;for(let i=0;i=-1e-6&&convertedDirVec3.z<=1e-6){return null}const t=-convertedOrigVec3.z/convertedDirVec3.z;if(t<=1e-5){return null}const u=convertedOrigVec3.x+t*convertedDirVec3.x;const v=convertedOrigVec3.y+t*convertedDirVec3.y;if(u<0||v<0||u+v>1){return null}const fDat=1-u-v;const pos0Vec3=new Vector3(this._vertices.position[pos0IndexBase],this._vertices.position[pos0IndexBase+1],this._vertices.position[pos0IndexBase+2]);const pos1Vec3=new Vector3(this._vertices.position[pos1IndexBase],this._vertices.position[pos1IndexBase+1],this._vertices.position[pos1IndexBase+2]);const pos2Vec3=new Vector3(this._vertices.position[pos2IndexBase],this._vertices.position[pos2IndexBase+1],this._vertices.position[pos2IndexBase+2]);const pos0=Vector3.multiply(pos0Vec3,u);const pos1=Vector3.multiply(pos1Vec3,v);const pos2=Vector3.multiply(pos2Vec3,fDat);const intersectedPosVec3=Vector3.add(Vector3.add(pos0,pos1),pos2);return[t,intersectedPosVec3]}_calcArenbergInverseMatrices(primitiveType){const positionElementNumPerVertex=this._vertices.components.position;let incrementNum=3;if(primitiveType===GLBoost$1.TRIANGLE_STRIP){incrementNum=1}this._vertices.inverseArenbergMatrix=[];this._vertices.arenberg3rdPosition=[];if(this._vertices.texcoord){if(!this._indicesArray){for(let i=0;i{if(this.BlendShapeShaderSource_isShapeTarget(attribName)){shaderText+=`${in_} vec3 aVertex_${attribName};\n`;shaderText+="uniform float blendWeight_"+attribName+";\n"}});return shaderText}VSTransform_BlendShapeShaderSource(existCamera_f,f,lights,material,extraData){var shaderText="";var numOfShapeTargets=this.BlendShapeShaderSource_numberOfShapeTargets(f);shaderText+=" vec3 blendedPosition = aVertex_position;\n";f.forEach(attribName=>{if(this.BlendShapeShaderSource_isShapeTarget(attribName)){shaderText+="blendedPosition += (aVertex_"+attribName+" - aVertex_position) * blendWeight_"+attribName+";\n"}});if(existCamera_f){shaderText+=" gl_Position = pvwMatrix * vec4(blendedPosition, 1.0);\n"}else{shaderText+=" gl_Position = vec4(blendedPosition, 1.0);\n"}return shaderText}prepare_BlendShapeShaderSource(gl,shaderProgram,expression,vertexAttribs,existCamera_f,lights,material,extraData){var vertexAttribsAsResult=[];vertexAttribs.forEach(attribName=>{if(this.BlendShapeShaderSource_isShapeTarget(attribName)){vertexAttribsAsResult.push(attribName);shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName])}});vertexAttribs.forEach(attribName=>{if(this.BlendShapeShaderSource_isShapeTarget(attribName)){material["uniform_FloatSampler_blendWeight_"+attribName]=this._glContext.getUniformLocation(shaderProgram,"blendWeight_"+attribName);this._glContext.uniform1f(material["uniform_FloatSampler_blendWeight_"+attribName],0,true)}});return vertexAttribsAsResult}BlendShapeShaderSource_isShapeTarget(attribName){return!Shader._exist(attribName,GLBoost.POSITION)&&!Shader._exist(attribName,GLBoost.COLOR)&&!Shader._exist(attribName,GLBoost.TEXCOORD)}BlendShapeShaderSource_numberOfShapeTargets(attributes){var count=0;attributes.forEach(attribName=>{if(this.BlendShapeShaderSource_isShapeTarget(attribName)){count+=1}});return count}}class BlendShapeGeometry extends Geometry{constructor(glBoostContext){super(glBoostContext);this._blendWeight_1=0;this._blendWeight_2=0;this._blendWeight_3=0;this._blendWeight_4=0;this._blendWeight_5=0;this._blendWeight_6=0;this._blendWeight_7=0;this._blendWeight_8=0;this._blendWeight_9=0;this._blendWeight_10=0;this._currentRenderPassIndex=0;this._materialForBlend=null}draw(data){this._currentRenderPassIndex=data.renderPass_index;super.draw({expression:data.expression,lights:data.lights,camera:data.camera,mesh:data.mesh,scene:data.scene,renderPassIndex:data.renderPassIndex,viewport:data.viewport,isWebVRMode:data.isWebVRMode,webvrFrameData:data.webvrFrameData})}prepareToRender(expression,existCamera_f,pointLight,meshMaterial,mesh){if(meshMaterial){this._materialForBlend=meshMaterial}else{this._materialForBlend=this._defaultMaterial}class BlendShapeShader extends this._materialForBlend.shaderClass{constructor(glBoostContext,basicShader){super(glBoostContext,basicShader);BlendShapeShader.mixin(BlendShapeShaderSource)}}this._materialForBlend.shaderClass=BlendShapeShader;super.prepareToRender(expression,existCamera_f,pointLight,meshMaterial,mesh)}_setBlendWeightToGlslProgram(blendTargetNumber,weight){let blendTarget=GLBoost$1.getValueOfGLBoostConstant(blendTargetNumber);let materials=[this._materialForBlend];for(let i=0;i{return!light.isTypeAmbient()}).length;return shaderText}VSTransform_VertexWorldShadowShaderSource(existCamera_f,f,lights,material,extraData){var shaderText="";let gl=this._glContext.gl;return shaderText}FSDefine_VertexWorldShadowShaderSource(in_,f,lights,material,extraData){let shaderText="";shaderText+="uniform float depthBias;\n";let lightNumExceptAmbient=lights.filter(light=>{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform mat4 depthPVMatrix[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_VertexWorldShadowShaderSource(f,gl,lights){let shaderText="";shaderText+="float visibilityLevel = 1.0;\n";if(lights.length>0){shaderText+=` vec4 shadowCoord[${lights.length}];\n`}for(let i=0;i{if(attribName==="position"||attribName==="normal"){shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);if(shaderProgram["vertexAttribute_"+attribName]!==-1){gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName]);vertexAttribsAsResult.push(attribName)}}});for(let i=0;i{if(attribName==="color"||attribName==="texcoord"){shaderProgram["vertexAttribute_"+attribName]=gl.getAttribLocation(shaderProgram,"aVertex_"+attribName);if(shaderProgram["vertexAttribute_"+attribName]!==-1){gl.enableVertexAttribArray(shaderProgram["vertexAttribute_"+attribName]);vertexAttribsAsResult.push(attribName)}}});material.setUniform(shaderProgram,"uniform_materialBaseColor",this._glContext.getUniformLocation(shaderProgram,"materialBaseColor"));let diffuseTexture=material.getTextureFromPurpose(GLBoost$1.TEXTURE_PURPOSE_DIFFUSE);if(!diffuseTexture){diffuseTexture=this._glBoostContext.defaultDummyTexture}if(diffuseTexture.toMultiplyAlphaToColorPreviously){let uIsTextureToMultiplyAlphaToColorPreviously=this._glContext.getUniformLocation(shaderProgram,"uIsTextureToMultiplyAlphaToColorPreviously");material.setUniform(shaderProgram,"uIsTextureToMultiplyAlphaToColorPreviously",uIsTextureToMultiplyAlphaToColorPreviously)}let uTexture=this._glContext.getUniformLocation(shaderProgram,"uTexture");material.setUniform(shaderProgram,"uTexture",uTexture);this._glContext.uniform1i(uTexture,0,true);material._semanticsDic["TEXTURE"]=[];material.uniformTextureSamplerDic["uTexture"]={};if(material.hasAnyTextures()||diffuseTexture){material.uniformTextureSamplerDic["uTexture"].textureUnitIndex=0;material.uniformTextureSamplerDic["uTexture"].textureName=diffuseTexture.userFlavorName;material._semanticsDic["TEXTURE"]="uTexture"}let normalTexture=material.getTextureFromPurpose(GLBoost$1.TEXTURE_PURPOSE_NORMAL);let uNormalTexture=this._glContext.getUniformLocation(shaderProgram,"uNormalTexture");if(uNormalTexture){material.setUniform(shaderProgram,"uNormalTexture",normalTexture);this._glContext.uniform1i(uNormalTexture,1,true);material.uniformTextureSamplerDic["uNormalTexture"]={};if(material.hasAnyTextures()){material.uniformTextureSamplerDic["uNormalTexture"].textureUnitIndex=1;material.uniformTextureSamplerDic["uNormalTexture"].textureName=normalTexture.userFlavorName;material._semanticsDic["TEXTURE"].push("uNormalTexture")}}return vertexAttribsAsResult}}class DecalShader extends FragmentSimpleShader{constructor(glBoostContext){super(glBoostContext);DecalShader.mixin(VertexWorldShadowShaderSource);DecalShader.mixin(DecalShaderSource);this._lut=null}setUniforms(gl,glslProgram,scene,material,camera,mesh,lights){super.setUniforms(gl,glslProgram,scene,material,camera,mesh,lights);let baseColor=material.baseColor;this._glContext.uniform4f(material.getUniform(glslProgram,"uniform_materialBaseColor"),baseColor.x,baseColor.y,baseColor.z,baseColor.w,true);let diffuseTexture=material.getTextureFromPurpose(GLBoost$1.TEXTURE_PURPOSE_DIFFUSE);if(diffuseTexture){material.uniformTextureSamplerDic["uTexture"].textureName=diffuseTexture.userFlavorName;this._glContext.uniform1i(material.getUniform(glslProgram,"uIsTextureToMultiplyAlphaToColorPreviously"),diffuseTexture.toMultiplyAlphaToColorPreviously,true)}for(let i=0;i{if(state===3042){isTransparent=true}})}}return isTransparent}set name(name){this._name=name;this._updateCount()}get name(){return this._name}setVertexN(geom,num){this._vertexNofGeometries[geom]=num;this._updateCount()}getVertexN(geom){return typeof this._vertexNofGeometries[geom]==="undefined"?0:this._vertexNofGeometries[geom]}setUpTexture(textureName,textureUnitIndex){var gl=this._gl;let texture=this.getTexture(textureName);let isCalledWebGLBindTexture=true;if(texture){isCalledWebGLBindTexture=texture.setUp(textureUnitIndex);return isCalledWebGLBindTexture}else{this._glBoostContext.defaultDummyTexture.setUp(0);isCalledWebGLBindTexture=true;return isCalledWebGLBindTexture}}tearDownTexture(textureName,textureUnitIndex){let texture=this.getTexture(textureName);if(texture){texture.tearDown(textureUnitIndex)}}_setUpMaterialStates(states){let gl=this._gl;if(states){if(states.enable){states.enable.forEach(state=>{gl.enable(state)})}if(states.functions){for(let functionName in states.functions){gl[functionName].apply(gl,states.functions[functionName])}}}}setUpStates(){let globalStatesUsage=this._glBoostContext.globalStatesUsage;if(this._globalStatesUsage){globalStatesUsage=this._globalStatesUsage}switch(globalStatesUsage){case GLBoost$1.GLOBAL_STATES_USAGE_DO_NOTHING:break;case GLBoost$1.GLOBAL_STATES_USAGE_IGNORE:this._setUpMaterialStates(this._states);break;case GLBoost$1.GLOBAL_STATES_USAGE_INCLUSIVE:this._glBoostContext.reflectGlobalGLState();this._setUpMaterialStates(this._states);break;case GLBoost$1.GLOBAL_STATES_USAGE_EXCLUSIVE:this._glBoostContext.reflectGlobalGLState();break;default:break}}tearDownStates(){this._glBoostContext.disableAllGLState();this._setUpMaterialStates({functions:this._stateFunctionsToReset})}setUniform(glslProgram,uniformLocationName,uniformLocation){if(!this._shaderUniformLocationsOfExpressions[glslProgram.hashId]){this._shaderUniformLocationsOfExpressions[glslProgram.hashId]={}}this._shaderUniformLocationsOfExpressions[glslProgram.hashId][uniformLocationName]=uniformLocation;glslProgram["uniform_"+uniformLocationName]=uniformLocationName;this._updateCount()}getUniform(glslProgram,uniformLocationName){if(typeof this._shaderUniformLocationsOfExpressions[glslProgram.hashId]!=="undefined"){return this._shaderUniformLocationsOfExpressions[glslProgram.hashId][uniformLocationName]}return void 0}set isVisible(flg){this._isVisibleForGeometiesAssginedByThisMaterial=flg;this._updateCount()}get isVisible(){return this._isVisibleForGeometiesAssginedByThisMaterial}set globalStatesUsage(usage){this._globalStatesUsage=usage;this._updateCount()}get globalStatesUsage(){return this._globalStatesUsage}get shaderParameters(){return this._shaderParametersForShaderInstance}set shaderParameters(shaderParameterDic){this._shaderParametersForShaderInstance=shaderParameterDic}addSemanticsDic(uniform,uniformName){if(typeof this._semanticsDic[uniform]==="undefined"){this._semanticsDic[uniform]=uniformName}else if(typeof this._semanticsDic[uniform]==="string"){let tmpSemanticsStr=this._semanticsDic[uniform];this._semanticsDic[uniform]=[];this._semanticsDic[uniform].push(tmpSemanticsStr);this._semanticsDic[uniform].push(uniformName)}else{this._semanticsDic[uniform].push(uniformName)}}removeSemanticsDic(uniform){delete this._semanticsDic[uniform]}readyForDiscard(){for(let userFlavorName in this._textureDic){this.removeTexture(userFlavorName,true)}if(this._shaderInstance){this._shaderInstance.readyForDiscard()}this._shaderInstance=null}}GLBoost$1["L_AbstractMaterial"]=L_AbstractMaterial;class ClassicMaterial$1 extends L_AbstractMaterial{constructor(glBoostContext){super(glBoostContext);this._wireframeWidthRelativeScale=1}get wireframeWidthRelativeScale(){return this._wireframeWidthRelativeScale}}GLBoost$1["ClassicMaterial"]=ClassicMaterial$1;class L_AbstractCamera extends L_Element{constructor(glBoostContext,toRegister,lookat){super(glBoostContext,toRegister);if(this.constructor===L_AbstractCamera){throw new TypeError("Cannot construct AbstractCamera instances directly.")}this._translate=lookat.eye;this._translateInner=super.translate.clone();this._center=lookat.center;this._up=lookat.up;this._upInner=lookat.up;this._centerInner=this._up.clone();this._cameraController=null;this._dirtyView=true;this._middleLevelCamera=null}set cameraController(controller){this._cameraController=controller;if(this._middleLevelCamera!==null){controller.addCamera(this._middleLevelCamera)}else{controller.addCamera(this)}}get cameraController(){return this._cameraController}_affectedByCameraController(){if(this._cameraController!==null){let results=this._cameraController.convert(this);this._translateInner=results[0];this._centerInner=results[1];this._upInner=results[2];this._zNearInner=results[3];this._zFarInner=results[4];this._leftInner=results[5];this._rightInner=results[6];this._topInner=results[7];this._bottomInner=results[8]}else{this._translateInner=super.translate.clone();this._centerInner=this._center.clone();this._upInner=this._up.clone();this._zNearInner=this._zNear;this._zFarInner=this._zFar;this._leftInner=this._left;this._rightInner=this._right;this._topInner=this._top;this._bottomInner=this._bottom}}get middleLevelCamera(){return this._middleLevelCamera}_needUpdateView(withTryingResetOfCameraController=true){if(this._cameraController!==null&&withTryingResetOfCameraController){this._cameraController.tryReset()}this._dirtyView=true}lookAtRHMatrix(){if(this._dirtyView){this._affectedByCameraController();this._viewMatrix=L_AbstractCamera.lookAtRHMatrix(this.translateInner,this.centerInner,this.upInner);this._dirtyView=false;return this._viewMatrix.clone()}else{return this._viewMatrix.clone()}}static lookAtRHMatrix(eye,center,up){var f=Vector3.normalize(Vector3.subtract(center,eye));var s=Vector3.normalize(Vector3.cross(f,up));var u=Vector3.cross(s,f);return new Matrix44$2(s.x,s.y,s.z,-Vector3.dotProduct(s,eye),u.x,u.y,u.z,-Vector3.dotProduct(u,eye),-f.x,-f.y,-f.z,Vector3.dotProduct(f,eye),0,0,0,1)}setAsMainCamera(scene){L_AbstractCamera._mainCamera[scene.toString()]=this}isMainCamera(scene){return L_AbstractCamera._mainCamera[scene.toString()]===this}set translate(vec){super.translate=vec;this._needUpdateView()}get translate(){return this._translate}get translateInner(){return this._translateInner}set eye(vec){super.translate=vec;this._needUpdateView()}get eye(){return this._translate}get eyeInner(){return this._translateInner}set center(vec){if(this._center.isEqual(vec)){return}this._center=vec;this._needUpdateView()}get center(){return this._center}get centerInner(){return this._centerInner}set up(vec){if(this._up.isEqual(vec)){return}this._up=vec;this._needUpdateView()}get up(){return this._up}get upInner(){return this._upInner}set texture(texture){this._texture=texture}get texture(){return this._texture}}L_AbstractCamera._mainCamera={};class L_PerspectiveCamera extends L_AbstractCamera{constructor(glBoostContext,toRegister,lookat,perspective){super(glBoostContext,toRegister,lookat);this._fovy=perspective.fovy;this._aspect=perspective.aspect;this._zNear=perspective.zNear;this._zFar=perspective.zFar;this._zNearInner=perspective.zNear;this._zFarInner=perspective.zFar;this._dirtyProjection=true;this._updateCountAsCameraProjection=0}_needUpdateProjection(){this._dirtyProjection=true;this._updateCountAsCameraProjection++}get updateCountAsCameraProjection(){return this._updateCountAsCameraProjection}projectionRHMatrix(){if(this._dirtyProjection){this._projectionMatrix=L_PerspectiveCamera.perspectiveRHMatrix(this._fovy,this._aspect,this._zNearInner,this._zFarInner);this._dirtyProjection=false;return this._projectionMatrix.clone()}else{return this._projectionMatrix.clone()}}static perspectiveRHMatrix(fovy,aspect,zNear,zFar){var yscale=1/Math.tan(.5*fovy*Math.PI/180);var xscale=yscale/aspect;if(zFar){return new Matrix44$2(xscale,0,0,0,0,yscale,0,0,0,0,-(zFar+zNear)/(zFar-zNear),-(2*zFar*zNear)/(zFar-zNear),0,0,-1,0)}else{return new Matrix44$2(xscale,0,0,0,0,yscale,0,0,0,0,-1,0,-2*zNear,0,0,-1,0)}}set fovy(value){if(this._fovy===value){return}this._fovy=value;this._needUpdateProjection()}get fovy(){return this._fovy}set aspect(value){if(this._aspect===value){return}this._aspect=value;this._needUpdateProjection()}get aspect(){return this._aspect}set zNear(value){if(this._zNear===value){return}this._zNear=value;this._needUpdateProjection()}get zNear(){return this._zNear}set zFar(value){if(this._zFar===value){return}this._zFar=value;this._needUpdateProjection()}get zFar(){return this._zFar}}class L_FrustumCamera extends L_AbstractCamera{constructor(glBoostContext,toRegister,lookat,frustum){super(glBoostContext,toRegister,lookat);this._left=frustum.left;this._right=frustum.right;this._top=frustum.top;this._bottom=frustum.bottom;this._zNear=frustum.zNear;this._zFar=frustum.zFar;this._zNearInner=frustum.zNear;this._zFarInner=frustum.zFar;this._dirtyProjection=true;this._updateCountAsCameraProjection=0}_needUpdateProjection(){this._dirtyProjection=true;this._updateCountAsCameraProjection++}get updateCountAsCameraProjection(){return this._updateCountAsCameraProjection}projectionRHMatrix(){if(this._dirtyProjection){this._projectionMatrix=L_FrustumCamera.frustumRHMatrix(this._leftInner,this._rightInner,this._topInner,this._bottomInner,this._zNearInner,this._zFarInner);this._dirtyProjection=false;return this._projectionMatrix.clone()}else{return this._projectionMatrix.clone()}}static frustumRHMatrix(left,right,top,bottom,zNear,zFar){return new Matrix44$2(2*zNear/(right-left),0,(right+left)/(right-left),0,0,2*zNear/(top-bottom),(top+bottom)/(top-bottom),0,0,0,-(zFar+zNear)/(zFar-zNear),-1*2*zFar*zNear/(zFar-zNear),0,0,-1,0)}set left(value){if(this._left===value){return}this._left=value;this._needUpdateProjection()}get left(){return this._left}set right(value){if(this._right===value){return}this._right=value;this._needUpdateProjection()}get right(){return this._right}set top(value){if(this._top===value){return}this._top=value;this._needUpdateProjection()}get top(){return this._top}set bottom(value){if(this._bottom===value){return}this._bottom=value;this._needUpdateProjection()}get bottom(){return this._bottom}set zNear(value){if(this._zNear===value){return}this._zNear=value;this._needUpdateProjection()}get zNear(){return this._zNear}set zFar(value){if(this._zFar===value){return}this._zFar=value;this._needUpdateProjection()}get zFar(){return this._zFar}get aspect(){return(this.right-this.left)/(this.top-this.bottom)}}class L_OrthoCamera extends L_AbstractCamera{constructor(glBoostContext,toRegister,lookat,ortho){super(glBoostContext,toRegister,lookat);this._left=typeof ortho.left==="undefined"?-1:ortho.left;this._right=typeof ortho.right==="undefined"?1:ortho.right;this._bottom=typeof ortho.bottom==="undefined"?-1:ortho.bottom;this._top=typeof ortho.top==="undefined"?1:ortho.top;this._zNear=ortho.zNear;this._zFar=ortho.zFar;this._xmag=ortho.xmag;this._ymag=ortho.ymag;this._dirtyProjection=true;this._updateCountAsCameraProjection=0}_needUpdateProjection(){this._dirtyProjection=true;this._updateCountAsCameraProjection++}get updateCountAsCameraProjection(){return this._updateCountAsCameraProjection}projectionRHMatrix(){if(this._dirtyProjection){this._projectionMatrix=L_OrthoCamera.orthoRHMatrix(this._left,this._right,this._bottom,this._top,this._zNear,this._zFar,this._xmag,this._ymag);this._dirtyProjection=false;return this._projectionMatrix.clone()}else{return this._projectionMatrix.clone()}}static orthoRHMatrix(left,right,bottom,top,near,far,xmag,ymag){if(xmag&&ymag){return new Matrix44$2(1/xmag,0,0,0,0,1/ymag,0,0,0,0,-2/(far-near),-(far+near)/(far-near),0,0,0,1)}else{return new Matrix44$2(2/(right-left),0,0,-(right+left)/(right-left),0,2/(top-bottom),0,-(top+bottom)/(top-bottom),0,0,-2/(far-near),-(far+near)/(far-near),0,0,0,1)}}set left(value){if(this._left===value){return}this._left=value;this._needUpdateProjection()}get left(){return this._left}set right(value){if(this._right===value){return}this._right=value;this._needUpdateProjection()}get right(){return this._right}set bottom(value){if(this._bottom===value){return}this._bottom=value;this._needUpdateProjection()}get bottom(){return this._bottom}set top(value){if(this._top===value){return}this._top=value;this._needUpdateProjection()}get top(){return this._top}set zNear(value){if(this._zNear===value){return}this._zNear=value;this._needUpdateProjection()}get zNear(){return this._zNear}set zFar(value){if(this._zFar===value){return}this._zFar=value;this._needUpdateProjection()}get zFar(){return this._zFar}set xmag(value){if(this._xmag===value){return}this._xmag=value;this._needUpdateProjection()}get xmag(){return this._xmag}set ymag(value){if(this._ymag===value){return}this._ymag=value;this._needUpdateProjection()}get ymag(){return this._ymag}get aspect(){return(this.right-this.left)/(this.top-this.bottom)}}class M_AbstractCamera extends M_Element{constructor(glBoostContext,toRegister){super(glBoostContext,toRegister);if(this.constructor===M_AbstractCamera){throw new TypeError("Cannot construct M_AbstractCamera instances directly.")}this._lowLevelCamera=null;this._updateCountAsCameraView=0;this._texture=null}set cameraController(controller){this._lowLevelCamera.cameraController=controller}get cameraController(){return this._lowLevelCamera.cameraController}_needUpdateView(){this._lowLevelCamera._needUpdateView();this._updateCountAsCameraView++}get updateCountAsCameraView(){return this._updateCountAsCameraView}get latestViewStateInfoString(){var tempString=this._accumulateMyAndParentNameWithUpdateInfo(this);tempString+="_updateCountAsCameraView_"+this._updateCountAsCameraView;return tempString}setAsMainCamera(scene){this._lowLevelCamera.setAsMainCamera(scene)}isMainCamera(scene){return this._lowLevelCamera.isMainCamera(scene)}set texture(texture){this._texture=texture}get texture(){return this._texture}lookAtRHMatrix(){return this._lowLevelCamera.lookAtRHMatrix()}set translate(vec){this._lowLevelCamera.translate=vec}get translate(){return this._lowLevelCamera.translate}get translateInner(){return this._lowLevelCamera.translateInner}set eye(vec){this._lowLevelCamera.eye=vec}get eye(){return this._lowLevelCamera.eye}get eyeInner(){return this._lowLevelCamera.eyeInner}set center(vec){this._lowLevelCamera.center=vec}get center(){return this._lowLevelCamera.center}get centerInner(){return this._lowLevelCamera.centerInner}set up(vec){this._lowLevelCamera.up=vec}get up(){return this._lowLevelCamera.up}get upInner(){return this._lowLevelCamera.upInner}}GLBoost["M_AbstractCamera"]=M_AbstractCamera;class L_CameraController extends GLBoostObject{constructor(glBoostContext,options={isSymmetryMode:true,doResetWhenCameraSettingChanged:false,isForceGrab:false,efficiency:1,eventTargetDom:document}){super(glBoostContext);this._camaras=new Set;this._isKeyUp=true;this._isForceGrab=options.isForceGrab!==void 0?options.isForceGrab:false;this._isSymmetryMode=options.isSymmetryMode!==void 0?options.isSymmetryMode:true;this._efficiency=options.efficiency!==void 0?.5*options.efficiency:1;let eventTargetDom=options.eventTargetDom;this._rot_bgn_x=0;this._rot_bgn_y=0;this._rot_x=0;this._rot_y=0;this._clickedMouseYOnCanvas=0;this._clickedMouseXOnCanvas=0;this._verticalAngleOfVectors=0;this._verticalAngleThrethold=90;this._wheel_y=1;this._mouse_translate_y=0;this._mouse_translate_x=0;this._mouseTranslateVec=new Vector3(0,0,0);this._newUpVec=new Vector3(0,0,0);this._target=null;this._lengthCenterToCorner=10;this._lengthOfCenterToEye=10;this._scaleOfTraslation=5;this._scaleOfLengthCameraToCenter=.5;this._foyvBias=1;this._zFarAdjustingFactorBasedOnAABB=1;this._doResetWhenCameraSettingChanged=options.doResetWhenCameraSettingChanged!==void 0?options.doResetWhenCameraSettingChanged:false;this._shiftCameraTo=null;this._onMouseDown=(evt=>{let rect=evt.target.getBoundingClientRect();this._clickedMouseXOnCanvas=evt.clientX-rect.left;this._clickedMouseYOnCanvas=evt.clientY-rect.top;this._movedMouseYOnCanvas=-1;this._movedMouseXOnCanvas=-1;this._rot_bgn_x=this._rot_x;this._rot_bgn_y=this._rot_y;this._isKeyUp=false;if(typeof evt.buttons!=="undefined"){this.updateCamera()}return false});this._onMouseUp=(evt=>{this._isKeyUp=true;this._movedMouseYOnCanvas=-1;this._movedMouseXOnCanvas=-1});this._onMouseMove=(evt=>{if(this._isKeyUp){return}let rect=evt.target.getBoundingClientRect();this._movedMouseXOnCanvas=evt.clientX-rect.left;this._movedMouseYOnCanvas=evt.clientY-rect.top;if(typeof evt.buttons!=="undefined"){let data=evt.buttons;let button_l=data&1?true:false;let button_c=data&4?true:false;if(button_c){this._mouse_translate_y=(this._movedMouseYOnCanvas-this._clickedMouseYOnCanvas)/1e3*this._efficiency;this._mouse_translate_x=(this._movedMouseXOnCanvas-this._clickedMouseXOnCanvas)/1e3*this._efficiency;let scale=this._lengthOfCenterToEye*this._foyvBias*this._scaleOfTraslation;if(evt.shiftKey){this._mouseTranslateVec=Vector3.add(this._mouseTranslateVec,Vector3.normalize(this._newEyeToCenterVec).multiply(-this._mouse_translate_y).multiply(scale))}else{this._mouseTranslateVec=Vector3.add(this._mouseTranslateVec,Vector3.normalize(this._newUpVec).multiply(this._mouse_translate_y).multiply(scale))}this._mouseTranslateVec=Vector3.add(this._mouseTranslateVec,Vector3.normalize(this._newTangentVec).multiply(this._mouse_translate_x).multiply(scale));this._clickedMouseYOnCanvas=this._movedMouseYOnCanvas;this._clickedMouseXOnCanvas=this._movedMouseXOnCanvas}this.updateCamera();if(!button_l){return}}let delta_y=(this._movedMouseYOnCanvas-this._clickedMouseYOnCanvas)*this._efficiency;let delta_x=(this._movedMouseXOnCanvas-this._clickedMouseXOnCanvas)*this._efficiency;this._rot_y=this._rot_bgn_y-delta_y;this._rot_x=this._rot_bgn_x-delta_x;if(this._verticalAngleThrethold-this._verticalAngleOfVectors{evt.preventDefault();this.dolly+=evt.deltaY/600});this._onContexMenu=(evt=>{if(evt.preventDefault){evt.preventDefault()}else{event.returnValue=false}});this._onMouseDblClick=(evt=>{if(evt.shiftKey){this._mouseTranslateVec=new Vector3(0,0,0)}else{this._rot_y=0;this._rot_x=0;this._rot_bgn_y=0;this._rot_bgn_x=0}this.updateCamera()});this.registerEventListeners(eventTargetDom)}registerEventListeners(eventTargetDom=document){if(eventTargetDom){if("ontouchend"in document){eventTargetDom.addEventListener("touchstart",this._onMouseDown);eventTargetDom.addEventListener("touchend",this._onMouseUp);eventTargetDom.addEventListener("touchmove",this._onMouseMove)}if("onmouseup"in document){eventTargetDom.addEventListener("mousedown",this._onMouseDown);eventTargetDom.addEventListener("mouseup",this._onMouseUp);eventTargetDom.addEventListener("mousemove",this._onMouseMove)}if(window.WheelEvent){eventTargetDom.addEventListener("wheel",this._onMouseWheel)}eventTargetDom.addEventListener("contextmenu",this._onContexMenu,false);eventTargetDom.addEventListener("dblclick",this._onMouseDblClick)}}unregisterEventListeners(eventTargetDom=document){if(eventTargetDom){if("ontouchend"in document){eventTargetDom.removeEventListener("touchstart",this._onMouseDown);eventTargetDom.removeEventListener("touchend",this._onMouseUp);eventTargetDom.removeEventListener("touchmove",this._onMouseMove)}if("onmouseup"in document){eventTargetDom.removeEventListener("mousedown",this._onMouseDown);eventTargetDom.removeEventListener("mouseup",this._onMouseUp);eventTargetDom.removeEventListener("mousemove",this._onMouseMove)}if(window.WheelEvent){eventTargetDom.removeEventListener("wheel",this._onMouseWheel)}eventTargetDom.removeEventListener("contextmenu",this._onContexMenu,false);eventTargetDom.removeEventListener("dblclick",this._onMouseDblClick)}}_getFovyFromCamera(camera){if(camera.fovy){return camera.fovy}else{return MathUtil.radianToDegree(2*Math.atan(Math.abs(camera.top-camera.bottom)/(2*camera.zNear)))}}convert(camera){let newEyeVec=null;let newCenterVec=null;let newUpVec=null;if(this._isKeyUp||!this._isForceGrab){this._eyeVec=this._shiftCameraTo!==null?Vector3.add(Vector3.subtract(this._shiftCameraTo,camera.center),camera.eye):camera.eye;this._centerVec=this._shiftCameraTo!==null?this._shiftCameraTo:camera.center;this._upVec=camera.up}let fovy=this._getFovyFromCamera(camera);if(this._isSymmetryMode){let centerToEyeVec=Vector3.subtract(this._eyeVec,this._centerVec).multiply(this._wheel_y*1/Math.tan(MathUtil.degreeToRadian(fovy/2)));this._lengthOfCenterToEye=centerToEyeVec.length();let horizontalAngleOfVectors=Vector3.angleOfVectors(new Vector3(centerToEyeVec.x,0,centerToEyeVec.z),new Vector3(0,0,1));let horizontalSign=Vector3.cross(new Vector3(centerToEyeVec.x,0,centerToEyeVec.z),new Vector3(0,0,1)).y;if(horizontalSign>=0){horizontalSign=1}else{horizontalSign=-1}horizontalAngleOfVectors*=horizontalSign;let rotateM_Reset=Matrix33.rotateY(horizontalAngleOfVectors);let rotateM_X=Matrix33.rotateX(this._rot_y);let rotateM_Y=Matrix33.rotateY(this._rot_x);let rotateM_Revert=Matrix33.rotateY(-horizontalAngleOfVectors);let rotateM=Matrix33.multiply(rotateM_Revert,Matrix33.multiply(rotateM_Y,Matrix33.multiply(rotateM_X,rotateM_Reset)));newUpVec=rotateM.multiplyVector(this._upVec);this._newUpVec=newUpVec;newEyeVec=rotateM.multiplyVector(centerToEyeVec).add(this._centerVec);newCenterVec=this._centerVec.clone();this._newEyeToCenterVec=Vector3.subtract(newCenterVec,newEyeVec);this._newTangentVec=Vector3.cross(this._newUpVec,this._newEyeToCenterVec);newEyeVec.add(this._mouseTranslateVec);newCenterVec.add(this._mouseTranslateVec);let horizonResetVec=rotateM_Reset.multiplyVector(centerToEyeVec);this._verticalAngleOfVectors=Vector3.angleOfVectors(horizonResetVec,new Vector3(0,0,1));let verticalSign=Vector3.cross(horizonResetVec,new Vector3(0,0,1)).x;if(verticalSign>=0){verticalSign=1}else{verticalSign=-1}}else{let centerToEyeVec=Vector3.subtract(this._eyeVec,this._centerVec).multiply(this._wheel_y*1/Math.tan(MathUtil.degreeToRadian(fovy/2)));let rotateM_X=Matrix33.rotateX(this._rot_y);let rotateM_Y=Matrix33.rotateY(this._rot_x);let rotateM=rotateM_Y.multiply(rotateM_X);newUpVec=rotateM.multiplyVector(this._upVec);this._newUpVec=newUpVec;newEyeVec=rotateM.multiplyVector(centerToEyeVec).add(this._centerVec);newCenterVec=this._centerVec.clone();this._newEyeToCenterVec=Vector3.subtract(newCenterVec,newEyeVec);this._newTangentVec=Vector3.cross(this._newUpVec,this._newEyeToCenterVec);newEyeVec.add(this._mouseTranslateVec);newCenterVec.add(this._mouseTranslateVec)}let newZNear=camera.zNear;let newZFar=camera.zFar;if(this._target){newZFar=camera.zNear+Vector3.subtract(newCenterVec,newEyeVec).length();newZFar+=this._getTargetAABB().lengthCenterToCorner*this._zFarAdjustingFactorBasedOnAABB}this._foyvBias=Math.tan(MathUtil.degreeToRadian(fovy/2));return[newEyeVec,newCenterVec,newUpVec,newZNear,newZFar]}_getTargetAABB(){let targetAABB=null;if(typeof this._target.updateAABB!=="undefined"){targetAABB=this._target.updateAABB()}else{targetAABB=this._target.AABB}return targetAABB}_updateTargeting(camera,eyeVec,centerVec,upVec,fovy){if(this._target===null){return[eyeVec,centerVec,upVec]}let targetAABB=this._getTargetAABB();this._lengthCenterToCorner=targetAABB.lengthCenterToCorner;let lengthCameraToObject=targetAABB.lengthCenterToCorner/Math.sin(fovy*Math.PI/180/2)*this._scaleOfLengthCameraToCenter;let newCenterVec=targetAABB.centerPoint;let centerToCameraVec=Vector3.subtract(eyeVec,centerVec);let centerToCameraVecNormalized=Vector3.normalize(centerToCameraVec);let newEyeVec=Vector3.multiply(centerToCameraVecNormalized,lengthCameraToObject).add(newCenterVec);let newUpVec=null;if(camera instanceof M_AbstractCamera){let mat=camera.inverseWorldMatrixWithoutMySelf;newEyeVec=mat.multiplyVector(new Vector4(newEyeVec.x,newEyeVec.y,newEyeVec.z,1)).toVector3();newCenterVec=mat.multiplyVector(new Vector4(newCenterVec.x,newCenterVec.y,newCenterVec.z,1)).toVector3();newUpVec=mat.multiplyVector(new Vector4(upVec.x,upVec.y,upVec.z,1)).toVector3()}else{newUpVec=upVec}return[newEyeVec,newCenterVec,newUpVec]}tryReset(){if(this._doResetWhenCameraSettingChanged){if(this._isKeyUp){this._rot_y=0;this._rot_x=0;this._rot_bgn_y=0;this._rot_bgn_x=0}}}reset(){this._rot_y=0;this._rot_x=0;this._rot_bgn_y=0;this._rot_bgn_x=0;this._wheel_y=1;this._mouseTranslateVec=new Vector3(0,0,0);this._camaras.forEach(function(camera){camera._needUpdateView(false)})}updateTargeting(){this._camaras.forEach(camera=>{let vectors=this._updateTargeting(camera,camera.eye,camera.center,camera.up,this._getFovyFromCamera(camera));camera.eye=vectors[0];camera.center=vectors[1];camera.up=vectors[2]})}updateCamera(){this._camaras.forEach(function(camera){camera._needUpdateView(false);camera._needUpdateProjection()})}addCamera(camera){this._camaras.add(camera)}set target(object){this._target=object;this.updateTargeting()}set zFarAdjustingFactorBasedOnAABB(value){this._zFarAdjustingFactorBasedOnAABB=value}get zFarAdjustingFactorBasedOnAABB(){return this._zFarAdjustingFactorBasedOnAABB}set shiftCameraTo(value){this._shiftCameraTo=value}get shiftCameraTo(){return this._shiftCameraTo}resetDolly(){this.dolly=1;this._updateCameras()}set dolly(value){this._wheel_y=value;this._wheel_y=Math.min(this._wheel_y,3);this._wheel_y=Math.max(this._wheel_y,.01);this.updateCamera()}get dolly(){return this._wheel_y}get rotX(){return this._rot_x}set rotX(value){this._rot_x=value;this._rot_bgn_x=0;this._camaras.forEach(function(camera){camera._needUpdateView(true);camera._needUpdateProjection()})}get rotY(){return this._rot_y}set rotY(value){this._rot_y=value;this._rot_bgn_y=0;this._camaras.forEach(function(camera){camera._needUpdateView(true);camera._needUpdateProjection()})}}GLBoost$1["L_CameraController"]=L_CameraController;class L_WalkThroughCameraController extends GLBoostObject{constructor(glBoostContext,options={eventTargetDom:document,horizontalSpeed:1,turnSpeed:5}){super(glBoostContext);this._camaras=new Set;this._horizontalSpeed=options.horizontalSpeed;this._virticalSpeed=options.virticalSpeed;this._turnSpeed=options.turnSpeed;this._isKeyDown=false;this._lastKeyCode=null;this._currentPos=null;this._currentCenter=null;this._currentDir=null;this._onKeydown=(e=>{this._isKeyDown=true;this._lastKeyCode=e.keyCode;this.updateCamera()});this._onKeyup=(e=>{this._isKeyDown=false;this._lastKeyCode=null});const eventTargetDom=options.eventTargetDom;this.registerEventListeners(eventTargetDom)}updateCamera(){this._camaras.forEach(function(camera){camera._needUpdateView(false);camera._needUpdateProjection()})}registerEventListeners(eventTargetDom=document){if(eventTargetDom){eventTargetDom.addEventListener("keydown",this._onKeydown);eventTargetDom.addEventListener("keyup",this._onKeyup)}}unregisterEventListeners(eventTargetDom=document){if(eventTargetDom){eventTargetDom.removeEventListener("keydown",this._onKeydown);eventTargetDom.removeEventListener("keyup",this._onKeyup)}}tryReset(){}addCamera(camera){this._camaras.add(camera)}convert(camera){if(this._currentPos===null){this._currentPos=camera.eye.clone()}if(this._currentCenter===null){this._currentCenter=camera.center.clone()}if(this._currentDir===null){this._currentDir=Vector3.subtract(camera.center,camera.eye).normalize()}let newEyeToCenter=null;switch(this._lastKeyCode){case 87:this._currentPos.add(Vector3.multiply(this._currentDir,this._horizontalSpeed));this._currentCenter.add(Vector3.multiply(this._currentDir,this._horizontalSpeed));break;case 65:this._currentDir=Matrix33.rotateY(this._turnSpeed).multiplyVector(this._currentDir);newEyeToCenter=Matrix33.rotateY(this._turnSpeed).multiplyVector(Vector3.subtract(this._currentCenter,this._currentPos));this._currentCenter=Vector3.add(this._currentPos,newEyeToCenter);break;case 83:this._currentPos.add(Vector3.multiply(this._currentDir,-this._horizontalSpeed));this._currentCenter.add(Vector3.multiply(this._currentDir,-this._horizontalSpeed));break;case 68:this._currentDir=Matrix33.rotateY(-this._turnSpeed).multiplyVector(this._currentDir);newEyeToCenter=Matrix33.rotateY(-this._turnSpeed).multiplyVector(Vector3.subtract(this._currentCenter,this._currentPos));this._currentCenter=Vector3.add(this._currentPos,newEyeToCenter);break;case 81:{const leftDir=Matrix33.rotateY(90).multiplyVector(this._currentDir);this._currentPos.add(Vector3.multiply(leftDir,this._horizontalSpeed));this._currentCenter.add(Vector3.multiply(leftDir,this._horizontalSpeed))}break;case 69:{const rightDir=Matrix33.rotateY(-90).multiplyVector(this._currentDir);this._currentPos.add(Vector3.multiply(rightDir,this._horizontalSpeed));this._currentCenter.add(Vector3.multiply(rightDir,this._horizontalSpeed))}break;case 82:this._currentPos.add(new Vector3(0,this._virticalSpeed,0));this._currentCenter.add(new Vector3(0,this._virticalSpeed,0));break;case 70:this._currentPos.add(new Vector3(0,-this._virticalSpeed,0));this._currentCenter.add(new Vector3(0,-this._virticalSpeed,0));break}return[this._currentPos,this._currentCenter,camera.up.clone(),camera.zNear,camera.zFar]}getDirection(){return this._currentCenter!==null?this._currentDir.clone():null}}GLBoost$1["L_WalkThroughCameraController"]=L_WalkThroughCameraController;class MutableTexture extends AbstractTexture{constructor(glBoostContext,width,height,level=0,internalFormat=6408,format=6408,type=5121,magFileter=9729,minFilter=9729,wrapS=33071,wrapT=33071){super(glBoostContext);this._isTextureReady=false;this._texture=null;this._width=width;this._height=height;this._fbo=null;this._colorAttachmentId=null;this._depthAttachmentId=null;var gl=this._glContext.gl;this._texture=this._glContext.createTexture(this);gl.bindTexture(gl.TEXTURE_2D,this._texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,magFileter);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,minFilter);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,wrapS);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,wrapT);if(GLBoost$1.isThisGLVersion_2(gl)&&(internalFormat===6402||internalFormat===33189||internalFormat===33190||internalFormat===33191)){gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_COMPARE_MODE,gl.COMPARE_REF_TO_TEXTURE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_COMPARE_FUNC,gl.LESS)}gl.texImage2D(gl.TEXTURE_2D,level,internalFormat,width,height,0,format,type,null);gl.bindTexture(gl.TEXTURE_2D,null)}set colorAttachment(colorAttachmentId){this._colorAttachmentId=colorAttachmentId}get colorAttachment(){return this._colorAttachmentId}set depthAttachment(depthAttachmentId){this._depthAttachmentId=depthAttachmentId}get depthAttachment(){return this._depthAttachmentId}set frameBufferObject(fbo){this._fbo=fbo}get frameBufferObject(){return this._fbo}}class DataUtil{constructor(){}static isNode(){let isNode=window===void 0&&typeof process!=="undefined"&&typeof require!=="undefined";return isNode}static btoa(str){let isNode=DataUtil.isNode();if(isNode){let buffer;if(Buffer.isBuffer(str)){buffer=str}else{buffer=new Buffer(str.toString(),"binary")}return buffer.toString("base64")}else{return btoa(str)}}static atob(str){let isNode=DataUtil.isNode();if(isNode){return new Buffer(str,"base64").toString("binary")}else{return atob(str)}}static base64ToArrayBuffer(dataUri){let splittedDataUri=dataUri.split(",");let type=splittedDataUri[0].split(":")[1].split(";")[0];let byteString=DataUtil.atob(splittedDataUri[1]);let byteStringLength=byteString.length;let arrayBuffer=new ArrayBuffer(byteStringLength);let uint8Array=new Uint8Array(arrayBuffer);for(let i=0;i{let isNode=DataUtil.isNode();if(isNode){let fs=require("fs");let args=[resourceUri];let func=(err,response)=>{if(err){if(rejectCallback){rejectCallback(reject,err)}return}if(isBinary){let buffer=new Buffer(response,"binary");let uint8Buffer=new Uint8Array(buffer);response=uint8Buffer.buffer}resolveCallback(resolve,response)};if(isBinary){args.push(func)}else{args.push("utf8");args.push(func)}fs.readFile.apply(fs,args)}else{let xmlHttp=new XMLHttpRequest;if(isBinary){xmlHttp.responseType="arraybuffer";xmlHttp.onload=(oEvent=>{let response=null;if(isBinary){response=xmlHttp.response}else{response=xmlHttp.responseText}resolveCallback(resolve,response)})}else{xmlHttp.onreadystatechange=(()=>{if(xmlHttp.readyState===4&&(Math.floor(xmlHttp.status/100)===2||xmlHttp.status===0)){let response=null;if(isBinary){response=xmlHttp.response}else{response=xmlHttp.responseText}resolveCallback(resolve,response)}else{if(rejectCallback){rejectCallback(reject,xmlHttp.status)}}})}xmlHttp.open("GET",resourceUri,true);xmlHttp.send(null)}})}}GLBoost$1["DataUtil"]=DataUtil;class Texture extends AbstractTexture{constructor(glBoostContext,src,userFlavorName,parameters=null){super(glBoostContext);this._isTextureReady=false;this._texture=null;if(typeof userFlavorName==="undefined"||userFlavorName===null){this.userFlavorName=this._instanceName}else{this.userFlavorName=userFlavorName}this._parameters=parameters?parameters:{};if(typeof src==="undefined"||src===null);else if(typeof src==="string"){this.generateTextureFromUri(src)}else if(src instanceof Image){this.generateTextureFromImage(src)}else{this._generateTextureFromImageData(src)}}_getParameter(paramNumber){let isParametersExist=false;if(this._parameters){isParametersExist=true}let params=this._parameters;let paramName=GLBoost$1.getNameOfGLBoostConstant(paramNumber);let ret=null;switch(paramNumber){case GLBoost$1["UNPACK_FLIP_Y_WEBGL"]:case GLBoost$1["UNPACK_PREMULTIPLY_ALPHA_WEBGL"]:case GLBoost$1["TEXTURE_MAG_FILTER"]:case GLBoost$1["TEXTURE_MIN_FILTER"]:case GLBoost$1["TEXTURE_WRAP_S"]:case GLBoost$1["TEXTURE_WRAP_T"]:if(isParametersExist&¶ms[paramName]){ret=params[paramName]}break}return ret}_getParamWithAlternative(paramNumber,alternative){return MiscUtil.getTheValueOrAlternative(this._getParameter(paramNumber),alternative)}generateTextureFromUri(imageUri,isKeepBound=false){return new Promise((resolve,reject)=>{let isNode=DataUtil.isNode();if(isNode){let getPixels=require("get-pixels");let results=getPixels(imageUri,(err,pixels)=>{if(err){console.log("Bad image path");reject();return}this._width=pixels.shape[0];this._height=pixels.shape[1];let texture=this._generateTextureInnerWithArrayBufferView(pixels.data,this._width,this._height,isKeepBound);this._texture=texture;this._isTextureReady=true;resolve()})}else{this._img=new Image;if(!imageUri.match(/^data:/)){this._img.crossOrigin="Anonymous"}this._img.onload=(()=>{let imgCanvas=this._getResizedCanvas(this._img);this._width=imgCanvas.width;this._height=imgCanvas.height;let texture=this._generateTextureInner(imgCanvas,isKeepBound);this._texture=texture;this._isTextureReady=true;resolve()});this._img.src=imageUri}})}generateTextureFromImage(img){let imgCanvas=this._getResizedCanvas(img);this._width=imgCanvas.width;this._height=imgCanvas.height;let texture=this._generateTextureInner(imgCanvas,false);this._texture=texture;this._isTextureReady=true}_generateTextureFromImageData(imageData){var gl=this._glContext.gl;var glem=GLExtensionsManager.getInstance(this._glContext);var imgCanvas=this._getResizedCanvas(imageData);this._width=imgCanvas.width;this._height=imgCanvas.height;var texture=this._generateTextureInner(imgCanvas,false);this._texture=texture;this._isTextureReady=true;this._img=imageData;this._onLoad()}_generateTextureInnerWithArrayBufferView(imgCanvas,width,height,isKeepBound){var gl=this._glContext.gl;var glem=GLExtensionsManager.getInstance(this._glContext);var texture=this._glContext.createTexture(this);gl.bindTexture(gl.TEXTURE_2D,texture);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this._getParamWithAlternative(GLBoost$1.UNPACK_FLIP_Y_WEBGL,false));gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._getParamWithAlternative(GLBoost$1.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false));gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,width,height,0,gl.RGBA,gl.UNSIGNED_BYTE,imgCanvas);if(glem.extTFA){gl.texParameteri(gl.TEXTURE_2D,glem.extTFA.TEXTURE_MAX_ANISOTROPY_EXT,4)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,this._getParamWithAlternative(GLBoost$1.TEXTURE_MAG_FILTER,gl.LINEAR));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,this._getParamWithAlternative(GLBoost$1.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_LINEAR));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,this._getParamWithAlternative(GLBoost$1.TEXTURE_WRAP_S,gl.REPEAT));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,this._getParamWithAlternative(GLBoost$1.TEXTURE_WRAP_T,gl.REPEAT));gl.generateMipmap(gl.TEXTURE_2D);if(!isKeepBound){gl.bindTexture(gl.TEXTURE_2D,null)}return texture}_generateTextureInner(imgCanvas,isKeepBound){var gl=this._glContext.gl;var glem=GLExtensionsManager.getInstance(this._glContext);var texture=this._glContext.createTexture(this);gl.bindTexture(gl.TEXTURE_2D,texture);gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this._getParamWithAlternative(GLBoost$1.UNPACK_FLIP_Y_WEBGL,false));gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._getParamWithAlternative(GLBoost$1.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false));gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,imgCanvas);if(glem.extTFA){gl.texParameteri(gl.TEXTURE_2D,glem.extTFA.TEXTURE_MAX_ANISOTROPY_EXT,4)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,this._getParamWithAlternative(GLBoost$1.TEXTURE_MAG_FILTER,gl.LINEAR));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,this._getParamWithAlternative(GLBoost$1.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_LINEAR));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,this._getParamWithAlternative(GLBoost$1.TEXTURE_WRAP_S,gl.REPEAT));gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,this._getParamWithAlternative(GLBoost$1.TEXTURE_WRAP_T,gl.REPEAT));gl.generateMipmap(gl.TEXTURE_2D);if(!isKeepBound){gl.bindTexture(gl.TEXTURE_2D,null)}return texture}_onLoad(){}get isTextureReady(){return this._isTextureReady}get isImageAssignedForTexture(){return typeof this._img=="undefined"}}class PhinaTexture extends Texture{constructor(glBoostContext,width,height,fillStyle,parameters=null){super(glBoostContext,null,null,parameters);this._parameters["UNPACK_FLIP_Y_WEBGL"]=true;this._width=width;this._height=height;this._fillStyle=fillStyle;this._phinaObjects=[];this._setUpOffscreen()}_setUpOffscreen(){this._offscreen=phina.display.OffScreenLayer({width:this.width,height:this.height,fillStyle:this._fillStyle});this._offscreen.reset()}addPhinaObject(object){this._phinaObjects.push(object);return this}addPhinaObjects(objects){this._phinaObjects=this._phinaObjects.concat(objects);return this}setPhinaObjects(objects){this._phinaObjects=objects.concat();return this}clearPhinaObjects(){this._phinaObjects.length=0;return this}renderPhinaObjects(){for(let i=0;i0){result=[];for(var i=0,len=arguments.length;i{var glTexture=texture.glTextureResource;var attachimentId=glem.colorAttachiment(gl,i);texture.colorAttachment=attachimentId;gl.framebufferTexture2D(gl.FRAMEBUFFER,attachimentId,gl.TEXTURE_2D,glTexture,0)});gl.framebufferRenderbuffer(gl.FRAMEBUFFER,gl.DEPTH_ATTACHMENT,gl.RENDERBUFFER,renderBuffer);gl.bindRenderbuffer(gl.RENDERBUFFER,null);gl.bindFramebuffer(gl.FRAMEBUFFER,null);return fbo._glboostTextures.concat()}createDepthTexturesForRenderTarget(width,height){var glContext=this._glContext;var gl=glContext.gl;var glem=GLExtensionsManager.getInstance(glContext);var fbo=glContext.createFramebuffer(this);gl.bindFramebuffer(gl.FRAMEBUFFER,fbo);fbo.width=width;fbo.height=height;let format=gl.DEPTH_COMPONENT;let internalFormat=gl.DEPTH_COMPONENT;let type=gl.UNSIGNED_INT;if(GLBoost$1.isThisGLVersion_2(gl)){type=gl.UNSIGNED_INT;format=gl.DEPTH_COMPONENT;internalFormat=gl.DEPTH_COMPONENT24}else if(glem.extDepthTex){type=glem.extDepthTex.UNSIGNED_INT_24_8_WEBGL;format=gl.DEPTH_STENCIL;internalFormat=gl.DEPTH_STENCIL}let depthTexture=new MutableTexture(this,fbo.width,fbo.height,0,internalFormat,format,type,gl.LINEAR,gl.LINEAR,gl.CLAMP_TO_EDGE,gl.CLAMP_TO_EDGE);depthTexture.fbo=fbo;var glTexture=depthTexture.glTextureResource;var attachimentId=gl.DEPTH_ATTACHMENT;if(GLBoost$1.isThisGLVersion_2(gl)){attachimentId=gl.DEPTH_ATTACHMENT}else if(glem.extDepthTex){attachimentId=gl.DEPTH_STENCIL_ATTACHMENT}depthTexture.depthAttachment=attachimentId;gl.framebufferTexture2D(gl.FRAMEBUFFER,attachimentId,gl.TEXTURE_2D,glTexture,0);gl.bindFramebuffer(gl.FRAMEBUFFER,null);return depthTexture}get belongingCanvasId(){return this._glContext.belongingCanvasId}set globalStatesUsage(usageMode){this._globalStatesUsage=usageMode}get globalStatesUsage(){return this._globalStatesUsage}reflectGlobalGLState(){let gl=this._glContext.gl;this.currentGlobalStates.forEach(state=>{gl.enable(state)});gl.depthFunc(gl.LEQUAL);gl.blendEquation(gl.FUNC_ADD);gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA);gl.clearDepth(1);gl.clearStencil(0)}disableAllGLState(){let states=[3042,2884,2929,32823,32926];let glContext=this._glContext;let gl=glContext.gl;states.forEach(state=>{gl.disable(state)})}set currentGlobalStates(states){this._currentGlobalStates=states.concat()}get currentGlobalStates(){return this._currentGlobalStates.concat()}restoreGlobalStatesToDefault(){this._currentGlobalStates=this._defaultGlobalStates.concat()}}GLBoost$1["GLBoostLowContext"]=GLBoostLowContext;class M_Mesh extends M_Element{constructor(glBoostContext,geometry,material){super(glBoostContext);if(geometry){this.geometry=geometry}if(material){this.material=material}this._transformedDepth=0}prepareToRender(expression,existCamera_f,lights){this._geometry.prepareToRender(expression,existCamera_f,lights,this._material,this)}draw(data){this._geometry.draw({expression:data.expression,lights:data.lights,camera:data.camera,scene:data.renderPass.scene,renderPassIndex:data.renderPassIndex,mesh:this,viewport:data.viewport,isWebVRMode:data.isWebVRMode,webvrFrameData:data.webvrFrameData})}set geometry(geometry){this._geometry=geometry;geometry._parent=this;M_Mesh._geometries[geometry.toString()]=geometry}get geometry(){return this._geometry}set material(material){this._material=material}get material(){return this._material}bakeTransformToGeometry(){var positions=this._geometry._vertices.position;var mat=this.worldMatrix;let componentN=this._geometry._vertices.components.position;let length=positions.length/componentN;for(let i=0;i3){positions[i*componentN+3]=transformedPosVec.w}}this._geometry._vertices.position=positions;if(this._geometry._vertices.normal){var normals=this._geometry._vertices.normal;length=normals.length/3;for(let i=0;i3){positions[i*componentN+3]=transformedPosVec.w}}this._geometry._vertices.position=positions;let mat=this.worldMatrix;if(this._geometry._vertices.normal){var normals=this._geometry._vertices.normal;length=normals.length/3;for(let i=0;i0){objects=objects.concat(hitChildren)}}return objects}if(type.name.indexOf("Gizmo")!==-1&&element instanceof M_Element){let gizmos=element._gizmos;for(let gizmo of gizmos){if(this._validateByQuery(gizmo,query,queryMeta)){objects.push(gizmo)}}return objects}if(type===L_AbstractMaterial&&element instanceof M_Mesh){let materials=element.getAppropriateMaterials();for(let material of materials){if(this._validateByQuery(material,query,queryMeta)){objects.push(material)}}return objects}else if(this._validateByQuery(element,query,queryMeta)&&element instanceof type){return[element]}return objects}getStartAnimationInputValue(inputLineName,element=this){if(element instanceof M_Group){let latestInputValue=element.getStartInputValueOfAnimation(inputLineName);let children=element.getChildren();for(let i=0;ilatestInputValue){latestInputValue=endInputValueOfThisElement}}else{let endInputValueOfThisElement=hitChildOrInputValue;if(endInputValueOfThisElement>latestInputValue){latestInputValue=endInputValueOfThisElement}}}return latestInputValue}return element.getEndInputValueOfAnimation(inputLineName)}updateAABB(){var aabb=function mergeAABBRecursively(elem){if(elem instanceof M_Group){var children=elem.getChildren();for(let i=0;i{if(typeof element.clone!=="undefined"){instance._elements.push(element.clone(clonedOriginalRootElement,clonedRootElement,onCompleteFuncs))}else{instance._elements.push(element)}});onCompleteFuncs.forEach(func=>{func()});return instance}_copy(instance){super._copy(instance);instance._AABB=this._AABB.clone();instance._isRootJointGroup=this._isRootJointGroup}set isVisible(flg){let collectVisibility=function(elem){elem._isVisible=flg;if(elem instanceof M_Group){let children=elem.getChildren();children.forEach(function(child){collectVisibility(child)})}};collectVisibility(this)}get isVisible(){return this._isVisible}_updateAABBGizmo(){let world_m=this.worldMatrix;let aabbInWorld=AABB.multiplyMatrix(world_m,this._AABB)}readyForDiscard(){this.removeAll()}rayCast(x,y,camera,viewport){const meshes=this.searchElementsByType(M_Mesh);let currentShortestT=Number.MAX_VALUE;let currentShortestIntersectedPosVec3=null;for(let mesh of meshes){const result=mesh.rayCast(x,y,camera,viewport);if(result===null){return[null,null]}const t=result[1];if(tself.indexOf(mesh)===i);return meshes}getTriangleCount(userFlavorNameOrGLBoostObject){let objects=this.getGLBoostObjectsFromArgument(userFlavorNameOrGLBoostObject);let meshes=this.getMMeshes(objects);let count=0;for(let mesh of meshes){count+=mesh.geometry.getTriangleCount(mesh)}return count}getVertexCount(userFlavorNameOrGLBoostObject){let objects=this.getGLBoostObjectsFromArgument(userFlavorNameOrGLBoostObject);let meshes=this.getMMeshes(objects);let count=0;for(let mesh of meshes){count+=mesh.geometry.getVertexCount(mesh)}return count}getTextureUserFlavorNames(userFlavorNameOrGLBoostObject){let objects=this.getGLBoostObjectsFromArgument(userFlavorNameOrGLBoostObject);let meshes=this.getMMeshes(objects);let textureUserFlavorNames=[];for(let mesh of meshes){let materials=mesh.geometry._getAppropriateMaterials(mesh);for(let i=0;i{renderPass._expression=this});this._renderPasses=this._renderPasses.concat(renderPasses)}addRenderPass(renderPass){renderPath._expression=this;this._renderPasses.push(renderPass)}clearRenderPasses(){this._renderPasses.forEach(renderPass=>{renderPass._expression=null});this._renderPasses.length=0}get renderPasses(){return this._renderPasses}setCurrentAnimationValue(inputName,inputValue){for(let renderPass of this.renderPasses){if(renderPass.scene){renderPass.scene.setCurrentAnimationValue(inputName,inputValue)}}}prepareToRender(){this._renderPasses.forEach((renderPass,index)=>{renderPass.prepareToRender(this)})}}GLBoost$1["Expression"]=Expression;class RenderPass extends GLBoostObject{constructor(glBoostContext){super(glBoostContext);this._scene=null;this._meshes=[];this._gizmos=[];this._opacityMeshes=[];this._transparentMeshes=[];this._transparentMeshesAsManualOrder=null;this._drawBuffers=[this._glContext.gl.NONE];this._clearColor=null;this._clearDepth=null;this._colorMask=null;this._renderTargetColorTextures=[];this._renderTargetDepthTexture=[];this._expression=null;this._viewport=null;this._isRenderTargetAttachedTextures=false;this._isEnableToDraw=true;this._customFunctionWhenPrepareToRender=null;this._customFunctionWhenPreRender=null;this._customFunctionWhenPostRender=null;this._webglStatesAssignDictionaries=[];this._backupWebGLStatesOfMaterials=[];this._shaderParametersAssignDictionaries=[];this._backupShaderParametersOfMaterials=[];this._shaderAssignDictionaries=[];this._backupShadersOfInstances=[];this._newShaderInstance=null;this._oldShaderClass=null;this._backupShaderClassDic={};this._doPreRender=true;this._doPostRender=true;this._tag=""}set tag(name){this._tag=name}get tag(){return this._tag}get doPreRender(){return this._doPreRender}set doPreRender(flg){this._doPreRender=flg}get doPostRender(){return this._doPostRender}set doPostRender(flg){this._doPostRender=flg}get expression(){return this._expression}set scene(scene){this._scene=scene}get scene(){return this._scene}get meshes(){return this._meshes}get opacityMeshes(){return this._opacityMeshes}get transparentMeshes(){return this._transparentMeshes}get gizmos(){return this._gizmos}specifyRenderTargetTextures(renderTargetTextures){var gl=this._glContext.gl;var colorRenderTargetTextures=renderTargetTextures.filter(renderTargetTexture=>{if(renderTargetTexture.colorAttachment){return true}else{return false}});if(colorRenderTargetTextures.length>0){this._drawBuffers=[];colorRenderTargetTextures.forEach(texture=>{var attachment=texture.colorAttachment;this._drawBuffers.push(attachment)});this._renderTargetColorTextures=colorRenderTargetTextures}else{this._drawBuffers=[gl.NONE]}var depthRenderTargetTextures=renderTargetTextures.filter(renderTargetTexture=>{if(renderTargetTexture.depthAttachment){return true}else{return false}});this._renderTargetDepthTexture=depthRenderTargetTextures[0];this._isRenderTargetAttachedTextures=true}get buffersToDraw(){return this.isRenderTargetAttachedTextures?this._drawBuffers:[this._glContext.gl.BACK]}set isRenderTargetAttachedTextures(flg){this._isRenderTargetAttachedTextures=flg}get isRenderTargetAttachedTextures(){return this._isRenderTargetAttachedTextures}get fbo(){if(this._renderTargetColorTextures.length>0){return this._renderTargetColorTextures[0].fbo}else if(this._renderTargetDepthTexture){return this._renderTargetDepthTexture.fbo}else{return null}}get viewport(){return this._viewport}set viewport(vec4){this._viewport=vec4}setViewportAsFittingToRenderTarget(){let width;let height;if(this._renderTargetColorTextures.length>0){width=this._renderTargetColorTextures[0].width;height=this._renderTargetColorTextures[0].height}if(this._renderTargetDepthTexture){width=this._renderTargetDepthTexture.width;height=this._renderTargetDepthTexture.height}if(typeof width!=="undefined"&&typeof height!=="undefined"){this._viewport=new Vector4(0,0,width,height);return true}else{return false}}get renderTargetColorTextures(){return this._renderTargetColorTextures}get renderTargetDepthTexture(){return this._renderTargetDepthTexture}setClearColor(color){this._clearColor=color}get clearColor(){return this._clearColor}setClearDepth(depth){this._clearDepth=depth}get clearDepth(){return this._clearDepth}setColorMask(colorMask){this._colorMask=colorMask}get colorMask(){return this._colorMask}setWebGLStatesAssignDictionaries(dictionaries){this._webglStatesAssignDictionaries=dictionaries}setShaderParametersAssignDictionaries(dictionaries){this._shaderParametersAssignDictionaries=dictionaries}setShaderAssignDictionaries(dictionaries){this._newShaderInstance=null;this._backupShaderClassDic={};this._shaderAssignDictionaries=[];for(let directory of dictionaries){let meshes=[];for(let instance of directory.instances){if(instance instanceof M_Group){meshes=meshes.concat(instance.searchElementsByType(GLBoost.M_Mesh))}else{meshes.push(instance)}}this._shaderAssignDictionaries.push({instances:meshes,shaderClass:directory.shaderClass})}}_assignWebGLStates(){if(this._webglStatesAssignDictionaries.length===0){return}for(let dic of this._webglStatesAssignDictionaries){for(let material of dic.materials){this._backupWebGLStatesOfMaterials.push({material:material,states:material.states});material.states=dic.states}}}_restoreWebGLStates(){if(this._backupWebGLStatesOfMaterials.length===0){return}for(let dic of this._backupWebGLStatesOfMaterials){dic.material.states=dic.states}}_assignShaderParameters(){if(this._shaderParametersAssignDictionaries.length===0){return}for(let dic of this._shaderParametersAssignDictionaries){for(let mesh of this._meshes){let materials=mesh.getAppropriateMaterials();for(let material of materials){this._backupShaderParametersOfMaterials.push({mesh:mesh,shaderParameters:material.shaderParameters});material.shaderParameters=dic.shaderParameters}}}}_restoreShaderParameters(){if(this._backupShaderParametersOfMaterials.length===0){return}for(let i=0;i{this._backupShadersOfInstances.push({instance:obj,backupShaderClass:material.shaderClass,backupShaderInstance:material.shaderInstance});if(this._newShaderInstance&&material.shaderClass.name!==this._oldShaderClass.name){this._newShaderInstance.readyForDiscard();this._newShaderInstance=void 0}if(!this._newShaderInstance){let glslProgram=obj.geometry.prepareGLSLProgramAndSetVertexNtoMaterial(this.expression,material,0,existCamera_f,lights,false,dic.shaderClass);this._oldShaderClass=material.shaderClass;this._newShaderInstance=material.shaderInstance}})}}}}_restoreShaders(existCamera_f,lights){if(this._backupShadersOfInstances.length===0){return}for(let dic of this._backupShadersOfInstances){dic.instance.getAppropriateMaterials().forEach((material,index)=>{let shaderInstance=dic.backupShaderInstance;if(!shaderInstance){material.shaderInstance=obj.geometry.prepareGLSLProgramAndSetVertexNtoMaterial(this.expression,material,0,existCamera_f,lights,false,dic.shaderClass)}})}}clearAssignShaders(){for(let dic of this._shaderAssignDictionaries){if(dic._newShaderInstance){dic._newShaderInstance.readyForDiscard()}dic._newShaderInstance=void 0}}set customFunctionWhenPrepareToRender(func){this._customFunctionWhenPrepareToRender=func}get customFunctionWhenPrepareToRender(){return this._customFunctionWhenPrepareToRender}set customFunctionWhenPreRender(func){this._customFunctionWhenPreRender=func}get customFunctionWhenPreRender(){return this._customFunctionWhenPreRender}set customFunctionWhenPostRender(func){this._customFunctionWhenPostRender=func}get customFunctionWhenPostRender(){return this._customFunctionWhenPostRender}prepareToRender(expression){let collectElements=function(elem,elementsType){if(elem instanceof M_Group){var children=elem.getChildren();var meshes=[];children.forEach(function(child){var childMeshes=collectElements(child,elementsType);meshes=meshes.concat(childMeshes)});return meshes}else if(elem instanceof elementsType){return[elem]}else{return[]}};this._meshes=[];this._gizmos=[];if(this._scene){let elements=[];Array.prototype.push.apply(this._gizmos,this._scene._gizmos);this._scene.getChildren().forEach(elm=>{Array.prototype.push.apply(this._gizmos,elm._gizmos);this._meshes=this._meshes.concat(collectElements(elm,M_Mesh));elements=elements.concat(collectElements(elm,M_Element))})}this._opacityMeshes=[];this._transparentMeshes=[];this._meshes.forEach(mesh=>{if(mesh.isTransparent){this._transparentMeshes.push(mesh)}else{this._opacityMeshes.push(mesh)}});this._skeletalMeshes=[];this._meshes.forEach(mesh=>{if(mesh.instanceName.indexOf("SkeletalMesh")!==-1){this._skeletalMeshes.push(mesh)}});if(this._scene){this._scene.prepareToRender(expression)}var camera=this.scene.getMainCamera(this);let lights=this.scene.lightsExceptAmbient;for(let dic of this._shaderAssignDictionaries){for(let obj of dic.instances){let renderSpecificMaterials=[];obj.getAppropriateMaterials().forEach((material,index)=>{let newMaterial=this._glBoostContext.createClassicMaterial();renderSpecificMaterials.push(newMaterial)});let materials=obj.geometry.prepareToRender(this.expression,camera?true:false,lights,null,obj,dic.shaderClass,renderSpecificMaterials);obj.getAppropriateMaterials().forEach((material,index)=>{material["renderpassSpecificMaterial_"+this.instanceName+"_material_"+index]=materials[index]})}}if(this._customFunctionWhenPrepareToRender){this._customFunctionWhenPrepareToRender()}}sortTransparentMeshes(camera){this._transparentMeshes.forEach(mesh=>{mesh.calcTransformedDepth(camera)});this._transparentMeshes.sort(function(a,b){if(a.transformedDepthb.transformedDepth)return 1;return 0})}set isEnableToDraw(flg){this._isEnableToDraw=flg}get isEnableToDraw(){return this._isEnableToDraw}preRender(existCamera_f,lights){if(!this.doPreRender){return}if(this._customFunctionWhenPreRender){this._customFunctionWhenPreRender()}this._assignWebGLStates()}postRender(existCamera_f,lights){if(!this.doPostRender){return}if(this._customFunctionWhenPostRender){this._customFunctionWhenPostRender()}this._restoreWebGLStates()}set transparentMeshesAsManualOrder(meshes){this._transparentMeshesAsManualOrder=meshes}get transparentMeshesAsManualOrder(){return this._transparentMeshesAsManualOrder}}class Renderer extends GLBoostObject{constructor(glBoostContext,parameters){super(glBoostContext);var _clearColor=parameters.clearColor;var gl=this._glContext.gl;this._glBoostContext.reflectGlobalGLState();if(_clearColor){gl.clearColor(_clearColor.red,_clearColor.green,_clearColor.blue,_clearColor.alpha)}this.__animationFrameId=-1;this.__isWebVRMode=false;this.__webvrFrameData=null;this.__webvrDisplay=null;this.__defaultUserSittingPositionInVR=new Vector3(0,1.1,1.5);this.__requestedToEnterWebVR=false;this.__isReadyForWebVR=false;this.__animationFrameObject=window}update(expression){let skeletalMeshes=[];for(let renderPass of expression.renderPasses){skeletalMeshes=skeletalMeshes.concat(renderPass._skeletalMeshes);renderPass.scene.updateAmountOfAmbientLightsIntensity()}let unique=function(array){return array.reduce(function(a,b){if(a.instanceName!==b.instanceName){a.push(b)}return a},[])};skeletalMeshes=unique(skeletalMeshes);for(let mesh of skeletalMeshes){mesh.geometry.update(mesh)}if(typeof effekseer!=="undefined"){effekseer.update()}}draw(expression){let renderPassTag="";expression.renderPasses.forEach((renderPass,index)=>{if(!renderPass.isEnableToDraw||!renderPass.scene){return}if(renderPassTag!==renderPass.tag){renderPass.clearAssignShaders()}renderPassTag=renderPass.tag;var camera=renderPass.scene.getMainCamera();let lights=renderPass.scene.lightsExceptAmbient;renderPass.preRender(camera?true:false,lights);var glContext=this._glContext;var gl=glContext.gl;var glem=GLExtensionsManager.getInstance(this._glContext);if(renderPass.fbo&&renderPass.isRenderTargetAttachedTextures){gl.bindFramebuffer(gl.FRAMEBUFFER,renderPass.fbo)}glem.drawBuffers(gl,renderPass.buffersToDraw);let viewport=null;if(renderPass.viewport){viewport=[renderPass.viewport.x,renderPass.viewport.y,renderPass.viewport.z,renderPass.viewport.w]}else{if(this.isWebVRMode){viewport=[0,0,glContext.canvasWidth,glContext.canvasHeight]}else if(camera){let deltaWidth=glContext.canvasHeight*camera.aspect-glContext.canvasWidth;viewport=[-deltaWidth/2,0,glContext.canvasHeight*camera.aspect,glContext.canvasHeight]}else{viewport=[0,0,glContext.canvasWidth,glContext.canvasHeight]}}if(!this.isWebVRMode){gl.viewport.apply(gl,viewport)}this._clearBuffer(gl,renderPass);if(this.__animationFrameObject===this.__webvrDisplay){this.__webvrDisplay.getFrameData(this.__webvrFrameData);if(this.__webvrDisplay.stageParameters){this.__webvrFrameData.sittingToStandingTransform=this.__webvrDisplay.stageParameters.sittingToStandingTransform}else{this.__webvrFrameData.sittingToStandingTransform=Matrix44$2.translate(this.__defaultUserSittingPositionInVR).flatten()}}const opacityMeshes=renderPass.opacityMeshes;opacityMeshes.forEach(mesh=>{if(mesh.isVisible){mesh.draw({expression:expression,lights:lights,camera:camera,renderPass:renderPass,renderPassIndex:index,viewport:viewport,isWebVRMode:this.isWebVRMode,webvrFrameData:this.__webvrFrameData})}});if(camera){renderPass.sortTransparentMeshes(camera)}const transparentMeshes=renderPass.transparentMeshesAsManualOrder?renderPass.transparentMeshesAsManualOrder:renderPass.transparentMeshes;transparentMeshes.forEach(mesh=>{if(mesh.isVisible){mesh.draw({expression:expression,lights:lights,camera:camera,renderPass:renderPass,renderPassIndex:index,viewport:viewport,isWebVRMode:this.isWebVRMode,webvrFrameData:this.__webvrFrameData})}});const globalStatesUsageBackup=this._glBoostContext.globalStatesUsage;this._glBoostContext.globalStatesUsage=GLBoost.GLOBAL_STATES_USAGE_EXCLUSIVE;this._glBoostContext.currentGlobalStates=[3042];let gizmos=renderPass.gizmos;for(let gizmo of gizmos){if(gizmo.isVisible){gizmo.mesh.draw({expression:expression,lights:lights,camera:camera,renderPass:renderPass,renderPassIndex:index,viewport:viewport,isWebVRMode:this.isWebVRMode,webvrFrameData:this.__webvrFrameData})}}this._glBoostContext.globalStatesUsage=globalStatesUsageBackup;this._glBoostContext.restoreGlobalStatesToDefault();gl.bindFramebuffer(gl.FRAMEBUFFER,null);if(typeof effekseer!=="undefined"){effekseer.setProjectionMatrix(camera.projectionRHMatrix().m);effekseer.setCameraMatrix(camera.inverseWorldMatrix.m);effekseer.draw()}renderPass.postRender(camera?true:false,lights)})}_clearBuffer(gl,renderPass){const clearColor=renderPass.clearColor;const clearDepth=renderPass.clearDepth;const colorMask=renderPass.colorMask;if(clearColor){gl.clearColor(clearColor.x,clearColor.y,clearColor.z,clearColor.w)}if(clearDepth){gl.clearDepth(clearDepth)}if(colorMask){gl.colorMask.apply(null,[colorMask])}if(renderPass.buffersToDraw[0]===gl.NONE){{gl.clear(gl.DEPTH_BUFFER_BIT)}}else if(clearColor||clearDepth){gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT)}else if(clearColor){gl.clear(gl.COLOR_BUFFER_BIT)}}clearCanvas(color_flg,depth_flg,stencil_flg){var gl=this._glContext.gl;var bufferBits=0;if(color_flg===void 0||color_flg)bufferBits|=gl.COLOR_BUFFER_BIT;if(depth_flg===void 0||depth_flg)bufferBits|=gl.DEPTH_BUFFER_BIT;if(stencil_flg===void 0||stencil_flg)bufferBits|=gl.STENCIL_BUFFER_BIT;gl.clear(bufferBits)}get glContext(){return this._glContext.gl}resize(width,height){this._glContext.canvasWidth=width;this._glContext.canvasHeight=height}doRenderLoop(renderLoopFunc,...args){renderLoopFunc.apply(renderLoopFunc,args);this.__animationFrameId=this.__animationFrameObject.requestAnimationFrame(()=>{this.doRenderLoop(renderLoopFunc,...args);if(this.__requestedToEnterWebVR){this.__isWebVRMode=true}})}doConvenientRenderLoop(expression,beforeCallback,afterCallback,...args){if(beforeCallback){beforeCallback.apply(beforeCallback,args)}this.clearCanvas();this.update(expression);this.draw(expression);if(afterCallback){afterCallback.apply(afterCallback,args)}if(this.__webvrDisplay&&this.__webvrDisplay.isPresenting){this.__webvrDisplay.submitFrame()}this.__animationFrameId=this.__animationFrameObject.requestAnimationFrame(()=>{this.doConvenientRenderLoop(expression,beforeCallback,afterCallback,...args);if(this.__requestedToEnterWebVR){this.__isWebVRMode=true}})}stopRenderLoop(){this.__cancelAnimationFrame(this.__animationFrameId);this.__animationFrameId=-1}async enterWebVR(initialUserSittingPositionIfStageParametersDoNotExist){if(initialUserSittingPositionIfStageParametersDoNotExist){this.__defaultUserSittingPositionInVR=initialUserSittingPositionIfStageParametersDoNotExist}return new Promise((resolve,reject)=>{if(!this.__webvrDisplay.isPresenting){this.__webvrDisplay.requestPresent([{source:this._glContext.canvas}]).then(()=>{this.__animationFrameObject=this.__webvrDisplay;const leftEye=this.__webvrDisplay.getEyeParameters("left");const rightEye=this.__webvrDisplay.getEyeParameters("right");this.resize(Math.max(leftEye.renderWidth,rightEye.renderWidth)*2,Math.max(leftEye.renderHeight,rightEye.renderHeight));this.__requestedToEnterWebVR=true;resolve()}).catch(()=>{console.error("Failed to requestPresent. Please check your VR Setting, or something wrong with your VR system?");reject()})}})}async readyForWebVR(requestButtonDom){if(window.VRFrameData){this.__webvrFrameData=new window.VRFrameData}return new Promise((resolve,reject)=>{if(navigator.getVRDisplays){navigator.getVRDisplays().then(vrDisplays=>{if(vrDisplays.length>0){const webvrDisplay=vrDisplays[vrDisplays.length-1];webvrDisplay.depthNear=.01;webvrDisplay.depthFar=1e4;if(webvrDisplay.capabilities.canPresent){this.__webvrDisplay=webvrDisplay;if(requestButtonDom){requestButtonDom.style.display="block"}else{const paragrach=document.createElement("p");const anchor=document.createElement("a");anchor.setAttribute("id","enter-vr");const enterVr=document.createTextNode("Enter VR");anchor.appendChild(enterVr);paragrach.appendChild(anchor);const canvas=this.glContext.canvas;canvas.parent.insertBefore(paragrach,canvas);window.addEventListener("click",this.enterWebVR.bind(this))}this.__isReadyForWebVR=true;resolve()}else{console.error("Can't requestPresent now. try again.");reject()}}else{console.error("Failed to get VR Display. Please check your VR Setting, or something wrong with your VR system?");reject()}}).catch(()=>{console.error("Failed to get VR Displays. Please check your VR Setting.");reject()})}else{console.error("Your browser does not support WebVR. Or it is disabled. Check again.");reject()}})}async exitWebVR(){this.__isWebVRMode=false;if(this.__webvrDisplay&&this.__webvrDisplay.isPresenting){await this.__webvrDisplay.exitPresent()}this.__isReadyForWebVR=false;this.__animationFrameObject=window}async disableWebVR(){this.__isWebVRMode=false;this.__requestedToEnterWebVR=false;this.__isReadyForWebVR=false;if(this.__webvrDisplay&&this.__webvrDisplay.isPresenting){await this.__webvrDisplay.exitPresent()}this.__animationFrameObject=window;this.__webvrDisplay=null}get isWebVRMode(){return this.__isWebVRMode}get isReadyForWebVR(){return this.__isReadyForWebVR}webVrSubmitFrame(){if(this.__webvrDisplay&&this.__webvrDisplay.isPresenting){this.__webvrDisplay.submitFrame()}}}class M_Scene extends M_Group{constructor(glBoostContext){super(glBoostContext);this._gl=this._glContext.gl;this._reset()}_reset(){this._meshes=[];this._lights=[];this._lightsExceptAmbient=[];this._ambientLights=[];this._cameras=[];this._accumulatedAmbientIntensity=Vector4.zero()}_getCurrentAnimationInputValue(inputName){let value=this._currentAnimationInputValues[inputName];if(typeof value==="undefined"){return void 0}else{return value}}prepareToRender(expression){this._reset();var aabb=function setParentAndClearAccumulatedTransformMatriAndMergeAABBRecursively(elem){if(elem instanceof M_Group){elem._needUpdate();var children=elem.getChildren();for(let i=0;i{this._lights=this._lights.concat(collectLights(elm));this._lightsExceptAmbient=this._lights.filter(light=>{return!light.isTypeAmbient()});this._ambientLights=this._lights.filter(light=>{return light.isTypeAmbient()})});let existCamera_f=false;let collectCameras=function(elem){if(elem instanceof M_Group){var children=elem.getChildren();var cameras=[];children.forEach(function(child){var childCameras=collectCameras(child);cameras=cameras.concat(childCameras)});return cameras}else if(elem instanceof M_AbstractCamera){existCamera_f=true;return[elem]}else{return[]}};this._cameras=[];this._elements.forEach(elm=>{this._cameras=this._cameras.concat(collectCameras(elm))});if(this._cameras.length===0);else if(this._cameras.length===1){this._cameras[0].setAsMainCamera(this)}else{let isNotMainCameraFound=true;for(let camera of this._cameras){if(camera.isMainCamera(this)){isNotMainCameraFound=false;break}}if(isNotMainCameraFound){this._cameras[0].setAsMainCamera(this)}}let collectMeshes=function(elem){if(elem instanceof M_Group){var children=elem.getChildren();var meshes=[];children.forEach(function(child){var childMeshes=collectMeshes(child);meshes=meshes.concat(childMeshes)});return meshes}else if(elem instanceof M_Mesh){return[elem]}else{return[]}};this._meshes=[];this._elements.forEach(elm=>{this._meshes=this._meshes.concat(collectMeshes(elm))});let callPrepareToRenderMethodOfAllElements=elem=>{if(elem instanceof M_Group){var children=elem.getChildren();children.forEach(function(child){callPrepareToRenderMethodOfAllElements(child)});for(let gizmo of elem._gizmos){gizmo.mesh.prepareToRender(expression,existCamera_f,[])}}else if(elem instanceof M_Mesh){elem.prepareToRender(expression,existCamera_f,this._lights);for(let gizmo of elem._gizmos){gizmo.mesh.prepareToRender(expression,existCamera_f,this._lights)}}else if(elem instanceof M_Element){elem.prepareToRender();for(let gizmo of elem._gizmos){gizmo.mesh.prepareToRender(expression,existCamera_f,[])}}else{return}};callPrepareToRenderMethodOfAllElements(this)}getMainCamera(renderPass){var camera=null;this.cameras.forEach(elm=>{if(elm.isMainCamera(this)){camera=elm}});return camera}get lightsExceptAmbient(){return this._lightsExceptAmbient}updateAmountOfAmbientLightsIntensity(){this._accumulatedAmbientIntensity=Vector4.zero();for(let light of this._ambientLights){this._accumulatedAmbientIntensity.add(light.intensity)}}getAmountOfAmbientLightsIntensity(){return this._accumulatedAmbientIntensity.clone()}getChildren(){return this._elements}get elements(){return this._elements}get meshes(){return this._meshes}get lights(){return this._lights}get lightsExceptAmbient(){return this._lightsExceptAmbient}get cameras(){return this._cameras}}class M_Gizmo extends M_Group{constructor(glBoostContext){super(glBoostContext,null,null);this._mesh=null}get mesh(){return this._mesh}}class JointPrimitive extends Geometry{constructor(glBoostContext,length,lineCount=1){super(glBoostContext);this._colors=[];this.color=new Vector4(1,1,1,1);this._worldPositionOfThisJoint=new Vector3(0,0,1);this._worldPositionOfParentJoint=new Vector3(0,0,0);this._vertexData=this._setupVertexData();this.setVerticesData(this._vertexData,null,GLBoost$1.LINES);this._width=1}_setupVertexData(){let length=Vector3.lengthBtw(this._worldPositionOfThisJoint,this._worldPositionOfParentJoint);let arrowWidth=this._width;let arrowheadLength=length/7.5;let arrowStickLength=length-arrowheadLength;let positions=[];let deltaVec=Vector3.subtract(this._worldPositionOfParentJoint,this._worldPositionOfThisJoint);let directionToParent=new Vector3(0,1,0);if(!deltaVec.isEqual(Vector3.zero())){directionToParent=Vector3.subtract(this._worldPositionOfParentJoint,this._worldPositionOfThisJoint).normalize()}const arrowStickPosition=Vector3.add(this._worldPositionOfThisJoint,Vector3.multiply(directionToParent,arrowStickLength));let dummyVector=new Vector3(0,1,0);let dummyVector2=new Vector3(0,-1,0);if(Math.abs(Vector3.dotProduct(directionToParent,dummyVector))>.4){dummyVector=new Vector3(1,0,0);dummyVector2=new Vector3(-1,0,0)}if(Math.abs(Vector3.dotProduct(directionToParent,dummyVector))>.4){dummyVector=new Vector3(0,0,1);dummyVector2=new Vector3(0,0,-1)}const crossVector=Vector3.multiply(Vector3.cross(directionToParent,dummyVector).normalize(),arrowWidth);const crossVector2=Vector3.multiply(Vector3.cross(directionToParent,crossVector).normalize(),arrowWidth);const crossVector3=Vector3.multiply(Vector3.cross(directionToParent,dummyVector2).normalize(),arrowWidth);const crossVector4=Vector3.multiply(Vector3.cross(directionToParent,crossVector3).normalize(),arrowWidth);const crossPosition=Vector3.add(arrowStickPosition,crossVector);const crossPosition2=Vector3.add(arrowStickPosition,crossVector2);const crossPosition3=Vector3.add(arrowStickPosition,crossVector3);const crossPosition4=Vector3.add(arrowStickPosition,crossVector4);positions.push(this._worldPositionOfThisJoint);positions.push(crossPosition);positions.push(this._worldPositionOfThisJoint);positions.push(crossPosition2);positions.push(this._worldPositionOfThisJoint);positions.push(crossPosition3);positions.push(this._worldPositionOfThisJoint);positions.push(crossPosition4);positions.push(crossPosition);positions.push(crossPosition2);positions.push(crossPosition2);positions.push(crossPosition3);positions.push(crossPosition3);positions.push(crossPosition4);positions.push(crossPosition4);positions.push(crossPosition);positions.push(this._worldPositionOfParentJoint);positions.push(crossPosition);positions.push(this._worldPositionOfParentJoint);positions.push(crossPosition2);positions.push(this._worldPositionOfParentJoint);positions.push(crossPosition3);positions.push(this._worldPositionOfParentJoint);positions.push(crossPosition4);this._vertexData={position:positions,color:this._colors};return this._vertexData}set worldPositionOfThisJoint(vec){this._worldPositionOfThisJoint=vec}get worldPositionOfThisJoint(){return this._worldPositionOfThisJoint}set worldPositionOfParentJoint(vec){this._worldPositionOfParentJoint=vec}get worldPositionOfParentJoint(){return this._worldPositionOfParentJoint}set width(value){this._width=value}get width(){return this._width}set color(vec){this._color=vec;this._colors=[];for(let i=0;i<24;i++){this._colors.push(this._color)}}get color(){return this._color}update(){this._vertexData=this._setupVertexData();this.updateVerticesData(this._vertexData,true)}set meshContainingSelf(jointGizmoMesh){this._mesh=jointGizmoMesh}}GLBoost$1["JointPrimitive"]=JointPrimitive;class M_JointGizmo extends M_Gizmo{constructor(glBoostContext,joint,length){super(glBoostContext,null,null);this._init(glBoostContext,joint,length);this.isVisible=false;this.baseColor=new Vector4(0,1,1,.25)}_init(glBoostContext,joint,length){this._joint=joint;this._primitive=new JointPrimitive(this._glBoostContext,length,1);this._mesh=new M_Mesh(glBoostContext,this._primitive,null);this._mesh.masterElement=this;this.addChild(this._mesh)}set baseColor(colorVec){this._primitive.color=colorVec}get baseColor(){return this._primitive.color}get worldMatrixInner(){return Matrix44$2.identity()}set worldPositionOfThisJoint(vec3){this._primitive.worldPositionOfThisJoint=vec3}get worldPositionOfThisJoint(){return this._primitive.worldPositionOfThisJoint}set worldPositionOfParentJoint(vec3){this._primitive.worldPositionOfParentJoint=vec3}get worldPositionOfParentJoint(){return this._primitive.worldPositionOfParentJoint}set width(value){this._primitive.width=value}get width(){return this._primitive.width}update(){this._primitive.update()}set isVisible(flag){this._mesh.isVisible=flag}get isVisible(){return this._mesh.isVisible}}GLBoost$1["M_JointGizmo"]=M_JointGizmo;class M_Joint extends M_Element{constructor(glBoostContext,isExistJointGizmo=false){super(glBoostContext);if(isExistJointGizmo){this._gizmo=new M_JointGizmo(glBoostContext,this,length);this._gizmos.push(this._gizmo)}else{this._gizmo={}}M_Joint._calculatedTransforms={};M_Joint._calculatedTranslates={};this._childJoints=[];this._jointsOfParentHierarchies=[];this.length=new Vector3(length,length,length);this._isCalculatedJointGizmo=false;this._jointPoseMatrix=Matrix44$2.identity();this._length=1;this._inverseBindMatrix=Matrix44$2.identity();this._skeletalMesh=null}set inverseBindMatrix(mat4){this._inverseBindMatrix=mat4}get inverseBindMatrix(){return this._inverseBindMatrix}set skeletalMesh(skeletalMesh){this._skeletalMesh=skeletalMesh}get skeletalMesh(){return this._skeletalMesh}set worldPositionOfThisJoint(vec){this._gizmo.worldPositionOfThisJoint=vec}get worldPositionOfThisJoint(){return this._gizmo.worldPositionOfThisJoint}set worldPositionOfParentJoint(vec){this._gizmo.worldPositionOfParentJoint=vec}get worldPositionOfParentJoint(){return this._gizmo.worldPositionOfParentJoint}set width(value){this._gizmo.width=value}get width(){return this._gizmo.width}set jointPoseMatrix(matrix){this._jointPoseMatrix=matrix}get jointPoseMatrix(){return this._jointPoseMatrix}clearIsCalculatedLengthFlag(){this._isCalculatedJointGizmo=false}get isCalculatedJointGizmo(){return this._isCalculatedJointGizmo}set isVisible(flg){this._gizmo.isVisible=flg}get isVisible(){return this._gizmo.isVisible}set childJoints(joints){this._childJoints=joints}get childJoints(){return this._childJoints}set jointsOfParentHierarchies(joints){this._jointsOfParentHierarchies=joints}get jointsOfParentHierarchies(){return this._jointsOfParentHierarchies}updateGizmoDisplay(){this._gizmo.update()}clone(){let instance=new M_Joint(this._glBoostContext);this._copy(instance);return instance}_copy(instance){super._copy(instance)}}GLBoost$1["M_Joint"]=M_Joint;class M_SkeletalMesh extends M_Mesh{constructor(glBoostContext,geometry,material,rootJointName){super(glBoostContext,geometry,material,rootJointName);this._rootJointName=rootJointName;this._jointsHierarchy=null;this._inverseBindMatrices=[];this._bindShapeMatrix=Matrix44$2.identity();this._jointNames=[];this._gltfJointIndices=[];this._joints=[];this._jointMatrices=null;this._qArray=null;this._tArray=null;this._qtArray=null;this._translationScale=0}prepareToRender(expression,existCamera_f,lights,renderPasses){let joints=this.jointsHierarchy.searchElementsByType(M_Joint);this._joints=[];let jointCount=0;for(let i=0;i{let children=joint.parent.parent.getChildren();let parentJoint=null;for(let i=0;i0){const rootJointMatrix=this._joints[0].worldMatrix;let rootJointPosWorld=rootJointMatrix.multiplyVector(Vector4.zero()).toVector3();return rootJointPosWorld}return Vector3.zero()}getRootJointsWorldPositionAt(inputValue){if(this._joints.length>0){const rootJointMatrix=this._joints[0].getWorldMatrixAt(inputValue);let rootJointPosWorld=rootJointMatrix.multiplyVector(Vector4.zero()).toVector3();return rootJointPosWorld}return Vector3.zero()}}GLBoost$1["M_SkeletalMesh"]=M_SkeletalMesh;class M_SkeletalGeometry extends Geometry{constructor(glBoostContext){super(glBoostContext);this._skeletalShaderSpecified=null;this._skeletalShaderNormal=null}update(skeletalMesh){var joints=skeletalMesh._joints;var matrices=[];let areThereAnyJointsWhichHaveAnimation=false;if(joints[0].parent._getCurrentAnimationInputValue(joints[0].parent._activeAnimationLineName)!==null){areThereAnyJointsWhichHaveAnimation=true}let input=joints[0]._getCurrentAnimationInputValue("time");let jointZeroWorldMatrix=null;let skeletalMeshWorldMatrix=null;let skeletalMeshTransformMatrixAccmulatedAncestry=skeletalMesh.getWorldMatrixAt(input);let inverseSkeletalMeshTransformMatrixAccmulatedAncestry=Matrix44$2.invert(skeletalMeshTransformMatrixAccmulatedAncestry);for(let i=joints.length-1;i>=0;i--){let globalJointTransform=null;let inverseBindMatrix=joints[i].inverseBindMatrix;if(areThereAnyJointsWhichHaveAnimation){globalJointTransform=joints[i].getWorldMatrixAt(input);skeletalMeshWorldMatrix=globalJointTransform}else{globalJointTransform=skeletalMeshTransformMatrixAccmulatedAncestry;skeletalMeshWorldMatrix=globalJointTransform;let bindMat=joints[i].bindMatrix;globalJointTransform=Matrix44$2.multiply(skeletalMeshWorldMatrix,bindMat)}if(i===0){jointZeroWorldMatrix=globalJointTransform}if(this._materialForSkeletals[0].shaderInstance.constructor===FreeShader){matrices[i]=inverseSkeletalMeshTransformMatrixAccmulatedAncestry}else{matrices[i]=Matrix44$2.identity()}matrices[i]=Matrix44$2.multiply(matrices[i],globalJointTransform);joints[i].jointPoseMatrix=Matrix44$2.multiply(Matrix44$2.identity(),globalJointTransform);matrices[i]=Matrix44$2.multiply(matrices[i],inverseBindMatrix);matrices[i]=Matrix44$2.multiply(matrices[i],skeletalMesh.bindShapeMatrix)}GLBoost$1.JointGizmoUpdater.update(joints,jointZeroWorldMatrix);if(!GLBoost$1.VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL){let flatMatrices=[];for(let i=0;i1){{skeletalMesh._qtArray=new Float32Array(matrices.length*4);let tXArray=[];let tYArray=[];let tZArray=[];for(let i=0;i1){Shader.trySettingVec4ArrayToUniform(gl,glslProgram,material,material._semanticsDic,"JOINT_QUATTRANSLATION",skeletalMesh._qtArray);this._glContext.uniform3f(material.getUniform(glslProgram,"uniform_translationScale"),skeletalMesh._translationScale.x,skeletalMesh._translationScale.y,skeletalMesh._translationScale.z,true)}}prepareToRender(expression,existCamera_f,pointLight,meshMaterial,skeletalMesh,shaderClassSpecified=void 0,argMaterials=void 0){if(argMaterials!==void 0){this._materialForSkeletals=argMaterials}else{if(this._materials.length>0){this._materialForSkeletals=this._materials}else if(meshMaterial){this._materialForSkeletals=[meshMaterial]}else{this._materialForSkeletals=[this._defaultMaterial]}}let derrivedClass=null;if(!(this._materialForSkeletals[0].shaderInstance&&this._materialForSkeletals[0].shaderInstance.constructor===FreeShader)){let baseClass=null;if(shaderClassSpecified){baseClass=shaderClassSpecified;class SkeletalShader extends baseClass{constructor(glBoostContext,basicShader){super(glBoostContext,basicShader);SkeletalShader.mixin(SkeletalShaderSource)}}derrivedClass=SkeletalShader;this._skeletalShaderSpecified=derrivedClass}else{for(let materialForSkeletal of this._materialForSkeletals){baseClass=materialForSkeletal.shaderClass;class SkeletalShader extends baseClass{constructor(glBoostContext,basicShader){super(glBoostContext,basicShader);SkeletalShader.mixin(SkeletalShaderSource)}}derrivedClass=SkeletalShader}this._skeletalShaderNormal=derrivedClass}for(let i=0;i{this.__effect=effekseer.loadEffect(uri,()=>{if(playJustAfterLoaded){this.play()}resolve(this.__effect)})})}play(){this.__handle=effekseer.play(this.__effect);this.__handle.setLocation(this.translate.x,this.translate.y,this.translate.z);this.__handle.setRotation(this.rotate.x,this.rotate.y,this.rotate.z);this.__handle.setScale(this.scale.x,this.scale.y,this.scale.z);this.__handle.setSpeed(this.__speed)}set playSpeed(val){if(this.__handle){this.__handle.setSpeed(val)}this.__speed=val}get playSpeed(){return this.__speed}set translate(vec){if(this.__handle){this.__handle.setLocation(vec.x,vec.y,vec.z)}super.translate=vec}get translate(){return super.translate}set rotate(vec){if(this.__handle){this.__handle.setRotation(vec.x,vec.y,vec.z)}super.rotate=vec}get rotate(){return super.rotate}set scale(vec){if(this.__handle){this.__handle.setScale(vec.x,vec.y,vec.z)}super.scale=vec}get scale(){return super.scale}}class M_ScreenMesh extends M_Mesh{constructor(glBoostContext,customVertexAttributes){super(glBoostContext,null,null);this._init(customVertexAttributes)}_init(customVertexAttributes){let gl=this._glContext.gl;this.geometry=new Screen(this._glBoostContext,void 0,customVertexAttributes);this.isAffectedByWorldMatrix=false;this.isAffectedByViewMatrix=false;this.isAffectedByProjectionMatrix=false;let material=new ClassicMaterial$1(this._glBoostContext);material.globalStatesUsage=GLBoost.GLOBAL_STATES_USAGE_IGNORE;material.states={enable:[gl.BLEND],functions:{blendFuncSeparate:[770,771,1,1]}};this.geometry.materials=[material];this._material=material}set material(obj){this._material=obj;this.geometry.materials=[obj]}get material(){return this._material}}GLBoost["M_ScreenMesh"]=M_ScreenMesh;class GLBoostMiddleContext extends GLBoostLowContext{constructor(canvas,initParameter,gl,width,height){super(canvas,initParameter,gl,width,height);this._glBoostMonitor=M_GLBoostMonitor.getInstance()}createScene(){return new M_Scene(this)}createGroup(){return new M_Group(this)}createMesh(geometry,material){return new M_Mesh(this,geometry,material)}createSkeletalMesh(geometry,material,rootJointName){return new M_SkeletalMesh(this,geometry,material,rootJointName)}createSkeletalGeometry(){return new M_SkeletalGeometry(this)}createRenderer(parameters){return new Renderer(this,parameters)}createExpression(){return this.createExpressionAndRenderPasses(1)}createExpressionAndRenderPasses(number){var expression=new Expression(this);var renderPasses=this.createRenderPasses(number);expression.addRenderPasses(renderPasses);return expression}createRenderPasses(number){var renderPasses=[];for(let i=0;i{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform highp ${sampler2D} uDepthTexture[${lightNumExceptAmbient}];\n`;shaderText+=`${in_} vec4 v_shadowCoord[${lightNumExceptAmbient}];\n`;shaderText+=`uniform int isShadowCasting[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_PhongShaderSource(f,gl,lights){var shaderText="";shaderText+=" float depthBias = 0.005;\n";shaderText+=" vec4 surfaceColor = rt0;\n";shaderText+=" rt0 = vec4(0.0, 0.0, 0.0, 0.0);\n";for(let i=0;i{let gotText=responseText;let partsOfPath=url.split("/");let basePath="";for(let i=0;i{})}_loadMaterialsFromString(glBoostContext,mtlString,defaultShader,basePath="",resolve){var mtlTextRows=mtlString.split("\n");var numMaterial=0;for(let i=0;i{resolve(materials)})}_loadMaterialsFromFile(glBoostContext,basePath,fileName,defaultShader){return DataUtil.loadResourceAsync(basePath+fileName,false,(resolve,responseText)=>{this._loadMaterialsFromString(glBoostContext,responseText,defaultShader,basePath,resolve)},(reject,err)=>{})}_constructMesh(glBoostContext,objText,basePath,defaultShader,mtlString,resolve){var objTextRows=objText.split("\n");var promise=null;let vCount=0;let fCount=0;let vnCount=0;let vtCount=0;if(mtlString){promise=(()=>{return new Promise((resolve,reject)=>{this._loadMaterialsFromString(glBoostContext,mtlString,defaultShader,"",resolve)})})()}for(let i=0;i{for(let i=0;i{if(isFinite(glboostConstant_or_glboostConstantValueName)){let glboostConstant=glboostConstant_or_glboostConstantValueName;let glboostConstantName=GLBoost$1.getNameOfGLBoostConstant(glboostConstant);if(glboostConstantName){let glboostConstantValueName="VALUE_"+glboostConstantName;Object.defineProperty(GLBoost$1,glboostConstantValueName,{get:function(){return this.valueOfGLBoostConstants[glboostConstant]},set:function(flg){this.valueOfGLBoostConstants[glboostConstant]=flg}});GLBoost$1[glboostConstantValueName]=value}}else{let glboostConstantValueName=glboostConstant_or_glboostConstantValueName;GLBoost$1[glboostConstantValueName]=value}};let define=defineValueOfGLBoostConstants;define("VALUE_TARGET_WEBGL_VERSION",1);define("VALUE_SKELETAL_SHADER_OPITIMIZATION_LEVEL",0);define("VALUE_DEFAULT_POINTLIGHT_INTENSITY",new Vector3(1,1,1));define("VALUE_ANGLE_UNIT",GLBoost$1.DEGREE);define("VALUE_WEBGL_ONE_USE_EXTENSIONS",true);define("VALUE_CONSOLE_OUT_FOR_DEBUGGING",false);define(GLBoost$1.LOG_GENERAL,true);define(GLBoost$1.LOG_SHADER_CODE,true);define(GLBoost$1.LOG_GLBOOST_OBJECT_LIFECYCLE,true);define(GLBoost$1.LOG_GL_RESOURCE_LIFECYCLE,true);define(GLBoost$1.LOG_GL_ERROR,true);define(GLBoost$1.LOG_OMISSION_PROCESSING,false)})();class LambertShaderSource{FSDefine_LambertShaderSource(in_,f,lights){var sampler2D=this._sampler2DShadow_func();var shaderText="";shaderText+="uniform vec4 Kd;\n";shaderText+="uniform vec4 ambient;\n";let lightNumExceptAmbient=lights.filter(light=>{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform highp ${sampler2D} uDepthTexture[${lightNumExceptAmbient}];\n`;shaderText+=`uniform int isShadowCasting[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_LambertShaderSource(f,gl,lights){var shaderText="";shaderText+=" vec4 surfaceColor = rt0;\n";shaderText+=" rt0 = vec4(0.0, 0.0, 0.0, 0.0);\n";for(let i=0;i{this.checkArrayBufferOfGltf(options.files[fileName],null,options,defaultOptions,glBoostContext,resolve)},(reject,error)=>{})}}}return DataUtil.loadResourceAsync(url,true,(resolve,response)=>{var arrayBuffer=response;this.checkArrayBufferOfGltf(arrayBuffer,url,options,defaultOptions,glBoostContext,resolve)},(reject,error)=>{})}checkArrayBufferOfGltf(arrayBuffer,url,options,defaultOptions,glBoostContext,resolve){let dataView=new DataView(arrayBuffer,0,20);let isLittleEndian=true;let magicStr="";magicStr+=String.fromCharCode(dataView.getUint8(0,isLittleEndian));magicStr+=String.fromCharCode(dataView.getUint8(1,isLittleEndian));magicStr+=String.fromCharCode(dataView.getUint8(2,isLittleEndian));magicStr+=String.fromCharCode(dataView.getUint8(3,isLittleEndian));if(magicStr!=="glTF"){this.loadAsTextJson(arrayBuffer,url,options,defaultOptions,glBoostContext,resolve)}else{this.loadAsBinaryJson(dataView,isLittleEndian,arrayBuffer,options,defaultOptions,glBoostContext,resolve)}}loadAsBinaryJson(dataView,isLittleEndian,arrayBuffer,options,defaultOptions,glBoostContext,resolve){let gltfVer=dataView.getUint32(4,isLittleEndian);if(gltfVer!==1){reject("invalid version field in this binary glTF file.")}let lengthOfThisFile=dataView.getUint32(8,isLittleEndian);let lengthOfContent=dataView.getUint32(12,isLittleEndian);let contentFormat=dataView.getUint32(16,isLittleEndian);if(contentFormat!==0){reject("invalid contentFormat field in this binary glTF file.")}let arrayBufferContent=arrayBuffer.slice(20,lengthOfContent+20);let gotText=DataUtil.arrayBufferToString(arrayBufferContent);let json=JSON.parse(gotText);let arrayBufferBinary=arrayBuffer.slice(20+lengthOfContent);let glTFVer=this._checkGLTFVersion(json);options=this.getOptions(defaultOptions,json,options);const defaultShader=this.getDefaultShader(options);this._loadResourcesAndScene(glBoostContext,arrayBufferBinary,null,json,defaultShader,glTFVer,resolve,options);return{options:options,defaultShader:defaultShader}}loadAsTextJson(arrayBuffer,url,options,defaultOptions,glBoostContext,resolve){let gotText=DataUtil.arrayBufferToString(arrayBuffer);let basePath="";if(url){let partsOfPath=url.split("/");for(let i=0;i{let arrayBuffer=DataUtil.base64ToArrayBuffer(shaderUri);shaders[shaderName].shaderText=DataUtil.arrayBufferToString(arrayBuffer);shaders[shaderName].shaderType=shaderType;fulfilled()}))}else{shaderUri=basePath+shaderUri;promisesToLoadResources.push(DataUtil.loadResourceAsync(shaderUri,false,(resolve,response)=>{shaders[shaderName].shaderText=response;shaders[shaderName].shaderType=shaderType;resolve()},(reject,error)=>{}))}}for(let bufferName in json.buffers){let bufferInfo=json.buffers[bufferName];const splitted=bufferInfo.uri.split("/");const filename=splitted[splitted.length-1];if(bufferInfo.uri.match(/^data:application\/octet-stream;base64,/)){promisesToLoadResources.push(new Promise((fulfilled,rejected)=>{let arrayBuffer=DataUtil.base64ToArrayBuffer(bufferInfo.uri);buffers[bufferName]=arrayBuffer;fulfilled()}))}else if(bufferInfo.uri==="data:,"){buffers[bufferName]=arrayBufferBinary}else if(options.files&&options.files[filename]){const arrayBuffer=options.files[filename];buffers[bufferName]=arrayBuffer}else{promisesToLoadResources.push(DataUtil.loadResourceAsync(basePath+bufferInfo.uri,true,(resolve,response)=>{buffers[bufferName]=response;resolve()},(reject,error)=>{}))}}for(let textureName in json.textures){let textureJson=json.textures[textureName];let imageJson=json.images[textureJson.source];let samplerJson=json.samplers[textureJson.sampler];let textureUri=null;if(typeof imageJson.extensions!=="undefined"&&typeof imageJson.extensions.KHR_binary_glTF!=="undefined"){textureUri=this._accessBinaryAsImage(imageJson.extensions.KHR_binary_glTF.bufferView,json,arrayBufferBinary,imageJson.extensions.KHR_binary_glTF.mimeType)}else{let imageFileStr=imageJson.uri;const splitted=imageFileStr.split("/");const filename=splitted[splitted.length-1];if(options.files&&options.files[filename]){const arrayBuffer=options.files[filename];const splitted=filename.split(".");const fileExtension=splitted[splitted.length-1];textureUri=this._accessArrayBufferAsImage(arrayBuffer,fileExtension)}else if(imageFileStr.match(/^data:/)){textureUri=imageFileStr}else{textureUri=basePath+imageFileStr}}let texture=glBoostContext.createTexture(null,textureName,{TEXTURE_MAG_FILTER:samplerJson.magFilter,TEXTURE_MIN_FILTER:samplerJson.minFilter,TEXTURE_WRAP_S:samplerJson.wrapS,TEXTURE_WRAP_T:samplerJson.wrapT});if(options.loaderExtension&&options.loaderExtension.setUVTransformToTexture){options.loaderExtension.setUVTransformToTexture(texture,samplerJson)}let promise=texture.generateTextureFromUri(textureUri,false);textures[textureName]=texture;promisesToLoadResources.push(promise)}if(promisesToLoadResources.length>0){Promise.resolve().then(()=>{return Promise.all(promisesToLoadResources)}).then(()=>{this._IterateNodeOfScene(glBoostContext,buffers,json,defaultShader,shaders,textures,glTFVer,resolve,options)})}else{this._IterateNodeOfScene(glBoostContext,buffers,json,defaultShader,shaders,textures,glTFVer,resolve,options)}}_IterateNodeOfScene(glBoostContext,buffers,json,defaultShader,shaders,textures,glTFVer,resolve,options){let rootGroup=glBoostContext.createGroup();rootGroup.userFlavorName="glTFFileRoot";for(let sceneStr in json.scenes){let sceneJson=json.scenes[sceneStr];let group=glBoostContext.createGroup();group.userFlavorName="Scene_"+sceneStr;let nodeStr=null;for(let i=0;i{let rootJointGroup=group.searchElementByNameAndType(skeletalMesh.rootJointName,M_Group);if(!rootJointGroup){rootJointGroup=this._recursiveIterateNode(glBoostContext,skeletalMesh.rootJointName,buffers,json,defaultShader,shaders,textures,glTFVer,options);group.addChild(rootJointGroup)}rootJointGroup._isRootJointGroup=true;skeletalMesh.jointsHierarchy=rootJointGroup});this._loadAnimation(group,buffers,json,glTFVer,options);if(options&&options.loaderExtension&&options.loaderExtension.setAssetPropertiesToRootGroup){options.loaderExtension.setAssetPropertiesToRootGroup(rootGroup,json.asset)}rootGroup.addChild(group)}resolve(rootGroup)}_setTransform(element,nodeJson){if(nodeJson.translation){element.translate=new Vector3(nodeJson.translation[0],nodeJson.translation[1],nodeJson.translation[2])}if(nodeJson.scale){element.scale=new Vector3(nodeJson.scale[0],nodeJson.scale[1],nodeJson.scale[2])}if(nodeJson.rotation){element.quaternion=new Quaternion(nodeJson.rotation[0],nodeJson.rotation[1],nodeJson.rotation[2],nodeJson.rotation[3])}if(nodeJson.matrix){element.matrix=new Matrix44$2(nodeJson.matrix,true)}}_recursiveIterateNode(glBoostContext,nodeStr,buffers,json,defaultShader,shaders,textures,glTFVer,options){var nodeJson=json.nodes[nodeStr];var group=glBoostContext.createGroup();group.userFlavorName=nodeStr;this._setTransform(group,nodeJson);if(nodeJson.meshes){for(let i=0;i1){let lengthDic={index:0,position:0,normal:0,joint:0,weight:0,texcoord:0};for(let i=0;i{for(let valueName in values){let value=null;if(isParameter){value=values[valueName].value;if(typeof value==="undefined"){continue}}else{value=values[valueName]}if(glTFVer>=1.1){value=value[0]}if(typeof value==="string"){let textureStr=value;let texturePurpose;if(valueName==="diffuse"||materialJson.technique==="CONSTANT"&&valueName==="ambient"){texturePurpose=GLBoost$1.TEXTURE_PURPOSE_DIFFUSE}let texture=textures[textureStr];let isNeededToMultiplyAlphaToColorOfTexture=false;if(options.isNeededToMultiplyAlphaToColorOfPixelOutput){if(options.isTextureImageToLoadPreMultipliedAlphaAsDefault);else{isNeededToMultiplyAlphaToColorOfTexture=true}}else{if(options.isTextureImageToLoadPreMultipliedAlphaAsDefault);}if(options&&options.statesOfElements){for(let statesInfo of options.statesOfElements){if(statesInfo.targets){for(let target of statesInfo.targets){let isMatch=false;let specifyMethod=statesInfo.specifyMethod!==void 0?statesInfo.specifyMethod:GLBoost$1.QUERY_TYPE_USER_FLAVOR_NAME;switch(specifyMethod){case GLBoost$1.QUERY_TYPE_USER_FLAVOR_NAME:isMatch=group.userFlavorName===target;break;case GLBoost$1.QUERY_TYPE_INSTANCE_NAME:isMatch=group.instanceName===target;break;case GLBoost$1.QUERY_TYPE_INSTANCE_NAME_WITH_USER_FLAVOR:isMatch=group.instanceNameWithUserFlavor===target;break}if(isMatch){if(options.isNeededToMultiplyAlphaToColorOfPixelOutput){if(statesInfo.isTextureImageToLoadPreMultipliedAlpha);else{isNeededToMultiplyAlphaToColorOfTexture=true}}else{if(statesInfo.isTextureImageToLoadPreMultipliedAlpha);}}}}}}material.setTexture(texture,texturePurpose);texture.toMultiplyAlphaToColorPreviously=isNeededToMultiplyAlphaToColorOfTexture}}};setTextures(materialJson.values,false);if(materialJson.technique&&json.techniques){if(typeof json.techniques[materialJson.technique]!=="undefined"){setTextures(json.techniques[materialJson.technique].parameters,true)}}}else{if(typeof vertexData.components.texcoord!=="undefined"){let emptyTexcoords=[];let componentN=vertexData.components.position;let length=positions.length/componentN;for(let k=0;k{this._checkArrayBufferOfGltf(options.files[fileName],null,options,defaultOptions,resolve)},(reject,error)=>{})}}}return DataUtil.loadResourceAsync(uri,true,(resolve,response)=>{var arrayBuffer=response;this._checkArrayBufferOfGltf(arrayBuffer,uri,options,defaultOptions,resolve)},(reject,error)=>{})}_checkArrayBufferOfGltf(arrayBuffer,uri,options,defaultOptions,resolve){this._materials=[];let dataView=new DataView(arrayBuffer,0,20);let isLittleEndian=true;let magic=dataView.getUint32(0,isLittleEndian);if(magic!==1179937895){this._loadAsTextJson(arrayBuffer,uri,options,defaultOptions,resolve)}else{this._loadAsBinaryJson(dataView,uri,isLittleEndian,arrayBuffer,options,defaultOptions,resolve)}}_loadAsBinaryJson(dataView,uri,isLittleEndian,arrayBuffer,options,defaultOptions,resolve){let gltfVer=dataView.getUint32(4,isLittleEndian);if(gltfVer!==2){reject("invalid version field in this binary glTF file.")}let lengthOfThisFile=dataView.getUint32(8,isLittleEndian);let lengthOfJSonChunkData=dataView.getUint32(12,isLittleEndian);let chunkType=dataView.getUint32(16,isLittleEndian);if(chunkType!==1313821514){reject("invalid chunkType of chunk0 in this binary glTF file.")}let arrayBufferJSonContent=arrayBuffer.slice(20,20+lengthOfJSonChunkData);let gotText=DataUtil.arrayBufferToString(arrayBufferJSonContent);let gltfJson=JSON.parse(gotText);options=this._getOptions(defaultOptions,gltfJson,options);let arrayBufferBinary=arrayBuffer.slice(20+lengthOfJSonChunkData+8);let basePath=null;if(uri){basePath=uri.substring(0,uri.lastIndexOf("/"))+"/"}let promise=this._loadInner(arrayBufferBinary,basePath,gltfJson,options);promise.then(gltfJson=>{console.log("Resoureces loading done!");resolve(gltfJson[0][0])})}_loadAsTextJson(arrayBuffer,uri,options,defaultOptions,resolve){let gotText=DataUtil.arrayBufferToString(arrayBuffer);let basePath=null;if(uri){basePath=uri.substring(0,uri.lastIndexOf("/"))+"/"}let gltfJson=JSON.parse(gotText);options=this._getOptions(defaultOptions,gltfJson,options);let promise=this._loadInner(null,basePath,gltfJson,options);promise.then(gltfJson=>{console.log("Resoureces loading done!");resolve(gltfJson[0][0])})}_loadInner(arrayBufferBinary,basePath,gltfJson,options){let promises=[];let resources={shaders:[],buffers:[],images:[]};promises.push(this._loadResources(arrayBufferBinary,basePath,gltfJson,options,resources));promises.push(new Promise((resolve,reject)=>{this._loadJsonContent(gltfJson,resources,options);resolve()}));return Promise.all(promises)}_loadJsonContent(gltfJson,resources,options){this._loadDependenciesOfScenes(gltfJson);this._loadDependenciesOfNodes(gltfJson);this._loadDependenciesOfMeshes(gltfJson);this._loadDependenciesOfMaterials(gltfJson);this._loadDependenciesOfTextures(gltfJson);this._loadDependenciesOfJoints(gltfJson);this._loadDependenciesOfAnimations(gltfJson);this._loadDependenciesOfAccessors(gltfJson);this._loadDependenciesOfBufferViews(gltfJson);if(gltfJson.asset===void 0){gltfJson.asset={}}if(gltfJson.asset.extras===void 0){gltfJson.asset.extras={}}gltfJson.asset.extras.glboostOptions=options}_loadDependenciesOfScenes(gltfJson){for(let scene of gltfJson.scenes){scene.nodesIndices=scene.nodes.concat();for(let i in scene.nodesIndices){scene.nodes[i]=gltfJson.nodes[scene.nodesIndices[i]]}}}_loadDependenciesOfNodes(gltfJson){for(let node of gltfJson.nodes){if(node.children){node.childrenIndices=node.children.concat();node.children=[];for(let i in node.childrenIndices){node.children[i]=gltfJson.nodes[node.childrenIndices[i]]}}if(node.mesh!==void 0&&gltfJson.meshes!==void 0){node.meshIndex=node.mesh;node.mesh=gltfJson.meshes[node.meshIndex]}if(node.skin!==void 0&&gltfJson.skins!==void 0){node.skinIndex=node.skin;node.skin=gltfJson.skins[node.skinIndex];if(node.mesh.extras===void 0){node.mesh.extras={}}node.mesh.extras._skin=node.skin}if(node.camera!==void 0&&gltfJson.cameras!==void 0){node.cameraIndex=node.camera;node.camera=gltfJson.cameras[node.cameraIndex]}}}_loadDependenciesOfMeshes(gltfJson){for(let mesh of gltfJson.meshes){for(let primitive of mesh.primitives){if(primitive.material!==void 0){primitive.materialIndex=primitive.material;primitive.material=gltfJson.materials[primitive.materialIndex]}primitive.attributesindex=Object.assign({},primitive.attributes);for(let attributeName in primitive.attributesindex){if(primitive.attributesindex[attributeName]>=0){let accessor=gltfJson.accessors[primitive.attributesindex[attributeName]];accessor.extras={toGetAsTypedArray:true};primitive.attributes[attributeName]=accessor}else{primitive.attributes[attributeName]=void 0}}if(primitive.indices!==void 0){primitive.indicesIndex=primitive.indices;primitive.indices=gltfJson.accessors[primitive.indicesIndex]}}}}_loadDependenciesOfMaterials(gltfJson){if(gltfJson.materials){for(let material of gltfJson.materials){if(material.pbrMetallicRoughness){let baseColorTexture=material.pbrMetallicRoughness.baseColorTexture;if(baseColorTexture!==void 0){baseColorTexture.texture=gltfJson.textures[baseColorTexture.index]}let metallicRoughnessTexture=material.pbrMetallicRoughness.metallicRoughnessTexture;if(metallicRoughnessTexture!==void 0){metallicRoughnessTexture.texture=gltfJson.textures[metallicRoughnessTexture.index]}}let normalTexture=material.normalTexture;if(normalTexture!==void 0){normalTexture.texture=gltfJson.textures[normalTexture.index]}}}}_loadDependenciesOfTextures(gltfJson){if(gltfJson.textures){for(let texture of gltfJson.textures){if(texture.sampler!==void 0){texture.samplerIndex=texture.sampler;texture.sampler=gltfJson.samplers[texture.samplerIndex]}if(texture.source!==void 0){texture.sourceIndex=texture.source;texture.image=gltfJson.images[texture.sourceIndex]}}}}_loadDependenciesOfJoints(gltfJson){if(gltfJson.skins){for(let skin of gltfJson.skins){skin.skeletonIndex=skin.skeleton;skin.skeleton=gltfJson.nodes[skin.skeletonIndex];skin.inverseBindMatricesIndex=skin.inverseBindMatrices;skin.inverseBindMatrices=gltfJson.accessors[skin.inverseBindMatricesIndex];skin.jointsIndices=skin.joints;skin.joints=[];for(let jointIndex of skin.jointsIndices){skin.joints.push(gltfJson.nodes[jointIndex])}}}}_loadDependenciesOfAnimations(gltfJson){if(gltfJson.animations){for(let animation of gltfJson.animations){for(let channel of animation.channels){channel.samplerIndex=channel.sampler;channel.sampler=animation.samplers[channel.samplerIndex];channel.target.nodeIndex=channel.target.node;channel.target.node=gltfJson.nodes[channel.target.nodeIndex]}for(let channel of animation.channels){channel.sampler.inputIndex=channel.sampler.input;channel.sampler.outputIndex=channel.sampler.output;channel.sampler.input=gltfJson.accessors[channel.sampler.inputIndex];channel.sampler.output=gltfJson.accessors[channel.sampler.outputIndex];if(channel.target.path==="rotation"){if(channel.sampler.output.extras===void 0){channel.sampler.output.extras={}}channel.sampler.output.extras.quaternionIfVec4=true}}}}}_loadDependenciesOfAccessors(gltfJson){for(let accessor of gltfJson.accessors){if(accessor.bufferView!==void 0){accessor.bufferViewIndex=accessor.bufferView;accessor.bufferView=gltfJson.bufferViews[accessor.bufferViewIndex]}}}_loadDependenciesOfBufferViews(gltfJson){for(let bufferView of gltfJson.bufferViews){if(bufferView.buffer!==void 0){bufferView.bufferIndex=bufferView.buffer;bufferView.buffer=gltfJson.buffers[bufferView.bufferIndex]}}}_loadResources(arrayBufferBinary,basePath,gltfJson,options,resources){let promisesToLoadResources=[];for(let i in gltfJson.shaders){resources.shaders[i]={};let shaderJson=gltfJson.shaders[i];let shaderType=shaderJson.type;if(typeof shaderJson.extensions!=="undefined"&&typeof shaderJson.extensions.KHR_binary_glTF!=="undefined"){resources.shaders[i].shaderText=this._accessBinaryAsShader(shaderJson.extensions.KHR_binary_glTF.bufferView,gltfJson,arrayBufferBinary);resources.shaders[i].shaderType=shaderType;continue}let shaderUri=shaderJson.uri;if(options.files){const splitted=shaderUri.split("/");const filename=splitted[splitted.length-1];if(options.files[filename]){const arrayBuffer=options.files[filename];shaders[shaderName].shaderText=DataUtil.arrayBufferToString(arrayBuffer);shaders[shaderName].shaderType=shaderType;continue}}if(shaderUri.match(/^data:/)){promisesToLoadResources.push(new Promise((resolve,rejected)=>{let arrayBuffer=DataUtil.base64ToArrayBuffer(shaderUri);resources.shaders[i].shaderText=DataUtil.arrayBufferToString(arrayBuffer);resources.shaders[i].shaderType=shaderType;resolve()}))}else{shaderUri=basePath+shaderUri;promisesToLoadResources.push(DataUtil.loadResourceAsync(shaderUri,false,(resolve,response)=>{resources.shaders[i].shaderText=response;resources.shaders[i].shaderType=shaderType;resolve(gltfJson)},(reject,error)=>{}))}}for(let i in gltfJson.buffers){let bufferInfo=gltfJson.buffers[i];let splitted=null;let filename=null;if(bufferInfo.uri){splitted=bufferInfo.uri.split("/");filename=splitted[splitted.length-1]}if(typeof bufferInfo.uri==="undefined"){promisesToLoadResources.push(new Promise((resolve,rejected)=>{resources.buffers[i]=arrayBufferBinary;bufferInfo.buffer=arrayBufferBinary;resolve(gltfJson)}))}else if(bufferInfo.uri.match(/^data:application\/octet-stream;base64,/)){promisesToLoadResources.push(new Promise((resolve,rejected)=>{let arrayBuffer=DataUtil.base64ToArrayBuffer(bufferInfo.uri);resources.buffers[i]=arrayBuffer;bufferInfo.buffer=arrayBuffer;resolve(gltfJson)}))}else if(options.files&&options.files[filename]){promisesToLoadResources.push(new Promise((resolve,rejected)=>{const arrayBuffer=options.files[filename];resources.buffers[i]=arrayBuffer;bufferInfo.buffer=arrayBuffer;resolve(gltfJson)}))}else{promisesToLoadResources.push(DataUtil.loadResourceAsync(basePath+bufferInfo.uri,true,(resolve,response)=>{resources.buffers[i]=response;bufferInfo.buffer=response;resolve(gltfJson)},(reject,error)=>{}))}}for(let i in gltfJson.images){let imageJson=gltfJson.images[i];let imageUri=null;if(typeof imageJson.uri==="undefined"){imageUri=this._accessBinaryAsImage(imageJson.bufferView,gltfJson,arrayBufferBinary,imageJson.mimeType)}else{let imageFileStr=imageJson.uri;const splitted=imageFileStr.split("/");const filename=splitted[splitted.length-1];if(options.files&&options.files[filename]){const arrayBuffer=options.files[filename];const splitted=filename.split(".");const fileExtension=splitted[splitted.length-1];imageUri=this._accessArrayBufferAsImage(arrayBuffer,fileExtension)}else if(imageFileStr.match(/^data:/)){imageUri=imageFileStr}else{imageUri=basePath+imageFileStr}}if(options.isNeededToMultiplyAlphaToColorOfPixelOutput){if(options.isTextureImageToLoadPreMultipliedAlpha);}else{if(options.isTextureImageToLoadPreMultipliedAlpha);}if(options.extensionLoader&&options.extensionLoader.setUVTransformToTexture){options.extensionLoader.setUVTransformToTexture(texture,samplerJson)}promisesToLoadResources.push(new Promise((resolve,reject)=>{let img=new Image;img.src=imageUri;imageJson.image=img;if(imageUri.match(/^data:/)){resolve(gltfJson)}else{img.crossOrigin="Anonymous";img.onload=(()=>{resolve(gltfJson)})}resources.images[i]=img}))}return Promise.all(promisesToLoadResources)}_sliceBufferViewToArrayBuffer(json,bufferViewStr,arrayBuffer){let bufferViewJson=json.bufferViews[bufferViewStr];let byteOffset=bufferViewJson.byteOffset;let byteLength=bufferViewJson.byteLength;let arrayBufferSliced=arrayBuffer.slice(byteOffset,byteOffset+byteLength);return arrayBufferSliced}_accessBinaryAsImage(bufferViewStr,json,arrayBuffer,mimeType){let arrayBufferSliced=this._sliceBufferViewToArrayBuffer(json,bufferViewStr,arrayBuffer);return this._accessArrayBufferAsImage(arrayBufferSliced,mimeType)}_accessArrayBufferAsImage(arrayBuffer,imageType){let bytes=new Uint8Array(arrayBuffer);let binaryData="";for(let i=0,len=bytes.byteLength;i1){let lengthDic={index:0,position:0,normal:0,joint:0,weight:0,texcoord:0};for(let i=0;i{if(materialJson.pbrMetallicRoughness){let baseColorTexture=materialJson.pbrMetallicRoughness.baseColorTexture;if(baseColorTexture){let sampler=baseColorTexture.texture.sampler;let isNeededToMultiplyAlphaToColorOfTexture=false;if(options.isNeededToMultiplyAlphaToColorOfPixelOutput){if(options.isTextureImageToLoadPreMultipliedAlphaAsDefault);else{isNeededToMultiplyAlphaToColorOfTexture=true}}else{if(options.isTextureImageToLoadPreMultipliedAlphaAsDefault);}if(options&&options.statesOfElements){for(let statesInfo of options.statesOfElements){if(statesInfo.targets){for(let target of statesInfo.targets){let isMatch=false;let specifyMethod=statesInfo.specifyMethod!==void 0?statesInfo.specifyMethod:GLBoost$1.QUERY_TYPE_USER_FLAVOR_NAME;switch(specifyMethod){case GLBoost$1.QUERY_TYPE_USER_FLAVOR_NAME:isMatch=group.userFlavorName===target;break;case GLBoost$1.QUERY_TYPE_INSTANCE_NAME:isMatch=group.instanceName===target;break;case GLBoost$1.QUERY_TYPE_INSTANCE_NAME_WITH_USER_FLAVOR:isMatch=group.instanceNameWithUserFlavor===target;break}if(isMatch){if(options.isNeededToMultiplyAlphaToColorOfPixelOutput){if(statesInfo.isTextureImageToLoadPreMultipliedAlpha);else{isNeededToMultiplyAlphaToColorOfTexture=true}}else{if(statesInfo.isTextureImageToLoadPreMultipliedAlpha);}}}}}}let texture=glBoostContext.createTexture(baseColorTexture.texture.image.image,"",{TEXTURE_MAG_FILTER:sampler===void 0?GLBoost$1.LINEAR:sampler.magFilter,TEXTURE_MIN_FILTER:sampler===void 0?GLBoost$1.LINEAR_MIPMAP_LINEAR:sampler.minFilter,TEXTURE_WRAP_S:sampler===void 0?GLBoost$1.REPEAT:sampler.wrapS,TEXTURE_WRAP_T:sampler===void 0?GLBoost$1.REPEAT:sampler.wrapT,UNPACK_PREMULTIPLY_ALPHA_WEBGL:isNeededToMultiplyAlphaToColorOfTexture});gltfMaterial.setTexture(texture,GLBoost$1.TEXTURE_PURPOSE_DIFFUSE)}let enables=[];if(options.isBlend){enables.push(3042)}if(options.isDepthTest){enables.push(2929)}gltfMaterial.states.enable=enables;if(options.isBlend&&options.isNeededToMultiplyAlphaToColorOfPixelOutput){gltfMaterial.states.functions.blendFuncSeparate=[1,771,1,771]}gltfMaterial.globalStatesUsage=GLBoost$1.GLOBAL_STATES_USAGE_IGNORE}};setTextures(materialJson)}else{if(typeof vertexData.components.texcoord!=="undefined"){let emptyTexcoords=[];let componentN=vertexData.components.position;let length=_positions[i].length/componentN;for(let k=0;k{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform highp ${sampler2D} uDepthTexture[${lightNumExceptAmbient}];\n`;shaderText+=`${in_} vec4 v_shadowCoord[${lightNumExceptAmbient}];\n`;shaderText+=`uniform int isShadowCasting[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_BlinnPhongShaderSource(f,gl,lights){var shaderText="";shaderText+=" float depthBias = 0.005;\n";shaderText+=" vec4 surfaceColor = rt0;\n";shaderText+=" rt0 = vec4(0.0, 0.0, 0.0, 0.0);\n";for(let i=0;i{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform highp ${sampler2D} uDepthTexture[${lightNumExceptAmbient}];\n`;shaderText+=`${in_} vec4 v_shadowCoord[${lightNumExceptAmbient}];\n`;shaderText+=`uniform int isShadowCasting[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_HalfLambertShaderSource(f,gl,lights){var shaderText="";shaderText+=" vec4 surfaceColor = rt0;\n";shaderText+=" rt0 = vec4(0.0, 0.0, 0.0, 0.0);\n";for(let i=0;i{return!light.isTypeAmbient()}).length;if(lightNumExceptAmbient>0){shaderText+=`uniform highp ${sampler2D} uDepthTexture[${lightNumExceptAmbient}];\n`;shaderText+=`${in_} vec4 v_shadowCoord[${lightNumExceptAmbient}];\n`;shaderText+=`uniform int isShadowCasting[${lightNumExceptAmbient}];\n`}return shaderText}FSShade_HalfLambertAndWrapLightingShaderSource(f,gl,lights){var shaderText="";shaderText+=" vec4 surfaceColor = rt0;\n";shaderText+=" rt0 = vec4(0.0, 0.0, 0.0, 0.0);\n";for(let i=0;ithis.__animationEndRange){this.moveToTheTime(this.__animationStartRange)}else if(localAnimationCurrentTimethis.__animationLength){this.moveToTheTime(this.__animationStartRange)}this.__animationCurrentTime=localAnimationCurrentTime/speedRatio;return localAnimationCurrentTime}__setupMultiMotions(group){const json={name:"All",start:group.getStartAnimationInputValue("time")*this.__FpsForPlaying,end:group.getEndAnimationInputValue("time")*this.__FpsForPlaying};this.animationMotions.push(json);if(!group.animationTracks){return}if(group.animationTracks){Array.prototype.push.apply(this.animationMotions,group.animationTracks)}this.__currentMotion=group.animationTracks[0].name}moveToTheTime(time){this.__currentMillisecondAtStart=Date.now();this.__animationCurrentTime=time;this.__animationLastTime=this.__animationCurrentTime}changeMotion(motionName){for(let motion of this.__animationMotions){if(motion.name===motionName){this.changeRange(motion.start/this.__FpsForPlaying,motion.end/this.__FpsForPlaying);this.moveToTheTime(motion.start/this.__FpsForPlaying)}}}changeRange(start,end){this.__animationStartRange=start;this.__animationEndRange=end;const time=this.__animationCurrentTime;this.moveToTheTime(time)}get animationMotions(){return this.__animationMotions}set animationMotions(motions){this.__animationMotions=motions}}GLBoost$1["AnimationPlayer"]=AnimationPlayer;async function formatDetector(uri,files){if(files){for(let fileName in files){const splitted=fileName.split(".");const fileExtension=splitted[splitted.length-1];if(fileExtension==="gltf"||fileExtension==="glb"){return new Promise((resolve,response)=>{checkArrayBufferOfGltf(files[fileName],resolve)},(reject,error)=>{})}}}return DataUtil.loadResourceAsync(uri,true,(resolve,response)=>{const arrayBuffer=response;checkArrayBufferOfGltf(arrayBuffer,resolve)})}function checkArrayBufferOfGltf(arrayBuffer,resolve){const isLittleEndian=true;const dataView=new DataView(arrayBuffer,0,20);const magic=dataView.getUint32(0,isLittleEndian);if(magic!==1179937895){let gotText=DataUtil.arrayBufferToString(arrayBuffer);let gltfJson=JSON.parse(gotText);let glTFVer=checkGLTFVersion(gltfJson);resolve("glTF"+glTFVer);return}let glTFVer=dataView.getUint32(4,isLittleEndian);resolve("glTF"+glTFVer)}function checkGLTFVersion(gltfJson){let glTFVer=1;if(gltfJson.asset&&gltfJson.asset.version){glTFVer=parseFloat(gltfJson.asset.version)}return glTFVer}GLBoost$1["formatDetector"]=formatDetector}); //# sourceMappingURL=glboost.min.js.map -(0,eval)('this').GLBoost.VERSION='version: 0.0.4-26-g5494-mod branch: develop'; +(0,eval)('this').GLBoost.VERSION='version: 0.0.4-36-g02e83-mod branch: develop'; diff --git a/pre-commit b/pre-commit index e55504df..d2ed77e0 100755 --- a/pre-commit +++ b/pre-commit @@ -1,5 +1,10 @@ -#!/bin/sh +#!/bin/bash -npm rum build +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + +if [[ $CURRENT_BRANCH = master || $CURRENT_BRANCH = develop ]] +then + npm rum build +fi git add ./VERSION-FILE ./build/glboost.js ./build/glboost.min.js ./build/glboost.min.js.map