mage-engine 3.23.3 → 3.23.5

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 +1823 -2001
  2. package/package.json +1 -1
package/dist/mage.js CHANGED
@@ -39152,7 +39152,7 @@ function LoadingManager( onLoad, onProgress, onError ) {
39152
39152
 
39153
39153
  const DefaultLoadingManager = new LoadingManager();
39154
39154
 
39155
- function Loader$1( manager ) {
39155
+ function Loader( manager ) {
39156
39156
 
39157
39157
  this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;
39158
39158
 
@@ -39164,7 +39164,7 @@ function Loader$1( manager ) {
39164
39164
 
39165
39165
  }
39166
39166
 
39167
- Object.assign( Loader$1.prototype, {
39167
+ Object.assign( Loader.prototype, {
39168
39168
 
39169
39169
  load: function ( /* url, onLoad, onProgress, onError */ ) {},
39170
39170
 
@@ -39223,11 +39223,11 @@ const loading = {};
39223
39223
 
39224
39224
  function FileLoader( manager ) {
39225
39225
 
39226
- Loader$1.call( this, manager );
39226
+ Loader.call( this, manager );
39227
39227
 
39228
39228
  }
39229
39229
 
39230
- FileLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
39230
+ FileLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
39231
39231
 
39232
39232
  constructor: FileLoader,
39233
39233
 
@@ -39513,7 +39513,7 @@ FileLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
39513
39513
 
39514
39514
  } );
39515
39515
 
39516
- class AnimationLoader extends Loader$1 {
39516
+ class AnimationLoader extends Loader {
39517
39517
 
39518
39518
  constructor( manager ) {
39519
39519
 
@@ -39581,11 +39581,11 @@ class AnimationLoader extends Loader$1 {
39581
39581
 
39582
39582
  function CompressedTextureLoader( manager ) {
39583
39583
 
39584
- Loader$1.call( this, manager );
39584
+ Loader.call( this, manager );
39585
39585
 
39586
39586
  }
39587
39587
 
39588
- CompressedTextureLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
39588
+ CompressedTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
39589
39589
 
39590
39590
  constructor: CompressedTextureLoader,
39591
39591
 
@@ -39702,7 +39702,7 @@ CompressedTextureLoader.prototype = Object.assign( Object.create( Loader$1.proto
39702
39702
 
39703
39703
  } );
39704
39704
 
39705
- class ImageLoader extends Loader$1 {
39705
+ class ImageLoader extends Loader {
39706
39706
 
39707
39707
  constructor( manager ) {
39708
39708
 
@@ -39782,7 +39782,7 @@ class ImageLoader extends Loader$1 {
39782
39782
 
39783
39783
  }
39784
39784
 
39785
- class CubeTextureLoader extends Loader$1 {
39785
+ class CubeTextureLoader extends Loader {
39786
39786
 
39787
39787
  constructor( manager ) {
39788
39788
 
@@ -39840,11 +39840,11 @@ class CubeTextureLoader extends Loader$1 {
39840
39840
 
39841
39841
  function DataTextureLoader( manager ) {
39842
39842
 
39843
- Loader$1.call( this, manager );
39843
+ Loader.call( this, manager );
39844
39844
 
39845
39845
  }
39846
39846
 
39847
- DataTextureLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
39847
+ DataTextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
39848
39848
 
39849
39849
  constructor: DataTextureLoader,
39850
39850
 
@@ -39937,11 +39937,11 @@ DataTextureLoader.prototype = Object.assign( Object.create( Loader$1.prototype )
39937
39937
 
39938
39938
  function TextureLoader( manager ) {
39939
39939
 
39940
- Loader$1.call( this, manager );
39940
+ Loader.call( this, manager );
39941
39941
 
39942
39942
  }
39943
39943
 
39944
- TextureLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
39944
+ TextureLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
39945
39945
 
39946
39946
  constructor: TextureLoader,
39947
39947
 
@@ -42894,7 +42894,7 @@ class LightProbe extends Light$2 {
42894
42894
 
42895
42895
  LightProbe.prototype.isLightProbe = true;
42896
42896
 
42897
- class MaterialLoader extends Loader$1 {
42897
+ class MaterialLoader extends Loader {
42898
42898
 
42899
42899
  constructor( manager ) {
42900
42900
 
@@ -43318,7 +43318,7 @@ InstancedBufferAttribute.prototype = Object.assign( Object.create( BufferAttribu
43318
43318
 
43319
43319
  } );
43320
43320
 
43321
- class BufferGeometryLoader extends Loader$1 {
43321
+ class BufferGeometryLoader extends Loader {
43322
43322
 
43323
43323
  constructor( manager ) {
43324
43324
 
@@ -43520,7 +43520,7 @@ class BufferGeometryLoader extends Loader$1 {
43520
43520
 
43521
43521
  }
43522
43522
 
43523
- class ObjectLoader extends Loader$1 {
43523
+ class ObjectLoader extends Loader {
43524
43524
 
43525
43525
  constructor( manager ) {
43526
43526
 
@@ -44647,13 +44647,13 @@ function ImageBitmapLoader( manager ) {
44647
44647
 
44648
44648
  }
44649
44649
 
44650
- Loader$1.call( this, manager );
44650
+ Loader.call( this, manager );
44651
44651
 
44652
44652
  this.options = { premultiplyAlpha: 'none' };
44653
44653
 
44654
44654
  }
44655
44655
 
44656
- ImageBitmapLoader.prototype = Object.assign( Object.create( Loader$1.prototype ), {
44656
+ ImageBitmapLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
44657
44657
 
44658
44658
  constructor: ImageBitmapLoader,
44659
44659
 
@@ -45158,7 +45158,7 @@ function createPath( char, scale, offsetX, offsetY, data ) {
45158
45158
 
45159
45159
  Font.prototype.isFont = true;
45160
45160
 
45161
- class FontLoader extends Loader$1 {
45161
+ class FontLoader extends Loader {
45162
45162
 
45163
45163
  constructor( manager ) {
45164
45164
 
@@ -45229,7 +45229,7 @@ const AudioContext = {
45229
45229
 
45230
45230
  };
45231
45231
 
45232
- class AudioLoader extends Loader$1 {
45232
+ class AudioLoader extends Loader {
45233
45233
 
45234
45234
  constructor( manager ) {
45235
45235
 
@@ -52087,14 +52087,14 @@ function WireframeHelper( object, hex ) {
52087
52087
 
52088
52088
  //
52089
52089
 
52090
- Loader$1.prototype.extractUrlBase = function ( url ) {
52090
+ Loader.prototype.extractUrlBase = function ( url ) {
52091
52091
 
52092
52092
  console.warn( 'THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.' );
52093
52093
  return LoaderUtils.extractUrlBase( url );
52094
52094
 
52095
52095
  };
52096
52096
 
52097
- Loader$1.Handlers = {
52097
+ Loader.Handlers = {
52098
52098
 
52099
52099
  add: function ( /* regex, loader */ ) {
52100
52100
 
@@ -53918,7 +53918,7 @@ if ( typeof window !== 'undefined' ) {
53918
53918
 
53919
53919
  }
53920
53920
 
53921
- }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$1,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$2,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]";
53921
+ }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$1,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$2,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,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]";
53922
53922
  var DEPRECATED = "[DEPRECATED]";
53923
53923
  var DEPRECATIONS = {
53924
53924
  PARTICLES_ADD_PARTICLE_EMITTER: "".concat(PREFIX, " ").concat(DEPRECATED, " Particles.addParticleEmitter is deprecated, use Particles.add instead. Will be removed in the next major release"),
@@ -55854,7 +55854,7 @@ var convertAmmoVector = function convertAmmoVector(_ref2) {
55854
55854
  };
55855
55855
  };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() {
55856
55856
  return "".concat(document.location.protocol, "//").concat(document.location.host);
55857
- };var _excluded$a = ["uuid"];
55857
+ };var _excluded$9 = ["uuid"];
55858
55858
  var COLLIDER_TYPES = COLLIDER_TYPES$1;
55859
55859
  var getBoxDescriptionForElement = getBoxDescriptionForElement$1,
55860
55860
  extractPositionAndQuaternion = extractPositionAndQuaternion$1,
@@ -55928,7 +55928,7 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
55928
55928
 
55929
55929
  _defineProperty$1(_assertThisInitialized(_this), "handleBodyUpdate", function (_ref3) {
55930
55930
  var uuid = _ref3.uuid,
55931
- data = _objectWithoutProperties(_ref3, _excluded$a);
55931
+ data = _objectWithoutProperties(_ref3, _excluded$9);
55932
55932
 
55933
55933
  var element = Universe$1.getByUUID(uuid);
55934
55934
 
@@ -57777,7 +57777,7 @@ function applyMiddleware() {
57777
57777
 
57778
57778
  var thunk = createThunkMiddleware();
57779
57779
  thunk.withExtraArgument = createThunkMiddleware;var name$1 = "mage-engine";
57780
- var version$1 = "3.23.3";
57780
+ var version$1 = "3.23.5";
57781
57781
  var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
57782
57782
  var main = "dist/mage.js";
57783
57783
  var author$1 = {
@@ -59046,7 +59046,7 @@ if (!self.fetch) {
59046
59046
  self.Headers = Headers;
59047
59047
  self.Request = Request;
59048
59048
  self.Response = Response;
59049
- }var _excluded$9 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59049
+ }var _excluded$8 = ["wheels", "accelerationKey", "brakingKey", "rightKey", "leftKey", "debug", "autostart"];
59050
59050
 
59051
59051
  var BaseCar = /*#__PURE__*/function (_BaseScript) {
59052
59052
  _inherits(BaseCar, _BaseScript);
@@ -59074,7 +59074,7 @@ var BaseCar = /*#__PURE__*/function (_BaseScript) {
59074
59074
  options.debug;
59075
59075
  var _options$autostart = options.autostart,
59076
59076
  autostart = _options$autostart === void 0 ? true : _options$autostart,
59077
- physicsOptions = _objectWithoutProperties(options, _excluded$9);
59077
+ physicsOptions = _objectWithoutProperties(options, _excluded$8);
59078
59078
 
59079
59079
  this.car = element;
59080
59080
  this.wheels = wheels;
@@ -59762,10 +59762,7 @@ var CascadeShadowMaps = /*#__PURE__*/function () {
59762
59762
  }]);
59763
59763
 
59764
59764
  return CascadeShadowMaps;
59765
- }();var POINTLIGHT = 'pointlight';
59766
- var AMBIENTLIGHT = 'ambientlight';
59767
- var SUNLIGHT = 'sunlight';
59768
- var Lights = /*#__PURE__*/function () {
59765
+ }();var Lights = /*#__PURE__*/function () {
59769
59766
  function Lights() {
59770
59767
  _classCallCheck(this, Lights);
59771
59768
 
@@ -61102,7 +61099,7 @@ var tweenTo = function tweenTo(origin, target) {
61102
61099
  }(EventDispatcher);var _MATERIAL_TEXTURE_MAP;
61103
61100
  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);var material_constants=/*#__PURE__*/Object.freeze({__proto__:null,MATERIAL_TEXTURE_MAP:MATERIAL_TEXTURE_MAP});var isTextureMapAllowedForMaterial = function isTextureMapAllowedForMaterial(materialType, textureType) {
61104
61101
  return MATERIAL_TEXTURE_MAP[materialType] && MATERIAL_TEXTURE_MAP[materialType].includes(textureType);
61105
- };var _excluded$8 = ["position", "quaternion"],
61102
+ };var _excluded$7 = ["position", "quaternion"],
61106
61103
  _excluded2 = ["applyPhysicsUpdate"],
61107
61104
  _excluded3 = ["dt", "event"];
61108
61105
  var COLLIDER_TAG = "collider";
@@ -61292,7 +61289,7 @@ var Element$1 = /*#__PURE__*/function (_Entity) {
61292
61289
  _defineProperty$1(_assertThisInitialized(_this), "handlePhysicsUpdate", function (_ref6) {
61293
61290
  var position = _ref6.position,
61294
61291
  quaternion = _ref6.quaternion,
61295
- data = _objectWithoutProperties(_ref6, _excluded$8);
61292
+ data = _objectWithoutProperties(_ref6, _excluded$7);
61296
61293
 
61297
61294
  _this.setPosition(position);
61298
61295
 
@@ -62431,7 +62428,7 @@ var Plane = /*#__PURE__*/function (_Element) {
62431
62428
  }
62432
62429
 
62433
62430
  return Box;
62434
- }(Element$1);var _excluded$7 = ["anisotropy"];
62431
+ }(Element$1);var _excluded$6 = ["anisotropy"];
62435
62432
 
62436
62433
  var validateAnisotropy = function validateAnisotropy(anisotropy) {
62437
62434
  var max = Scene$1.getRenderer().capabilities.getMaxAnisotropy();
@@ -62457,7 +62454,7 @@ var Sprite = /*#__PURE__*/function (_Element) {
62457
62454
 
62458
62455
  var _options$anisotropy = options.anisotropy,
62459
62456
  anisotropy = _options$anisotropy === void 0 ? 1 : _options$anisotropy,
62460
- rest = _objectWithoutProperties(options, _excluded$7);
62457
+ rest = _objectWithoutProperties(options, _excluded$6);
62461
62458
 
62462
62459
  var texture = Images$1.get(spriteTexture);
62463
62460
  texture.anisotropy = validateAnisotropy(anisotropy);
@@ -69042,13 +69039,13 @@ var RequirementsTracer = /*#__PURE__*/function (_EventDispatcher) {
69042
69039
 
69043
69040
  var GLTFLoader = function () {
69044
69041
  function GLTFLoader(manager) {
69045
- Loader$1.call(this, manager);
69042
+ Loader.call(this, manager);
69046
69043
  this.dracoLoader = null;
69047
69044
  this.ddsLoader = null;
69048
69045
  this.options = {};
69049
69046
  }
69050
69047
 
69051
- GLTFLoader.prototype = Object.assign(Object.create(Loader$1.prototype), {
69048
+ GLTFLoader.prototype = Object.assign(Object.create(Loader.prototype), {
69052
69049
  constructor: GLTFLoader,
69053
69050
  setOptions: function setOptions(options) {
69054
69051
  this.options = options || {};
@@ -74656,7 +74653,9 @@ var NURBSCurve = /*#__PURE__*/function (_Curve) {
74656
74653
  }]);
74657
74654
 
74658
74655
  return NURBSCurve;
74659
- }(Curve);/**
74656
+ }(Curve);var isAbsoluteURL = function isAbsoluteURL(url) {
74657
+ return /^(?:\w+:)\/\//.test(url);
74658
+ };/**
74660
74659
  * Loader loads FBX file and generates Group representing FBX scene.
74661
74660
  * Requires FBX file to be >= 7.0 and in ASCII or >= 6400 in Binary format
74662
74661
  * Versions lower than this may load but will probably have errors
@@ -74748,21 +74747,27 @@ var buildFBXLoader = function buildFBXLoader() {
74748
74747
  var _this$options$texture = this.options.texture,
74749
74748
  texture = _this$options$texture === void 0 ? "" : _this$options$texture;
74750
74749
  var texturePath = LoaderUtils.extractUrlBase(texture);
74751
- var textureLoader = new TextureLoader(this.manager).setPath(this.resourcePath || texturePath || path).setCrossOrigin(this.crossOrigin);
74752
- return new FBXTreeParser(textureLoader, this.manager).parse(fbxTree);
74750
+ var textureLoader = new TextureLoader(this.manager).setCrossOrigin(this.crossOrigin);
74751
+
74752
+ if (!isAbsoluteURL(texture)) {
74753
+ textureLoader.setPath(this.resourcePath || texturePath || path);
74754
+ }
74755
+
74756
+ return new FBXTreeParser(textureLoader, this.manager, this.options).parse(fbxTree);
74753
74757
  }
74754
74758
  }]);
74755
74759
 
74756
74760
  return FBXLoader;
74757
- }(Loader$1); // Parse the FBXTree object returned by the BinaryParser or TextParser and return a Group
74761
+ }(Loader); // Parse the FBXTree object returned by the BinaryParser or TextParser and return a Group
74758
74762
 
74759
74763
 
74760
74764
  var FBXTreeParser = /*#__PURE__*/function () {
74761
- function FBXTreeParser(textureLoader, manager) {
74765
+ function FBXTreeParser(textureLoader, manager, options) {
74762
74766
  _classCallCheck(this, FBXTreeParser);
74763
74767
 
74764
74768
  this.textureLoader = textureLoader;
74765
74769
  this.manager = manager;
74770
+ this.options = options;
74766
74771
  }
74767
74772
 
74768
74773
  _createClass(FBXTreeParser, [{
@@ -74955,12 +74960,13 @@ var buildFBXLoader = function buildFBXLoader() {
74955
74960
  }, {
74956
74961
  key: "loadTexture",
74957
74962
  value: function loadTexture(textureNode, images) {
74963
+ var textureOption = this.options.texture;
74958
74964
  var fileName;
74959
74965
  var currentPath = this.textureLoader.path;
74960
74966
  var children = connections.get(textureNode.id).children;
74961
74967
 
74962
74968
  if (children !== undefined && children.length > 0 && images[children[0].ID] !== undefined) {
74963
- fileName = images[children[0].ID];
74969
+ fileName = textureOption instanceof Object ? textureOption[children[0].ID] : textureOption || images[children[0].ID];
74964
74970
 
74965
74971
  if (fileName.indexOf("blob:") === 0 || fileName.indexOf("data:") === 0) {
74966
74972
  this.textureLoader.setPath(undefined);
@@ -77889,7 +77895,7 @@ var MTLLoader = /*#__PURE__*/function (_Loader) {
77889
77895
  }]);
77890
77896
 
77891
77897
  return MTLLoader;
77892
- }(Loader$1);
77898
+ }(Loader);
77893
77899
  /**
77894
77900
  * Create a new MTLLoader.MaterialCreator
77895
77901
  * @param baseUrl - Url relative to which textures are loaded
@@ -78817,7 +78823,7 @@ var OBJLoader = /*#__PURE__*/function (_Loader) {
78817
78823
  }]);
78818
78824
 
78819
78825
  return OBJLoader;
78820
- }(Loader$1);var EXTENSIONS$1 = {
78826
+ }(Loader);var EXTENSIONS$1 = {
78821
78827
  OBJ: ".obj",
78822
78828
  MTL: ".mtl"
78823
78829
  };
@@ -83072,1407 +83078,416 @@ var Stats = /*#__PURE__*/function () {
83072
83078
  return Stats;
83073
83079
  }();
83074
83080
 
83075
- var Stats$1 = new Stats();var Loader = /*#__PURE__*/function () {
83076
- function Loader() {
83077
- _classCallCheck(this, Loader);
83081
+ var Stats$1 = new Stats();var Pass = /*#__PURE__*/function () {
83082
+ function Pass() {
83083
+ _classCallCheck(this, Pass);
83084
+
83085
+ // if set to true, the pass is processed by the composer
83086
+ this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
83087
+
83088
+ this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
83089
+
83090
+ this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
83078
83091
 
83079
- this.loader = new ObjectLoader();
83092
+ this.renderToScreen = false;
83093
+ this.isPass = true;
83080
83094
  }
83081
83095
 
83082
- _createClass(Loader, [{
83083
- key: "load",
83084
- value: function load() {}
83096
+ _createClass(Pass, [{
83097
+ key: "setSize",
83098
+ value: function setSize() {}
83099
+ }, {
83100
+ key: "render",
83101
+ value: function render() {
83102
+ console.error('THREE.Pass: .render() must be implemented in derived pass.');
83103
+ }
83085
83104
  }]);
83086
83105
 
83087
- return Loader;
83088
- }();var _excluded$6 = ["mesh", "scripts", "texture"];
83089
- var MeshLoader = /*#__PURE__*/function (_Loader) {
83090
- _inherits(MeshLoader, _Loader);
83106
+ return Pass;
83107
+ }(); // Helper for passes that need to fill the viewport with a single quad.
83091
83108
 
83092
- var _super = _createSuper(MeshLoader);
83109
+ var _camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1); // https://github.com/mrdoob/three.js/pull/21358
83093
83110
 
83094
- function MeshLoader() {
83095
- _classCallCheck(this, MeshLoader);
83096
83111
 
83097
- return _super.call(this);
83098
- }
83112
+ var _geometry = new BufferGeometry();
83099
83113
 
83100
- _createClass(MeshLoader, [{
83101
- key: "load",
83102
- value: function load() {
83103
- var _this = this;
83114
+ _geometry.setAttribute('position', new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
83104
83115
 
83105
- var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
83106
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
83107
- this.options = options;
83116
+ _geometry.setAttribute('uv', new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
83108
83117
 
83109
- try {
83110
- elements.map(function (_ref) {
83111
- var mesh = _ref.mesh,
83112
- scripts = _ref.scripts,
83113
- texture = _ref.texture,
83114
- opts = _objectWithoutProperties(_ref, _excluded$6);
83118
+ var FullScreenQuad = /*#__PURE__*/function () {
83119
+ function FullScreenQuad(material) {
83120
+ _classCallCheck(this, FullScreenQuad);
83115
83121
 
83116
- return _this.loadMesh(_this.parseMesh(mesh), scripts, texture, opts);
83117
- });
83118
- } catch (e) {
83119
- console.log(e);
83120
- }
83122
+ this._mesh = new Mesh(_geometry, material);
83123
+ }
83124
+
83125
+ _createClass(FullScreenQuad, [{
83126
+ key: "dispose",
83127
+ value: function dispose() {
83128
+ this._mesh.geometry.dispose();
83121
83129
  }
83122
83130
  }, {
83123
- key: "parseMesh",
83124
- value: function parseMesh(mesh) {
83125
- return this.loader.parse(mesh);
83131
+ key: "render",
83132
+ value: function render(renderer) {
83133
+ renderer.render(this._mesh, _camera);
83126
83134
  }
83127
83135
  }, {
83128
- key: "loadMesh",
83129
- value: function loadMesh(_ref2, scripts, texture, elementOptions) {
83130
- var geometry = _ref2.geometry,
83131
- material = _ref2.material,
83132
- position = _ref2.position,
83133
- rotation = _ref2.rotation,
83134
- scale = _ref2.scale;
83135
- var _this$options$scriptE = this.options.scriptEnabled,
83136
- scriptEnabled = _this$options$scriptE === void 0 ? true : _this$options$scriptE;
83137
- var element = new Element$1(_objectSpread2$1({
83138
- geometry: geometry,
83139
- material: material
83140
- }, elementOptions));
83141
- element.setPosition(_objectSpread2$1({}, position));
83142
- element.setRotation(_objectSpread2$1({}, rotation));
83143
- element.setScale(_objectSpread2$1({}, scale));
83136
+ key: "material",
83137
+ get: function get() {
83138
+ return this._mesh.material;
83139
+ },
83140
+ set: function set(value) {
83141
+ this._mesh.material = value;
83142
+ }
83143
+ }]);
83144
83144
 
83145
- if (scripts && scripts.length) {
83146
- element.addScripts(scripts.names, scripts.options, scriptEnabled);
83147
- element.start();
83145
+ return FullScreenQuad;
83146
+ }();var ShaderPass = /*#__PURE__*/function (_Pass) {
83147
+ _inherits(ShaderPass, _Pass);
83148
+
83149
+ var _super = _createSuper(ShaderPass);
83150
+
83151
+ function ShaderPass(shader, textureID) {
83152
+ var _this;
83153
+
83154
+ _classCallCheck(this, ShaderPass);
83155
+
83156
+ _this = _super.call(this);
83157
+ _this.textureID = textureID !== undefined ? textureID : 'tDiffuse';
83158
+
83159
+ if (shader instanceof ShaderMaterial) {
83160
+ _this.uniforms = shader.uniforms;
83161
+ _this.material = shader;
83162
+ } else if (shader) {
83163
+ _this.uniforms = UniformsUtils.clone(shader.uniforms);
83164
+ _this.material = new ShaderMaterial({
83165
+ defines: Object.assign({}, shader.defines),
83166
+ uniforms: _this.uniforms,
83167
+ vertexShader: shader.vertexShader,
83168
+ fragmentShader: shader.fragmentShader
83169
+ });
83170
+ }
83171
+
83172
+ _this.fsQuad = new FullScreenQuad(_this.material);
83173
+ return _this;
83174
+ }
83175
+
83176
+ _createClass(ShaderPass, [{
83177
+ key: "render",
83178
+ value: function render(renderer, writeBuffer, readBuffer
83179
+ /*, deltaTime, maskActive */
83180
+ ) {
83181
+ if (this.uniforms[this.textureID]) {
83182
+ this.uniforms[this.textureID].value = readBuffer.texture;
83148
83183
  }
83149
83184
 
83150
- return element;
83185
+ this.fsQuad.material = this.material;
83186
+
83187
+ if (this.renderToScreen) {
83188
+ renderer.setRenderTarget(null);
83189
+ this.fsQuad.render(renderer);
83190
+ } else {
83191
+ renderer.setRenderTarget(writeBuffer); // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
83192
+
83193
+ if (this.clear) renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
83194
+ this.fsQuad.render(renderer);
83195
+ }
83151
83196
  }
83152
83197
  }]);
83153
83198
 
83154
- return MeshLoader;
83155
- }(Loader);
83156
- var MeshLoader$1 = new MeshLoader();var Light$1 = /*#__PURE__*/function (_Entity) {
83157
- _inherits(Light, _Entity);
83199
+ return ShaderPass;
83200
+ }(Pass);/**
83201
+ * Full-screen textured quad shader
83202
+ */
83203
+ var CopyShader = {
83204
+ uniforms: {
83205
+ 'tDiffuse': {
83206
+ value: null
83207
+ },
83208
+ 'opacity': {
83209
+ value: 1.0
83210
+ }
83211
+ },
83212
+ vertexShader:
83213
+ /* glsl */
83214
+ "\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
83215
+ fragmentShader:
83216
+ /* glsl */
83217
+ "\n\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n gl_FragColor.a *= opacity;\n }"
83218
+ };var MaskPass = /*#__PURE__*/function (_Pass) {
83219
+ _inherits(MaskPass, _Pass);
83158
83220
 
83159
- var _super = _createSuper(Light);
83221
+ var _super = _createSuper(MaskPass);
83160
83222
 
83161
- function Light(_ref) {
83223
+ function MaskPass(scene, camera) {
83162
83224
  var _this;
83163
83225
 
83164
- var color = _ref.color,
83165
- intensity = _ref.intensity,
83166
- _name = _ref.name;
83226
+ _classCallCheck(this, MaskPass);
83167
83227
 
83168
- _classCallCheck(this, Light);
83228
+ _this = _super.call(this);
83229
+ _this.scene = scene;
83230
+ _this.camera = camera;
83231
+ _this.clear = true;
83232
+ _this.needsSwap = false;
83233
+ _this.inverse = false;
83234
+ return _this;
83235
+ }
83169
83236
 
83170
- _this = _super.call(this, {
83171
- name: _name
83172
- });
83237
+ _createClass(MaskPass, [{
83238
+ key: "render",
83239
+ value: function render(renderer, writeBuffer, readBuffer
83240
+ /*, deltaTime, maskActive */
83241
+ ) {
83242
+ var context = renderer.getContext();
83243
+ var state = renderer.state; // don't update color or depth
83173
83244
 
83174
- _defineProperty$1(_assertThisInitialized(_this), "addHolder", function () {
83175
- var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "lightholder";
83176
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
83177
- var holderSprite = new HelperSprite(size, size, name, {
83178
- name: name
83179
- });
83245
+ state.buffers.color.setMask(false);
83246
+ state.buffers.depth.setMask(false); // lock buffers
83180
83247
 
83181
- if (holderSprite) {
83182
- holderSprite.setSizeAttenuation(false);
83183
- holderSprite.setDepthTest(false);
83184
- holderSprite.setDepthWrite(false);
83185
- holderSprite.setSerializable(false);
83186
- holderSprite.setPosition(_this.getPosition());
83187
- holderSprite.addTags([TAGS.HELPER, TAGS.LIGHTS.HELPER, TAGS.LIGHTS.HOLDER, name]);
83188
- holderSprite.setHelperTarget(_assertThisInitialized(_this));
83189
- _this.holder = holderSprite;
83190
- return true;
83248
+ state.buffers.color.setLocked(true);
83249
+ state.buffers.depth.setLocked(true); // set up stencil
83250
+
83251
+ var writeValue, clearValue;
83252
+
83253
+ if (this.inverse) {
83254
+ writeValue = 0;
83255
+ clearValue = 1;
83191
83256
  } else {
83192
- console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND$1);
83193
- return false;
83257
+ writeValue = 1;
83258
+ clearValue = 0;
83194
83259
  }
83195
- });
83196
83260
 
83197
- _defineProperty$1(_assertThisInitialized(_this), "addTargetHolder", function () {
83198
- var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "targetholder";
83199
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
83200
- var targetSprite = new HelperSprite(size, size, name, {
83201
- name: name
83202
- });
83261
+ state.buffers.stencil.setTest(true);
83262
+ state.buffers.stencil.setOp(context.REPLACE, context.REPLACE, context.REPLACE);
83263
+ state.buffers.stencil.setFunc(context.ALWAYS, writeValue, 0xffffffff);
83264
+ state.buffers.stencil.setClear(clearValue);
83265
+ state.buffers.stencil.setLocked(true); // draw into the stencil buffer
83203
83266
 
83204
- if (targetSprite) {
83205
- targetSprite.setSizeAttenuation(false);
83206
- targetSprite.setDepthTest(false);
83207
- targetSprite.setDepthWrite(false);
83208
- targetSprite.setSerializable(false);
83209
- targetSprite.setPosition(_this.getTarget().getPosition());
83210
- targetSprite.addTags([TAGS.LIGHTS.HELPER, TAGS.LIGHTS.TARGET, name]);
83211
- targetSprite.setHelperTarget(_assertThisInitialized(_this));
83212
- targetSprite.getBody().add(_this.getBody().target);
83213
- _this.targetHolder = targetSprite;
83214
- }
83215
- });
83267
+ renderer.setRenderTarget(readBuffer);
83268
+ if (this.clear) renderer.clear();
83269
+ renderer.render(this.scene, this.camera);
83270
+ renderer.setRenderTarget(writeBuffer);
83271
+ if (this.clear) renderer.clear();
83272
+ renderer.render(this.scene, this.camera); // unlock color and depth buffer for subsequent rendering
83216
83273
 
83217
- _this.color = color;
83218
- _this.intensity = intensity;
83219
- _this.name = _name || generateRandomName("Light");
83220
- _this.isLightOn = false;
83221
- _this.body = undefined; // helper body for this light
83274
+ state.buffers.color.setLocked(false);
83275
+ state.buffers.depth.setLocked(false); // only render where stencil is set to 1
83222
83276
 
83223
- _this.isUsingHelper = undefined; // holder body representing the light
83277
+ state.buffers.stencil.setLocked(false);
83278
+ state.buffers.stencil.setFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
83224
83279
 
83225
- _this.holder = undefined; // target body for the light (only used by directional light)
83280
+ state.buffers.stencil.setOp(context.KEEP, context.KEEP, context.KEEP);
83281
+ state.buffers.stencil.setLocked(true);
83282
+ }
83283
+ }]);
83226
83284
 
83227
- _this.target = undefined;
83285
+ return MaskPass;
83286
+ }(Pass);var ClearMaskPass = /*#__PURE__*/function (_Pass) {
83287
+ _inherits(ClearMaskPass, _Pass);
83228
83288
 
83229
- _this.setEntityType(ENTITY_TYPES.LIGHT.DEFAULT);
83289
+ var _super = _createSuper(ClearMaskPass);
83230
83290
 
83231
- Lights$1.add(_assertThisInitialized(_this));
83291
+ function ClearMaskPass() {
83292
+ var _this;
83293
+
83294
+ _classCallCheck(this, ClearMaskPass);
83295
+
83296
+ _this = _super.call(this);
83297
+ _this.needsSwap = false;
83232
83298
  return _this;
83233
83299
  }
83234
83300
 
83235
- _createClass(Light, [{
83236
- key: "addToScene",
83237
- value: function addToScene() {
83238
- if (this.hasBody()) {
83239
- Scene$1.add(this.body, this);
83240
- }
83241
- }
83242
- }, {
83243
- key: "usingHelper",
83244
- value: function usingHelper() {
83245
- return !!this.isUsingHelper;
83246
- }
83247
- }, {
83248
- key: "hasHolder",
83249
- value: function hasHolder() {
83250
- return !!this.holder;
83251
- }
83252
- }, {
83253
- key: "hasTarget",
83254
- value: function hasTarget() {
83255
- return false;
83301
+ _createClass(ClearMaskPass, [{
83302
+ key: "render",
83303
+ value: function render(renderer
83304
+ /*, writeBuffer, readBuffer, deltaTime, maskActive */
83305
+ ) {
83306
+ renderer.state.buffers.stencil.setLocked(false);
83307
+ renderer.state.buffers.stencil.setTest(false);
83256
83308
  }
83257
- }, {
83258
- key: "getPosition",
83259
- value: function getPosition() {
83260
- return {
83261
- x: this.body.position.x,
83262
- y: this.body.position.y,
83263
- z: this.body.position.z
83264
- };
83309
+ }]);
83310
+
83311
+ return ClearMaskPass;
83312
+ }(Pass);var EffectComposer = /*#__PURE__*/function () {
83313
+ function EffectComposer(renderer, renderTarget) {
83314
+ var _this = this;
83315
+
83316
+ _classCallCheck(this, EffectComposer);
83317
+
83318
+ _defineProperty$1(this, "ensureLastPassIsRendered", function () {
83319
+ _this.passes.forEach(function (pass, index) {
83320
+ return pass.renderToScreen = index === _this.passes.length - 1;
83321
+ });
83322
+ });
83323
+
83324
+ this.renderer = renderer;
83325
+
83326
+ if (renderTarget === undefined) {
83327
+ var size = renderer.getSize(new Vector2());
83328
+ this._pixelRatio = renderer.getPixelRatio();
83329
+ this._width = size.width;
83330
+ this._height = size.height;
83331
+ renderTarget = new WebGLRenderTarget(this._width * this._pixelRatio, this._height * this._pixelRatio);
83332
+ renderTarget.texture.name = 'EffectComposer.rt1';
83333
+ } else {
83334
+ this._pixelRatio = 1;
83335
+ this._width = renderTarget.width;
83336
+ this._height = renderTarget.height;
83265
83337
  }
83266
- }, {
83267
- key: "setPosition",
83268
- value: function setPosition(where) {
83269
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
83270
- _ref2$updateHolder = _ref2.updateHolder,
83271
- updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
83272
83338
 
83273
- var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
83339
+ this.renderTarget1 = renderTarget;
83340
+ this.renderTarget2 = renderTarget.clone();
83341
+ this.renderTarget2.texture.name = 'EffectComposer.rt2';
83342
+ this.writeBuffer = this.renderTarget1;
83343
+ this.readBuffer = this.renderTarget2;
83344
+ this.renderToScreen = true;
83345
+ this.passes = []; // dependencies
83274
83346
 
83275
- var x = position.x,
83276
- y = position.y,
83277
- z = position.z;
83347
+ if (CopyShader === undefined) {
83348
+ console.error('THREE.EffectComposer relies on CopyShader');
83349
+ }
83278
83350
 
83279
- if (this.hasBody()) {
83280
- this.body.position.set(x, y, z);
83281
- }
83351
+ if (ShaderPass === undefined) {
83352
+ console.error('THREE.EffectComposer relies on ShaderPass');
83353
+ }
83282
83354
 
83283
- if (this.hasHolder() && updateHolder) {
83284
- this.holder.setPosition({
83285
- x: x,
83286
- y: y,
83287
- z: z
83288
- });
83289
- }
83355
+ this.copyPass = new ShaderPass(CopyShader);
83356
+ this.clock = new Clock();
83357
+ }
83358
+
83359
+ _createClass(EffectComposer, [{
83360
+ key: "swapBuffers",
83361
+ value: function swapBuffers() {
83362
+ var tmp = this.readBuffer;
83363
+ this.readBuffer = this.writeBuffer;
83364
+ this.writeBuffer = tmp;
83290
83365
  }
83291
83366
  }, {
83292
- key: "isAlreadyOn",
83293
- value: function isAlreadyOn() {
83294
- return this.hasBody() && this.body.intensity === this.intensity;
83367
+ key: "addPass",
83368
+ value: function addPass(pass) {
83369
+ this.passes.push(pass);
83370
+ pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
83295
83371
  }
83296
83372
  }, {
83297
- key: "isAlreadyOff",
83298
- value: function isAlreadyOff() {
83299
- return this.hasBody() && this.body.intensity <= 0;
83373
+ key: "insertPass",
83374
+ value: function insertPass(pass, index) {
83375
+ this.passes.splice(index, 0, pass);
83376
+ pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
83300
83377
  }
83301
83378
  }, {
83302
- key: "setIntensity",
83303
- value: function setIntensity(value) {
83304
- if (this.hasBody()) {
83305
- this.body.intensity = value;
83306
- this.intensity = value;
83379
+ key: "removePass",
83380
+ value: function removePass(pass) {
83381
+ var index = this.passes.indexOf(pass);
83382
+
83383
+ if (index !== -1) {
83384
+ this.passes.splice(index, 1);
83307
83385
  }
83308
83386
  }
83309
83387
  }, {
83310
- key: "getIntensity",
83311
- value: function getIntensity() {
83312
- if (this.hasBody()) {
83313
- return this.body.intensity;
83388
+ key: "isLastEnabledPass",
83389
+ value: function isLastEnabledPass(passIndex) {
83390
+ for (var i = passIndex + 1; i < this.passes.length; i++) {
83391
+ if (this.passes[i].enabled) {
83392
+ return false;
83393
+ }
83314
83394
  }
83395
+
83396
+ return true;
83315
83397
  }
83316
83398
  }, {
83317
- key: "setColor",
83318
- value: function setColor(color) {
83319
- this.body.color = color;
83399
+ key: "render",
83400
+ value: function render(deltaTime) {
83401
+ // deltaTime value is in seconds
83402
+ if (deltaTime === undefined) {
83403
+ deltaTime = this.clock.getDelta();
83404
+ }
83405
+
83406
+ var currentRenderTarget = this.renderer.getRenderTarget();
83407
+ var maskActive = false;
83408
+
83409
+ for (var i = 0, il = this.passes.length; i < il; i++) {
83410
+ var pass = this.passes[i];
83411
+ if (pass.enabled === false) continue;
83412
+ pass.renderToScreen = this.renderToScreen && this.isLastEnabledPass(i);
83413
+ pass.render(this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive);
83414
+
83415
+ if (pass.needsSwap) {
83416
+ if (maskActive) {
83417
+ var context = this.renderer.getContext();
83418
+ var stencil = this.renderer.state.buffers.stencil; //context.stencilFunc(context.NOTEQUAL, 1, 0xffffffff);
83419
+
83420
+ stencil.setFunc(context.NOTEQUAL, 1, 0xffffffff);
83421
+ this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, deltaTime); //context.stencilFunc(context.EQUAL, 1, 0xffffffff);
83422
+
83423
+ stencil.setFunc(context.EQUAL, 1, 0xffffffff);
83424
+ }
83425
+
83426
+ this.swapBuffers();
83427
+ }
83428
+
83429
+ if (MaskPass !== undefined) {
83430
+ if (pass instanceof MaskPass) {
83431
+ maskActive = true;
83432
+ } else if (pass instanceof ClearMaskPass) {
83433
+ maskActive = false;
83434
+ }
83435
+ }
83436
+ }
83437
+
83438
+ this.renderer.setRenderTarget(currentRenderTarget);
83320
83439
  }
83321
83440
  }, {
83322
- key: "getColor",
83323
- value: function getColor() {
83324
- return this.body.color;
83441
+ key: "reset",
83442
+ value: function reset(renderTarget) {
83443
+ if (renderTarget === undefined) {
83444
+ var size = this.renderer.getSize(new Vector2());
83445
+ this._pixelRatio = this.renderer.getPixelRatio();
83446
+ this._width = size.width;
83447
+ this._height = size.height;
83448
+ renderTarget = this.renderTarget1.clone();
83449
+ renderTarget.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
83450
+ }
83451
+
83452
+ this.renderTarget1.dispose();
83453
+ this.renderTarget2.dispose();
83454
+ this.renderTarget1 = renderTarget;
83455
+ this.renderTarget2 = renderTarget.clone();
83456
+ this.writeBuffer = this.renderTarget1;
83457
+ this.readBuffer = this.renderTarget2;
83325
83458
  }
83326
83459
  }, {
83327
- key: "setCastShadow",
83328
- value: function setCastShadow(castShadow) {
83329
- this.castShadow = castShadow;
83330
- this.getBody().castShadow = castShadow;
83460
+ key: "setSize",
83461
+ value: function setSize(width, height) {
83462
+ this._width = width;
83463
+ this._height = height;
83464
+ var effectiveWidth = this._width * this._pixelRatio;
83465
+ var effectiveHeight = this._height * this._pixelRatio;
83466
+ this.renderTarget1.setSize(effectiveWidth, effectiveHeight);
83467
+ this.renderTarget2.setSize(effectiveWidth, effectiveHeight);
83468
+
83469
+ for (var i = 0; i < this.passes.length; i++) {
83470
+ this.passes[i].setSize(effectiveWidth, effectiveHeight);
83471
+ }
83331
83472
  }
83332
83473
  }, {
83333
- key: "getCastShadow",
83334
- value: function getCastShadow() {
83335
- return this.castShadow;
83474
+ key: "setPixelRatio",
83475
+ value: function setPixelRatio(pixelRatio) {
83476
+ this._pixelRatio = pixelRatio;
83477
+ this.setSize(this._width, this._height);
83336
83478
  }
83337
- }, {
83338
- key: "dim",
83339
- value: function dim() {
83340
- var _this2 = this;
83479
+ }]);
83341
83480
 
83342
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getIntensity();
83343
- var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
83344
- var intensity = this.getIntensity();
83481
+ return EffectComposer;
83482
+ }();var RenderPass = /*#__PURE__*/function (_Pass) {
83483
+ _inherits(RenderPass, _Pass);
83345
83484
 
83346
- var onUpdate = function onUpdate(value) {
83347
- return !_this2.isDisposed() && _this2.setIntensity(value);
83348
- };
83485
+ var _super = _createSuper(RenderPass);
83349
83486
 
83350
- return tweenTo(intensity, value, {
83351
- time: time,
83352
- onUpdate: onUpdate
83353
- });
83354
- }
83355
- }, {
83356
- key: "on",
83357
- value: function on() {
83358
- var _this3 = this;
83487
+ function RenderPass(scene, camera, overrideMaterial, clearColor, clearAlpha) {
83488
+ var _this;
83359
83489
 
83360
- var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
83361
-
83362
- if (this.hasBody()) {
83363
- this.dim(this.intensity, time).then(function () {
83364
- return _this3.isLightOn = true;
83365
- });
83366
- } else {
83367
- console.log(LIGHT_NOT_FOUND);
83368
- }
83369
- }
83370
- }, {
83371
- key: "off",
83372
- value: function off() {
83373
- var _this4 = this;
83374
-
83375
- var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
83376
-
83377
- if (this.hasBody()) {
83378
- this.dim(0, time).then(function () {
83379
- return _this4.isLightOn = false;
83380
- });
83381
- } else {
83382
- console.log(LIGHT_NOT_FOUND);
83383
- }
83384
- }
83385
- }, {
83386
- key: "toJSON",
83387
- value: function toJSON() {
83388
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this)), {}, {
83389
- type: this.getEntityType(),
83390
- color: this.getColor(),
83391
- intensity: this.getIntensity(),
83392
- name: this.getName(),
83393
- castShadow: this.getCastShadow()
83394
- });
83395
- }
83396
- }]);
83397
-
83398
- return Light;
83399
- }(Entity);var DEFAULT_NEAR$2 = 0.1;
83400
- var DEFAULT_FAR$2 = 100;
83401
- var DEFAULT_FOV = 75;
83402
- var DEFAULT_POSITION$3 = {
83403
- x: 0,
83404
- y: 1,
83405
- z: 0
83406
- };
83407
- var DEFAULT_INTENSITY$4 = 0.5;
83408
- var DEFAULT_MAP_SIZE$2 = 512;
83409
- var DEFAULT_BIAS$2 = -0.0001;
83410
- var WHITE$3 = 0xffffff;
83411
-
83412
- var SunLight = /*#__PURE__*/function (_Light) {
83413
- _inherits(SunLight, _Light);
83414
-
83415
- var _super = _createSuper(SunLight);
83416
-
83417
- function SunLight() {
83418
- var _this;
83419
-
83420
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
83421
-
83422
- _classCallCheck(this, SunLight);
83423
-
83424
- var _options$color = options.color,
83425
- color = _options$color === void 0 ? WHITE$3 : _options$color,
83426
- _options$intensity = options.intensity,
83427
- intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$4 : _options$intensity,
83428
- _options$name = options.name,
83429
- name = _options$name === void 0 ? generateRandomName("SunLight") : _options$name;
83430
- _this = _super.call(this, {
83431
- color: color,
83432
- intensity: intensity,
83433
- name: name
83434
- });
83435
-
83436
- _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
83437
- var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$2;
83438
- var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$2;
83439
- _this.near = near;
83440
- _this.far = far;
83441
- var d = _this.far / 2;
83442
- _this.getBody().shadow.camera.left = -d;
83443
- _this.getBody().shadow.camera.right = d;
83444
- _this.getBody().shadow.camera.top = d;
83445
- _this.getBody().shadow.camera.bottom = -d;
83446
- _this.getBody().shadow.camera.near = near;
83447
- _this.getBody().shadow.camera.far = far;
83448
- });
83449
-
83450
- _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
83451
- var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$2;
83452
- _this.bias = bias;
83453
- _this.getBody().shadow.bias = bias;
83454
- });
83455
-
83456
- _this.options = options;
83457
- _this.target = ORIGIN;
83458
-
83459
- _this.setLight({
83460
- color: color,
83461
- intensity: intensity
83462
- });
83463
-
83464
- _this.setEntityType(ENTITY_TYPES.LIGHT.SUN);
83465
-
83466
- _this.setName(name);
83467
-
83468
- return _this;
83469
- }
83470
-
83471
- _createClass(SunLight, [{
83472
- key: "setLight",
83473
- value: function setLight(_ref) {
83474
- var light = _ref.light,
83475
- _ref$color = _ref.color,
83476
- color = _ref$color === void 0 ? WHITE$3 : _ref$color,
83477
- _ref$intensity = _ref.intensity,
83478
- intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$4 : _ref$intensity;
83479
-
83480
- if (light) {
83481
- this.setBody({
83482
- body: light
83483
- });
83484
- } else {
83485
- this.setBody({
83486
- body: new DirectionalLight(color, intensity)
83487
- });
83488
- }
83489
-
83490
- if (this.hasBody()) {
83491
- this.postLightCreation();
83492
- }
83493
- }
83494
- }, {
83495
- key: "postLightCreation",
83496
- value: function postLightCreation() {
83497
- var _this$options$positio = this.options.position,
83498
- position = _this$options$positio === void 0 ? DEFAULT_POSITION$3 : _this$options$positio;
83499
- var emptyTarget = new Element$1({
83500
- body: new Object3D()
83501
- });
83502
- this.setPosition(position);
83503
- this.setTarget(emptyTarget);
83504
- this.setLightShadows();
83505
- this.addToScene();
83506
- }
83507
- }, {
83508
- key: "setLightShadows",
83509
- value: function setLightShadows() {
83510
- var _this$options = this.options,
83511
- _this$options$near = _this$options.near,
83512
- near = _this$options$near === void 0 ? DEFAULT_NEAR$2 : _this$options$near,
83513
- _this$options$far = _this$options.far,
83514
- far = _this$options$far === void 0 ? DEFAULT_FAR$2 : _this$options$far,
83515
- _this$options$mapSize = _this$options.mapSize,
83516
- mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE$2 : _this$options$mapSize,
83517
- _this$options$bias = _this$options.bias,
83518
- bias = _this$options$bias === void 0 ? DEFAULT_BIAS$2 : _this$options$bias,
83519
- _this$options$fov = _this$options.fov,
83520
- fov = _this$options$fov === void 0 ? DEFAULT_FOV : _this$options$fov;
83521
-
83522
- if (Config$1.lights().shadows) {
83523
- this.setCastShadow(true);
83524
- this.setMapSize(mapSize);
83525
- this.setShadowCameraNearFar(near, far);
83526
- this.setBias(bias);
83527
- this.setShadowCameraFov(fov);
83528
- }
83529
- }
83530
- }, {
83531
- key: "getShadowCameraNearFar",
83532
- value: function getShadowCameraNearFar() {
83533
- return {
83534
- near: this.near,
83535
- far: this.far
83536
- };
83537
- }
83538
- }, {
83539
- key: "setShadowCameraFov",
83540
- value: function setShadowCameraFov() {
83541
- var fov = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_FOV;
83542
- this.fov = fov;
83543
- this.getBody().shadow.camera.fov = fov;
83544
- }
83545
- }, {
83546
- key: "getShadowCameraFov",
83547
- value: function getShadowCameraFov() {
83548
- return this.fov;
83549
- }
83550
- }, {
83551
- key: "setMapSize",
83552
- value: function setMapSize() {
83553
- var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$2;
83554
- this.mapSize = mapSize;
83555
- this.getBody().shadow.mapSize.height = mapSize;
83556
- this.getBody().shadow.mapSize.width = mapSize;
83557
- }
83558
- }, {
83559
- key: "getMapSize",
83560
- value: function getMapSize() {
83561
- return this.mapSize;
83562
- }
83563
- }, {
83564
- key: "getBias",
83565
- value: function getBias() {
83566
- return this.bias;
83567
- }
83568
- }, {
83569
- key: "hasTarget",
83570
- value: function hasTarget() {
83571
- return true;
83572
- }
83573
- }, {
83574
- key: "setTarget",
83575
- value: function setTarget(target) {
83576
- this.target = target;
83577
- this.getBody().target = target.getBody();
83578
- Scene$1.add(this.getBody().target, null, false);
83579
- }
83580
- }, {
83581
- key: "getTarget",
83582
- value: function getTarget() {
83583
- return this.target;
83584
- }
83585
- }, {
83586
- key: "addHelpers",
83587
- value: function addHelpers() {
83588
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
83589
- _ref2$holderName = _ref2.holderName,
83590
- holderName = _ref2$holderName === void 0 ? "sunlightholder" : _ref2$holderName,
83591
- _ref2$holderSize = _ref2.holderSize,
83592
- holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize,
83593
- _ref2$targetHolderNam = _ref2.targetHolderName,
83594
- targetHolderName = _ref2$targetHolderNam === void 0 ? "targetholder" : _ref2$targetHolderNam,
83595
- _ref2$targetHolderSiz = _ref2.targetHolderSize,
83596
- targetHolderSize = _ref2$targetHolderSiz === void 0 ? 0.05 : _ref2$targetHolderSiz;
83597
-
83598
- this.helper = new DirectionalLightHelper(this.getBody(), 5);
83599
- this.shadowHelper = new CameraHelper(this.getBody().shadow.camera);
83600
- Scene$1.add(this.helper, null, false);
83601
- Scene$1.add(this.shadowHelper, null, false);
83602
- this.addHolder(holderName, holderSize);
83603
- this.addTargetHolder(targetHolderName, targetHolderSize);
83604
- this.isUsingHelper = true;
83605
- }
83606
- }, {
83607
- key: "update",
83608
- value: function update(dt) {
83609
- _get(_getPrototypeOf(SunLight.prototype), "update", this).call(this, dt);
83610
-
83611
- if (this.usingHelper()) {
83612
- this.helper.update();
83613
- this.shadowHelper.update();
83614
- }
83615
-
83616
- if (this.hasHolder()) {
83617
- this.setPosition(this.holder.getPosition(), {
83618
- updateHolder: false
83619
- });
83620
- }
83621
- }
83622
- }, {
83623
- key: "toJSON",
83624
- value: function toJSON() {
83625
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this)), {}, {
83626
- target: this.getTarget(),
83627
- bias: this.getBias(),
83628
- mapSize: this.getMapSize(),
83629
- shadowCamera: _objectSpread2$1(_objectSpread2$1({}, this.getShadowCameraNearFar()), {}, {
83630
- fov: this.setShadowCameraFov()
83631
- })
83632
- });
83633
- }
83634
- }]);
83635
-
83636
- return SunLight;
83637
- }(Light$1);var DEFAULT_POSITION$2 = {
83638
- x: 0,
83639
- y: 0,
83640
- z: 0
83641
- };
83642
- var DEFAULT_INTENSITY$3 = 0.5;
83643
- var WHITE$2 = 0xffffff;
83644
-
83645
- var AmbientLight = /*#__PURE__*/function (_Light) {
83646
- _inherits(AmbientLight, _Light);
83647
-
83648
- var _super = _createSuper(AmbientLight);
83649
-
83650
- function AmbientLight() {
83651
- var _this;
83652
-
83653
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
83654
-
83655
- _classCallCheck(this, AmbientLight);
83656
-
83657
- var _options$color = options.color,
83658
- color = _options$color === void 0 ? WHITE$2 : _options$color,
83659
- _options$intensity = options.intensity,
83660
- intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$3 : _options$intensity,
83661
- _options$name = options.name,
83662
- name = _options$name === void 0 ? generateRandomName("AmbientLight") : _options$name;
83663
- _this = _super.call(this, {
83664
- color: color,
83665
- intensity: intensity,
83666
- name: name
83667
- });
83668
- _this.options = options;
83669
-
83670
- _this.setLight({
83671
- color: color,
83672
- intensity: intensity
83673
- });
83674
-
83675
- _this.setEntityType(ENTITY_TYPES.LIGHT.AMBIENT);
83676
-
83677
- _this.setName(name);
83678
-
83679
- return _this;
83680
- }
83681
-
83682
- _createClass(AmbientLight, [{
83683
- key: "setLight",
83684
- value: function setLight(_ref) {
83685
- var light = _ref.light,
83686
- _ref$color = _ref.color,
83687
- color = _ref$color === void 0 ? WHITE$2 : _ref$color,
83688
- _ref$intensity = _ref.intensity,
83689
- intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$3 : _ref$intensity;
83690
-
83691
- if (light) {
83692
- this.setBody({
83693
- body: light
83694
- });
83695
- } else {
83696
- this.setBody({
83697
- body: new AmbientLight$1(color, intensity)
83698
- });
83699
- }
83700
-
83701
- if (this.hasBody()) {
83702
- this.postLightCreation();
83703
- }
83704
- }
83705
- }, {
83706
- key: "postLightCreation",
83707
- value: function postLightCreation() {
83708
- var _this$options$positio = this.options.position,
83709
- position = _this$options$positio === void 0 ? DEFAULT_POSITION$2 : _this$options$positio;
83710
- this.setPosition(position);
83711
- this.addToScene();
83712
- }
83713
- }, {
83714
- key: "addHelpers",
83715
- value: function addHelpers() {
83716
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
83717
- _ref2$holderName = _ref2.holderName,
83718
- holderName = _ref2$holderName === void 0 ? "ambientlightholder" : _ref2$holderName,
83719
- _ref2$holderSize = _ref2.holderSize,
83720
- holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize;
83721
-
83722
- this.addHolder(holderName, holderSize);
83723
- this.isUsingHelper = true;
83724
- }
83725
- }, {
83726
- key: "update",
83727
- value: function update(dt) {
83728
- _get(_getPrototypeOf(AmbientLight.prototype), "update", this).call(this, dt);
83729
-
83730
- if (this.usingHelper()) {
83731
- this.setPosition(this.holder.getPosition(), {
83732
- updateHolder: false
83733
- });
83734
- }
83735
- }
83736
- }]);
83737
-
83738
- return AmbientLight;
83739
- }(Light$1);var DEFAULT_NEAR$1 = 0.1;
83740
- var DEFAULT_FAR$1 = 100;
83741
- var DEFAULT_POSITION$1 = {
83742
- x: 0,
83743
- y: 0,
83744
- z: 0
83745
- };
83746
- var DEFAULT_INTENSITY$2 = 0.5;
83747
- var DEFAULT_DISTANCE = 0;
83748
- var DEFAULT_DECAY = 1;
83749
- var DEFAULT_MAP_SIZE$1 = 2048;
83750
- var DEFAULT_BIAS$1 = -0.0001;
83751
- var WHITE$1 = 0xffffff;
83752
- var GREEN$2 = 0x2ecc71;
83753
-
83754
- var PointLight = /*#__PURE__*/function (_Light) {
83755
- _inherits(PointLight, _Light);
83756
-
83757
- var _super = _createSuper(PointLight);
83758
-
83759
- function PointLight() {
83760
- var _this;
83761
-
83762
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
83763
-
83764
- _classCallCheck(this, PointLight);
83765
-
83766
- var _options$color = options.color,
83767
- color = _options$color === void 0 ? WHITE$1 : _options$color,
83768
- _options$intensity = options.intensity,
83769
- intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$2 : _options$intensity,
83770
- _options$name = options.name,
83771
- name = _options$name === void 0 ? generateRandomName("PointLight") : _options$name,
83772
- distance = options.distance,
83773
- decay = options.decay;
83774
- _this = _super.call(this, {
83775
- color: color,
83776
- intensity: intensity,
83777
- name: name
83778
- });
83779
-
83780
- _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
83781
- var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$1;
83782
- var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$1;
83783
- _this.near = near;
83784
- _this.far = far;
83785
- var d = _this.far / 2;
83786
- _this.getBody().shadow.camera.left = -d;
83787
- _this.getBody().shadow.camera.right = d;
83788
- _this.getBody().shadow.camera.top = d;
83789
- _this.getBody().shadow.camera.bottom = -d;
83790
- _this.getBody().shadow.camera.near = near;
83791
- _this.getBody().shadow.camera.far = far;
83792
- });
83793
-
83794
- _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
83795
- var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$1;
83796
- _this.bias = bias;
83797
- _this.getBody().shadow.bias = bias;
83798
- });
83799
-
83800
- _this.options = options;
83801
-
83802
- _this.setLight({
83803
- color: color,
83804
- intensity: intensity,
83805
- distance: distance,
83806
- decay: decay
83807
- });
83808
-
83809
- _this.setEntityType(ENTITY_TYPES.LIGHT.POINT);
83810
-
83811
- _this.setName(name);
83812
-
83813
- return _this;
83814
- }
83815
-
83816
- _createClass(PointLight, [{
83817
- key: "setLight",
83818
- value: function setLight(_ref) {
83819
- var light = _ref.light,
83820
- _ref$color = _ref.color,
83821
- color = _ref$color === void 0 ? WHITE$1 : _ref$color,
83822
- _ref$intensity = _ref.intensity,
83823
- intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$2 : _ref$intensity,
83824
- _ref$distance = _ref.distance,
83825
- distance = _ref$distance === void 0 ? DEFAULT_DISTANCE : _ref$distance,
83826
- _ref$decay = _ref.decay,
83827
- decay = _ref$decay === void 0 ? DEFAULT_DECAY : _ref$decay;
83828
-
83829
- if (light) {
83830
- this.setBody({
83831
- body: light
83832
- });
83833
- } else {
83834
- this.setBody({
83835
- body: new PointLight$1(color, intensity)
83836
- });
83837
- this.setDistance(distance);
83838
- this.setDecay(decay);
83839
- }
83840
-
83841
- if (this.hasBody()) {
83842
- this.postLightCreation();
83843
- }
83844
- }
83845
- }, {
83846
- key: "postLightCreation",
83847
- value: function postLightCreation() {
83848
- var _this$options$positio = this.options.position,
83849
- position = _this$options$positio === void 0 ? DEFAULT_POSITION$1 : _this$options$positio;
83850
- this.setPosition(position);
83851
- this.setLightShadows();
83852
- this.addToScene();
83853
- }
83854
- }, {
83855
- key: "setLightShadows",
83856
- value: function setLightShadows() {
83857
- var _this$options = this.options,
83858
- _this$options$near = _this$options.near,
83859
- near = _this$options$near === void 0 ? DEFAULT_NEAR$1 : _this$options$near,
83860
- _this$options$far = _this$options.far,
83861
- far = _this$options$far === void 0 ? DEFAULT_FAR$1 : _this$options$far,
83862
- _this$options$mapSize = _this$options.mapSize,
83863
- mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE$1 : _this$options$mapSize,
83864
- _this$options$bias = _this$options.bias,
83865
- bias = _this$options$bias === void 0 ? DEFAULT_BIAS$1 : _this$options$bias;
83866
-
83867
- if (Config$1.lights().shadows) {
83868
- this.setCastShadow(true);
83869
- this.setMapSize(mapSize);
83870
- this.setShadowCameraNearFar(near, far);
83871
- this.setBias(bias);
83872
- }
83873
- }
83874
- }, {
83875
- key: "setDistance",
83876
- value: function setDistance() {
83877
- var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISTANCE;
83878
- this.distance = distance;
83879
- this.getBody().distance = distance;
83880
- }
83881
- }, {
83882
- key: "getDistance",
83883
- value: function getDistance() {
83884
- return this.distance;
83885
- }
83886
- }, {
83887
- key: "setDecay",
83888
- value: function setDecay() {
83889
- var decay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DECAY;
83890
- this.decay = decay;
83891
- this.getBody().decay = decay;
83892
- }
83893
- }, {
83894
- key: "getDecay",
83895
- value: function getDecay() {
83896
- return this.decay;
83897
- }
83898
- }, {
83899
- key: "getShadowCameraNearFar",
83900
- value: function getShadowCameraNearFar() {
83901
- return {
83902
- near: this.near,
83903
- far: this.far
83904
- };
83905
- }
83906
- }, {
83907
- key: "setMapSize",
83908
- value: function setMapSize() {
83909
- var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$1;
83910
- this.mapSize = mapSize;
83911
- this.getBody().shadow.mapSize.height = mapSize;
83912
- this.getBody().shadow.mapSize.width = mapSize;
83913
- }
83914
- }, {
83915
- key: "getMapSize",
83916
- value: function getMapSize() {
83917
- return this.mapSize;
83918
- }
83919
- }, {
83920
- key: "getBias",
83921
- value: function getBias() {
83922
- return this.bias;
83923
- }
83924
- }, {
83925
- key: "addHelpers",
83926
- value: function addHelpers() {
83927
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
83928
- _ref2$holderName = _ref2.holderName,
83929
- holderName = _ref2$holderName === void 0 ? "pointlightholder" : _ref2$holderName,
83930
- _ref2$holderSize = _ref2.holderSize,
83931
- holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize;
83932
-
83933
- this.helper = new PointLightHelper(this.getBody(), 2, GREEN$2);
83934
- this.shadowHelper = new CameraHelper(this.getBody().shadow.camera);
83935
- Scene$1.add(this.helper, null, false);
83936
- Scene$1.add(this.shadowHelper, null, false);
83937
- this.addHolder(holderName, holderSize);
83938
- this.isUsingHelper = true;
83939
- }
83940
- }, {
83941
- key: "update",
83942
- value: function update(dt) {
83943
- _get(_getPrototypeOf(PointLight.prototype), "update", this).call(this, dt);
83944
-
83945
- if (this.usingHelper()) {
83946
- this.helper.update();
83947
- this.shadowHelper.update();
83948
- }
83949
-
83950
- if (this.hasHolder()) {
83951
- this.setPosition(this.holder.getPosition(), {
83952
- updateHolder: false
83953
- });
83954
- }
83955
- }
83956
- }, {
83957
- key: "toJSON",
83958
- value: function toJSON() {
83959
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(PointLight.prototype), "toJSON", this).call(this)), {}, {
83960
- distance: this.getDistance(),
83961
- decay: this.getDecay(),
83962
- bias: this.getBias(),
83963
- mapSize: this.getMapSize(),
83964
- shadowCamera: this.getShadowCameraNearFar()
83965
- });
83966
- }
83967
- }]);
83968
-
83969
- return PointLight;
83970
- }(Light$1);var LightLoader = /*#__PURE__*/function (_Loader) {
83971
- _inherits(LightLoader, _Loader);
83972
-
83973
- var _super = _createSuper(LightLoader);
83974
-
83975
- function LightLoader() {
83976
- var _this;
83977
-
83978
- _classCallCheck(this, LightLoader);
83979
-
83980
- _this = _super.call(this);
83981
-
83982
- _defineProperty$1(_assertThisInitialized(_this), "createLight", function (useHelper) {
83983
- return function (l) {
83984
- var light;
83985
-
83986
- switch (l.type) {
83987
- case SUNLIGHT:
83988
- light = _this.createSunlight(l);
83989
- break;
83990
-
83991
- case POINTLIGHT:
83992
- light = _this.createPointlight(l);
83993
- break;
83994
-
83995
- case AMBIENTLIGHT:
83996
- light = _this.createAmbientLight(l);
83997
- break;
83998
- }
83999
-
84000
- if (light && useHelper) {
84001
- light.addHelpers();
84002
- }
84003
- };
84004
- });
84005
-
84006
- return _this;
84007
- }
84008
-
84009
- _createClass(LightLoader, [{
84010
- key: "load",
84011
- value: function load(lights, _ref) {
84012
- var _ref$useHelper = _ref.useHelper,
84013
- useHelper = _ref$useHelper === void 0 ? false : _ref$useHelper;
84014
- lights.forEach(this.createLight(useHelper));
84015
- }
84016
- }, {
84017
- key: "createSunlight",
84018
- value: function createSunlight(_ref2) {
84019
- var color = _ref2.color,
84020
- intensity = _ref2.intensity,
84021
- position = _ref2.position,
84022
- target = _ref2.target,
84023
- name = _ref2.name;
84024
- return new SunLight({
84025
- color: color,
84026
- intensity: intensity,
84027
- position: position,
84028
- target: target,
84029
- name: name
84030
- });
84031
- }
84032
- }, {
84033
- key: "createAmbientLight",
84034
- value: function createAmbientLight(_ref3) {
84035
- var color = _ref3.color,
84036
- intensity = _ref3.intensity,
84037
- position = _ref3.position,
84038
- name = _ref3.name;
84039
- return new AmbientLight({
84040
- color: color,
84041
- intensity: intensity,
84042
- position: position,
84043
- name: name
84044
- });
84045
- }
84046
- }, {
84047
- key: "createPointlight",
84048
- value: function createPointlight(_ref4) {
84049
- var color = _ref4.color,
84050
- intensity = _ref4.intensity,
84051
- position = _ref4.position,
84052
- distance = _ref4.distance,
84053
- name = _ref4.name;
84054
- return new PointLight({
84055
- color: color,
84056
- intensity: intensity,
84057
- position: position,
84058
- distance: distance,
84059
- name: name
84060
- });
84061
- }
84062
- }]);
84063
-
84064
- return LightLoader;
84065
- }(Loader);
84066
- var LightLoader$1 = new LightLoader();var Pass = /*#__PURE__*/function () {
84067
- function Pass() {
84068
- _classCallCheck(this, Pass);
84069
-
84070
- // if set to true, the pass is processed by the composer
84071
- this.enabled = true; // if set to true, the pass indicates to swap read and write buffer after rendering
84072
-
84073
- this.needsSwap = true; // if set to true, the pass clears its buffer before rendering
84074
-
84075
- this.clear = false; // if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
84076
-
84077
- this.renderToScreen = false;
84078
- this.isPass = true;
84079
- }
84080
-
84081
- _createClass(Pass, [{
84082
- key: "setSize",
84083
- value: function setSize() {}
84084
- }, {
84085
- key: "render",
84086
- value: function render() {
84087
- console.error('THREE.Pass: .render() must be implemented in derived pass.');
84088
- }
84089
- }]);
84090
-
84091
- return Pass;
84092
- }(); // Helper for passes that need to fill the viewport with a single quad.
84093
-
84094
- var _camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1); // https://github.com/mrdoob/three.js/pull/21358
84095
-
84096
-
84097
- var _geometry = new BufferGeometry();
84098
-
84099
- _geometry.setAttribute('position', new Float32BufferAttribute([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3));
84100
-
84101
- _geometry.setAttribute('uv', new Float32BufferAttribute([0, 2, 0, 0, 2, 0], 2));
84102
-
84103
- var FullScreenQuad = /*#__PURE__*/function () {
84104
- function FullScreenQuad(material) {
84105
- _classCallCheck(this, FullScreenQuad);
84106
-
84107
- this._mesh = new Mesh(_geometry, material);
84108
- }
84109
-
84110
- _createClass(FullScreenQuad, [{
84111
- key: "dispose",
84112
- value: function dispose() {
84113
- this._mesh.geometry.dispose();
84114
- }
84115
- }, {
84116
- key: "render",
84117
- value: function render(renderer) {
84118
- renderer.render(this._mesh, _camera);
84119
- }
84120
- }, {
84121
- key: "material",
84122
- get: function get() {
84123
- return this._mesh.material;
84124
- },
84125
- set: function set(value) {
84126
- this._mesh.material = value;
84127
- }
84128
- }]);
84129
-
84130
- return FullScreenQuad;
84131
- }();var ShaderPass = /*#__PURE__*/function (_Pass) {
84132
- _inherits(ShaderPass, _Pass);
84133
-
84134
- var _super = _createSuper(ShaderPass);
84135
-
84136
- function ShaderPass(shader, textureID) {
84137
- var _this;
84138
-
84139
- _classCallCheck(this, ShaderPass);
84140
-
84141
- _this = _super.call(this);
84142
- _this.textureID = textureID !== undefined ? textureID : 'tDiffuse';
84143
-
84144
- if (shader instanceof ShaderMaterial) {
84145
- _this.uniforms = shader.uniforms;
84146
- _this.material = shader;
84147
- } else if (shader) {
84148
- _this.uniforms = UniformsUtils.clone(shader.uniforms);
84149
- _this.material = new ShaderMaterial({
84150
- defines: Object.assign({}, shader.defines),
84151
- uniforms: _this.uniforms,
84152
- vertexShader: shader.vertexShader,
84153
- fragmentShader: shader.fragmentShader
84154
- });
84155
- }
84156
-
84157
- _this.fsQuad = new FullScreenQuad(_this.material);
84158
- return _this;
84159
- }
84160
-
84161
- _createClass(ShaderPass, [{
84162
- key: "render",
84163
- value: function render(renderer, writeBuffer, readBuffer
84164
- /*, deltaTime, maskActive */
84165
- ) {
84166
- if (this.uniforms[this.textureID]) {
84167
- this.uniforms[this.textureID].value = readBuffer.texture;
84168
- }
84169
-
84170
- this.fsQuad.material = this.material;
84171
-
84172
- if (this.renderToScreen) {
84173
- renderer.setRenderTarget(null);
84174
- this.fsQuad.render(renderer);
84175
- } else {
84176
- renderer.setRenderTarget(writeBuffer); // TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
84177
-
84178
- if (this.clear) renderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);
84179
- this.fsQuad.render(renderer);
84180
- }
84181
- }
84182
- }]);
84183
-
84184
- return ShaderPass;
84185
- }(Pass);/**
84186
- * Full-screen textured quad shader
84187
- */
84188
- var CopyShader = {
84189
- uniforms: {
84190
- 'tDiffuse': {
84191
- value: null
84192
- },
84193
- 'opacity': {
84194
- value: 1.0
84195
- }
84196
- },
84197
- vertexShader:
84198
- /* glsl */
84199
- "\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
84200
- fragmentShader:
84201
- /* glsl */
84202
- "\n\n uniform float opacity;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n gl_FragColor.a *= opacity;\n }"
84203
- };var MaskPass = /*#__PURE__*/function (_Pass) {
84204
- _inherits(MaskPass, _Pass);
84205
-
84206
- var _super = _createSuper(MaskPass);
84207
-
84208
- function MaskPass(scene, camera) {
84209
- var _this;
84210
-
84211
- _classCallCheck(this, MaskPass);
84212
-
84213
- _this = _super.call(this);
84214
- _this.scene = scene;
84215
- _this.camera = camera;
84216
- _this.clear = true;
84217
- _this.needsSwap = false;
84218
- _this.inverse = false;
84219
- return _this;
84220
- }
84221
-
84222
- _createClass(MaskPass, [{
84223
- key: "render",
84224
- value: function render(renderer, writeBuffer, readBuffer
84225
- /*, deltaTime, maskActive */
84226
- ) {
84227
- var context = renderer.getContext();
84228
- var state = renderer.state; // don't update color or depth
84229
-
84230
- state.buffers.color.setMask(false);
84231
- state.buffers.depth.setMask(false); // lock buffers
84232
-
84233
- state.buffers.color.setLocked(true);
84234
- state.buffers.depth.setLocked(true); // set up stencil
84235
-
84236
- var writeValue, clearValue;
84237
-
84238
- if (this.inverse) {
84239
- writeValue = 0;
84240
- clearValue = 1;
84241
- } else {
84242
- writeValue = 1;
84243
- clearValue = 0;
84244
- }
84245
-
84246
- state.buffers.stencil.setTest(true);
84247
- state.buffers.stencil.setOp(context.REPLACE, context.REPLACE, context.REPLACE);
84248
- state.buffers.stencil.setFunc(context.ALWAYS, writeValue, 0xffffffff);
84249
- state.buffers.stencil.setClear(clearValue);
84250
- state.buffers.stencil.setLocked(true); // draw into the stencil buffer
84251
-
84252
- renderer.setRenderTarget(readBuffer);
84253
- if (this.clear) renderer.clear();
84254
- renderer.render(this.scene, this.camera);
84255
- renderer.setRenderTarget(writeBuffer);
84256
- if (this.clear) renderer.clear();
84257
- renderer.render(this.scene, this.camera); // unlock color and depth buffer for subsequent rendering
84258
-
84259
- state.buffers.color.setLocked(false);
84260
- state.buffers.depth.setLocked(false); // only render where stencil is set to 1
84261
-
84262
- state.buffers.stencil.setLocked(false);
84263
- state.buffers.stencil.setFunc(context.EQUAL, 1, 0xffffffff); // draw if == 1
84264
-
84265
- state.buffers.stencil.setOp(context.KEEP, context.KEEP, context.KEEP);
84266
- state.buffers.stencil.setLocked(true);
84267
- }
84268
- }]);
84269
-
84270
- return MaskPass;
84271
- }(Pass);var ClearMaskPass = /*#__PURE__*/function (_Pass) {
84272
- _inherits(ClearMaskPass, _Pass);
84273
-
84274
- var _super = _createSuper(ClearMaskPass);
84275
-
84276
- function ClearMaskPass() {
84277
- var _this;
84278
-
84279
- _classCallCheck(this, ClearMaskPass);
84280
-
84281
- _this = _super.call(this);
84282
- _this.needsSwap = false;
84283
- return _this;
84284
- }
84285
-
84286
- _createClass(ClearMaskPass, [{
84287
- key: "render",
84288
- value: function render(renderer
84289
- /*, writeBuffer, readBuffer, deltaTime, maskActive */
84290
- ) {
84291
- renderer.state.buffers.stencil.setLocked(false);
84292
- renderer.state.buffers.stencil.setTest(false);
84293
- }
84294
- }]);
84295
-
84296
- return ClearMaskPass;
84297
- }(Pass);var EffectComposer = /*#__PURE__*/function () {
84298
- function EffectComposer(renderer, renderTarget) {
84299
- var _this = this;
84300
-
84301
- _classCallCheck(this, EffectComposer);
84302
-
84303
- _defineProperty$1(this, "ensureLastPassIsRendered", function () {
84304
- _this.passes.forEach(function (pass, index) {
84305
- return pass.renderToScreen = index === _this.passes.length - 1;
84306
- });
84307
- });
84308
-
84309
- this.renderer = renderer;
84310
-
84311
- if (renderTarget === undefined) {
84312
- var size = renderer.getSize(new Vector2());
84313
- this._pixelRatio = renderer.getPixelRatio();
84314
- this._width = size.width;
84315
- this._height = size.height;
84316
- renderTarget = new WebGLRenderTarget(this._width * this._pixelRatio, this._height * this._pixelRatio);
84317
- renderTarget.texture.name = 'EffectComposer.rt1';
84318
- } else {
84319
- this._pixelRatio = 1;
84320
- this._width = renderTarget.width;
84321
- this._height = renderTarget.height;
84322
- }
84323
-
84324
- this.renderTarget1 = renderTarget;
84325
- this.renderTarget2 = renderTarget.clone();
84326
- this.renderTarget2.texture.name = 'EffectComposer.rt2';
84327
- this.writeBuffer = this.renderTarget1;
84328
- this.readBuffer = this.renderTarget2;
84329
- this.renderToScreen = true;
84330
- this.passes = []; // dependencies
84331
-
84332
- if (CopyShader === undefined) {
84333
- console.error('THREE.EffectComposer relies on CopyShader');
84334
- }
84335
-
84336
- if (ShaderPass === undefined) {
84337
- console.error('THREE.EffectComposer relies on ShaderPass');
84338
- }
84339
-
84340
- this.copyPass = new ShaderPass(CopyShader);
84341
- this.clock = new Clock();
84342
- }
84343
-
84344
- _createClass(EffectComposer, [{
84345
- key: "swapBuffers",
84346
- value: function swapBuffers() {
84347
- var tmp = this.readBuffer;
84348
- this.readBuffer = this.writeBuffer;
84349
- this.writeBuffer = tmp;
84350
- }
84351
- }, {
84352
- key: "addPass",
84353
- value: function addPass(pass) {
84354
- this.passes.push(pass);
84355
- pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
84356
- }
84357
- }, {
84358
- key: "insertPass",
84359
- value: function insertPass(pass, index) {
84360
- this.passes.splice(index, 0, pass);
84361
- pass.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
84362
- }
84363
- }, {
84364
- key: "removePass",
84365
- value: function removePass(pass) {
84366
- var index = this.passes.indexOf(pass);
84367
-
84368
- if (index !== -1) {
84369
- this.passes.splice(index, 1);
84370
- }
84371
- }
84372
- }, {
84373
- key: "isLastEnabledPass",
84374
- value: function isLastEnabledPass(passIndex) {
84375
- for (var i = passIndex + 1; i < this.passes.length; i++) {
84376
- if (this.passes[i].enabled) {
84377
- return false;
84378
- }
84379
- }
84380
-
84381
- return true;
84382
- }
84383
- }, {
84384
- key: "render",
84385
- value: function render(deltaTime) {
84386
- // deltaTime value is in seconds
84387
- if (deltaTime === undefined) {
84388
- deltaTime = this.clock.getDelta();
84389
- }
84390
-
84391
- var currentRenderTarget = this.renderer.getRenderTarget();
84392
- var maskActive = false;
84393
-
84394
- for (var i = 0, il = this.passes.length; i < il; i++) {
84395
- var pass = this.passes[i];
84396
- if (pass.enabled === false) continue;
84397
- pass.renderToScreen = this.renderToScreen && this.isLastEnabledPass(i);
84398
- pass.render(this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive);
84399
-
84400
- if (pass.needsSwap) {
84401
- if (maskActive) {
84402
- var context = this.renderer.getContext();
84403
- var stencil = this.renderer.state.buffers.stencil; //context.stencilFunc(context.NOTEQUAL, 1, 0xffffffff);
84404
-
84405
- stencil.setFunc(context.NOTEQUAL, 1, 0xffffffff);
84406
- this.copyPass.render(this.renderer, this.writeBuffer, this.readBuffer, deltaTime); //context.stencilFunc(context.EQUAL, 1, 0xffffffff);
84407
-
84408
- stencil.setFunc(context.EQUAL, 1, 0xffffffff);
84409
- }
84410
-
84411
- this.swapBuffers();
84412
- }
84413
-
84414
- if (MaskPass !== undefined) {
84415
- if (pass instanceof MaskPass) {
84416
- maskActive = true;
84417
- } else if (pass instanceof ClearMaskPass) {
84418
- maskActive = false;
84419
- }
84420
- }
84421
- }
84422
-
84423
- this.renderer.setRenderTarget(currentRenderTarget);
84424
- }
84425
- }, {
84426
- key: "reset",
84427
- value: function reset(renderTarget) {
84428
- if (renderTarget === undefined) {
84429
- var size = this.renderer.getSize(new Vector2());
84430
- this._pixelRatio = this.renderer.getPixelRatio();
84431
- this._width = size.width;
84432
- this._height = size.height;
84433
- renderTarget = this.renderTarget1.clone();
84434
- renderTarget.setSize(this._width * this._pixelRatio, this._height * this._pixelRatio);
84435
- }
84436
-
84437
- this.renderTarget1.dispose();
84438
- this.renderTarget2.dispose();
84439
- this.renderTarget1 = renderTarget;
84440
- this.renderTarget2 = renderTarget.clone();
84441
- this.writeBuffer = this.renderTarget1;
84442
- this.readBuffer = this.renderTarget2;
84443
- }
84444
- }, {
84445
- key: "setSize",
84446
- value: function setSize(width, height) {
84447
- this._width = width;
84448
- this._height = height;
84449
- var effectiveWidth = this._width * this._pixelRatio;
84450
- var effectiveHeight = this._height * this._pixelRatio;
84451
- this.renderTarget1.setSize(effectiveWidth, effectiveHeight);
84452
- this.renderTarget2.setSize(effectiveWidth, effectiveHeight);
84453
-
84454
- for (var i = 0; i < this.passes.length; i++) {
84455
- this.passes[i].setSize(effectiveWidth, effectiveHeight);
84456
- }
84457
- }
84458
- }, {
84459
- key: "setPixelRatio",
84460
- value: function setPixelRatio(pixelRatio) {
84461
- this._pixelRatio = pixelRatio;
84462
- this.setSize(this._width, this._height);
84463
- }
84464
- }]);
84465
-
84466
- return EffectComposer;
84467
- }();var RenderPass = /*#__PURE__*/function (_Pass) {
84468
- _inherits(RenderPass, _Pass);
84469
-
84470
- var _super = _createSuper(RenderPass);
84471
-
84472
- function RenderPass(scene, camera, overrideMaterial, clearColor, clearAlpha) {
84473
- var _this;
84474
-
84475
- _classCallCheck(this, RenderPass);
83490
+ _classCallCheck(this, RenderPass);
84476
83491
 
84477
83492
  _this = _super.call(this);
84478
83493
  _this.scene = scene;
@@ -90419,9 +89434,9 @@ var Controls = /*#__PURE__*/function () {
90419
89434
  return Controls;
90420
89435
  }();
90421
89436
  var Controls$1 = new Controls();var author = {
90422
- name: 'Marco Stagni',
90423
- email: 'mrc.stagni@gmail.com',
90424
- website: 'http://mage.studio'
89437
+ name: "Marco Stagni",
89438
+ email: "mrc.stagni@gmail.com",
89439
+ website: "http://mage.studio"
90425
89440
  };
90426
89441
  var Level = /*#__PURE__*/function (_EventDispatcher) {
90427
89442
  _inherits(Level, _EventDispatcher);
@@ -90437,30 +89452,23 @@ var Level = /*#__PURE__*/function (_EventDispatcher) {
90437
89452
 
90438
89453
  _defineProperty$1(_assertThisInitialized(_this), "onStateChange", function (state) {});
90439
89454
 
90440
- _defineProperty$1(_assertThisInitialized(_this), "parseScene", function (_ref) {
90441
- var _ref$elements = _ref.elements,
90442
- elements = _ref$elements === void 0 ? [] : _ref$elements,
90443
- _ref$models = _ref.models,
90444
- models = _ref$models === void 0 ? [] : _ref$models,
90445
- _ref$lights = _ref.lights,
90446
- lights = _ref$lights === void 0 ? [] : _ref$lights;
90447
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
90448
- return new Promise(function (resolve, reject) {
90449
- if (elements.length) {
90450
- for (var i in models) {
90451
- elements.push(models[i]);
90452
- }
90453
-
90454
- MeshLoader$1.load(elements, options);
90455
- }
90456
-
90457
- if (lights.length) {
90458
- LightLoader$1.load(lights, options);
90459
- }
90460
-
90461
- Scene$1.updateChildren();
90462
- resolve();
90463
- });
89455
+ _defineProperty$1(_assertThisInitialized(_this), "parseScene", function (_ref) {// return new Promise((resolve, reject) => {
89456
+ // if (elements.length) {
89457
+ // for (let i in models) {
89458
+ // elements.push(models[i]);
89459
+ // }
89460
+ // MeshLoader.load(elements, options);
89461
+ // }
89462
+ // if (lights.length) {
89463
+ // LightLoader.load(lights, options);
89464
+ // }
89465
+ // Scene.updateChildren();
89466
+ // resolve();
89467
+ // })
89468
+
89469
+ _ref.elements;
89470
+ _ref.models;
89471
+ _ref.lights;
90464
89472
  });
90465
89473
 
90466
89474
  _defineProperty$1(_assertThisInitialized(_this), "getJSONUrl", function () {
@@ -91209,50 +90217,607 @@ var DEFAULT_RADIAL_SEGMENTS = 8;
91209
90217
  var DEFAULT_HEIGHT_SEGMENTS = 1;
91210
90218
  var DEFAULT_OPENENDED = false;
91211
90219
 
91212
- var Cone = /*#__PURE__*/function (_Element) {
91213
- _inherits(Cone, _Element);
90220
+ var Cone = /*#__PURE__*/function (_Element) {
90221
+ _inherits(Cone, _Element);
90222
+
90223
+ var _super = _createSuper(Cone);
90224
+
90225
+ function Cone() {
90226
+ var _this;
90227
+
90228
+ var radius = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_RADIUS;
90229
+ var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HEIGHT;
90230
+ var color = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Color.randomColor(true);
90231
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
90232
+
90233
+ _classCallCheck(this, Cone);
90234
+
90235
+ _this = _super.call(this, options);
90236
+ var _options$radialSegmen = options.radialSegments,
90237
+ radialSegments = _options$radialSegmen === void 0 ? DEFAULT_RADIAL_SEGMENTS : _options$radialSegmen,
90238
+ _options$heightSegmen = options.heightSegments,
90239
+ heightSegments = _options$heightSegmen === void 0 ? DEFAULT_HEIGHT_SEGMENTS : _options$heightSegmen,
90240
+ _options$openEnded = options.openEnded,
90241
+ openEnded = _options$openEnded === void 0 ? DEFAULT_OPENENDED : _options$openEnded;
90242
+ var geometry = new ConeGeometry(radius, height, radialSegments, heightSegments, openEnded);
90243
+ var material = new MeshBasicMaterial(_objectSpread2$1({
90244
+ color: color,
90245
+ wireframe: false
90246
+ }, options));
90247
+
90248
+ _this.setBody({
90249
+ geometry: geometry,
90250
+ material: material
90251
+ });
90252
+
90253
+ _this.setEntityType(ENTITY_TYPES.MESH);
90254
+
90255
+ return _this;
90256
+ }
90257
+
90258
+ return Cone;
90259
+ }(Element$1);var DEFAULT_SETUP_CONFIG$1 = {
90260
+ deferred: false
90261
+ };
90262
+
90263
+ var Sound$1 = /*#__PURE__*/function (_Entity) {
90264
+ _inherits(Sound, _Entity);
90265
+
90266
+ var _super = _createSuper(Sound);
90267
+
90268
+ function Sound() {
90269
+ var _this;
90270
+
90271
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90272
+
90273
+ _classCallCheck(this, Sound);
90274
+
90275
+ var source = options.source,
90276
+ _options$loop = options.loop,
90277
+ loop = _options$loop === void 0 ? false : _options$loop,
90278
+ loopStart = options.loopStart,
90279
+ loopEnd = options.loopEnd,
90280
+ autoplay = options.autoplay,
90281
+ reconnectOnReset = options.reconnectOnReset,
90282
+ _options$setupConfig = options.setupConfig,
90283
+ setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG$1 : _options$setupConfig,
90284
+ _options$name = options.name,
90285
+ name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
90286
+ _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
90287
+ source: source,
90288
+ loop: loop,
90289
+ loopStart: loopStart,
90290
+ loopEnd: loopEnd,
90291
+ autoplay: autoplay,
90292
+ reconnectOnReset: reconnectOnReset,
90293
+ name: name
90294
+ }));
90295
+
90296
+ _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
90297
+ _this.playing = false;
90298
+
90299
+ _this.disconnect();
90300
+
90301
+ _this.setupAudio();
90302
+
90303
+ _this.connect();
90304
+ });
90305
+
90306
+ _this.setupConfig = setupConfig;
90307
+ _this.source = source;
90308
+ _this.loop = loop;
90309
+ _this.loopStart = loopStart;
90310
+ _this.loopEnd = loopEnd;
90311
+ _this.autoplay = autoplay;
90312
+ _this.reconnectOnReset = reconnectOnReset;
90313
+ _this.name = name;
90314
+ _this.connected = false;
90315
+ _this.playing = false;
90316
+ _this.setupCompleted = false;
90317
+ _this.hasPlayed = false;
90318
+ _this.buffer = null;
90319
+ _this.audioNode = null;
90320
+ _this.volumeNode = null;
90321
+ _this.detuneValue = 0;
90322
+
90323
+ if (!_this.setupConfig.deferred) {
90324
+ _this.setupAudio();
90325
+ }
90326
+
90327
+ _this.setName(name);
90328
+
90329
+ _this.setBody({
90330
+ body: new Object3D()
90331
+ });
90332
+
90333
+ _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
90334
+
90335
+ Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
90336
+ Audio$1.add(_assertThisInitialized(_this));
90337
+
90338
+ if (_this.isSetupCompleted()) {
90339
+ _this.connect();
90340
+ }
90341
+
90342
+ return _this;
90343
+ }
90344
+
90345
+ _createClass(Sound, [{
90346
+ key: "addHelpers",
90347
+ value: function addHelpers() {
90348
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
90349
+ _ref$holderName = _ref.holderName,
90350
+ holderName = _ref$holderName === void 0 ? "soundholder" : _ref$holderName,
90351
+ _ref$holderSize = _ref.holderSize,
90352
+ holderSize = _ref$holderSize === void 0 ? 0.05 : _ref$holderSize;
90353
+
90354
+ var holderSprite = new HelperSprite(holderSize, holderSize, holderName, {
90355
+ name: holderName
90356
+ });
90357
+
90358
+ if (holderSprite) {
90359
+ holderSprite.setSizeAttenuation(false);
90360
+ holderSprite.setDepthTest(false);
90361
+ holderSprite.setDepthWrite(false);
90362
+ holderSprite.setSerializable(false);
90363
+ holderSprite.setPosition(this.getPosition());
90364
+ holderSprite.addTags([TAGS.HELPER, TAGS.SOUNDS.HELPER, TAGS.SOUNDS.HOLDER, name]);
90365
+ holderSprite.setHelperTarget(this);
90366
+ this.holder = holderSprite;
90367
+ return true;
90368
+ } else {
90369
+ console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND);
90370
+ return false;
90371
+ }
90372
+ }
90373
+ }, {
90374
+ key: "isPlaying",
90375
+ value: function isPlaying() {
90376
+ return this.playing;
90377
+ }
90378
+ }, {
90379
+ key: "isSetupCompleted",
90380
+ value: function isSetupCompleted() {
90381
+ return this.setupCompleted;
90382
+ }
90383
+ }, {
90384
+ key: "isConnected",
90385
+ value: function isConnected() {
90386
+ return this.connected;
90387
+ }
90388
+ }, {
90389
+ key: "setupAudio",
90390
+ value: function setupAudio() {
90391
+ this.createAudioNode();
90392
+ this.createVolumeNode();
90393
+ this.setBuffer();
90394
+ this.setupAudioNodeLoop();
90395
+ this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
90396
+ this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
90397
+ this.setupCompleted = true;
90398
+ }
90399
+ }, {
90400
+ key: "setSource",
90401
+ value: function setSource(source) {
90402
+ this.source = source;
90403
+ }
90404
+ }, {
90405
+ key: "getSource",
90406
+ value: function getSource() {
90407
+ return this.source;
90408
+ }
90409
+ }, {
90410
+ key: "createAudioNode",
90411
+ value: function createAudioNode() {
90412
+ this.audioNode = Audio$1.context.createBufferSource();
90413
+ }
90414
+ }, {
90415
+ key: "setupAudioNodeLoop",
90416
+ value: function setupAudioNodeLoop() {
90417
+ this.audioNode.loop = this.loop;
90418
+ this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
90419
+ this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
90420
+ }
90421
+ }, {
90422
+ key: "createVolumeNode",
90423
+ value: function createVolumeNode() {
90424
+ this.volumeNode = Audio$1.context.createGain();
90425
+ this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
90426
+ }
90427
+ }, {
90428
+ key: "tryAutoplay",
90429
+ value: function tryAutoplay() {
90430
+ if (this.autoplay && !this.hasPlayed && !this.setupConfig.deferred) {
90431
+ this.play();
90432
+ }
90433
+ }
90434
+ }, {
90435
+ key: "connect",
90436
+ value: function connect() {
90437
+ if (this.isConnected()) {
90438
+ this.disconnect();
90439
+ }
90440
+
90441
+ this.volumeNode.connect(Audio$1.getMasterVolumeNode());
90442
+ this.audioNode.connect(this.volumeNode);
90443
+ this.connected = true;
90444
+ this.tryAutoplay();
90445
+ }
90446
+ }, {
90447
+ key: "disconnect",
90448
+ value: function disconnect() {
90449
+ if (this.isConnected()) {
90450
+ this.volumeNode.disconnect();
90451
+ this.audioNode.disconnect();
90452
+ this.connected = false;
90453
+ }
90454
+ }
90455
+ }, {
90456
+ key: "dispose",
90457
+ value: function dispose() {
90458
+ _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
90459
+
90460
+ this.stop();
90461
+ this.disconnect();
90462
+ }
90463
+ }, {
90464
+ key: "getVolume",
90465
+ value: function getVolume() {
90466
+ return this.volumeNode ? this.volumeNode.gain.value : Audio$1.getVolume();
90467
+ }
90468
+ }, {
90469
+ key: "setVolume",
90470
+ value: function setVolume() {
90471
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
90472
+ this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
90473
+ }
90474
+ }, {
90475
+ key: "hasBuffer",
90476
+ value: function hasBuffer() {
90477
+ return !!this.buffer;
90478
+ }
90479
+ }, {
90480
+ key: "setBuffer",
90481
+ value: function setBuffer() {
90482
+ if (!this.getSource()) {
90483
+ console.error(AUDIO_SOURCE_NOT_DEFINED);
90484
+ return false;
90485
+ }
90486
+
90487
+ var buffer = Audio$1.get(this.source);
90488
+
90489
+ if (!buffer) {
90490
+ console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
90491
+ return false;
90492
+ }
90493
+
90494
+ this.buffer = buffer;
90495
+ this.audioNode.buffer = buffer;
90496
+ return true;
90497
+ }
90498
+ }, {
90499
+ key: "play",
90500
+ value: function play() {
90501
+ var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
90502
+ var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
90503
+ var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
90504
+ if (this.isPlaying()) return this;
90505
+ if (!this.isSetupCompleted()) this.setupAudio();
90506
+ if (!this.isConnected()) this.connect();
90507
+ console.log("goin to start playing at volume", volume, this.source);
90508
+ this.setVolume(0);
90509
+ this.audioNode.start();
90510
+ this.hasPlayed = true;
90511
+ this.playing = true;
90512
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
90513
+
90514
+ if (ramp === AUDIO_RAMPS.LINEAR) {
90515
+ this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
90516
+ } else {
90517
+ this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
90518
+ }
90519
+
90520
+ return this;
90521
+ }
90522
+ }, {
90523
+ key: "onSoundEnded",
90524
+ value: function onSoundEnded() {
90525
+ this.reset();
90526
+ this.dispatchEvent({
90527
+ type: ENTITY_EVENTS.AUDIO.ENDED
90528
+ });
90529
+ }
90530
+ }, {
90531
+ key: "stop",
90532
+ value: function stop() {
90533
+ var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
90534
+ var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
90535
+ var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
90536
+
90537
+ if (ramp === AUDIO_RAMPS.LINEAR) {
90538
+ this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
90539
+ } else {
90540
+ this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
90541
+ }
90542
+
90543
+ setTimeout(this.reset, delay);
90544
+ return this;
90545
+ }
90546
+ }, {
90547
+ key: "detune",
90548
+ value: function detune(value) {
90549
+ if (this.audioNode) {
90550
+ this.detuneValue = value;
90551
+ this.audioNode.detune.value = this.detuneValue;
90552
+ }
90553
+ }
90554
+ }, {
90555
+ key: "getDetune",
90556
+ value: function getDetune() {
90557
+ return this.detuneValue;
90558
+ }
90559
+ }, {
90560
+ key: "addEffect",
90561
+ value: function addEffect(effect) {
90562
+ if (!this.hasEffect() && effect) {
90563
+ this.convolverNode = Audio$1.context.createConvolver();
90564
+ this.mixerNode = Audio$1.createGain();
90565
+
90566
+ if (this.hasPannerNode()) {
90567
+ this.pannerNode.disconnect();
90568
+ this.pannerNode.connect(this.mixerNode);
90569
+ } else {
90570
+ this.volumeNode.disconnect();
90571
+ this.volumeNode.connect(this.mixerNode);
90572
+ } //creating gains
90573
+
90574
+
90575
+ this.plainGainNode = Audio$1.context.createGain();
90576
+ this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
90577
+
90578
+ this.mixerNode.connect(this.plainGainNode);
90579
+ this.mixerNode.connect(this.convolverGainNode);
90580
+ this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
90581
+ this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
90582
+ this.convolverNode.buffer = Audio$1.get(effect);
90583
+ this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
90584
+ this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
90585
+ }
90586
+ }
90587
+ }, {
90588
+ key: "setPosition",
90589
+ value: function setPosition(where) {
90590
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
90591
+ _ref2$updateHolder = _ref2.updateHolder,
90592
+ updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
90593
+
90594
+ var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
90595
+
90596
+ var x = position.x,
90597
+ y = position.y,
90598
+ z = position.z;
90599
+
90600
+ if (this.hasBody()) {
90601
+ this.body.position.set(x, y, z);
90602
+ }
90603
+
90604
+ if (this.hasHolder() && updateHolder) {
90605
+ this.holder.setPosition({
90606
+ x: x,
90607
+ y: y,
90608
+ z: z
90609
+ });
90610
+ }
90611
+ }
90612
+ }, {
90613
+ key: "usingHelper",
90614
+ value: function usingHelper() {
90615
+ return !!this.isUsingHelper;
90616
+ }
90617
+ }, {
90618
+ key: "hasHolder",
90619
+ value: function hasHolder() {
90620
+ return !!this.holder;
90621
+ }
90622
+ }, {
90623
+ key: "toJSON",
90624
+ value: function toJSON() {
90625
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
90626
+ source: this.source,
90627
+ loop: this.loop,
90628
+ loopStart: this.loopStart,
90629
+ loopEnd: this.loopEnd,
90630
+ autoplay: this.autoplay,
90631
+ volume: this.getVolume(),
90632
+ detune: this.getDetune(),
90633
+ hasPlayed: this.hasPlayed,
90634
+ playing: this.isPlaying(),
90635
+ connected: this.isConnected(),
90636
+ duration: this.hasBuffer() ? this.duration : 0,
90637
+ sampleRate: this.hasBuffer() ? this.sampleRate : 0,
90638
+ numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
90639
+ });
90640
+ }
90641
+ }, {
90642
+ key: "sampleRate",
90643
+ get: function get() {
90644
+ return this.buffer.sampleRate;
90645
+ }
90646
+ }, {
90647
+ key: "duration",
90648
+ get: function get() {
90649
+ return this.buffer.duration * 1000;
90650
+ }
90651
+ }, {
90652
+ key: "numberOfChannels",
90653
+ get: function get() {
90654
+ return this.buffer.numberOfChannels;
90655
+ }
90656
+ }]);
90657
+
90658
+ return Sound;
90659
+ }(Entity);var _excluded$2 = ["name"];
90660
+
90661
+ var AmbientSound = /*#__PURE__*/function (_Sound) {
90662
+ _inherits(AmbientSound, _Sound);
90663
+
90664
+ var _super = _createSuper(AmbientSound);
90665
+
90666
+ function AmbientSound(source) {
90667
+ var _this;
90668
+
90669
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
90670
+ _ref$name = _ref.name,
90671
+ name = _ref$name === void 0 ? generateRandomName("AmbientSound") : _ref$name,
90672
+ options = _objectWithoutProperties(_ref, _excluded$2);
90673
+
90674
+ _classCallCheck(this, AmbientSound);
90675
+
90676
+ _this = _super.call(this, _objectSpread2$1({
90677
+ source: source,
90678
+ name: name
90679
+ }, options));
90680
+
90681
+ _this.setEntityType(ENTITY_TYPES.AUDIO.AMBIENT);
90682
+
90683
+ return _this;
90684
+ }
90685
+
90686
+ return AmbientSound;
90687
+ }(Sound$1);var _excluded$1 = ["name"];
90688
+
90689
+ var DirectionalSound = /*#__PURE__*/function (_Sound) {
90690
+ _inherits(DirectionalSound, _Sound);
91214
90691
 
91215
- var _super = _createSuper(Cone);
90692
+ var _super = _createSuper(DirectionalSound);
91216
90693
 
91217
- function Cone() {
90694
+ function DirectionalSound(source) {
91218
90695
  var _this;
91219
90696
 
91220
- var radius = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_RADIUS;
91221
- var height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_HEIGHT;
91222
- var color = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Color.randomColor(true);
91223
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
90697
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
90698
+ _ref$name = _ref.name,
90699
+ name = _ref$name === void 0 ? generateRandomName("DirectionalSound") : _ref$name,
90700
+ options = _objectWithoutProperties(_ref, _excluded$1);
91224
90701
 
91225
- _classCallCheck(this, Cone);
90702
+ _classCallCheck(this, DirectionalSound);
91226
90703
 
91227
- _this = _super.call(this, options);
91228
- var _options$radialSegmen = options.radialSegments,
91229
- radialSegments = _options$radialSegmen === void 0 ? DEFAULT_RADIAL_SEGMENTS : _options$radialSegmen,
91230
- _options$heightSegmen = options.heightSegments,
91231
- heightSegments = _options$heightSegmen === void 0 ? DEFAULT_HEIGHT_SEGMENTS : _options$heightSegmen,
91232
- _options$openEnded = options.openEnded,
91233
- openEnded = _options$openEnded === void 0 ? DEFAULT_OPENENDED : _options$openEnded;
91234
- var geometry = new ConeGeometry(radius, height, radialSegments, heightSegments, openEnded);
91235
- var material = new MeshBasicMaterial(_objectSpread2$1({
91236
- color: color,
91237
- wireframe: false
90704
+ _this = _super.call(this, _objectSpread2$1({
90705
+ source: source,
90706
+ name: name
91238
90707
  }, options));
91239
90708
 
91240
- _this.setBody({
91241
- geometry: geometry,
91242
- material: material
91243
- });
91244
-
91245
- _this.setEntityType(ENTITY_TYPES.MESH);
90709
+ _this.setEntityType(ENTITY_TYPES.AUDIO.DIRECTIONAL);
91246
90710
 
91247
90711
  return _this;
91248
90712
  }
91249
90713
 
91250
- return Cone;
91251
- }(Element$1);var DEFAULT_SETUP_CONFIG$1 = {
90714
+ _createClass(DirectionalSound, [{
90715
+ key: "setupAudio",
90716
+ value: function setupAudio() {
90717
+ _get(_getPrototypeOf(DirectionalSound.prototype), "setupAudio", this).call(this);
90718
+
90719
+ this.createPannerNode(this.options);
90720
+ }
90721
+ }, {
90722
+ key: "hasPannerNode",
90723
+ value: function hasPannerNode() {
90724
+ return !!this.pannerNode;
90725
+ }
90726
+ }, {
90727
+ key: "createPannerNode",
90728
+ value: function createPannerNode() {
90729
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
90730
+ var _options$coneInnerAng = options.coneInnerAngleDegrees,
90731
+ coneInnerAngleDegrees = _options$coneInnerAng === void 0 ? 360 : _options$coneInnerAng,
90732
+ _options$coneOuterAng = options.coneOuterAngleDegrees,
90733
+ coneOuterAngleDegrees = _options$coneOuterAng === void 0 ? 0 : _options$coneOuterAng,
90734
+ _options$coneOuterGai = options.coneOuterGain,
90735
+ coneOuterGain = _options$coneOuterGai === void 0 ? 0 : _options$coneOuterGai,
90736
+ _options$maxDistance = options.maxDistance,
90737
+ maxDistance = _options$maxDistance === void 0 ? 10000 : _options$maxDistance,
90738
+ _options$rolloffFacto = options.rolloffFactor,
90739
+ rolloffFactor = _options$rolloffFacto === void 0 ? 1 : _options$rolloffFacto,
90740
+ _options$refDistance = options.refDistance,
90741
+ refDistance = _options$refDistance === void 0 ? 1 : _options$refDistance;
90742
+ this.pannerNode = Audio$1.context.createPanner();
90743
+ this.pannerNode.panningModel = "HRTF";
90744
+ this.pannerNode.distanceModel = "inverse";
90745
+ this.pannerNode.refDistance = refDistance;
90746
+ this.pannerNode.maxDistance = maxDistance;
90747
+ this.pannerNode.rolloffFactor = rolloffFactor;
90748
+ this.pannerNode.coneInnerAngle = coneInnerAngleDegrees;
90749
+ this.pannerNode.coneOuterAngle = coneOuterAngleDegrees;
90750
+ this.pannerNode.coneOuterGain = coneOuterGain;
90751
+ }
90752
+ }, {
90753
+ key: "connect",
90754
+ value: function connect() {
90755
+ if (this.connected) {
90756
+ this.disconnect();
90757
+ }
90758
+
90759
+ this.volumeNode.connect(Audio$1.getMasterVolumeNode());
90760
+ this.pannerNode.connect(this.volumeNode);
90761
+ this.audioNode.connect(this.pannerNode);
90762
+ this.connected = true;
90763
+ this.tryAutoplay();
90764
+ }
90765
+ }, {
90766
+ key: "disconnect",
90767
+ value: function disconnect() {
90768
+ if (this.connected) {
90769
+ this.volumeNode.disconnect();
90770
+ this.pannerNode.disconnect();
90771
+ this.audioNode.disconnect();
90772
+ this.connected = false;
90773
+ }
90774
+ }
90775
+ }, {
90776
+ key: "updatePannerOrientation",
90777
+ value: function updatePannerOrientation() {
90778
+ var vec = new Vector3$1(0, 0, 1);
90779
+ var m = this.getBody().matrixWorld;
90780
+ var mx = m.elements[12],
90781
+ my = m.elements[13],
90782
+ mz = m.elements[14];
90783
+ m.elements[12] = m.elements[13] = m.elements[14] = 0;
90784
+ vec.applyMatrix4(m);
90785
+ vec.normalize();
90786
+ this.pannerNode.orientationX.setValueAtTime(vec.x, Audio$1.context.currentTime);
90787
+ this.pannerNode.orientationY.setValueAtTime(vec.y, Audio$1.context.currentTime);
90788
+ this.pannerNode.orientationZ.setValueAtTime(vec.z, Audio$1.context.currentTime);
90789
+ m.elements[12] = mx;
90790
+ m.elements[13] = my;
90791
+ m.elements[14] = mz;
90792
+ }
90793
+ }, {
90794
+ key: "updatePannerPosition",
90795
+ value: function updatePannerPosition() {
90796
+ this.getBody().updateMatrixWorld();
90797
+ var position = new Vector3$1();
90798
+ position.setFromMatrixPosition(this.getBody().matrixWorld);
90799
+ this.pannerNode.positionX.setValueAtTime(position.x, Audio$1.context.currentTime);
90800
+ this.pannerNode.positionY.setValueAtTime(position.y, Audio$1.context.currentTime);
90801
+ this.pannerNode.positionZ.setValueAtTime(position.z, Audio$1.context.currentTime);
90802
+ }
90803
+ }, {
90804
+ key: "update",
90805
+ value: function update(dt) {
90806
+ _get(_getPrototypeOf(DirectionalSound.prototype), "update", this).call(this, dt);
90807
+
90808
+ if (this.hasPannerNode()) {
90809
+ this.updatePannerOrientation();
90810
+ this.updatePannerPosition();
90811
+ }
90812
+ }
90813
+ }]);
90814
+
90815
+ return DirectionalSound;
90816
+ }(Sound$1);var DEFAULT_SETUP_CONFIG = {
91252
90817
  deferred: false
91253
90818
  };
91254
90819
 
91255
- var Sound$1 = /*#__PURE__*/function (_Entity) {
90820
+ var Sound = /*#__PURE__*/function (_Entity) {
91256
90821
  _inherits(Sound, _Entity);
91257
90822
 
91258
90823
  var _super = _createSuper(Sound);
@@ -91272,7 +90837,7 @@ var Sound$1 = /*#__PURE__*/function (_Entity) {
91272
90837
  autoplay = options.autoplay,
91273
90838
  reconnectOnReset = options.reconnectOnReset,
91274
90839
  _options$setupConfig = options.setupConfig,
91275
- setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG$1 : _options$setupConfig,
90840
+ setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG : _options$setupConfig,
91276
90841
  _options$name = options.name,
91277
90842
  name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
91278
90843
  _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
@@ -91614,703 +91179,960 @@ var Sound$1 = /*#__PURE__*/function (_Entity) {
91614
91179
  }, {
91615
91180
  key: "toJSON",
91616
91181
  value: function toJSON() {
91617
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
91618
- source: this.source,
91619
- loop: this.loop,
91620
- loopStart: this.loopStart,
91621
- loopEnd: this.loopEnd,
91622
- autoplay: this.autoplay,
91623
- volume: this.getVolume(),
91624
- detune: this.getDetune(),
91625
- hasPlayed: this.hasPlayed,
91626
- playing: this.isPlaying(),
91627
- connected: this.isConnected(),
91628
- duration: this.hasBuffer() ? this.duration : 0,
91629
- sampleRate: this.hasBuffer() ? this.sampleRate : 0,
91630
- numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
91182
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
91183
+ source: this.source,
91184
+ loop: this.loop,
91185
+ loopStart: this.loopStart,
91186
+ loopEnd: this.loopEnd,
91187
+ autoplay: this.autoplay,
91188
+ volume: this.getVolume(),
91189
+ detune: this.getDetune(),
91190
+ hasPlayed: this.hasPlayed,
91191
+ playing: this.isPlaying(),
91192
+ connected: this.isConnected(),
91193
+ duration: this.hasBuffer() ? this.duration : 0,
91194
+ sampleRate: this.hasBuffer() ? this.sampleRate : 0,
91195
+ numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
91196
+ });
91197
+ }
91198
+ }, {
91199
+ key: "sampleRate",
91200
+ get: function get() {
91201
+ return this.buffer.sampleRate;
91202
+ }
91203
+ }, {
91204
+ key: "duration",
91205
+ get: function get() {
91206
+ return this.buffer.duration * 1000;
91207
+ }
91208
+ }, {
91209
+ key: "numberOfChannels",
91210
+ get: function get() {
91211
+ return this.buffer.numberOfChannels;
91212
+ }
91213
+ }]);
91214
+
91215
+ return Sound;
91216
+ }(Entity);var BLOB_TYPE = 'application/javascript';
91217
+ var createBlob = function createBlob(task) {
91218
+ return new Blob(['(', task.toString(), ')()'], {
91219
+ type: BLOB_TYPE
91220
+ });
91221
+ };
91222
+ var createWorker = function createWorker(task, message) {
91223
+ if (Features$1.isFeatureSupported(FEATURES.WEBWORKER)) {
91224
+ var url = URL.createObjectURL(createBlob(task));
91225
+ var worker = new Worker(url); // Won't be needing this anymore
91226
+
91227
+ URL.revokeObjectURL(url);
91228
+
91229
+ if (message) {
91230
+ worker.postMessage(message);
91231
+ }
91232
+
91233
+ return worker;
91234
+ } else {
91235
+ console.error(WORKERS_NOT_AVAILABLE);
91236
+ return null;
91237
+ }
91238
+ };
91239
+ var createPromiseWorker = function createPromiseWorker(task, message) {
91240
+ return new Promise(function (resolve, reject) {
91241
+ var worker = createWorker(task, message);
91242
+
91243
+ if (worker) {
91244
+ worker.onmessage = function (data) {
91245
+ resolve(data);
91246
+ worker.terminate();
91247
+ };
91248
+ } else {
91249
+ reject(WORKERS_NOT_AVAILABLE);
91250
+ }
91251
+ });
91252
+ };var workers=/*#__PURE__*/Object.freeze({__proto__:null,createBlob:createBlob,createWorker:createWorker,createPromiseWorker:createPromiseWorker});var HIT_BOX_COLOR = 0xf368e0;
91253
+ var HIT_BOX_INCREASE = .03;
91254
+ var DEFAULT_HITBOX_OPTIONS = {
91255
+ shadowsEnabled: false
91256
+ };
91257
+ var getBoxHitbox = function getBoxHitbox(element) {
91258
+ var size = new Vector3$1();
91259
+ element.boundingBox.getSize(size);
91260
+ var scaledSize = {
91261
+ x: size.x + HIT_BOX_INCREASE,
91262
+ y: size.y + HIT_BOX_INCREASE,
91263
+ z: size.z + HIT_BOX_INCREASE
91264
+ };
91265
+ var box = new Box(scaledSize.x, scaledSize.y, scaledSize.z, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS); //box.setQuaternion(quaternion);
91266
+
91267
+ box.setWireframe(true);
91268
+ box.setWireframeLineWidth(2);
91269
+ return box;
91270
+ };
91271
+ var getSphereHitbox = function getSphereHitbox(element) {
91272
+ var radius = element.boundingSphere.radius;
91273
+ var sphere = new Sphere(radius, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
91274
+ sphere.setWireframe(true);
91275
+ sphere.setWireframeLineWidth(2);
91276
+ return sphere;
91277
+ };
91278
+ var mapColliderTypeToHitbox = function mapColliderTypeToHitbox() {
91279
+ var _COLLIDER_TYPES$BOX$C;
91280
+
91281
+ var colliderType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : COLLIDER_TYPES$1.BOX;
91282
+ return (_COLLIDER_TYPES$BOX$C = {}, _defineProperty$1(_COLLIDER_TYPES$BOX$C, COLLIDER_TYPES$1.BOX, getBoxHitbox), _defineProperty$1(_COLLIDER_TYPES$BOX$C, COLLIDER_TYPES$1.SPHERE, getSphereHitbox), _COLLIDER_TYPES$BOX$C)[colliderType] || getBoxHitbox;
91283
+ };
91284
+ var addHitBox = function addHitBox(element) {
91285
+ var colliderType = element.getPhysicsOptions('colliderType');
91286
+ var getHitbox = mapColliderTypeToHitbox(colliderType);
91287
+ element.add(getHitbox(element));
91288
+ };var hitbox=/*#__PURE__*/Object.freeze({__proto__:null,getBoxHitbox:getBoxHitbox,getSphereHitbox:getSphereHitbox,mapColliderTypeToHitbox:mapColliderTypeToHitbox,addHitBox:addHitBox});var LabelComponent = /*#__PURE__*/function (_Component) {
91289
+ _inherits(LabelComponent, _Component);
91290
+
91291
+ var _super = _createSuper(LabelComponent);
91292
+
91293
+ function LabelComponent(props) {
91294
+ var _this;
91295
+
91296
+ _classCallCheck(this, LabelComponent);
91297
+
91298
+ _this = _super.call(this, props);
91299
+ _this.element = createRef();
91300
+ return _this;
91301
+ }
91302
+
91303
+ _createClass(LabelComponent, [{
91304
+ key: "componentDidUpdate",
91305
+ value: function componentDidUpdate() {
91306
+ this.props.onUpdate(this.element.current);
91307
+ }
91308
+ }, {
91309
+ key: "componentDidMount",
91310
+ value: function componentDidMount() {
91311
+ this.props.onMount(this.element.current);
91312
+ }
91313
+ }, {
91314
+ key: "componentWillUnmount",
91315
+ value: function componentWillUnmount() {
91316
+ this.props.onUnmount(this.element.current);
91317
+ }
91318
+ }]);
91319
+
91320
+ return LabelComponent;
91321
+ }(Component$1);var Light$1 = /*#__PURE__*/function (_Entity) {
91322
+ _inherits(Light, _Entity);
91323
+
91324
+ var _super = _createSuper(Light);
91325
+
91326
+ function Light(_ref) {
91327
+ var _this;
91328
+
91329
+ var color = _ref.color,
91330
+ intensity = _ref.intensity,
91331
+ _name = _ref.name;
91332
+
91333
+ _classCallCheck(this, Light);
91334
+
91335
+ _this = _super.call(this, {
91336
+ name: _name
91337
+ });
91338
+
91339
+ _defineProperty$1(_assertThisInitialized(_this), "addHolder", function () {
91340
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "lightholder";
91341
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
91342
+ var holderSprite = new HelperSprite(size, size, name, {
91343
+ name: name
91344
+ });
91345
+
91346
+ if (holderSprite) {
91347
+ holderSprite.setSizeAttenuation(false);
91348
+ holderSprite.setDepthTest(false);
91349
+ holderSprite.setDepthWrite(false);
91350
+ holderSprite.setSerializable(false);
91351
+ holderSprite.setPosition(_this.getPosition());
91352
+ holderSprite.addTags([TAGS.HELPER, TAGS.LIGHTS.HELPER, TAGS.LIGHTS.HOLDER, name]);
91353
+ holderSprite.setHelperTarget(_assertThisInitialized(_this));
91354
+ _this.holder = holderSprite;
91355
+ return true;
91356
+ } else {
91357
+ console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND$1);
91358
+ return false;
91359
+ }
91360
+ });
91361
+
91362
+ _defineProperty$1(_assertThisInitialized(_this), "addTargetHolder", function () {
91363
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "targetholder";
91364
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.05;
91365
+ var targetSprite = new HelperSprite(size, size, name, {
91366
+ name: name
91367
+ });
91368
+
91369
+ if (targetSprite) {
91370
+ targetSprite.setSizeAttenuation(false);
91371
+ targetSprite.setDepthTest(false);
91372
+ targetSprite.setDepthWrite(false);
91373
+ targetSprite.setSerializable(false);
91374
+ targetSprite.setPosition(_this.getTarget().getPosition());
91375
+ targetSprite.addTags([TAGS.LIGHTS.HELPER, TAGS.LIGHTS.TARGET, name]);
91376
+ targetSprite.setHelperTarget(_assertThisInitialized(_this));
91377
+ targetSprite.getBody().add(_this.getBody().target);
91378
+ _this.targetHolder = targetSprite;
91379
+ }
91380
+ });
91381
+
91382
+ _this.color = color;
91383
+ _this.intensity = intensity;
91384
+ _this.name = _name || generateRandomName("Light");
91385
+ _this.isLightOn = false;
91386
+ _this.body = undefined; // helper body for this light
91387
+
91388
+ _this.isUsingHelper = undefined; // holder body representing the light
91389
+
91390
+ _this.holder = undefined; // target body for the light (only used by directional light)
91391
+
91392
+ _this.target = undefined;
91393
+
91394
+ _this.setEntityType(ENTITY_TYPES.LIGHT.DEFAULT);
91395
+
91396
+ Lights$1.add(_assertThisInitialized(_this));
91397
+ return _this;
91398
+ }
91399
+
91400
+ _createClass(Light, [{
91401
+ key: "addToScene",
91402
+ value: function addToScene() {
91403
+ if (this.hasBody()) {
91404
+ Scene$1.add(this.body, this);
91405
+ }
91406
+ }
91407
+ }, {
91408
+ key: "usingHelper",
91409
+ value: function usingHelper() {
91410
+ return !!this.isUsingHelper;
91411
+ }
91412
+ }, {
91413
+ key: "hasHolder",
91414
+ value: function hasHolder() {
91415
+ return !!this.holder;
91416
+ }
91417
+ }, {
91418
+ key: "hasTarget",
91419
+ value: function hasTarget() {
91420
+ return false;
91421
+ }
91422
+ }, {
91423
+ key: "getPosition",
91424
+ value: function getPosition() {
91425
+ return {
91426
+ x: this.body.position.x,
91427
+ y: this.body.position.y,
91428
+ z: this.body.position.z
91429
+ };
91430
+ }
91431
+ }, {
91432
+ key: "setPosition",
91433
+ value: function setPosition(where) {
91434
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
91435
+ _ref2$updateHolder = _ref2.updateHolder,
91436
+ updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
91437
+
91438
+ var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
91439
+
91440
+ var x = position.x,
91441
+ y = position.y,
91442
+ z = position.z;
91443
+
91444
+ if (this.hasBody()) {
91445
+ this.body.position.set(x, y, z);
91446
+ }
91447
+
91448
+ if (this.hasHolder() && updateHolder) {
91449
+ this.holder.setPosition({
91450
+ x: x,
91451
+ y: y,
91452
+ z: z
91453
+ });
91454
+ }
91455
+ }
91456
+ }, {
91457
+ key: "isAlreadyOn",
91458
+ value: function isAlreadyOn() {
91459
+ return this.hasBody() && this.body.intensity === this.intensity;
91460
+ }
91461
+ }, {
91462
+ key: "isAlreadyOff",
91463
+ value: function isAlreadyOff() {
91464
+ return this.hasBody() && this.body.intensity <= 0;
91465
+ }
91466
+ }, {
91467
+ key: "setIntensity",
91468
+ value: function setIntensity(value) {
91469
+ if (this.hasBody()) {
91470
+ this.body.intensity = value;
91471
+ this.intensity = value;
91472
+ }
91473
+ }
91474
+ }, {
91475
+ key: "getIntensity",
91476
+ value: function getIntensity() {
91477
+ if (this.hasBody()) {
91478
+ return this.body.intensity;
91479
+ }
91480
+ }
91481
+ }, {
91482
+ key: "setColor",
91483
+ value: function setColor(color) {
91484
+ this.body.color = color;
91485
+ }
91486
+ }, {
91487
+ key: "getColor",
91488
+ value: function getColor() {
91489
+ return this.body.color;
91490
+ }
91491
+ }, {
91492
+ key: "setCastShadow",
91493
+ value: function setCastShadow(castShadow) {
91494
+ this.castShadow = castShadow;
91495
+ this.getBody().castShadow = castShadow;
91496
+ }
91497
+ }, {
91498
+ key: "getCastShadow",
91499
+ value: function getCastShadow() {
91500
+ return this.castShadow;
91501
+ }
91502
+ }, {
91503
+ key: "dim",
91504
+ value: function dim() {
91505
+ var _this2 = this;
91506
+
91507
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getIntensity();
91508
+ var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
91509
+ var intensity = this.getIntensity();
91510
+
91511
+ var onUpdate = function onUpdate(value) {
91512
+ return !_this2.isDisposed() && _this2.setIntensity(value);
91513
+ };
91514
+
91515
+ return tweenTo(intensity, value, {
91516
+ time: time,
91517
+ onUpdate: onUpdate
91518
+ });
91519
+ }
91520
+ }, {
91521
+ key: "on",
91522
+ value: function on() {
91523
+ var _this3 = this;
91524
+
91525
+ var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
91526
+
91527
+ if (this.hasBody()) {
91528
+ this.dim(this.intensity, time).then(function () {
91529
+ return _this3.isLightOn = true;
91530
+ });
91531
+ } else {
91532
+ console.log(LIGHT_NOT_FOUND);
91533
+ }
91534
+ }
91535
+ }, {
91536
+ key: "off",
91537
+ value: function off() {
91538
+ var _this4 = this;
91539
+
91540
+ var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 500;
91541
+
91542
+ if (this.hasBody()) {
91543
+ this.dim(0, time).then(function () {
91544
+ return _this4.isLightOn = false;
91545
+ });
91546
+ } else {
91547
+ console.log(LIGHT_NOT_FOUND);
91548
+ }
91549
+ }
91550
+ }, {
91551
+ key: "toJSON",
91552
+ value: function toJSON() {
91553
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Light.prototype), "toJSON", this).call(this)), {}, {
91554
+ type: this.getEntityType(),
91555
+ color: this.getColor(),
91556
+ intensity: this.getIntensity(),
91557
+ name: this.getName(),
91558
+ castShadow: this.getCastShadow()
91631
91559
  });
91632
91560
  }
91633
- }, {
91634
- key: "sampleRate",
91635
- get: function get() {
91636
- return this.buffer.sampleRate;
91637
- }
91638
- }, {
91639
- key: "duration",
91640
- get: function get() {
91641
- return this.buffer.duration * 1000;
91642
- }
91643
- }, {
91644
- key: "numberOfChannels",
91645
- get: function get() {
91646
- return this.buffer.numberOfChannels;
91647
- }
91648
91561
  }]);
91649
91562
 
91650
- return Sound;
91651
- }(Entity);var _excluded$2 = ["name"];
91563
+ return Light;
91564
+ }(Entity);var DEFAULT_POSITION$3 = {
91565
+ x: 0,
91566
+ y: 0,
91567
+ z: 0
91568
+ };
91569
+ var DEFAULT_INTENSITY$4 = 0.5;
91570
+ var WHITE$3 = 0xffffff;
91652
91571
 
91653
- var AmbientSound = /*#__PURE__*/function (_Sound) {
91654
- _inherits(AmbientSound, _Sound);
91572
+ var AmbientLight = /*#__PURE__*/function (_Light) {
91573
+ _inherits(AmbientLight, _Light);
91655
91574
 
91656
- var _super = _createSuper(AmbientSound);
91575
+ var _super = _createSuper(AmbientLight);
91657
91576
 
91658
- function AmbientSound(source) {
91577
+ function AmbientLight() {
91659
91578
  var _this;
91660
91579
 
91661
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
91662
- _ref$name = _ref.name,
91663
- name = _ref$name === void 0 ? generateRandomName("AmbientSound") : _ref$name,
91664
- options = _objectWithoutProperties(_ref, _excluded$2);
91580
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91665
91581
 
91666
- _classCallCheck(this, AmbientSound);
91582
+ _classCallCheck(this, AmbientLight);
91667
91583
 
91668
- _this = _super.call(this, _objectSpread2$1({
91669
- source: source,
91584
+ var _options$color = options.color,
91585
+ color = _options$color === void 0 ? WHITE$3 : _options$color,
91586
+ _options$intensity = options.intensity,
91587
+ intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$4 : _options$intensity,
91588
+ _options$name = options.name,
91589
+ name = _options$name === void 0 ? generateRandomName("AmbientLight") : _options$name;
91590
+ _this = _super.call(this, {
91591
+ color: color,
91592
+ intensity: intensity,
91670
91593
  name: name
91671
- }, options));
91672
-
91673
- _this.setEntityType(ENTITY_TYPES.AUDIO.AMBIENT);
91674
-
91675
- return _this;
91676
- }
91677
-
91678
- return AmbientSound;
91679
- }(Sound$1);var _excluded$1 = ["name"];
91680
-
91681
- var DirectionalSound = /*#__PURE__*/function (_Sound) {
91682
- _inherits(DirectionalSound, _Sound);
91683
-
91684
- var _super = _createSuper(DirectionalSound);
91685
-
91686
- function DirectionalSound(source) {
91687
- var _this;
91688
-
91689
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
91690
- _ref$name = _ref.name,
91691
- name = _ref$name === void 0 ? generateRandomName("DirectionalSound") : _ref$name,
91692
- options = _objectWithoutProperties(_ref, _excluded$1);
91594
+ });
91595
+ _this.options = options;
91693
91596
 
91694
- _classCallCheck(this, DirectionalSound);
91597
+ _this.setLight({
91598
+ color: color,
91599
+ intensity: intensity
91600
+ });
91695
91601
 
91696
- _this = _super.call(this, _objectSpread2$1({
91697
- source: source,
91698
- name: name
91699
- }, options));
91602
+ _this.setEntityType(ENTITY_TYPES.LIGHT.AMBIENT);
91700
91603
 
91701
- _this.setEntityType(ENTITY_TYPES.AUDIO.DIRECTIONAL);
91604
+ _this.setName(name);
91702
91605
 
91703
91606
  return _this;
91704
91607
  }
91705
91608
 
91706
- _createClass(DirectionalSound, [{
91707
- key: "setupAudio",
91708
- value: function setupAudio() {
91709
- _get(_getPrototypeOf(DirectionalSound.prototype), "setupAudio", this).call(this);
91609
+ _createClass(AmbientLight, [{
91610
+ key: "setLight",
91611
+ value: function setLight(_ref) {
91612
+ var light = _ref.light,
91613
+ _ref$color = _ref.color,
91614
+ color = _ref$color === void 0 ? WHITE$3 : _ref$color,
91615
+ _ref$intensity = _ref.intensity,
91616
+ intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$4 : _ref$intensity;
91710
91617
 
91711
- this.createPannerNode(this.options);
91712
- }
91713
- }, {
91714
- key: "hasPannerNode",
91715
- value: function hasPannerNode() {
91716
- return !!this.pannerNode;
91717
- }
91718
- }, {
91719
- key: "createPannerNode",
91720
- value: function createPannerNode() {
91721
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91722
- var _options$coneInnerAng = options.coneInnerAngleDegrees,
91723
- coneInnerAngleDegrees = _options$coneInnerAng === void 0 ? 360 : _options$coneInnerAng,
91724
- _options$coneOuterAng = options.coneOuterAngleDegrees,
91725
- coneOuterAngleDegrees = _options$coneOuterAng === void 0 ? 0 : _options$coneOuterAng,
91726
- _options$coneOuterGai = options.coneOuterGain,
91727
- coneOuterGain = _options$coneOuterGai === void 0 ? 0 : _options$coneOuterGai,
91728
- _options$maxDistance = options.maxDistance,
91729
- maxDistance = _options$maxDistance === void 0 ? 10000 : _options$maxDistance,
91730
- _options$rolloffFacto = options.rolloffFactor,
91731
- rolloffFactor = _options$rolloffFacto === void 0 ? 1 : _options$rolloffFacto,
91732
- _options$refDistance = options.refDistance,
91733
- refDistance = _options$refDistance === void 0 ? 1 : _options$refDistance;
91734
- this.pannerNode = Audio$1.context.createPanner();
91735
- this.pannerNode.panningModel = "HRTF";
91736
- this.pannerNode.distanceModel = "inverse";
91737
- this.pannerNode.refDistance = refDistance;
91738
- this.pannerNode.maxDistance = maxDistance;
91739
- this.pannerNode.rolloffFactor = rolloffFactor;
91740
- this.pannerNode.coneInnerAngle = coneInnerAngleDegrees;
91741
- this.pannerNode.coneOuterAngle = coneOuterAngleDegrees;
91742
- this.pannerNode.coneOuterGain = coneOuterGain;
91743
- }
91744
- }, {
91745
- key: "connect",
91746
- value: function connect() {
91747
- if (this.connected) {
91748
- this.disconnect();
91618
+ if (light) {
91619
+ this.setBody({
91620
+ body: light
91621
+ });
91622
+ } else {
91623
+ this.setBody({
91624
+ body: new AmbientLight$1(color, intensity)
91625
+ });
91749
91626
  }
91750
91627
 
91751
- this.volumeNode.connect(Audio$1.getMasterVolumeNode());
91752
- this.pannerNode.connect(this.volumeNode);
91753
- this.audioNode.connect(this.pannerNode);
91754
- this.connected = true;
91755
- this.tryAutoplay();
91756
- }
91757
- }, {
91758
- key: "disconnect",
91759
- value: function disconnect() {
91760
- if (this.connected) {
91761
- this.volumeNode.disconnect();
91762
- this.pannerNode.disconnect();
91763
- this.audioNode.disconnect();
91764
- this.connected = false;
91628
+ if (this.hasBody()) {
91629
+ this.postLightCreation();
91765
91630
  }
91766
91631
  }
91767
91632
  }, {
91768
- key: "updatePannerOrientation",
91769
- value: function updatePannerOrientation() {
91770
- var vec = new Vector3$1(0, 0, 1);
91771
- var m = this.getBody().matrixWorld;
91772
- var mx = m.elements[12],
91773
- my = m.elements[13],
91774
- mz = m.elements[14];
91775
- m.elements[12] = m.elements[13] = m.elements[14] = 0;
91776
- vec.applyMatrix4(m);
91777
- vec.normalize();
91778
- this.pannerNode.orientationX.setValueAtTime(vec.x, Audio$1.context.currentTime);
91779
- this.pannerNode.orientationY.setValueAtTime(vec.y, Audio$1.context.currentTime);
91780
- this.pannerNode.orientationZ.setValueAtTime(vec.z, Audio$1.context.currentTime);
91781
- m.elements[12] = mx;
91782
- m.elements[13] = my;
91783
- m.elements[14] = mz;
91633
+ key: "postLightCreation",
91634
+ value: function postLightCreation() {
91635
+ var _this$options$positio = this.options.position,
91636
+ position = _this$options$positio === void 0 ? DEFAULT_POSITION$3 : _this$options$positio;
91637
+ this.setPosition(position);
91638
+ this.addToScene();
91784
91639
  }
91785
91640
  }, {
91786
- key: "updatePannerPosition",
91787
- value: function updatePannerPosition() {
91788
- this.getBody().updateMatrixWorld();
91789
- var position = new Vector3$1();
91790
- position.setFromMatrixPosition(this.getBody().matrixWorld);
91791
- this.pannerNode.positionX.setValueAtTime(position.x, Audio$1.context.currentTime);
91792
- this.pannerNode.positionY.setValueAtTime(position.y, Audio$1.context.currentTime);
91793
- this.pannerNode.positionZ.setValueAtTime(position.z, Audio$1.context.currentTime);
91641
+ key: "addHelpers",
91642
+ value: function addHelpers() {
91643
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91644
+ _ref2$holderName = _ref2.holderName,
91645
+ holderName = _ref2$holderName === void 0 ? "ambientlightholder" : _ref2$holderName,
91646
+ _ref2$holderSize = _ref2.holderSize,
91647
+ holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize;
91648
+
91649
+ this.addHolder(holderName, holderSize);
91650
+ this.isUsingHelper = true;
91794
91651
  }
91795
91652
  }, {
91796
91653
  key: "update",
91797
91654
  value: function update(dt) {
91798
- _get(_getPrototypeOf(DirectionalSound.prototype), "update", this).call(this, dt);
91655
+ _get(_getPrototypeOf(AmbientLight.prototype), "update", this).call(this, dt);
91799
91656
 
91800
- if (this.hasPannerNode()) {
91801
- this.updatePannerOrientation();
91802
- this.updatePannerPosition();
91657
+ if (this.usingHelper()) {
91658
+ this.setPosition(this.holder.getPosition(), {
91659
+ updateHolder: false
91660
+ });
91803
91661
  }
91804
91662
  }
91805
91663
  }]);
91806
91664
 
91807
- return DirectionalSound;
91808
- }(Sound$1);var DEFAULT_SETUP_CONFIG = {
91809
- deferred: false
91665
+ return AmbientLight;
91666
+ }(Light$1);var DEFAULT_NEAR$2 = 0.1;
91667
+ var DEFAULT_FAR$2 = 100;
91668
+ var DEFAULT_FOV = 75;
91669
+ var DEFAULT_POSITION$2 = {
91670
+ x: 0,
91671
+ y: 1,
91672
+ z: 0
91810
91673
  };
91674
+ var DEFAULT_INTENSITY$3 = 0.5;
91675
+ var DEFAULT_MAP_SIZE$2 = 512;
91676
+ var DEFAULT_BIAS$2 = -0.0001;
91677
+ var WHITE$2 = 0xffffff;
91811
91678
 
91812
- var Sound = /*#__PURE__*/function (_Entity) {
91813
- _inherits(Sound, _Entity);
91679
+ var SunLight = /*#__PURE__*/function (_Light) {
91680
+ _inherits(SunLight, _Light);
91814
91681
 
91815
- var _super = _createSuper(Sound);
91682
+ var _super = _createSuper(SunLight);
91816
91683
 
91817
- function Sound() {
91684
+ function SunLight() {
91818
91685
  var _this;
91819
91686
 
91820
91687
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
91821
91688
 
91822
- _classCallCheck(this, Sound);
91689
+ _classCallCheck(this, SunLight);
91823
91690
 
91824
- var source = options.source,
91825
- _options$loop = options.loop,
91826
- loop = _options$loop === void 0 ? false : _options$loop,
91827
- loopStart = options.loopStart,
91828
- loopEnd = options.loopEnd,
91829
- autoplay = options.autoplay,
91830
- reconnectOnReset = options.reconnectOnReset,
91831
- _options$setupConfig = options.setupConfig,
91832
- setupConfig = _options$setupConfig === void 0 ? DEFAULT_SETUP_CONFIG : _options$setupConfig,
91691
+ var _options$color = options.color,
91692
+ color = _options$color === void 0 ? WHITE$2 : _options$color,
91693
+ _options$intensity = options.intensity,
91694
+ intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$3 : _options$intensity,
91833
91695
  _options$name = options.name,
91834
- name = _options$name === void 0 ? generateRandomName("sound") : _options$name;
91835
- _this = _super.call(this, _objectSpread2$1(_objectSpread2$1({}, options), {}, {
91836
- source: source,
91837
- loop: loop,
91838
- loopStart: loopStart,
91839
- loopEnd: loopEnd,
91840
- autoplay: autoplay,
91841
- reconnectOnReset: reconnectOnReset,
91696
+ name = _options$name === void 0 ? generateRandomName("SunLight") : _options$name;
91697
+ _this = _super.call(this, {
91698
+ color: color,
91699
+ intensity: intensity,
91842
91700
  name: name
91843
- }));
91844
-
91845
- _defineProperty$1(_assertThisInitialized(_this), "reset", function () {
91846
- _this.playing = false;
91847
-
91848
- _this.disconnect();
91849
-
91850
- _this.setupAudio();
91851
-
91852
- _this.connect();
91853
91701
  });
91854
91702
 
91855
- _this.setupConfig = setupConfig;
91856
- _this.source = source;
91857
- _this.loop = loop;
91858
- _this.loopStart = loopStart;
91859
- _this.loopEnd = loopEnd;
91860
- _this.autoplay = autoplay;
91861
- _this.reconnectOnReset = reconnectOnReset;
91862
- _this.name = name;
91863
- _this.connected = false;
91864
- _this.playing = false;
91865
- _this.setupCompleted = false;
91866
- _this.hasPlayed = false;
91867
- _this.buffer = null;
91868
- _this.audioNode = null;
91869
- _this.volumeNode = null;
91870
- _this.detuneValue = 0;
91703
+ _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
91704
+ var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$2;
91705
+ var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$2;
91706
+ _this.near = near;
91707
+ _this.far = far;
91708
+ var d = _this.far / 2;
91709
+ _this.getBody().shadow.camera.left = -d;
91710
+ _this.getBody().shadow.camera.right = d;
91711
+ _this.getBody().shadow.camera.top = d;
91712
+ _this.getBody().shadow.camera.bottom = -d;
91713
+ _this.getBody().shadow.camera.near = near;
91714
+ _this.getBody().shadow.camera.far = far;
91715
+ });
91871
91716
 
91872
- if (!_this.setupConfig.deferred) {
91873
- _this.setupAudio();
91874
- }
91717
+ _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
91718
+ var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$2;
91719
+ _this.bias = bias;
91720
+ _this.getBody().shadow.bias = bias;
91721
+ });
91875
91722
 
91876
- _this.setName(name);
91723
+ _this.options = options;
91724
+ _this.target = ORIGIN;
91877
91725
 
91878
- _this.setBody({
91879
- body: new Object3D()
91726
+ _this.setLight({
91727
+ color: color,
91728
+ intensity: intensity
91880
91729
  });
91881
91730
 
91882
- _this.setEntityType(ENTITY_TYPES.AUDIO.DEFAULT);
91883
-
91884
- Scene$1.add(_this.getBody(), _assertThisInitialized(_this));
91885
- Audio$1.add(_assertThisInitialized(_this));
91731
+ _this.setEntityType(ENTITY_TYPES.LIGHT.SUN);
91886
91732
 
91887
- if (_this.isSetupCompleted()) {
91888
- _this.connect();
91889
- }
91733
+ _this.setName(name);
91890
91734
 
91891
91735
  return _this;
91892
91736
  }
91893
91737
 
91894
- _createClass(Sound, [{
91895
- key: "addHelpers",
91896
- value: function addHelpers() {
91897
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91898
- _ref$holderName = _ref.holderName,
91899
- holderName = _ref$holderName === void 0 ? "soundholder" : _ref$holderName,
91900
- _ref$holderSize = _ref.holderSize,
91901
- holderSize = _ref$holderSize === void 0 ? 0.05 : _ref$holderSize;
91902
-
91903
- var holderSprite = new HelperSprite(holderSize, holderSize, holderName, {
91904
- name: holderName
91905
- });
91738
+ _createClass(SunLight, [{
91739
+ key: "setLight",
91740
+ value: function setLight(_ref) {
91741
+ var light = _ref.light,
91742
+ _ref$color = _ref.color,
91743
+ color = _ref$color === void 0 ? WHITE$2 : _ref$color,
91744
+ _ref$intensity = _ref.intensity,
91745
+ intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$3 : _ref$intensity;
91906
91746
 
91907
- if (holderSprite) {
91908
- holderSprite.setSizeAttenuation(false);
91909
- holderSprite.setDepthTest(false);
91910
- holderSprite.setDepthWrite(false);
91911
- holderSprite.setSerializable(false);
91912
- holderSprite.setPosition(this.getPosition());
91913
- holderSprite.addTags([TAGS.HELPER, TAGS.SOUNDS.HELPER, TAGS.SOUNDS.HOLDER, name]);
91914
- holderSprite.setHelperTarget(this);
91915
- this.holder = holderSprite;
91916
- return true;
91747
+ if (light) {
91748
+ this.setBody({
91749
+ body: light
91750
+ });
91917
91751
  } else {
91918
- console.warn(LIGHT_HOLDER_MODEL_NOT_FOUND);
91919
- return false;
91752
+ this.setBody({
91753
+ body: new DirectionalLight(color, intensity)
91754
+ });
91755
+ }
91756
+
91757
+ if (this.hasBody()) {
91758
+ this.postLightCreation();
91920
91759
  }
91921
91760
  }
91922
91761
  }, {
91923
- key: "isPlaying",
91924
- value: function isPlaying() {
91925
- return this.playing;
91926
- }
91927
- }, {
91928
- key: "isSetupCompleted",
91929
- value: function isSetupCompleted() {
91930
- return this.setupCompleted;
91931
- }
91932
- }, {
91933
- key: "isConnected",
91934
- value: function isConnected() {
91935
- return this.connected;
91936
- }
91937
- }, {
91938
- key: "setupAudio",
91939
- value: function setupAudio() {
91940
- this.createAudioNode();
91941
- this.createVolumeNode();
91942
- this.setBuffer();
91943
- this.setupAudioNodeLoop();
91944
- this.audioNode.removeEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
91945
- this.audioNode.addEventListener(ENTITY_EVENTS.AUDIO.ENDED, this.onSoundEnded.bind(this));
91946
- this.setupCompleted = true;
91947
- }
91948
- }, {
91949
- key: "setSource",
91950
- value: function setSource(source) {
91951
- this.source = source;
91952
- }
91953
- }, {
91954
- key: "getSource",
91955
- value: function getSource() {
91956
- return this.source;
91957
- }
91958
- }, {
91959
- key: "createAudioNode",
91960
- value: function createAudioNode() {
91961
- this.audioNode = Audio$1.context.createBufferSource();
91962
- }
91963
- }, {
91964
- key: "setupAudioNodeLoop",
91965
- value: function setupAudioNodeLoop() {
91966
- this.audioNode.loop = this.loop;
91967
- this.audioNode.loopEnd = this.loopEnd === undefined ? this.duration : this.loopEnd;
91968
- this.audioNode.loopStart = this.loopStart === undefined ? this.duration : this.loopStart;
91969
- }
91970
- }, {
91971
- key: "createVolumeNode",
91972
- value: function createVolumeNode() {
91973
- this.volumeNode = Audio$1.context.createGain();
91974
- this.volumeNode.gain.value = DEFAULT_AUDIO_NODE_VOLUME;
91762
+ key: "postLightCreation",
91763
+ value: function postLightCreation() {
91764
+ var _this$options$positio = this.options.position,
91765
+ position = _this$options$positio === void 0 ? DEFAULT_POSITION$2 : _this$options$positio;
91766
+ var emptyTarget = new Element$1({
91767
+ body: new Object3D()
91768
+ });
91769
+ this.setPosition(position);
91770
+ this.setTarget(emptyTarget);
91771
+ this.setLightShadows();
91772
+ this.addToScene();
91975
91773
  }
91976
91774
  }, {
91977
- key: "tryAutoplay",
91978
- value: function tryAutoplay() {
91979
- if (this.autoplay && !this.hasPlayed && !this.setupConfig.deferred) {
91980
- this.play();
91775
+ key: "setLightShadows",
91776
+ value: function setLightShadows() {
91777
+ var _this$options = this.options,
91778
+ _this$options$near = _this$options.near,
91779
+ near = _this$options$near === void 0 ? DEFAULT_NEAR$2 : _this$options$near,
91780
+ _this$options$far = _this$options.far,
91781
+ far = _this$options$far === void 0 ? DEFAULT_FAR$2 : _this$options$far,
91782
+ _this$options$mapSize = _this$options.mapSize,
91783
+ mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE$2 : _this$options$mapSize,
91784
+ _this$options$bias = _this$options.bias,
91785
+ bias = _this$options$bias === void 0 ? DEFAULT_BIAS$2 : _this$options$bias,
91786
+ _this$options$fov = _this$options.fov,
91787
+ fov = _this$options$fov === void 0 ? DEFAULT_FOV : _this$options$fov;
91788
+
91789
+ if (Config$1.lights().shadows) {
91790
+ this.setCastShadow(true);
91791
+ this.setMapSize(mapSize);
91792
+ this.setShadowCameraNearFar(near, far);
91793
+ this.setBias(bias);
91794
+ this.setShadowCameraFov(fov);
91981
91795
  }
91982
91796
  }
91983
91797
  }, {
91984
- key: "connect",
91985
- value: function connect() {
91986
- if (this.isConnected()) {
91987
- this.disconnect();
91988
- }
91989
-
91990
- this.volumeNode.connect(Audio$1.getMasterVolumeNode());
91991
- this.audioNode.connect(this.volumeNode);
91992
- this.connected = true;
91993
- this.tryAutoplay();
91798
+ key: "getShadowCameraNearFar",
91799
+ value: function getShadowCameraNearFar() {
91800
+ return {
91801
+ near: this.near,
91802
+ far: this.far
91803
+ };
91994
91804
  }
91995
91805
  }, {
91996
- key: "disconnect",
91997
- value: function disconnect() {
91998
- if (this.isConnected()) {
91999
- this.volumeNode.disconnect();
92000
- this.audioNode.disconnect();
92001
- this.connected = false;
92002
- }
91806
+ key: "setShadowCameraFov",
91807
+ value: function setShadowCameraFov() {
91808
+ var fov = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_FOV;
91809
+ this.fov = fov;
91810
+ this.getBody().shadow.camera.fov = fov;
92003
91811
  }
92004
91812
  }, {
92005
- key: "dispose",
92006
- value: function dispose() {
92007
- _get(_getPrototypeOf(Sound.prototype), "dispose", this).call(this);
92008
-
92009
- this.stop();
92010
- this.disconnect();
91813
+ key: "getShadowCameraFov",
91814
+ value: function getShadowCameraFov() {
91815
+ return this.fov;
92011
91816
  }
92012
91817
  }, {
92013
- key: "getVolume",
92014
- value: function getVolume() {
92015
- return this.volumeNode ? this.volumeNode.gain.value : Audio$1.getVolume();
91818
+ key: "setMapSize",
91819
+ value: function setMapSize() {
91820
+ var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$2;
91821
+ this.mapSize = mapSize;
91822
+ this.getBody().shadow.mapSize.height = mapSize;
91823
+ this.getBody().shadow.mapSize.width = mapSize;
92016
91824
  }
92017
91825
  }, {
92018
- key: "setVolume",
92019
- value: function setVolume() {
92020
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_VOLUME;
92021
- this.volumeNode.gain.setValueAtTime(value, Audio$1.context.currentTime);
91826
+ key: "getMapSize",
91827
+ value: function getMapSize() {
91828
+ return this.mapSize;
92022
91829
  }
92023
91830
  }, {
92024
- key: "hasBuffer",
92025
- value: function hasBuffer() {
92026
- return !!this.buffer;
91831
+ key: "getBias",
91832
+ value: function getBias() {
91833
+ return this.bias;
92027
91834
  }
92028
91835
  }, {
92029
- key: "setBuffer",
92030
- value: function setBuffer() {
92031
- if (!this.getSource()) {
92032
- console.error(AUDIO_SOURCE_NOT_DEFINED);
92033
- return false;
92034
- }
92035
-
92036
- var buffer = Audio$1.get(this.source);
92037
-
92038
- if (!buffer) {
92039
- console.error(AUDIO_UNABLE_TO_LOAD_SOUND);
92040
- return false;
92041
- }
92042
-
92043
- this.buffer = buffer;
92044
- this.audioNode.buffer = buffer;
91836
+ key: "hasTarget",
91837
+ value: function hasTarget() {
92045
91838
  return true;
92046
91839
  }
92047
91840
  }, {
92048
- key: "play",
92049
- value: function play() {
92050
- var volume = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getVolume();
92051
- var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_AUDIO_NODE_RAMP_TIME;
92052
- var ramp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : AUDIO_RAMPS.LINEAR;
92053
- if (this.isPlaying()) return this;
92054
- if (!this.isSetupCompleted()) this.setupAudio();
92055
- if (!this.isConnected()) this.connect();
92056
- console.log("goin to start playing at volume", volume, this.source);
92057
- this.setVolume(0);
92058
- this.audioNode.start();
92059
- this.hasPlayed = true;
92060
- this.playing = true;
92061
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
92062
-
92063
- if (ramp === AUDIO_RAMPS.LINEAR) {
92064
- this.volumeNode.gain.linearRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
92065
- } else {
92066
- this.volumeNode.gain.exponentialRampToValueAtTime(volume, Audio$1.context.currentTime + audioDelay);
92067
- }
92068
-
92069
- return this;
91841
+ key: "setTarget",
91842
+ value: function setTarget(target) {
91843
+ this.target = target;
91844
+ this.getBody().target = target.getBody();
91845
+ Scene$1.add(this.getBody().target, null, false);
92070
91846
  }
92071
91847
  }, {
92072
- key: "onSoundEnded",
92073
- value: function onSoundEnded() {
92074
- this.reset();
92075
- this.dispatchEvent({
92076
- type: ENTITY_EVENTS.AUDIO.ENDED
92077
- });
91848
+ key: "getTarget",
91849
+ value: function getTarget() {
91850
+ return this.target;
92078
91851
  }
92079
91852
  }, {
92080
- key: "stop",
92081
- value: function stop() {
92082
- var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_AUDIO_NODE_RAMP_TIME;
92083
- var ramp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : AUDIO_RAMPS.LINEAR;
92084
- var audioDelay = delay / 1000; // linearRampToValueAtTime/exponentialRampToValueAtTime requires time to be expressed in seconds
92085
-
92086
- if (ramp === AUDIO_RAMPS.LINEAR) {
92087
- this.volumeNode.gain.linearRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
92088
- } else {
92089
- this.volumeNode.gain.exponentialRampToValueAtTime(ALMOST_ZERO, Audio$1.context.currentTime + audioDelay);
92090
- }
91853
+ key: "addHelpers",
91854
+ value: function addHelpers() {
91855
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
91856
+ _ref2$holderName = _ref2.holderName,
91857
+ holderName = _ref2$holderName === void 0 ? "sunlightholder" : _ref2$holderName,
91858
+ _ref2$holderSize = _ref2.holderSize,
91859
+ holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize,
91860
+ _ref2$targetHolderNam = _ref2.targetHolderName,
91861
+ targetHolderName = _ref2$targetHolderNam === void 0 ? "targetholder" : _ref2$targetHolderNam,
91862
+ _ref2$targetHolderSiz = _ref2.targetHolderSize,
91863
+ targetHolderSize = _ref2$targetHolderSiz === void 0 ? 0.05 : _ref2$targetHolderSiz;
92091
91864
 
92092
- setTimeout(this.reset, delay);
92093
- return this;
91865
+ this.helper = new DirectionalLightHelper(this.getBody(), 5);
91866
+ this.shadowHelper = new CameraHelper(this.getBody().shadow.camera);
91867
+ Scene$1.add(this.helper, null, false);
91868
+ Scene$1.add(this.shadowHelper, null, false);
91869
+ this.addHolder(holderName, holderSize);
91870
+ this.addTargetHolder(targetHolderName, targetHolderSize);
91871
+ this.isUsingHelper = true;
92094
91872
  }
92095
91873
  }, {
92096
- key: "detune",
92097
- value: function detune(value) {
92098
- if (this.audioNode) {
92099
- this.detuneValue = value;
92100
- this.audioNode.detune.value = this.detuneValue;
91874
+ key: "update",
91875
+ value: function update(dt) {
91876
+ _get(_getPrototypeOf(SunLight.prototype), "update", this).call(this, dt);
91877
+
91878
+ if (this.usingHelper()) {
91879
+ this.helper.update();
91880
+ this.shadowHelper.update();
91881
+ }
91882
+
91883
+ if (this.hasHolder()) {
91884
+ this.setPosition(this.holder.getPosition(), {
91885
+ updateHolder: false
91886
+ });
92101
91887
  }
92102
91888
  }
92103
91889
  }, {
92104
- key: "getDetune",
92105
- value: function getDetune() {
92106
- return this.detuneValue;
91890
+ key: "toJSON",
91891
+ value: function toJSON() {
91892
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(SunLight.prototype), "toJSON", this).call(this)), {}, {
91893
+ target: this.getTarget(),
91894
+ bias: this.getBias(),
91895
+ mapSize: this.getMapSize(),
91896
+ shadowCamera: _objectSpread2$1(_objectSpread2$1({}, this.getShadowCameraNearFar()), {}, {
91897
+ fov: this.setShadowCameraFov()
91898
+ })
91899
+ });
92107
91900
  }
92108
- }, {
92109
- key: "addEffect",
92110
- value: function addEffect(effect) {
92111
- if (!this.hasEffect() && effect) {
92112
- this.convolverNode = Audio$1.context.createConvolver();
92113
- this.mixerNode = Audio$1.createGain();
91901
+ }]);
92114
91902
 
92115
- if (this.hasPannerNode()) {
92116
- this.pannerNode.disconnect();
92117
- this.pannerNode.connect(this.mixerNode);
92118
- } else {
92119
- this.volumeNode.disconnect();
92120
- this.volumeNode.connect(this.mixerNode);
92121
- } //creating gains
91903
+ return SunLight;
91904
+ }(Light$1);var DEFAULT_NEAR$1 = 0.1;
91905
+ var DEFAULT_FAR$1 = 100;
91906
+ var DEFAULT_POSITION$1 = {
91907
+ x: 0,
91908
+ y: 0,
91909
+ z: 0
91910
+ };
91911
+ var DEFAULT_INTENSITY$2 = 0.5;
91912
+ var DEFAULT_DISTANCE = 0;
91913
+ var DEFAULT_DECAY = 1;
91914
+ var DEFAULT_MAP_SIZE$1 = 2048;
91915
+ var DEFAULT_BIAS$1 = -0.0001;
91916
+ var WHITE$1 = 0xffffff;
91917
+ var GREEN$2 = 0x2ecc71;
92122
91918
 
91919
+ var PointLight = /*#__PURE__*/function (_Light) {
91920
+ _inherits(PointLight, _Light);
92123
91921
 
92124
- this.plainGainNode = Audio$1.context.createGain();
92125
- this.convolverGainNode = Audio$1.context.createGain(); //connect mixer to new gains
91922
+ var _super = _createSuper(PointLight);
92126
91923
 
92127
- this.mixerNode.connect(this.plainGainNode);
92128
- this.mixerNode.connect(this.convolverGainNode);
92129
- this.plainGainNode.connect(Audio$1.getMasterVolumeNode());
92130
- this.convolverGainNode.connect(Audio$1.getMasterVolumeNode());
92131
- this.convolverNode.buffer = Audio$1.get(effect);
92132
- this.convolverGainNode.gain.setValueAtTime(0.7, Audio$1.context.currentTime);
92133
- this.plainGainNode.gain.setValueAtTime(0.3, Audio$1.context.currentTime);
92134
- }
92135
- }
92136
- }, {
92137
- key: "setPosition",
92138
- value: function setPosition(where) {
92139
- var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
92140
- _ref2$updateHolder = _ref2.updateHolder,
92141
- updateHolder = _ref2$updateHolder === void 0 ? true : _ref2$updateHolder;
91924
+ function PointLight() {
91925
+ var _this;
92142
91926
 
92143
- var position = _objectSpread2$1(_objectSpread2$1({}, this.getPosition()), where);
91927
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92144
91928
 
92145
- var x = position.x,
92146
- y = position.y,
92147
- z = position.z;
91929
+ _classCallCheck(this, PointLight);
91930
+
91931
+ var _options$color = options.color,
91932
+ color = _options$color === void 0 ? WHITE$1 : _options$color,
91933
+ _options$intensity = options.intensity,
91934
+ intensity = _options$intensity === void 0 ? DEFAULT_INTENSITY$2 : _options$intensity,
91935
+ _options$name = options.name,
91936
+ name = _options$name === void 0 ? generateRandomName("PointLight") : _options$name,
91937
+ distance = options.distance,
91938
+ decay = options.decay;
91939
+ _this = _super.call(this, {
91940
+ color: color,
91941
+ intensity: intensity,
91942
+ name: name
91943
+ });
91944
+
91945
+ _defineProperty$1(_assertThisInitialized(_this), "setShadowCameraNearFar", function () {
91946
+ var near = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_NEAR$1;
91947
+ var far = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_FAR$1;
91948
+ _this.near = near;
91949
+ _this.far = far;
91950
+ var d = _this.far / 2;
91951
+ _this.getBody().shadow.camera.left = -d;
91952
+ _this.getBody().shadow.camera.right = d;
91953
+ _this.getBody().shadow.camera.top = d;
91954
+ _this.getBody().shadow.camera.bottom = -d;
91955
+ _this.getBody().shadow.camera.near = near;
91956
+ _this.getBody().shadow.camera.far = far;
91957
+ });
91958
+
91959
+ _defineProperty$1(_assertThisInitialized(_this), "setBias", function () {
91960
+ var bias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BIAS$1;
91961
+ _this.bias = bias;
91962
+ _this.getBody().shadow.bias = bias;
91963
+ });
91964
+
91965
+ _this.options = options;
91966
+
91967
+ _this.setLight({
91968
+ color: color,
91969
+ intensity: intensity,
91970
+ distance: distance,
91971
+ decay: decay
91972
+ });
91973
+
91974
+ _this.setEntityType(ENTITY_TYPES.LIGHT.POINT);
91975
+
91976
+ _this.setName(name);
91977
+
91978
+ return _this;
91979
+ }
91980
+
91981
+ _createClass(PointLight, [{
91982
+ key: "setLight",
91983
+ value: function setLight(_ref) {
91984
+ var light = _ref.light,
91985
+ _ref$color = _ref.color,
91986
+ color = _ref$color === void 0 ? WHITE$1 : _ref$color,
91987
+ _ref$intensity = _ref.intensity,
91988
+ intensity = _ref$intensity === void 0 ? DEFAULT_INTENSITY$2 : _ref$intensity,
91989
+ _ref$distance = _ref.distance,
91990
+ distance = _ref$distance === void 0 ? DEFAULT_DISTANCE : _ref$distance,
91991
+ _ref$decay = _ref.decay,
91992
+ decay = _ref$decay === void 0 ? DEFAULT_DECAY : _ref$decay;
91993
+
91994
+ if (light) {
91995
+ this.setBody({
91996
+ body: light
91997
+ });
91998
+ } else {
91999
+ this.setBody({
92000
+ body: new PointLight$1(color, intensity)
92001
+ });
92002
+ this.setDistance(distance);
92003
+ this.setDecay(decay);
92004
+ }
92148
92005
 
92149
92006
  if (this.hasBody()) {
92150
- this.body.position.set(x, y, z);
92007
+ this.postLightCreation();
92151
92008
  }
92009
+ }
92010
+ }, {
92011
+ key: "postLightCreation",
92012
+ value: function postLightCreation() {
92013
+ var _this$options$positio = this.options.position,
92014
+ position = _this$options$positio === void 0 ? DEFAULT_POSITION$1 : _this$options$positio;
92015
+ this.setPosition(position);
92016
+ this.setLightShadows();
92017
+ this.addToScene();
92018
+ }
92019
+ }, {
92020
+ key: "setLightShadows",
92021
+ value: function setLightShadows() {
92022
+ var _this$options = this.options,
92023
+ _this$options$near = _this$options.near,
92024
+ near = _this$options$near === void 0 ? DEFAULT_NEAR$1 : _this$options$near,
92025
+ _this$options$far = _this$options.far,
92026
+ far = _this$options$far === void 0 ? DEFAULT_FAR$1 : _this$options$far,
92027
+ _this$options$mapSize = _this$options.mapSize,
92028
+ mapSize = _this$options$mapSize === void 0 ? DEFAULT_MAP_SIZE$1 : _this$options$mapSize,
92029
+ _this$options$bias = _this$options.bias,
92030
+ bias = _this$options$bias === void 0 ? DEFAULT_BIAS$1 : _this$options$bias;
92152
92031
 
92153
- if (this.hasHolder() && updateHolder) {
92154
- this.holder.setPosition({
92155
- x: x,
92156
- y: y,
92157
- z: z
92158
- });
92032
+ if (Config$1.lights().shadows) {
92033
+ this.setCastShadow(true);
92034
+ this.setMapSize(mapSize);
92035
+ this.setShadowCameraNearFar(near, far);
92036
+ this.setBias(bias);
92159
92037
  }
92160
92038
  }
92161
92039
  }, {
92162
- key: "usingHelper",
92163
- value: function usingHelper() {
92164
- return !!this.isUsingHelper;
92040
+ key: "setDistance",
92041
+ value: function setDistance() {
92042
+ var distance = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISTANCE;
92043
+ this.distance = distance;
92044
+ this.getBody().distance = distance;
92165
92045
  }
92166
92046
  }, {
92167
- key: "hasHolder",
92168
- value: function hasHolder() {
92169
- return !!this.holder;
92047
+ key: "getDistance",
92048
+ value: function getDistance() {
92049
+ return this.distance;
92170
92050
  }
92171
92051
  }, {
92172
- key: "toJSON",
92173
- value: function toJSON() {
92174
- return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Sound.prototype), "toJSON", this).call(this)), {}, {
92175
- source: this.source,
92176
- loop: this.loop,
92177
- loopStart: this.loopStart,
92178
- loopEnd: this.loopEnd,
92179
- autoplay: this.autoplay,
92180
- volume: this.getVolume(),
92181
- detune: this.getDetune(),
92182
- hasPlayed: this.hasPlayed,
92183
- playing: this.isPlaying(),
92184
- connected: this.isConnected(),
92185
- duration: this.hasBuffer() ? this.duration : 0,
92186
- sampleRate: this.hasBuffer() ? this.sampleRate : 0,
92187
- numberOfChannels: this.hasBuffer() ? this.numberOfChannels : 0
92188
- });
92052
+ key: "setDecay",
92053
+ value: function setDecay() {
92054
+ var decay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DECAY;
92055
+ this.decay = decay;
92056
+ this.getBody().decay = decay;
92189
92057
  }
92190
92058
  }, {
92191
- key: "sampleRate",
92192
- get: function get() {
92193
- return this.buffer.sampleRate;
92059
+ key: "getDecay",
92060
+ value: function getDecay() {
92061
+ return this.decay;
92194
92062
  }
92195
92063
  }, {
92196
- key: "duration",
92197
- get: function get() {
92198
- return this.buffer.duration * 1000;
92064
+ key: "getShadowCameraNearFar",
92065
+ value: function getShadowCameraNearFar() {
92066
+ return {
92067
+ near: this.near,
92068
+ far: this.far
92069
+ };
92199
92070
  }
92200
92071
  }, {
92201
- key: "numberOfChannels",
92202
- get: function get() {
92203
- return this.buffer.numberOfChannels;
92072
+ key: "setMapSize",
92073
+ value: function setMapSize() {
92074
+ var mapSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_MAP_SIZE$1;
92075
+ this.mapSize = mapSize;
92076
+ this.getBody().shadow.mapSize.height = mapSize;
92077
+ this.getBody().shadow.mapSize.width = mapSize;
92204
92078
  }
92205
- }]);
92206
-
92207
- return Sound;
92208
- }(Entity);var BLOB_TYPE = 'application/javascript';
92209
- var createBlob = function createBlob(task) {
92210
- return new Blob(['(', task.toString(), ')()'], {
92211
- type: BLOB_TYPE
92212
- });
92213
- };
92214
- var createWorker = function createWorker(task, message) {
92215
- if (Features$1.isFeatureSupported(FEATURES.WEBWORKER)) {
92216
- var url = URL.createObjectURL(createBlob(task));
92217
- var worker = new Worker(url); // Won't be needing this anymore
92218
-
92219
- URL.revokeObjectURL(url);
92220
-
92221
- if (message) {
92222
- worker.postMessage(message);
92079
+ }, {
92080
+ key: "getMapSize",
92081
+ value: function getMapSize() {
92082
+ return this.mapSize;
92223
92083
  }
92224
-
92225
- return worker;
92226
- } else {
92227
- console.error(WORKERS_NOT_AVAILABLE);
92228
- return null;
92229
- }
92230
- };
92231
- var createPromiseWorker = function createPromiseWorker(task, message) {
92232
- return new Promise(function (resolve, reject) {
92233
- var worker = createWorker(task, message);
92234
-
92235
- if (worker) {
92236
- worker.onmessage = function (data) {
92237
- resolve(data);
92238
- worker.terminate();
92239
- };
92240
- } else {
92241
- reject(WORKERS_NOT_AVAILABLE);
92084
+ }, {
92085
+ key: "getBias",
92086
+ value: function getBias() {
92087
+ return this.bias;
92242
92088
  }
92243
- });
92244
- };var workers=/*#__PURE__*/Object.freeze({__proto__:null,createBlob:createBlob,createWorker:createWorker,createPromiseWorker:createPromiseWorker});var HIT_BOX_COLOR = 0xf368e0;
92245
- var HIT_BOX_INCREASE = .03;
92246
- var DEFAULT_HITBOX_OPTIONS = {
92247
- shadowsEnabled: false
92248
- };
92249
- var getBoxHitbox = function getBoxHitbox(element) {
92250
- var size = new Vector3$1();
92251
- element.boundingBox.getSize(size);
92252
- var scaledSize = {
92253
- x: size.x + HIT_BOX_INCREASE,
92254
- y: size.y + HIT_BOX_INCREASE,
92255
- z: size.z + HIT_BOX_INCREASE
92256
- };
92257
- var box = new Box(scaledSize.x, scaledSize.y, scaledSize.z, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS); //box.setQuaternion(quaternion);
92258
-
92259
- box.setWireframe(true);
92260
- box.setWireframeLineWidth(2);
92261
- return box;
92262
- };
92263
- var getSphereHitbox = function getSphereHitbox(element) {
92264
- var radius = element.boundingSphere.radius;
92265
- var sphere = new Sphere(radius, HIT_BOX_COLOR, DEFAULT_HITBOX_OPTIONS);
92266
- sphere.setWireframe(true);
92267
- sphere.setWireframeLineWidth(2);
92268
- return sphere;
92269
- };
92270
- var mapColliderTypeToHitbox = function mapColliderTypeToHitbox() {
92271
- var _COLLIDER_TYPES$BOX$C;
92272
-
92273
- var colliderType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : COLLIDER_TYPES$1.BOX;
92274
- return (_COLLIDER_TYPES$BOX$C = {}, _defineProperty$1(_COLLIDER_TYPES$BOX$C, COLLIDER_TYPES$1.BOX, getBoxHitbox), _defineProperty$1(_COLLIDER_TYPES$BOX$C, COLLIDER_TYPES$1.SPHERE, getSphereHitbox), _COLLIDER_TYPES$BOX$C)[colliderType] || getBoxHitbox;
92275
- };
92276
- var addHitBox = function addHitBox(element) {
92277
- var colliderType = element.getPhysicsOptions('colliderType');
92278
- var getHitbox = mapColliderTypeToHitbox(colliderType);
92279
- element.add(getHitbox(element));
92280
- };var hitbox=/*#__PURE__*/Object.freeze({__proto__:null,getBoxHitbox:getBoxHitbox,getSphereHitbox:getSphereHitbox,mapColliderTypeToHitbox:mapColliderTypeToHitbox,addHitBox:addHitBox});var LabelComponent = /*#__PURE__*/function (_Component) {
92281
- _inherits(LabelComponent, _Component);
92282
-
92283
- var _super = _createSuper(LabelComponent);
92284
-
92285
- function LabelComponent(props) {
92286
- var _this;
92287
-
92288
- _classCallCheck(this, LabelComponent);
92289
-
92290
- _this = _super.call(this, props);
92291
- _this.element = createRef();
92292
- return _this;
92293
- }
92089
+ }, {
92090
+ key: "addHelpers",
92091
+ value: function addHelpers() {
92092
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
92093
+ _ref2$holderName = _ref2.holderName,
92094
+ holderName = _ref2$holderName === void 0 ? "pointlightholder" : _ref2$holderName,
92095
+ _ref2$holderSize = _ref2.holderSize,
92096
+ holderSize = _ref2$holderSize === void 0 ? 0.05 : _ref2$holderSize;
92294
92097
 
92295
- _createClass(LabelComponent, [{
92296
- key: "componentDidUpdate",
92297
- value: function componentDidUpdate() {
92298
- this.props.onUpdate(this.element.current);
92098
+ this.helper = new PointLightHelper(this.getBody(), 2, GREEN$2);
92099
+ this.shadowHelper = new CameraHelper(this.getBody().shadow.camera);
92100
+ Scene$1.add(this.helper, null, false);
92101
+ Scene$1.add(this.shadowHelper, null, false);
92102
+ this.addHolder(holderName, holderSize);
92103
+ this.isUsingHelper = true;
92299
92104
  }
92300
92105
  }, {
92301
- key: "componentDidMount",
92302
- value: function componentDidMount() {
92303
- this.props.onMount(this.element.current);
92106
+ key: "update",
92107
+ value: function update(dt) {
92108
+ _get(_getPrototypeOf(PointLight.prototype), "update", this).call(this, dt);
92109
+
92110
+ if (this.usingHelper()) {
92111
+ this.helper.update();
92112
+ this.shadowHelper.update();
92113
+ }
92114
+
92115
+ if (this.hasHolder()) {
92116
+ this.setPosition(this.holder.getPosition(), {
92117
+ updateHolder: false
92118
+ });
92119
+ }
92304
92120
  }
92305
92121
  }, {
92306
- key: "componentWillUnmount",
92307
- value: function componentWillUnmount() {
92308
- this.props.onUnmount(this.element.current);
92122
+ key: "toJSON",
92123
+ value: function toJSON() {
92124
+ return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(PointLight.prototype), "toJSON", this).call(this)), {}, {
92125
+ distance: this.getDistance(),
92126
+ decay: this.getDecay(),
92127
+ bias: this.getBias(),
92128
+ mapSize: this.getMapSize(),
92129
+ shadowCamera: this.getShadowCameraNearFar()
92130
+ });
92309
92131
  }
92310
92132
  }]);
92311
92133
 
92312
- return LabelComponent;
92313
- }(Component$1);var DEFAULT_NEAR = 0.1;
92134
+ return PointLight;
92135
+ }(Light$1);var DEFAULT_NEAR = 0.1;
92314
92136
  var DEFAULT_FAR = 100;
92315
92137
  var DEFAULT_POSITION = {
92316
92138
  x: 0,
@@ -94556,4 +94378,4 @@ var Shaders$1 = new Shaders();var Shader = function Shader(name, attributes, uni
94556
94378
  } else {
94557
94379
  this.instance = this.shader.instance;
94558
94380
  }
94559
- };var constants = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants), material_constants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,LightLoader$1 as LightLoader,Lights$1 as Lights,Line,MeshLoader$1 as MeshLoader,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$3 as xstate};
94381
+ };var constants = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, lib_constants), light_contants), material_constants);export{AUDIO_RAMPS,AmbientLight,AmbientSound,Atmosphere,Audio$1 as Audio,Axes,BUILTIN,BaseScript,Box,Camera,Color,Cone,Config$1 as Config,Controls$1 as Controls,Cube,CurveLine,Cylinder,DirectionalSound,ENTITY_EVENTS,ENTITY_TYPES,Element$1 as Element,Entity,EventDispatcher,FEATURES,Features$1 as Features,GameRunner$1 as GameRunner,Grid,HelperSprite,HemisphereLight,INPUT_EVENTS,Images$1 as Images,Input$1 as Input,Label,LabelComponent,Level,Lights$1 as Lights,Line,Mirror,Models$1 as Models,Ocean,PALETTES,PARTICLES,constants$1 as PHYSICS_CONSTANTS,PHYSICS_EVENTS,ParticleEmitter,ParticleEmitterGroup,Particles$1 as Particles,index$1 as Partykals,Physics$1 as Physics,Plane,PointLight,PostProcessing$1 as PostProcessing,Proton,ProtonParticleEmitter,Provider,Router$1 as Router,Scene$1 as Scene,Scripts$1 as Scripts,Shader,Sky,Skybox,Sound,Sphere,SpotLight,Sprite,Stats$1 as Stats,SunLight,three_module as THREE,Universe$1 as Universe,Vector3$1 as Vector3,Water,author,connect,constants,createElement,easing,functions,hitbox as hitboxUtils,index_esm as inferno,math,utils as physicsUtils,index$2 as rxjs,index as store,strings,uuid$1 as uuid,workers,index$3 as xstate};