mage-engine 3.17.4 → 3.17.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/mage.js +1655 -1602
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -53543,9 +53543,12 @@ if ( typeof window !== 'undefined' ) {
53543
53543
  }
53544
53544
 
53545
53545
  }var three_module=/*#__PURE__*/Object.freeze({__proto__:null,ACESFilmicToneMapping:ACESFilmicToneMapping,AddEquation:AddEquation,AddOperation:AddOperation,AdditiveAnimationBlendMode:AdditiveAnimationBlendMode,AdditiveBlending:AdditiveBlending,AlphaFormat:AlphaFormat,AlwaysDepth:AlwaysDepth,AlwaysStencilFunc:AlwaysStencilFunc,AmbientLight:AmbientLight$1,AmbientLightProbe:AmbientLightProbe,AnimationClip:AnimationClip,AnimationLoader:AnimationLoader,AnimationMixer:AnimationMixer,AnimationObjectGroup:AnimationObjectGroup,AnimationUtils:AnimationUtils,ArcCurve:ArcCurve,ArrayCamera:ArrayCamera,ArrowHelper:ArrowHelper,Audio:Audio$2,AudioAnalyser:AudioAnalyser,AudioContext:AudioContext,AudioListener:AudioListener,AudioLoader:AudioLoader,AxesHelper:AxesHelper,AxisHelper:AxisHelper,BackSide:BackSide,BasicDepthPacking:BasicDepthPacking,BasicShadowMap:BasicShadowMap,BinaryTextureLoader:BinaryTextureLoader,Bone:Bone,BooleanKeyframeTrack:BooleanKeyframeTrack,BoundingBoxHelper:BoundingBoxHelper,Box2:Box2,Box3:Box3,Box3Helper:Box3Helper,BoxBufferGeometry:BoxGeometry,BoxGeometry:BoxGeometry,BoxHelper:BoxHelper,BufferAttribute:BufferAttribute,BufferGeometry:BufferGeometry,BufferGeometryLoader:BufferGeometryLoader,ByteType:ByteType,Cache:Cache,Camera:Camera$1,CameraHelper:CameraHelper,CanvasRenderer:CanvasRenderer,CanvasTexture:CanvasTexture,CatmullRomCurve3:CatmullRomCurve3,CineonToneMapping:CineonToneMapping,CircleBufferGeometry:CircleGeometry,CircleGeometry:CircleGeometry,ClampToEdgeWrapping:ClampToEdgeWrapping,Clock:Clock,Color:Color$1,ColorKeyframeTrack:ColorKeyframeTrack,CompressedTexture:CompressedTexture,CompressedTextureLoader:CompressedTextureLoader,ConeBufferGeometry:ConeGeometry,ConeGeometry:ConeGeometry,CubeCamera:CubeCamera,CubeReflectionMapping:CubeReflectionMapping,CubeRefractionMapping:CubeRefractionMapping,CubeTexture:CubeTexture,CubeTextureLoader:CubeTextureLoader,CubeUVReflectionMapping:CubeUVReflectionMapping,CubeUVRefractionMapping:CubeUVRefractionMapping,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,CubicInterpolant:CubicInterpolant,CullFaceBack:CullFaceBack,CullFaceFront:CullFaceFront,CullFaceFrontBack:CullFaceFrontBack,CullFaceNone:CullFaceNone,Curve:Curve,CurvePath:CurvePath,CustomBlending:CustomBlending,CustomToneMapping:CustomToneMapping,CylinderBufferGeometry:CylinderGeometry,CylinderGeometry:CylinderGeometry,Cylindrical:Cylindrical,DataTexture:DataTexture,DataTexture2DArray:DataTexture2DArray,DataTexture3D:DataTexture3D,DataTextureLoader:DataTextureLoader,DataUtils:DataUtils,DecrementStencilOp:DecrementStencilOp,DecrementWrapStencilOp:DecrementWrapStencilOp,DefaultLoadingManager:DefaultLoadingManager,DepthFormat:DepthFormat,DepthStencilFormat:DepthStencilFormat,DepthTexture:DepthTexture,DirectionalLight:DirectionalLight,DirectionalLightHelper:DirectionalLightHelper,DiscreteInterpolant:DiscreteInterpolant,DodecahedronBufferGeometry:DodecahedronGeometry,DodecahedronGeometry:DodecahedronGeometry,DoubleSide:DoubleSide,DstAlphaFactor:DstAlphaFactor,DstColorFactor:DstColorFactor,DynamicBufferAttribute:DynamicBufferAttribute,DynamicCopyUsage:DynamicCopyUsage,DynamicDrawUsage:DynamicDrawUsage,DynamicReadUsage:DynamicReadUsage,EdgesGeometry:EdgesGeometry,EdgesHelper:EdgesHelper,EllipseCurve:EllipseCurve,EqualDepth:EqualDepth,EqualStencilFunc:EqualStencilFunc,EquirectangularReflectionMapping:EquirectangularReflectionMapping,EquirectangularRefractionMapping:EquirectangularRefractionMapping,Euler:Euler,EventDispatcher:EventDispatcher,ExtrudeBufferGeometry:ExtrudeGeometry,ExtrudeGeometry:ExtrudeGeometry,FaceColors:FaceColors,FileLoader:FileLoader,FlatShading:FlatShading,Float16BufferAttribute:Float16BufferAttribute,Float32Attribute:Float32Attribute,Float32BufferAttribute:Float32BufferAttribute,Float64Attribute:Float64Attribute,Float64BufferAttribute:Float64BufferAttribute,FloatType:FloatType$1,Fog:Fog,FogExp2:FogExp2,Font:Font,FontLoader:FontLoader,FrontSide:FrontSide,Frustum:Frustum$1,GLBufferAttribute:GLBufferAttribute,GLSL1:GLSL1,GLSL3:GLSL3,GammaEncoding:GammaEncoding,GreaterDepth:GreaterDepth,GreaterEqualDepth:GreaterEqualDepth,GreaterEqualStencilFunc:GreaterEqualStencilFunc,GreaterStencilFunc:GreaterStencilFunc,GridHelper:GridHelper,Group:Group,HalfFloatType:HalfFloatType,HemisphereLight:HemisphereLight$1,HemisphereLightHelper:HemisphereLightHelper,HemisphereLightProbe:HemisphereLightProbe,IcosahedronBufferGeometry:IcosahedronGeometry,IcosahedronGeometry:IcosahedronGeometry,ImageBitmapLoader:ImageBitmapLoader,ImageLoader:ImageLoader,ImageUtils:ImageUtils,ImmediateRenderObject:ImmediateRenderObject,IncrementStencilOp:IncrementStencilOp,IncrementWrapStencilOp:IncrementWrapStencilOp,InstancedBufferAttribute:InstancedBufferAttribute,InstancedBufferGeometry:InstancedBufferGeometry,InstancedInterleavedBuffer:InstancedInterleavedBuffer,InstancedMesh:InstancedMesh,Int16Attribute:Int16Attribute,Int16BufferAttribute:Int16BufferAttribute,Int32Attribute:Int32Attribute,Int32BufferAttribute:Int32BufferAttribute,Int8Attribute:Int8Attribute,Int8BufferAttribute:Int8BufferAttribute,IntType:IntType,InterleavedBuffer:InterleavedBuffer,InterleavedBufferAttribute:InterleavedBufferAttribute,Interpolant:Interpolant,InterpolateDiscrete:InterpolateDiscrete,InterpolateLinear:InterpolateLinear,InterpolateSmooth:InterpolateSmooth,InvertStencilOp:InvertStencilOp,JSONLoader:JSONLoader,KeepStencilOp:KeepStencilOp,KeyframeTrack:KeyframeTrack,LOD:LOD,LatheBufferGeometry:LatheGeometry,LatheGeometry:LatheGeometry,Layers:Layers,LensFlare:LensFlare,LessDepth:LessDepth,LessEqualDepth:LessEqualDepth,LessEqualStencilFunc:LessEqualStencilFunc,LessStencilFunc:LessStencilFunc,Light:Light$1,LightProbe:LightProbe,Line:Line$1,Line3:Line3,LineBasicMaterial:LineBasicMaterial,LineCurve:LineCurve,LineCurve3:LineCurve3,LineDashedMaterial:LineDashedMaterial,LineLoop:LineLoop,LinePieces:LinePieces,LineSegments:LineSegments,LineStrip:LineStrip,LinearEncoding:LinearEncoding,LinearFilter:LinearFilter,LinearInterpolant:LinearInterpolant,LinearMipMapLinearFilter:LinearMipMapLinearFilter,LinearMipMapNearestFilter:LinearMipMapNearestFilter,LinearMipmapLinearFilter:LinearMipmapLinearFilter,LinearMipmapNearestFilter:LinearMipmapNearestFilter,LinearToneMapping:LinearToneMapping,Loader:Loader$1,LoaderUtils:LoaderUtils,LoadingManager:LoadingManager,LogLuvEncoding:LogLuvEncoding,LoopOnce:LoopOnce,LoopPingPong:LoopPingPong,LoopRepeat:LoopRepeat,LuminanceAlphaFormat:LuminanceAlphaFormat,LuminanceFormat:LuminanceFormat,MOUSE:MOUSE,Material:Material,MaterialLoader:MaterialLoader,Math:MathUtils,MathUtils:MathUtils,Matrix3:Matrix3,Matrix4:Matrix4,MaxEquation:MaxEquation,Mesh:Mesh,MeshBasicMaterial:MeshBasicMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshFaceMaterial:MeshFaceMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshMatcapMaterial:MeshMatcapMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshToonMaterial:MeshToonMaterial,MinEquation:MinEquation,MirroredRepeatWrapping:MirroredRepeatWrapping,MixOperation:MixOperation,MultiMaterial:MultiMaterial,MultiplyBlending:MultiplyBlending,MultiplyOperation:MultiplyOperation,NearestFilter:NearestFilter,NearestMipMapLinearFilter:NearestMipMapLinearFilter,NearestMipMapNearestFilter:NearestMipMapNearestFilter,NearestMipmapLinearFilter:NearestMipmapLinearFilter,NearestMipmapNearestFilter:NearestMipmapNearestFilter,NeverDepth:NeverDepth,NeverStencilFunc:NeverStencilFunc,NoBlending:NoBlending,NoColors:NoColors,NoToneMapping:NoToneMapping,NormalAnimationBlendMode:NormalAnimationBlendMode,NormalBlending:NormalBlending,NotEqualDepth:NotEqualDepth,NotEqualStencilFunc:NotEqualStencilFunc,NumberKeyframeTrack:NumberKeyframeTrack,Object3D:Object3D,ObjectLoader:ObjectLoader,ObjectSpaceNormalMap:ObjectSpaceNormalMap,OctahedronBufferGeometry:OctahedronGeometry,OctahedronGeometry:OctahedronGeometry,OneFactor:OneFactor,OneMinusDstAlphaFactor:OneMinusDstAlphaFactor,OneMinusDstColorFactor:OneMinusDstColorFactor,OneMinusSrcAlphaFactor:OneMinusSrcAlphaFactor,OneMinusSrcColorFactor:OneMinusSrcColorFactor,OrthographicCamera:OrthographicCamera,PCFShadowMap:PCFShadowMap,PCFSoftShadowMap:PCFSoftShadowMap,PMREMGenerator:PMREMGenerator,ParametricBufferGeometry:ParametricGeometry,ParametricGeometry:ParametricGeometry,Particle:Particle,ParticleBasicMaterial:ParticleBasicMaterial,ParticleSystem:ParticleSystem,ParticleSystemMaterial:ParticleSystemMaterial,Path:Path,PerspectiveCamera:PerspectiveCamera,Plane:Plane$1,PlaneBufferGeometry:PlaneGeometry,PlaneGeometry:PlaneGeometry,PlaneHelper:PlaneHelper,PointCloud:PointCloud,PointCloudMaterial:PointCloudMaterial,PointLight:PointLight$1,PointLightHelper:PointLightHelper,Points:Points,PointsMaterial:PointsMaterial,PolarGridHelper:PolarGridHelper,PolyhedronBufferGeometry:PolyhedronGeometry,PolyhedronGeometry:PolyhedronGeometry,PositionalAudio:PositionalAudio,PropertyBinding:PropertyBinding,PropertyMixer:PropertyMixer,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,Quaternion:Quaternion,QuaternionKeyframeTrack:QuaternionKeyframeTrack,QuaternionLinearInterpolant:QuaternionLinearInterpolant,REVISION:REVISION,RGBADepthPacking:RGBADepthPacking,RGBAFormat:RGBAFormat,RGBAIntegerFormat:RGBAIntegerFormat,RGBA_ASTC_10x10_Format:RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format:RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format:RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format:RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format:RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format:RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format:RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format:RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format:RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format:RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format:RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format:RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format:RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format:RGBA_ASTC_8x8_Format,RGBA_BPTC_Format:RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format:RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format:RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format:RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format:RGBA_S3TC_DXT5_Format,RGBDEncoding:RGBDEncoding,RGBEEncoding:RGBEEncoding,RGBEFormat:RGBEFormat,RGBFormat:RGBFormat,RGBIntegerFormat:RGBIntegerFormat,RGBM16Encoding:RGBM16Encoding,RGBM7Encoding:RGBM7Encoding,RGB_ETC1_Format:RGB_ETC1_Format,RGB_ETC2_Format:RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format:RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format:RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:RGB_S3TC_DXT1_Format,RGFormat:RGFormat,RGIntegerFormat:RGIntegerFormat,RawShaderMaterial:RawShaderMaterial,Ray:Ray,Raycaster:Raycaster,RectAreaLight:RectAreaLight,RedFormat:RedFormat,RedIntegerFormat:RedIntegerFormat,ReinhardToneMapping:ReinhardToneMapping,RepeatWrapping:RepeatWrapping$1,ReplaceStencilOp:ReplaceStencilOp,ReverseSubtractEquation:ReverseSubtractEquation,RingBufferGeometry:RingGeometry,RingGeometry:RingGeometry,SRGB8_ALPHA8_ASTC_10x10_Format:SRGB8_ALPHA8_ASTC_10x10_Format,SRGB8_ALPHA8_ASTC_10x5_Format:SRGB8_ALPHA8_ASTC_10x5_Format,SRGB8_ALPHA8_ASTC_10x6_Format:SRGB8_ALPHA8_ASTC_10x6_Format,SRGB8_ALPHA8_ASTC_10x8_Format:SRGB8_ALPHA8_ASTC_10x8_Format,SRGB8_ALPHA8_ASTC_12x10_Format:SRGB8_ALPHA8_ASTC_12x10_Format,SRGB8_ALPHA8_ASTC_12x12_Format:SRGB8_ALPHA8_ASTC_12x12_Format,SRGB8_ALPHA8_ASTC_4x4_Format:SRGB8_ALPHA8_ASTC_4x4_Format,SRGB8_ALPHA8_ASTC_5x4_Format:SRGB8_ALPHA8_ASTC_5x4_Format,SRGB8_ALPHA8_ASTC_5x5_Format:SRGB8_ALPHA8_ASTC_5x5_Format,SRGB8_ALPHA8_ASTC_6x5_Format:SRGB8_ALPHA8_ASTC_6x5_Format,SRGB8_ALPHA8_ASTC_6x6_Format:SRGB8_ALPHA8_ASTC_6x6_Format,SRGB8_ALPHA8_ASTC_8x5_Format:SRGB8_ALPHA8_ASTC_8x5_Format,SRGB8_ALPHA8_ASTC_8x6_Format:SRGB8_ALPHA8_ASTC_8x6_Format,SRGB8_ALPHA8_ASTC_8x8_Format:SRGB8_ALPHA8_ASTC_8x8_Format,Scene:Scene$2,SceneUtils:SceneUtils,ShaderChunk:ShaderChunk,ShaderLib:ShaderLib,ShaderMaterial:ShaderMaterial,ShadowMaterial:ShadowMaterial,Shape:Shape,ShapeBufferGeometry:ShapeGeometry,ShapeGeometry:ShapeGeometry,ShapePath:ShapePath,ShapeUtils:ShapeUtils,ShortType:ShortType,Skeleton:Skeleton,SkeletonHelper:SkeletonHelper,SkinnedMesh:SkinnedMesh,SmoothShading:SmoothShading,Sphere:Sphere$1,SphereBufferGeometry:SphereGeometry,SphereGeometry:SphereGeometry,Spherical:Spherical,SphericalHarmonics3:SphericalHarmonics3,SplineCurve:SplineCurve,SpotLight:SpotLight$1,SpotLightHelper:SpotLightHelper,Sprite:Sprite$1,SpriteMaterial:SpriteMaterial,SrcAlphaFactor:SrcAlphaFactor,SrcAlphaSaturateFactor:SrcAlphaSaturateFactor,SrcColorFactor:SrcColorFactor,StaticCopyUsage:StaticCopyUsage,StaticDrawUsage:StaticDrawUsage,StaticReadUsage:StaticReadUsage,StereoCamera:StereoCamera,StreamCopyUsage:StreamCopyUsage,StreamDrawUsage:StreamDrawUsage,StreamReadUsage:StreamReadUsage,StringKeyframeTrack:StringKeyframeTrack,SubtractEquation:SubtractEquation,SubtractiveBlending:SubtractiveBlending,TOUCH:TOUCH,TangentSpaceNormalMap:TangentSpaceNormalMap,TetrahedronBufferGeometry:TetrahedronGeometry,TetrahedronGeometry:TetrahedronGeometry,TextBufferGeometry:TextGeometry,TextGeometry:TextGeometry,Texture:Texture,TextureLoader:TextureLoader,TorusBufferGeometry:TorusGeometry,TorusGeometry:TorusGeometry,TorusKnotBufferGeometry:TorusKnotGeometry,TorusKnotGeometry:TorusKnotGeometry,Triangle:Triangle,TriangleFanDrawMode:TriangleFanDrawMode,TriangleStripDrawMode:TriangleStripDrawMode,TrianglesDrawMode:TrianglesDrawMode,TubeBufferGeometry:TubeGeometry,TubeGeometry:TubeGeometry,UVMapping:UVMapping,Uint16Attribute:Uint16Attribute,Uint16BufferAttribute:Uint16BufferAttribute,Uint32Attribute:Uint32Attribute,Uint32BufferAttribute:Uint32BufferAttribute,Uint8Attribute:Uint8Attribute,Uint8BufferAttribute:Uint8BufferAttribute,Uint8ClampedAttribute:Uint8ClampedAttribute,Uint8ClampedBufferAttribute:Uint8ClampedBufferAttribute,Uniform:Uniform,UniformsLib:UniformsLib,UniformsUtils:UniformsUtils,UnsignedByteType:UnsignedByteType,UnsignedInt248Type:UnsignedInt248Type,UnsignedIntType:UnsignedIntType,UnsignedShort4444Type:UnsignedShort4444Type,UnsignedShort5551Type:UnsignedShort5551Type,UnsignedShort565Type:UnsignedShort565Type,UnsignedShortType:UnsignedShortType,VSMShadowMap:VSMShadowMap,Vector2:Vector2,Vector3:Vector3$1,Vector4:Vector4,VectorKeyframeTrack:VectorKeyframeTrack,Vertex:Vertex,VertexColors:VertexColors,VideoTexture:VideoTexture,WebGL1Renderer:WebGL1Renderer,WebGLCubeRenderTarget:WebGLCubeRenderTarget,WebGLMultisampleRenderTarget:WebGLMultisampleRenderTarget,WebGLRenderTarget:WebGLRenderTarget,WebGLRenderTargetCube:WebGLRenderTargetCube,WebGLRenderer:WebGLRenderer,WebGLUtils:WebGLUtils,WireframeGeometry:WireframeGeometry,WireframeHelper:WireframeHelper,WrapAroundEnding:WrapAroundEnding,XHRLoader:XHRLoader,ZeroCurvatureEnding:ZeroCurvatureEnding,ZeroFactor:ZeroFactor,ZeroSlopeEnding:ZeroSlopeEnding,ZeroStencilOp:ZeroStencilOp,sRGBEncoding:sRGBEncoding});var PREFIX = '[Mage]';
53546
+ var DEPRECATED = '[DEPRECATED]';
53546
53547
  var DEPRECATIONS = {
53547
- SCRIPTS_CREATE: "".concat(PREFIX, " [DEPRECATED] Scripts.create is deprecated, use Scripts.register instead. Will be removed in next major release."),
53548
- ELEMENT_SET_TEXTURE_MAP: "".concat(PREFIX, " [DEPRECATED] Element.setTextureMap is deprecated, use Element.setTexture() instead. Will be removed in next major release.")
53548
+ PARTICLES_ADD_PARTICLE_EMITTER: "".concat(PREFIX, " ").concat(DEPRECATED, " Particles.addParticleEmitter is deprecated, use Particles.add instead. Will be removed in the next major release"),
53549
+ MODELS_GETMODEL: "".concat(PREFIX, " ").concat(DEPRECATED, " Models.getModel is deprecated, use Models.get instead. Will be removed in next major release"),
53550
+ SCRIPTS_CREATE: "".concat(PREFIX, " ").concat(DEPRECATED, " Scripts.create is deprecated, use Scripts.register instead. Will be removed in next major release."),
53551
+ ELEMENT_SET_TEXTURE_MAP: "".concat(PREFIX, " ").concat(DEPRECATED, " Element.setTextureMap is deprecated, use Element.setTexture() instead. Will be removed in next major release.")
53549
53552
  };
53550
53553
  var ONCREATE_NOT_AVAILABLE = "".concat(PREFIX, " Your scene needs a onCreate method.");
53551
53554
  var PATH_NOT_FOUND = "".concat(PREFIX, " can't find requested path");
@@ -53560,10 +53563,11 @@ var METHOD_NOT_SUPPORTED = "".concat(PREFIX, " This method is not supported.");
53560
53563
  var ANIMATION_NOT_FOUND = "".concat(PREFIX, " Required animation can't be found.");
53561
53564
  var ANIMATION_HANDLER_NOT_FOUND = "".concat(PREFIX, " AnimationHander hasn't been defined yet.");
53562
53565
  var ELEMENT_NOT_SET$1 = "".concat(PREFIX, " Body hasn't been defined yet.");
53563
- var ELEMENT_NAME_NOT_PROVIDED = "".concat(PREFIX, " Desired element name wasn't provided.");
53564
53566
  var ELEMENT_SET_COLOR_MISSING_COLOR = "".concat(PREFIX, " Can't set color for this element, missing color");
53565
53567
  var ELEMENT_MATERIAL_NO_SUPPORT_FOR_TEXTURE = "".concat(PREFIX, " This element's material does not support texture: ");
53568
+ var ENTITY_NOT_SET = "".concat(PREFIX, " This entity does not have a body.");
53566
53569
  var ENTITY_TYPE_NOT_ALLOWED = "".concat(PREFIX, " The desired Entity type is not allowed.");
53570
+ var ENTITY_CANT_ADD_NOT_ENTITY = "".concat(PREFIX, " Entity.add requires an Entity.");
53567
53571
  var ERROR_LOADING_TEXTURE = "".concat(PREFIX, " Error while loading texture:");
53568
53572
  var TAG_CANT_BE_REMOVED = "".concat(PREFIX, " The default tag can't be removed.");
53569
53573
  var TAG_ALREADY_EXISTS = "".concat(PREFIX, " The following tag has already been added: ");
@@ -53576,7 +53580,6 @@ var EFFECT_COULD_NOT_BE_CREATED = "".concat(PREFIX, " Could not create requeste
53576
53580
  var EFFECT_UNAVAILABLE = "".concat(PREFIX, " Requested effect is not available.");
53577
53581
  var SCRIPT_NOT_FOUND = "".concat(PREFIX, " Could not find desired script.");
53578
53582
  var KEYBOARD_COMBO_ALREADY_REGISTERED = "".concat(PREFIX, " Keyboard combo already registered.");
53579
- var KEYBOARD_COMBO_IS_INVALID = "".concat(PREFIX, " Keyboard combo is not valid.");
53580
53583
  var PHYSICS_ELEMENT_CANT_BE_REMOVED = "".concat(PREFIX, " This element can't be removed from physics world.");
53581
53584
  var PHYSICS_ELEMENT_ALREADY_STORED = "".concat(PREFIX, " This element has already been added to the world.");
53582
53585
  var ASSETS_AUDIO_LOAD_FAIL = "".concat(PREFIX, " Could not load audio.");
@@ -53592,9 +53595,24 @@ var LIGHT_HOLDER_MODEL_NOT_FOUND = "".concat(PREFIX, " This light holder model c
53592
53595
  }
53593
53596
  }, {
53594
53597
  key: "__hasStarted",
53595
- value: function __hasStarted(flag) {
53598
+ value: function __hasStarted() {
53599
+ return this.hasStarted;
53600
+ }
53601
+ }, {
53602
+ key: "__isDisposed",
53603
+ value: function __isDisposed() {
53604
+ return this.isDisposed;
53605
+ }
53606
+ }, {
53607
+ key: "__setStartedFlag",
53608
+ value: function __setStartedFlag(flag) {
53596
53609
  this.hasStarted = flag;
53597
53610
  }
53611
+ }, {
53612
+ key: "__setDisposedFlag",
53613
+ value: function __setDisposedFlag(flag) {
53614
+ this.isDisposed = flag;
53615
+ }
53598
53616
  }]);
53599
53617
 
53600
53618
  function BaseScript(name) {
@@ -54175,30 +54193,46 @@ if (typeof window !== 'undefined') {
54175
54193
  keyup: true,
54176
54194
  keydown: true
54177
54195
  };
54178
- var COMBINATION_DIVIDER = '+';
54196
+ var KEY_PRESS = 'keyPress';
54197
+ var KEY_DOWN = 'keyDown';
54198
+ var KEY_UP = 'keyUp';
54199
+
54200
+ var Keyboard = /*#__PURE__*/function (_EventDispatcher) {
54201
+ _inherits(Keyboard, _EventDispatcher);
54202
+
54203
+ var _super = _createSuper(Keyboard);
54179
54204
 
54180
- var Keyboard = /*#__PURE__*/function () {
54181
54205
  function Keyboard() {
54182
- var _this = this;
54206
+ var _this;
54183
54207
 
54184
54208
  _classCallCheck(this, Keyboard);
54185
54209
 
54186
- _defineProperty$1(this, "handler", function (event, handler) {
54187
- if (!_this.enabled) return;
54210
+ _this = _super.call(this);
54188
54211
 
54189
- _this.listener(event, handler); // this stops propagation and deafult OS handling for events like cmd + s, cmd + r
54212
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeydown", function (event) {
54213
+ _this.dispatchEvent({
54214
+ type: KEY_DOWN,
54215
+ event: event
54216
+ });
54217
+ });
54190
54218
 
54219
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeyup", function (event) {
54220
+ _this.dispatchEvent({
54221
+ type: KEY_UP,
54222
+ event: event
54223
+ });
54224
+ });
54191
54225
 
54192
- return false;
54226
+ _defineProperty$1(_assertThisInitialized(_this), "handleKeypress", function (event) {
54227
+ _this.dispatchEvent({
54228
+ type: KEY_PRESS,
54229
+ event: event
54230
+ });
54193
54231
  });
54194
54232
 
54195
- this.keys = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'l', 'k', 'j', 'h', 'g', 'f', 'd', 's', 'a', 'z', 'x', 'c', 'v', 'b', 'n', 'm'];
54196
- this.specials = ['esc', 'escape', 'enter', 'space'];
54197
- this.symbols = [];
54198
- this.numbers = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
54199
- this.combos = [].concat(_toConsumableArray(this.keys), _toConsumableArray(this.numbers), _toConsumableArray(this.specials), _toConsumableArray(this.symbols));
54200
- this.enabled = false;
54201
- this.listener = undefined;
54233
+ _this.combos = [];
54234
+ _this.enabled = false;
54235
+ return _this;
54202
54236
  }
54203
54237
 
54204
54238
  _createClass(Keyboard, [{
@@ -54211,63 +54245,34 @@ var Keyboard = /*#__PURE__*/function () {
54211
54245
  }
54212
54246
 
54213
54247
  this.combos.push(combo);
54214
- hotkeys(combo, DEFAULT_OPTIONS, handler || this.handler);
54215
- }
54216
- }
54217
- }, {
54218
- key: "registerCombination",
54219
- value: function registerCombination() {
54220
- var combo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
54221
- var handler = arguments.length > 1 ? arguments[1] : undefined;
54222
-
54223
- if (combo instanceof Array && combo.length > 1) {
54224
- this.register(combo.join(COMBINATION_DIVIDER), handler);
54225
- } else {
54226
- console.warn(KEYBOARD_COMBO_IS_INVALID, combo);
54248
+ hotkeys(combo, DEFAULT_OPTIONS, handler);
54227
54249
  }
54228
54250
  }
54229
54251
  }, {
54230
54252
  key: "enable",
54231
54253
  value: function enable() {
54232
- var _this2 = this;
54233
-
54234
- var cb = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (f) {
54235
- return f;
54236
- };
54237
54254
  this.enabled = true;
54238
- this.listener = cb;
54239
- this.combos.forEach(function (combo) {
54240
- hotkeys(combo, DEFAULT_OPTIONS, _this2.handler);
54241
- });
54255
+ window.addEventListener(KEY_DOWN, this.handleKeydown.bind(this));
54256
+ window.addEventListener(KEY_UP, this.handleKeyup.bind(this));
54257
+ window.addEventListener(KEY_PRESS, this.handleKeypress.bind(this));
54242
54258
  }
54243
54259
  }, {
54244
54260
  key: "disable",
54245
54261
  value: function disable() {
54246
54262
  this.enabled = false;
54247
- this.listener = undefined;
54248
- this.combos.forEach(function (combo) {
54249
- hotkeys.unbind(combo);
54250
- });
54263
+ window.removeEventListener(KEY_DOWN, this.handleKeydown.bind(this));
54264
+ window.removeEventListener(KEY_UP, this.handleKeyup.bind(this));
54265
+ window.removeEventListener(KEY_PRESS, this.handleKeypress.bind(this));
54251
54266
  }
54252
54267
  }, {
54253
54268
  key: "isPressed",
54254
54269
  value: function isPressed(key) {
54255
54270
  return hotkeys.isPressed(key);
54256
54271
  }
54257
- }], [{
54258
- key: "KEYDOWN",
54259
- get: function get() {
54260
- return 'keydown';
54261
- }
54262
- }, {
54263
- key: "KEYUP",
54264
- get: function get() {
54265
- return 'keyup';
54266
- }
54267
54272
  }]);
54268
54273
 
54269
54274
  return Keyboard;
54270
- }();var SHADOW_TYPES = {
54275
+ }(EventDispatcher);var SHADOW_TYPES = {
54271
54276
  BASIC: 'BASIC',
54272
54277
  SOFT: 'SOFT',
54273
54278
  HARD: 'HARD'
@@ -54320,13 +54325,15 @@ var Config = /*#__PURE__*/function () {
54320
54325
  function Config() {
54321
54326
  _classCallCheck(this, Config);
54322
54327
 
54323
- getWindow();
54324
54328
  this.default = {
54325
54329
  tests: [],
54326
54330
  screen: {
54327
54331
  frameRate: 60,
54328
54332
  alpha: true
54329
54333
  },
54334
+ postprocessing: {
54335
+ enabled: false
54336
+ },
54330
54337
  fog: {
54331
54338
  enabled: false,
54332
54339
  density: 0,
@@ -54427,8 +54434,8 @@ var Config = /*#__PURE__*/function () {
54427
54434
  };
54428
54435
  }
54429
54436
  }, {
54430
- key: "getDefaults",
54431
- value: function getDefaults() {
54437
+ key: "getScreenDefaults",
54438
+ value: function getScreenDefaults() {
54432
54439
  return {
54433
54440
  h: DEFAULT_HEIGHT$1,
54434
54441
  w: DEFAULT_WIDTH,
@@ -54438,7 +54445,7 @@ var Config = /*#__PURE__*/function () {
54438
54445
  }, {
54439
54446
  key: "screen",
54440
54447
  value: function screen() {
54441
- var _ref = this.getContainerSize() || this.getWindowSize() || this.getDefaults(),
54448
+ var _ref = this.getContainerSize() || this.getWindowSize() || this.getScreenDefaults(),
54442
54449
  h = _ref.h,
54443
54450
  w = _ref.w,
54444
54451
  ratio = _ref.ratio;
@@ -54451,6 +54458,11 @@ var Config = /*#__PURE__*/function () {
54451
54458
  });
54452
54459
  return this.config.screen;
54453
54460
  }
54461
+ }, {
54462
+ key: "postprocessing",
54463
+ value: function postprocessing() {
54464
+ return this.config.postprocessing;
54465
+ }
54454
54466
  }, {
54455
54467
  key: "ui",
54456
54468
  value: function ui() {
@@ -54483,9 +54495,8 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
54483
54495
  });
54484
54496
 
54485
54497
  _defineProperty$1(this, "forEach", function (callback) {
54486
- var keys = Object.keys(_this.reality);
54487
- keys.forEach(function (k) {
54488
- return callback(_this.reality[k]);
54498
+ Object.keys(_this.reality).forEach(function (k) {
54499
+ return callback(_this.reality[k], k);
54489
54500
  });
54490
54501
  });
54491
54502
 
@@ -54493,14 +54504,14 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
54493
54504
  var keys = Object.keys(_this.reality);
54494
54505
  return new Promise(function (resolve) {
54495
54506
  Promise.all(keys.map(function (k) {
54496
- return callback(_this.reality[k]);
54507
+ return callback(_this.reality[k], k);
54497
54508
  })).then(resolve);
54498
54509
  });
54499
54510
  });
54500
54511
 
54501
54512
  _defineProperty$1(this, "bigfreeze", function () {
54502
54513
  _this.forEach(function (o) {
54503
- return o.dispose();
54514
+ o && o.dispose && o.dispose();
54504
54515
  });
54505
54516
 
54506
54517
  _this.reset();
@@ -54917,8 +54928,12 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
54917
54928
  }
54918
54929
  };var PI = Math.PI;
54919
54930
  var PI_2$1 = PI / 2;
54920
- var pickRandom = function pickRandom(list) {
54921
- return list.length && list[Math.floor(Math.random() * list.length)];
54931
+ var identity = function identity(a) {
54932
+ return a;
54933
+ };
54934
+ var pickRandom = function pickRandom() {
54935
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
54936
+ return list[Math.floor(Math.random() * list.length)];
54922
54937
  };
54923
54938
  var degToRad = function degToRad(angle) {
54924
54939
  return angle * (PI / 180);
@@ -55045,7 +55060,7 @@ var smoothDampAngle = function smoothDampAngle(current, target, currentVelocity,
55045
55060
  var dt = arguments.length > 5 ? arguments[5] : undefined;
55046
55061
  target = current + deltaAngle(current, target);
55047
55062
  return smoothDamp(current, target, currentVelocity, smoothTime, maxSpeed, dt);
55048
- };var math=/*#__PURE__*/Object.freeze({__proto__:null,PI:PI,PI_2:PI_2$1,pickRandom:pickRandom,degToRad:degToRad,getProportion:getProportion,clamp:clamp,isWithin:isWithin,randomIntFromInterval:randomIntFromInterval,getDistance:getDistance,findPointBetweenAtDistance:findPointBetweenAtDistance,lerpVectors:lerpVectors,lerp:lerp,scaleVector:scaleVector,getSphereVolume:getSphereVolume,repeat:repeat,deltaAngle:deltaAngle,smoothDamp:smoothDamp,smoothDampAngle:smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
55063
+ };var math=/*#__PURE__*/Object.freeze({__proto__:null,PI:PI,PI_2:PI_2$1,identity:identity,pickRandom:pickRandom,degToRad:degToRad,getProportion:getProportion,clamp:clamp,isWithin:isWithin,randomIntFromInterval:randomIntFromInterval,getDistance:getDistance,findPointBetweenAtDistance:findPointBetweenAtDistance,lerpVectors:lerpVectors,lerp:lerp,scaleVector:scaleVector,getSphereVolume:getSphereVolume,repeat:repeat,deltaAngle:deltaAngle,smoothDamp:smoothDamp,smoothDampAngle:smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
55049
55064
  var TYPES = {
55050
55065
  BOX: 'BOX',
55051
55066
  SPHERE: 'SPHERE',
@@ -55310,7 +55325,7 @@ var convertAmmoVector = function convertAmmoVector(_ref2) {
55310
55325
  };
55311
55326
  };var utils=/*#__PURE__*/Object.freeze({__proto__:null,DEFAULT_DESCRIPTION:DEFAULT_DESCRIPTION$1,mapColliderTypeToAddEvent:mapColliderTypeToAddEvent$1,extractBoundingBox:extractBoundingBox,extractBiggestBoundingBox:extractBiggestBoundingBox,extractBoundingSphere:extractBoundingSphere,extractBiggestBoundingSphere:extractBiggestBoundingSphere,parseBoundingBoxSize:parseBoundingBoxSize,extractPositionAndQuaternion:extractPositionAndQuaternion$1,extractBoxDescription:extractBoxDescription,extractSphereDescription:extractSphereDescription,getBoxDescriptionForElement:getBoxDescriptionForElement$1,getSphereDescriptionForElement:getSphereDescriptionForElement,mapColliderTypeToDescription:mapColliderTypeToDescription$1,iterateGeometries:iterateGeometries$1,convertAmmoVector:convertAmmoVector});var getHostURL = function getHostURL() {
55312
55327
  return "".concat(document.location.protocol, "//").concat(document.location.host);
55313
- };var _excluded$5 = ["uuid"];
55328
+ };var _excluded$7 = ["uuid"];
55314
55329
  var COLLIDER_TYPES = COLLIDER_TYPES$1;
55315
55330
  var getBoxDescriptionForElement = getBoxDescriptionForElement$1,
55316
55331
  extractPositionAndQuaternion = extractPositionAndQuaternion$1,
@@ -55376,7 +55391,7 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
55376
55391
 
55377
55392
  _defineProperty$1(_assertThisInitialized(_this), "handleBodyUpdate", function (_ref3) {
55378
55393
  var uuid = _ref3.uuid,
55379
- data = _objectWithoutProperties(_ref3, _excluded$5);
55394
+ data = _objectWithoutProperties(_ref3, _excluded$7);
55380
55395
 
55381
55396
  var element = Universe$1.getByUUID(uuid);
55382
55397
 
@@ -55505,17 +55520,6 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
55505
55520
  }
55506
55521
  });
55507
55522
 
55508
- _defineProperty$1(_assertThisInitialized(_this), "disposeElement", function (element) {
55509
- if (Config$1.physics().enabled) {
55510
- var uuid = element.uuid();
55511
-
55512
- _this.worker.postMessage({
55513
- event: PHYSICS_EVENTS.ELEMENT.DISPOSE,
55514
- uuid: uuid
55515
- });
55516
- }
55517
- });
55518
-
55519
55523
  _defineProperty$1(_assertThisInitialized(_this), "explosion", function (element, strength, radius) {
55520
55524
  if (Config$1.physics().enabled) {
55521
55525
  var uuid = element.uuid();
@@ -55778,16 +55782,6 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
55778
55782
  _this.resize(w, h);
55779
55783
  });
55780
55784
 
55781
- _defineProperty$1(this, "render", function () {
55782
- _this.renderer.setClearColor(_this.clearColor, _this.alpha);
55783
-
55784
- _this.renderer.clear();
55785
-
55786
- _this.renderer.setRenderTarget(null);
55787
-
55788
- _this.renderer.render(_this.scene, _this.camera.getBody());
55789
- });
55790
-
55791
55785
  _defineProperty$1(this, "onPhysicsUpdate", function (_ref) {
55792
55786
  var dt = _ref.dt;
55793
55787
  Universe$1.onPhysicsUpdate(dt);
@@ -56018,7 +56012,8 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
56018
56012
  var container = Config$1.container();
56019
56013
  this.renderer = new WebGLRenderer({
56020
56014
  alpha: alpha,
56021
- antialias: antialias
56015
+ antialias: antialias,
56016
+ powerPreference: 'high-performance'
56022
56017
  });
56023
56018
 
56024
56019
  if (shadows) {
@@ -56054,6 +56049,14 @@ var DEFAULT_TAG = 'all';var Scene = /*#__PURE__*/function () {
56054
56049
  this.camera.getBody().updateProjectionMatrix();
56055
56050
  this.renderer.setSize(width, height);
56056
56051
  }
56052
+ }, {
56053
+ key: "render",
56054
+ value: function render() {
56055
+ this.renderer.setClearColor(this.clearColor, this.alpha);
56056
+ this.renderer.clear();
56057
+ this.renderer.setRenderTarget(null);
56058
+ this.renderer.render(this.scene, this.camera.getBody());
56059
+ }
56057
56060
  }, {
56058
56061
  key: "setFog",
56059
56062
  value: function setFog(color, density) {
@@ -56283,11 +56286,9 @@ var Features = /*#__PURE__*/function () {
56283
56286
  value: function setUpPolyfills() {
56284
56287
  var frameRate = Config$1.screen().frameRate;
56285
56288
 
56286
- window.requestNextFrame = function () {
56287
- return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
56288
- window.setTimeout(callback, 1000 / frameRate);
56289
- };
56290
- }();
56289
+ window.requestNextFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
56290
+ window.setTimeout(callback, 1000 / frameRate);
56291
+ };
56291
56292
  }
56292
56293
  }, {
56293
56294
  key: "isFeatureSupported",
@@ -57203,7 +57204,7 @@ function applyMiddleware() {
57203
57204
 
57204
57205
  var thunk = createThunkMiddleware();
57205
57206
  thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
57206
- var version = "3.17.4";
57207
+ var version = "3.17.7";
57207
57208
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57208
57209
  var main = "dist/mage.js";
57209
57210
  var author$1 = {
@@ -57817,10 +57818,6 @@ var Gamepad = /*#__PURE__*/function (_EventDispatcher) {
57817
57818
 
57818
57819
  return Gamepad;
57819
57820
  }(EventDispatcher);var _INPUT_EVENTS;
57820
- var KEY_PRESS = 'keyPress';
57821
- var KEY_DOWN = 'keyDown';
57822
- var KEY_UP = 'keyUp';
57823
- var INPUT_EVENTS_LIST = [KEY_PRESS, KEY_DOWN, KEY_UP, MOUSE_DOWN, MOUSE_UP, MOUSE_DOWN, ELEMENT_CLICK, ELEMENT_DESELECT, GAMEPAD_CONNECTED_EVENT, GAMEPAD_DISCONNECTED_EVENT, BUTTON_PRESSED_EVENT, BUTTON_RELEASED_EVENT, AXIS_CHANGE_EVENT];
57824
57821
  var INPUT_EVENTS = (_INPUT_EVENTS = {
57825
57822
  KEY_PRESS: KEY_PRESS,
57826
57823
  KEY_DOWN: KEY_DOWN,
@@ -57844,27 +57841,6 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57844
57841
  _this.dispatchEvent(event);
57845
57842
  });
57846
57843
 
57847
- _defineProperty$1(_assertThisInitialized(_this), "handleKeyBoardEvent", function (event, handler) {
57848
- if (event.type === Keyboard.KEYDOWN) {
57849
- _this.dispatchEvent({
57850
- type: KEY_DOWN,
57851
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57852
- });
57853
- }
57854
-
57855
- if (event.type === Keyboard.KEYUP) {
57856
- _this.dispatchEvent({
57857
- type: KEY_UP,
57858
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57859
- });
57860
- }
57861
-
57862
- _this.dispatchEvent({
57863
- type: KEY_PRESS,
57864
- event: _objectSpread2$1(_objectSpread2$1({}, event), handler)
57865
- });
57866
- });
57867
-
57868
57844
  _this.enabled = false;
57869
57845
  return _this;
57870
57846
  }
@@ -57915,7 +57891,9 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57915
57891
  key: "enableKeyboard",
57916
57892
  value: function enableKeyboard() {
57917
57893
  dispatch(keyboardEnabled());
57918
- this.keyboard.enable(this.handleKeyBoardEvent.bind(this));
57894
+ this.keyboard.enable();
57895
+ this.keyboard.addEventListener(KEY_DOWN, this.propagate.bind(this));
57896
+ this.keyboard.addEventListener(KEY_UP, this.propagate.bind(this));
57919
57897
  }
57920
57898
  }, {
57921
57899
  key: "enableMouse",
@@ -57933,6 +57911,8 @@ var Input = /*#__PURE__*/function (_EventDispatcher) {
57933
57911
  value: function disableKeyboard() {
57934
57912
  dispatch(keyboardDisabled());
57935
57913
  this.keyboard.disable();
57914
+ this.keyboard.removeEventListener(KEY_DOWN, this.propagate.bind(this));
57915
+ this.keyboard.removeEventListener(KEY_UP, this.propagate.bind(this));
57936
57916
  this.keyboard = undefined;
57937
57917
  }
57938
57918
  }, {
@@ -58490,7 +58470,7 @@ if (!self.fetch) {
58490
58470
  self.Headers = Headers;
58491
58471
  self.Request = Request;
58492
58472
  self.Response = Response;
58493
- }var _excluded$4 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug"];
58473
+ }var _excluded$6 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug"];
58494
58474
 
58495
58475
  var BaseCar = /*#__PURE__*/function (_BaseScript) {
58496
58476
  _inherits(BaseCar, _BaseScript);
@@ -58516,7 +58496,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
58516
58496
  _options$leftKey = options.leftKey,
58517
58497
  leftKey = _options$leftKey === void 0 ? 'a' : _options$leftKey;
58518
58498
  options.debug;
58519
- var physicsOptions = _objectWithoutProperties(options, _excluded$4);
58499
+ var physicsOptions = _objectWithoutProperties(options, _excluded$6);
58520
58500
 
58521
58501
  this.car = element;
58522
58502
  this.wheels = wheels;
@@ -58740,1552 +58720,1646 @@ var Scripts = /*#__PURE__*/function () {
58740
58720
 
58741
58721
  return Scripts;
58742
58722
  }();
58743
- var Scripts$1 = new Scripts();var Entity = /*#__PURE__*/function (_EventDispatcher) {
58744
- _inherits(Entity, _EventDispatcher);
58745
-
58746
- var _super = _createSuper(Entity);
58747
-
58748
- function Entity(_ref) {
58749
- var _this;
58750
-
58751
- var _ref$serializable = _ref.serializable,
58752
- serializable = _ref$serializable === void 0 ? true : _ref$serializable,
58753
- _ref$tag = _ref.tag,
58754
- tag = _ref$tag === void 0 ? '' : _ref$tag,
58755
- _ref$tags = _ref.tags,
58756
- tags = _ref$tags === void 0 ? [] : _ref$tags;
58757
-
58758
- _classCallCheck(this, Entity);
58759
-
58760
- _this = _super.call(this);
58761
-
58762
- _defineProperty$1(_assertThisInitialized(_this), "addTag", function (tagName) {
58763
- if (!tagName) return;
58723
+ var Scripts$1 = new Scripts();var inverseProjectionMatrix = new Matrix4();
58764
58724
 
58765
- if (!_this.hasTag(tagName)) {
58766
- _this.tags.push(tagName);
58725
+ var Frustum = /*#__PURE__*/function () {
58726
+ function Frustum(data) {
58727
+ _classCallCheck(this, Frustum);
58767
58728
 
58768
- return true;
58769
- } else {
58770
- console.log(TAG_ALREADY_EXISTS, tagName);
58771
- return false;
58772
- }
58773
- });
58729
+ data = data || {};
58730
+ this.vertices = {
58731
+ near: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()],
58732
+ far: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()]
58733
+ };
58774
58734
 
58775
- _defineProperty$1(_assertThisInitialized(_this), "hasStateMachine", function () {
58776
- return !!_this.stateMachine;
58777
- });
58735
+ if (data.projectionMatrix !== undefined) {
58736
+ this.setFromProjectionMatrix(data.projectionMatrix, data.maxFar || 10000);
58737
+ }
58738
+ }
58778
58739
 
58779
- _defineProperty$1(_assertThisInitialized(_this), "hasScripts", function () {
58780
- return _this.scripts.length > 0;
58781
- });
58740
+ _createClass(Frustum, [{
58741
+ key: "setFromProjectionMatrix",
58742
+ value: function setFromProjectionMatrix(projectionMatrix, maxFar) {
58743
+ var isOrthographic = projectionMatrix.elements[2 * 4 + 3] === 0;
58744
+ inverseProjectionMatrix.copy(projectionMatrix).invert(); // 3 --- 0 vertices.near/far order
58745
+ // | |
58746
+ // 2 --- 1
58747
+ // clip space spans from [-1, 1]
58782
58748
 
58783
- _defineProperty$1(_assertThisInitialized(_this), "parseScripts", function (list, options, enabled) {
58784
- return list.map(function (script, i) {
58785
- return {
58786
- script: script,
58787
- name: script.getName(),
58788
- enabled: enabled,
58789
- options: options[i]
58790
- };
58749
+ this.vertices.near[0].set(1, 1, -1);
58750
+ this.vertices.near[1].set(1, -1, -1);
58751
+ this.vertices.near[2].set(-1, -1, -1);
58752
+ this.vertices.near[3].set(-1, 1, -1);
58753
+ this.vertices.near.forEach(function (v) {
58754
+ v.applyMatrix4(inverseProjectionMatrix);
58791
58755
  });
58792
- });
58756
+ this.vertices.far[0].set(1, 1, 1);
58757
+ this.vertices.far[1].set(1, -1, 1);
58758
+ this.vertices.far[2].set(-1, -1, 1);
58759
+ this.vertices.far[3].set(-1, 1, 1);
58760
+ this.vertices.far.forEach(function (v) {
58761
+ v.applyMatrix4(inverseProjectionMatrix);
58762
+ var absZ = Math.abs(v.z);
58793
58763
 
58794
- _defineProperty$1(_assertThisInitialized(_this), "isMesh", function () {
58795
- return _this.getEntityType() === ENTITY_TYPES.MESH;
58796
- });
58764
+ if (isOrthographic) {
58765
+ v.z *= Math.min(maxFar / absZ, 1.0);
58766
+ } else {
58767
+ v.multiplyScalar(Math.min(maxFar / absZ, 1.0));
58768
+ }
58769
+ });
58770
+ return this.vertices;
58771
+ }
58772
+ }, {
58773
+ key: "split",
58774
+ value: function split(breaks, target) {
58775
+ while (breaks.length > target.length) {
58776
+ target.push(new Frustum());
58777
+ }
58797
58778
 
58798
- _defineProperty$1(_assertThisInitialized(_this), "isModel", function () {
58799
- return _this.getEntityType() === ENTITY_TYPES.MODEL;
58800
- });
58779
+ target.length = breaks.length;
58801
58780
 
58802
- _defineProperty$1(_assertThisInitialized(_this), "isSprite", function () {
58803
- return _this.getEntityType() === ENTITY_TYPES.SPRITE;
58804
- });
58781
+ for (var i = 0; i < breaks.length; i++) {
58782
+ var cascade = target[i];
58805
58783
 
58806
- _defineProperty$1(_assertThisInitialized(_this), "isLight", function () {
58807
- return Object.values(ENTITY_TYPES.LIGHT).includes(_this.getEntityType());
58808
- });
58784
+ if (i === 0) {
58785
+ for (var j = 0; j < 4; j++) {
58786
+ cascade.vertices.near[j].copy(this.vertices.near[j]);
58787
+ }
58788
+ } else {
58789
+ for (var _j = 0; _j < 4; _j++) {
58790
+ cascade.vertices.near[_j].lerpVectors(this.vertices.near[_j], this.vertices.far[_j], breaks[i - 1]);
58791
+ }
58792
+ }
58809
58793
 
58810
- _defineProperty$1(_assertThisInitialized(_this), "isHelper", function () {
58811
- return Object.values(ENTITY_TYPES.HELPER).includes(_this.getEntityType());
58812
- });
58794
+ if (i === breaks - 1) {
58795
+ for (var _j2 = 0; _j2 < 4; _j2++) {
58796
+ cascade.vertices.far[_j2].copy(this.vertices.far[_j2]);
58797
+ }
58798
+ } else {
58799
+ for (var _j3 = 0; _j3 < 4; _j3++) {
58800
+ cascade.vertices.far[_j3].lerpVectors(this.vertices.near[_j3], this.vertices.far[_j3], breaks[i]);
58801
+ }
58802
+ }
58803
+ }
58804
+ }
58805
+ }, {
58806
+ key: "toSpace",
58807
+ value: function toSpace(cameraMatrix, target) {
58808
+ for (var i = 0; i < 4; i++) {
58809
+ target.vertices.near[i].copy(this.vertices.near[i]).applyMatrix4(cameraMatrix);
58810
+ target.vertices.far[i].copy(this.vertices.far[i]).applyMatrix4(cameraMatrix);
58811
+ }
58812
+ }
58813
+ }]);
58813
58814
 
58814
- _defineProperty$1(_assertThisInitialized(_this), "isEffect", function () {
58815
- return Object.values(ENTITY_TYPES.EFFECT).includes(_this.getEntityType());
58816
- });
58815
+ return Frustum;
58816
+ }();var Shader$1 = {
58817
+ lights_fragment_begin:
58818
+ /* glsl */
58819
+ "\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n float linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n vec2 cascade;\n float cascadeCenter;\n float closestEdge;\n float margin;\n float csmx;\n float csmy;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n // NOTE: Depth gets larger away from the camera.\n // cascade.x is closer, cascade.y is further\n cascade = CSM_cascades[ i ];\n cascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n margin = 0.25 * pow( closestEdge, 2.0 );\n csmx = cascade.x - margin / 2.0;\n csmy = cascade.y + margin / 2.0;\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS && linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n float dist = min( linearDepth - csmx, csmy - linearDepth );\n float ratio = clamp( dist / margin, 0.0, 1.0 );\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) {\n\n vec3 prevColor = directLight.color;\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n }\n\n ReflectedLight prevLight = reflectedLight;\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n float blendRatio = shouldBlend ? ratio : 1.0;\n\n reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n }\n\n }\n #pragma unroll_loop_end\n #else\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #endif\n\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n RectAreaLight rectAreaLight;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",
58820
+ lights_pars_begin:
58821
+ /* glsl */
58822
+ "\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n " + ShaderChunk.lights_pars_begin
58823
+ };var _cameraToLightMatrix = new Matrix4();
58817
58824
 
58818
- _defineProperty$1(_assertThisInitialized(_this), "setQuaternion", function (_ref2) {
58819
- var x = _ref2.x,
58820
- y = _ref2.y,
58821
- z = _ref2.z,
58822
- w = _ref2.w;
58825
+ var _lightSpaceFrustum = new Frustum();
58823
58826
 
58824
- _this.body.quaternion.set(x, y, z, w);
58825
- });
58827
+ var _center = new Vector3$1();
58826
58828
 
58827
- _defineProperty$1(_assertThisInitialized(_this), "setUuid", function (uuid) {
58828
- if (uuid) {
58829
- _this.body.uuid = uuid;
58830
- }
58831
- });
58829
+ var _bbox = new Box3();
58832
58830
 
58833
- _this.scripts = [];
58834
- _this.tags = [];
58835
- _this.children = [];
58836
- _this.isMage = true;
58831
+ var _uniformArray = [];
58832
+ var _logArray = [];
58833
+ var DEFAULT_MAX_FAR = 100000;
58834
+ var DEFAULT_MODE = 'practical';
58835
+ var DEFAULT_SHADOWMAP_SIZE = 2048;
58836
+ var DEFAULT_CASCADE = 3;
58837
+ var DEFAULT_BIAS$3 = 0.000001;
58838
+ var DEFAULT_INTENSITY$5 = 1;
58839
+ var DEFAULT_NEAR$3 = 1;
58840
+ var DEFAULT_FAR$3 = 2000;
58841
+ var DEFAULT_MARGIN = 200;
58842
+ var CascadeShadowMaps = /*#__PURE__*/function () {
58843
+ function CascadeShadowMaps(_ref) {
58844
+ var _ref$camera = _ref.camera,
58845
+ camera = _ref$camera === void 0 ? Scene$1.getCameraBody() : _ref$camera,
58846
+ _ref$parent = _ref.parent,
58847
+ parent = _ref$parent === void 0 ? Scene$1.getScene() : _ref$parent,
58848
+ _ref$cascades = _ref.cascades,
58849
+ cascades = _ref$cascades === void 0 ? DEFAULT_CASCADE : _ref$cascades,
58850
+ _ref$maxFar = _ref.maxFar,
58851
+ maxFar = _ref$maxFar === void 0 ? DEFAULT_MAX_FAR : _ref$maxFar,
58852
+ _ref$mode = _ref.mode,
58853
+ mode = _ref$mode === void 0 ? DEFAULT_MODE : _ref$mode,
58854
+ _ref$shadowMapSize = _ref.shadowMapSize,
58855
+ shadowMapSize = _ref$shadowMapSize === void 0 ? DEFAULT_SHADOWMAP_SIZE : _ref$shadowMapSize,
58856
+ _ref$shadowBias = _ref.shadowBias,
58857
+ shadowBias = _ref$shadowBias === void 0 ? DEFAULT_BIAS$3 : _ref$shadowBias,
58858
+ _ref$lightDirection = _ref.lightDirection,
58859
+ lightDirection = _ref$lightDirection === void 0 ? new Vector3$1(1, -1, 1).normalize() : _ref$lightDirection,
58860
+ _ref$lightIntensity = _ref.lightIntensity,
58861
+ lightIntensity = _ref$lightIntensity === void 0 ? DEFAULT_INTENSITY$5 : _ref$lightIntensity,
58862
+ _ref$lightNear = _ref.lightNear,
58863
+ lightNear = _ref$lightNear === void 0 ? DEFAULT_NEAR$3 : _ref$lightNear,
58864
+ _ref$lightFar = _ref.lightFar,
58865
+ lightFar = _ref$lightFar === void 0 ? DEFAULT_FAR$3 : _ref$lightFar,
58866
+ _ref$lightMargin = _ref.lightMargin,
58867
+ lightMargin = _ref$lightMargin === void 0 ? DEFAULT_MARGIN : _ref$lightMargin,
58868
+ customSplitsCallback = _ref.customSplitsCallback;
58837
58869
 
58838
- _this.addTags([DEFAULT_TAG, tag].concat(_toConsumableArray(tags)));
58870
+ _classCallCheck(this, CascadeShadowMaps);
58839
58871
 
58840
- _this.serializable = serializable;
58841
- return _this;
58872
+ this.camera = camera;
58873
+ this.parent = parent;
58874
+ this.cascades = cascades;
58875
+ this.maxFar = maxFar;
58876
+ this.mode = mode;
58877
+ this.shadowMapSize = shadowMapSize;
58878
+ this.shadowBias = shadowBias;
58879
+ this.lightDirection = lightDirection;
58880
+ this.lightIntensity = lightIntensity;
58881
+ this.lightNear = lightNear;
58882
+ this.lightFar = lightFar;
58883
+ this.lightMargin = lightMargin;
58884
+ this.customSplitsCallback = customSplitsCallback;
58885
+ this.fade = false;
58886
+ this.mainFrustum = new Frustum();
58887
+ this.frustums = [];
58888
+ this.breaks = [];
58889
+ this.lights = [];
58890
+ this.shaders = new Map();
58891
+ this.createLights();
58892
+ this.updateFrustums();
58893
+ this.injectInclude();
58842
58894
  }
58843
58895
 
58844
- _createClass(Entity, [{
58845
- key: "reset",
58846
- value: function reset() {
58847
- this.scripts = [];
58848
- this.tags = [DEFAULT_TAG];
58849
- }
58850
- }, {
58851
- key: "hasBody",
58852
- value: function hasBody() {
58853
- return !!this.body;
58854
- }
58855
- }, {
58856
- key: "getBody",
58857
- value: function getBody() {
58858
- return this.body;
58859
- }
58860
- }, {
58861
- key: "setBody",
58862
- value: function setBody(body) {
58863
- this.body = body;
58864
- }
58865
- }, {
58866
- key: "hasParent",
58867
- value: function hasParent() {
58868
- return !!this.parent;
58869
- }
58870
- }, {
58871
- key: "getParent",
58872
- value: function getParent() {
58873
- return this.parent;
58896
+ _createClass(CascadeShadowMaps, [{
58897
+ key: "createLights",
58898
+ value: function createLights() {
58899
+ for (var i = 0; i < this.cascades; i++) {
58900
+ var light = new DirectionalLight(0xffffff, this.lightIntensity);
58901
+ light.castShadow = true;
58902
+ light.shadow.mapSize.width = this.shadowMapSize;
58903
+ light.shadow.mapSize.height = this.shadowMapSize;
58904
+ light.shadow.camera.near = this.lightNear;
58905
+ light.shadow.camera.far = this.lightFar;
58906
+ light.shadow.bias = this.shadowBias;
58907
+ this.parent.add(light);
58908
+ this.parent.add(light.target);
58909
+ this.lights.push(light);
58910
+ }
58874
58911
  }
58875
58912
  }, {
58876
- key: "setParent",
58877
- value: function setParent(parent) {
58878
- this.parent = parent;
58913
+ key: "initCascades",
58914
+ value: function initCascades() {
58915
+ var camera = this.camera;
58916
+ camera.updateProjectionMatrix();
58917
+ this.mainFrustum.setFromProjectionMatrix(camera.projectionMatrix, this.maxFar);
58918
+ this.mainFrustum.split(this.breaks, this.frustums);
58879
58919
  }
58880
58920
  }, {
58881
- key: "add",
58882
- value: function add(element) {
58883
- var _this2 = this;
58884
-
58885
- if (this.hasBody()) {
58886
- var _add = function _add(toAdd) {
58887
- _this2.children.push(toAdd);
58921
+ key: "updateShadowBounds",
58922
+ value: function updateShadowBounds() {
58923
+ var frustums = this.frustums;
58888
58924
 
58889
- toAdd.setParent(_this2);
58925
+ for (var i = 0; i < frustums.length; i++) {
58926
+ var light = this.lights[i];
58927
+ var shadowCam = light.shadow.camera;
58928
+ var frustum = this.frustums[i]; // Get the two points that represent that furthest points on the frustum assuming
58929
+ // that's either the diagonal across the far plane or the diagonal across the whole
58930
+ // frustum itself.
58890
58931
 
58891
- _this2.getBody().add(toAdd.getBody());
58892
- };
58932
+ var nearVerts = frustum.vertices.near;
58933
+ var farVerts = frustum.vertices.far;
58934
+ var point1 = farVerts[0];
58935
+ var point2 = void 0;
58893
58936
 
58894
- if (Array.isArray(element)) {
58895
- element.forEach(_add);
58937
+ if (point1.distanceTo(farVerts[2]) > point1.distanceTo(nearVerts[2])) {
58938
+ point2 = farVerts[2];
58896
58939
  } else {
58897
- _add(element);
58940
+ point2 = nearVerts[2];
58941
+ }
58942
+
58943
+ var squaredBBWidth = point1.distanceTo(point2);
58944
+
58945
+ if (this.fade) {
58946
+ // expand the shadow extents by the fade margin if fade is enabled.
58947
+ var camera = this.camera;
58948
+ var far = Math.max(camera.far, this.maxFar);
58949
+ var linearDepth = frustum.vertices.far[0].z / (far - camera.near);
58950
+ var margin = 0.25 * Math.pow(linearDepth, 2.0) * (far - camera.near);
58951
+ squaredBBWidth += margin;
58898
58952
  }
58953
+
58954
+ shadowCam.left = -squaredBBWidth / 2;
58955
+ shadowCam.right = squaredBBWidth / 2;
58956
+ shadowCam.top = squaredBBWidth / 2;
58957
+ shadowCam.bottom = -squaredBBWidth / 2;
58958
+ shadowCam.updateProjectionMatrix();
58899
58959
  }
58900
58960
  }
58901
58961
  }, {
58902
- key: "isParentOf",
58903
- value: function isParentOf(element) {
58904
- var comparator = function comparator(child) {
58905
- return !!child.getBody().getObjectById(element.id);
58906
- };
58962
+ key: "getBreaks",
58963
+ value: function getBreaks() {
58964
+ var camera = this.camera;
58965
+ var far = Math.min(camera.far, this.maxFar);
58966
+ this.breaks.length = 0;
58907
58967
 
58908
- if (element.isMage) {
58909
- comparator = function comparator(child) {
58910
- return child.getBody().getObjectById(element.id());
58911
- };
58912
- }
58968
+ switch (this.mode) {
58969
+ case 'uniform':
58970
+ uniformSplit(this.cascades, camera.near, far, this.breaks);
58971
+ break;
58913
58972
 
58914
- return this.children.filter(comparator).length > 0;
58915
- }
58916
- }, {
58917
- key: "has",
58918
- value: function has(element) {
58919
- if (element.isMage) {
58920
- return this.equals(element) || this.isParentOf(element);
58921
- } else {
58922
- return this.getBody().getObjectById(element.id);
58973
+ case 'logarithmic':
58974
+ logarithmicSplit(this.cascades, camera.near, far, this.breaks);
58975
+ break;
58976
+
58977
+ case 'practical':
58978
+ practicalSplit(this.cascades, camera.near, far, 0.5, this.breaks);
58979
+ break;
58980
+
58981
+ case 'custom':
58982
+ if (this.customSplitsCallback === undefined) console.error('CSM: Custom split scheme callback not defined.');
58983
+ this.customSplitsCallback(this.cascades, camera.near, far, this.breaks);
58984
+ break;
58923
58985
  }
58924
- }
58925
- }, {
58926
- key: "remove",
58927
- value: function remove(element) {
58928
- if (this.hasBody() && this.has(element)) {
58929
- this.body.remove(element.body);
58930
- var index = this.children.findIndex(function (m) {
58931
- return m.equals(element);
58932
- });
58933
- this.children.splice(index, 1);
58986
+
58987
+ function uniformSplit(amount, near, far, target) {
58988
+ for (var i = 1; i < amount; i++) {
58989
+ target.push((near + (far - near) * i / amount) / far);
58990
+ }
58991
+
58992
+ target.push(1);
58934
58993
  }
58935
- }
58936
- }, {
58937
- key: "getHierarchy",
58938
- value: function getHierarchy() {
58939
- return {
58940
- element: this,
58941
- children: this.children.map(function (e) {
58942
- return e.getHierarchy();
58943
- })
58944
- };
58945
- }
58946
- }, {
58947
- key: "addTags",
58948
- value: function addTags() {
58949
- var tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
58950
- tags.forEach(this.addTag);
58951
- }
58952
- }, {
58953
- key: "removeTag",
58954
- value: function removeTag(tagName) {
58955
- if (tagName === DEFAULT_TAG) {
58956
- console.log(TAG_CANT_BE_REMOVED);
58957
- return;
58994
+
58995
+ function logarithmicSplit(amount, near, far, target) {
58996
+ for (var i = 1; i < amount; i++) {
58997
+ target.push(near * Math.pow(far / near, i / amount) / far);
58998
+ }
58999
+
59000
+ target.push(1);
58958
59001
  }
58959
59002
 
58960
- if (this.hasTag(tagName)) {
58961
- this.tags.splice(this.tags.indexOf(tagName), 1);
58962
- } else {
58963
- console.log(TAG_NOT_EXISTING_REMOVAL);
59003
+ function practicalSplit(amount, near, far, lambda, target) {
59004
+ _uniformArray.length = 0;
59005
+ _logArray.length = 0;
59006
+ logarithmicSplit(amount, near, far, _logArray);
59007
+ uniformSplit(amount, near, far, _uniformArray);
59008
+
59009
+ for (var i = 1; i < amount; i++) {
59010
+ target.push(MathUtils.lerp(_uniformArray[i - 1], _logArray[i - 1], lambda));
59011
+ }
59012
+
59013
+ target.push(1);
58964
59014
  }
58965
59015
  }
58966
59016
  }, {
58967
- key: "removeAllTags",
58968
- value: function removeAllTags() {
58969
- this.tags = [DEFAULT_TAG];
58970
- }
58971
- }, {
58972
- key: "hasTag",
58973
- value: function hasTag(tagName) {
58974
- return this.tags.includes(tagName);
58975
- }
58976
- }, {
58977
- key: "getTags",
58978
- value: function getTags() {
58979
- return this.tags;
58980
- }
58981
- }, {
58982
- key: "stopScripts",
58983
- value: function stopScripts() {
58984
- if (this.hasScripts()) {
58985
- this.scripts.forEach(function (_ref3) {
58986
- var script = _ref3.script,
58987
- enabled = _ref3.enabled;
59017
+ key: "update",
59018
+ value: function update() {
59019
+ var camera = this.camera;
59020
+ var frustums = this.frustums;
58988
59021
 
58989
- if (enabled) {
58990
- script.onDispose();
59022
+ for (var i = 0; i < frustums.length; i++) {
59023
+ var light = this.lights[i];
59024
+ var shadowCam = light.shadow.camera;
59025
+ var texelWidth = (shadowCam.right - shadowCam.left) / this.shadowMapSize;
59026
+ var texelHeight = (shadowCam.top - shadowCam.bottom) / this.shadowMapSize;
59027
+ light.shadow.camera.updateMatrixWorld(true);
58991
59028
 
58992
- script.__hasStarted(false);
58993
- }
58994
- });
58995
- }
58996
- }
58997
- }, {
58998
- key: "start",
58999
- value: function start() {
59000
- var _this3 = this;
59029
+ _cameraToLightMatrix.multiplyMatrices(light.shadow.camera.matrixWorldInverse, camera.matrixWorld);
59001
59030
 
59002
- if (this.hasScripts()) {
59003
- this.scripts.forEach(function (_ref4) {
59004
- var script = _ref4.script,
59005
- enabled = _ref4.enabled,
59006
- options = _ref4.options;
59031
+ frustums[i].toSpace(_cameraToLightMatrix, _lightSpaceFrustum);
59032
+ var nearVerts = _lightSpaceFrustum.vertices.near;
59033
+ var farVerts = _lightSpaceFrustum.vertices.far;
59007
59034
 
59008
- if (enabled) {
59009
- script.start(_this3, options);
59035
+ _bbox.makeEmpty();
59010
59036
 
59011
- script.__hasStarted(true);
59012
- }
59013
- });
59014
- }
59015
- }
59016
- }, {
59017
- key: "update",
59018
- value: function update(dt) {
59019
- if (this.hasScripts()) {
59020
- this.scripts.forEach(function (_ref5) {
59021
- var script = _ref5.script,
59022
- enabled = _ref5.enabled;
59037
+ for (var j = 0; j < 4; j++) {
59038
+ _bbox.expandByPoint(nearVerts[j]);
59023
59039
 
59024
- if (script && enabled) {
59025
- script.update(dt);
59026
- }
59027
- });
59040
+ _bbox.expandByPoint(farVerts[j]);
59041
+ }
59042
+
59043
+ _bbox.getCenter(_center);
59044
+
59045
+ _center.z = _bbox.max.z + this.lightMargin;
59046
+ _center.x = Math.floor(_center.x / texelWidth) * texelWidth;
59047
+ _center.y = Math.floor(_center.y / texelHeight) * texelHeight;
59048
+
59049
+ _center.applyMatrix4(light.shadow.camera.matrixWorld);
59050
+
59051
+ light.position.copy(_center);
59052
+ light.target.position.copy(_center);
59053
+ light.target.position.x += this.lightDirection.x;
59054
+ light.target.position.y += this.lightDirection.y;
59055
+ light.target.position.z += this.lightDirection.z;
59028
59056
  }
59029
59057
  }
59030
59058
  }, {
59031
- key: "onPhysicsUpdate",
59032
- value: function onPhysicsUpdate(dt) {
59033
- if (this.hasScripts()) {
59034
- this.scripts.forEach(function (_ref6) {
59035
- var script = _ref6.script,
59036
- enabled = _ref6.enabled;
59037
-
59038
- if (script && enabled) {
59039
- script.physicsUpdate(dt);
59040
- }
59041
- });
59042
- }
59059
+ key: "injectInclude",
59060
+ value: function injectInclude() {
59061
+ ShaderChunk.lights_fragment_begin = Shader$1.lights_fragment_begin;
59062
+ ShaderChunk.lights_pars_begin = Shader$1.lights_pars_begin;
59043
59063
  }
59044
59064
  }, {
59045
- key: "dispose",
59046
- value: function dispose() {
59047
- if (this.hasBody()) {
59048
- this.stopStateMachine();
59049
- this.stopScripts();
59050
- this.reset();
59065
+ key: "setupMaterial",
59066
+ value: function setupMaterial(material) {
59067
+ material.defines = material.defines || {};
59068
+ material.defines.USE_CSM = 1;
59069
+ material.defines.CSM_CASCADES = this.cascades;
59070
+
59071
+ if (this.fade) {
59072
+ material.defines.CSM_FADE = '';
59051
59073
  }
59052
59074
 
59053
- this.dispatchEvent({
59054
- type: ENTITY_EVENTS.DISPOSE
59055
- });
59056
- }
59057
- }, {
59058
- key: "addStateMachine",
59059
- value: function addStateMachine(description) {
59060
- var _this4 = this;
59075
+ var breaksVec2 = [];
59076
+ var scope = this;
59077
+ var shaders = this.shaders;
59061
59078
 
59062
- this.stateMachine = interpret(createMachine(description)).onTransition(function (state) {
59063
- _this4.dispatchEvent({
59064
- type: ENTITY_EVENTS.STATE_MACHINE.CHANGE,
59065
- state: state
59066
- });
59067
- });
59079
+ material.onBeforeCompile = function (shader) {
59080
+ var far = Math.min(scope.camera.far, scope.maxFar);
59081
+ scope.getExtendedBreaks(breaksVec2);
59082
+ shader.uniforms.CSM_cascades = {
59083
+ value: breaksVec2
59084
+ };
59085
+ shader.uniforms.cameraNear = {
59086
+ value: scope.camera.near
59087
+ };
59088
+ shader.uniforms.shadowFar = {
59089
+ value: far
59090
+ };
59091
+ shaders.set(material, shader);
59092
+ };
59068
59093
 
59069
- if (description.autostart) {
59070
- this.startStateMachine();
59071
- }
59094
+ shaders.set(material, null);
59072
59095
  }
59073
59096
  }, {
59074
- key: "startStateMachine",
59075
- value: function startStateMachine() {
59076
- if (this.hasStateMachine()) {
59077
- this.stateMachine.start();
59078
- } else {
59079
- console.log(STATE_MACHINE_NOT_AVAILABLE);
59080
- }
59097
+ key: "updateUniforms",
59098
+ value: function updateUniforms() {
59099
+ var far = Math.min(this.camera.far, this.maxFar);
59100
+ var shaders = this.shaders;
59101
+ shaders.forEach(function (shader, material) {
59102
+ if (shader !== null) {
59103
+ var uniforms = shader.uniforms;
59104
+ this.getExtendedBreaks(uniforms.CSM_cascades.value);
59105
+ uniforms.cameraNear.value = this.camera.near;
59106
+ uniforms.shadowFar.value = far;
59107
+ }
59108
+
59109
+ if (!this.fade && 'CSM_FADE' in material.defines) {
59110
+ delete material.defines.CSM_FADE;
59111
+ material.needsUpdate = true;
59112
+ } else if (this.fade && !('CSM_FADE' in material.defines)) {
59113
+ material.defines.CSM_FADE = '';
59114
+ material.needsUpdate = true;
59115
+ }
59116
+ }, this);
59081
59117
  }
59082
59118
  }, {
59083
- key: "stopStateMachine",
59084
- value: function stopStateMachine() {
59085
- if (this.hasStateMachine()) {
59086
- this.stateMachine.stop();
59119
+ key: "getExtendedBreaks",
59120
+ value: function getExtendedBreaks(target) {
59121
+ while (target.length < this.breaks.length) {
59122
+ target.push(new Vector2());
59123
+ }
59124
+
59125
+ target.length = this.breaks.length;
59126
+
59127
+ for (var i = 0; i < this.cascades; i++) {
59128
+ var amount = this.breaks[i];
59129
+ var prev = this.breaks[i - 1] || 0;
59130
+ target[i].x = prev;
59131
+ target[i].y = amount;
59087
59132
  }
59088
59133
  }
59089
59134
  }, {
59090
- key: "changeState",
59091
- value: function changeState(event) {
59092
- if (this.hasStateMachine()) {
59093
- this.stateMachine.send(event);
59094
- } else {
59095
- console.log(STATE_MACHINE_NOT_AVAILABLE);
59096
- }
59135
+ key: "updateFrustums",
59136
+ value: function updateFrustums() {
59137
+ this.getBreaks();
59138
+ this.initCascades();
59139
+ this.updateShadowBounds();
59140
+ this.updateUniforms();
59097
59141
  }
59098
59142
  }, {
59099
- key: "getScript",
59100
- value: function getScript(name) {
59101
- var script = this.scripts.filter(function (script) {
59102
- return script.name === name;
59103
- })[0].script;
59104
-
59105
- if (script) {
59106
- return script;
59107
- } else {
59108
- console.warn(SCRIPT_NOT_FOUND);
59143
+ key: "remove",
59144
+ value: function remove() {
59145
+ for (var i = 0; i < this.lights.length; i++) {
59146
+ this.parent.remove(this.lights[i]);
59109
59147
  }
59110
59148
  }
59111
59149
  }, {
59112
- key: "addScripts",
59113
- value: function addScripts() {
59114
- var _this5 = this;
59150
+ key: "dispose",
59151
+ value: function dispose() {
59152
+ var shaders = this.shaders;
59153
+ shaders.forEach(function (shader, material) {
59154
+ delete material.onBeforeCompile;
59155
+ delete material.defines.USE_CSM;
59156
+ delete material.defines.CSM_CASCADES;
59157
+ delete material.defines.CSM_FADE;
59115
59158
 
59116
- var scripts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
59117
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
59118
- var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
59119
- var parsedScripts = this.parseScripts(scripts, options, enabled);
59120
- this.scripts = [].concat(_toConsumableArray(this.scripts), [parsedScripts]);
59159
+ if (shader !== null) {
59160
+ delete shader.uniforms.CSM_cascades;
59161
+ delete shader.uniforms.cameraNear;
59162
+ delete shader.uniforms.shadowFar;
59163
+ }
59121
59164
 
59122
- if (enabled) {
59123
- parsedScripts.forEach(function (parsed) {
59124
- return parsed.start(_this5, parsed.options);
59125
- });
59126
- }
59165
+ material.needsUpdate = true;
59166
+ });
59167
+ shaders.clear();
59127
59168
  }
59128
- }, {
59129
- key: "addScript",
59130
- value: function addScript(name) {
59131
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59132
- var script = Scripts$1.get(name);
59133
- var _options$enabled = options.enabled,
59134
- enabled = _options$enabled === void 0 ? true : _options$enabled;
59169
+ }]);
59135
59170
 
59136
- if (script) {
59137
- this.scripts.push({
59138
- script: script,
59139
- name: name,
59140
- enabled: enabled,
59141
- options: options
59142
- });
59171
+ return CascadeShadowMaps;
59172
+ }();var POINTLIGHT = 'pointlight';
59173
+ var AMBIENTLIGHT = 'ambientlight';
59174
+ var SUNLIGHT = 'sunlight';
59175
+ var SPOTLIGHT = 'spotlight';
59176
+ var HEMISPHERELIGHT = 'hemisphere';
59177
+ var TIME_TO_UPDATE = 5;
59178
+ var Lights = /*#__PURE__*/function () {
59179
+ function Lights() {
59180
+ _classCallCheck(this, Lights);
59143
59181
 
59144
- if (enabled) {
59145
- script.start(this, options);
59146
- }
59147
- } else {
59148
- console.log(SCRIPT_NOT_FOUND);
59149
- }
59182
+ this.delayFactor = 0.1;
59183
+ this.delayStep = 30;
59184
+ this.holderRadius = 0.01;
59185
+ this.holderSegments = 1;
59186
+ this.numLights = 0;
59187
+ this.map = {};
59188
+ this.lights = [];
59189
+ this.csm = undefined;
59190
+ }
59150
59191
 
59151
- return script;
59192
+ _createClass(Lights, [{
59193
+ key: "isUsingCSM",
59194
+ value: function isUsingCSM() {
59195
+ return !!this.csm;
59152
59196
  }
59153
59197
  }, {
59154
- key: "enableScripts",
59155
- value: function enableScripts() {
59156
- this.scriptsEnabled = true;
59198
+ key: "setUpCSM",
59199
+ value: function setUpCSM() {
59200
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
59201
+ this.csm = new CascadeShadowMaps(options);
59157
59202
  }
59158
59203
  }, {
59159
- key: "disableScripts",
59160
- value: function disableScripts() {
59161
- this.scriptsEnabled = false;
59204
+ key: "add",
59205
+ value: function add(light) {
59206
+ this.lights.push(light);
59162
59207
  }
59163
59208
  }, {
59164
- key: "setEntityType",
59165
- value: function setEntityType(type) {
59166
- if (FLAT_ENTITY_TYPES.includes(type)) {
59167
- this.entityType = type;
59168
- } else {
59169
- console.log(ENTITY_TYPE_NOT_ALLOWED);
59170
- this.entityType = ENTITY_TYPES.UNKNOWN;
59209
+ key: "update",
59210
+ value: function update(dt) {
59211
+ if (this.isUsingCSM()) {
59212
+ this.csm.update();
59171
59213
  }
59172
- }
59173
- }, {
59174
- key: "getEntityType",
59175
- value: function getEntityType() {
59176
- return this.entityType;
59177
- }
59178
- }, {
59179
- key: "addLight",
59180
- // TODO: sounds should become entities
59181
- // addSound(name, options) {
59182
- // const { autoplay = false, ...opts } = options;
59183
- // this.isPlayingSound = autoplay;
59184
- // this.sound = new Sound(name, {
59185
- // autoplay,
59186
- // ...opts
59187
- // });
59188
- // this.sound.setTarget(this);
59189
- // return this.sound;
59190
- // }
59191
- // addDirectionalSound(name, options) {
59192
- // const { autoplay = false, ...opts } = options;
59193
- // this.isPlayingSound = autoplay;
59194
- // this.sound = new DirectionalSound(name, {
59195
- // autoplay,
59196
- // ...opts
59197
- // });
59198
- // this.sound.setTarget(this);
59199
- // return this.sound;
59200
- // }
59201
- // addAmbientSound(name, options) {
59202
- // const { autoplay = false, ...opts } = options;
59203
- // this.isPlayingSound = autoplay;
59204
- // this.sound = new AmbientSound(name, {
59205
- // body: this.body,
59206
- // autoplay,
59207
- // ...opts
59208
- // });
59209
- // return this.sound;
59210
- // }
59211
- value: function addLight(light) {
59212
- var _this$getPosition = this.getPosition(),
59213
- x = _this$getPosition.x,
59214
- y = _this$getPosition.y,
59215
- z = _this$getPosition.z;
59216
59214
 
59217
- light.setPosition({
59218
- x: x,
59219
- y: y,
59220
- z: z
59221
- });
59222
- this.light = light;
59223
- }
59224
- }, {
59225
- key: "playSound",
59226
- value: function playSound() {
59227
- if (this.sound && !this.isPlayingSound) {
59228
- this.sound.play();
59229
- this.isPlayingSound = true;
59230
- }
59231
- }
59232
- }, {
59233
- key: "stopSound",
59234
- value: function stopSound() {
59235
- if (this.sound && this.isPlayingSound) {
59236
- this.sound.stop();
59237
- this.isPlayingSound = false;
59215
+ var start = new Date();
59216
+
59217
+ for (var index in this.lights) {
59218
+ var light = this.lights[index];
59219
+ light.update(dt);
59220
+ if (+new Date() - start > TIME_TO_UPDATE) break;
59238
59221
  }
59239
59222
  }
59240
59223
  }, {
59241
- key: "getScale",
59242
- value: function getScale() {
59224
+ key: "toJSON",
59225
+ value: function toJSON() {
59243
59226
  return {
59244
- x: this.body.scale.x,
59245
- y: this.body.scale.y,
59246
- z: this.body.scale.z
59227
+ lights: this.lights.map(function (l) {
59228
+ return l.toJSON();
59229
+ })
59247
59230
  };
59248
59231
  }
59249
- }, {
59250
- key: "setScale",
59251
- value: function setScale(howbig) {
59252
- if (this.hasBody()) {
59253
- var scale = _objectSpread2$1(_objectSpread2$1({}, this.getScale()), howbig);
59232
+ }]);
59254
59233
 
59255
- this.body.scale.set(scale.x, scale.y, scale.z);
59256
- }
59257
- }
59258
- }, {
59259
- key: "getQuaternion",
59260
- value: function getQuaternion() {
59261
- if (this.hasBody()) {
59262
- return this.getBody().quaternion.clone();
59263
- }
59234
+ return Lights;
59235
+ }();
59236
+ var Lights$1 = new Lights();var ToonShader = {
59237
+ uniforms: {
59238
+ "uDirLightPos": {
59239
+ type: "v3",
59240
+ value: new Vector3$1()
59241
+ },
59242
+ "uDirLightColor": {
59243
+ type: "c",
59244
+ value: new Color$1(0xffffff)
59245
+ },
59246
+ "uMaterialColor": {
59247
+ type: "c",
59248
+ value: new Color$1(0xffffff)
59249
+ },
59250
+ uKd: {
59251
+ type: "f",
59252
+ value: 1
59253
+ },
59254
+ uBorder: {
59255
+ type: "f",
59256
+ value: 0.4
59264
59257
  }
59265
- }, {
59266
- key: "getPosition",
59267
- value: function getPosition() {
59268
- return this.getBody().position.clone();
59258
+ },
59259
+ vertexShader: ["varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "vNormal = normalize( normalMatrix * normal );", "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", "vViewPosition = -mvPosition.xyz;", "}"].join("\n"),
59260
+ fragmentShader: ["uniform vec3 uMaterialColor;", "uniform vec3 uDirLightPos;", "uniform vec3 uDirLightColor;", "uniform float uKd;", "uniform float uBorder;", "varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", // compute direction to light
59261
+ "vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );", "vec3 lVector = normalize( lDirection.xyz );", // diffuse: N * L. Normal must be normalized, since it's interpolated.
59262
+ "vec3 normal = normalize( vNormal );", //was: "float diffuse = max( dot( normal, lVector ), 0.0);",
59263
+ // solution
59264
+ "float diffuse = dot( normal, lVector );", "if ( diffuse > 0.6 ) { diffuse = 1.0; }", "else if ( diffuse > -0.2 ) { diffuse = 0.7; }", "else { diffuse = 0.3; }", "gl_FragColor = vec4( uKd * uMaterialColor * uDirLightColor * diffuse, 1.0 );", "}"].join("\n")
59265
+ };
59266
+
59267
+ var ToonMaterial = /*#__PURE__*/function (_ShaderMaterial) {
59268
+ _inherits(ToonMaterial, _ShaderMaterial);
59269
+
59270
+ var _super = _createSuper(ToonMaterial);
59271
+
59272
+ function ToonMaterial(_ref) {
59273
+ var _this;
59274
+
59275
+ var _ref$light = _ref.light,
59276
+ light = _ref$light === void 0 ? {} : _ref$light,
59277
+ color = _ref.color;
59278
+
59279
+ _classCallCheck(this, ToonMaterial);
59280
+
59281
+ var uniforms = UniformsUtils.clone(ToonShader.uniforms);
59282
+ var vertexShader = ToonShader.vertexShader,
59283
+ fragmentShader = ToonShader.fragmentShader;
59284
+ _this = _super.call(this, {
59285
+ uniforms: uniforms,
59286
+ vertexShader: vertexShader,
59287
+ fragmentShader: fragmentShader,
59288
+ flatShading: true
59289
+ });
59290
+ var position = light.position,
59291
+ lightColor = light.color;
59292
+
59293
+ if (color) {
59294
+ var materialColor = new Color$1(color);
59295
+
59296
+ _this.uniforms.uMaterialColor.value.copy(materialColor);
59269
59297
  }
59270
- }, {
59271
- key: "setPosition",
59272
- value: function setPosition(where) {
59273
- if (this.hasBody()) {
59274
- var _this$getPosition2 = this.getPosition(),
59275
- x = _this$getPosition2.x,
59276
- y = _this$getPosition2.y,
59277
- z = _this$getPosition2.z;
59278
59298
 
59279
- var position = _objectSpread2$1({
59280
- x: x,
59281
- y: y,
59282
- z: z
59283
- }, where);
59299
+ _this.uniforms.uDirLightPos.value = position;
59284
59300
 
59285
- this.body.position.set(position.x, position.y, position.z);
59301
+ _this.uniforms.uDirLightColor.value.copy(new Color$1(lightColor));
59302
+
59303
+ _this.side = DoubleSide;
59304
+ return _this;
59305
+ }
59306
+
59307
+ return ToonMaterial;
59308
+ }(ShaderMaterial);var setUpLightsAndShadows = function setUpLightsAndShadows(mesh) {
59309
+ var _Config$lights = Config$1.lights(),
59310
+ textureAnisotropy = _Config$lights.textureAnisotropy,
59311
+ shadows = _Config$lights.shadows;
59312
+
59313
+ mesh.castShadow = Boolean(shadows);
59314
+ mesh.receiveShadow = Boolean(shadows);
59315
+
59316
+ if (hasMaterial(mesh)) {
59317
+ var setUpMaterial = function setUpMaterial(material) {
59318
+ if (Lights$1.isUsingCSM()) {
59319
+ Lights$1.csm.setupMaterial(material);
59286
59320
  }
59287
- }
59288
- }, {
59289
- key: "getRotation",
59290
- value: function getRotation() {
59291
- return this.getBody().rotation.clone();
59292
- }
59293
- }, {
59294
- key: "setRotation",
59295
- value: function setRotation(how) {
59296
- if (this.hasBody()) {
59297
- var _this$getRotation = this.getRotation(),
59298
- x = _this$getRotation.x,
59299
- y = _this$getRotation.y,
59300
- z = _this$getRotation.z;
59301
59321
 
59302
- var rotation = _objectSpread2$1({
59303
- x: x,
59304
- y: y,
59305
- z: z
59306
- }, how);
59322
+ if (material.map) {
59323
+ material.map.anisotropy = textureAnisotropy;
59324
+ }
59307
59325
 
59308
- this.body.rotation.set(rotation.x, rotation.y, rotation.z);
59326
+ return material;
59327
+ };
59328
+
59329
+ mesh.material = processMaterial(mesh.material, setUpMaterial);
59330
+ }
59331
+ };
59332
+ var isScene = function isScene(mesh) {
59333
+ return mesh.isScene;
59334
+ };
59335
+
59336
+ var hasMaterial = function hasMaterial(mesh) {
59337
+ return Boolean(mesh.material);
59338
+ };
59339
+ var hasGeometry = function hasGeometry(mesh) {
59340
+ return Boolean(mesh.geometry);
59341
+ };
59342
+ var processMaterial = function processMaterial(material, callback) {
59343
+ return Array.isArray(material) ? material.map(callback) : callback(material);
59344
+ };
59345
+ var changeMaterialByName = function changeMaterialByName(name, mesh, materialOptions) {
59346
+ if (!hasMaterial(mesh)) return;
59347
+
59348
+ switch (name) {
59349
+ case MATERIALS.LAMBERT:
59350
+ return cloneMaterial(MeshLambertMaterial, mesh, materialOptions);
59351
+
59352
+ case MATERIALS.PHONG:
59353
+ return cloneMaterial(MeshPhongMaterial, mesh, materialOptions);
59354
+
59355
+ case MATERIALS.DEPTH:
59356
+ return cloneMaterial(MeshDepthMaterial, mesh, materialOptions);
59357
+
59358
+ case MATERIALS.STANDARD:
59359
+ return cloneMaterial(MeshStandardMaterial, mesh, materialOptions);
59360
+
59361
+ case MATERIALS.TOON:
59362
+ return cloneMaterial(ToonMaterial, mesh, materialOptions);
59363
+
59364
+ case MATERIALS.THREE_TOON:
59365
+ return cloneMaterial(MeshToonMaterial, mesh, materialOptions);
59366
+
59367
+ case MATERIALS.BASIC:
59368
+ default:
59369
+ return cloneMaterial(MeshBasicMaterial, mesh, materialOptions);
59370
+ }
59371
+ };
59372
+
59373
+ var cloneMaterial = function cloneMaterial(MeshMaterial, mesh) {
59374
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
59375
+
59376
+ var _cloneMaterial = function _cloneMaterial(material) {
59377
+ var clone = material.clone();
59378
+ var newMaterial = new MeshMaterial(_objectSpread2$1({
59379
+ map: clone.map,
59380
+ color: clone.color
59381
+ }, options));
59382
+ newMaterial.skinning = true;
59383
+ return newMaterial;
59384
+ };
59385
+
59386
+ mesh.material = processMaterial(mesh.material, _cloneMaterial);
59387
+ setUpLightsAndShadows(mesh);
59388
+ };
59389
+
59390
+ var disposeTextures = function disposeTextures(mesh) {
59391
+ if (hasMaterial(mesh)) {
59392
+ var _disposeTexture = function _disposeTexture(material) {
59393
+ Object.values(TEXTURES).forEach(function (key) {
59394
+ if (material[key]) {
59395
+ material[key].dispose();
59396
+ }
59397
+ });
59398
+ };
59399
+
59400
+ processMaterial(mesh.material, _disposeTexture);
59401
+ }
59402
+ };
59403
+ var disposeMaterial = function disposeMaterial(mesh) {
59404
+ if (hasMaterial(mesh)) {
59405
+ mesh.material.dispose && mesh.material.dispose();
59406
+ }
59407
+ };
59408
+ var disposeGeometry = function disposeGeometry(mesh) {
59409
+ if (hasGeometry(mesh)) {
59410
+ mesh.geometry.dispose && mesh.geometry.dispose();
59411
+ }
59412
+ };
59413
+ var prepareModel = function prepareModel(model) {
59414
+ setUpLightsAndShadows(model);
59415
+ model.traverse(function (mesh) {
59416
+ setUpLightsAndShadows(mesh);
59417
+ });
59418
+ return model;
59419
+ };var Entity = /*#__PURE__*/function (_EventDispatcher) {
59420
+ _inherits(Entity, _EventDispatcher);
59421
+
59422
+ var _super = _createSuper(Entity);
59423
+
59424
+ function Entity() {
59425
+ var _this;
59426
+
59427
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
59428
+ _ref$serializable = _ref.serializable,
59429
+ serializable = _ref$serializable === void 0 ? true : _ref$serializable,
59430
+ _ref$tag = _ref.tag,
59431
+ tag = _ref$tag === void 0 ? '' : _ref$tag,
59432
+ _ref$tags = _ref.tags,
59433
+ tags = _ref$tags === void 0 ? [] : _ref$tags;
59434
+
59435
+ _classCallCheck(this, Entity);
59436
+
59437
+ _this = _super.call(this);
59438
+
59439
+ _defineProperty$1(_assertThisInitialized(_this), "getBodyByName", function (name) {
59440
+ if (name && _this.hasBody()) {
59441
+ return _this.getBody().getObjectByName(name);
59309
59442
  }
59310
- }
59311
- }, {
59312
- key: "getWorldTransform",
59313
- value: function getWorldTransform() {
59314
- var position = this.getBody().getWorldPosition(new Vector3$1());
59315
- var quaternion = this.getBody().getWorldQuaternion(new Quaternion(0, 0, 0, 1));
59316
- var rotation = new Euler(0, 0, 0, 'XYZ').setFromQuaternion(quaternion, 'XYZ');
59317
- return {
59318
- position: position,
59319
- rotation: rotation,
59320
- quaternion: quaternion
59321
- };
59322
- }
59323
- }, {
59324
- key: "translate",
59325
- value: function translate(_ref7) {
59326
- var _ref7$x = _ref7.x,
59327
- x = _ref7$x === void 0 ? 0 : _ref7$x,
59328
- _ref7$y = _ref7.y,
59329
- y = _ref7$y === void 0 ? 0 : _ref7$y,
59330
- _ref7$z = _ref7.z,
59331
- z = _ref7$z === void 0 ? 0 : _ref7$z;
59332
59443
 
59333
- if (this.hasBody()) {
59334
- this.body.translateX(x);
59335
- this.body.translateY(y);
59336
- this.body.translateZ(z);
59337
- }
59338
- }
59339
- }, {
59340
- key: "rotateTo",
59341
- value: function rotateTo() {
59342
- var _this6 = this;
59444
+ console.warn(ELEMENT_NAME_NOT_PROVIDED);
59445
+ });
59446
+
59447
+ _defineProperty$1(_assertThisInitialized(_this), "addTag", function (tagName) {
59448
+ if (!tagName) return;
59449
+
59450
+ if (!_this.hasTag(tagName)) {
59451
+ _this.tags.push(tagName);
59452
+
59453
+ return true;
59454
+ } else {
59455
+ console.log(TAG_ALREADY_EXISTS, tagName);
59456
+ return false;
59457
+ }
59458
+ });
59459
+
59460
+ _defineProperty$1(_assertThisInitialized(_this), "hasStateMachine", function () {
59461
+ return !!_this.stateMachine;
59462
+ });
59463
+
59464
+ _defineProperty$1(_assertThisInitialized(_this), "hasScripts", function () {
59465
+ return _this.scripts.length > 0;
59466
+ });
59467
+
59468
+ _defineProperty$1(_assertThisInitialized(_this), "parseScripts", function (list, options, enabled) {
59469
+ return list.map(function (script, i) {
59470
+ return {
59471
+ script: script,
59472
+ name: script.getName(),
59473
+ enabled: enabled,
59474
+ options: options[i]
59475
+ };
59476
+ });
59477
+ });
59478
+
59479
+ _defineProperty$1(_assertThisInitialized(_this), "isMesh", function () {
59480
+ return _this.getEntityType() === ENTITY_TYPES.MESH;
59481
+ });
59482
+
59483
+ _defineProperty$1(_assertThisInitialized(_this), "isModel", function () {
59484
+ return _this.getEntityType() === ENTITY_TYPES.MODEL;
59485
+ });
59486
+
59487
+ _defineProperty$1(_assertThisInitialized(_this), "isSprite", function () {
59488
+ return _this.getEntityType() === ENTITY_TYPES.SPRITE;
59489
+ });
59490
+
59491
+ _defineProperty$1(_assertThisInitialized(_this), "isLight", function () {
59492
+ return Object.values(ENTITY_TYPES.LIGHT).includes(_this.getEntityType());
59493
+ });
59494
+
59495
+ _defineProperty$1(_assertThisInitialized(_this), "isHelper", function () {
59496
+ return Object.values(ENTITY_TYPES.HELPER).includes(_this.getEntityType());
59497
+ });
59498
+
59499
+ _defineProperty$1(_assertThisInitialized(_this), "isEffect", function () {
59500
+ return Object.values(ENTITY_TYPES.EFFECT).includes(_this.getEntityType());
59501
+ });
59502
+
59503
+ _defineProperty$1(_assertThisInitialized(_this), "setQuaternion", function (_ref2) {
59504
+ var x = _ref2.x,
59505
+ y = _ref2.y,
59506
+ z = _ref2.z,
59507
+ w = _ref2.w;
59343
59508
 
59344
- var rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
59345
- var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
59509
+ _this.body.quaternion.set(x, y, z, w);
59510
+ });
59346
59511
 
59347
- var _this$getRotation2 = this.getRotation(),
59348
- x = _this$getRotation2.x,
59349
- y = _this$getRotation2.y,
59350
- z = _this$getRotation2.z;
59512
+ _defineProperty$1(_assertThisInitialized(_this), "setUuid", function (uuid) {
59513
+ if (uuid) {
59514
+ _this.body.uuid = uuid;
59515
+ }
59516
+ });
59351
59517
 
59352
- return new Promise(function (resolve) {
59353
- return new Between({
59354
- x: x,
59355
- y: y,
59356
- z: z
59357
- }, rotation).time(time).on('update', function (value) {
59358
- return _this6.setRotation(value);
59359
- }).on('complete', resolve);
59360
- });
59361
- }
59362
- }, {
59363
- key: "goTo",
59364
- value: function goTo() {
59365
- var _this7 = this;
59518
+ _this.scripts = [];
59519
+ _this.tags = [];
59520
+ _this.children = [];
59521
+ _this.isMage = true;
59522
+ _this.parent = false;
59523
+ _this.disposed = false;
59366
59524
 
59367
- var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getPosition();
59368
- var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
59525
+ _this.addTags([DEFAULT_TAG, tag].concat(_toConsumableArray(tags)));
59369
59526
 
59370
- var _this$getPosition3 = this.getPosition(),
59371
- x = _this$getPosition3.x,
59372
- y = _this$getPosition3.y,
59373
- z = _this$getPosition3.z;
59527
+ _this.serializable = serializable;
59528
+ return _this;
59529
+ }
59374
59530
 
59375
- return new Promise(function (resolve) {
59376
- return new Between({
59377
- x: x,
59378
- y: y,
59379
- z: z
59380
- }, position).time(time).on('update', function (value) {
59381
- return _this7.setPosition(value);
59382
- }).on('complete', resolve);
59383
- });
59531
+ _createClass(Entity, [{
59532
+ key: "isSerializable",
59533
+ value: function isSerializable() {
59534
+ return !!this.serializable;
59384
59535
  }
59385
59536
  }, {
59386
- key: "uuid",
59387
- value: function uuid() {
59388
- return this.body.uuid;
59537
+ key: "isDisposed",
59538
+ value: function isDisposed() {
59539
+ return this.disposed;
59389
59540
  }
59390
59541
  }, {
59391
- key: "setId",
59392
- value: function setId() {
59393
- return this.body.id;
59542
+ key: "reset",
59543
+ value: function reset() {
59544
+ this.scripts = [];
59545
+ this.children = [];
59546
+ this.isMage = true;
59547
+ this.parent = false;
59548
+ this.tags = [DEFAULT_TAG];
59394
59549
  }
59395
59550
  }, {
59396
- key: "id",
59397
- value: function id() {
59398
- return this.body.id;
59551
+ key: "hasBody",
59552
+ value: function hasBody() {
59553
+ return !!this.body;
59399
59554
  }
59400
59555
  }, {
59401
- key: "setVisible",
59402
- value: function setVisible() {
59403
- var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
59404
- this.getBody().visible = flag;
59556
+ key: "getBody",
59557
+ value: function getBody() {
59558
+ return this.body;
59405
59559
  }
59406
59560
  }, {
59407
- key: "equals",
59408
- value: function equals(entity) {
59409
- try {
59410
- return entity.uuid ? this.uuid() === entity.uuid() : false;
59411
- } catch (e) {
59412
- return false;
59413
- }
59561
+ key: "setBody",
59562
+ value: function setBody(body) {
59563
+ this.body = body;
59414
59564
  }
59415
59565
  }, {
59416
- key: "setName",
59417
- value: function setName(name) {
59418
- this.name = name;
59566
+ key: "hasParent",
59567
+ value: function hasParent() {
59568
+ return !!this.parent;
59419
59569
  }
59420
59570
  }, {
59421
- key: "getName",
59422
- value: function getName() {
59423
- return this.name;
59571
+ key: "getParent",
59572
+ value: function getParent() {
59573
+ return this.parent;
59424
59574
  }
59425
59575
  }, {
59426
- key: "setData",
59427
- value: function setData(key, value) {
59428
- if (this.getBody().userData) {
59429
- if (key && value) {
59430
- this.getBody().userData[key] = value;
59431
- } else {
59432
- console.log(KEY_VALUE_IS_MISSING);
59433
- }
59434
- } else {
59435
- console.log(USER_DATA_IS_MISSING);
59436
- }
59576
+ key: "setParent",
59577
+ value: function setParent(parent) {
59578
+ this.parent = parent;
59437
59579
  }
59438
59580
  }, {
59439
- key: "getData",
59440
- value: function getData(key) {
59441
- if (this.getBody().userData) {
59442
- if (key) {
59443
- return this.getBody().userData[key];
59581
+ key: "add",
59582
+ value: function add(child) {
59583
+ var _this2 = this;
59584
+
59585
+ var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getBody();
59586
+
59587
+ if (this.hasBody()) {
59588
+ var _add = function _add(toAdd) {
59589
+ if (toAdd instanceof Entity) {
59590
+ _this2.children.push(toAdd);
59591
+
59592
+ toAdd.setParent(_this2);
59593
+ container.add(toAdd.getBody());
59594
+ } else {
59595
+ console.log(ENTITY_CANT_ADD_NOT_ENTITY);
59596
+ }
59597
+ };
59598
+
59599
+ if (Array.isArray(child)) {
59600
+ child.forEach(_add);
59444
59601
  } else {
59445
- console.log(KEY_IS_MISSING);
59602
+ _add(child);
59446
59603
  }
59447
59604
  } else {
59448
- console.log(USER_DATA_IS_MISSING);
59605
+ console.log(ENTITY_NOT_SET);
59449
59606
  }
59450
59607
  }
59451
59608
  }, {
59452
- key: "mapScriptsToJSON",
59453
- value: function mapScriptsToJSON() {
59454
- this.scripts.reduce(function (acc, _ref8) {
59455
- var name = _ref8.name,
59456
- _ref8$options = _ref8.options,
59457
- options = _ref8$options === void 0 ? {} : _ref8$options;
59458
- acc.names.push(name);
59459
- acc.options.push(options);
59460
- return acc;
59461
- }, {
59462
- names: [],
59463
- options: []
59464
- });
59465
- }
59466
- }, {
59467
- key: "toJSON",
59468
- value: function toJSON() {
59469
- return {
59470
- position: this.getPosition(),
59471
- rotation: this.getRotation(),
59472
- scale: this.getScale(),
59473
- entityType: this.getEntityType(),
59474
- tags: this.getTags()
59475
- };
59476
- }
59477
- }]);
59478
-
59479
- return Entity;
59480
- }(EventDispatcher);var AnimationHandler = /*#__PURE__*/function (_EventDispatcher) {
59481
- _inherits(AnimationHandler, _EventDispatcher);
59482
-
59483
- var _super = _createSuper(AnimationHandler);
59484
-
59485
- function AnimationHandler(mesh) {
59486
- var _this;
59487
-
59488
- var animations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
59489
-
59490
- _classCallCheck(this, AnimationHandler);
59491
-
59492
- _this = _super.call(this);
59493
-
59494
- _defineProperty$1(_assertThisInitialized(_this), "getAnimationEventHandler", function (type) {
59495
- return function (_ref) {
59496
- var action = _ref.action,
59497
- direction = _ref.direction;
59498
-
59499
- _this.dispatchEvent({
59500
- type: type,
59501
- action: action,
59502
- direction: direction
59503
- });
59609
+ key: "isParentOf",
59610
+ value: function isParentOf(child) {
59611
+ var comparator = function comparator(child) {
59612
+ return !!child.getBody().getObjectById(child.id);
59504
59613
  };
59505
- });
59506
-
59507
- _this.mixer = new AnimationMixer(mesh);
59508
- _this.animations = animations;
59509
-
59510
- _this.addEventsListeners();
59511
-
59512
- return _this;
59513
- }
59514
-
59515
- _createClass(AnimationHandler, [{
59516
- key: "addEventsListeners",
59517
- value: function addEventsListeners() {
59518
- this.mixer.addEventListener('loop', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.LOOP));
59519
- this.mixer.addEventListener('finished', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.FINISHED));
59520
- }
59521
- }, {
59522
- key: "getAction",
59523
- value: function getAction(id) {
59524
- var action;
59525
59614
 
59526
- if (typeof id === 'number') {
59527
- action = this.animations[id];
59528
- } else if (typeof id === 'string') {
59529
- action = AnimationClip.findByName(this.animations, id);
59615
+ if (child.isMage) {
59616
+ comparator = function comparator(child) {
59617
+ return child.getBody().getObjectById(child.id());
59618
+ };
59530
59619
  }
59531
59620
 
59532
- return action;
59533
- }
59534
- }, {
59535
- key: "getAvailableAnimations",
59536
- value: function getAvailableAnimations() {
59537
- return this.animations.map(function (_ref2) {
59538
- var name = _ref2.name;
59539
- return name;
59540
- });
59541
- }
59542
- }, {
59543
- key: "stopAll",
59544
- value: function stopAll() {
59545
- this.mixer.stopAllAction();
59621
+ return this.children.filter(comparator).length > 0;
59546
59622
  }
59547
59623
  }, {
59548
- key: "stopCurrentAnimation",
59549
- value: function stopCurrentAnimation() {
59550
- if (this.currentAction) {
59551
- this.currentAction.stop();
59624
+ key: "has",
59625
+ value: function has(child) {
59626
+ if (child.isMage) {
59627
+ return this.equals(child) || this.isParentOf(child);
59628
+ } else {
59629
+ return !!this.getBody().getObjectById(child.id);
59552
59630
  }
59553
59631
  }
59554
59632
  }, {
59555
- key: "playAnimation",
59556
- value: function playAnimation(id, options) {
59557
- var action = this.getAction(id);
59558
- var _options$loop = options.loop,
59559
- loop = _options$loop === void 0 ? LoopRepeat : _options$loop;
59560
-
59561
- if (this.currentAction) {
59562
- this.fadeToAnimation(action, options);
59563
- } else if (action) {
59564
- this.currentAction = this.mixer.clipAction(action).setLoop(loop).play();
59565
- } else {
59566
- console.warn(ANIMATION_NOT_FOUND);
59633
+ key: "remove",
59634
+ value: function remove(element) {
59635
+ if (this.hasBody() && this.has(element)) {
59636
+ if (element.isMage) {
59637
+ this.body.remove(element.getBody());
59638
+ var index = this.children.findIndex(function (m) {
59639
+ return m.equals(element);
59640
+ });
59641
+ if (index) this.children.splice(index, 1);
59642
+ } else {
59643
+ this.body.remove(element.getBody());
59644
+ }
59567
59645
  }
59568
59646
  }
59569
59647
  }, {
59570
- key: "fadeToAnimation",
59571
- value: function fadeToAnimation(action) {
59572
- var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
59573
- _ref3$duration = _ref3.duration,
59574
- duration = _ref3$duration === void 0 ? 0.2 : _ref3$duration,
59575
- _ref3$loop = _ref3.loop,
59576
- loop = _ref3$loop === void 0 ? LoopRepeat : _ref3$loop;
59577
-
59578
- var previousAction = this.currentAction;
59579
- this.currentAction = this.mixer.clipAction(action);
59580
-
59581
- if (previousAction !== this.currentAction) {
59582
- previousAction.fadeOut(duration);
59648
+ key: "addTo",
59649
+ value: function addTo(target, childName) {
59650
+ if (target && target.isMage) {
59651
+ if (childName) {
59652
+ target.add(this, target.getBodyByName(childName));
59653
+ } else {
59654
+ target.add(this);
59655
+ }
59583
59656
  }
59584
-
59585
- this.currentAction.reset().setEffectiveTimeScale(1).setEffectiveWeight(1).fadeIn(duration).setLoop(loop).play();
59586
59657
  }
59587
59658
  }, {
59588
- key: "update",
59589
- value: function update(dt) {
59590
- this.mixer.update(dt);
59659
+ key: "hasChildren",
59660
+ value: function hasChildren() {
59661
+ return this.children.length > 0;
59591
59662
  }
59592
- }]);
59593
-
59594
- return AnimationHandler;
59595
- }(EventDispatcher);var inverseProjectionMatrix = new Matrix4();
59596
-
59597
- var Frustum = /*#__PURE__*/function () {
59598
- function Frustum(data) {
59599
- _classCallCheck(this, Frustum);
59600
-
59601
- data = data || {};
59602
- this.vertices = {
59603
- near: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()],
59604
- far: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()]
59605
- };
59606
-
59607
- if (data.projectionMatrix !== undefined) {
59608
- this.setFromProjectionMatrix(data.projectionMatrix, data.maxFar || 10000);
59663
+ }, {
59664
+ key: "getHierarchy",
59665
+ value: function getHierarchy() {
59666
+ return {
59667
+ element: this,
59668
+ children: this.children.map(function (e) {
59669
+ return e.getHierarchy();
59670
+ })
59671
+ };
59609
59672
  }
59610
- }
59611
-
59612
- _createClass(Frustum, [{
59613
- key: "setFromProjectionMatrix",
59614
- value: function setFromProjectionMatrix(projectionMatrix, maxFar) {
59615
- var isOrthographic = projectionMatrix.elements[2 * 4 + 3] === 0;
59616
- inverseProjectionMatrix.copy(projectionMatrix).invert(); // 3 --- 0 vertices.near/far order
59617
- // | |
59618
- // 2 --- 1
59619
- // clip space spans from [-1, 1]
59620
-
59621
- this.vertices.near[0].set(1, 1, -1);
59622
- this.vertices.near[1].set(1, -1, -1);
59623
- this.vertices.near[2].set(-1, -1, -1);
59624
- this.vertices.near[3].set(-1, 1, -1);
59625
- this.vertices.near.forEach(function (v) {
59626
- v.applyMatrix4(inverseProjectionMatrix);
59627
- });
59628
- this.vertices.far[0].set(1, 1, 1);
59629
- this.vertices.far[1].set(1, -1, 1);
59630
- this.vertices.far[2].set(-1, -1, 1);
59631
- this.vertices.far[3].set(-1, 1, 1);
59632
- this.vertices.far.forEach(function (v) {
59633
- v.applyMatrix4(inverseProjectionMatrix);
59634
- var absZ = Math.abs(v.z);
59635
-
59636
- if (isOrthographic) {
59637
- v.z *= Math.min(maxFar / absZ, 1.0);
59638
- } else {
59639
- v.multiplyScalar(Math.min(maxFar / absZ, 1.0));
59640
- }
59641
- });
59642
- return this.vertices;
59673
+ }, {
59674
+ key: "addTags",
59675
+ value: function addTags() {
59676
+ var tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
59677
+ tags.forEach(this.addTag);
59643
59678
  }
59644
59679
  }, {
59645
- key: "split",
59646
- value: function split(breaks, target) {
59647
- while (breaks.length > target.length) {
59648
- target.push(new Frustum());
59680
+ key: "removeTag",
59681
+ value: function removeTag(tagName) {
59682
+ if (tagName === DEFAULT_TAG) {
59683
+ console.log(TAG_CANT_BE_REMOVED);
59684
+ return;
59649
59685
  }
59650
59686
 
59651
- target.length = breaks.length;
59652
-
59653
- for (var i = 0; i < breaks.length; i++) {
59654
- var cascade = target[i];
59655
-
59656
- if (i === 0) {
59657
- for (var j = 0; j < 4; j++) {
59658
- cascade.vertices.near[j].copy(this.vertices.near[j]);
59659
- }
59660
- } else {
59661
- for (var _j = 0; _j < 4; _j++) {
59662
- cascade.vertices.near[_j].lerpVectors(this.vertices.near[_j], this.vertices.far[_j], breaks[i - 1]);
59663
- }
59664
- }
59665
-
59666
- if (i === breaks - 1) {
59667
- for (var _j2 = 0; _j2 < 4; _j2++) {
59668
- cascade.vertices.far[_j2].copy(this.vertices.far[_j2]);
59669
- }
59670
- } else {
59671
- for (var _j3 = 0; _j3 < 4; _j3++) {
59672
- cascade.vertices.far[_j3].lerpVectors(this.vertices.near[_j3], this.vertices.far[_j3], breaks[i]);
59673
- }
59674
- }
59687
+ if (this.hasTag(tagName)) {
59688
+ this.tags.splice(this.tags.indexOf(tagName), 1);
59689
+ } else {
59690
+ console.log(TAG_NOT_EXISTING_REMOVAL);
59675
59691
  }
59676
59692
  }
59677
59693
  }, {
59678
- key: "toSpace",
59679
- value: function toSpace(cameraMatrix, target) {
59680
- for (var i = 0; i < 4; i++) {
59681
- target.vertices.near[i].copy(this.vertices.near[i]).applyMatrix4(cameraMatrix);
59682
- target.vertices.far[i].copy(this.vertices.far[i]).applyMatrix4(cameraMatrix);
59683
- }
59694
+ key: "removeAllTags",
59695
+ value: function removeAllTags() {
59696
+ this.tags = [DEFAULT_TAG];
59684
59697
  }
59685
- }]);
59686
-
59687
- return Frustum;
59688
- }();var Shader$1 = {
59689
- lights_fragment_begin:
59690
- /* glsl */
59691
- "\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n float linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n vec2 cascade;\n float cascadeCenter;\n float closestEdge;\n float margin;\n float csmx;\n float csmy;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n // NOTE: Depth gets larger away from the camera.\n // cascade.x is closer, cascade.y is further\n cascade = CSM_cascades[ i ];\n cascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n margin = 0.25 * pow( closestEdge, 2.0 );\n csmx = cascade.x - margin / 2.0;\n csmy = cascade.y + margin / 2.0;\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS && linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n float dist = min( linearDepth - csmx, csmy - linearDepth );\n float ratio = clamp( dist / margin, 0.0, 1.0 );\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) {\n\n vec3 prevColor = directLight.color;\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n }\n\n ReflectedLight prevLight = reflectedLight;\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n float blendRatio = shouldBlend ? ratio : 1.0;\n\n reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n }\n\n }\n #pragma unroll_loop_end\n #else\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #endif\n\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n RectAreaLight rectAreaLight;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",
59692
- lights_pars_begin:
59693
- /* glsl */
59694
- "\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n " + ShaderChunk.lights_pars_begin
59695
- };var _cameraToLightMatrix = new Matrix4();
59696
-
59697
- var _lightSpaceFrustum = new Frustum();
59698
-
59699
- var _center = new Vector3$1();
59700
-
59701
- var _bbox = new Box3();
59702
-
59703
- var _uniformArray = [];
59704
- var _logArray = [];
59705
- var DEFAULT_MAX_FAR = 100000;
59706
- var DEFAULT_MODE = 'practical';
59707
- var DEFAULT_SHADOWMAP_SIZE = 2048;
59708
- var DEFAULT_CASCADE = 3;
59709
- var DEFAULT_BIAS$3 = 0.000001;
59710
- var DEFAULT_INTENSITY$5 = 1;
59711
- var DEFAULT_NEAR$3 = 1;
59712
- var DEFAULT_FAR$3 = 2000;
59713
- var DEFAULT_MARGIN = 200;
59714
- var CascadeShadowMaps = /*#__PURE__*/function () {
59715
- function CascadeShadowMaps(_ref) {
59716
- var _ref$camera = _ref.camera,
59717
- camera = _ref$camera === void 0 ? Scene$1.getCameraBody() : _ref$camera,
59718
- _ref$parent = _ref.parent,
59719
- parent = _ref$parent === void 0 ? Scene$1.getScene() : _ref$parent,
59720
- _ref$cascades = _ref.cascades,
59721
- cascades = _ref$cascades === void 0 ? DEFAULT_CASCADE : _ref$cascades,
59722
- _ref$maxFar = _ref.maxFar,
59723
- maxFar = _ref$maxFar === void 0 ? DEFAULT_MAX_FAR : _ref$maxFar,
59724
- _ref$mode = _ref.mode,
59725
- mode = _ref$mode === void 0 ? DEFAULT_MODE : _ref$mode,
59726
- _ref$shadowMapSize = _ref.shadowMapSize,
59727
- shadowMapSize = _ref$shadowMapSize === void 0 ? DEFAULT_SHADOWMAP_SIZE : _ref$shadowMapSize,
59728
- _ref$shadowBias = _ref.shadowBias,
59729
- shadowBias = _ref$shadowBias === void 0 ? DEFAULT_BIAS$3 : _ref$shadowBias,
59730
- _ref$lightDirection = _ref.lightDirection,
59731
- lightDirection = _ref$lightDirection === void 0 ? new Vector3$1(1, -1, 1).normalize() : _ref$lightDirection,
59732
- _ref$lightIntensity = _ref.lightIntensity,
59733
- lightIntensity = _ref$lightIntensity === void 0 ? DEFAULT_INTENSITY$5 : _ref$lightIntensity,
59734
- _ref$lightNear = _ref.lightNear,
59735
- lightNear = _ref$lightNear === void 0 ? DEFAULT_NEAR$3 : _ref$lightNear,
59736
- _ref$lightFar = _ref.lightFar,
59737
- lightFar = _ref$lightFar === void 0 ? DEFAULT_FAR$3 : _ref$lightFar,
59738
- _ref$lightMargin = _ref.lightMargin,
59739
- lightMargin = _ref$lightMargin === void 0 ? DEFAULT_MARGIN : _ref$lightMargin,
59740
- customSplitsCallback = _ref.customSplitsCallback;
59741
-
59742
- _classCallCheck(this, CascadeShadowMaps);
59743
-
59744
- this.camera = camera;
59745
- this.parent = parent;
59746
- this.cascades = cascades;
59747
- this.maxFar = maxFar;
59748
- this.mode = mode;
59749
- this.shadowMapSize = shadowMapSize;
59750
- this.shadowBias = shadowBias;
59751
- this.lightDirection = lightDirection;
59752
- this.lightIntensity = lightIntensity;
59753
- this.lightNear = lightNear;
59754
- this.lightFar = lightFar;
59755
- this.lightMargin = lightMargin;
59756
- this.customSplitsCallback = customSplitsCallback;
59757
- this.fade = false;
59758
- this.mainFrustum = new Frustum();
59759
- this.frustums = [];
59760
- this.breaks = [];
59761
- this.lights = [];
59762
- this.shaders = new Map();
59763
- this.createLights();
59764
- this.updateFrustums();
59765
- this.injectInclude();
59766
- }
59767
-
59768
- _createClass(CascadeShadowMaps, [{
59769
- key: "createLights",
59770
- value: function createLights() {
59771
- for (var i = 0; i < this.cascades; i++) {
59772
- var light = new DirectionalLight(0xffffff, this.lightIntensity);
59773
- light.castShadow = true;
59774
- light.shadow.mapSize.width = this.shadowMapSize;
59775
- light.shadow.mapSize.height = this.shadowMapSize;
59776
- light.shadow.camera.near = this.lightNear;
59777
- light.shadow.camera.far = this.lightFar;
59778
- light.shadow.bias = this.shadowBias;
59779
- this.parent.add(light);
59780
- this.parent.add(light.target);
59781
- this.lights.push(light);
59782
- }
59698
+ }, {
59699
+ key: "hasTag",
59700
+ value: function hasTag(tagName) {
59701
+ return this.tags.includes(tagName);
59783
59702
  }
59784
59703
  }, {
59785
- key: "initCascades",
59786
- value: function initCascades() {
59787
- var camera = this.camera;
59788
- camera.updateProjectionMatrix();
59789
- this.mainFrustum.setFromProjectionMatrix(camera.projectionMatrix, this.maxFar);
59790
- this.mainFrustum.split(this.breaks, this.frustums);
59704
+ key: "getTags",
59705
+ value: function getTags() {
59706
+ return this.tags;
59791
59707
  }
59792
59708
  }, {
59793
- key: "updateShadowBounds",
59794
- value: function updateShadowBounds() {
59795
- var frustums = this.frustums;
59796
-
59797
- for (var i = 0; i < frustums.length; i++) {
59798
- var light = this.lights[i];
59799
- var shadowCam = light.shadow.camera;
59800
- var frustum = this.frustums[i]; // Get the two points that represent that furthest points on the frustum assuming
59801
- // that's either the diagonal across the far plane or the diagonal across the whole
59802
- // frustum itself.
59709
+ key: "disposeScripts",
59710
+ value: function disposeScripts() {
59711
+ if (this.hasScripts()) {
59712
+ var length = this.scripts.length;
59803
59713
 
59804
- var nearVerts = frustum.vertices.near;
59805
- var farVerts = frustum.vertices.far;
59806
- var point1 = farVerts[0];
59807
- var point2 = void 0;
59714
+ for (var i = 0; i < length; i++) {
59715
+ var _this$scripts$i = this.scripts[i],
59716
+ script = _this$scripts$i.script,
59717
+ enabled = _this$scripts$i.enabled;
59808
59718
 
59809
- if (point1.distanceTo(farVerts[2]) > point1.distanceTo(nearVerts[2])) {
59810
- point2 = farVerts[2];
59811
- } else {
59812
- point2 = nearVerts[2];
59813
- }
59719
+ if (enabled) {
59720
+ script.onDispose();
59814
59721
 
59815
- var squaredBBWidth = point1.distanceTo(point2);
59722
+ script.__setStartedFlag(false);
59723
+ }
59816
59724
 
59817
- if (this.fade) {
59818
- // expand the shadow extents by the fade margin if fade is enabled.
59819
- var camera = this.camera;
59820
- var far = Math.max(camera.far, this.maxFar);
59821
- var linearDepth = frustum.vertices.far[0].z / (far - camera.near);
59822
- var margin = 0.25 * Math.pow(linearDepth, 2.0) * (far - camera.near);
59823
- squaredBBWidth += margin;
59725
+ delete this.scripts[i];
59824
59726
  }
59825
-
59826
- shadowCam.left = -squaredBBWidth / 2;
59827
- shadowCam.right = squaredBBWidth / 2;
59828
- shadowCam.top = squaredBBWidth / 2;
59829
- shadowCam.bottom = -squaredBBWidth / 2;
59830
- shadowCam.updateProjectionMatrix();
59831
59727
  }
59832
59728
  }
59833
59729
  }, {
59834
- key: "getBreaks",
59835
- value: function getBreaks() {
59836
- var camera = this.camera;
59837
- var far = Math.min(camera.far, this.maxFar);
59838
- this.breaks.length = 0;
59839
-
59840
- switch (this.mode) {
59841
- case 'uniform':
59842
- uniformSplit(this.cascades, camera.near, far, this.breaks);
59843
- break;
59730
+ key: "start",
59731
+ value: function start() {
59732
+ var _this3 = this;
59844
59733
 
59845
- case 'logarithmic':
59846
- logarithmicSplit(this.cascades, camera.near, far, this.breaks);
59847
- break;
59734
+ if (this.hasScripts()) {
59735
+ this.scripts.forEach(function (_ref3) {
59736
+ var script = _ref3.script,
59737
+ enabled = _ref3.enabled,
59738
+ options = _ref3.options;
59848
59739
 
59849
- case 'practical':
59850
- practicalSplit(this.cascades, camera.near, far, 0.5, this.breaks);
59851
- break;
59740
+ if (enabled) {
59741
+ script.start(_this3, options);
59852
59742
 
59853
- case 'custom':
59854
- if (this.customSplitsCallback === undefined) console.error('CSM: Custom split scheme callback not defined.');
59855
- this.customSplitsCallback(this.cascades, camera.near, far, this.breaks);
59856
- break;
59743
+ script.__setStartedFlag(true);
59744
+ }
59745
+ });
59857
59746
  }
59747
+ }
59748
+ }, {
59749
+ key: "update",
59750
+ value: function update(dt) {
59751
+ if (this.hasScripts()) {
59752
+ this.scripts.forEach(function (_ref4) {
59753
+ var script = _ref4.script,
59754
+ enabled = _ref4.enabled;
59858
59755
 
59859
- function uniformSplit(amount, near, far, target) {
59860
- for (var i = 1; i < amount; i++) {
59861
- target.push((near + (far - near) * i / amount) / far);
59862
- }
59756
+ if (script && enabled) {
59757
+ script.update(dt);
59758
+ }
59759
+ });
59760
+ }
59761
+ }
59762
+ }, {
59763
+ key: "onPhysicsUpdate",
59764
+ value: function onPhysicsUpdate(dt) {
59765
+ if (this.hasScripts()) {
59766
+ this.scripts.forEach(function (_ref5) {
59767
+ var script = _ref5.script,
59768
+ enabled = _ref5.enabled;
59863
59769
 
59864
- target.push(1);
59770
+ if (script && enabled) {
59771
+ script.physicsUpdate(dt);
59772
+ }
59773
+ });
59865
59774
  }
59775
+ }
59776
+ }, {
59777
+ key: "disposeBody",
59778
+ value: function disposeBody() {
59779
+ this.getBody().clear();
59866
59780
 
59867
- function logarithmicSplit(amount, near, far, target) {
59868
- for (var i = 1; i < amount; i++) {
59869
- target.push(near * Math.pow(far / near, i / amount) / far);
59870
- }
59781
+ if (this.getBody().dispose && !isScene(this.getBody())) {
59782
+ this.getBody().dispose();
59783
+ }
59784
+ }
59785
+ }, {
59786
+ key: "dispose",
59787
+ value: function dispose() {
59788
+ if (this.hasChildren()) {
59789
+ this.children.forEach(function (child) {
59790
+ child.dispose();
59791
+ });
59792
+ }
59871
59793
 
59872
- target.push(1);
59794
+ if (this.hasBody()) {
59795
+ this.stopStateMachine();
59796
+ this.disposeScripts();
59797
+ Scene$1.remove(this.getBody());
59798
+ this.disposeBody();
59873
59799
  }
59874
59800
 
59875
- function practicalSplit(amount, near, far, lambda, target) {
59876
- _uniformArray.length = 0;
59877
- _logArray.length = 0;
59878
- logarithmicSplit(amount, near, far, _logArray);
59879
- uniformSplit(amount, near, far, _uniformArray);
59801
+ this.dispatchEvent({
59802
+ type: ENTITY_EVENTS.DISPOSE
59803
+ });
59804
+ this.reset();
59805
+ }
59806
+ }, {
59807
+ key: "addStateMachine",
59808
+ value: function addStateMachine(description) {
59809
+ var _this4 = this;
59880
59810
 
59881
- for (var i = 1; i < amount; i++) {
59882
- target.push(MathUtils.lerp(_uniformArray[i - 1], _logArray[i - 1], lambda));
59883
- }
59811
+ this.stateMachine = interpret(createMachine(description)).onTransition(function (state) {
59812
+ _this4.dispatchEvent({
59813
+ type: ENTITY_EVENTS.STATE_MACHINE.CHANGE,
59814
+ state: state
59815
+ });
59816
+ });
59884
59817
 
59885
- target.push(1);
59818
+ if (description.autostart) {
59819
+ this.startStateMachine();
59886
59820
  }
59887
59821
  }
59888
59822
  }, {
59889
- key: "update",
59890
- value: function update() {
59891
- var camera = this.camera;
59892
- var frustums = this.frustums;
59893
-
59894
- for (var i = 0; i < frustums.length; i++) {
59895
- var light = this.lights[i];
59896
- var shadowCam = light.shadow.camera;
59897
- var texelWidth = (shadowCam.right - shadowCam.left) / this.shadowMapSize;
59898
- var texelHeight = (shadowCam.top - shadowCam.bottom) / this.shadowMapSize;
59899
- light.shadow.camera.updateMatrixWorld(true);
59823
+ key: "startStateMachine",
59824
+ value: function startStateMachine() {
59825
+ if (this.hasStateMachine()) {
59826
+ this.stateMachine.start();
59827
+ } else {
59828
+ console.log(STATE_MACHINE_NOT_AVAILABLE);
59829
+ }
59830
+ }
59831
+ }, {
59832
+ key: "stopStateMachine",
59833
+ value: function stopStateMachine() {
59834
+ if (this.hasStateMachine()) {
59835
+ this.stateMachine.stop();
59836
+ }
59837
+ }
59838
+ }, {
59839
+ key: "changeState",
59840
+ value: function changeState(event) {
59841
+ if (this.hasStateMachine()) {
59842
+ this.stateMachine.send(event);
59843
+ } else {
59844
+ console.log(STATE_MACHINE_NOT_AVAILABLE);
59845
+ }
59846
+ }
59847
+ }, {
59848
+ key: "getScript",
59849
+ value: function getScript(name) {
59850
+ var script = this.scripts.filter(function (script) {
59851
+ return script.name === name;
59852
+ })[0].script;
59900
59853
 
59901
- _cameraToLightMatrix.multiplyMatrices(light.shadow.camera.matrixWorldInverse, camera.matrixWorld);
59854
+ if (script) {
59855
+ return script;
59856
+ } else {
59857
+ console.warn(SCRIPT_NOT_FOUND);
59858
+ }
59859
+ }
59860
+ }, {
59861
+ key: "addScripts",
59862
+ value: function addScripts() {
59863
+ var _this5 = this;
59902
59864
 
59903
- frustums[i].toSpace(_cameraToLightMatrix, _lightSpaceFrustum);
59904
- var nearVerts = _lightSpaceFrustum.vertices.near;
59905
- var farVerts = _lightSpaceFrustum.vertices.far;
59865
+ var scripts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
59866
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
59867
+ var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
59868
+ var parsedScripts = this.parseScripts(scripts, options, enabled);
59869
+ this.scripts = [].concat(_toConsumableArray(this.scripts), [parsedScripts]);
59906
59870
 
59907
- _bbox.makeEmpty();
59871
+ if (enabled) {
59872
+ parsedScripts.forEach(function (parsed) {
59873
+ return parsed.start(_this5, parsed.options);
59874
+ });
59875
+ }
59876
+ }
59877
+ }, {
59878
+ key: "addScript",
59879
+ value: function addScript(name) {
59880
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
59881
+ var script = Scripts$1.get(name);
59882
+ var _options$enabled = options.enabled,
59883
+ enabled = _options$enabled === void 0 ? true : _options$enabled;
59908
59884
 
59909
- for (var j = 0; j < 4; j++) {
59910
- _bbox.expandByPoint(nearVerts[j]);
59885
+ if (script) {
59886
+ this.scripts.push({
59887
+ script: script,
59888
+ name: name,
59889
+ enabled: enabled,
59890
+ options: options
59891
+ });
59911
59892
 
59912
- _bbox.expandByPoint(farVerts[j]);
59893
+ if (enabled) {
59894
+ script.start(this, options);
59913
59895
  }
59896
+ } else {
59897
+ console.log(SCRIPT_NOT_FOUND);
59898
+ }
59914
59899
 
59915
- _bbox.getCenter(_center);
59916
-
59917
- _center.z = _bbox.max.z + this.lightMargin;
59918
- _center.x = Math.floor(_center.x / texelWidth) * texelWidth;
59919
- _center.y = Math.floor(_center.y / texelHeight) * texelHeight;
59920
-
59921
- _center.applyMatrix4(light.shadow.camera.matrixWorld);
59922
-
59923
- light.position.copy(_center);
59924
- light.target.position.copy(_center);
59925
- light.target.position.x += this.lightDirection.x;
59926
- light.target.position.y += this.lightDirection.y;
59927
- light.target.position.z += this.lightDirection.z;
59900
+ return script;
59901
+ }
59902
+ }, {
59903
+ key: "enableScripts",
59904
+ value: function enableScripts() {
59905
+ this.scriptsEnabled = true;
59906
+ }
59907
+ }, {
59908
+ key: "disableScripts",
59909
+ value: function disableScripts() {
59910
+ this.scriptsEnabled = false;
59911
+ }
59912
+ }, {
59913
+ key: "setEntityType",
59914
+ value: function setEntityType(type) {
59915
+ if (FLAT_ENTITY_TYPES.includes(type)) {
59916
+ this.entityType = type;
59917
+ } else {
59918
+ console.log(ENTITY_TYPE_NOT_ALLOWED);
59919
+ this.entityType = ENTITY_TYPES.UNKNOWN;
59928
59920
  }
59929
59921
  }
59930
59922
  }, {
59931
- key: "injectInclude",
59932
- value: function injectInclude() {
59933
- ShaderChunk.lights_fragment_begin = Shader$1.lights_fragment_begin;
59934
- ShaderChunk.lights_pars_begin = Shader$1.lights_pars_begin;
59923
+ key: "getEntityType",
59924
+ value: function getEntityType() {
59925
+ return this.entityType;
59935
59926
  }
59936
59927
  }, {
59937
- key: "setupMaterial",
59938
- value: function setupMaterial(material) {
59939
- material.defines = material.defines || {};
59940
- material.defines.USE_CSM = 1;
59941
- material.defines.CSM_CASCADES = this.cascades;
59928
+ key: "addLight",
59929
+ // TODO: sounds should become entities
59930
+ // addSound(name, options) {
59931
+ // const { autoplay = false, ...opts } = options;
59932
+ // this.isPlayingSound = autoplay;
59933
+ // this.sound = new Sound(name, {
59934
+ // autoplay,
59935
+ // ...opts
59936
+ // });
59937
+ // this.sound.setTarget(this);
59938
+ // return this.sound;
59939
+ // }
59940
+ // addDirectionalSound(name, options) {
59941
+ // const { autoplay = false, ...opts } = options;
59942
+ // this.isPlayingSound = autoplay;
59943
+ // this.sound = new DirectionalSound(name, {
59944
+ // autoplay,
59945
+ // ...opts
59946
+ // });
59947
+ // this.sound.setTarget(this);
59948
+ // return this.sound;
59949
+ // }
59950
+ // addAmbientSound(name, options) {
59951
+ // const { autoplay = false, ...opts } = options;
59952
+ // this.isPlayingSound = autoplay;
59953
+ // this.sound = new AmbientSound(name, {
59954
+ // body: this.body,
59955
+ // autoplay,
59956
+ // ...opts
59957
+ // });
59958
+ // return this.sound;
59959
+ // }
59960
+ value: function addLight(light) {
59961
+ var _this$getPosition = this.getPosition(),
59962
+ x = _this$getPosition.x,
59963
+ y = _this$getPosition.y,
59964
+ z = _this$getPosition.z;
59942
59965
 
59943
- if (this.fade) {
59944
- material.defines.CSM_FADE = '';
59966
+ light.setPosition({
59967
+ x: x,
59968
+ y: y,
59969
+ z: z
59970
+ });
59971
+ this.light = light;
59972
+ }
59973
+ }, {
59974
+ key: "playSound",
59975
+ value: function playSound() {
59976
+ if (this.sound && !this.isPlayingSound) {
59977
+ this.sound.play();
59978
+ this.isPlayingSound = true;
59945
59979
  }
59946
-
59947
- var breaksVec2 = [];
59948
- var scope = this;
59949
- var shaders = this.shaders;
59950
-
59951
- material.onBeforeCompile = function (shader) {
59952
- var far = Math.min(scope.camera.far, scope.maxFar);
59953
- scope.getExtendedBreaks(breaksVec2);
59954
- shader.uniforms.CSM_cascades = {
59955
- value: breaksVec2
59956
- };
59957
- shader.uniforms.cameraNear = {
59958
- value: scope.camera.near
59959
- };
59960
- shader.uniforms.shadowFar = {
59961
- value: far
59962
- };
59963
- shaders.set(material, shader);
59980
+ }
59981
+ }, {
59982
+ key: "stopSound",
59983
+ value: function stopSound() {
59984
+ if (this.sound && this.isPlayingSound) {
59985
+ this.sound.stop();
59986
+ this.isPlayingSound = false;
59987
+ }
59988
+ }
59989
+ }, {
59990
+ key: "getScale",
59991
+ value: function getScale() {
59992
+ return {
59993
+ x: this.body.scale.x,
59994
+ y: this.body.scale.y,
59995
+ z: this.body.scale.z
59964
59996
  };
59965
-
59966
- shaders.set(material, null);
59967
59997
  }
59968
59998
  }, {
59969
- key: "updateUniforms",
59970
- value: function updateUniforms() {
59971
- var far = Math.min(this.camera.far, this.maxFar);
59972
- var shaders = this.shaders;
59973
- shaders.forEach(function (shader, material) {
59974
- if (shader !== null) {
59975
- var uniforms = shader.uniforms;
59976
- this.getExtendedBreaks(uniforms.CSM_cascades.value);
59977
- uniforms.cameraNear.value = this.camera.near;
59978
- uniforms.shadowFar.value = far;
59979
- }
59999
+ key: "setScale",
60000
+ value: function setScale(howbig) {
60001
+ if (this.hasBody()) {
60002
+ var scale = _objectSpread2$1(_objectSpread2$1({}, this.getScale()), howbig);
59980
60003
 
59981
- if (!this.fade && 'CSM_FADE' in material.defines) {
59982
- delete material.defines.CSM_FADE;
59983
- material.needsUpdate = true;
59984
- } else if (this.fade && !('CSM_FADE' in material.defines)) {
59985
- material.defines.CSM_FADE = '';
59986
- material.needsUpdate = true;
59987
- }
59988
- }, this);
60004
+ this.body.scale.set(scale.x, scale.y, scale.z);
60005
+ }
59989
60006
  }
59990
60007
  }, {
59991
- key: "getExtendedBreaks",
59992
- value: function getExtendedBreaks(target) {
59993
- while (target.length < this.breaks.length) {
59994
- target.push(new Vector2());
60008
+ key: "getQuaternion",
60009
+ value: function getQuaternion() {
60010
+ if (this.hasBody()) {
60011
+ return this.getBody().quaternion.clone();
60012
+ }
60013
+ }
60014
+ }, {
60015
+ key: "getPosition",
60016
+ value: function getPosition() {
60017
+ return this.getBody().position.clone();
60018
+ }
60019
+ }, {
60020
+ key: "setPosition",
60021
+ value: function setPosition(where) {
60022
+ if (this.hasBody()) {
60023
+ var _this$getPosition2 = this.getPosition(),
60024
+ x = _this$getPosition2.x,
60025
+ y = _this$getPosition2.y,
60026
+ z = _this$getPosition2.z;
60027
+
60028
+ var position = _objectSpread2$1({
60029
+ x: x,
60030
+ y: y,
60031
+ z: z
60032
+ }, where);
60033
+
60034
+ this.body.position.set(position.x, position.y, position.z);
59995
60035
  }
60036
+ }
60037
+ }, {
60038
+ key: "getRotation",
60039
+ value: function getRotation() {
60040
+ return this.getBody().rotation.clone();
60041
+ }
60042
+ }, {
60043
+ key: "setRotation",
60044
+ value: function setRotation(how) {
60045
+ if (this.hasBody()) {
60046
+ var _this$getRotation = this.getRotation(),
60047
+ x = _this$getRotation.x,
60048
+ y = _this$getRotation.y,
60049
+ z = _this$getRotation.z;
59996
60050
 
59997
- target.length = this.breaks.length;
60051
+ var rotation = _objectSpread2$1({
60052
+ x: x,
60053
+ y: y,
60054
+ z: z
60055
+ }, how);
59998
60056
 
59999
- for (var i = 0; i < this.cascades; i++) {
60000
- var amount = this.breaks[i];
60001
- var prev = this.breaks[i - 1] || 0;
60002
- target[i].x = prev;
60003
- target[i].y = amount;
60057
+ this.body.rotation.set(rotation.x, rotation.y, rotation.z);
60004
60058
  }
60005
60059
  }
60006
60060
  }, {
60007
- key: "updateFrustums",
60008
- value: function updateFrustums() {
60009
- this.getBreaks();
60010
- this.initCascades();
60011
- this.updateShadowBounds();
60012
- this.updateUniforms();
60061
+ key: "getWorldTransform",
60062
+ value: function getWorldTransform() {
60063
+ var position = this.getBody().getWorldPosition(new Vector3$1());
60064
+ var quaternion = this.getBody().getWorldQuaternion(new Quaternion(0, 0, 0, 1));
60065
+ var rotation = new Euler(0, 0, 0, 'XYZ').setFromQuaternion(quaternion, 'XYZ');
60066
+ return {
60067
+ position: position,
60068
+ rotation: rotation,
60069
+ quaternion: quaternion
60070
+ };
60013
60071
  }
60014
60072
  }, {
60015
- key: "remove",
60016
- value: function remove() {
60017
- for (var i = 0; i < this.lights.length; i++) {
60018
- this.parent.remove(this.lights[i]);
60073
+ key: "translate",
60074
+ value: function translate(_ref6) {
60075
+ var _ref6$x = _ref6.x,
60076
+ x = _ref6$x === void 0 ? 0 : _ref6$x,
60077
+ _ref6$y = _ref6.y,
60078
+ y = _ref6$y === void 0 ? 0 : _ref6$y,
60079
+ _ref6$z = _ref6.z,
60080
+ z = _ref6$z === void 0 ? 0 : _ref6$z;
60081
+
60082
+ if (this.hasBody()) {
60083
+ this.body.translateX(x);
60084
+ this.body.translateY(y);
60085
+ this.body.translateZ(z);
60019
60086
  }
60020
60087
  }
60021
60088
  }, {
60022
- key: "dispose",
60023
- value: function dispose() {
60024
- var shaders = this.shaders;
60025
- shaders.forEach(function (shader, material) {
60026
- delete material.onBeforeCompile;
60027
- delete material.defines.USE_CSM;
60028
- delete material.defines.CSM_CASCADES;
60029
- delete material.defines.CSM_FADE;
60089
+ key: "rotateTo",
60090
+ value: function rotateTo() {
60091
+ var _this6 = this;
60030
60092
 
60031
- if (shader !== null) {
60032
- delete shader.uniforms.CSM_cascades;
60033
- delete shader.uniforms.cameraNear;
60034
- delete shader.uniforms.shadowFar;
60035
- }
60093
+ var rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
60094
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
60036
60095
 
60037
- material.needsUpdate = true;
60096
+ var _this$getRotation2 = this.getRotation(),
60097
+ x = _this$getRotation2.x,
60098
+ y = _this$getRotation2.y,
60099
+ z = _this$getRotation2.z;
60100
+
60101
+ return new Promise(function (resolve) {
60102
+ return new Between({
60103
+ x: x,
60104
+ y: y,
60105
+ z: z
60106
+ }, rotation).time(time).on('update', function (value) {
60107
+ return !_this6.isDisposed() && _this6.setRotation(value);
60108
+ }).on('complete', resolve);
60038
60109
  });
60039
- shaders.clear();
60040
60110
  }
60041
- }]);
60111
+ }, {
60112
+ key: "goTo",
60113
+ value: function goTo() {
60114
+ var _this7 = this;
60042
60115
 
60043
- return CascadeShadowMaps;
60044
- }();var POINTLIGHT = 'pointlight';
60045
- var AMBIENTLIGHT = 'ambientlight';
60046
- var SUNLIGHT = 'sunlight';
60047
- var SPOTLIGHT = 'spotlight';
60048
- var HEMISPHERELIGHT = 'hemisphere';
60049
- var TIME_TO_UPDATE = 100;
60050
- var Lights = /*#__PURE__*/function () {
60051
- function Lights() {
60052
- _classCallCheck(this, Lights);
60116
+ var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getPosition();
60117
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
60053
60118
 
60054
- this.delayFactor = 0.1;
60055
- this.delayStep = 30;
60056
- this.holderRadius = 0.01;
60057
- this.holderSegments = 1;
60058
- this.numLights = 0;
60059
- this.map = {};
60060
- this.lights = [];
60061
- this.csm = undefined;
60062
- }
60119
+ var _this$getPosition3 = this.getPosition(),
60120
+ x = _this$getPosition3.x,
60121
+ y = _this$getPosition3.y,
60122
+ z = _this$getPosition3.z;
60063
60123
 
60064
- _createClass(Lights, [{
60065
- key: "isUsingCSM",
60066
- value: function isUsingCSM() {
60067
- return !!this.csm;
60124
+ return new Promise(function (resolve) {
60125
+ return new Between({
60126
+ x: x,
60127
+ y: y,
60128
+ z: z
60129
+ }, position).time(time).on('update', function (value) {
60130
+ return !_this7.isDisposed() && _this7.setPosition(value);
60131
+ }).on('complete', resolve);
60132
+ });
60068
60133
  }
60069
60134
  }, {
60070
- key: "setUpCSM",
60071
- value: function setUpCSM() {
60072
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60073
- this.csm = new CascadeShadowMaps(options);
60135
+ key: "uuid",
60136
+ value: function uuid() {
60137
+ return this.body.uuid;
60074
60138
  }
60075
60139
  }, {
60076
- key: "add",
60077
- value: function add(light) {
60078
- this.lights.push(light);
60140
+ key: "setId",
60141
+ value: function setId() {
60142
+ return this.body.id;
60079
60143
  }
60080
60144
  }, {
60081
- key: "update",
60082
- value: function update(dt) {
60083
- if (this.isUsingCSM()) {
60084
- this.csm.update();
60145
+ key: "id",
60146
+ value: function id() {
60147
+ return this.body.id;
60148
+ }
60149
+ }, {
60150
+ key: "setVisible",
60151
+ value: function setVisible() {
60152
+ var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
60153
+ this.getBody().visible = flag;
60154
+ }
60155
+ }, {
60156
+ key: "equals",
60157
+ value: function equals(entity) {
60158
+ try {
60159
+ return entity.uuid ? this.uuid() === entity.uuid() : false;
60160
+ } catch (e) {
60161
+ return false;
60085
60162
  }
60086
-
60087
- var start = new Date();
60088
-
60089
- for (var index in this.lights) {
60090
- var light = this.lights[index];
60091
- light.update(dt);
60092
- if (+new Date() - start > TIME_TO_UPDATE) break;
60163
+ }
60164
+ }, {
60165
+ key: "setName",
60166
+ value: function setName(name) {
60167
+ this.name = name;
60168
+ }
60169
+ }, {
60170
+ key: "getName",
60171
+ value: function getName() {
60172
+ return this.name;
60173
+ }
60174
+ }, {
60175
+ key: "setData",
60176
+ value: function setData(key, value) {
60177
+ if (this.getBody().userData) {
60178
+ if (key && value) {
60179
+ this.getBody().userData[key] = value;
60180
+ } else {
60181
+ console.log(KEY_VALUE_IS_MISSING);
60182
+ }
60183
+ } else {
60184
+ console.log(USER_DATA_IS_MISSING);
60185
+ }
60186
+ }
60187
+ }, {
60188
+ key: "getData",
60189
+ value: function getData(key) {
60190
+ if (this.getBody().userData) {
60191
+ if (key) {
60192
+ return this.getBody().userData[key];
60193
+ } else {
60194
+ console.log(KEY_IS_MISSING);
60195
+ }
60196
+ } else {
60197
+ console.log(USER_DATA_IS_MISSING);
60093
60198
  }
60094
60199
  }
60200
+ }, {
60201
+ key: "mapScriptsToJSON",
60202
+ value: function mapScriptsToJSON() {
60203
+ this.scripts.reduce(function (acc, _ref7) {
60204
+ var name = _ref7.name,
60205
+ _ref7$options = _ref7.options,
60206
+ options = _ref7$options === void 0 ? {} : _ref7$options;
60207
+ acc.names.push(name);
60208
+ acc.options.push(options);
60209
+ return acc;
60210
+ }, {
60211
+ names: [],
60212
+ options: []
60213
+ });
60214
+ }
60095
60215
  }, {
60096
60216
  key: "toJSON",
60097
60217
  value: function toJSON() {
60098
- return {
60099
- lights: this.lights.map(function (l) {
60100
- return l.toJSON();
60101
- })
60102
- };
60218
+ if (this.isSerializable()) {
60219
+ return {
60220
+ position: this.getPosition(),
60221
+ rotation: this.getRotation(),
60222
+ scale: this.getScale(),
60223
+ entityType: this.getEntityType(),
60224
+ scripts: this.mapScriptsToJSON(),
60225
+ tags: this.getTags()
60226
+ };
60227
+ }
60103
60228
  }
60104
- }]);
60105
-
60106
- return Lights;
60107
- }();
60108
- var Lights$1 = new Lights();var ToonShader = {
60109
- uniforms: {
60110
- "uDirLightPos": {
60111
- type: "v3",
60112
- value: new Vector3$1()
60113
- },
60114
- "uDirLightColor": {
60115
- type: "c",
60116
- value: new Color$1(0xffffff)
60117
- },
60118
- "uMaterialColor": {
60119
- type: "c",
60120
- value: new Color$1(0xffffff)
60121
- },
60122
- uKd: {
60123
- type: "f",
60124
- value: 1
60125
- },
60126
- uBorder: {
60127
- type: "f",
60128
- value: 0.4
60229
+ }], [{
60230
+ key: "create",
60231
+ value: function create() {
60232
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60233
+ return new this(options);
60129
60234
  }
60130
- },
60131
- vertexShader: ["varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "vNormal = normalize( normalMatrix * normal );", "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", "vViewPosition = -mvPosition.xyz;", "}"].join("\n"),
60132
- fragmentShader: ["uniform vec3 uMaterialColor;", "uniform vec3 uDirLightPos;", "uniform vec3 uDirLightColor;", "uniform float uKd;", "uniform float uBorder;", "varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", // compute direction to light
60133
- "vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );", "vec3 lVector = normalize( lDirection.xyz );", // diffuse: N * L. Normal must be normalized, since it's interpolated.
60134
- "vec3 normal = normalize( vNormal );", //was: "float diffuse = max( dot( normal, lVector ), 0.0);",
60135
- // solution
60136
- "float diffuse = dot( normal, lVector );", "if ( diffuse > 0.6 ) { diffuse = 1.0; }", "else if ( diffuse > -0.2 ) { diffuse = 0.7; }", "else { diffuse = 0.3; }", "gl_FragColor = vec4( uKd * uMaterialColor * uDirLightColor * diffuse, 1.0 );", "}"].join("\n")
60137
- };
60235
+ }]);
60138
60236
 
60139
- var ToonMaterial = /*#__PURE__*/function (_ShaderMaterial) {
60140
- _inherits(ToonMaterial, _ShaderMaterial);
60237
+ return Entity;
60238
+ }(EventDispatcher);var AnimationHandler = /*#__PURE__*/function (_EventDispatcher) {
60239
+ _inherits(AnimationHandler, _EventDispatcher);
60141
60240
 
60142
- var _super = _createSuper(ToonMaterial);
60241
+ var _super = _createSuper(AnimationHandler);
60143
60242
 
60144
- function ToonMaterial(_ref) {
60243
+ function AnimationHandler(mesh) {
60145
60244
  var _this;
60146
60245
 
60147
- var _ref$light = _ref.light,
60148
- light = _ref$light === void 0 ? {} : _ref$light,
60149
- color = _ref.color;
60246
+ var animations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
60150
60247
 
60151
- _classCallCheck(this, ToonMaterial);
60248
+ _classCallCheck(this, AnimationHandler);
60152
60249
 
60153
- var uniforms = UniformsUtils.clone(ToonShader.uniforms);
60154
- var vertexShader = ToonShader.vertexShader,
60155
- fragmentShader = ToonShader.fragmentShader;
60156
- _this = _super.call(this, {
60157
- uniforms: uniforms,
60158
- vertexShader: vertexShader,
60159
- fragmentShader: fragmentShader,
60160
- flatShading: true
60161
- });
60162
- var position = light.position,
60163
- lightColor = light.color;
60250
+ _this = _super.call(this);
60164
60251
 
60165
- if (color) {
60166
- var materialColor = new Color$1(color);
60252
+ _defineProperty$1(_assertThisInitialized(_this), "getAnimationEventHandler", function (type) {
60253
+ return function (_ref) {
60254
+ var action = _ref.action,
60255
+ direction = _ref.direction;
60167
60256
 
60168
- _this.uniforms.uMaterialColor.value.copy(materialColor);
60169
- }
60257
+ _this.dispatchEvent({
60258
+ type: type,
60259
+ action: action,
60260
+ direction: direction
60261
+ });
60262
+ };
60263
+ });
60170
60264
 
60171
- _this.uniforms.uDirLightPos.value = position;
60265
+ _this.mixer = new AnimationMixer(mesh);
60266
+ _this.animations = animations;
60267
+ _this.isPlaying = false;
60172
60268
 
60173
- _this.uniforms.uDirLightColor.value.copy(new Color$1(lightColor));
60269
+ _this.addEventsListeners();
60174
60270
 
60175
- _this.side = DoubleSide;
60176
60271
  return _this;
60177
60272
  }
60178
60273
 
60179
- return ToonMaterial;
60180
- }(ShaderMaterial);var setUpLightsAndShadows = function setUpLightsAndShadows(mesh) {
60181
- var _Config$lights = Config$1.lights(),
60182
- textureAnisotropy = _Config$lights.textureAnisotropy,
60183
- shadows = _Config$lights.shadows;
60184
-
60185
- mesh.castShadow = Boolean(shadows);
60186
- mesh.receiveShadow = Boolean(shadows);
60274
+ _createClass(AnimationHandler, [{
60275
+ key: "addEventsListeners",
60276
+ value: function addEventsListeners() {
60277
+ this.mixer.addEventListener('loop', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.LOOP));
60278
+ this.mixer.addEventListener('finished', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.FINISHED));
60279
+ }
60280
+ }, {
60281
+ key: "getAction",
60282
+ value: function getAction(id) {
60283
+ var action;
60187
60284
 
60188
- if (hasMaterial(mesh)) {
60189
- var setUpMaterial = function setUpMaterial(material) {
60190
- if (Lights$1.isUsingCSM()) {
60191
- Lights$1.csm.setupMaterial(material);
60285
+ if (typeof id === 'number') {
60286
+ action = this.animations[id];
60287
+ } else if (typeof id === 'string') {
60288
+ action = AnimationClip.findByName(this.animations, id);
60192
60289
  }
60193
60290
 
60194
- if (material.map) {
60195
- material.map.anisotropy = textureAnisotropy;
60291
+ return action;
60292
+ }
60293
+ }, {
60294
+ key: "getAvailableAnimations",
60295
+ value: function getAvailableAnimations() {
60296
+ return this.animations.map(function (_ref2) {
60297
+ var name = _ref2.name;
60298
+ return name;
60299
+ });
60300
+ }
60301
+ }, {
60302
+ key: "stopAll",
60303
+ value: function stopAll() {
60304
+ this.mixer.stopAllAction();
60305
+ this.isPlaying = false;
60306
+ }
60307
+ }, {
60308
+ key: "stopCurrentAnimation",
60309
+ value: function stopCurrentAnimation() {
60310
+ if (this.currentAction) {
60311
+ this.currentAction.stop();
60196
60312
  }
60197
60313
 
60198
- return material;
60199
- };
60200
-
60201
- mesh.material = processMaterial(mesh.material, setUpMaterial);
60202
- }
60203
- };
60204
-
60205
- var hasMaterial = function hasMaterial(mesh) {
60206
- return Boolean(mesh.material);
60207
- };
60208
- var hasGeometry = function hasGeometry(mesh) {
60209
- return Boolean(mesh.geometry);
60210
- };
60211
- var processMaterial = function processMaterial(material, callback) {
60212
- return Array.isArray(material) ? material.map(callback) : callback(material);
60213
- };
60214
- var changeMaterialByName = function changeMaterialByName(name, mesh, materialOptions) {
60215
- if (!hasMaterial(mesh)) return;
60216
-
60217
- switch (name) {
60218
- case MATERIALS.LAMBERT:
60219
- return cloneMaterial(MeshLambertMaterial, mesh, materialOptions);
60220
-
60221
- case MATERIALS.PHONG:
60222
- return cloneMaterial(MeshPhongMaterial, mesh, materialOptions);
60223
-
60224
- case MATERIALS.DEPTH:
60225
- return cloneMaterial(MeshDepthMaterial, mesh, materialOptions);
60226
-
60227
- case MATERIALS.STANDARD:
60228
- return cloneMaterial(MeshStandardMaterial, mesh, materialOptions);
60229
-
60230
- case MATERIALS.TOON:
60231
- return cloneMaterial(ToonMaterial, mesh, materialOptions);
60232
-
60233
- case MATERIALS.THREE_TOON:
60234
- return cloneMaterial(MeshToonMaterial, mesh, materialOptions);
60235
-
60236
- case MATERIALS.BASIC:
60237
- default:
60238
- return cloneMaterial(MeshBasicMaterial, mesh, materialOptions);
60239
- }
60240
- };
60314
+ this.isPlaying = false;
60315
+ }
60316
+ }, {
60317
+ key: "playAnimation",
60318
+ value: function playAnimation(id, options) {
60319
+ var action = this.getAction(id);
60320
+ var _options$loop = options.loop,
60321
+ loop = _options$loop === void 0 ? LoopRepeat : _options$loop;
60322
+ this.isPlaying = true;
60241
60323
 
60242
- var cloneMaterial = function cloneMaterial(MeshMaterial, mesh) {
60243
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
60324
+ if (this.currentAction) {
60325
+ this.fadeToAnimation(action, options);
60326
+ } else if (action) {
60327
+ this.currentAction = this.mixer.clipAction(action).setLoop(loop).play();
60328
+ } else {
60329
+ console.warn(ANIMATION_NOT_FOUND);
60330
+ }
60331
+ }
60332
+ }, {
60333
+ key: "fadeToAnimation",
60334
+ value: function fadeToAnimation(action) {
60335
+ var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
60336
+ _ref3$duration = _ref3.duration,
60337
+ duration = _ref3$duration === void 0 ? 0.2 : _ref3$duration,
60338
+ _ref3$loop = _ref3.loop,
60339
+ loop = _ref3$loop === void 0 ? LoopRepeat : _ref3$loop;
60244
60340
 
60245
- var _cloneMaterial = function _cloneMaterial(material) {
60246
- var clone = material.clone();
60247
- var newMaterial = new MeshMaterial(_objectSpread2$1({
60248
- map: clone.map,
60249
- color: clone.color
60250
- }, options));
60251
- newMaterial.skinning = true;
60252
- return newMaterial;
60253
- };
60341
+ var previousAction = this.currentAction;
60342
+ this.currentAction = this.mixer.clipAction(action);
60254
60343
 
60255
- mesh.material = processMaterial(mesh.material, _cloneMaterial);
60256
- setUpLightsAndShadows(mesh);
60257
- };
60344
+ if (previousAction !== this.currentAction) {
60345
+ previousAction.fadeOut(duration);
60346
+ }
60258
60347
 
60259
- var disposeTextures = function disposeTextures(mesh) {
60260
- if (hasMaterial(mesh)) {
60261
- var _disposeTexture = function _disposeTexture(material) {
60262
- material.map && material.dispose();
60263
- };
60348
+ this.currentAction.reset().setEffectiveTimeScale(1).setEffectiveWeight(1).fadeIn(duration).setLoop(loop).play();
60349
+ }
60350
+ }, {
60351
+ key: "update",
60352
+ value: function update(dt) {
60353
+ this.mixer.update(dt);
60354
+ }
60355
+ }]);
60264
60356
 
60265
- processMaterial(mesh.material, _disposeTexture);
60266
- }
60267
- };
60268
- var disposeMaterial = function disposeMaterial(mesh) {
60269
- if (hasMaterial(mesh)) {
60270
- mesh.material.dispose();
60271
- }
60272
- };
60273
- var disposeGeometry = function disposeGeometry(mesh) {
60274
- if (hasGeometry(mesh)) {
60275
- mesh.geometry.dispose();
60276
- }
60277
- };
60278
- var prepareModel = function prepareModel(model) {
60279
- setUpLightsAndShadows(model);
60280
- model.traverse(function (mesh) {
60281
- setUpLightsAndShadows(mesh);
60282
- });
60283
- return model;
60284
- };var _MATERIAL_TEXTURE_MAP;
60357
+ return AnimationHandler;
60358
+ }(EventDispatcher);var _MATERIAL_TEXTURE_MAP;
60285
60359
  var MATERIAL_TEXTURE_MAP = (_MATERIAL_TEXTURE_MAP = {}, _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.BASIC, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.LAMBERT, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.PHONG, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.DEPTH, [TEXTURES.ALPHA, TEXTURES.MAP, TEXTURES.DISPLACEMENT]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.STANDARD, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL, TEXTURES.METALNESS, TEXTURES.ROUGHNESS]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.THREE_TOON, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.EMISSIVE, TEXTURES.GRADIENT, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.NORMAL]), _MATERIAL_TEXTURE_MAP);
60286
60360
  var isTextureMapAllowedForMaterial = function isTextureMapAllowedForMaterial(materialType, textureType) {
60287
60361
  return MATERIAL_TEXTURE_MAP[materialType] && MATERIAL_TEXTURE_MAP[materialType].includes(textureType);
60288
- };var _excluded$3 = ["position", "quaternion"],
60362
+ };var _excluded$5 = ["position", "quaternion"],
60289
60363
  _excluded2 = ["applyPhysicsUpdate"],
60290
60364
  _excluded3 = ["dt", "event"];
60291
60365
  var COLLIDER_TAG = 'collider';
@@ -60312,30 +60386,6 @@ var Element = /*#__PURE__*/function (_Entity) {
60312
60386
 
60313
60387
  _this = _super.call(this, _options);
60314
60388
 
60315
- _defineProperty$1(_assertThisInitialized(_this), "getBodyByName", function (name) {
60316
- if (name) {
60317
- if (_this.hasBody()) {
60318
- return _this.body.getObjectByName(name);
60319
- } else {
60320
- var body;
60321
-
60322
- _this.body.traverse(function (element) {
60323
- if (element.name === name) {
60324
- body = element;
60325
- }
60326
- });
60327
-
60328
- if (body) {
60329
- return body;
60330
- }
60331
-
60332
- console.warn(ELEMENT_NOT_SET$1);
60333
- }
60334
- } else {
60335
- console.warn(ELEMENT_NAME_NOT_PROVIDED);
60336
- }
60337
- });
60338
-
60339
60389
  _defineProperty$1(_assertThisInitialized(_this), "handleAnimationHandlerEvents", function (e) {
60340
60390
  _this.dispatchEvent(e);
60341
60391
  });
@@ -60499,7 +60549,7 @@ var Element = /*#__PURE__*/function (_Entity) {
60499
60549
  _defineProperty$1(_assertThisInitialized(_this), "handlePhysicsUpdate", function (_ref6) {
60500
60550
  var position = _ref6.position,
60501
60551
  quaternion = _ref6.quaternion,
60502
- data = _objectWithoutProperties(_ref6, _excluded$3);
60552
+ data = _objectWithoutProperties(_ref6, _excluded$5);
60503
60553
 
60504
60554
  _this.setPosition(position);
60505
60555
 
@@ -60517,15 +60567,14 @@ var Element = /*#__PURE__*/function (_Entity) {
60517
60567
  });
60518
60568
 
60519
60569
  var _options$name = _options.name,
60520
- _name = _options$name === void 0 ? "default_".concat(Math.random()) : _options$name,
60570
+ name = _options$name === void 0 ? "default_".concat(Math.random()) : _options$name,
60521
60571
  geometry = _options.geometry,
60522
60572
  material = _options.material,
60523
60573
  _body = _options.body;
60524
-
60525
60574
  _this.textures = {};
60526
60575
  _this.opacity = 1;
60527
60576
  _this.options = _objectSpread2$1(_objectSpread2$1({}, _options), {}, {
60528
- name: _name
60577
+ name: name
60529
60578
  });
60530
60579
  _this.physicsOptions = DEFAULT_PHYSICS_OPTIONS;
60531
60580
  _this.physicsState = {};
@@ -60976,7 +61025,7 @@ var Element = /*#__PURE__*/function (_Entity) {
60976
61025
 
60977
61026
  return new Promise(function (resolve) {
60978
61027
  return new Between(_this4.opacity, opacity).time(time).on('update', function (value) {
60979
- return _this4.setOpacity(value);
61028
+ return !_this4.isDisposed() && _this4.setOpacity(value);
60980
61029
  }).on('complete', resolve);
60981
61030
  });
60982
61031
  }
@@ -61013,19 +61062,21 @@ var Element = /*#__PURE__*/function (_Entity) {
61013
61062
  }, {
61014
61063
  key: "disposeBody",
61015
61064
  value: function disposeBody() {
61016
- if (hasMaterial(this.body)) {
61065
+ _get(_getPrototypeOf(Element.prototype), "disposeBody", this).call(this);
61066
+
61067
+ if (hasMaterial(this.getBody())) {
61017
61068
  disposeTextures(this.getBody());
61018
61069
  disposeMaterial(this.getBody());
61019
61070
  disposeGeometry(this.getBody());
61020
- } else {
61021
- this.body.traverse(function (child) {
61022
- if (hasMaterial(child)) {
61023
- disposeTextures(child);
61024
- disposeMaterial(child);
61025
- disposeGeometry(child);
61026
- }
61027
- });
61028
61071
  }
61072
+
61073
+ this.getBody().traverse(function (child) {
61074
+ if (hasMaterial(child)) {
61075
+ disposeTextures(child);
61076
+ disposeMaterial(child);
61077
+ disposeGeometry(child);
61078
+ }
61079
+ });
61029
61080
  }
61030
61081
  }, {
61031
61082
  key: "update",
@@ -61037,7 +61088,7 @@ var Element = /*#__PURE__*/function (_Entity) {
61037
61088
  this.checkCollisions();
61038
61089
  }
61039
61090
 
61040
- if (this.hasAnimationHandler()) {
61091
+ if (this.hasAnimationHandler() && this.animationHandler.isPlaying) {
61041
61092
  this.animationHandler.update(dt);
61042
61093
  }
61043
61094
  }
@@ -61046,11 +61097,6 @@ var Element = /*#__PURE__*/function (_Entity) {
61046
61097
  value: function dispose() {
61047
61098
  _get(_getPrototypeOf(Element.prototype), "dispose", this).call(this);
61048
61099
 
61049
- if (this.hasBody()) {
61050
- Scene$1.remove(this.getBody());
61051
- this.disposeBody();
61052
- }
61053
-
61054
61100
  if (this.hasAnimationHandler()) {
61055
61101
  this.removeAnimationHandlerListeners();
61056
61102
  }
@@ -61060,10 +61106,9 @@ var Element = /*#__PURE__*/function (_Entity) {
61060
61106
  }, {
61061
61107
  key: "toJSON",
61062
61108
  value: function toJSON() {
61063
- if (this.serializable) {
61109
+ if (this.isSerializable()) {
61064
61110
  return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Element.prototype), "toJSON", this).call(this)), {}, {
61065
61111
  body: this.body.toJSON(),
61066
- scripts: this.mapScriptsToJSON(),
61067
61112
  textures: this.textures
61068
61113
  }, this.options);
61069
61114
  }
@@ -61507,7 +61552,7 @@ var Plane = /*#__PURE__*/function (_Element) {
61507
61552
  }
61508
61553
 
61509
61554
  return Box;
61510
- }(Element);var _excluded$2 = ["anisotropy"];
61555
+ }(Element);var _excluded$4 = ["anisotropy"];
61511
61556
 
61512
61557
  var validateAnisotropy = function validateAnisotropy(anisotropy) {
61513
61558
  var max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
@@ -61533,7 +61578,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
61533
61578
 
61534
61579
  var _options$anisotropy = options.anisotropy,
61535
61580
  anisotropy = _options$anisotropy === void 0 ? 1 : _options$anisotropy,
61536
- rest = _objectWithoutProperties(options, _excluded$2);
61581
+ rest = _objectWithoutProperties(options, _excluded$4);
61537
61582
 
61538
61583
  var texture = Images$1.get(spriteTexture);
61539
61584
  texture.anisotropy = validateAnisotropy(anisotropy);
@@ -61581,7 +61626,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
61581
61626
  (function(a,b){module.exports=b(require$$0);})(commonjsGlobal,function(a){function bd(a,b,c,d){bd._super_.call(this),this.camera=a,this.renderer=b,this.dis=c||20,d=d||"1234";for(var e=1;e<5;e++)this["d"+e]=d.indexOf(e+"")>=0;this.name="ScreenZone";}function bc(a,c,d,e,f,g){var h,i,j,k,l,e;bc._super_.call(this),b.Util.isUndefined(c,d,e,f,g)?(h=i=j=0,k=l=e=a||100):b.Util.isUndefined(e,f,g)?(h=i=j=0,k=a,l=c,e=d):(h=a,i=c,j=d,k=e,l=f,e=g),this.x=h,this.y=i,this.z=j,this.width=k,this.height=l,this.depth=e,this.friction=.85,this.max=6;}function bb(a,c,d){var e,f,g;bb._super_.call(this),b.Util.isUndefined(a,c,d)?e=f=g=0:(e=a,f=c,g=d),this.x=e,this.y=f,this.z=g;}function ba(b,c){ba._super_.call(this),b instanceof a.Geometry?this.geometry=b:this.geometry=b.geometry,this.scale=c||1;}function _(a,c,d,e){var f,i;_._super_.call(this),b.Util.isUndefined(c,d,e)?(f=0,i=a||100):(f=a,i=e),this.x=f,this.y=f,this.z=f,this.radius=i,this.tha=this.phi=0;}function $(a,c,d,e,f,g){$._super_.call(this),a instanceof b.Vector3D?(this.x1=a.x,this.y1=a.y,this.z1=a.z,this.x2=e.x,this.y2=e.y,this.z2=e.z):(this.x1=a,this.y1=c,this.z1=d,this.x2=e,this.y2=f,this.z2=g);}function Z(){this.vector=new b.Vector3D(0,0,0),this.random=0,this.crossType="dead",this.log=!0;}function Y(){Y._super_.call(this),this.targetPool=new b.Pool,this.materialPool=new b.Pool,this.name="CustomRender";}function X(b){X._super_.call(this,b),this._body=new a.Sprite(new a.SpriteMaterial({color:16777215})),this.name="SpriteRender";}function W(a){W._super_.call(this),this.points=a,this.name="PointsRender";}function V(c){V._super_.call(this),this.container=c,this._targetPool=new b.Pool,this._materialPool=new b.Pool,this._body=new a.Mesh(new a.BoxGeometry(50,50,50),new a.MeshLambertMaterial({color:"#ff0000"})),this.name="MeshRender";}function U(){this.name="BaseRender";}function R(a,c,d){this.mouseTarget=b.Util.initValue(a,window),this.ease=b.Util.initValue(c,.7),this._allowEmitting=!1,this.mouse=new b.Vector3D,this.initEventHandler(),R._super_.call(this,d);}function Q(a){this.selfBehaviours=[],Q._super_.call(this,a);}function P(a){this.initializes=[],this.particles=[],this.behaviours=[],this.currentEmitTime=0,this.totalEmitTimes=-1,this.damping=.006,this.bindEmitter=!0,this.rate=new b.Rate(1,.1),P._super_.call(this,a),this.id="emitter_"+P.ID++,this.cID=0,this.name="Emitter";}function O(a,b,c,d,e,f,g){O._super_.call(this,f,g),O.prototype.reset(a,b,c,d,e),this.name="Spring";}function N(a,b,c,d){N._super_.call(this,c,d),this.reset(a,b),this.name="Color";}function M(a,b,c,d,e){M._super_.call(this,d,e),this.reset(a,b,c),this.name="Rotate";}function L(a,b,c,d){L._super_.call(this,c,d),this.reset(a,b),this.name="Scale";}function K(a,b,c,d){K._super_.call(this,c,d),this.reset(a,b),this.name="Alpha";}function J(a,b,c,d){J._super_.call(this,c,d),this.reset(a,b),this.name="CrossZone";}function I(a,b,c,d,e){I._super_.call(this,d,e),this.reset(a,b,c),this.name="Collision";}function H(a,b,c){H._super_.call(this,0,-a,0,b,c),this.name="Gravity";}function G(a,b,c,d,e){G._super_.call(this,a,b,c,d,e),this.force*=-1,this.name="Repulsion";}function F(a,b,c,d,e,f){F._super_.call(this,e,f),this.reset(a,b,c,d),this.time=0,this.name="RandomDrift";}function E(a,c,d,e,f){E._super_.call(this,e,f),this.targetPosition=b.Util.initValue(a,new b.Vector3D),this.radius=b.Util.initValue(d,1e3),this.force=b.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new b.Vector3D,this.lengthSq=0,this.name="Attraction";}function D(a,b,c,d,e){D._super_.call(this,d,e),D.prototype.reset.call(this,a,b,c),this.name="Force";}function C(a,c,d){C._super_.call(this),this.body=b.createArraySpan(a),this.w=c,this.h=b.Util.initValue(d,this.w);}function B(a,c,d){B._super_.call(this),this.radius=b.createSpan(a,c,d);}function A(a,c,d){A._super_.call(this),this.massPan=b.createSpan(a,c,d);}function z(a,c,d){z._super_.call(this),this.reset(a,c,d),this.dirVec=new b.Vector3D(0,0,0),this.name="Velocity";}function y(){y._super_.call(this),this.reset.apply(this,arguments);}function x(a,c,d){x._super_.call(this),this.lifePan=b.createSpan(a,c,d);}function v(){this.name="Initialize";}function u(a,c){this.numPan=b.createSpan(b.Util.initValue(a,1)),this.timePan=b.createSpan(b.Util.initValue(c,1)),this.startTime=0,this.nextTime=0,this.init();}function t(a,c){this.id="Behaviour_"+t.id++,this.life=b.Util.initValue(a,Infinity),this.easing=b.Util.initValue(c,b.ease.setEasingByName(b.ease.easeLinear)),this.age=0,this.energy=1,this.dead=!1,this.name="Behaviour";}function s(a,b,c,d,e,f){this.x=a,this.y=b,this.z=c,this.width=d,this.height=e,this.depth=f,this.bottom=this.y+this.height,this.right=this.x+this.width,this.right=this.x+this.width;}function q(a){this._arr=b.Util.isArray(a)?a:[a];}function p(a,c,d){this._isArray=!1,b.Util.isArray(a)?(this._isArray=!0,this.a=a):(this.a=b.Util.initValue(a,1),this.b=b.Util.initValue(c,this.a),this._center=b.Util.initValue(d,!1));}function j(){this.cID=0,this.list={};}function i(a){this.id="particle_"+i.ID++,this.name="Particle",this.reset("init"),b.Util.setPrototypeByObj(this,a);}function c(){this.initialize();}function b(a,c){this.preParticles=b.Util.initValue(a,b.POOL_MAX),this.integrationType=b.Util.initValue(c,b.EULER),this.emitters=[],this.renderers=[],this.pool=new b.Pool,b.integrator=new b.Integration(this.integrationType);}b.POOL_MAX=500,b.TIME_STEP=60,b.PI=3.142,b.DR=b.PI/180,b.MEASURE=100,b.EULER="euler",b.RK2="runge-kutta2",b.RK4="runge-kutta4",b.VERLET="verlet",b.PARTICLE_CREATED="partilcleCreated",b.PARTICLE_UPDATE="partilcleUpdate",b.PARTICLE_SLEEP="particleSleep",b.PARTICLE_DEAD="partilcleDead",b.PROTON_UPDATE="protonUpdate",b.PROTON_UPDATE_AFTER="protonUpdateAfter",b.EMITTER_ADDED="emitterAdded",b.EMITTER_REMOVED="emitterRemoved",b.bindEmtterEvent=!1,b.prototype={addRender:function(a){this.renderers.push(a),a.init(this);},removeRender:function(a){this.renderers.splice(this.renderers.indexOf(a),1),a.remove(this);},addEmitter:function(a){this.emitters.push(a),a.parent=this,this.dispatchEvent("EMITTER_ADDED",a);},removeEmitter:function(a){a.parent==this&&(this.emitters.splice(this.emitters.indexOf(a),1),a.parent=null,this.dispatchEvent("EMITTER_REMOVED",a));},update:function(a){this.dispatchEvent("PROTON_UPDATE",this);var b=a||.0167;if(b>0){var c=this.emitters.length;while(c--)this.emitters[c].update(b);}this.dispatchEvent("PROTON_UPDATE_AFTER",this);},getCount:function(){var a=0,b,c=this.emitters.length;for(b=0;b<c;b++)a+=this.emitters[b].particles.length;return a},destroy:function(){var a=0,b=this.emitters.length;for(a;a<b;a++)this.emitters[a].destroy(),delete this.emitters[a];this.emitters.length=0,this.pool.destroy();}},c.initialize=function(a){a.addEventListener=d.addEventListener,a.removeEventListener=d.removeEventListener,a.removeAllEventListeners=d.removeAllEventListeners,a.hasEventListener=d.hasEventListener,a.dispatchEvent=d.dispatchEvent;};var d=c.prototype;d._listeners=null,d.initialize=function(){},d.addEventListener=function(a,b){this._listeners?this.removeEventListener(a,b):this._listeners={},this._listeners[a]||(this._listeners[a]=[]),this._listeners[a].push(b);return b},d.removeEventListener=function(a,b){if(!!this._listeners){if(!this._listeners[a])return;var c=this._listeners[a];for(var d=0,e=c.length;d<e;d++)if(c[d]==b){e==1?delete this._listeners[a]:c.splice(d,1);break}}},d.removeAllEventListeners=function(a){a?this._listeners&&delete this._listeners[a]:this._listeners=null;},d.dispatchEvent=function(a,b){var c=!1,d=this._listeners;if(a&&d){var e=d[a];if(!e)return c;e=e.slice();var f,g=e.length;while(g--){var f=e[g];c=c||f(b);}}return !!c},d.hasEventListener=function(a){var b=this._listeners;return !!b&&!!b[a]},c.initialize(b.prototype),b.EventDispatcher=c;var e=e||{initValue:function(a,b){var a=a!=null&&a!=undefined?a:b;return a},isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},destroyArray:function(a){a.length=0;},destroyObject:function(a){for(var b in a)delete a[b];},isUndefined:function(){for(var a in arguments){var b=arguments[a];if(b!==undefined)return !1}return !0},setVectorByObj:function(a,b){b.x!==undefined&&(a.p.x=b.x),b.y!==undefined&&(a.p.y=b.y),b.z!==undefined&&(a.p.z=b.z),b.vx!==undefined&&(a.v.x=b.vx),b.vy!==undefined&&(a.v.y=b.vy),b.vz!==undefined&&(a.v.z=b.vz),b.ax!==undefined&&(a.a.x=b.ax),b.ay!==undefined&&(a.a.y=b.ay),b.az!==undefined&&(a.a.z=b.az),b.p!==undefined&&a.p.copy(b.p),b.v!==undefined&&a.v.copy(b.v),b.a!==undefined&&a.a.copy(b.a),b.position!==undefined&&a.p.copy(b.position),b.velocity!==undefined&&a.v.copy(b.velocity),b.accelerate!==undefined&&a.a.copy(b.accelerate);},setPrototypeByObj:function(a,b,c){for(var d in b)a.hasOwnProperty(d)&&(c?c.indexOf(d)<0&&(a[d]=e._getValue(b[d])):a[d]=e._getValue(b[d]));return a},_getValue:function(a){return a instanceof p?a.getValue():a},inherits:function(a,b){a._super_=b;if(Object.create)a.prototype=Object.create(b.prototype,{constructor:{value:a}});else {var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a;}}};b.Util=e;var f=f||{getRGB:function(b){var c={};if(typeof b=="number")e=Math.floor(b),c.r=(b>>16&255)/255,c.g=(b>>8&255)/255,c.b=(b&255)/255;else if(typeof b=="string"){var d;if(d=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(b))c.r=Math.min(255,parseInt(d[1],10))/255,c.g=Math.min(255,parseInt(d[2],10))/255,c.b=Math.min(255,parseInt(d[3],10))/255;else if(d=/^\#([A-Fa-f0-9]+)$/.exec(b)){var e=d[1];c.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,c.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,c.b=parseInt(e.charAt(4)+e.charAt(5),16)/255;}}else b instanceof a.Color&&(c.r=b.r,c.g=b.g,c.b=b.b);return c}};b.ColorUtil=f;var g={toScreenPos:function(){var b=new a.Vector3;return function(a,c,d){b.copy(a),b.project(c),b.x=Math.round((b.x+1)*d.width/2),b.y=Math.round((-b.y+1)*d.height/2),b.z=0;return b}}(),toSpacePos:function(){var b=new a.Vector3,c=new a.Vector3,d;return function(a,e,f){b.set(a.x/f.width*2-1,-(a.y/f.height)*2+1,.5),b.unproject(e),c.copy(b.sub(e.position).normalize()),d=-e.position.z/c.z,b.copy(e.position),b.add(c.multiplyScalar(d));return b}}(),getTexture:function(){var c={};return function(d){if(d instanceof a.Texture)return d;if(typeof d=="string"){var e=b.PUID.hash(d);c[e]||(c[e]=new a.Texture(d));return c[e]}if(d instanceof Image){var e=b.PUID.hash(d.src);c[e]||(c[e]=new a.Texture(d));return c[e]}}}()};b.THREEUtil=g;var h=h||{_id:0,_uids:{},id:function(a){for(var b in this._uids)if(this._uids[b]==a)return b;var c="PUID_"+this._id++;this._uids[c]=a;return c},hash:function(a){return}};b.PUID=h,i.ID=0,i.prototype={getDirection:function(){return Math.atan2(this.v.x,-this.v.y)*(180/b.PI)},reset:function(a){this.life=Infinity,this.age=0,this.energy=1,this.dead=!1,this.sleep=!1,this.body=null,this.parent=null,this.mass=1,this.radius=10,this.alpha=1,this.scale=1,this.useColor=!1,this.useAlpha=!1,this.easing=b.ease.setEasingByName(b.ease.easeLinear),a?(this.p=new b.Vector3D,this.v=new b.Vector3D,this.a=new b.Vector3D,this.old={},this.old.p=this.p.clone(),this.old.v=this.v.clone(),this.old.a=this.a.clone(),this.behaviours=[],this.transform={},this.color={r:0,g:0,b:0},this.rotation=new b.Vector3D):(this.p.set(0,0,0),this.v.set(0,0,0),this.a.set(0,0,0),this.old.p.set(0,0,0),this.old.v.set(0,0,0),this.old.a.set(0,0,0),this.color.r=0,this.color.g=0,this.color.b=0,this.rotation.clear(),b.Util.destroyObject(this.transform),this.removeAllBehaviours());return this},update:function(a,b){if(!this.sleep){this.age+=a;var c=this.behaviours.length;while(c--)this.behaviours[c]&&this.behaviours[c].applyBehaviour(this,a,b);}if(this.age>=this.life)this.destroy();else {var d=this.easing(this.age/this.life);this.energy=Math.max(1-d,0);}},addBehaviour:function(a){this.behaviours.push(a),a.initialize(this);},addBehaviours:function(a){var b=a.length;while(b--)this.addBehaviour(a[b]);},removeBehaviour:function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1);},removeAllBehaviours:function(){b.Util.destroyArray(this.behaviours);},destroy:function(){this.removeAllBehaviours(),this.energy=0,this.dead=!0,this.parent=null;}},b.Particle=i,j.prototype={create:function(a){this.cID++;return typeof a=="function"?new a:a.clone()},getCount:function(){var a=0;for(var b in this.list)a+=this.list[b].length;return a++},get:function(a){var c,d=a.__puid||b.PUID.id(a);this.list[d]&&this.list[d].length>0?c=this.list[d].pop():c=this.create(a),c.__puid=a.__puid||d;return c},expire:function(a){return this._getList(a.__puid).push(a)},destroy:function(){for(var a in this.list)this.list[a].length=0,delete this.list[a];},_getList:function(a){a=a||"default",this.list[a]||(this.list[a]=[]);return this.list[a]}},b.Pool=j;var k={randomAToB:function(a,b,c){return c?(Math.random()*(b-a)>>0)+a:a+Math.random()*(b-a)},randomFloating:function(a,b,c){return k.randomAToB(a-b,a+b,c)},randomZone:function(a){},degreeTransform:function(a){return a*b.PI/180},toColor16:function(a){return "#"+a.toString(16)},randomColor:function(){return "#"+("00000"+(Math.random()*16777216<<0).toString(16)).slice(-6)},lerp:function(a,b,c){return b+(a-b)*c},getNormal:function(a,b){a.x==0&&a.y==0?a.z==0?b.set(1,0,1):b.set(1,1,-a.y/a.z):a.x==0?b.set(1,0,1):b.set(-a.y/a.x,1,1);return b.normalize()},axisRotate:function(a,b,c,d){var e=Math.cos(d),f=Math.sin(d),g=c.dot(b)*(1-e);a.copy(c),a.cross(b).scalar(f),a.addValue(b.x*e,b.y*e,b.z*e),a.addValue(c.x*g,c.y*g,c.z*g);}};b.MathUtils=k;var m=function(a){this.type=b.Util.initValue(a,b.EULER);};m.prototype={integrate:function(a,b,c){this.euler(a,b,c);},euler:function(a,b,c){a.sleep||(a.old.p.copy(a.p),a.old.v.copy(a.v),a.a.scalar(1/a.mass),a.v.add(a.a.scalar(b)),a.p.add(a.old.v.scalar(b)),c&&a.v.scalar(c),a.a.clear());}},b.Integration=m;var n=function(a,b,c){this.x=a||0,this.y=b||0,this.z=c||0;};n.prototype={set:function(a,b,c){this.x=a,this.y=b,this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},getGradient:function(){if(this.x!=0)return Math.atan2(this.y,this.x);if(this.y>0)return b.PI/2;if(this.y<0)return -b.PI/2},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z;return this},add:function(a,b){if(b!==undefined)return this.addVectors(a,b);this.x+=a.x,this.y+=a.y,this.z+=a.z;return this},addValue:function(a,b,c){this.x+=a,this.y+=b,this.z+=c;return this},addVectors:function(a,b){this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z;return this},addScalar:function(a){this.x+=a,this.y+=a,this.z+=a;return this},sub:function(a,b){if(b!==undefined)return this.subVectors(a,b);this.x-=a.x,this.y-=a.y,this.z-=a.z;return this},subVectors:function(a,b){this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z;return this},scalar:function(a){this.x*=a,this.y*=a,this.z*=a;return this},divideScalar:function(a){a!==0?(this.x/=a,this.y/=a,this.z/=a):this.set(0,0,0);return this},negate:function(){return this.scalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},cross:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y,this.y=d*a.x-b*a.z,this.z=b*a.y-c*a.x;return this},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g,this.y=e*f-c*h,this.z=c*g-d*f;return this},eulerFromDir:function(a){},applyEuler:function(){var a;return function(c){a===undefined&&(a=new b.Quaternion),this.applyQuaternion(a.setFromEuler(c));return this}}(),applyAxisAngle:function(){var a;return function(c,d){a===undefined&&(a=new b.Quaternion),this.applyQuaternion(a.setFromAxisAngle(c,d));return this}}(),applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z,h=a.w,i=h*b+f*d-g*c,j=h*c+g*b-e*d,k=h*d+e*c-f*b,l=-e*b-f*c-g*d;this.x=i*h+l*-e+j*-g-k*-f,this.y=j*h+l*-f+k*-e-i*-g,this.z=k*h+l*-g+i*-f-j*-e;return this},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y,d=this.z-a.z;return b*b+c*c+d*d},lerp:function(a,b){this.x+=(a.x-this.x)*b,this.y+=(a.y-this.y)*b,this.z+=(a.z-this.z)*b;return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},clear:function(){this.x=0,this.y=0,this.z=0;return this},clone:function(){return new b.Vector3D(this.x,this.y,this.z)},toString:function(){return "x:"+this.x+"y:"+this.y+"z:"+this.z}},b.Vector3D=n;var o=function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0;};o.prototype={set:function(a,b,c){this.radius=a||1,this.phi=c||0,this.theta=b||0;return this},setRadius:function(a){this.radius=a;return this},setPhi:function(a){this.phi=a;return this},setTheta:function(a){this.theta=a;return this},copy:function(a){this.radius=a.radius,this.phi=a.phi,this.theta=a.theta;return this},toVector3D:function(){return new b.Vector3D(this.getX(),this.getY(),this.getZ())},getX:function(){return this.radius*Math.sin(this.theta)*Math.cos(this.phi)},getY:function(){return -this.radius*Math.sin(this.theta)*Math.sin(this.phi)},getZ:function(){return this.radius*Math.cos(this.theta)},normalize:function(){this.radius=1;return this},equals:function(a){return a.radius===this.radius&&a.phi===this.phi&&a.theta===this.theta},clear:function(){this.radius=0,this.phi=0,this.theta=0;return this},clone:function(){return new o(this.radius,this.phi,this.theta)}},b.Polar3D=o,p.prototype={getValue:function(a){return this._isArray?this.a[this.a.length*Math.random()>>0]:this._center?b.MathUtils.randomFloating(this.a,this.b,a):b.MathUtils.randomAToB(this.a,this.b,a)}},b.createSpan=function(a,b,c){if(a instanceof p)return a;return b===undefined?new p(a):c===undefined?new p(a,b):new p(a,b,c)},b.Span=p,b.Util.inherits(q,b.Span),q.prototype.getValue=function(){var a=this._arr[this._arr.length*Math.random()>>0];return a=="random"||a=="Random"?b.MathUtils.randomColor():a},b.createArraySpan=function(a){if(!a)return null;return a instanceof b.ArraySpan?a:new b.ArraySpan(a)},b.ArraySpan=q;var r=function(a,b,c,d){this.x=a||0,this.y=b||0,this.z=c||0,this.w=d!==undefined?d:1;};r.prototype={set:function(a,b,c,d){this.x=a,this.y=b,this.z=c,this.w=d;return this},clone:function(){return new b.Quaternion(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x,this.y=a.y,this.z=a.z,this.w=a.w;return this},setFromEuler:function(a){var b=Math.cos(a.x/2),c=Math.cos(a.y/2),d=Math.cos(a.z/2),e=Math.sin(a.x/2),f=Math.sin(a.y/2),g=Math.sin(a.z/2);this.x=e*c*d+b*f*g,this.y=b*f*d-e*c*g,this.z=b*c*g+e*f*d,this.w=b*c*d-e*f*g;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d,this.y=a.y*d,this.z=a.z*d,this.w=Math.cos(c);return this},normalize:function(){var a=this.length();a===0?(this.x=0,this.y=0,this.z=0,this.w=1):(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w}},b.Quaternion=r,s.prototype={contains:function(a,b,c){return a<=this.right&&a>=this.x&&b<=this.bottom&&b>=this.y&&c<=this.depth&&c>=this.z?!0:!1}},b.Box=s,t.id=0,t.prototype={reset:function(a,c){this.life=b.Util.initValue(a,Infinity),this.easing=b.Util.initValue(c,b.ease.setEasingByName(b.ease.easeLinear));},normalizeForce:function(a){return a.scalar(b.MEASURE)},normalizeValue:function(a){return a*b.MEASURE},initialize:function(a){},applyBehaviour:function(a,b,c){if(!this.dead){this.age+=b;if(this.age>=this.life){this.energy=0,this.dead=!0;return}var d=this.easing(a.age/a.life);this.energy=Math.max(1-d,0);}},destroy:function(){}},b.Behaviour=t,u.prototype={init:function(){this.startTime=0,this.nextTime=this.timePan.getValue();},getValue:function(a){this.startTime+=a;if(this.startTime>=this.nextTime){this.init();return this.numPan.b==1?this.numPan.getValue("Float")>.5?1:0:this.numPan.getValue("Int")}return 0}},b.Rate=u,v.prototype.reset=function(){},v.prototype.init=function(a,b){b?this.initialize(b):this.initialize(a);},v.prototype.initialize=function(a){},b.Initialize=v;var w={initialize:function(a,c,d){var e=d.length;while(e--){var f=d[e];f instanceof b.Initialize?f.init(a,c):w.init(a,c,f);}w.bindEmitter(a,c);},init:function(a,c,d){b.Util.setPrototypeByObj(c,d),b.Util.setVectorByObj(c,d);},bindEmitter:function(a,b){a.bindEmitter&&(b.p.add(a.p),b.v.add(a.v),b.a.add(a.a),b.v.applyEuler(a.rotation));}};b.InitializeUtil=w,b.Util.inherits(x,b.Initialize),x.prototype.initialize=function(a){this.lifePan.a==Infinity||this.lifePan.a=="infi"?a.life=Infinity:a.life=this.lifePan.getValue();},b.Life=x,b.Util.inherits(y,b.Initialize),y.prototype.reset=function(){this.zones?this.zones.length=0:this.zones=[];var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a);},y.prototype.addZone=function(){var a=Array.prototype.slice.call(arguments);this.zones=this.zones.concat(a);},y.prototype.initialize=function(){return function(a){var b=this.zones[Math.random()*this.zones.length>>0];b.getPosition(),a.p.x=b.vector.x,a.p.y=b.vector.y,a.p.z=b.vector.z;}}(),b.Position=y,b.P=y,b.Util.inherits(z,b.Initialize),z.prototype.reset=function(a,c,d){a instanceof b.Vector3D?(this.radiusPan=b.createSpan(1),this.dir=a.clone(),this.tha=c*b.DR,this._useV=!0):a instanceof b.Polar3D?(this.tha=c*b.DR,this.dirVec=a.toVector3D(),this._useV=!1):(this.radiusPan=b.createSpan(a),this.dir=c.clone().normalize(),this.tha=d*b.DR,this._useV=!0);},z.prototype.normalize=function(a){return a*b.MEASURE},z.prototype.initialize=function(){var a,c=new b.Vector3D(0,0,1),d=new b.Vector3D(0,0,0);return function(e){a=this.tha*Math.random(),this._useV&&this.dirVec.copy(this.dir).scalar(this.radiusPan.getValue()),b.MathUtils.getNormal(this.dirVec,c),d.copy(this.dirVec).applyAxisAngle(c,a),d.applyAxisAngle(this.dirVec.normalize(),Math.random()*b.PI*2),e.v.copy(d);return this}}(),b.Velocity=z,b.V=z,b.Util.inherits(A,b.Initialize),A.prototype.initialize=function(a){a.mass=this.massPan.getValue();},b.Mass=A,b.Util.inherits(B,b.Initialize),B.prototype.reset=function(a,c,d){this.radius=b.createSpan(a,c,d);},B.prototype.initialize=function(a){a.radius=this.radius.getValue(),a.transform.oldRadius=a.radius;},b.Radius=B,b.Util.inherits(C,b.Initialize),C.prototype.initialize=function(a){var b=this.body.getValue();this.w?a.body={width:this.w,height:this.h,body:b}:a.body=b;},b.Body=C,b.Util.inherits(D,b.Behaviour),D.prototype.reset=function(a,c,d){this.force=this.normalizeForce(new b.Vector3D(a,c,d)),this.force.id=Math.random();},D.prototype.applyBehaviour=function(a,b,c){D._super_.prototype.applyBehaviour.call(this,a,b,c),a.a.add(this.force);},b.F=b.Force=D,b.Util.inherits(E,b.Behaviour),E.prototype.reset=function(a,c,d,e,f){this.targetPosition=b.Util.initValue(a,new b.Vector3D),this.radius=b.Util.initValue(d,1e3),this.force=b.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new b.Vector3D,this.lengthSq=0,e&&E._super_.prototype.reset.call(this,e,f);},E.prototype.applyBehaviour=function(a,b,c){E._super_.prototype.applyBehaviour.call(this,a,b,c),this.attractionForce.copy(this.targetPosition),this.attractionForce.sub(a.p),this.lengthSq=this.attractionForce.lengthSq(),this.lengthSq>4e-6&&this.lengthSq<this.radiusSq&&(this.attractionForce.normalize(),this.attractionForce.scalar(1-this.lengthSq/this.radiusSq),this.attractionForce.scalar(this.force),a.a.add(this.attractionForce));},b.Attraction=E,b.Util.inherits(F,b.Behaviour),F.prototype.reset=function(a,c,d,e,f,g){this.randomFoce=this.normalizeForce(new b.Vector3D(a,c,d)),this.delayPan=b.createSpan(e||.03),this.time=0,f&&F._super_.prototype.reset.call(this,f,g);},F.prototype.applyBehaviour=function(a,c,d){F._super_.prototype.applyBehaviour.call(this,a,c,d),this.time+=c;if(this.time>=this.delayPan.getValue()){var e=b.MathUtils.randomAToB(-this.randomFoce.x,this.randomFoce.x),f=b.MathUtils.randomAToB(-this.randomFoce.y,this.randomFoce.y),g=b.MathUtils.randomAToB(-this.randomFoce.z,this.randomFoce.z);a.a.addValue(e,f,g),this.time=0;}},b.RandomDrift=F,b.Util.inherits(G,b.Attraction),G.prototype.reset=function(a,b,c,d,e){G._super_.prototype.reset.call(this,a,b,c,d,e),this.force*=-1;},b.Repulsion=G,b.Util.inherits(H,b.Force),H.prototype.reset=function(a,b,c){H._super_.prototype.reset.call(this,0,-a,0,b,c);},b.Gravity=H,b.G=H,b.Util.inherits(I,b.Behaviour),I.prototype.reset=function(a,c,d,e,f){this.emitter=a,this.useMass=c,this.callback=d,this.particles=[],this.delta=new b.Vector3D,e&&I._super_.prototype.reset.call(this,e,f);},I.prototype.applyBehaviour=function(a,b,c){var d=this.emitter?this.emitter.particles.slice(c):this.particles.slice(c),e,f,g,h,i,j,k=d.length;while(k--){e=d[k];if(e==a)continue;this.delta.copy(e.p).sub(a.p),f=this.delta.lengthSq(),h=a.radius+e.radius,f<=h*h&&(g=h-Math.sqrt(f),g+=.5,i=this._getAverageMass(a,e),j=this._getAverageMass(e,a),a.p.add(this.delta.clone().normalize().scalar(g*-i)),e.p.add(this.delta.normalize().scalar(g*j)),this.callback&&this.callback(a,e));}},I.prototype._getAverageMass=function(a,b){return this.useMass?b.mass/(a.mass+b.mass):.5},b.Collision=I,b.Util.inherits(J,b.Behaviour),J.prototype.reset=function(a,c,d,e){var f,g;typeof a=="string"?(g=a,f=c):(g=c,f=a),this.zone=f,this.zone.crossType=b.Util.initValue(g,"dead"),d&&J._super_.prototype.reset.call(this,d,e);},J.prototype.applyBehaviour=function(a,b,c){J._super_.prototype.applyBehaviour.call(this,a,b,c),this.zone.crossing.call(this.zone,a);},b.CrossZone=J,b.Util.inherits(K,b.Behaviour),K.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createSpan(b.Util.initValue(a,1)),this.b=b.createSpan(c),d&&K._super_.prototype.reset.call(this,d,e);},K.prototype.initialize=function(a){a.useAlpha=!0,a.transform.alphaA=this.a.getValue(),this._same?a.transform.alphaB=a.transform.alphaA:a.transform.alphaB=this.b.getValue();},K.prototype.applyBehaviour=function(a,c,d){K._super_.prototype.applyBehaviour.call(this,a,c,d),a.alpha=b.MathUtils.lerp(a.transform.alphaA,a.transform.alphaB,this.energy),a.alpha<.002&&(a.alpha=0);},b.Alpha=K,b.Util.inherits(L,b.Behaviour),L.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createSpan(b.Util.initValue(a,1)),this.b=b.createSpan(c),d&&L._super_.prototype.reset.call(this,d,e);},L.prototype.initialize=function(a){a.transform.scaleA=this.a.getValue(),a.transform.oldRadius=a.radius,this._same?a.transform.scaleB=a.transform.scaleA:a.transform.scaleB=this.b.getValue();},L.prototype.applyBehaviour=function(a,c,d){L._super_.prototype.applyBehaviour.call(this,a,c,d),a.scale=b.MathUtils.lerp(a.transform.scaleA,a.transform.scaleB,this.energy),a.scale<5e-4&&(a.scale=0),a.radius=a.transform.oldRadius*a.scale;},b.Scale=L,b.Util.inherits(M,b.Behaviour),M.prototype.reset=function(a,c,d,e,f){this.a=a||0,this.b=c||0,this.c=d||0,a===undefined||a=="same"?this._type="same":c==undefined?this._type="set":d===undefined?this._type="to":(this._type="add",this.a=b.createSpan(this.a*b.DR),this.b=b.createSpan(this.b*b.DR),this.c=b.createSpan(this.c*b.DR)),e&&M._super_.prototype.reset.call(this,e,f);},M.prototype.initialize=function(a){switch(this._type){case"same":break;case"set":this._setRotation(a.rotation,this.a);break;case"to":a.transform.fR=a.transform.fR||new b.Vector3D,a.transform.tR=a.transform.tR||new b.Vector3D,this._setRotation(a.transform.fR,this.a),this._setRotation(a.transform.tR,this.b);break;case"add":a.transform.addR=new b.Vector3D(this.a.getValue(),this.b.getValue(),this.c.getValue());}},M.prototype._setRotation=function(a,c){a=a||new b.Vector3D;if(c=="random"){var d=b.MathUtils.randomAToB(-b.PI,b.PI),e=b.MathUtils.randomAToB(-b.PI,b.PI),f=b.MathUtils.randomAToB(-b.PI,b.PI);a.set(d,e,f);}else c instanceof b.Vector3D&&a.copy(c);},M.prototype.applyBehaviour=function(a,c,d){M._super_.prototype.applyBehaviour.call(this,a,c,d);switch(this._type){case"same":a.rotation||(a.rotation=new b.Vector3D),a.rotation.eulerFromDir(a.v);break;case"set":break;case"to":a.rotation.x=b.MathUtils.lerp(a.transform.fR.x,a.transform.tR.x,this.energy),a.rotation.y=b.MathUtils.lerp(a.transform.fR.y,a.transform.tR.y,this.energy),a.rotation.z=b.MathUtils.lerp(a.transform.fR.z,a.transform.tR.z,this.energy);break;case"add":a.rotation.add(a.transform.addR);}},b.Rotate=M,b.Util.inherits(N,b.Behaviour),N.prototype.reset=function(a,c,d,e){c==null||c==undefined?this._same=!0:this._same=!1,this.a=b.createArraySpan(a),this.b=b.createArraySpan(c),d&&N._super_.prototype.reset.call(this,d,e);},N.prototype.initialize=function(a){a.transform.colorA=b.ColorUtil.getRGB(this.a.getValue()),a.useColor=!0,this._same?a.transform.colorB=a.transform.colorA:a.transform.colorB=b.ColorUtil.getRGB(this.b.getValue());},N.prototype.applyBehaviour=function(a,c,d){N._super_.prototype.applyBehaviour.call(this,a,c,d),this._same?(a.color.r=a.transform.colorA.r,a.color.g=a.transform.colorA.g,a.color.b=a.transform.colorA.b):(a.color.r=b.MathUtils.lerp(a.transform.colorA.r,a.transform.colorB.r,this.energy),a.color.g=b.MathUtils.lerp(a.transform.colorA.g,a.transform.colorB.g,this.energy),a.color.b=b.MathUtils.lerp(a.transform.colorA.b,a.transform.colorB.b,this.energy));},b.Color=N,b.Util.inherits(O,b.Behaviour),O.prototype.reset=function(a,c,d,e,f){this.pos?this.pos.set(a,c,d):this.pos=new b.Vector3D(a,c,d),this.spring=e||.1,this.friction=f||.98;},O.prototype.applyBehaviour=function(a,b,c){O._super_.prototype.applyBehaviour.call(this,a,b,c),a.v.x+=(this.pos.x-a.p.x)*this.spring,a.v.y+=(this.pos.y-a.p.y)*this.spring,a.v.z+=(this.pos.z-a.p.z)*this.spring;},b.Spring=O,P.ID=0,b.Util.inherits(P,b.Particle),b.EventDispatcher.initialize(P.prototype),P.prototype.emit=function(a,c){this.currentEmitTime=0,this.totalEmitTimes=b.Util.initValue(a,Infinity),c==!0||c=="life"||c=="destroy"?this.life=a=="once"?1:this.totalEmitTimes:isNaN(c)||(this.life=c),this.rate.init();},P.prototype.stopEmit=function(){this.totalEmitTimes=-1,this.currentEmitTime=0;},P.prototype.removeAllParticles=function(){var a=this.particles.length;while(a--)this.particles[a].dead=!0;},P.prototype.createParticle=function(a,c){var d=this.parent.pool.get(b.Particle);this.setupParticle(d,a,c),this.parent&&this.parent.dispatchEvent("PARTICLE_CREATED",d),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_CREATED",d);return d},P.prototype.addSelfInitialize=function(a){a.init?a.init(this):this.initAll();},P.prototype.addInitialize=function(){var a=arguments.length;while(a--)this.initializes.push(arguments[a]);},P.prototype.removeInitialize=function(a){var b=this.initializes.indexOf(a);b>-1&&this.initializes.splice(b,1);},P.prototype.removeInitializers=function(){b.Util.destroyArray(this.initializes);},P.prototype.addBehaviour=function(){var a=arguments.length;while(a--)this.behaviours.push(arguments[a]);},P.prototype.removeBehaviour=function(a){var b=this.behaviours.indexOf(a);b>-1&&this.behaviours.splice(b,1);},P.prototype.removeAllBehaviours=function(){b.Util.destroyArray(this.behaviours);},P.prototype.integrate=function(a){var c=1-this.damping;b.integrator.integrate(this,a,c);var d=this.particles.length;while(d--){var e=this.particles[d];e.update(a,d),b.integrator.integrate(e,a,c),this.parent&&this.parent.dispatchEvent("PARTICLE_UPDATE",e),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_UPDATE",e);}},P.prototype.emitting=function(a){if(this.totalEmitTimes=="once"){var b=this.rate.getValue(99999);b>0&&(this.cID=b);while(b--)this.createParticle();this.totalEmitTimes="none";}else if(!isNaN(this.totalEmitTimes)){this.currentEmitTime+=a;if(this.currentEmitTime<this.totalEmitTimes){var b=this.rate.getValue(a);b>0&&(this.cID=b);while(b--)this.createParticle();}}},P.prototype.update=function(a){this.age+=a,(this.dead||this.age>=this.life)&&this.destroy(),this.emitting(a),this.integrate(a);var c,d=this.particles.length;while(d--)c=this.particles[d],c.dead&&(this.parent&&this.parent.dispatchEvent("PARTICLE_DEAD",c),b.bindEmtterEvent&&this.dispatchEvent("PARTICLE_DEAD",c),this.parent.pool.expire(c.reset()),this.particles.splice(d,1));},P.prototype.setupParticle=function(a,c,d){var e=this.initializes,f=this.behaviours;c&&(b.Util.isArray(c)?e=c:e=[c]),d&&(b.Util.isArray(d)?f=d:f=[d]),b.InitializeUtil.initialize(this,a,e),a.addBehaviours(f),a.parent=this,this.particles.push(a);},P.prototype.destroy=function(){this.dead=!0,this.energy=0,this.totalEmitTimes=-1,this.particles.length==0&&(this.removeInitializers(),this.removeAllBehaviours(),this.parent&&this.parent.removeEmitter(this));},b.Emitter=P,b.Util.inherits(Q,b.Emitter),Q.prototype.addSelfBehaviour=function(){var a=arguments.length,b;for(b=0;b<a;b++)this.selfBehaviours.push(arguments[b]);},Q.prototype.removeSelfBehaviour=function(a){var b=this.selfBehaviours.indexOf(a);b>-1&&this.selfBehaviours.splice(b,1);},Q.prototype.update=function(a){Q._super_.prototype.update.call(this,a);if(!this.sleep){var b=this.selfBehaviours.length,c;for(c=0;c<b;c++)this.selfBehaviours[c].applyBehaviour(this,a,c);}},b.BehaviourEmitter=Q,b.Util.inherits(R,b.Emitter),R.prototype.initEventHandler=function(){var a=this;this.mousemoveHandler=function(b){a.mousemove.call(a,b);},this.mousedownHandler=function(b){a.mousedown.call(a,b);},this.mouseupHandler=function(b){a.mouseup.call(a,b);},this.mouseTarget.addEventListener("mousemove",this.mousemoveHandler,!1);},R.prototype.emit=function(){this._allowEmitting=!0;},R.prototype.stopEmit=function(){this._allowEmitting=!1;},R.prototype.setCameraAndCanvas=function(a,b){this.camera=a,this.canvas=b;},R.prototype.setCameraAndRenderer=function(a,b){this.camera=a,this.renderer=b,this.canvas=b.domElement;},R.prototype.mousemove=function(a){var c=this.canvas.getBoundingClientRect(),d=a.clientX-c.left,e=a.clientY-c.top,f=this.renderer?this.renderer.getPixelRatio():1;d*=f,e*=f,this.mouse.x+=(d-this.mouse.x)*this.ease,this.mouse.y+=(e-this.mouse.y)*this.ease,this.p.copy(b.THREEUtil.toSpacePos(this.mouse,this.camera,this.canvas,this.renderer)),this._allowEmitting&&R._super_.prototype.emit.call(this,"once");},R.prototype.destroy=function(){R._super_.prototype.destroy.call(this),this.mouseTarget.removeEventListener("mousemove",this.mousemoveHandler,!1);},b.FollowEmitter=R;var S=S||{easeLinear:function(a){return a},easeInQuad:function(a){return Math.pow(a,2)},easeOutQuad:function(a){return -(Math.pow(a-1,2)-1)},easeInOutQuad:function(a){if((a/=.5)<1)return .5*Math.pow(a,2);return -0.5*((a-=2)*a-2)},easeInCubic:function(a){return Math.pow(a,3)},easeOutCubic:function(a){return Math.pow(a-1,3)+1},easeInOutCubic:function(a){if((a/=.5)<1)return .5*Math.pow(a,3);return .5*(Math.pow(a-2,3)+2)},easeInQuart:function(a){return Math.pow(a,4)},easeOutQuart:function(a){return -(Math.pow(a-1,4)-1)},easeInOutQuart:function(a){if((a/=.5)<1)return .5*Math.pow(a,4);return -0.5*((a-=2)*Math.pow(a,3)-2)},easeInSine:function(a){return -Math.cos(a*(b.PI/2))+1},easeOutSine:function(a){return Math.sin(a*(b.PI/2))},easeInOutSine:function(a){return -0.5*(Math.cos(b.PI*a)-1)},easeInExpo:function(a){return a===0?0:Math.pow(2,10*(a-1))},easeOutExpo:function(a){return a===1?1:-Math.pow(2,-10*a)+1},easeInOutExpo:function(a){if(a===0)return 0;if(a===1)return 1;if((a/=.5)<1)return .5*Math.pow(2,10*(a-1));return .5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return -(Math.sqrt(1-a*a)-1)},easeOutCirc:function(a){return Math.sqrt(1-Math.pow(a-1,2))},easeInOutCirc:function(a){if((a/=.5)<1)return -0.5*(Math.sqrt(1-a*a)-1);return .5*(Math.sqrt(1-(a-=2)*a)+1)},easeInBack:function(a){var b=1.70158;return a*a*((b+1)*a-b)},easeOutBack:function(a){var b=1.70158;return (a=a-1)*a*((b+1)*a+b)+1},easeInOutBack:function(a){var b=1.70158;if((a/=.5)<1)return .5*a*a*(((b*=1.525)+1)*a-b);return .5*((a-=2)*a*(((b*=1.525)+1)*a+b)+2)},setEasingByName:function(a){return S[a]?S[a]:S.easeLinear}};for(var T in S)T!="setEasingByName"&&(b[T]=S[T]);b.ease=S,U.prototype={init:function(a){var b=this;this.proton=a,this.proton.addEventListener("PROTON_UPDATE",function(a){b.onProtonUpdate.call(b,a);}),this.proton.addEventListener("PARTICLE_CREATED",function(a){b.onParticleCreated.call(b,a);}),this.proton.addEventListener("PARTICLE_UPDATE",function(a){b.onParticleUpdate.call(b,a);}),this.proton.addEventListener("PARTICLE_DEAD",function(a){b.onParticleDead.call(b,a);});},remove:function(a){this.proton=null;},onParticleCreated:function(a){},onParticleUpdate:function(a){},onParticleDead:function(a){},onProtonUpdate:function(a){}},b.BaseRender=U,b.Util.inherits(V,b.BaseRender),V.prototype.onProtonUpdate=function(){},V.prototype.onParticleCreated=function(a){if(!a.target){a.body||(a.body=this._body),a.target=this._targetPool.get(a.body);if(a.useAlpha||a.useColor)a.target.material.__puid=b.PUID.id(a.body.material),a.target.material=this._materialPool.get(a.target.material);}a.target&&(a.target.position.copy(a.p),this.container.add(a.target));},V.prototype.onParticleUpdate=function(a){a.target&&(a.target.position.copy(a.p),a.target.rotation.set(a.rotation.x,a.rotation.y,a.rotation.z),this.scale(a),a.useAlpha&&(a.target.material.opacity=a.alpha,a.target.material.transparent=!0),a.useColor&&a.target.material.color.copy(a.color));},V.prototype.scale=function(a){a.target.scale.set(a.scale,a.scale,a.scale);},V.prototype.onParticleDead=function(a){a.target&&((a.useAlpha||a.useColor)&&this._materialPool.expire(a.target.material),this._targetPool.expire(a.target),this.container.remove(a.target),a.target=null);},b.MeshRender=V,b.Util.inherits(W,b.BaseRender),W.prototype.onProtonUpdate=function(){},W.prototype.onParticleCreated=function(b){b.target||(b.target=new a.Vector3),b.target.copy(b.p),this.points.geometry.vertices.push(b.target);},W.prototype.onParticleUpdate=function(a){a.target&&a.target.copy(a.p);},W.prototype.onParticleDead=function(a){if(a.target){var b=this.points.geometry.vertices.indexOf(a.target);b>-1&&this.points.geometry.vertices.splice(b,1),a.target=null;}},b.PointsRender=W,b.Util.inherits(X,b.MeshRender),X.prototype.scale=function(a){a.target.scale.set(a.scale*a.radius,a.scale*a.radius,1);},b.SpriteRender=X,b.Util.inherits(Y,b.BaseRender),Y.prototype.onProtonUpdate=function(){},Y.prototype.onParticleCreated=function(a){},Y.prototype.onParticleUpdate=function(a){},Y.prototype.onParticleDead=function(a){},b.CustomRender=Y,Z.prototype={getPosition:function(){return null},crossing:function(a){switch(this.crossType){case"bound":this._bound(a);break;case"cross":this._cross(a);break;case"dead":this._dead(a);}},_dead:function(a){},_bound:function(a){},_cross:function(a){}},b.Zone=Z,b.Util.inherits($,b.Zone),$.prototype.getPosition=function(){this.random=Math.random(),this.vector.x=this.x1+this.random*(this.x2-this.x1),this.vector.y=this.y1+this.random*(this.y2-this.y1),this.vector.z=this.z1+this.random*(this.z2-this.z1);return this.vector},$.prototype.crossing=function(a){this.log&&(console.error("Sorry LineZone does not support crossing method"),this.log=!1);},b.LineZone=$,b.Util.inherits(_,b.Zone),_.prototype.getPosition=function(){var a,c,d;return function(){this.random=Math.random(),d=this.random*this.radius,a=b.PI*Math.random(),c=b.PI*2*Math.random(),this.vector.x=this.x+d*Math.sin(a)*Math.cos(c),this.vector.y=this.y+d*Math.sin(c)*Math.sin(a),this.vector.z=this.z+d*Math.cos(a);return this.vector}}(),_.prototype._dead=function(a){var b=a.p.distanceTo(this);b-a.radius>this.radius&&(a.dead=!0);},_.prototype._bound=function(){var a=new b.Vector3D,c=new b.Vector3D,d;return function(b){var e=b.p.distanceTo(this);e+b.radius>=this.radius&&(a.copy(b.p).sub(this).normalize(),c.copy(b.v),d=2*c.dot(a),b.v.sub(a.scalar(d)));}}(),_.prototype._cross=function(a){this.log&&(console.error("Sorry SphereZone does not support _cross method"),this.log=!1);},b.SphereZone=_,b.Util.inherits(ba,b.Zone),ba.prototype.getPosition=function(){var a=this.geometry.vertices,b=a[a.length*Math.random()>>0];this.vector.x=b.x*this.scale,this.vector.y=b.y*this.scale,this.vector.z=b.z*this.scale;return this.vector},ba.prototype.crossing=function(a){this.log&&(console.error("Sorry MeshZone does not support crossing method"),this.log=!1);},b.MeshZone=ba,b.Util.inherits(bb,b.Zone),bb.prototype.getPosition=function(){this.vector.x=this.x,this.vector.y=this.y,this.vector.z=this.z;return this.vector},bb.prototype.crossing=function(a){this.log&&(console.error("Sorry PointZone does not support crossing method"),this.log=!1);},b.PointZone=bb,b.Util.inherits(bc,b.Zone),bc.prototype.getPosition=function(){this.vector.x=this.x+b.MathUtils.randomAToB(-0.5,.5)*this.width,this.vector.y=this.y+b.MathUtils.randomAToB(-0.5,.5)*this.height,this.vector.z=this.z+b.MathUtils.randomAToB(-0.5,.5)*this.depth;return this.vector},bc.prototype._dead=function(a){a.p.x+a.radius<this.x-this.width/2?a.dead=!0:a.p.x-a.radius>this.x+this.width/2&&(a.dead=!0),a.p.y+a.radius<this.y-this.height/2?a.dead=!0:a.p.y-a.radius>this.y+this.height/2&&(a.dead=!0),a.p.z+a.radius<this.z-this.depth/2?a.dead=!0:a.p.z-a.radius>this.z+this.depth/2&&(a.dead=!0);},bc.prototype._bound=function(a){a.p.x-a.radius<this.x-this.width/2?(a.p.x=this.x-this.width/2+a.radius,a.v.x*=-this.friction,this._static(a,"x")):a.p.x+a.radius>this.x+this.width/2&&(a.p.x=this.x+this.width/2-a.radius,a.v.x*=-this.friction,this._static(a,"x")),a.p.y-a.radius<this.y-this.height/2?(a.p.y=this.y-this.height/2+a.radius,a.v.y*=-this.friction,this._static(a,"y")):a.p.y+a.radius>this.y+this.height/2&&(a.p.y=this.y+this.height/2-a.radius,a.v.y*=-this.friction,this._static(a,"y")),a.p.z-a.radius<this.z-this.depth/2?(a.p.z=this.z-this.depth/2+a.radius,a.v.z*=-this.friction,this._static(a,"z")):a.p.z+a.radius>this.z+this.depth/2&&(a.p.z=this.z+this.depth/2-a.radius,a.v.z*=-this.friction,this._static(a,"z"));},bc.prototype._static=function(a,b){a.v[b]*a.a[b]>0||Math.abs(a.v[b])<Math.abs(a.a[b])*.0167*this.max&&(a.v[b]=0,a.a[b]=0);},bc.prototype._cross=function(a){a.p.x+a.radius<this.x-this.width/2&&a.v.x<=0?a.p.x=this.x+this.width/2+a.radius:a.p.x-a.radius>this.x+this.width/2&&a.v.x>=0&&(a.p.x=this.x-this.width/2-a.radius),a.p.y+a.radius<this.y-this.height/2&&a.v.y<=0?a.p.y=this.y+this.height/2+a.radius:a.p.y-a.radius>this.y+this.height/2&&a.v.y>=0&&(a.p.y=this.y-this.height/2-a.radius),a.p.z+a.radius<this.z-this.depth/2&&a.v.z<=0?a.p.z=this.z+this.depth/2+a.radius:a.p.z-a.radius>this.z+this.depth/2&&a.v.z>=0&&(a.p.z=this.z-this.depth/2-a.radius);},b.BoxZone=bc,b.Util.inherits(bd,b.Zone),bd.prototype.getPosition=function(){var a=new b.Vector3D,c;return function(){c=this.renderer.domElement,a.x=Math.random()*c.width,a.y=Math.random()*c.height,this.vector.copy(b.THREEUtil.toSpacePos(a,this.camera,c));return this.vector}}(),bd.prototype._dead=function(a){var c=b.THREEUtil.toScreenPos(a.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+a.radius<-this.dis&&this.d1?a.dead=!0:c.y-a.radius>d.height+this.dis&&this.d3&&(a.dead=!0),c.x+a.radius<-this.dis&&this.d4?a.dead=!0:c.x-a.radius>d.width+this.dis&&this.d2&&(a.dead=!0);},bd.prototype._cross=function(){var a=new b.Vector3D;return function(c){var d=b.THREEUtil.toScreenPos(c.p,this.camera,this.renderer.domElement),e=this.renderer.domElement;d.y+c.radius<-this.dis?(a.x=d.x,a.y=e.height+this.dis+c.radius,c.p.y=b.THREEUtil.toSpacePos(a,this.camera,e).y):d.y-c.radius>e.height+this.dis&&(a.x=d.x,a.y=-this.dis-c.radius,c.p.y=b.THREEUtil.toSpacePos(a,this.camera,e).y),d.x+c.radius<-this.dis?(a.y=d.y,a.x=e.width+this.dis+c.radius,c.p.x=b.THREEUtil.toSpacePos(a,this.camera,e).x):d.x-c.radius>e.width+this.dis&&(a.y=d.y,a.x=-this.dis-c.radius,c.p.x=b.THREEUtil.toSpacePos(a,this.camera,e).x);}}(),bd.prototype._bound=function(a){var c=b.THREEUtil.toScreenPos(a.p,this.camera,this.renderer.domElement),d=this.renderer.domElement;c.y+a.radius<-this.dis?a.v.y*=-1:c.y-a.radius>d.height+this.dis&&(a.v.y*=-1),c.x+a.radius<-this.dis?a.v.y*=-1:c.x-a.radius>d.width+this.dis&&(a.v.y*=-1);},b.ScreenZone=bd;var be=function(){if(window.console&&window.console.trace){var a=Array.prototype.slice.call(arguments),b=arguments[0]+"";if(b.indexOf("+")==0){var c=parseInt(arguments[0]);be.once<c&&(a.shift(),console.trace.apply(console,a),be.once++);}else a.unshift("+15"),be.apply(console,a);}};be.once=0,b.log=be;var bf=bf||{addEventListener:function(a,b){a.addEventListener("PROTON_UPDATE",function(a){b(a);});},drawZone:function(c,d,e){var f,g,h;e instanceof b.PointZone?f=new a.SphereGeometry(15):e instanceof b.LineZone||(e instanceof b.BoxZone?f=new a.BoxGeometry(e.width,e.height,e.depth):e instanceof b.SphereZone?f=new a.SphereGeometry(e.radius,10,10):e instanceof b.MeshZone&&(e.geometry instanceof a.Geometry?f=e.geometry:f=e.geometry.geometry,f=new a.SphereGeometry(e.radius,10,10))),g=new a.MeshBasicMaterial({color:"#2194ce",wireframe:!0}),h=new a.Mesh(f,g),d.add(h),this.addEventListener(c,function(a){h.position.set(e.x,e.y,e.z);});},drawEmitter:function(b,c,d,e){var f=new a.OctahedronGeometry(15),g=new a.MeshBasicMaterial({color:e||"#aaa",wireframe:!0}),h=new a.Mesh(f,g);c.add(h),this.addEventListener(b,function(){h.position.copy(d.p),h.rotation.set(d.rotation.x,d.rotation.y,d.rotation.z);});},renderInfo:function(){function b(a){var b=a.emitters[0];return Math.round(b.p.x)+","+Math.round(b.p.y)+","+Math.round(b.p.z)}function a(a,b){var c=b=="material"?"_materialPool":"_targetPool",d=a.renderers[0];return d[c].cID}return function(c,d){this.addInfo(d);var e="";switch(this._infoType){case 2:e+="emitter:"+c.emitters.length+"<br>",e+="em speed:"+c.emitters[0].cID+"<br>",e+="pos:"+b(c);break;case 3:e+=c.renderers[0].name+"<br>",e+="target:"+a(c,"target")+"<br>",e+="material:"+a(c,"material");break;default:e+="particles:"+c.getCount()+"<br>",e+="pool:"+c.pool.getCount()+"<br>",e+="total:"+(c.getCount()+c.pool.getCount());}this._infoCon.innerHTML=e;}}(),addInfo:function(){return function(a){var b=this;if(!this._infoCon){this._infoCon=document.createElement("div"),this._infoCon.style.cssText=["position:fixed;bottom:0px;left:0;cursor:pointer;","opacity:0.9;z-index:10000;padding:10px;font-size:12px;","width:120px;height:50px;background-color:#002;color:#0ff;"].join(""),this._infoType=1,this._infoCon.addEventListener("click",function(a){b._infoType++,b._infoType>3&&(b._infoType=1);},!1);var c,d;switch(a){case 2:c="#201",d="#f08";break;case 3:c="#020",d="#0f0";break;default:c="#002",d="#0ff";}this._infoCon.style["background-color"]=c,this._infoCon.style.color=d;}this._infoCon.parentNode||document.body.appendChild(this._infoCon);}}()};b.Debug=bf;return b});
61582
61627
  }(three_proton_min));
61583
61628
 
61584
- var Proton = three_proton_min.exports;var TIME_FOR_UPDATE = 150;
61629
+ var Proton = three_proton_min.exports;var TIME_FOR_UPDATE = 5;
61585
61630
  var VOLUME = 2;
61586
61631
  var AUDIO_EVENTS = {
61587
61632
  ENDED: 'ended'
@@ -72444,14 +72489,23 @@ var EXTENSIONS = {
72444
72489
  OBJ: 'obj'
72445
72490
  };
72446
72491
  var FULL_STOP = '.';
72447
- var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, new ObjectLoader()), _defineProperty$1(_loaders, EXTENSIONS.GLB, new GLTFLoader()), _defineProperty$1(_loaders, EXTENSIONS.GLTF, new GLTFLoader()), _defineProperty$1(_loaders, EXTENSIONS.FBX, new FBXLoader()), _defineProperty$1(_loaders, EXTENSIONS.OBJ, new OBJMTLLoader()), _loaders);
72492
+ var loaders = (_loaders = {}, _defineProperty$1(_loaders, EXTENSIONS.JSON, ObjectLoader), _defineProperty$1(_loaders, EXTENSIONS.GLB, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.GLTF, GLTFLoader), _defineProperty$1(_loaders, EXTENSIONS.FBX, FBXLoader), _defineProperty$1(_loaders, EXTENSIONS.OBJ, OBJMTLLoader), _loaders);
72493
+ var loaderInstances = {};
72448
72494
 
72449
72495
  var extractExtension = function extractExtension(path) {
72450
72496
  return path.split(FULL_STOP).slice(-1).pop();
72451
72497
  };
72452
72498
 
72453
72499
  var getLoaderFromExtension = function getLoaderFromExtension(extension) {
72454
- return loaders[extension] || new ObjectLoader();
72500
+ var instance = loaderInstances[extension];
72501
+
72502
+ if (!instance) {
72503
+ var LoaderClass = loaders[extension] || ObjectLoader;
72504
+ instance = new LoaderClass();
72505
+ loaderInstances[extension] = instance;
72506
+ }
72507
+
72508
+ return instance;
72455
72509
  };
72456
72510
 
72457
72511
  var glbParser = function glbParser(_ref) {
@@ -72504,7 +72558,9 @@ var colladaParser = function colladaParser(_ref3) {
72504
72558
  var fbxParser = function fbxParser(scene) {
72505
72559
  scene.traverse(function (node) {
72506
72560
  if (node.isSkinnedMesh) {
72507
- node.material.skinning = true;
72561
+ processMaterial(node.material, function (material) {
72562
+ return material.skinning = true;
72563
+ });
72508
72564
  }
72509
72565
  });
72510
72566
  return {
@@ -72535,6 +72591,12 @@ var Models = function Models() {
72535
72591
 
72536
72592
  _defineProperty$1(this, "getModel", function (name) {
72537
72593
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72594
+ console.warn(DEPRECATIONS.MODELS_GETMODEL);
72595
+ return _this.get(name, options);
72596
+ });
72597
+
72598
+ _defineProperty$1(this, "get", function (name) {
72599
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72538
72600
 
72539
72601
  var _ref4 = _this.map[name] || _this.map[buildAssetId(name, _this.currentLevel)] || {},
72540
72602
  scene = _ref4.scene,
@@ -73571,11 +73633,6 @@ var Stats = /*#__PURE__*/function () {
73571
73633
  this._fps = 0;
73572
73634
  this._fpsMax = 100;
73573
73635
  this.fps = new Subject();
73574
- this.hasMemoryUsage = Features$1.isFeatureSupported(FEATURES.MEMORY);
73575
-
73576
- if (this.hasMemoryUsage) {
73577
- this.collectMemoryUsage();
73578
- }
73579
73636
  }
73580
73637
 
73581
73638
  _createClass(Stats, [{
@@ -73600,33 +73657,27 @@ var Stats = /*#__PURE__*/function () {
73600
73657
  return this._fps;
73601
73658
  }
73602
73659
  }, {
73603
- key: "collectMemoryUsage",
73604
- value: function collectMemoryUsage() {
73605
- this.memory = performance.memory.usedJSHeapSize / ONE_MB;
73606
- this.memoryMax = performance.memory.jsHeapSizeLimit / ONE_MB;
73660
+ key: "subscribe",
73661
+ value: function subscribe(handler) {
73662
+ var _this = this;
73663
+
73664
+ this.fps.subscribe(handler);
73665
+ return function () {
73666
+ return _this.fps.unsubscribe(handler);
73667
+ };
73607
73668
  }
73608
73669
  }, {
73609
- key: "getMemory",
73610
- value: function getMemory() {
73611
- this.frames++;
73612
- var time = (performance || Date).now();
73613
-
73614
- if (time >= this.prevTime + 1000) {
73615
- this.prevTime = time;
73616
- this.frames = 0;
73617
- this.collectMemoryUsage();
73670
+ key: "getMemoryUsage",
73671
+ value: function getMemoryUsage() {
73672
+ if (Features$1.isFeatureSupported(FEATURES.MEMORY)) {
73673
+ this.memory = performance.memory.usedJSHeapSize / ONE_MB;
73674
+ this.memoryMax = performance.memory.jsHeapSizeLimit / ONE_MB;
73618
73675
  }
73619
-
73620
- this.beginTime = time;
73621
73676
  }
73622
73677
  }, {
73623
73678
  key: "update",
73624
73679
  value: function update() {
73625
73680
  this.getFPS();
73626
-
73627
- if (this.hasMemoryUsage) {
73628
- this.getMemory();
73629
- }
73630
73681
  }
73631
73682
  }]);
73632
73683
 
@@ -73646,7 +73697,7 @@ var Stats$1 = new Stats();var Loader = /*#__PURE__*/function () {
73646
73697
  }]);
73647
73698
 
73648
73699
  return Loader;
73649
- }();var _excluded$1 = ["mesh", "scripts", "texture"];
73700
+ }();var _excluded$3 = ["mesh", "scripts", "texture"];
73650
73701
  var MeshLoader = /*#__PURE__*/function (_Loader) {
73651
73702
  _inherits(MeshLoader, _Loader);
73652
73703
 
@@ -73672,7 +73723,7 @@ var MeshLoader = /*#__PURE__*/function (_Loader) {
73672
73723
  var mesh = _ref.mesh,
73673
73724
  scripts = _ref.scripts,
73674
73725
  texture = _ref.texture,
73675
- opts = _objectWithoutProperties(_ref, _excluded$1);
73726
+ opts = _objectWithoutProperties(_ref, _excluded$3);
73676
73727
 
73677
73728
  return _this.loadMesh(_this.parseMesh(mesh), scripts, texture, opts);
73678
73729
  });
@@ -73861,7 +73912,7 @@ var Light = /*#__PURE__*/function (_Entity) {
73861
73912
  var intensity = this.getIntensity();
73862
73913
  return new Promise(function (resolve) {
73863
73914
  return new Between(intensity, value).time(time).on('update', function (value) {
73864
- return _this2.setIntensity(value);
73915
+ return !_this2.isDisposed() && _this2.setIntensity(value);
73865
73916
  }).on('complete', resolve);
73866
73917
  });
73867
73918
  }
@@ -74107,9 +74158,11 @@ var AmbientLight = /*#__PURE__*/function (_Light) {
74107
74158
 
74108
74159
  var _super = _createSuper(AmbientLight);
74109
74160
 
74110
- function AmbientLight(options) {
74161
+ function AmbientLight() {
74111
74162
  var _this;
74112
74163
 
74164
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
74165
+
74113
74166
  _classCallCheck(this, AmbientLight);
74114
74167
 
74115
74168
  var _options$color = options.color,
@@ -76453,14 +76506,22 @@ var OutlineEffect = /*#__PURE__*/function () {
76453
76506
  _classCallCheck(this, PostProcessing);
76454
76507
 
76455
76508
  _defineProperty$1(this, "isEnabled", function () {
76456
- return !!_this.effects.length || !!_this.customs.length;
76509
+ return _this.enabled && (!!_this.effects.length || !!_this.customs.length);
76457
76510
  });
76458
76511
 
76459
76512
  _defineProperty$1(this, "init", function () {
76460
- window.addEventListener('resize', _this.onWindowResize, false);
76461
- _this.composer = new EffectComposer(Scene$1.getRenderer());
76513
+ var _Config$postprocessin = Config$1.postprocessing(),
76514
+ _Config$postprocessin2 = _Config$postprocessin.enabled,
76515
+ enabled = _Config$postprocessin2 === void 0 ? false : _Config$postprocessin2;
76462
76516
 
76463
- _this.composer.addPass(new RenderPass(Scene$1.getScene(), Scene$1.getCameraBody()));
76517
+ _this.enabled = enabled;
76518
+
76519
+ if (enabled) {
76520
+ window.addEventListener('resize', _this.onWindowResize, false);
76521
+ _this.composer = new EffectComposer(Scene$1.getRenderer());
76522
+
76523
+ _this.composer.addPass(new RenderPass(Scene$1.getScene(), Scene$1.getCameraBody()));
76524
+ }
76464
76525
  });
76465
76526
 
76466
76527
  _defineProperty$1(this, "dispose", function () {
@@ -76523,14 +76584,6 @@ var OutlineEffect = /*#__PURE__*/function () {
76523
76584
  }
76524
76585
  });
76525
76586
 
76526
- _defineProperty$1(this, "render", function (dt) {
76527
- _this.composer.render(dt);
76528
-
76529
- _this.customs.forEach(function (e) {
76530
- return e.render(Scene$1.getScene(), Scene$1.getCameraBody(), dt);
76531
- });
76532
- });
76533
-
76534
76587
  this.map = (_this$map = {}, _defineProperty$1(_this$map, EFFECTS.SEPIA, {
76535
76588
  effect: SepiaEffect,
76536
76589
  isClass: false
@@ -76558,6 +76611,7 @@ var OutlineEffect = /*#__PURE__*/function () {
76558
76611
  }), _this$map);
76559
76612
  this.effects = [];
76560
76613
  this.customs = [];
76614
+ this.enabled = false;
76561
76615
  }
76562
76616
 
76563
76617
  _createClass(PostProcessing, [{
@@ -76565,6 +76619,16 @@ var OutlineEffect = /*#__PURE__*/function () {
76565
76619
  value: function get(id) {
76566
76620
  return this.map[id] || null;
76567
76621
  }
76622
+ }, {
76623
+ key: "render",
76624
+ value: function render(dt) {
76625
+ var scene = Scene$1.getScene();
76626
+ var camera = Scene$1.getCameraBody();
76627
+ this.composer.render(dt);
76628
+ this.customs.forEach(function (e) {
76629
+ return e.render(scene, camera, dt);
76630
+ });
76631
+ }
76568
76632
  }], [{
76569
76633
  key: "createEffect",
76570
76634
  value: function createEffect(_ref, options) {
@@ -76611,12 +76675,12 @@ var index$1=/*#__PURE__*/Object.freeze({__proto__:null,Emitter:k,Particle:P,Part
76611
76675
 
76612
76676
  _this.setSystem();
76613
76677
 
76678
+ _this.setName(name);
76679
+
76614
76680
  _this.setBody({
76615
76681
  body: new Object3D()
76616
76682
  });
76617
76683
 
76618
- _this.setName(name);
76619
-
76620
76684
  _this.setEntityType(ENTITY_TYPES.EFFECT.PARTICLE);
76621
76685
 
76622
76686
  return _this;
@@ -76718,12 +76782,17 @@ var index$1=/*#__PURE__*/Object.freeze({__proto__:null,Emitter:k,Particle:P,Part
76718
76782
  this.system.particleSystem.rotation.set(rotation.x, rotation.y, rotation.z);
76719
76783
  }
76720
76784
  }
76785
+ }, {
76786
+ key: "dispose",
76787
+ value: function dispose() {
76788
+ _get(_getPrototypeOf(ParticleEmitter.prototype), "dispose", this).call(this);
76789
+ }
76721
76790
  }, {
76722
76791
  key: "update",
76723
76792
  value: function update(dt) {
76724
76793
  _get(_getPrototypeOf(ParticleEmitter.prototype), "update", this).call(this, dt);
76725
76794
 
76726
- if (this.hasSystem()) {
76795
+ if (this.hasSystem() && !this.isSystemDead()) {
76727
76796
  this.system.update(dt);
76728
76797
  }
76729
76798
 
@@ -76964,7 +77033,9 @@ var index$1=/*#__PURE__*/Object.freeze({__proto__:null,Emitter:k,Particle:P,Part
76964
77033
  }]);
76965
77034
 
76966
77035
  return ParticleEmitterGroup;
76967
- }(Entity);var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
77036
+ }(Entity);var _excluded$2 = ["initializers", "behaviours", "texture", "color", "rate"];
77037
+ var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
77038
+ var SYSTEM_DISPOSE_TIMEOUT = 700;
76968
77039
 
76969
77040
  var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
76970
77041
  _inherits(ProtonParticleEmitter, _ParticleEmitter);
@@ -76972,6 +77043,8 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
76972
77043
  var _super = _createSuper(ProtonParticleEmitter);
76973
77044
 
76974
77045
  function ProtonParticleEmitter() {
77046
+ var _this;
77047
+
76975
77048
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
76976
77049
 
76977
77050
  _classCallCheck(this, ProtonParticleEmitter);
@@ -76984,15 +77057,28 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
76984
77057
  texture = _options$texture === void 0 ? false : _options$texture,
76985
77058
  _options$color = options.color,
76986
77059
  color = _options$color === void 0 ? DEFAULT_PARTICLE_COLOR : _options$color,
76987
- rate = options.rate;
76988
- var parsedOptions = {
77060
+ rate = options.rate,
77061
+ rest = _objectWithoutProperties(options, _excluded$2);
77062
+
77063
+ var parsedOptions = _objectSpread2$1({
76989
77064
  initializers: initializers,
76990
77065
  behaviours: behaviours,
76991
77066
  texture: texture,
76992
77067
  color: color,
76993
77068
  rate: rate
76994
- };
76995
- return _super.call(this, parsedOptions);
77069
+ }, rest);
77070
+
77071
+ _this = _super.call(this, parsedOptions);
77072
+
77073
+ _defineProperty$1(_assertThisInitialized(_this), "disposeSystem", function () {
77074
+ if (_this.hasSystem()) {
77075
+ _this.system.removeAllParticles();
77076
+
77077
+ _this.system.destroy();
77078
+ }
77079
+ });
77080
+
77081
+ return _this;
76996
77082
  }
76997
77083
 
76998
77084
  _createClass(ProtonParticleEmitter, [{
@@ -77020,7 +77106,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
77020
77106
  }, {
77021
77107
  key: "setSystem",
77022
77108
  value: function setSystem() {
77023
- var _this = this;
77109
+ var _this2 = this;
77024
77110
 
77025
77111
  var _this$options = this.options,
77026
77112
  _this$options$initial = _this$options.initializers,
@@ -77033,7 +77119,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
77033
77119
  this.system = new Proton.Emitter();
77034
77120
  this.system.rate = rate;
77035
77121
  initializers.forEach(function (initializer) {
77036
- return _this.system.addInitialize(initializer);
77122
+ return _this2.system.addInitialize(initializer);
77037
77123
  });
77038
77124
 
77039
77125
  if (texture) {
@@ -77041,7 +77127,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
77041
77127
  }
77042
77128
 
77043
77129
  behaviours.forEach(function (behaviour) {
77044
- return _this.system.addBehaviour(behaviour);
77130
+ return _this2.system.addBehaviour(behaviour);
77045
77131
  });
77046
77132
  }
77047
77133
  }, {
@@ -77082,8 +77168,8 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
77082
77168
  value: function dispose() {
77083
77169
  _get(_getPrototypeOf(ProtonParticleEmitter.prototype), "dispose", this).call(this);
77084
77170
 
77085
- this.system.stopEmit();
77086
- this.system.destroy();
77171
+ this.stop();
77172
+ setTimeout(this.disposeSystem, SYSTEM_DISPOSE_TIMEOUT);
77087
77173
  }
77088
77174
  }]);
77089
77175
 
@@ -77181,7 +77267,9 @@ var Explosion = /*#__PURE__*/function (_ParticleEmitterGroup) {
77181
77267
  }
77182
77268
 
77183
77269
  return Explosion;
77184
- }(ParticleEmitterGroup);var getFireRate = function getFireRate() {
77270
+ }(ParticleEmitterGroup);var _excluded$1 = ["texture", "direction", "size", "strength", "colors"];
77271
+
77272
+ var getFireRate = function getFireRate() {
77185
77273
  return new Proton.Rate(new Proton.Span(10, 15), new Proton.Span(.05, .1));
77186
77274
  };
77187
77275
 
@@ -77191,7 +77279,8 @@ var getFireInitializers = function getFireInitializers(direction, strength, size
77191
77279
  };
77192
77280
 
77193
77281
  var getFireBehaviours = function getFireBehaviours(direction, strength) {
77194
- return [new Proton.Scale(new Proton.Span(2, 2.5), 0), new Proton.G(strength / 100), new Proton.Color('#FF0026', ['#ffff00', '#ffff11'], Infinity, Proton.easeOutSine), new Proton.RandomDrift(direction.x / 100, direction.y / 100, direction.z / 100, 2.5)];
77282
+ var colors = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [PALETTES.FRENCH.MANDARIN_RED, PALETTES.FRENCH.MELON_MELODY];
77283
+ return [new Proton.Scale(new Proton.Span(2, 2.5), 0), new Proton.G(strength / 100), new Proton.Color(colors[0], colors[1], Infinity, Proton.easeOutSine), new Proton.RandomDrift(direction.x / 100, direction.y / 100, direction.z / 100, 2.5)];
77195
77284
  };
77196
77285
 
77197
77286
  var Fire = /*#__PURE__*/function (_ProtonParticleEmitte) {
@@ -77208,13 +77297,17 @@ var Fire = /*#__PURE__*/function (_ProtonParticleEmitte) {
77208
77297
  _options$size = options.size,
77209
77298
  size = _options$size === void 0 ? 20 : _options$size,
77210
77299
  _options$strength = options.strength,
77211
- strength = _options$strength === void 0 ? 100 : _options$strength;
77212
- var fireOptions = {
77300
+ strength = _options$strength === void 0 ? 100 : _options$strength,
77301
+ colors = options.colors,
77302
+ rest = _objectWithoutProperties(options, _excluded$1);
77303
+
77304
+ var fireOptions = _objectSpread2$1({
77213
77305
  rate: getFireRate(),
77214
77306
  texture: texture,
77215
77307
  initializers: getFireInitializers(direction, strength, size),
77216
- behaviours: getFireBehaviours(direction, strength)
77217
- };
77308
+ behaviours: getFireBehaviours(direction, strength, colors)
77309
+ }, rest);
77310
+
77218
77311
  return _super.call(this, fireOptions);
77219
77312
  }
77220
77313
 
@@ -77380,11 +77473,7 @@ var Particles = /*#__PURE__*/function () {
77380
77473
  _defineProperty$1(this, "updateEmitters", function (dt) {
77381
77474
  _this.toDispose = [];
77382
77475
  Object.keys(_this.emitters).forEach(function (uuid) {
77383
- var emitter = _this.emitters[uuid]; // if (emitter.getType() === GROUP) {
77384
- // emitter.forEach(emitter => this.updateSingleEmitter(emitter, dt));
77385
- // } else {
77386
- // this.updateSingleEmitter(emitter, dt);
77387
- // }
77476
+ var emitter = _this.emitters[uuid];
77388
77477
 
77389
77478
  _this.updateSingleEmitter(emitter, dt);
77390
77479
  });
@@ -77423,7 +77512,14 @@ var Particles = /*#__PURE__*/function () {
77423
77512
  }
77424
77513
  }, {
77425
77514
  key: "addParticleEmitter",
77426
- value: function addParticleEmitter(_emitter) {
77515
+ value: function addParticleEmitter(emitter) {
77516
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
77517
+ console.warn(DEPRECATIONS.PARTICLES_ADD_PARTICLE_EMITTER);
77518
+ return this.add(emitter, options);
77519
+ }
77520
+ }, {
77521
+ key: "add",
77522
+ value: function add(_emitter) {
77427
77523
  var _this2 = this;
77428
77524
 
77429
77525
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -77476,7 +77572,7 @@ var Particles = /*#__PURE__*/function () {
77476
77572
  }
77477
77573
 
77478
77574
  if (emitter.isSystemDead()) {
77479
- this.toDispose.push(emitter.uuid);
77575
+ this.toDispose.push(emitter.uuid());
77480
77576
  }
77481
77577
  }
77482
77578
  }, {
@@ -80675,7 +80771,6 @@ var Controls = /*#__PURE__*/function () {
80675
80771
  this.controls[CONTROLS.ORBIT] = new Orbit(Scene$1.getCameraBody(), Scene$1.getDOMElement());
80676
80772
  this.controls[CONTROLS.ORBIT].init();
80677
80773
  this.controls[CONTROLS.ORBIT].setTarget(target);
80678
- this.controls[CONTROLS.ORBIT].addEventListener(EVENTS.CHANGE, Scene$1.render);
80679
80774
  return this.controls[CONTROLS.ORBIT];
80680
80775
  }
80681
80776
  }, {
@@ -80730,37 +80825,6 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80730
80825
 
80731
80826
  _defineProperty$1(_assertThisInitialized(_this), "onStateChange", function (state) {});
80732
80827
 
80733
- _defineProperty$1(_assertThisInitialized(_this), "enableInput", function () {
80734
- Input$1.enable();
80735
-
80736
- if (!_this.inputListenersAreSet) {
80737
- INPUT_EVENTS_LIST.forEach(function (event) {
80738
- var methodName = "on".concat(upperCaseFirst(event));
80739
-
80740
- if (typeof _this[methodName] === 'function') {
80741
- Input$1.addEventListener(event, _this[methodName].bind(_assertThisInitialized(_this)));
80742
- }
80743
- });
80744
- _this.inputListenersAreSet = true;
80745
-
80746
- _this.onInputEnabled();
80747
- }
80748
- });
80749
-
80750
- _defineProperty$1(_assertThisInitialized(_this), "disableInput", function () {
80751
- Input$1.disable();
80752
- INPUT_EVENTS_LIST.forEach(function (event) {
80753
- var methodName = "on".concat(upperCaseFirst(event));
80754
-
80755
- if (typeof _this[methodName] === 'function') {
80756
- Input$1.removeEventListener(event, _this[methodName]);
80757
- }
80758
- });
80759
- _this.inputListenersAreSet = false;
80760
-
80761
- _this.onInputDisabled();
80762
- });
80763
-
80764
80828
  _defineProperty$1(_assertThisInitialized(_this), "parseScene", function (_ref) {
80765
80829
  var _ref$elements = _ref.elements,
80766
80830
  elements = _ref$elements === void 0 ? [] : _ref$elements,
@@ -80788,13 +80852,13 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80788
80852
  });
80789
80853
 
80790
80854
  _defineProperty$1(_assertThisInitialized(_this), "getJSONUrl", function () {
80791
- return "assets/scenes/".concat(_this.name, ".json");
80855
+ return null;
80792
80856
  });
80793
80857
 
80794
80858
  _defineProperty$1(_assertThisInitialized(_this), "loadScene", function () {
80795
80859
  var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getJSONUrl();
80796
80860
 
80797
- if (getWindow()) {
80861
+ if (getWindow() && url) {
80798
80862
  return fetch$1(url).then(function (res) {
80799
80863
  return res.json();
80800
80864
  }).then(_this.parseScene).catch(function () {
@@ -80810,38 +80874,13 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80810
80874
  return _this.loadScene(url);
80811
80875
  });
80812
80876
 
80813
- _defineProperty$1(_assertThisInitialized(_this), "requestNextAnimationFrame", function () {
80814
- _this.requestAnimationFrameId = requestNextFrame(_this.render.bind(_assertThisInitialized(_this)));
80815
- });
80816
-
80817
80877
  _defineProperty$1(_assertThisInitialized(_this), "cancelNextAnimationFrame", function () {
80818
- cancelAnimationFrame(_this.requestAnimationFrameId);
80819
- });
80820
-
80821
- _defineProperty$1(_assertThisInitialized(_this), "render", function () {
80822
- var dt = Scene$1.clock.getDelta();
80823
- Scene$1.render(dt);
80824
- Particles$1.update(dt);
80825
- PostProcessing$1.render(dt);
80826
-
80827
- _this.onUpdate(dt);
80828
-
80829
- Scene$1.update(dt);
80830
- Assets$1.update(dt);
80831
- Stats$1.update(dt);
80832
- Controls$1.update(dt);
80833
- Input$1.update(dt);
80834
-
80835
- _this.requestNextAnimationFrame();
80878
+ return cancelAnimationFrame(_this.requestAnimationFrameId);
80836
80879
  });
80837
80880
 
80838
80881
  _defineProperty$1(_assertThisInitialized(_this), "init", function () {
80839
- _this.options.path;
80840
80882
  Scene$1.create(_this.getName());
80841
80883
  Scene$1.createCamera(new Camera());
80842
-
80843
- _this.enableInput();
80844
-
80845
80884
  Physics$1.init().then(function () {
80846
80885
  Particles$1.init();
80847
80886
  PostProcessing$1.init();
@@ -80860,8 +80899,6 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80860
80899
  _defineProperty$1(_assertThisInitialized(_this), "dispose", function () {
80861
80900
  _this.onBeforeDispose();
80862
80901
 
80863
- _this.disableInput();
80864
-
80865
80902
  Physics$1.dispose();
80866
80903
  Audio$1.dispose();
80867
80904
  Particles$1.dispose();
@@ -80879,6 +80916,7 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80879
80916
  _this.name = _this.constructor.name;
80880
80917
  _this.debug = true;
80881
80918
  _this.inputListenersAreSet = false;
80919
+ _this.render = _this.render.bind(_assertThisInitialized(_this));
80882
80920
  return _this;
80883
80921
  }
80884
80922
 
@@ -80896,12 +80934,6 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80896
80934
  }, {
80897
80935
  key: "onUpdate",
80898
80936
  value: function onUpdate() {}
80899
- }, {
80900
- key: "onFailedTest",
80901
- value: function onFailedTest(message, test) {}
80902
- }, {
80903
- key: "onSuccededTest",
80904
- value: function onSuccededTest(message) {}
80905
80937
  }, {
80906
80938
  key: "onBeforeDispose",
80907
80939
  value: function onBeforeDispose() {}
@@ -80909,11 +80941,30 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
80909
80941
  key: "onDispose",
80910
80942
  value: function onDispose() {}
80911
80943
  }, {
80912
- key: "onInputEnabled",
80913
- value: function onInputEnabled() {}
80944
+ key: "requestNextAnimationFrame",
80945
+ value: function requestNextAnimationFrame() {
80946
+ this.requestAnimationFrameId = requestNextFrame(this.render);
80947
+ }
80914
80948
  }, {
80915
- key: "onInputDisabled",
80916
- value: function onInputDisabled() {}
80949
+ key: "render",
80950
+ value: function render() {
80951
+ var dt = Scene$1.clock.getDelta();
80952
+
80953
+ if (PostProcessing$1.isEnabled()) {
80954
+ PostProcessing$1.render(dt);
80955
+ } else {
80956
+ Scene$1.render(dt);
80957
+ }
80958
+
80959
+ Particles$1.update(dt);
80960
+ this.onUpdate(dt);
80961
+ Scene$1.update(dt);
80962
+ Assets$1.update(dt);
80963
+ Stats$1.update(dt);
80964
+ Controls$1.update(dt);
80965
+ Input$1.update(dt);
80966
+ this.requestNextAnimationFrame();
80967
+ }
80917
80968
  }, {
80918
80969
  key: "toJSON",
80919
80970
  value: function toJSON() {
@@ -86888,9 +86939,11 @@ var HemisphereLight = /*#__PURE__*/function (_Light) {
86888
86939
 
86889
86940
  var _super = _createSuper(HemisphereLight);
86890
86941
 
86891
- function HemisphereLight(options) {
86942
+ function HemisphereLight() {
86892
86943
  var _this;
86893
86944
 
86945
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
86946
+
86894
86947
  _classCallCheck(this, HemisphereLight);
86895
86948
 
86896
86949
  var _options$color = options.color,