UNPKG

the-world-engine

Version:

three.js based, unity like game engine for browser

1 lines 297 kB
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("three/src/Three"),require("three/src/math/MathUtils"),require("b2d"),require("three/examples/jsm/postprocessing/EffectComposer"),require("three/examples/jsm/postprocessing/RenderPass")):"function"==typeof define&&define.amd?define("TWE",["exports","three/src/Three","three/src/math/MathUtils","b2d","three/examples/jsm/postprocessing/EffectComposer","three/examples/jsm/postprocessing/RenderPass"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).TWE={},t.THREE,t.THREE.MathUtils,t.B2D,t.EffectComposer,t.RenderPass)}(this,(function(t,s,i,h,r,n){"use strict";!function(){function e(){}void 0===h&&(h={AABB:e,Abs:e,Acos:e,Alloc:e,AngularStiffness:e,AreaJoint:e,AreaJointDef:e,Asin:e,Assert:e,Atan2:e,BlockAllocator:e,Body:e,BodyDef:e,BroadPhase:e,BuoyancyController:e,CalculateParticleIterations:e,ChainAndCircleContact:e,ChainAndPolygonContact:e,ChainShape:e,CircleContact:e,CircleShape:e,Clamp:e,ClipSegmentToLine:e,ClipVertex:e,CollideCircles:e,CollideEdgeAndCircle:e,CollideEdgeAndPolygon:e,CollidePolygonAndCircle:e,CollidePolygons:e,Color:e,ConstantAccelController:e,ConstantForceController:e,Contact:e,ContactEdge:e,ContactFactory:e,ContactFeature:e,ContactFilter:e,ContactID:e,ContactImpulse:e,ContactListener:e,ContactManager:e,ContactPositionConstraint:e,ContactRegister:e,ContactSolver:e,ContactSolverDef:e,ContactVelocityConstraint:e,Controller:e,ControllerEdge:e,Cos:e,Counter:e,DegToRad:e,DestructionListener:e,Distance:e,DistanceInput:e,DistanceJoint:e,DistanceJointDef:e,DistanceOutput:e,DistanceProxy:e,Draw:e,DynamicTree:e,EdgeAndCircleContact:e,EdgeAndPolygonContact:e,EdgeShape:e,Filter:e,Fixture:e,FixtureDef:e,FixtureParticleQueryCallback:e,FixtureProxy:e,Free:e,FrictionJoint:e,FrictionJointDef:e,GearJoint:e,GearJointDef:e,GetPointStates:e,GravityController:e,GrowableBuffer:e,GrowableStack:e,InvSqrt:e,IsPowerOfTwo:e,IsValid:e,Island:e,Jacobian:e,Joint:e,JointDef:e,JointEdge:e,LinearStiffness:e,Log:e,MakeArray:e,MakeNullArray:e,MakeNumberArray:e,Manifold:e,ManifoldPoint:e,MassData:e,Mat22:e,Mat33:e,Max:e,Maybe:e,Min:e,MixFriction:e,MixRestitution:e,MixRestitutionThreshold:e,MotorJoint:e,MotorJointDef:e,MouseJoint:e,MouseJointDef:e,NextPowerOfTwo:e,Pair:e,ParseInt:e,ParseUInt:e,ParticleBodyContact:e,ParticleContact:e,ParticleDef:e,ParticleGroup:e,ParticleGroupDef:e,ParticleHandle:e,ParticlePair:e,ParticlePairSet:e,ParticleSystem:e,ParticleSystemDef:e,ParticleSystem_CompositeShape:e,ParticleSystem_ConnectionFilter:e,ParticleSystem_DestroyParticlesInShapeCallback:e,ParticleSystem_FixedSetAllocator:e,ParticleSystem_FixtureParticle:e,ParticleSystem_FixtureParticleSet:e,ParticleSystem_InsideBoundsEnumerator:e,ParticleSystem_JoinParticleGroupsFilter:e,ParticleSystem_ParticleListNode:e,ParticleSystem_ParticlePair:e,ParticleSystem_Proxy:e,ParticleSystem_ReactiveFilter:e,ParticleSystem_SolveCollisionCallback:e,ParticleSystem_UpdateBodyContactsCallback:e,ParticleSystem_UserOverridableBuffer:e,ParticleTriad:e,PolygonAndCircleContact:e,PolygonContact:e,PolygonShape:e,Position:e,PositionSolverManifold:e,Pow:e,PrismaticJoint:e,PrismaticJointDef:e,Profile:e,PulleyJoint:e,PulleyJointDef:e,QueryCallback:e,RadToDeg:e,Random:e,RandomRange:e,RayCastCallback:e,RayCastInput:e,RayCastOutput:e,RevoluteJoint:e,RevoluteJointDef:e,Rope:e,RopeDef:e,RopeTuning:e,Rot:e,SeparationFunction:e,Shape:e,ShapeCast:e,ShapeCastInput:e,ShapeCastOutput:e,Simplex:e,SimplexCache:e,SimplexVertex:e,Sin:e,SolverData:e,Sq:e,Sqrt:e,StackAllocator:e,StackQueue:e,Swap:e,Sweep:e,TOIInput:e,TOIOutput:e,TensorDampingController:e,TestOverlapAABB:e,TestOverlapShape:e,TimeOfImpact:e,TimeStep:e,Timer:e,Transform:e,TreeNode:e,Vec2:e,Vec2_zero:e,Vec3:e,Velocity:e,VelocityConstraintPoint:e,Version:e,VoronoiDiagram:e,VoronoiDiagram_Generator:e,VoronoiDiagram_Task:e,WeldJoint:e,WeldJointDef:e,WheelJoint:e,WheelJointDef:e,World:e,WorldManifold:e,_180_over_pi:e,_pi_over_180:e,aabbExtension:e,aabbMultiplier:e,angularSleepTolerance:e,angularSlop:e,barrierCollisionTime:e,baumgarte:e,branch:e,commit:e,dynamicBody:e,epsilon:e,epsilon_sq:e,get_g_blockSolve:e,gjk_reset:e,invalidParticleIndex:e,kinematicBody:e,lengthUnitsPerMeter:e,linearSleepTolerance:e,linearSlop:e,maxAngularCorrection:e,maxFloat:e,maxLinearCorrection:e,maxManifoldPoints:e,maxParticleForce:e,maxParticleIndex:e,maxParticlePressure:e,maxPolygonVertices:e,maxRotation:e,maxRotationSquared:e,maxSubSteps:e,maxTOIContacts:e,maxTranslation:e,maxTranslationSquared:e,maxTriadDistance:e,maxTriadDistanceSquared:e,minParticleSystemBufferCapacity:e,minParticleWeight:e,minPulleyLength:e,particleStride:e,pbdAngleBendingModel:e,pbdDistanceBendingModel:e,pbdHeightBendingModel:e,pbdStretchingModel:e,pbdTriangleBendingModel:e,pi:e,polygonRadius:e,set_g_blockSolve:e,springAngleBendingModel:e,staticBody:e,timeToSleep:e,toiBaumgarte:e,toi_reset:e,two_pi:e,version:e,xpbdAngleBendingModel:e,xpbdStretchingModel:e})}();var o,a=this&&this.t||(o=function(t,s){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])},o(t,s)},function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function __(){this.constructor=t}o(t,s),t.prototype=null===s?Object.create(s):(__.prototype=s.prototype,new __)}),l=function(){function ContainerIterator(t){void 0===t&&(t=0),this.iteratorType=t}return ContainerIterator.prototype.equals=function(t){return this.o===t.o},ContainerIterator}(),u=function(t){function Container(){return null!==t&&t.apply(this,arguments)||this}return a(Container,t),Container}(function(){function Base(){this.i=0}return Object.defineProperty(Base.prototype,"length",{get:function(){return this.i},enumerable:!1,configurable:!0}),Base.prototype.size=function(){return this.i},Base.prototype.empty=function(){return 0===this.i},Base}());function throwIteratorAccessError(){throw new RangeError("Iterator access denied!")}var c=this&&this.t||function(){var extendStatics=function(t,s){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])},extendStatics(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function __(){this.constructor=t}extendStatics(t,s),t.prototype=null===s?Object.create(s):(__.prototype=s.prototype,new __)}}(),d=function(){function TreeNode(t,s,i){void 0===i&&(i=1),this.Y=void 0,this.Z=void 0,this.tt=void 0,this.p=t,this.H=s,this.ee=i}return TreeNode.prototype.L=function(){var t=this,s=t.tt.tt===t;if(s&&1===t.ee)t=t.Z;else if(t.Y)for(t=t.Y;t.Z;)t=t.Z;else{if(s)return t.tt;for(var i=t.tt;i.Y===t;)i=(t=i).tt;t=i}return t},TreeNode.prototype.m=function(){var t=this;if(t.Z){for(t=t.Z;t.Y;)t=t.Y;return t}for(var s=t.tt;s.Z===t;)s=(t=s).tt;return t.Z!==s?s:t},TreeNode.prototype.te=function(){var t=this.tt,s=this.Z,i=s.Y;return t.tt===this?t.tt=s:t.Y===this?t.Y=s:t.Z=s,s.tt=t,s.Y=this,this.tt=s,this.Z=i,i&&(i.tt=this),s},TreeNode.prototype.ne=function(){var t=this.tt,s=this.Y,i=s.Z;return t.tt===this?t.tt=s:t.Y===this?t.Y=s:t.Z=s,s.tt=t,s.Z=this,this.tt=s,this.Y=i,i&&(i.tt=this),s},TreeNode}(),f=function(t){function TreeNodeEnableIndex(){var s=null!==t&&t.apply(this,arguments)||this;return s.rt=1,s}return c(TreeNodeEnableIndex,t),TreeNodeEnableIndex.prototype.te=function(){var s=t.prototype.te.call(this);return this.ie(),s.ie(),s},TreeNodeEnableIndex.prototype.ne=function(){var s=t.prototype.ne.call(this);return this.ie(),s.ie(),s},TreeNodeEnableIndex.prototype.ie=function(){this.rt=1,this.Y&&(this.rt+=this.Y.rt),this.Z&&(this.rt+=this.Z.rt)},TreeNodeEnableIndex}(d),g=this&&this.t||function(){var extendStatics=function(t,s){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])},extendStatics(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function __(){this.constructor=t}extendStatics(t,s),t.prototype=null===s?Object.create(s):(__.prototype=s.prototype,new __)}}(),m=function(t){function TreeContainer(s,i){void 0===s&&(s=function(t,s){return t<s?-1:t>s?1:0}),void 0===i&&(i=!1);var h=t.call(this)||this;return h.rr=void 0,h.j=s,h.enableIndex=i,h.re=i?f:d,h.u=new h.re,h}return g(TreeContainer,t),TreeContainer.prototype.$=function(t,s){for(var i=this.u;t;){var h=this.j(t.p,s);if(h<0)t=t.Z;else{if(!(h>0))return t;i=t,t=t.Y}}return i},TreeContainer.prototype.tr=function(t,s){for(var i=this.u;t;){this.j(t.p,s)<=0?t=t.Z:(i=t,t=t.Y)}return i},TreeContainer.prototype.er=function(t,s){for(var i=this.u;t;){var h=this.j(t.p,s);if(h<0)i=t,t=t.Z;else{if(!(h>0))return t;t=t.Y}}return i},TreeContainer.prototype.nr=function(t,s){for(var i=this.u;t;){this.j(t.p,s)<0?(i=t,t=t.Z):t=t.Y}return i},TreeContainer.prototype.se=function(t){for(;;){var s,i=t.tt;if(i===this.u)return;if(1===t.ee)return void(t.ee=0);if(t===i.Y)if(1===(s=i.Z).ee)s.ee=0,i.ee=1,i===this.rr?this.rr=i.te():i.te();else{if(s.Z&&1===s.Z.ee)return s.ee=i.ee,i.ee=0,s.Z.ee=0,void(i===this.rr?this.rr=i.te():i.te());s.Y&&1===s.Y.ee?(s.ee=1,s.Y.ee=0,s.ne()):(s.ee=1,t=i)}else if(1===(s=i.Y).ee)s.ee=0,i.ee=1,i===this.rr?this.rr=i.ne():i.ne();else{if(s.Y&&1===s.Y.ee)return s.ee=i.ee,i.ee=0,s.Y.ee=0,void(i===this.rr?this.rr=i.ne():i.ne());s.Z&&1===s.Z.ee?(s.ee=1,s.Z.ee=0,s.te()):(s.ee=1,t=i)}}},TreeContainer.prototype.U=function(t){if(1!==this.i){for(var s=t;s.Y||s.Z;){if(s.Z)for(s=s.Z;s.Y;)s=s.Y;else s=s.Y;var i=t.p;t.p=s.p,s.p=i;var h=t.H;t.H=s.H,s.H=h,t=s}this.u.Y===s?this.u.Y=s.tt:this.u.Z===s&&(this.u.Z=s.tt),this.se(s);var r=s.tt;if(s===r.Y?r.Y=void 0:r.Z=void 0,this.i-=1,this.rr.ee=0,this.enableIndex)for(;r!==this.u;)r.rt-=1,r=r.tt}else this.clear()},TreeContainer.prototype.ir=function(t){for(var s="number"==typeof t?t:void 0,i="function"==typeof t?t:void 0,h=void 0===t?[]:void 0,r=0,n=this.rr,o=[];o.length||n;)if(n)o.push(n),n=n.Y;else{if(n=o.pop(),r===s)return n;h&&h.push(n),i&&i(n,r,this),r+=1,n=n.Z}return h},TreeContainer.prototype.fe=function(t){for(;;){var s=t.tt;if(0===s.ee)return;var i=s.tt;if(s===i.Y){if((h=i.Z)&&1===h.ee){if(h.ee=s.ee=0,i===this.rr)return;i.ee=1,t=i;continue}if(t!==s.Z)return s.ee=0,i===this.rr?this.rr=i.ne():i.ne(),void(i.ee=1);t.ee=0,t.Y&&(t.Y.tt=s),t.Z&&(t.Z.tt=i),s.Z=t.Y,i.Y=t.Z,t.Y=s,t.Z=i,i===this.rr?(this.rr=t,this.u.tt=t):(r=i.tt).Y===i?r.Y=t:r.Z=t,t.tt=i.tt,s.tt=t,i.tt=t,i.ee=1}else{var h,r;if((h=i.Y)&&1===h.ee){if(h.ee=s.ee=0,i===this.rr)return;i.ee=1,t=i;continue}if(t!==s.Y)return s.ee=0,i===this.rr?this.rr=i.te():i.te(),void(i.ee=1);t.ee=0,t.Y&&(t.Y.tt=i),t.Z&&(t.Z.tt=s),i.Z=t.Y,s.Y=t.Z,t.Y=i,t.Z=s,i===this.rr?(this.rr=t,this.u.tt=t):(r=i.tt).Y===i?r.Y=t:r.Z=t,t.tt=i.tt,s.tt=t,i.tt=t,i.ee=1}return void(this.enableIndex&&(s.ie(),i.ie(),t.ie()))}},TreeContainer.prototype.v=function(t,s,i){if(void 0===this.rr)return this.i+=1,this.rr=new this.re(t,s,0),this.rr.tt=this.u,this.u.tt=this.u.Y=this.u.Z=this.rr,this.i;var h,r=this.u.Y,n=this.j(r.p,t);if(0===n)return r.H=s,this.i;if(n>0)r.Y=new this.re(t,s),r.Y.tt=r,h=r.Y,this.u.Y=h;else{var o=this.u.Z,a=this.j(o.p,t);if(0===a)return o.H=s,this.i;if(a<0)o.Z=new this.re(t,s),o.Z.tt=o,h=o.Z,this.u.Z=h;else{if(void 0!==i){var l=i.o;if(l!==this.u){var u=this.j(l.p,t);if(0===u)return l.H=s,this.i;if(u>0){var c=l.L(),d=this.j(c.p,t);if(0===d)return c.H=s,this.i;d<0&&(h=new this.re(t,s),void 0===c.Z?(c.Z=h,h.tt=c):(l.Y=h,h.tt=l))}}}if(void 0===h)for(h=this.rr;;){var f=this.j(h.p,t);if(f>0){if(void 0===h.Y){h.Y=new this.re(t,s),h.Y.tt=h,h=h.Y;break}h=h.Y}else{if(!(f<0))return h.H=s,this.i;if(void 0===h.Z){h.Z=new this.re(t,s),h.Z.tt=h,h=h.Z;break}h=h.Z}}}}if(this.enableIndex)for(var g=h.tt;g!==this.u;)g.rt+=1,g=g.tt;return this.fe(h),this.i+=1,this.i},TreeContainer.prototype.ar=function(t,s){for(;t;){var i=this.j(t.p,s);if(i<0)t=t.Z;else{if(!(i>0))return t;t=t.Y}}return t||this.u},TreeContainer.prototype.clear=function(){this.i=0,this.rr=void 0,this.u.tt=void 0,this.u.Y=this.u.Z=void 0},TreeContainer.prototype.updateKeyByIterator=function(t,s){var i=t.o;if(i===this.u&&throwIteratorAccessError(),1===this.i)return i.p=s,!0;var h=i.m().p;if(i===this.u.Y)return this.j(h,s)>0&&(i.p=s,!0);var r=i.L().p;return i===this.u.Z?this.j(r,s)<0&&(i.p=s,!0):!(this.j(r,s)>=0||this.j(h,s)<=0)&&(i.p=s,!0)},TreeContainer.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;var s=this.ir(t);return this.U(s),this.i},TreeContainer.prototype.eraseElementByKey=function(t){if(0===this.i)return!1;var s=this.ar(this.rr,t);return s!==this.u&&(this.U(s),!0)},TreeContainer.prototype.eraseElementByIterator=function(t){var s=t.o;s===this.u&&throwIteratorAccessError();var i=void 0===s.Z;return 0===t.iteratorType?i&&t.next():i&&void 0!==s.Y||t.next(),this.U(s),t},TreeContainer.prototype.getHeight=function(){if(0===this.i)return 0;return function traversal(t){return t?Math.max(traversal(t.Y),traversal(t.Z))+1:0}(this.rr)},TreeContainer}(u),p=m,w=this&&this.t||function(){var extendStatics=function(t,s){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])},extendStatics(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function __(){this.constructor=t}extendStatics(t,s),t.prototype=null===s?Object.create(s):(__.prototype=s.prototype,new __)}}(),C=function(t){function TreeIterator(s,i,h){var r=t.call(this,h)||this;return r.o=s,r.u=i,0===r.iteratorType?(r.pre=function(){return this.o===this.u.Y&&throwIteratorAccessError(),this.o=this.o.L(),this},r.next=function(){return this.o===this.u&&throwIteratorAccessError(),this.o=this.o.m(),this}):(r.pre=function(){return this.o===this.u.Z&&throwIteratorAccessError(),this.o=this.o.m(),this},r.next=function(){return this.o===this.u&&throwIteratorAccessError(),this.o=this.o.L(),this}),r}return w(TreeIterator,t),Object.defineProperty(TreeIterator.prototype,"index",{get:function(){var t=this.o,s=this.u.tt;if(t===this.u)return s?s.rt-1:0;var i=0;for(t.Y&&(i+=t.Y.rt);t!==s;){var h=t.tt;t===h.Z&&(i+=1,h.Y&&(i+=h.Y.rt)),t=h}return i},enumerable:!1,configurable:!0}),TreeIterator.prototype.isAccessible=function(){return this.o!==this.u},TreeIterator}(l),v=C,b=this&&this.t||function(){var extendStatics=function(t,s){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])},extendStatics(t,s)};return function(t,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function __(){this.constructor=t}extendStatics(t,s),t.prototype=null===s?Object.create(s):(__.prototype=s.prototype,new __)}}(),y=this&&this.h||function(t,s){var i,h,r,n,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return n={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function verb(t){return function(s){return step([t,s])}}function step(n){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,h&&(r=2&n[0]?h.return:n[0]?h.throw||((r=h.return)&&r.call(h),0):h.next)&&!(r=r.call(h,n[1])).done)return r;switch(h=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,h=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){o=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]<r[3])){o.label=n[1];break}if(6===n[0]&&o.label<r[1]){o.label=r[1],r=n;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(n);break}r[2]&&o.ops.pop(),o.trys.pop();continue}n=s.call(t,o)}catch(t){n=[6,t],h=0}finally{i=r=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}},M=function(t){function OrderedSetIterator(s,i,h,r){var n=t.call(this,s,i,r)||this;return n.container=h,n}return b(OrderedSetIterator,t),Object.defineProperty(OrderedSetIterator.prototype,"pointer",{get:function(){return this.o===this.u&&throwIteratorAccessError(),this.o.p},enumerable:!1,configurable:!0}),OrderedSetIterator.prototype.copy=function(){return new OrderedSetIterator(this.o,this.u,this.container,this.iteratorType)},OrderedSetIterator}(v),x=function(t){function OrderedSet(s,i,h){void 0===s&&(s=[]);var r=t.call(this,i,h)||this,n=r;return s.forEach((function(t){n.insert(t)})),r}return b(OrderedSet,t),OrderedSet.prototype.begin=function(){return new M(this.u.Y||this.u,this.u,this)},OrderedSet.prototype.end=function(){return new M(this.u,this.u,this)},OrderedSet.prototype.rBegin=function(){return new M(this.u.Z||this.u,this.u,this,1)},OrderedSet.prototype.rEnd=function(){return new M(this.u,this.u,this,1)},OrderedSet.prototype.front=function(){return this.u.Y?this.u.Y.p:void 0},OrderedSet.prototype.back=function(){return this.u.Z?this.u.Z.p:void 0},OrderedSet.prototype.lowerBound=function(t){var s=this.$(this.rr,t);return new M(s,this.u,this)},OrderedSet.prototype.upperBound=function(t){var s=this.tr(this.rr,t);return new M(s,this.u,this)},OrderedSet.prototype.reverseLowerBound=function(t){var s=this.er(this.rr,t);return new M(s,this.u,this)},OrderedSet.prototype.reverseUpperBound=function(t){var s=this.nr(this.rr,t);return new M(s,this.u,this)},OrderedSet.prototype.forEach=function(t){this.ir((function(s,i,h){t(s.p,i,h)}))},OrderedSet.prototype.insert=function(t,s){return this.v(t,void 0,s)},OrderedSet.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.ir(t).p},OrderedSet.prototype.find=function(t){var s=this.ar(this.rr,t);return new M(s,this.u,this)},OrderedSet.prototype.union=function(t){var s=this;return t.forEach((function(t){s.insert(t)})),this.i},OrderedSet.prototype[Symbol.iterator]=function(){var t,s,i;return y(this,(function(h){switch(h.label){case 0:t=this.i,s=this.ir(),i=0,h.label=1;case 1:return i<t?[4,s[i].p]:[3,4];case 2:h.sent(),h.label=3;case 3:return++i,[3,1];case 4:return[2]}}))},OrderedSet}(p),S=x;class MutIteratableCollection{constructor(t){this._iterateCollection=null,this._collection=new S(void 0,t),this._insertBuffer=new S(void 0,t),this._insertBufferSwap=new S(void 0,t),this._deleteBuffer=new S(void 0,t)}get size(){return this._collection.size()}insert(t){t.isRemoved=!1,null!==this._iterateCollection?(this._insertBuffer.insert(t),this._deleteBuffer.eraseElementByKey(t)):this._collection.insert(t)}delete(t){null!==this._iterateCollection?(t.isRemoved=!0,this._insertBuffer.eraseElementByKey(t),this._deleteBuffer.insert(t)):this._collection.eraseElementByKey(t)}clear(){this._collection.clear(),this._insertBuffer.clear(),this._deleteBuffer.clear()}forEach(t){this._iterateCollection=this._collection,this._iterateCollection.forEach((s=>{s.isRemoved||t(s)}));do{this._iterateCollection=this.flushBuffer(),this._iterateCollection.forEach((s=>{s.isRemoved||t(s)}))}while(0<this._insertBuffer.size()||0<this._deleteBuffer.size());this._iterateCollection=null}flushBuffer(){this._iterateCollection=null,this._deleteBuffer.forEach((t=>this.delete(t))),this._insertBuffer.forEach((t=>this.insert(t)));const t=this._insertBuffer;return this._insertBuffer=this._insertBufferSwap,this._insertBufferSwap=t,this._insertBuffer.clear(),this._deleteBuffer.clear(),t}}class ComponentEvent{constructor(t,s,i,h){this.isRemoved=!1,this._priority=i,this._eventId=t.generateEventId(),this._componentExecutionOrder=h,this._eventFunc=s}static createAwakeEvent(t,s){return new ComponentEvent(t,s,0,0)}static createStartEvent(t,s,i){return new ComponentEvent(t,s,2,i)}static createUpdateEvent(t,s,i){return new ComponentEvent(t,s,3,i)}static createOnEnableEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnDisableEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnDestroyEvent(t,s,i){return new ComponentEvent(t,s,4,i)}static createOnCollisionEnter2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnCollisionStay2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnCollisionExit2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnTriggerEnter2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnTriggerStay2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}static createOnTriggerExit2DEvent(t,s,i){return new ComponentEvent(t,s,1,i)}get invoke(){return this._eventFunc}static comparator(t,s){return t._priority===s._priority?t._componentExecutionOrder===s._componentExecutionOrder?t._eventId-s._eventId:t._componentExecutionOrder-s._componentExecutionOrder:t._priority-s._priority}}function isOnWorldMatrixUpdatedableComponent(t){return void 0!==t.onWorldMatrixUpdated}class GameObjectEventContainer{constructor(){this._matrixUpdateComponents=new Set,this._collisionEnter2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator),this._collisionStay2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator),this._collisionExit2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator),this._triggerEnter2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator),this._triggerStay2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator),this._triggerExit2DComponentEvents=new MutIteratableCollection(ComponentEvent.comparator)}registerComponent(t){isOnWorldMatrixUpdatedableComponent(t)&&this._matrixUpdateComponents.add(t);const s=t._engine_internal_componentEventContainer;s.onCollisionEnter2D&&this._collisionEnter2DComponentEvents.insert(s.onCollisionEnter2D),s.onCollisionStay2D&&this._collisionStay2DComponentEvents.insert(s.onCollisionStay2D),s.onCollisionExit2D&&this._collisionExit2DComponentEvents.insert(s.onCollisionExit2D),s.onTriggerEnter2D&&this._triggerEnter2DComponentEvents.insert(s.onTriggerEnter2D),s.onTriggerStay2D&&this._triggerStay2DComponentEvents.insert(s.onTriggerStay2D),s.onTriggerExit2D&&this._triggerExit2DComponentEvents.insert(s.onTriggerExit2D)}unregisterComponent(t){isOnWorldMatrixUpdatedableComponent(t)&&this._matrixUpdateComponents.delete(t);const s=t._engine_internal_componentEventContainer;s.onCollisionEnter2D&&this._collisionEnter2DComponentEvents.delete(s.onCollisionEnter2D),s.onCollisionStay2D&&this._collisionStay2DComponentEvents.delete(s.onCollisionStay2D),s.onCollisionExit2D&&this._collisionExit2DComponentEvents.delete(s.onCollisionExit2D),s.onTriggerEnter2D&&this._triggerEnter2DComponentEvents.delete(s.onTriggerEnter2D),s.onTriggerStay2D&&this._triggerStay2DComponentEvents.delete(s.onTriggerStay2D),s.onTriggerExit2D&&this._triggerExit2DComponentEvents.delete(s.onTriggerExit2D)}invokeOnWorldMatrixUpdated(){for(const t of this._matrixUpdateComponents)t.onWorldMatrixUpdated()}invokeOnCollisionEnter2D(t){0!==this._collisionEnter2DComponentEvents.size&&this._collisionEnter2DComponentEvents.forEach((s=>s.invoke(t)))}invokeOnCollisionStay2D(t){0!==this._collisionStay2DComponentEvents.size&&this._collisionStay2DComponentEvents.forEach((s=>s.invoke(t)))}invokeOnCollisionExit2D(t){0!==this._collisionExit2DComponentEvents.size&&this._collisionExit2DComponentEvents.forEach((s=>s.invoke(t)))}invokeOnTriggerEnter2D(t){0!==this._triggerEnter2DComponentEvents.size&&this._triggerEnter2DComponentEvents.forEach((s=>s.invoke(t)))}invokeOnTriggerStay2D(t){0!==this._triggerStay2DComponentEvents.size&&this._triggerStay2DComponentEvents.forEach((s=>s.invoke(t)))}invokeOnTriggerExit2D(t){0!==this._triggerExit2DComponentEvents.size&&this._triggerExit2DComponentEvents.forEach((s=>s.invoke(t)))}}class ObservableEuler{constructor(t=0,s=0,i=0,h=ObservableEuler.DefaultOrder){this.isEuler=!0,this._internalX=t,this._internalY=s,this._internalZ=i,this._internalOrder=h,this._onChangeCallback=()=>{},this._onBeforeChangeCallback=()=>{},this._onBeforeGetComponentCallback=()=>{}}onBeforeGetComponent(t){this._onBeforeGetComponentCallback=t}onBeforeChange(t){this._onBeforeChangeCallback=t}get _x(){return this._onBeforeGetComponentCallback(),this._internalX}set _x(t){this._internalX=t}get _y(){return this._onBeforeGetComponentCallback(),this._internalY}set _y(t){this._internalY=t}get _z(){return this._onBeforeGetComponentCallback(),this._internalZ}set _z(t){this._internalZ=t}get _order(){return this._onBeforeGetComponentCallback(),this._internalOrder}set _order(t){this._internalOrder=t}get x(){return this._onBeforeGetComponentCallback(),this._internalX}set x(t){this._onBeforeChangeCallback(),this._internalX=t,this._onChangeCallback()}get y(){return this._onBeforeGetComponentCallback(),this._internalY}set y(t){this._onBeforeChangeCallback(),this._internalY=t,this._onChangeCallback()}get z(){return this._onBeforeGetComponentCallback(),this._internalZ}set z(t){this._onBeforeChangeCallback(),this._internalZ=t,this._onChangeCallback()}get order(){return this._onBeforeGetComponentCallback(),this._internalOrder}set order(t){this._onBeforeChangeCallback(),this._internalOrder=t,this._onChangeCallback()}set(t,s,i,h){return this._onBeforeChangeCallback(),this._internalX=t,this._internalY=s,this._internalZ=i,h&&(this._internalOrder=h),this._onChangeCallback(),this}clone(){return this._onBeforeGetComponentCallback(),new s.Euler(this._internalX,this._internalY,this._internalZ,this._internalOrder)}copy(t){return this._onBeforeChangeCallback(),this._internalX=t._x,this._internalY=t._y,this._internalZ=t._z,this._internalOrder=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,s,h=!0){this._onBeforeGetComponentCallback();const r=t.elements,n=r[0],o=r[4],a=r[8],l=r[1],u=r[5],c=r[9],d=r[2],f=r[6],g=r[10];switch(s||(s=this._internalOrder),this._onBeforeChangeCallback(),s){case"XYZ":this._internalY=Math.asin(i.clamp(a,-1,1)),Math.abs(a)<.9999999?(this._internalX=Math.atan2(-c,g),this._internalZ=Math.atan2(-o,n)):(this._internalX=Math.atan2(f,u),this._internalZ=0);break;case"YXZ":this._internalX=Math.asin(-i.clamp(c,-1,1)),Math.abs(c)<.9999999?(this._internalY=Math.atan2(a,g),this._internalZ=Math.atan2(l,u)):(this._internalY=Math.atan2(-d,n),this._internalZ=0);break;case"ZXY":this._internalX=Math.asin(i.clamp(f,-1,1)),Math.abs(f)<.9999999?(this._internalY=Math.atan2(-d,g),this._internalZ=Math.atan2(-o,u)):(this._internalY=0,this._internalZ=Math.atan2(l,n));break;case"ZYX":this._internalY=Math.asin(-i.clamp(d,-1,1)),Math.abs(d)<.9999999?(this._internalX=Math.atan2(f,g),this._internalZ=Math.atan2(l,n)):(this._internalX=0,this._internalZ=Math.atan2(-o,u));break;case"YZX":this._internalZ=Math.asin(i.clamp(l,-1,1)),Math.abs(l)<.9999999?(this._internalX=Math.atan2(-c,u),this._internalY=Math.atan2(-d,n)):(this._internalX=0,this._internalY=Math.atan2(a,g));break;case"XZY":this._internalZ=Math.asin(-i.clamp(o,-1,1)),Math.abs(o)<.9999999?(this._internalX=Math.atan2(f,u),this._internalY=Math.atan2(a,n)):(this._internalX=Math.atan2(-c,g),this._internalY=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+s)}return this._internalOrder=s,!0===h&&this._onChangeCallback(),this}setFromQuaternion(t,s,i){return E.makeRotationFromQuaternion(t),this.setFromRotationMatrix(E,s,i)}setFromVector3(t,s){return this.set(t.x,t.y,t.z,s)}reorder(t){return D.setFromEuler(this),this.setFromQuaternion(D,t)}equals(t){return this._onBeforeGetComponentCallback(),t._x===this._internalX&&t._y===this._internalY&&t._z===this._internalZ&&t._order===this._internalOrder}fromArray(t){return this._internalX===t[0]&&this._internalY===t[1]&&this._internalZ===t[2]&&this._internalOrder===t[3]||(this._onBeforeChangeCallback(),this._internalX=t[0],this._internalY=t[1],this._internalZ=t[2],void 0!==t[3]&&(this._internalOrder=t[3]),this._onChangeCallback()),this}toArray(t=[],s=0){return this._onBeforeGetComponentCallback(),t[s]=this._internalX,t[s+1]=this._internalY,t[s+2]=this._internalZ,t[s+3]=this._internalOrder,t}_onChange(t){return this._onChangeCallback=t,this}*[Symbol.iterator](){this._onBeforeGetComponentCallback(),yield this._internalX,this._onBeforeGetComponentCallback(),yield this._internalY,this._onBeforeGetComponentCallback(),yield this._internalZ,this._onBeforeGetComponentCallback(),yield this._internalOrder}}ObservableEuler.DefaultOrder="XYZ",ObservableEuler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];const E=new s.Matrix4,D=new s.Quaternion;class ObservableQuaternion{constructor(t=0,s=0,i=0,h=1){this.isQuaternion=!0,this._internalX=t,this._internalY=s,this._internalZ=i,this._internalW=h,this._onChangeCallback=()=>{},this._onBeforeChangeCallback=()=>{},this._onBeforeGetComponentCallback=()=>{}}onBeforeGetComponent(t){this._onBeforeGetComponentCallback=t}onBeforeChange(t){this._onBeforeChangeCallback=t}static slerp(t,s,i,h){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),i.slerpQuaternions(t,s,h)}static slerpFlat(t,s,i,h,r,n,o){let a=i[h+0],l=i[h+1],u=i[h+2],c=i[h+3];const d=r[n+0],f=r[n+1],g=r[n+2],m=r[n+3];if(0===o)return t[s+0]=a,t[s+1]=l,t[s+2]=u,void(t[s+3]=c);if(1===o)return t[s+0]=d,t[s+1]=f,t[s+2]=g,void(t[s+3]=m);if(c!==m||a!==d||l!==f||u!==g){let t=1-o;const s=a*d+l*f+u*g+c*m,i=s>=0?1:-1,h=1-s*s;if(h>Number.EPSILON){const r=Math.sqrt(h),n=Math.atan2(r,s*i);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r}const r=o*i;if(a=a*t+d*r,l=l*t+f*r,u=u*t+g*r,c=c*t+m*r,t===1-o){const t=1/Math.sqrt(a*a+l*l+u*u+c*c);a*=t,l*=t,u*=t,c*=t}}t[s]=a,t[s+1]=l,t[s+2]=u,t[s+3]=c}static multiplyQuaternionsFlat(t,s,i,h,r,n){const o=i[h],a=i[h+1],l=i[h+2],u=i[h+3],c=r[n],d=r[n+1],f=r[n+2],g=r[n+3];return t[s]=o*g+u*c+a*f-l*d,t[s+1]=a*g+u*d+l*c-o*f,t[s+2]=l*g+u*f+o*d-a*c,t[s+3]=u*g-o*c-a*d-l*f,t}get _x(){return this._onBeforeGetComponentCallback(),this._internalX}set _x(t){this._internalX=t}get _y(){return this._onBeforeGetComponentCallback(),this._internalY}set _y(t){this._internalY=t}get _z(){return this._onBeforeGetComponentCallback(),this._internalZ}set _z(t){this._internalZ=t}get _w(){return this._onBeforeGetComponentCallback(),this._internalW}set _w(t){this._internalW=t}get x(){return this._onBeforeGetComponentCallback(),this._internalX}set x(t){this._onBeforeChangeCallback(),this._internalX=t,this._onChangeCallback()}get y(){return this._onBeforeGetComponentCallback(),this._internalY}set y(t){this._onBeforeChangeCallback(),this._internalY=t,this._onChangeCallback()}get z(){return this._onBeforeGetComponentCallback(),this._internalZ}set z(t){this._onBeforeChangeCallback(),this._internalZ=t,this._onChangeCallback()}get w(){return this._onBeforeGetComponentCallback(),this._internalW}set w(t){this._onBeforeChangeCallback(),this._internalW=t,this._onChangeCallback()}set(t,s,i,h){return this._onBeforeChangeCallback(),this._internalX=t,this._internalY=s,this._internalZ=i,this._internalW=h,this._onChangeCallback(),this}clone(){return this._onBeforeGetComponentCallback(),new s.Quaternion(this._internalX,this._internalY,this._internalZ,this._internalW)}copy(t){return this._onBeforeChangeCallback(),this._internalX=t.x,this._internalY=t.y,this._internalZ=t.z,this._internalW=t.w,this._onChangeCallback(),this}setFromEuler(t,s){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=t._x,h=t._y,r=t._z,n=t._order,o=Math.cos,a=Math.sin,l=o(i/2),u=o(h/2),c=o(r/2),d=a(i/2),f=a(h/2),g=a(r/2);switch(this._onBeforeChangeCallback(),n){case"XYZ":this._internalX=d*u*c+l*f*g,this._internalY=l*f*c-d*u*g,this._internalZ=l*u*g+d*f*c,this._internalW=l*u*c-d*f*g;break;case"YXZ":this._internalX=d*u*c+l*f*g,this._internalY=l*f*c-d*u*g,this._internalZ=l*u*g-d*f*c,this._internalW=l*u*c+d*f*g;break;case"ZXY":this._internalX=d*u*c-l*f*g,this._internalY=l*f*c+d*u*g,this._internalZ=l*u*g+d*f*c,this._internalW=l*u*c-d*f*g;break;case"ZYX":this._internalX=d*u*c-l*f*g,this._internalY=l*f*c+d*u*g,this._internalZ=l*u*g-d*f*c,this._internalW=l*u*c+d*f*g;break;case"YZX":this._internalX=d*u*c+l*f*g,this._internalY=l*f*c+d*u*g,this._internalZ=l*u*g-d*f*c,this._internalW=l*u*c-d*f*g;break;case"XZY":this._internalX=d*u*c-l*f*g,this._internalY=l*f*c-d*u*g,this._internalZ=l*u*g+d*f*c,this._internalW=l*u*c+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!1!==s&&this._onChangeCallback(),this}setFromAxisAngle(t,s){const i=s/2,h=Math.sin(i);return this._onBeforeChangeCallback(),this._internalX=t.x*h,this._internalY=t.y*h,this._internalZ=t.z*h,this._internalW=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const s=t.elements,i=s[0],h=s[4],r=s[8],n=s[1],o=s[5],a=s[9],l=s[2],u=s[6],c=s[10],d=i+o+c;if(this._onBeforeChangeCallback(),d>0){const t=.5/Math.sqrt(d+1);this._internalW=.25/t,this._internalX=(u-a)*t,this._internalY=(r-l)*t,this._internalZ=(n-h)*t}else if(i>o&&i>c){const t=2*Math.sqrt(1+i-o-c);this._internalW=(u-a)/t,this._internalX=.25*t,this._internalY=(h+n)/t,this._internalZ=(r+l)/t}else if(o>c){const t=2*Math.sqrt(1+o-i-c);this._internalW=(r-l)/t,this._internalX=(h+n)/t,this._internalY=.25*t,this._internalZ=(a+u)/t}else{const t=2*Math.sqrt(1+c-i-o);this._internalW=(n-h)/t,this._internalX=(r+l)/t,this._internalY=(a+u)/t,this._internalZ=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,s){let i=t.dot(s)+1;return this._onBeforeChangeCallback(),i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._internalX=-t.y,this._internalY=t.x,this._internalZ=0,this._internalW=i):(this._internalX=0,this._internalY=-t.z,this._internalZ=t.y,this._internalW=i)):(this._internalX=t.y*s.z-t.z*s.y,this._internalY=t.z*s.x-t.x*s.z,this._internalZ=t.x*s.y-t.y*s.x,this._internalW=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(i.clamp(this.dot(t),-1,1)))}rotateTowards(t,s){const i=this.angleTo(t);if(0===i)return this;const h=Math.min(1,s/i);return this.slerp(t,h),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._internalX*=-1,this._internalY*=-1,this._internalZ*=-1,this._onChangeCallback(),this}dot(t){return this._onBeforeGetComponentCallback(),this._internalX*t._x+this._internalY*t._y+this._internalZ*t._z+this._internalW*t._w}lengthSq(){return this._onBeforeGetComponentCallback(),this._internalX*this._internalX+this._internalY*this._internalY+this._internalZ*this._internalZ+this._internalW*this._internalW}length(){return this._onBeforeGetComponentCallback(),Math.sqrt(this._internalX*this._internalX+this._internalY*this._internalY+this._internalZ*this._internalZ+this._internalW*this._internalW)}normalize(){let t=this.length();return 0===t?(this._onBeforeChangeCallback(),this._internalX=0,this._internalY=0,this._internalZ=0,this._internalW=1):(t=1/t,this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._internalX=this._internalX*t,this._internalY=this._internalY*t,this._internalZ=this._internalZ*t,this._internalW=this._internalW*t),this._onChangeCallback(),this}multiply(t,s){return void 0!==s?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,s)):0===t._x&&0===t._y&&0===t._z&&1===t._w?this:this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,s){const i=t._x,h=t._y,r=t._z,n=t._w,o=s._x,a=s._y,l=s._z,u=s._w;return this._onBeforeChangeCallback(),this._internalX=i*u+n*o+h*l-r*a,this._internalY=h*u+n*a+r*o-i*l,this._internalZ=r*u+n*l+i*a-h*o,this._internalW=n*u-i*o-h*a-r*l,this._onChangeCallback(),this}slerp(t,s){if(0===s)return this;if(1===s)return this.copy(t);this._onBeforeGetComponentCallback();const i=this._internalX,h=this._internalY,r=this._internalZ,n=this._internalW;let o=n*t._w+i*t._x+h*t._y+r*t._z;if(this._onBeforeChangeCallback(),o<0?(this._internalW=-t._w,this._internalX=-t._x,this._internalY=-t._y,this._internalZ=-t._z,o=-o):this.copy(t),o>=1)return this._internalW=n,this._internalX=i,this._internalY=h,this._internalZ=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-s;return this._internalW=t*n+s*this._internalW,this._internalX=t*i+s*this._internalX,this._internalY=t*h+s*this._internalY,this._internalZ=t*r+s*this._internalZ,this.normalize(),this}const l=Math.sqrt(a),u=Math.atan2(l,o),c=Math.sin((1-s)*u)/l,d=Math.sin(s*u)/l;return this._internalW=n*c+this._internalW*d,this._internalX=i*c+this._internalX*d,this._internalY=h*c+this._internalY*d,this._internalZ=r*c+this._internalZ*d,this._onChangeCallback(),this}slerpQuaternions(t,s,i){return this.copy(t).slerp(s,i)}random(){const t=Math.random(),s=Math.sqrt(1-t),i=Math.sqrt(t),h=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(s*Math.cos(h),i*Math.sin(r),i*Math.cos(r),s*Math.sin(h))}equals(t){return this._onBeforeGetComponentCallback(),t._x===this._internalX&&t._y===this._internalY&&t._z===this._internalZ&&t._w===this._internalW}fromArray(t,s=0){return this._internalX===t[s]&&this._internalY===t[s+1]&&this._internalZ===t[s+2]&&this._internalW===t[s+3]||(this._onBeforeChangeCallback(),this._internalX=t[s],this._internalY=t[s+1],this._internalZ=t[s+2],this._internalW=t[s+3],this._onChangeCallback()),this}toArray(t=[],s=0){return this._onBeforeGetComponentCallback(),t[s]=this._internalX,t[s+1]=this._internalY,t[s+2]=this._internalZ,t[s+3]=this._internalW,t}fromBufferAttribute(t,s){return this._internalX=t.getX(s),this._internalY=t.getY(s),this._internalZ=t.getZ(s),this._internalW=t.getW(s),this}_onChange(t){return this._onChangeCallback=t,this}*[Symbol.iterator](){this._onBeforeGetComponentCallback(),yield this._internalX,this._onBeforeGetComponentCallback(),yield this._internalY,this._onBeforeGetComponentCallback(),yield this._internalZ,this._onBeforeGetComponentCallback(),yield this._internalW}}class ObservableVector3{constructor(t=0,s=0,i=0){this.isVector3=!0,this._x=t,this._y=s,this._z=i,this._onBeforeChangeCallback=()=>{},this._onBeforeGetComponentCallback=()=>{}}onBeforeChange(t){this._onBeforeChangeCallback=t}onBeforeGetComponent(t){this._onBeforeGetComponentCallback=t}get x(){return this._onBeforeGetComponentCallback(),this._x}set x(t){this._onBeforeChangeCallback(),this._x=t}get y(){return this._onBeforeGetComponentCallback(),this._y}set y(t){this._onBeforeChangeCallback(),this._y=t}get z(){return this._onBeforeGetComponentCallback(),this._z}set z(t){this._onBeforeChangeCallback(),this._z=t}set(t,s,i){return void 0===i&&(this._onBeforeGetComponentCallback(),i=this._z),this._onBeforeChangeCallback(),this._x=t,this._y=s,this._z=i,this}setScalar(t){return this._onBeforeChangeCallback(),this._x=t,this._y=t,this._z=t,this}setX(t){return this._onBeforeChangeCallback(),this._x=t,this}setY(t){return this._onBeforeChangeCallback(),this._y=t,this}setZ(t){return this._onBeforeChangeCallback(),this._z=t,this}setComponent(t,s){switch(t){case 0:this._onBeforeChangeCallback(),this._x=s;break;case 1:this._onBeforeChangeCallback(),this._y=s;break;case 2:this._onBeforeChangeCallback(),this._z=s;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(this._onBeforeGetComponentCallback(),t){case 0:return this._x;case 1:return this._y;case 2:return this._z;default:throw new Error("index is out of range: "+t)}}clone(){return this._onBeforeGetComponentCallback(),new s.Vector3(this._x,this._y,this._z)}copy(t){return this._onBeforeChangeCallback(),this._x=t.x,this._y=t.y,this._z=t.z,this}add(t,s){return void 0!==s?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,s)):(0===t.x&&0===t.y&&0===t.z||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x+=t.x,this._y+=t.y,this._z+=t.z),this)}addScalar(t){return 0===t||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x+=t,this._y+=t,this._z+=t),this}addVectors(t,s){return this._onBeforeChangeCallback(),this._x=t.x+s.x,this._y=t.y+s.y,this._z=t.z+s.z,this}addScaledVector(t,s){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x+=t.x*s,this._y+=t.y*s,this._z+=t.z*s,this}sub(t,s){return void 0!==s?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,s)):(0===t.x&&0===t.y&&0===t.z||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x-=t.x,this._y-=t.y,this._z-=t.z),this)}subScalar(t){return 0===t||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x-=t,this._y-=t,this._z-=t),this}subVectors(t,s){return this._onBeforeChangeCallback(),this._x=t.x-s.x,this._y=t.y-s.y,this._z=t.z-s.z,this}multiply(t,s){return void 0!==s?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,s)):(1===t.x&&1===t.y&&1===t.z||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x*=t.x,this._y*=t.y,this._z*=t.z),this)}multiplyScalar(t){return 1===t||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x*=t,this._y*=t,this._z*=t),this}multiplyVectors(t,s){return this._onBeforeChangeCallback(),this._x=t.x*s.x,this._y=t.y*s.y,this._z=t.z*s.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(T.setFromEuler(t))}applyAxisAngle(t,s){return this.applyQuaternion(T.setFromAxisAngle(t,s))}applyMatrix3(t){this._onBeforeGetComponentCallback();const s=this._x,i=this._y,h=this._z,r=t.elements;return this._onBeforeChangeCallback(),this._x=r[0]*s+r[3]*i+r[6]*h,this._y=r[1]*s+r[4]*i+r[7]*h,this._z=r[2]*s+r[5]*i+r[8]*h,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){this._onBeforeGetComponentCallback();const s=this._x,i=this._y,h=this._z,r=t.elements,n=1/(r[3]*s+r[7]*i+r[11]*h+r[15]);return this._onBeforeChangeCallback(),this._x=(r[0]*s+r[4]*i+r[8]*h+r[12])*n,this._y=(r[1]*s+r[5]*i+r[9]*h+r[13])*n,this._z=(r[2]*s+r[6]*i+r[10]*h+r[14])*n,this}applyQuaternion(t){this._onBeforeGetComponentCallback();const s=this._x,i=this._y,h=this._z,r=t.x,n=t.y,o=t.z,a=t.w,l=a*s+n*h-o*i,u=a*i+o*s-r*h,c=a*h+r*i-n*s,d=-r*s-n*i-o*h;return this._onBeforeChangeCallback(),this._x=l*a+d*-r+u*-o-c*-n,this._y=u*a+d*-n+c*-r-l*-o,this._z=c*a+d*-o+l*-n-u*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){this._onBeforeGetComponentCallback();const s=this._x,i=this._y,h=this._z,r=t.elements;return this._onBeforeChangeCallback(),this._x=r[0]*s+r[4]*i+r[8]*h,this._y=r[1]*s+r[5]*i+r[9]*h,this._z=r[2]*s+r[6]*i+r[10]*h,this.normalize()}divide(t){return 1===t.x&&1===t.y&&1===t.z||(this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x/=t.x,this._y/=t.y,this._z/=t.z),this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.min(this._x,t.x),this._y=Math.min(this._y,t.y),this._z=Math.min(this._z,t.z),this}max(t){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.max(this._x,t.x),this._y=Math.max(this._y,t.y),this._z=Math.max(this._z,t.z),this}clamp(t,s){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.max(t.x,Math.min(s.x,this._x)),this._y=Math.max(t.y,Math.min(s.y,this._y)),this._z=Math.max(t.z,Math.min(s.z,this._z)),this}clampScalar(t,s){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.max(t,Math.min(s,this._x)),this._y=Math.max(t,Math.min(s,this._y)),this._z=Math.max(t,Math.min(s,this._z)),this}clampLength(t,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(s,i)))}floor(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.floor(this._x),this._y=Math.floor(this._y),this._z=Math.floor(this._z),this}ceil(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.ceil(this._x),this._y=Math.ceil(this._y),this._z=Math.ceil(this._z),this}round(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=Math.round(this._x),this._y=Math.round(this._y),this._z=Math.round(this._z),this}roundToZero(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=this._x<0?Math.ceil(this._x):Math.floor(this._x),this._y=this._y<0?Math.ceil(this._y):Math.floor(this._y),this._z=this._z<0?Math.ceil(this._z):Math.floor(this._z),this}negate(){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x=-this._x,this._y=-this._y,this._z=-this._z,this}dot(t){return this._onBeforeGetComponentCallback(),this._x*t.x+this._y*t.y+this._z*t.z}lengthSq(){return this._onBeforeGetComponentCallback(),this._x*this._x+this._y*this._y+this._z*this._z}length(){return this._onBeforeGetComponentCallback(),Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z)}manhattanLength(){return this._onBeforeGetComponentCallback(),Math.abs(this._x)+Math.abs(this._y)+Math.abs(this._z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this._onBeforeGetComponentCallback(),this._onBeforeChangeCallback(),this._x+=(t.x-this._x)*s,this._y+=(t.y-this._y)*s,this._z+=(t.z-this._z)*s,this}lerpVectors(t,s,i){return this._onBeforeChangeCallback(),this._x=t.x+(s.x-t.x)*i,this._y=t.y+(s.y-t.y)*i,this._z=t.z+(s.z-t.z)*i,this}cross(t,s){return void 0!==s?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,s)):this.crossVectors(this,t)}crossVectors(t,s){const i=t.x,h=t.y,r=t.z,n=s.x,o=s.y,a=s.z;return this._onBeforeChangeCallback(),this._x=h*a-r*o,this._y=r*n-i*a,this._z=i*o-h*n,this}projectOnVector(t){const s=t.lengthSq();if(0===s)return this.set(0,0,0);const i=t.dot(this)/s;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return P.copy(this).projectOnVector(t),this.sub(P)}reflect(t){return this.sub(P.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===s)return Math.PI/2;const h=this.dot(t)/s;return Math.acos(i.clamp(h,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){this._onBeforeGetComponentCallback();const s=this._x-t.x,i=this._y-t.y,h=this._z-t.z;return s*s+i*i+h*h}manhattanDistanceTo(t){return this._onBeforeGetComponentCallback(),Math.abs(this._x-t.x)+Math.abs(this._y-t.y)+Math.abs(this._z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,s,i){const h=Math.sin(s)*t;return this._onBeforeChangeCallback(),this._x=h*Math.sin(i),this._y=Math.cos(s)*t,this._z=h*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,s,i){return this._onBeforeChangeCallback(),this._x=t*Math.sin(s),this._y=i,this._z=t*Math.cos(s),this}setFromMatrixPosition(t){const s=t.elements;return this._onBeforeChangeCallback(),this._x=s[12],this._y=s[13],this._z=s[14],this}setFromMatrixScale(t){const s=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),h=this.setFromMatrixColumn(t,2).length();return this._onBeforeChangeCallback(),this._x=s,this._y=i,this._z=h,this}setFromMatrixColumn(t,s){return this.fromArray(t.elements,4*s)}setFromMatrix3Column(t,s){return this.fromArray(t.elements,3*s)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return this._onBeforeGetComponentCallback(),t.x===this._x&&t.y===this._y&&t.z===this._z}fromArray(t,s=0){return this._x===t[s]&&this._y===t[s+1]&&this._z===t[s+2]||(this._onBeforeChangeCallback(),this._x=t[s],this._y=t[s+1],this._z=t[s+2]),this}toArray(t=[],s=0){return this._onBeforeGetComponentCallback(),t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t}fromBufferAttribute(t,s,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this._onBeforeChangeCallback(),this._x=t.getX(s),this._y=t.getY(s),this._z=t.getZ(s),this}random(){return this._onBeforeChangeCallback(),this._x=Math.random(),this._y=Math.random(),this._z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),s=Math.random()*Math.PI*2,i=Math.sqrt(1-Math.pow(t,2));return this._onBeforeChangeCallback(),this._x=i*Math.cos(s),this._y=i*Math.sin(s),this._z=t,this}*[Symbol.iterator](){this._onBeforeGetComponentCallback(),yield this._x,this._onBeforeGetComponentCallback(),yield this._y,this._onBeforeGetComponentCallback(),yield this._z}}const P=new ObservableVector3,T=new s.Quaternion;class Transform{constructor(t,s,i){this._hasChanged=!1,this._localMatrixNeedUpdate=!1,this._worldMatrixNeedUpdate=!1,this._worldPositionRotationScaleNeedUpdate=!1,this._localPositionRotationScaleNeedUpdate=!1,this._onBeforeGetLocalBind=this.onBeforeGetLocal.bind(this),this._onBeforeLocalChangeBind=this.onBeforeLocalChange.bind(this),this._onLocalEulerRotationChangedBind=this.onLocalEulerRotationChanged.bind(this),this._onLocalRotationChangedBind=this.onLocalRotationChanged.bind(this),this._onBeforeGetWorldBind=this.onBeforeGetWorld.bind(this),this._onBeforeWorldChangeBind=this.onBeforeWorldChange.bind(this),this._onWorldEulerRotationChangedBind=this.onWorldEulerRotationChanged.bind(this),this._onWorldRotationChangedBin