mage-engine 3.17.6 → 3.17.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mage.js +1458 -1388
- package/package.json +1 -1
package/dist/mage.js
CHANGED
|
@@ -53545,7 +53545,8 @@ if ( typeof window !== 'undefined' ) {
|
|
|
53545
53545
|
}var three_module=/*#__PURE__*/Object.freeze({__proto__:null,ACESFilmicToneMapping:ACESFilmicToneMapping,AddEquation:AddEquation,AddOperation:AddOperation,AdditiveAnimationBlendMode:AdditiveAnimationBlendMode,AdditiveBlending:AdditiveBlending,AlphaFormat:AlphaFormat,AlwaysDepth:AlwaysDepth,AlwaysStencilFunc:AlwaysStencilFunc,AmbientLight:AmbientLight$1,AmbientLightProbe:AmbientLightProbe,AnimationClip:AnimationClip,AnimationLoader:AnimationLoader,AnimationMixer:AnimationMixer,AnimationObjectGroup:AnimationObjectGroup,AnimationUtils:AnimationUtils,ArcCurve:ArcCurve,ArrayCamera:ArrayCamera,ArrowHelper:ArrowHelper,Audio:Audio$2,AudioAnalyser:AudioAnalyser,AudioContext:AudioContext,AudioListener:AudioListener,AudioLoader:AudioLoader,AxesHelper:AxesHelper,AxisHelper:AxisHelper,BackSide:BackSide,BasicDepthPacking:BasicDepthPacking,BasicShadowMap:BasicShadowMap,BinaryTextureLoader:BinaryTextureLoader,Bone:Bone,BooleanKeyframeTrack:BooleanKeyframeTrack,BoundingBoxHelper:BoundingBoxHelper,Box2:Box2,Box3:Box3,Box3Helper:Box3Helper,BoxBufferGeometry:BoxGeometry,BoxGeometry:BoxGeometry,BoxHelper:BoxHelper,BufferAttribute:BufferAttribute,BufferGeometry:BufferGeometry,BufferGeometryLoader:BufferGeometryLoader,ByteType:ByteType,Cache:Cache,Camera:Camera$1,CameraHelper:CameraHelper,CanvasRenderer:CanvasRenderer,CanvasTexture:CanvasTexture,CatmullRomCurve3:CatmullRomCurve3,CineonToneMapping:CineonToneMapping,CircleBufferGeometry:CircleGeometry,CircleGeometry:CircleGeometry,ClampToEdgeWrapping:ClampToEdgeWrapping,Clock:Clock,Color:Color$1,ColorKeyframeTrack:ColorKeyframeTrack,CompressedTexture:CompressedTexture,CompressedTextureLoader:CompressedTextureLoader,ConeBufferGeometry:ConeGeometry,ConeGeometry:ConeGeometry,CubeCamera:CubeCamera,CubeReflectionMapping:CubeReflectionMapping,CubeRefractionMapping:CubeRefractionMapping,CubeTexture:CubeTexture,CubeTextureLoader:CubeTextureLoader,CubeUVReflectionMapping:CubeUVReflectionMapping,CubeUVRefractionMapping:CubeUVRefractionMapping,CubicBezierCurve:CubicBezierCurve,CubicBezierCurve3:CubicBezierCurve3,CubicInterpolant:CubicInterpolant,CullFaceBack:CullFaceBack,CullFaceFront:CullFaceFront,CullFaceFrontBack:CullFaceFrontBack,CullFaceNone:CullFaceNone,Curve:Curve,CurvePath:CurvePath,CustomBlending:CustomBlending,CustomToneMapping:CustomToneMapping,CylinderBufferGeometry:CylinderGeometry,CylinderGeometry:CylinderGeometry,Cylindrical:Cylindrical,DataTexture:DataTexture,DataTexture2DArray:DataTexture2DArray,DataTexture3D:DataTexture3D,DataTextureLoader:DataTextureLoader,DataUtils:DataUtils,DecrementStencilOp:DecrementStencilOp,DecrementWrapStencilOp:DecrementWrapStencilOp,DefaultLoadingManager:DefaultLoadingManager,DepthFormat:DepthFormat,DepthStencilFormat:DepthStencilFormat,DepthTexture:DepthTexture,DirectionalLight:DirectionalLight,DirectionalLightHelper:DirectionalLightHelper,DiscreteInterpolant:DiscreteInterpolant,DodecahedronBufferGeometry:DodecahedronGeometry,DodecahedronGeometry:DodecahedronGeometry,DoubleSide:DoubleSide,DstAlphaFactor:DstAlphaFactor,DstColorFactor:DstColorFactor,DynamicBufferAttribute:DynamicBufferAttribute,DynamicCopyUsage:DynamicCopyUsage,DynamicDrawUsage:DynamicDrawUsage,DynamicReadUsage:DynamicReadUsage,EdgesGeometry:EdgesGeometry,EdgesHelper:EdgesHelper,EllipseCurve:EllipseCurve,EqualDepth:EqualDepth,EqualStencilFunc:EqualStencilFunc,EquirectangularReflectionMapping:EquirectangularReflectionMapping,EquirectangularRefractionMapping:EquirectangularRefractionMapping,Euler:Euler,EventDispatcher:EventDispatcher,ExtrudeBufferGeometry:ExtrudeGeometry,ExtrudeGeometry:ExtrudeGeometry,FaceColors:FaceColors,FileLoader:FileLoader,FlatShading:FlatShading,Float16BufferAttribute:Float16BufferAttribute,Float32Attribute:Float32Attribute,Float32BufferAttribute:Float32BufferAttribute,Float64Attribute:Float64Attribute,Float64BufferAttribute:Float64BufferAttribute,FloatType:FloatType$1,Fog:Fog,FogExp2:FogExp2,Font:Font,FontLoader:FontLoader,FrontSide:FrontSide,Frustum:Frustum$1,GLBufferAttribute:GLBufferAttribute,GLSL1:GLSL1,GLSL3:GLSL3,GammaEncoding:GammaEncoding,GreaterDepth:GreaterDepth,GreaterEqualDepth:GreaterEqualDepth,GreaterEqualStencilFunc:GreaterEqualStencilFunc,GreaterStencilFunc:GreaterStencilFunc,GridHelper:GridHelper,Group:Group,HalfFloatType:HalfFloatType,HemisphereLight:HemisphereLight$1,HemisphereLightHelper:HemisphereLightHelper,HemisphereLightProbe:HemisphereLightProbe,IcosahedronBufferGeometry:IcosahedronGeometry,IcosahedronGeometry:IcosahedronGeometry,ImageBitmapLoader:ImageBitmapLoader,ImageLoader:ImageLoader,ImageUtils:ImageUtils,ImmediateRenderObject:ImmediateRenderObject,IncrementStencilOp:IncrementStencilOp,IncrementWrapStencilOp:IncrementWrapStencilOp,InstancedBufferAttribute:InstancedBufferAttribute,InstancedBufferGeometry:InstancedBufferGeometry,InstancedInterleavedBuffer:InstancedInterleavedBuffer,InstancedMesh:InstancedMesh,Int16Attribute:Int16Attribute,Int16BufferAttribute:Int16BufferAttribute,Int32Attribute:Int32Attribute,Int32BufferAttribute:Int32BufferAttribute,Int8Attribute:Int8Attribute,Int8BufferAttribute:Int8BufferAttribute,IntType:IntType,InterleavedBuffer:InterleavedBuffer,InterleavedBufferAttribute:InterleavedBufferAttribute,Interpolant:Interpolant,InterpolateDiscrete:InterpolateDiscrete,InterpolateLinear:InterpolateLinear,InterpolateSmooth:InterpolateSmooth,InvertStencilOp:InvertStencilOp,JSONLoader:JSONLoader,KeepStencilOp:KeepStencilOp,KeyframeTrack:KeyframeTrack,LOD:LOD,LatheBufferGeometry:LatheGeometry,LatheGeometry:LatheGeometry,Layers:Layers,LensFlare:LensFlare,LessDepth:LessDepth,LessEqualDepth:LessEqualDepth,LessEqualStencilFunc:LessEqualStencilFunc,LessStencilFunc:LessStencilFunc,Light:Light$1,LightProbe:LightProbe,Line:Line$1,Line3:Line3,LineBasicMaterial:LineBasicMaterial,LineCurve:LineCurve,LineCurve3:LineCurve3,LineDashedMaterial:LineDashedMaterial,LineLoop:LineLoop,LinePieces:LinePieces,LineSegments:LineSegments,LineStrip:LineStrip,LinearEncoding:LinearEncoding,LinearFilter:LinearFilter,LinearInterpolant:LinearInterpolant,LinearMipMapLinearFilter:LinearMipMapLinearFilter,LinearMipMapNearestFilter:LinearMipMapNearestFilter,LinearMipmapLinearFilter:LinearMipmapLinearFilter,LinearMipmapNearestFilter:LinearMipmapNearestFilter,LinearToneMapping:LinearToneMapping,Loader:Loader$1,LoaderUtils:LoaderUtils,LoadingManager:LoadingManager,LogLuvEncoding:LogLuvEncoding,LoopOnce:LoopOnce,LoopPingPong:LoopPingPong,LoopRepeat:LoopRepeat,LuminanceAlphaFormat:LuminanceAlphaFormat,LuminanceFormat:LuminanceFormat,MOUSE:MOUSE,Material:Material,MaterialLoader:MaterialLoader,Math:MathUtils,MathUtils:MathUtils,Matrix3:Matrix3,Matrix4:Matrix4,MaxEquation:MaxEquation,Mesh:Mesh,MeshBasicMaterial:MeshBasicMaterial,MeshDepthMaterial:MeshDepthMaterial,MeshDistanceMaterial:MeshDistanceMaterial,MeshFaceMaterial:MeshFaceMaterial,MeshLambertMaterial:MeshLambertMaterial,MeshMatcapMaterial:MeshMatcapMaterial,MeshNormalMaterial:MeshNormalMaterial,MeshPhongMaterial:MeshPhongMaterial,MeshPhysicalMaterial:MeshPhysicalMaterial,MeshStandardMaterial:MeshStandardMaterial,MeshToonMaterial:MeshToonMaterial,MinEquation:MinEquation,MirroredRepeatWrapping:MirroredRepeatWrapping,MixOperation:MixOperation,MultiMaterial:MultiMaterial,MultiplyBlending:MultiplyBlending,MultiplyOperation:MultiplyOperation,NearestFilter:NearestFilter,NearestMipMapLinearFilter:NearestMipMapLinearFilter,NearestMipMapNearestFilter:NearestMipMapNearestFilter,NearestMipmapLinearFilter:NearestMipmapLinearFilter,NearestMipmapNearestFilter:NearestMipmapNearestFilter,NeverDepth:NeverDepth,NeverStencilFunc:NeverStencilFunc,NoBlending:NoBlending,NoColors:NoColors,NoToneMapping:NoToneMapping,NormalAnimationBlendMode:NormalAnimationBlendMode,NormalBlending:NormalBlending,NotEqualDepth:NotEqualDepth,NotEqualStencilFunc:NotEqualStencilFunc,NumberKeyframeTrack:NumberKeyframeTrack,Object3D:Object3D,ObjectLoader:ObjectLoader,ObjectSpaceNormalMap:ObjectSpaceNormalMap,OctahedronBufferGeometry:OctahedronGeometry,OctahedronGeometry:OctahedronGeometry,OneFactor:OneFactor,OneMinusDstAlphaFactor:OneMinusDstAlphaFactor,OneMinusDstColorFactor:OneMinusDstColorFactor,OneMinusSrcAlphaFactor:OneMinusSrcAlphaFactor,OneMinusSrcColorFactor:OneMinusSrcColorFactor,OrthographicCamera:OrthographicCamera,PCFShadowMap:PCFShadowMap,PCFSoftShadowMap:PCFSoftShadowMap,PMREMGenerator:PMREMGenerator,ParametricBufferGeometry:ParametricGeometry,ParametricGeometry:ParametricGeometry,Particle:Particle,ParticleBasicMaterial:ParticleBasicMaterial,ParticleSystem:ParticleSystem,ParticleSystemMaterial:ParticleSystemMaterial,Path:Path,PerspectiveCamera:PerspectiveCamera,Plane:Plane$1,PlaneBufferGeometry:PlaneGeometry,PlaneGeometry:PlaneGeometry,PlaneHelper:PlaneHelper,PointCloud:PointCloud,PointCloudMaterial:PointCloudMaterial,PointLight:PointLight$1,PointLightHelper:PointLightHelper,Points:Points,PointsMaterial:PointsMaterial,PolarGridHelper:PolarGridHelper,PolyhedronBufferGeometry:PolyhedronGeometry,PolyhedronGeometry:PolyhedronGeometry,PositionalAudio:PositionalAudio,PropertyBinding:PropertyBinding,PropertyMixer:PropertyMixer,QuadraticBezierCurve:QuadraticBezierCurve,QuadraticBezierCurve3:QuadraticBezierCurve3,Quaternion:Quaternion,QuaternionKeyframeTrack:QuaternionKeyframeTrack,QuaternionLinearInterpolant:QuaternionLinearInterpolant,REVISION:REVISION,RGBADepthPacking:RGBADepthPacking,RGBAFormat:RGBAFormat,RGBAIntegerFormat:RGBAIntegerFormat,RGBA_ASTC_10x10_Format:RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format:RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format:RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format:RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format:RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format:RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format:RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format:RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format:RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format:RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format:RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format:RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format:RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format:RGBA_ASTC_8x8_Format,RGBA_BPTC_Format:RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format:RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format:RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format:RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format:RGBA_S3TC_DXT5_Format,RGBDEncoding:RGBDEncoding,RGBEEncoding:RGBEEncoding,RGBEFormat:RGBEFormat,RGBFormat:RGBFormat,RGBIntegerFormat:RGBIntegerFormat,RGBM16Encoding:RGBM16Encoding,RGBM7Encoding:RGBM7Encoding,RGB_ETC1_Format:RGB_ETC1_Format,RGB_ETC2_Format:RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format:RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format:RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format:RGB_S3TC_DXT1_Format,RGFormat:RGFormat,RGIntegerFormat:RGIntegerFormat,RawShaderMaterial:RawShaderMaterial,Ray:Ray,Raycaster:Raycaster,RectAreaLight:RectAreaLight,RedFormat:RedFormat,RedIntegerFormat:RedIntegerFormat,ReinhardToneMapping:ReinhardToneMapping,RepeatWrapping:RepeatWrapping$1,ReplaceStencilOp:ReplaceStencilOp,ReverseSubtractEquation:ReverseSubtractEquation,RingBufferGeometry:RingGeometry,RingGeometry:RingGeometry,SRGB8_ALPHA8_ASTC_10x10_Format:SRGB8_ALPHA8_ASTC_10x10_Format,SRGB8_ALPHA8_ASTC_10x5_Format:SRGB8_ALPHA8_ASTC_10x5_Format,SRGB8_ALPHA8_ASTC_10x6_Format:SRGB8_ALPHA8_ASTC_10x6_Format,SRGB8_ALPHA8_ASTC_10x8_Format:SRGB8_ALPHA8_ASTC_10x8_Format,SRGB8_ALPHA8_ASTC_12x10_Format:SRGB8_ALPHA8_ASTC_12x10_Format,SRGB8_ALPHA8_ASTC_12x12_Format:SRGB8_ALPHA8_ASTC_12x12_Format,SRGB8_ALPHA8_ASTC_4x4_Format:SRGB8_ALPHA8_ASTC_4x4_Format,SRGB8_ALPHA8_ASTC_5x4_Format:SRGB8_ALPHA8_ASTC_5x4_Format,SRGB8_ALPHA8_ASTC_5x5_Format:SRGB8_ALPHA8_ASTC_5x5_Format,SRGB8_ALPHA8_ASTC_6x5_Format:SRGB8_ALPHA8_ASTC_6x5_Format,SRGB8_ALPHA8_ASTC_6x6_Format:SRGB8_ALPHA8_ASTC_6x6_Format,SRGB8_ALPHA8_ASTC_8x5_Format:SRGB8_ALPHA8_ASTC_8x5_Format,SRGB8_ALPHA8_ASTC_8x6_Format:SRGB8_ALPHA8_ASTC_8x6_Format,SRGB8_ALPHA8_ASTC_8x8_Format:SRGB8_ALPHA8_ASTC_8x8_Format,Scene:Scene$2,SceneUtils:SceneUtils,ShaderChunk:ShaderChunk,ShaderLib:ShaderLib,ShaderMaterial:ShaderMaterial,ShadowMaterial:ShadowMaterial,Shape:Shape,ShapeBufferGeometry:ShapeGeometry,ShapeGeometry:ShapeGeometry,ShapePath:ShapePath,ShapeUtils:ShapeUtils,ShortType:ShortType,Skeleton:Skeleton,SkeletonHelper:SkeletonHelper,SkinnedMesh:SkinnedMesh,SmoothShading:SmoothShading,Sphere:Sphere$1,SphereBufferGeometry:SphereGeometry,SphereGeometry:SphereGeometry,Spherical:Spherical,SphericalHarmonics3:SphericalHarmonics3,SplineCurve:SplineCurve,SpotLight:SpotLight$1,SpotLightHelper:SpotLightHelper,Sprite:Sprite$1,SpriteMaterial:SpriteMaterial,SrcAlphaFactor:SrcAlphaFactor,SrcAlphaSaturateFactor:SrcAlphaSaturateFactor,SrcColorFactor:SrcColorFactor,StaticCopyUsage:StaticCopyUsage,StaticDrawUsage:StaticDrawUsage,StaticReadUsage:StaticReadUsage,StereoCamera:StereoCamera,StreamCopyUsage:StreamCopyUsage,StreamDrawUsage:StreamDrawUsage,StreamReadUsage:StreamReadUsage,StringKeyframeTrack:StringKeyframeTrack,SubtractEquation:SubtractEquation,SubtractiveBlending:SubtractiveBlending,TOUCH:TOUCH,TangentSpaceNormalMap:TangentSpaceNormalMap,TetrahedronBufferGeometry:TetrahedronGeometry,TetrahedronGeometry:TetrahedronGeometry,TextBufferGeometry:TextGeometry,TextGeometry:TextGeometry,Texture:Texture,TextureLoader:TextureLoader,TorusBufferGeometry:TorusGeometry,TorusGeometry:TorusGeometry,TorusKnotBufferGeometry:TorusKnotGeometry,TorusKnotGeometry:TorusKnotGeometry,Triangle:Triangle,TriangleFanDrawMode:TriangleFanDrawMode,TriangleStripDrawMode:TriangleStripDrawMode,TrianglesDrawMode:TrianglesDrawMode,TubeBufferGeometry:TubeGeometry,TubeGeometry:TubeGeometry,UVMapping:UVMapping,Uint16Attribute:Uint16Attribute,Uint16BufferAttribute:Uint16BufferAttribute,Uint32Attribute:Uint32Attribute,Uint32BufferAttribute:Uint32BufferAttribute,Uint8Attribute:Uint8Attribute,Uint8BufferAttribute:Uint8BufferAttribute,Uint8ClampedAttribute:Uint8ClampedAttribute,Uint8ClampedBufferAttribute:Uint8ClampedBufferAttribute,Uniform:Uniform,UniformsLib:UniformsLib,UniformsUtils:UniformsUtils,UnsignedByteType:UnsignedByteType,UnsignedInt248Type:UnsignedInt248Type,UnsignedIntType:UnsignedIntType,UnsignedShort4444Type:UnsignedShort4444Type,UnsignedShort5551Type:UnsignedShort5551Type,UnsignedShort565Type:UnsignedShort565Type,UnsignedShortType:UnsignedShortType,VSMShadowMap:VSMShadowMap,Vector2:Vector2,Vector3:Vector3$1,Vector4:Vector4,VectorKeyframeTrack:VectorKeyframeTrack,Vertex:Vertex,VertexColors:VertexColors,VideoTexture:VideoTexture,WebGL1Renderer:WebGL1Renderer,WebGLCubeRenderTarget:WebGLCubeRenderTarget,WebGLMultisampleRenderTarget:WebGLMultisampleRenderTarget,WebGLRenderTarget:WebGLRenderTarget,WebGLRenderTargetCube:WebGLRenderTargetCube,WebGLRenderer:WebGLRenderer,WebGLUtils:WebGLUtils,WireframeGeometry:WireframeGeometry,WireframeHelper:WireframeHelper,WrapAroundEnding:WrapAroundEnding,XHRLoader:XHRLoader,ZeroCurvatureEnding:ZeroCurvatureEnding,ZeroFactor:ZeroFactor,ZeroSlopeEnding:ZeroSlopeEnding,ZeroStencilOp:ZeroStencilOp,sRGBEncoding:sRGBEncoding});var PREFIX = '[Mage]';
|
|
53546
53546
|
var DEPRECATED = '[DEPRECATED]';
|
|
53547
53547
|
var DEPRECATIONS = {
|
|
53548
|
-
|
|
53548
|
+
PARTICLES_ADD_PARTICLE_EMITTER: "".concat(PREFIX, " ").concat(DEPRECATED, " Particles.addParticleEmitter is deprecated, use Particles.add instead. Will be removed in the next major release"),
|
|
53549
|
+
MODELS_GETMODEL: "".concat(PREFIX, " ").concat(DEPRECATED, " Models.getModel is deprecated, use Models.get instead. Will be removed in next major release"),
|
|
53549
53550
|
SCRIPTS_CREATE: "".concat(PREFIX, " ").concat(DEPRECATED, " Scripts.create is deprecated, use Scripts.register instead. Will be removed in next major release."),
|
|
53550
53551
|
ELEMENT_SET_TEXTURE_MAP: "".concat(PREFIX, " ").concat(DEPRECATED, " Element.setTextureMap is deprecated, use Element.setTexture() instead. Will be removed in next major release.")
|
|
53551
53552
|
};
|
|
@@ -53594,9 +53595,24 @@ var LIGHT_HOLDER_MODEL_NOT_FOUND = "".concat(PREFIX, " This light holder model c
|
|
|
53594
53595
|
}
|
|
53595
53596
|
}, {
|
|
53596
53597
|
key: "__hasStarted",
|
|
53597
|
-
value: function __hasStarted(
|
|
53598
|
+
value: function __hasStarted() {
|
|
53599
|
+
return this.hasStarted;
|
|
53600
|
+
}
|
|
53601
|
+
}, {
|
|
53602
|
+
key: "__isDisposed",
|
|
53603
|
+
value: function __isDisposed() {
|
|
53604
|
+
return this.isDisposed;
|
|
53605
|
+
}
|
|
53606
|
+
}, {
|
|
53607
|
+
key: "__setStartedFlag",
|
|
53608
|
+
value: function __setStartedFlag(flag) {
|
|
53598
53609
|
this.hasStarted = flag;
|
|
53599
53610
|
}
|
|
53611
|
+
}, {
|
|
53612
|
+
key: "__setDisposedFlag",
|
|
53613
|
+
value: function __setDisposedFlag(flag) {
|
|
53614
|
+
this.isDisposed = flag;
|
|
53615
|
+
}
|
|
53600
53616
|
}]);
|
|
53601
53617
|
|
|
53602
53618
|
function BaseScript(name) {
|
|
@@ -54479,9 +54495,8 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
|
|
|
54479
54495
|
});
|
|
54480
54496
|
|
|
54481
54497
|
_defineProperty$1(this, "forEach", function (callback) {
|
|
54482
|
-
|
|
54483
|
-
|
|
54484
|
-
return callback(_this.reality[k]);
|
|
54498
|
+
Object.keys(_this.reality).forEach(function (k) {
|
|
54499
|
+
return callback(_this.reality[k], k);
|
|
54485
54500
|
});
|
|
54486
54501
|
});
|
|
54487
54502
|
|
|
@@ -54489,14 +54504,14 @@ var Config$1 = new Config();var Universe = /*#__PURE__*/function () {
|
|
|
54489
54504
|
var keys = Object.keys(_this.reality);
|
|
54490
54505
|
return new Promise(function (resolve) {
|
|
54491
54506
|
Promise.all(keys.map(function (k) {
|
|
54492
|
-
return callback(_this.reality[k]);
|
|
54507
|
+
return callback(_this.reality[k], k);
|
|
54493
54508
|
})).then(resolve);
|
|
54494
54509
|
});
|
|
54495
54510
|
});
|
|
54496
54511
|
|
|
54497
54512
|
_defineProperty$1(this, "bigfreeze", function () {
|
|
54498
54513
|
_this.forEach(function (o) {
|
|
54499
|
-
|
|
54514
|
+
o && o.dispose && o.dispose();
|
|
54500
54515
|
});
|
|
54501
54516
|
|
|
54502
54517
|
_this.reset();
|
|
@@ -54913,8 +54928,12 @@ function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
|
54913
54928
|
}
|
|
54914
54929
|
};var PI = Math.PI;
|
|
54915
54930
|
var PI_2$1 = PI / 2;
|
|
54916
|
-
var
|
|
54917
|
-
return
|
|
54931
|
+
var identity = function identity(a) {
|
|
54932
|
+
return a;
|
|
54933
|
+
};
|
|
54934
|
+
var pickRandom = function pickRandom() {
|
|
54935
|
+
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
54936
|
+
return list[Math.floor(Math.random() * list.length)];
|
|
54918
54937
|
};
|
|
54919
54938
|
var degToRad = function degToRad(angle) {
|
|
54920
54939
|
return angle * (PI / 180);
|
|
@@ -55041,7 +55060,7 @@ var smoothDampAngle = function smoothDampAngle(current, target, currentVelocity,
|
|
|
55041
55060
|
var dt = arguments.length > 5 ? arguments[5] : undefined;
|
|
55042
55061
|
target = current + deltaAngle(current, target);
|
|
55043
55062
|
return smoothDamp(current, target, currentVelocity, smoothTime, maxSpeed, dt);
|
|
55044
|
-
};var math=/*#__PURE__*/Object.freeze({__proto__:null,PI:PI,PI_2:PI_2$1,pickRandom:pickRandom,degToRad:degToRad,getProportion:getProportion,clamp:clamp,isWithin:isWithin,randomIntFromInterval:randomIntFromInterval,getDistance:getDistance,findPointBetweenAtDistance:findPointBetweenAtDistance,lerpVectors:lerpVectors,lerp:lerp,scaleVector:scaleVector,getSphereVolume:getSphereVolume,repeat:repeat,deltaAngle:deltaAngle,smoothDamp:smoothDamp,smoothDampAngle:smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
|
|
55063
|
+
};var math=/*#__PURE__*/Object.freeze({__proto__:null,PI:PI,PI_2:PI_2$1,identity:identity,pickRandom:pickRandom,degToRad:degToRad,getProportion:getProportion,clamp:clamp,isWithin:isWithin,randomIntFromInterval:randomIntFromInterval,getDistance:getDistance,findPointBetweenAtDistance:findPointBetweenAtDistance,lerpVectors:lerpVectors,lerp:lerp,scaleVector:scaleVector,getSphereVolume:getSphereVolume,repeat:repeat,deltaAngle:deltaAngle,smoothDamp:smoothDamp,smoothDampAngle:smoothDampAngle});var LIBRARY_NAME = 'ammo.js';
|
|
55045
55064
|
var TYPES = {
|
|
55046
55065
|
BOX: 'BOX',
|
|
55047
55066
|
SPHERE: 'SPHERE',
|
|
@@ -55501,17 +55520,6 @@ var Physics = /*#__PURE__*/function (_EventDispatcher) {
|
|
|
55501
55520
|
}
|
|
55502
55521
|
});
|
|
55503
55522
|
|
|
55504
|
-
_defineProperty$1(_assertThisInitialized(_this), "disposeElement", function (element) {
|
|
55505
|
-
if (Config$1.physics().enabled) {
|
|
55506
|
-
var uuid = element.uuid();
|
|
55507
|
-
|
|
55508
|
-
_this.worker.postMessage({
|
|
55509
|
-
event: PHYSICS_EVENTS.ELEMENT.DISPOSE,
|
|
55510
|
-
uuid: uuid
|
|
55511
|
-
});
|
|
55512
|
-
}
|
|
55513
|
-
});
|
|
55514
|
-
|
|
55515
55523
|
_defineProperty$1(_assertThisInitialized(_this), "explosion", function (element, strength, radius) {
|
|
55516
55524
|
if (Config$1.physics().enabled) {
|
|
55517
55525
|
var uuid = element.uuid();
|
|
@@ -57196,7 +57204,7 @@ function applyMiddleware() {
|
|
|
57196
57204
|
|
|
57197
57205
|
var thunk = createThunkMiddleware();
|
|
57198
57206
|
thunk.withExtraArgument = createThunkMiddleware;var name = "mage-engine";
|
|
57199
|
-
var version = "3.17.
|
|
57207
|
+
var version = "3.17.7";
|
|
57200
57208
|
var description = "A WebGL Javascript Game Engine, built on top of THREE.js and many other libraries.";
|
|
57201
57209
|
var main = "dist/mage.js";
|
|
57202
57210
|
var author$1 = {
|
|
@@ -58712,1601 +58720,1642 @@ var Scripts = /*#__PURE__*/function () {
|
|
|
58712
58720
|
|
|
58713
58721
|
return Scripts;
|
|
58714
58722
|
}();
|
|
58715
|
-
var Scripts$1 = new Scripts();var
|
|
58716
|
-
_inherits(Entity, _EventDispatcher);
|
|
58723
|
+
var Scripts$1 = new Scripts();var inverseProjectionMatrix = new Matrix4();
|
|
58717
58724
|
|
|
58718
|
-
|
|
58725
|
+
var Frustum = /*#__PURE__*/function () {
|
|
58726
|
+
function Frustum(data) {
|
|
58727
|
+
_classCallCheck(this, Frustum);
|
|
58719
58728
|
|
|
58720
|
-
|
|
58721
|
-
|
|
58729
|
+
data = data || {};
|
|
58730
|
+
this.vertices = {
|
|
58731
|
+
near: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()],
|
|
58732
|
+
far: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()]
|
|
58733
|
+
};
|
|
58722
58734
|
|
|
58723
|
-
|
|
58724
|
-
|
|
58725
|
-
|
|
58726
|
-
|
|
58727
|
-
tag = _ref$tag === void 0 ? '' : _ref$tag,
|
|
58728
|
-
_ref$tags = _ref.tags,
|
|
58729
|
-
tags = _ref$tags === void 0 ? [] : _ref$tags;
|
|
58735
|
+
if (data.projectionMatrix !== undefined) {
|
|
58736
|
+
this.setFromProjectionMatrix(data.projectionMatrix, data.maxFar || 10000);
|
|
58737
|
+
}
|
|
58738
|
+
}
|
|
58730
58739
|
|
|
58731
|
-
|
|
58740
|
+
_createClass(Frustum, [{
|
|
58741
|
+
key: "setFromProjectionMatrix",
|
|
58742
|
+
value: function setFromProjectionMatrix(projectionMatrix, maxFar) {
|
|
58743
|
+
var isOrthographic = projectionMatrix.elements[2 * 4 + 3] === 0;
|
|
58744
|
+
inverseProjectionMatrix.copy(projectionMatrix).invert(); // 3 --- 0 vertices.near/far order
|
|
58745
|
+
// | |
|
|
58746
|
+
// 2 --- 1
|
|
58747
|
+
// clip space spans from [-1, 1]
|
|
58732
58748
|
|
|
58733
|
-
|
|
58749
|
+
this.vertices.near[0].set(1, 1, -1);
|
|
58750
|
+
this.vertices.near[1].set(1, -1, -1);
|
|
58751
|
+
this.vertices.near[2].set(-1, -1, -1);
|
|
58752
|
+
this.vertices.near[3].set(-1, 1, -1);
|
|
58753
|
+
this.vertices.near.forEach(function (v) {
|
|
58754
|
+
v.applyMatrix4(inverseProjectionMatrix);
|
|
58755
|
+
});
|
|
58756
|
+
this.vertices.far[0].set(1, 1, 1);
|
|
58757
|
+
this.vertices.far[1].set(1, -1, 1);
|
|
58758
|
+
this.vertices.far[2].set(-1, -1, 1);
|
|
58759
|
+
this.vertices.far[3].set(-1, 1, 1);
|
|
58760
|
+
this.vertices.far.forEach(function (v) {
|
|
58761
|
+
v.applyMatrix4(inverseProjectionMatrix);
|
|
58762
|
+
var absZ = Math.abs(v.z);
|
|
58734
58763
|
|
|
58735
|
-
|
|
58736
|
-
|
|
58737
|
-
|
|
58764
|
+
if (isOrthographic) {
|
|
58765
|
+
v.z *= Math.min(maxFar / absZ, 1.0);
|
|
58766
|
+
} else {
|
|
58767
|
+
v.multiplyScalar(Math.min(maxFar / absZ, 1.0));
|
|
58768
|
+
}
|
|
58769
|
+
});
|
|
58770
|
+
return this.vertices;
|
|
58771
|
+
}
|
|
58772
|
+
}, {
|
|
58773
|
+
key: "split",
|
|
58774
|
+
value: function split(breaks, target) {
|
|
58775
|
+
while (breaks.length > target.length) {
|
|
58776
|
+
target.push(new Frustum());
|
|
58738
58777
|
}
|
|
58739
58778
|
|
|
58740
|
-
|
|
58741
|
-
});
|
|
58779
|
+
target.length = breaks.length;
|
|
58742
58780
|
|
|
58743
|
-
|
|
58744
|
-
|
|
58781
|
+
for (var i = 0; i < breaks.length; i++) {
|
|
58782
|
+
var cascade = target[i];
|
|
58745
58783
|
|
|
58746
|
-
|
|
58747
|
-
|
|
58784
|
+
if (i === 0) {
|
|
58785
|
+
for (var j = 0; j < 4; j++) {
|
|
58786
|
+
cascade.vertices.near[j].copy(this.vertices.near[j]);
|
|
58787
|
+
}
|
|
58788
|
+
} else {
|
|
58789
|
+
for (var _j = 0; _j < 4; _j++) {
|
|
58790
|
+
cascade.vertices.near[_j].lerpVectors(this.vertices.near[_j], this.vertices.far[_j], breaks[i - 1]);
|
|
58791
|
+
}
|
|
58792
|
+
}
|
|
58748
58793
|
|
|
58749
|
-
|
|
58750
|
-
|
|
58751
|
-
|
|
58752
|
-
|
|
58794
|
+
if (i === breaks - 1) {
|
|
58795
|
+
for (var _j2 = 0; _j2 < 4; _j2++) {
|
|
58796
|
+
cascade.vertices.far[_j2].copy(this.vertices.far[_j2]);
|
|
58797
|
+
}
|
|
58798
|
+
} else {
|
|
58799
|
+
for (var _j3 = 0; _j3 < 4; _j3++) {
|
|
58800
|
+
cascade.vertices.far[_j3].lerpVectors(this.vertices.near[_j3], this.vertices.far[_j3], breaks[i]);
|
|
58801
|
+
}
|
|
58802
|
+
}
|
|
58753
58803
|
}
|
|
58754
|
-
}
|
|
58755
|
-
|
|
58756
|
-
|
|
58757
|
-
|
|
58758
|
-
|
|
58759
|
-
|
|
58760
|
-
|
|
58761
|
-
|
|
58762
|
-
}
|
|
58763
|
-
|
|
58764
|
-
_defineProperty$1(_assertThisInitialized(_this), "parseScripts", function (list, options, enabled) {
|
|
58765
|
-
return list.map(function (script, i) {
|
|
58766
|
-
return {
|
|
58767
|
-
script: script,
|
|
58768
|
-
name: script.getName(),
|
|
58769
|
-
enabled: enabled,
|
|
58770
|
-
options: options[i]
|
|
58771
|
-
};
|
|
58772
|
-
});
|
|
58773
|
-
});
|
|
58774
|
-
|
|
58775
|
-
_defineProperty$1(_assertThisInitialized(_this), "isMesh", function () {
|
|
58776
|
-
return _this.getEntityType() === ENTITY_TYPES.MESH;
|
|
58777
|
-
});
|
|
58778
|
-
|
|
58779
|
-
_defineProperty$1(_assertThisInitialized(_this), "isModel", function () {
|
|
58780
|
-
return _this.getEntityType() === ENTITY_TYPES.MODEL;
|
|
58781
|
-
});
|
|
58782
|
-
|
|
58783
|
-
_defineProperty$1(_assertThisInitialized(_this), "isSprite", function () {
|
|
58784
|
-
return _this.getEntityType() === ENTITY_TYPES.SPRITE;
|
|
58785
|
-
});
|
|
58804
|
+
}
|
|
58805
|
+
}, {
|
|
58806
|
+
key: "toSpace",
|
|
58807
|
+
value: function toSpace(cameraMatrix, target) {
|
|
58808
|
+
for (var i = 0; i < 4; i++) {
|
|
58809
|
+
target.vertices.near[i].copy(this.vertices.near[i]).applyMatrix4(cameraMatrix);
|
|
58810
|
+
target.vertices.far[i].copy(this.vertices.far[i]).applyMatrix4(cameraMatrix);
|
|
58811
|
+
}
|
|
58812
|
+
}
|
|
58813
|
+
}]);
|
|
58786
58814
|
|
|
58787
|
-
|
|
58788
|
-
|
|
58789
|
-
|
|
58815
|
+
return Frustum;
|
|
58816
|
+
}();var Shader$1 = {
|
|
58817
|
+
lights_fragment_begin:
|
|
58818
|
+
/* glsl */
|
|
58819
|
+
"\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n float linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n vec2 cascade;\n float cascadeCenter;\n float closestEdge;\n float margin;\n float csmx;\n float csmy;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n // NOTE: Depth gets larger away from the camera.\n // cascade.x is closer, cascade.y is further\n cascade = CSM_cascades[ i ];\n cascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n margin = 0.25 * pow( closestEdge, 2.0 );\n csmx = cascade.x - margin / 2.0;\n csmy = cascade.y + margin / 2.0;\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS && linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n float dist = min( linearDepth - csmx, csmy - linearDepth );\n float ratio = clamp( dist / margin, 0.0, 1.0 );\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) {\n\n vec3 prevColor = directLight.color;\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n }\n\n ReflectedLight prevLight = reflectedLight;\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n float blendRatio = shouldBlend ? ratio : 1.0;\n\n reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n }\n\n }\n #pragma unroll_loop_end\n #else\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #endif\n\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n RectAreaLight rectAreaLight;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",
|
|
58820
|
+
lights_pars_begin:
|
|
58821
|
+
/* glsl */
|
|
58822
|
+
"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n " + ShaderChunk.lights_pars_begin
|
|
58823
|
+
};var _cameraToLightMatrix = new Matrix4();
|
|
58790
58824
|
|
|
58791
|
-
|
|
58792
|
-
return Object.values(ENTITY_TYPES.HELPER).includes(_this.getEntityType());
|
|
58793
|
-
});
|
|
58825
|
+
var _lightSpaceFrustum = new Frustum();
|
|
58794
58826
|
|
|
58795
|
-
|
|
58796
|
-
return Object.values(ENTITY_TYPES.EFFECT).includes(_this.getEntityType());
|
|
58797
|
-
});
|
|
58827
|
+
var _center = new Vector3$1();
|
|
58798
58828
|
|
|
58799
|
-
|
|
58800
|
-
var x = _ref2.x,
|
|
58801
|
-
y = _ref2.y,
|
|
58802
|
-
z = _ref2.z,
|
|
58803
|
-
w = _ref2.w;
|
|
58829
|
+
var _bbox = new Box3();
|
|
58804
58830
|
|
|
58805
|
-
|
|
58806
|
-
|
|
58831
|
+
var _uniformArray = [];
|
|
58832
|
+
var _logArray = [];
|
|
58833
|
+
var DEFAULT_MAX_FAR = 100000;
|
|
58834
|
+
var DEFAULT_MODE = 'practical';
|
|
58835
|
+
var DEFAULT_SHADOWMAP_SIZE = 2048;
|
|
58836
|
+
var DEFAULT_CASCADE = 3;
|
|
58837
|
+
var DEFAULT_BIAS$3 = 0.000001;
|
|
58838
|
+
var DEFAULT_INTENSITY$5 = 1;
|
|
58839
|
+
var DEFAULT_NEAR$3 = 1;
|
|
58840
|
+
var DEFAULT_FAR$3 = 2000;
|
|
58841
|
+
var DEFAULT_MARGIN = 200;
|
|
58842
|
+
var CascadeShadowMaps = /*#__PURE__*/function () {
|
|
58843
|
+
function CascadeShadowMaps(_ref) {
|
|
58844
|
+
var _ref$camera = _ref.camera,
|
|
58845
|
+
camera = _ref$camera === void 0 ? Scene$1.getCameraBody() : _ref$camera,
|
|
58846
|
+
_ref$parent = _ref.parent,
|
|
58847
|
+
parent = _ref$parent === void 0 ? Scene$1.getScene() : _ref$parent,
|
|
58848
|
+
_ref$cascades = _ref.cascades,
|
|
58849
|
+
cascades = _ref$cascades === void 0 ? DEFAULT_CASCADE : _ref$cascades,
|
|
58850
|
+
_ref$maxFar = _ref.maxFar,
|
|
58851
|
+
maxFar = _ref$maxFar === void 0 ? DEFAULT_MAX_FAR : _ref$maxFar,
|
|
58852
|
+
_ref$mode = _ref.mode,
|
|
58853
|
+
mode = _ref$mode === void 0 ? DEFAULT_MODE : _ref$mode,
|
|
58854
|
+
_ref$shadowMapSize = _ref.shadowMapSize,
|
|
58855
|
+
shadowMapSize = _ref$shadowMapSize === void 0 ? DEFAULT_SHADOWMAP_SIZE : _ref$shadowMapSize,
|
|
58856
|
+
_ref$shadowBias = _ref.shadowBias,
|
|
58857
|
+
shadowBias = _ref$shadowBias === void 0 ? DEFAULT_BIAS$3 : _ref$shadowBias,
|
|
58858
|
+
_ref$lightDirection = _ref.lightDirection,
|
|
58859
|
+
lightDirection = _ref$lightDirection === void 0 ? new Vector3$1(1, -1, 1).normalize() : _ref$lightDirection,
|
|
58860
|
+
_ref$lightIntensity = _ref.lightIntensity,
|
|
58861
|
+
lightIntensity = _ref$lightIntensity === void 0 ? DEFAULT_INTENSITY$5 : _ref$lightIntensity,
|
|
58862
|
+
_ref$lightNear = _ref.lightNear,
|
|
58863
|
+
lightNear = _ref$lightNear === void 0 ? DEFAULT_NEAR$3 : _ref$lightNear,
|
|
58864
|
+
_ref$lightFar = _ref.lightFar,
|
|
58865
|
+
lightFar = _ref$lightFar === void 0 ? DEFAULT_FAR$3 : _ref$lightFar,
|
|
58866
|
+
_ref$lightMargin = _ref.lightMargin,
|
|
58867
|
+
lightMargin = _ref$lightMargin === void 0 ? DEFAULT_MARGIN : _ref$lightMargin,
|
|
58868
|
+
customSplitsCallback = _ref.customSplitsCallback;
|
|
58807
58869
|
|
|
58808
|
-
|
|
58809
|
-
if (uuid) {
|
|
58810
|
-
_this.body.uuid = uuid;
|
|
58811
|
-
}
|
|
58812
|
-
});
|
|
58870
|
+
_classCallCheck(this, CascadeShadowMaps);
|
|
58813
58871
|
|
|
58814
|
-
|
|
58815
|
-
|
|
58816
|
-
|
|
58817
|
-
|
|
58818
|
-
|
|
58872
|
+
this.camera = camera;
|
|
58873
|
+
this.parent = parent;
|
|
58874
|
+
this.cascades = cascades;
|
|
58875
|
+
this.maxFar = maxFar;
|
|
58876
|
+
this.mode = mode;
|
|
58877
|
+
this.shadowMapSize = shadowMapSize;
|
|
58878
|
+
this.shadowBias = shadowBias;
|
|
58879
|
+
this.lightDirection = lightDirection;
|
|
58880
|
+
this.lightIntensity = lightIntensity;
|
|
58881
|
+
this.lightNear = lightNear;
|
|
58882
|
+
this.lightFar = lightFar;
|
|
58883
|
+
this.lightMargin = lightMargin;
|
|
58884
|
+
this.customSplitsCallback = customSplitsCallback;
|
|
58885
|
+
this.fade = false;
|
|
58886
|
+
this.mainFrustum = new Frustum();
|
|
58887
|
+
this.frustums = [];
|
|
58888
|
+
this.breaks = [];
|
|
58889
|
+
this.lights = [];
|
|
58890
|
+
this.shaders = new Map();
|
|
58891
|
+
this.createLights();
|
|
58892
|
+
this.updateFrustums();
|
|
58893
|
+
this.injectInclude();
|
|
58894
|
+
}
|
|
58819
58895
|
|
|
58820
|
-
|
|
58821
|
-
|
|
58822
|
-
|
|
58823
|
-
|
|
58824
|
-
|
|
58825
|
-
|
|
58826
|
-
|
|
58827
|
-
|
|
58828
|
-
|
|
58829
|
-
|
|
58830
|
-
|
|
58831
|
-
|
|
58832
|
-
|
|
58833
|
-
|
|
58834
|
-
|
|
58835
|
-
this.children = [];
|
|
58836
|
-
this.isMage = true;
|
|
58837
|
-
this.parent = false;
|
|
58838
|
-
this.tags = [DEFAULT_TAG];
|
|
58839
|
-
}
|
|
58840
|
-
}, {
|
|
58841
|
-
key: "hasBody",
|
|
58842
|
-
value: function hasBody() {
|
|
58843
|
-
return !!this.body;
|
|
58844
|
-
}
|
|
58845
|
-
}, {
|
|
58846
|
-
key: "getBody",
|
|
58847
|
-
value: function getBody() {
|
|
58848
|
-
return this.body;
|
|
58849
|
-
}
|
|
58850
|
-
}, {
|
|
58851
|
-
key: "setBody",
|
|
58852
|
-
value: function setBody(body) {
|
|
58853
|
-
this.body = body;
|
|
58854
|
-
}
|
|
58855
|
-
}, {
|
|
58856
|
-
key: "hasParent",
|
|
58857
|
-
value: function hasParent() {
|
|
58858
|
-
return !!this.parent;
|
|
58859
|
-
}
|
|
58860
|
-
}, {
|
|
58861
|
-
key: "getParent",
|
|
58862
|
-
value: function getParent() {
|
|
58863
|
-
return this.parent;
|
|
58896
|
+
_createClass(CascadeShadowMaps, [{
|
|
58897
|
+
key: "createLights",
|
|
58898
|
+
value: function createLights() {
|
|
58899
|
+
for (var i = 0; i < this.cascades; i++) {
|
|
58900
|
+
var light = new DirectionalLight(0xffffff, this.lightIntensity);
|
|
58901
|
+
light.castShadow = true;
|
|
58902
|
+
light.shadow.mapSize.width = this.shadowMapSize;
|
|
58903
|
+
light.shadow.mapSize.height = this.shadowMapSize;
|
|
58904
|
+
light.shadow.camera.near = this.lightNear;
|
|
58905
|
+
light.shadow.camera.far = this.lightFar;
|
|
58906
|
+
light.shadow.bias = this.shadowBias;
|
|
58907
|
+
this.parent.add(light);
|
|
58908
|
+
this.parent.add(light.target);
|
|
58909
|
+
this.lights.push(light);
|
|
58910
|
+
}
|
|
58864
58911
|
}
|
|
58865
58912
|
}, {
|
|
58866
|
-
key: "
|
|
58867
|
-
value: function
|
|
58868
|
-
|
|
58913
|
+
key: "initCascades",
|
|
58914
|
+
value: function initCascades() {
|
|
58915
|
+
var camera = this.camera;
|
|
58916
|
+
camera.updateProjectionMatrix();
|
|
58917
|
+
this.mainFrustum.setFromProjectionMatrix(camera.projectionMatrix, this.maxFar);
|
|
58918
|
+
this.mainFrustum.split(this.breaks, this.frustums);
|
|
58869
58919
|
}
|
|
58870
58920
|
}, {
|
|
58871
|
-
key: "
|
|
58872
|
-
value: function
|
|
58873
|
-
var
|
|
58874
|
-
|
|
58875
|
-
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getBody();
|
|
58921
|
+
key: "updateShadowBounds",
|
|
58922
|
+
value: function updateShadowBounds() {
|
|
58923
|
+
var frustums = this.frustums;
|
|
58876
58924
|
|
|
58877
|
-
|
|
58878
|
-
var
|
|
58879
|
-
|
|
58880
|
-
|
|
58925
|
+
for (var i = 0; i < frustums.length; i++) {
|
|
58926
|
+
var light = this.lights[i];
|
|
58927
|
+
var shadowCam = light.shadow.camera;
|
|
58928
|
+
var frustum = this.frustums[i]; // Get the two points that represent that furthest points on the frustum assuming
|
|
58929
|
+
// that's either the diagonal across the far plane or the diagonal across the whole
|
|
58930
|
+
// frustum itself.
|
|
58881
58931
|
|
|
58882
|
-
|
|
58883
|
-
|
|
58884
|
-
|
|
58885
|
-
|
|
58886
|
-
}
|
|
58887
|
-
};
|
|
58932
|
+
var nearVerts = frustum.vertices.near;
|
|
58933
|
+
var farVerts = frustum.vertices.far;
|
|
58934
|
+
var point1 = farVerts[0];
|
|
58935
|
+
var point2 = void 0;
|
|
58888
58936
|
|
|
58889
|
-
if (
|
|
58890
|
-
|
|
58937
|
+
if (point1.distanceTo(farVerts[2]) > point1.distanceTo(nearVerts[2])) {
|
|
58938
|
+
point2 = farVerts[2];
|
|
58891
58939
|
} else {
|
|
58892
|
-
|
|
58940
|
+
point2 = nearVerts[2];
|
|
58893
58941
|
}
|
|
58894
|
-
|
|
58895
|
-
|
|
58942
|
+
|
|
58943
|
+
var squaredBBWidth = point1.distanceTo(point2);
|
|
58944
|
+
|
|
58945
|
+
if (this.fade) {
|
|
58946
|
+
// expand the shadow extents by the fade margin if fade is enabled.
|
|
58947
|
+
var camera = this.camera;
|
|
58948
|
+
var far = Math.max(camera.far, this.maxFar);
|
|
58949
|
+
var linearDepth = frustum.vertices.far[0].z / (far - camera.near);
|
|
58950
|
+
var margin = 0.25 * Math.pow(linearDepth, 2.0) * (far - camera.near);
|
|
58951
|
+
squaredBBWidth += margin;
|
|
58952
|
+
}
|
|
58953
|
+
|
|
58954
|
+
shadowCam.left = -squaredBBWidth / 2;
|
|
58955
|
+
shadowCam.right = squaredBBWidth / 2;
|
|
58956
|
+
shadowCam.top = squaredBBWidth / 2;
|
|
58957
|
+
shadowCam.bottom = -squaredBBWidth / 2;
|
|
58958
|
+
shadowCam.updateProjectionMatrix();
|
|
58896
58959
|
}
|
|
58897
58960
|
}
|
|
58898
58961
|
}, {
|
|
58899
|
-
key: "
|
|
58900
|
-
value: function
|
|
58901
|
-
var
|
|
58902
|
-
|
|
58903
|
-
|
|
58962
|
+
key: "getBreaks",
|
|
58963
|
+
value: function getBreaks() {
|
|
58964
|
+
var camera = this.camera;
|
|
58965
|
+
var far = Math.min(camera.far, this.maxFar);
|
|
58966
|
+
this.breaks.length = 0;
|
|
58904
58967
|
|
|
58905
|
-
|
|
58906
|
-
|
|
58907
|
-
|
|
58908
|
-
|
|
58968
|
+
switch (this.mode) {
|
|
58969
|
+
case 'uniform':
|
|
58970
|
+
uniformSplit(this.cascades, camera.near, far, this.breaks);
|
|
58971
|
+
break;
|
|
58972
|
+
|
|
58973
|
+
case 'logarithmic':
|
|
58974
|
+
logarithmicSplit(this.cascades, camera.near, far, this.breaks);
|
|
58975
|
+
break;
|
|
58976
|
+
|
|
58977
|
+
case 'practical':
|
|
58978
|
+
practicalSplit(this.cascades, camera.near, far, 0.5, this.breaks);
|
|
58979
|
+
break;
|
|
58980
|
+
|
|
58981
|
+
case 'custom':
|
|
58982
|
+
if (this.customSplitsCallback === undefined) console.error('CSM: Custom split scheme callback not defined.');
|
|
58983
|
+
this.customSplitsCallback(this.cascades, camera.near, far, this.breaks);
|
|
58984
|
+
break;
|
|
58909
58985
|
}
|
|
58910
58986
|
|
|
58911
|
-
|
|
58912
|
-
|
|
58913
|
-
|
|
58914
|
-
|
|
58915
|
-
|
|
58916
|
-
|
|
58917
|
-
return this.equals(child) || this.isParentOf(child);
|
|
58918
|
-
} else {
|
|
58919
|
-
return !!this.getBody().getObjectById(child.id);
|
|
58987
|
+
function uniformSplit(amount, near, far, target) {
|
|
58988
|
+
for (var i = 1; i < amount; i++) {
|
|
58989
|
+
target.push((near + (far - near) * i / amount) / far);
|
|
58990
|
+
}
|
|
58991
|
+
|
|
58992
|
+
target.push(1);
|
|
58920
58993
|
}
|
|
58921
|
-
|
|
58922
|
-
|
|
58923
|
-
|
|
58924
|
-
|
|
58925
|
-
|
|
58926
|
-
|
|
58927
|
-
|
|
58928
|
-
|
|
58929
|
-
|
|
58930
|
-
|
|
58931
|
-
|
|
58932
|
-
|
|
58933
|
-
|
|
58994
|
+
|
|
58995
|
+
function logarithmicSplit(amount, near, far, target) {
|
|
58996
|
+
for (var i = 1; i < amount; i++) {
|
|
58997
|
+
target.push(near * Math.pow(far / near, i / amount) / far);
|
|
58998
|
+
}
|
|
58999
|
+
|
|
59000
|
+
target.push(1);
|
|
59001
|
+
}
|
|
59002
|
+
|
|
59003
|
+
function practicalSplit(amount, near, far, lambda, target) {
|
|
59004
|
+
_uniformArray.length = 0;
|
|
59005
|
+
_logArray.length = 0;
|
|
59006
|
+
logarithmicSplit(amount, near, far, _logArray);
|
|
59007
|
+
uniformSplit(amount, near, far, _uniformArray);
|
|
59008
|
+
|
|
59009
|
+
for (var i = 1; i < amount; i++) {
|
|
59010
|
+
target.push(MathUtils.lerp(_uniformArray[i - 1], _logArray[i - 1], lambda));
|
|
58934
59011
|
}
|
|
59012
|
+
|
|
59013
|
+
target.push(1);
|
|
58935
59014
|
}
|
|
58936
59015
|
}
|
|
58937
59016
|
}, {
|
|
58938
|
-
key: "
|
|
58939
|
-
value: function
|
|
58940
|
-
|
|
58941
|
-
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
|
|
59017
|
+
key: "update",
|
|
59018
|
+
value: function update() {
|
|
59019
|
+
var camera = this.camera;
|
|
59020
|
+
var frustums = this.frustums;
|
|
59021
|
+
|
|
59022
|
+
for (var i = 0; i < frustums.length; i++) {
|
|
59023
|
+
var light = this.lights[i];
|
|
59024
|
+
var shadowCam = light.shadow.camera;
|
|
59025
|
+
var texelWidth = (shadowCam.right - shadowCam.left) / this.shadowMapSize;
|
|
59026
|
+
var texelHeight = (shadowCam.top - shadowCam.bottom) / this.shadowMapSize;
|
|
59027
|
+
light.shadow.camera.updateMatrixWorld(true);
|
|
59028
|
+
|
|
59029
|
+
_cameraToLightMatrix.multiplyMatrices(light.shadow.camera.matrixWorldInverse, camera.matrixWorld);
|
|
59030
|
+
|
|
59031
|
+
frustums[i].toSpace(_cameraToLightMatrix, _lightSpaceFrustum);
|
|
59032
|
+
var nearVerts = _lightSpaceFrustum.vertices.near;
|
|
59033
|
+
var farVerts = _lightSpaceFrustum.vertices.far;
|
|
59034
|
+
|
|
59035
|
+
_bbox.makeEmpty();
|
|
59036
|
+
|
|
59037
|
+
for (var j = 0; j < 4; j++) {
|
|
59038
|
+
_bbox.expandByPoint(nearVerts[j]);
|
|
59039
|
+
|
|
59040
|
+
_bbox.expandByPoint(farVerts[j]);
|
|
58945
59041
|
}
|
|
59042
|
+
|
|
59043
|
+
_bbox.getCenter(_center);
|
|
59044
|
+
|
|
59045
|
+
_center.z = _bbox.max.z + this.lightMargin;
|
|
59046
|
+
_center.x = Math.floor(_center.x / texelWidth) * texelWidth;
|
|
59047
|
+
_center.y = Math.floor(_center.y / texelHeight) * texelHeight;
|
|
59048
|
+
|
|
59049
|
+
_center.applyMatrix4(light.shadow.camera.matrixWorld);
|
|
59050
|
+
|
|
59051
|
+
light.position.copy(_center);
|
|
59052
|
+
light.target.position.copy(_center);
|
|
59053
|
+
light.target.position.x += this.lightDirection.x;
|
|
59054
|
+
light.target.position.y += this.lightDirection.y;
|
|
59055
|
+
light.target.position.z += this.lightDirection.z;
|
|
58946
59056
|
}
|
|
58947
59057
|
}
|
|
58948
59058
|
}, {
|
|
58949
|
-
key: "
|
|
58950
|
-
value: function
|
|
58951
|
-
|
|
58952
|
-
|
|
58953
|
-
children: this.children.map(function (e) {
|
|
58954
|
-
return e.getHierarchy();
|
|
58955
|
-
})
|
|
58956
|
-
};
|
|
59059
|
+
key: "injectInclude",
|
|
59060
|
+
value: function injectInclude() {
|
|
59061
|
+
ShaderChunk.lights_fragment_begin = Shader$1.lights_fragment_begin;
|
|
59062
|
+
ShaderChunk.lights_pars_begin = Shader$1.lights_pars_begin;
|
|
58957
59063
|
}
|
|
58958
59064
|
}, {
|
|
58959
|
-
key: "
|
|
58960
|
-
value: function
|
|
58961
|
-
|
|
58962
|
-
|
|
58963
|
-
|
|
58964
|
-
}, {
|
|
58965
|
-
key: "removeTag",
|
|
58966
|
-
value: function removeTag(tagName) {
|
|
58967
|
-
if (tagName === DEFAULT_TAG) {
|
|
58968
|
-
console.log(TAG_CANT_BE_REMOVED);
|
|
58969
|
-
return;
|
|
58970
|
-
}
|
|
59065
|
+
key: "setupMaterial",
|
|
59066
|
+
value: function setupMaterial(material) {
|
|
59067
|
+
material.defines = material.defines || {};
|
|
59068
|
+
material.defines.USE_CSM = 1;
|
|
59069
|
+
material.defines.CSM_CASCADES = this.cascades;
|
|
58971
59070
|
|
|
58972
|
-
if (this.
|
|
58973
|
-
|
|
58974
|
-
} else {
|
|
58975
|
-
console.log(TAG_NOT_EXISTING_REMOVAL);
|
|
59071
|
+
if (this.fade) {
|
|
59072
|
+
material.defines.CSM_FADE = '';
|
|
58976
59073
|
}
|
|
58977
|
-
}
|
|
58978
|
-
}, {
|
|
58979
|
-
key: "removeAllTags",
|
|
58980
|
-
value: function removeAllTags() {
|
|
58981
|
-
this.tags = [DEFAULT_TAG];
|
|
58982
|
-
}
|
|
58983
|
-
}, {
|
|
58984
|
-
key: "hasTag",
|
|
58985
|
-
value: function hasTag(tagName) {
|
|
58986
|
-
return this.tags.includes(tagName);
|
|
58987
|
-
}
|
|
58988
|
-
}, {
|
|
58989
|
-
key: "getTags",
|
|
58990
|
-
value: function getTags() {
|
|
58991
|
-
return this.tags;
|
|
58992
|
-
}
|
|
58993
|
-
}, {
|
|
58994
|
-
key: "stopScripts",
|
|
58995
|
-
value: function stopScripts() {
|
|
58996
|
-
if (this.hasScripts()) {
|
|
58997
|
-
this.scripts.forEach(function (_ref3) {
|
|
58998
|
-
var script = _ref3.script,
|
|
58999
|
-
enabled = _ref3.enabled;
|
|
59000
59074
|
|
|
59001
|
-
|
|
59002
|
-
|
|
59075
|
+
var breaksVec2 = [];
|
|
59076
|
+
var scope = this;
|
|
59077
|
+
var shaders = this.shaders;
|
|
59003
59078
|
|
|
59004
|
-
|
|
59005
|
-
|
|
59006
|
-
|
|
59007
|
-
|
|
59079
|
+
material.onBeforeCompile = function (shader) {
|
|
59080
|
+
var far = Math.min(scope.camera.far, scope.maxFar);
|
|
59081
|
+
scope.getExtendedBreaks(breaksVec2);
|
|
59082
|
+
shader.uniforms.CSM_cascades = {
|
|
59083
|
+
value: breaksVec2
|
|
59084
|
+
};
|
|
59085
|
+
shader.uniforms.cameraNear = {
|
|
59086
|
+
value: scope.camera.near
|
|
59087
|
+
};
|
|
59088
|
+
shader.uniforms.shadowFar = {
|
|
59089
|
+
value: far
|
|
59090
|
+
};
|
|
59091
|
+
shaders.set(material, shader);
|
|
59092
|
+
};
|
|
59093
|
+
|
|
59094
|
+
shaders.set(material, null);
|
|
59008
59095
|
}
|
|
59009
59096
|
}, {
|
|
59010
|
-
key: "
|
|
59011
|
-
value: function
|
|
59012
|
-
var
|
|
59097
|
+
key: "updateUniforms",
|
|
59098
|
+
value: function updateUniforms() {
|
|
59099
|
+
var far = Math.min(this.camera.far, this.maxFar);
|
|
59100
|
+
var shaders = this.shaders;
|
|
59101
|
+
shaders.forEach(function (shader, material) {
|
|
59102
|
+
if (shader !== null) {
|
|
59103
|
+
var uniforms = shader.uniforms;
|
|
59104
|
+
this.getExtendedBreaks(uniforms.CSM_cascades.value);
|
|
59105
|
+
uniforms.cameraNear.value = this.camera.near;
|
|
59106
|
+
uniforms.shadowFar.value = far;
|
|
59107
|
+
}
|
|
59013
59108
|
|
|
59014
|
-
|
|
59015
|
-
|
|
59016
|
-
|
|
59017
|
-
|
|
59018
|
-
|
|
59109
|
+
if (!this.fade && 'CSM_FADE' in material.defines) {
|
|
59110
|
+
delete material.defines.CSM_FADE;
|
|
59111
|
+
material.needsUpdate = true;
|
|
59112
|
+
} else if (this.fade && !('CSM_FADE' in material.defines)) {
|
|
59113
|
+
material.defines.CSM_FADE = '';
|
|
59114
|
+
material.needsUpdate = true;
|
|
59115
|
+
}
|
|
59116
|
+
}, this);
|
|
59117
|
+
}
|
|
59118
|
+
}, {
|
|
59119
|
+
key: "getExtendedBreaks",
|
|
59120
|
+
value: function getExtendedBreaks(target) {
|
|
59121
|
+
while (target.length < this.breaks.length) {
|
|
59122
|
+
target.push(new Vector2());
|
|
59123
|
+
}
|
|
59019
59124
|
|
|
59020
|
-
|
|
59021
|
-
script.start(_this3, options);
|
|
59125
|
+
target.length = this.breaks.length;
|
|
59022
59126
|
|
|
59023
|
-
|
|
59024
|
-
|
|
59025
|
-
|
|
59127
|
+
for (var i = 0; i < this.cascades; i++) {
|
|
59128
|
+
var amount = this.breaks[i];
|
|
59129
|
+
var prev = this.breaks[i - 1] || 0;
|
|
59130
|
+
target[i].x = prev;
|
|
59131
|
+
target[i].y = amount;
|
|
59026
59132
|
}
|
|
59027
59133
|
}
|
|
59028
59134
|
}, {
|
|
59029
|
-
key: "
|
|
59030
|
-
value: function
|
|
59031
|
-
|
|
59032
|
-
|
|
59033
|
-
|
|
59034
|
-
|
|
59035
|
-
|
|
59036
|
-
if (script && enabled) {
|
|
59037
|
-
script.update(dt);
|
|
59038
|
-
}
|
|
59039
|
-
});
|
|
59040
|
-
}
|
|
59135
|
+
key: "updateFrustums",
|
|
59136
|
+
value: function updateFrustums() {
|
|
59137
|
+
this.getBreaks();
|
|
59138
|
+
this.initCascades();
|
|
59139
|
+
this.updateShadowBounds();
|
|
59140
|
+
this.updateUniforms();
|
|
59041
59141
|
}
|
|
59042
59142
|
}, {
|
|
59043
|
-
key: "
|
|
59044
|
-
value: function
|
|
59045
|
-
|
|
59046
|
-
this.
|
|
59047
|
-
var script = _ref6.script,
|
|
59048
|
-
enabled = _ref6.enabled;
|
|
59049
|
-
|
|
59050
|
-
if (script && enabled) {
|
|
59051
|
-
script.physicsUpdate(dt);
|
|
59052
|
-
}
|
|
59053
|
-
});
|
|
59143
|
+
key: "remove",
|
|
59144
|
+
value: function remove() {
|
|
59145
|
+
for (var i = 0; i < this.lights.length; i++) {
|
|
59146
|
+
this.parent.remove(this.lights[i]);
|
|
59054
59147
|
}
|
|
59055
59148
|
}
|
|
59056
59149
|
}, {
|
|
59057
59150
|
key: "dispose",
|
|
59058
59151
|
value: function dispose() {
|
|
59059
|
-
|
|
59060
|
-
|
|
59061
|
-
|
|
59062
|
-
|
|
59063
|
-
|
|
59152
|
+
var shaders = this.shaders;
|
|
59153
|
+
shaders.forEach(function (shader, material) {
|
|
59154
|
+
delete material.onBeforeCompile;
|
|
59155
|
+
delete material.defines.USE_CSM;
|
|
59156
|
+
delete material.defines.CSM_CASCADES;
|
|
59157
|
+
delete material.defines.CSM_FADE;
|
|
59064
59158
|
|
|
59065
|
-
|
|
59066
|
-
|
|
59159
|
+
if (shader !== null) {
|
|
59160
|
+
delete shader.uniforms.CSM_cascades;
|
|
59161
|
+
delete shader.uniforms.cameraNear;
|
|
59162
|
+
delete shader.uniforms.shadowFar;
|
|
59163
|
+
}
|
|
59164
|
+
|
|
59165
|
+
material.needsUpdate = true;
|
|
59067
59166
|
});
|
|
59167
|
+
shaders.clear();
|
|
59068
59168
|
}
|
|
59069
|
-
}
|
|
59070
|
-
key: "addStateMachine",
|
|
59071
|
-
value: function addStateMachine(description) {
|
|
59072
|
-
var _this4 = this;
|
|
59169
|
+
}]);
|
|
59073
59170
|
|
|
59074
|
-
|
|
59075
|
-
|
|
59076
|
-
|
|
59077
|
-
|
|
59078
|
-
|
|
59079
|
-
|
|
59171
|
+
return CascadeShadowMaps;
|
|
59172
|
+
}();var POINTLIGHT = 'pointlight';
|
|
59173
|
+
var AMBIENTLIGHT = 'ambientlight';
|
|
59174
|
+
var SUNLIGHT = 'sunlight';
|
|
59175
|
+
var SPOTLIGHT = 'spotlight';
|
|
59176
|
+
var HEMISPHERELIGHT = 'hemisphere';
|
|
59177
|
+
var TIME_TO_UPDATE = 5;
|
|
59178
|
+
var Lights = /*#__PURE__*/function () {
|
|
59179
|
+
function Lights() {
|
|
59180
|
+
_classCallCheck(this, Lights);
|
|
59080
59181
|
|
|
59081
|
-
|
|
59082
|
-
|
|
59083
|
-
|
|
59084
|
-
|
|
59085
|
-
|
|
59086
|
-
|
|
59087
|
-
|
|
59088
|
-
|
|
59089
|
-
|
|
59090
|
-
|
|
59091
|
-
|
|
59092
|
-
|
|
59182
|
+
this.delayFactor = 0.1;
|
|
59183
|
+
this.delayStep = 30;
|
|
59184
|
+
this.holderRadius = 0.01;
|
|
59185
|
+
this.holderSegments = 1;
|
|
59186
|
+
this.numLights = 0;
|
|
59187
|
+
this.map = {};
|
|
59188
|
+
this.lights = [];
|
|
59189
|
+
this.csm = undefined;
|
|
59190
|
+
}
|
|
59191
|
+
|
|
59192
|
+
_createClass(Lights, [{
|
|
59193
|
+
key: "isUsingCSM",
|
|
59194
|
+
value: function isUsingCSM() {
|
|
59195
|
+
return !!this.csm;
|
|
59093
59196
|
}
|
|
59094
59197
|
}, {
|
|
59095
|
-
key: "
|
|
59096
|
-
value: function
|
|
59097
|
-
|
|
59098
|
-
|
|
59099
|
-
}
|
|
59198
|
+
key: "setUpCSM",
|
|
59199
|
+
value: function setUpCSM() {
|
|
59200
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
59201
|
+
this.csm = new CascadeShadowMaps(options);
|
|
59100
59202
|
}
|
|
59101
59203
|
}, {
|
|
59102
|
-
key: "
|
|
59103
|
-
value: function
|
|
59104
|
-
|
|
59105
|
-
this.stateMachine.send(event);
|
|
59106
|
-
} else {
|
|
59107
|
-
console.log(STATE_MACHINE_NOT_AVAILABLE);
|
|
59108
|
-
}
|
|
59204
|
+
key: "add",
|
|
59205
|
+
value: function add(light) {
|
|
59206
|
+
this.lights.push(light);
|
|
59109
59207
|
}
|
|
59110
59208
|
}, {
|
|
59111
|
-
key: "
|
|
59112
|
-
value: function
|
|
59113
|
-
|
|
59114
|
-
|
|
59115
|
-
})[0].script;
|
|
59116
|
-
|
|
59117
|
-
if (script) {
|
|
59118
|
-
return script;
|
|
59119
|
-
} else {
|
|
59120
|
-
console.warn(SCRIPT_NOT_FOUND);
|
|
59209
|
+
key: "update",
|
|
59210
|
+
value: function update(dt) {
|
|
59211
|
+
if (this.isUsingCSM()) {
|
|
59212
|
+
this.csm.update();
|
|
59121
59213
|
}
|
|
59122
|
-
}
|
|
59123
|
-
}, {
|
|
59124
|
-
key: "addScripts",
|
|
59125
|
-
value: function addScripts() {
|
|
59126
|
-
var _this5 = this;
|
|
59127
59214
|
|
|
59128
|
-
var
|
|
59129
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
59130
|
-
var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
59131
|
-
var parsedScripts = this.parseScripts(scripts, options, enabled);
|
|
59132
|
-
this.scripts = [].concat(_toConsumableArray(this.scripts), [parsedScripts]);
|
|
59215
|
+
var start = new Date();
|
|
59133
59216
|
|
|
59134
|
-
|
|
59135
|
-
|
|
59136
|
-
|
|
59137
|
-
|
|
59217
|
+
for (var index in this.lights) {
|
|
59218
|
+
var light = this.lights[index];
|
|
59219
|
+
light.update(dt);
|
|
59220
|
+
if (+new Date() - start > TIME_TO_UPDATE) break;
|
|
59138
59221
|
}
|
|
59139
59222
|
}
|
|
59140
59223
|
}, {
|
|
59141
|
-
key: "
|
|
59142
|
-
value: function
|
|
59143
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
59144
|
-
var script = Scripts$1.get(name);
|
|
59145
|
-
var _options$enabled = options.enabled,
|
|
59146
|
-
enabled = _options$enabled === void 0 ? true : _options$enabled;
|
|
59147
|
-
|
|
59148
|
-
if (script) {
|
|
59149
|
-
this.scripts.push({
|
|
59150
|
-
script: script,
|
|
59151
|
-
name: name,
|
|
59152
|
-
enabled: enabled,
|
|
59153
|
-
options: options
|
|
59154
|
-
});
|
|
59155
|
-
|
|
59156
|
-
if (enabled) {
|
|
59157
|
-
script.start(this, options);
|
|
59158
|
-
}
|
|
59159
|
-
} else {
|
|
59160
|
-
console.log(SCRIPT_NOT_FOUND);
|
|
59161
|
-
}
|
|
59162
|
-
|
|
59163
|
-
return script;
|
|
59164
|
-
}
|
|
59165
|
-
}, {
|
|
59166
|
-
key: "enableScripts",
|
|
59167
|
-
value: function enableScripts() {
|
|
59168
|
-
this.scriptsEnabled = true;
|
|
59169
|
-
}
|
|
59170
|
-
}, {
|
|
59171
|
-
key: "disableScripts",
|
|
59172
|
-
value: function disableScripts() {
|
|
59173
|
-
this.scriptsEnabled = false;
|
|
59174
|
-
}
|
|
59175
|
-
}, {
|
|
59176
|
-
key: "setEntityType",
|
|
59177
|
-
value: function setEntityType(type) {
|
|
59178
|
-
if (FLAT_ENTITY_TYPES.includes(type)) {
|
|
59179
|
-
this.entityType = type;
|
|
59180
|
-
} else {
|
|
59181
|
-
console.log(ENTITY_TYPE_NOT_ALLOWED);
|
|
59182
|
-
this.entityType = ENTITY_TYPES.UNKNOWN;
|
|
59183
|
-
}
|
|
59184
|
-
}
|
|
59185
|
-
}, {
|
|
59186
|
-
key: "getEntityType",
|
|
59187
|
-
value: function getEntityType() {
|
|
59188
|
-
return this.entityType;
|
|
59189
|
-
}
|
|
59190
|
-
}, {
|
|
59191
|
-
key: "addLight",
|
|
59192
|
-
// TODO: sounds should become entities
|
|
59193
|
-
// addSound(name, options) {
|
|
59194
|
-
// const { autoplay = false, ...opts } = options;
|
|
59195
|
-
// this.isPlayingSound = autoplay;
|
|
59196
|
-
// this.sound = new Sound(name, {
|
|
59197
|
-
// autoplay,
|
|
59198
|
-
// ...opts
|
|
59199
|
-
// });
|
|
59200
|
-
// this.sound.setTarget(this);
|
|
59201
|
-
// return this.sound;
|
|
59202
|
-
// }
|
|
59203
|
-
// addDirectionalSound(name, options) {
|
|
59204
|
-
// const { autoplay = false, ...opts } = options;
|
|
59205
|
-
// this.isPlayingSound = autoplay;
|
|
59206
|
-
// this.sound = new DirectionalSound(name, {
|
|
59207
|
-
// autoplay,
|
|
59208
|
-
// ...opts
|
|
59209
|
-
// });
|
|
59210
|
-
// this.sound.setTarget(this);
|
|
59211
|
-
// return this.sound;
|
|
59212
|
-
// }
|
|
59213
|
-
// addAmbientSound(name, options) {
|
|
59214
|
-
// const { autoplay = false, ...opts } = options;
|
|
59215
|
-
// this.isPlayingSound = autoplay;
|
|
59216
|
-
// this.sound = new AmbientSound(name, {
|
|
59217
|
-
// body: this.body,
|
|
59218
|
-
// autoplay,
|
|
59219
|
-
// ...opts
|
|
59220
|
-
// });
|
|
59221
|
-
// return this.sound;
|
|
59222
|
-
// }
|
|
59223
|
-
value: function addLight(light) {
|
|
59224
|
-
var _this$getPosition = this.getPosition(),
|
|
59225
|
-
x = _this$getPosition.x,
|
|
59226
|
-
y = _this$getPosition.y,
|
|
59227
|
-
z = _this$getPosition.z;
|
|
59228
|
-
|
|
59229
|
-
light.setPosition({
|
|
59230
|
-
x: x,
|
|
59231
|
-
y: y,
|
|
59232
|
-
z: z
|
|
59233
|
-
});
|
|
59234
|
-
this.light = light;
|
|
59235
|
-
}
|
|
59236
|
-
}, {
|
|
59237
|
-
key: "playSound",
|
|
59238
|
-
value: function playSound() {
|
|
59239
|
-
if (this.sound && !this.isPlayingSound) {
|
|
59240
|
-
this.sound.play();
|
|
59241
|
-
this.isPlayingSound = true;
|
|
59242
|
-
}
|
|
59243
|
-
}
|
|
59244
|
-
}, {
|
|
59245
|
-
key: "stopSound",
|
|
59246
|
-
value: function stopSound() {
|
|
59247
|
-
if (this.sound && this.isPlayingSound) {
|
|
59248
|
-
this.sound.stop();
|
|
59249
|
-
this.isPlayingSound = false;
|
|
59250
|
-
}
|
|
59251
|
-
}
|
|
59252
|
-
}, {
|
|
59253
|
-
key: "getScale",
|
|
59254
|
-
value: function getScale() {
|
|
59224
|
+
key: "toJSON",
|
|
59225
|
+
value: function toJSON() {
|
|
59255
59226
|
return {
|
|
59256
|
-
|
|
59257
|
-
|
|
59258
|
-
|
|
59227
|
+
lights: this.lights.map(function (l) {
|
|
59228
|
+
return l.toJSON();
|
|
59229
|
+
})
|
|
59259
59230
|
};
|
|
59260
59231
|
}
|
|
59261
|
-
}
|
|
59262
|
-
key: "setScale",
|
|
59263
|
-
value: function setScale(howbig) {
|
|
59264
|
-
if (this.hasBody()) {
|
|
59265
|
-
var scale = _objectSpread2$1(_objectSpread2$1({}, this.getScale()), howbig);
|
|
59232
|
+
}]);
|
|
59266
59233
|
|
|
59267
|
-
|
|
59268
|
-
|
|
59269
|
-
|
|
59270
|
-
|
|
59271
|
-
|
|
59272
|
-
|
|
59273
|
-
|
|
59274
|
-
|
|
59275
|
-
|
|
59276
|
-
|
|
59277
|
-
|
|
59278
|
-
|
|
59279
|
-
|
|
59280
|
-
|
|
59234
|
+
return Lights;
|
|
59235
|
+
}();
|
|
59236
|
+
var Lights$1 = new Lights();var ToonShader = {
|
|
59237
|
+
uniforms: {
|
|
59238
|
+
"uDirLightPos": {
|
|
59239
|
+
type: "v3",
|
|
59240
|
+
value: new Vector3$1()
|
|
59241
|
+
},
|
|
59242
|
+
"uDirLightColor": {
|
|
59243
|
+
type: "c",
|
|
59244
|
+
value: new Color$1(0xffffff)
|
|
59245
|
+
},
|
|
59246
|
+
"uMaterialColor": {
|
|
59247
|
+
type: "c",
|
|
59248
|
+
value: new Color$1(0xffffff)
|
|
59249
|
+
},
|
|
59250
|
+
uKd: {
|
|
59251
|
+
type: "f",
|
|
59252
|
+
value: 1
|
|
59253
|
+
},
|
|
59254
|
+
uBorder: {
|
|
59255
|
+
type: "f",
|
|
59256
|
+
value: 0.4
|
|
59281
59257
|
}
|
|
59282
|
-
},
|
|
59283
|
-
|
|
59284
|
-
|
|
59285
|
-
|
|
59286
|
-
|
|
59287
|
-
|
|
59288
|
-
|
|
59289
|
-
|
|
59258
|
+
},
|
|
59259
|
+
vertexShader: ["varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "vNormal = normalize( normalMatrix * normal );", "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", "vViewPosition = -mvPosition.xyz;", "}"].join("\n"),
|
|
59260
|
+
fragmentShader: ["uniform vec3 uMaterialColor;", "uniform vec3 uDirLightPos;", "uniform vec3 uDirLightColor;", "uniform float uKd;", "uniform float uBorder;", "varying vec3 vNormal;", "varying vec3 vViewPosition;", "void main() {", // compute direction to light
|
|
59261
|
+
"vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );", "vec3 lVector = normalize( lDirection.xyz );", // diffuse: N * L. Normal must be normalized, since it's interpolated.
|
|
59262
|
+
"vec3 normal = normalize( vNormal );", //was: "float diffuse = max( dot( normal, lVector ), 0.0);",
|
|
59263
|
+
// solution
|
|
59264
|
+
"float diffuse = dot( normal, lVector );", "if ( diffuse > 0.6 ) { diffuse = 1.0; }", "else if ( diffuse > -0.2 ) { diffuse = 0.7; }", "else { diffuse = 0.3; }", "gl_FragColor = vec4( uKd * uMaterialColor * uDirLightColor * diffuse, 1.0 );", "}"].join("\n")
|
|
59265
|
+
};
|
|
59290
59266
|
|
|
59291
|
-
|
|
59292
|
-
|
|
59293
|
-
y: y,
|
|
59294
|
-
z: z
|
|
59295
|
-
}, where);
|
|
59267
|
+
var ToonMaterial = /*#__PURE__*/function (_ShaderMaterial) {
|
|
59268
|
+
_inherits(ToonMaterial, _ShaderMaterial);
|
|
59296
59269
|
|
|
59297
|
-
|
|
59298
|
-
|
|
59299
|
-
|
|
59300
|
-
|
|
59301
|
-
|
|
59302
|
-
|
|
59303
|
-
|
|
59270
|
+
var _super = _createSuper(ToonMaterial);
|
|
59271
|
+
|
|
59272
|
+
function ToonMaterial(_ref) {
|
|
59273
|
+
var _this;
|
|
59274
|
+
|
|
59275
|
+
var _ref$light = _ref.light,
|
|
59276
|
+
light = _ref$light === void 0 ? {} : _ref$light,
|
|
59277
|
+
color = _ref.color;
|
|
59278
|
+
|
|
59279
|
+
_classCallCheck(this, ToonMaterial);
|
|
59280
|
+
|
|
59281
|
+
var uniforms = UniformsUtils.clone(ToonShader.uniforms);
|
|
59282
|
+
var vertexShader = ToonShader.vertexShader,
|
|
59283
|
+
fragmentShader = ToonShader.fragmentShader;
|
|
59284
|
+
_this = _super.call(this, {
|
|
59285
|
+
uniforms: uniforms,
|
|
59286
|
+
vertexShader: vertexShader,
|
|
59287
|
+
fragmentShader: fragmentShader,
|
|
59288
|
+
flatShading: true
|
|
59289
|
+
});
|
|
59290
|
+
var position = light.position,
|
|
59291
|
+
lightColor = light.color;
|
|
59292
|
+
|
|
59293
|
+
if (color) {
|
|
59294
|
+
var materialColor = new Color$1(color);
|
|
59295
|
+
|
|
59296
|
+
_this.uniforms.uMaterialColor.value.copy(materialColor);
|
|
59304
59297
|
}
|
|
59305
|
-
}, {
|
|
59306
|
-
key: "setRotation",
|
|
59307
|
-
value: function setRotation(how) {
|
|
59308
|
-
if (this.hasBody()) {
|
|
59309
|
-
var _this$getRotation = this.getRotation(),
|
|
59310
|
-
x = _this$getRotation.x,
|
|
59311
|
-
y = _this$getRotation.y,
|
|
59312
|
-
z = _this$getRotation.z;
|
|
59313
59298
|
|
|
59314
|
-
|
|
59315
|
-
x: x,
|
|
59316
|
-
y: y,
|
|
59317
|
-
z: z
|
|
59318
|
-
}, how);
|
|
59299
|
+
_this.uniforms.uDirLightPos.value = position;
|
|
59319
59300
|
|
|
59320
|
-
|
|
59301
|
+
_this.uniforms.uDirLightColor.value.copy(new Color$1(lightColor));
|
|
59302
|
+
|
|
59303
|
+
_this.side = DoubleSide;
|
|
59304
|
+
return _this;
|
|
59305
|
+
}
|
|
59306
|
+
|
|
59307
|
+
return ToonMaterial;
|
|
59308
|
+
}(ShaderMaterial);var setUpLightsAndShadows = function setUpLightsAndShadows(mesh) {
|
|
59309
|
+
var _Config$lights = Config$1.lights(),
|
|
59310
|
+
textureAnisotropy = _Config$lights.textureAnisotropy,
|
|
59311
|
+
shadows = _Config$lights.shadows;
|
|
59312
|
+
|
|
59313
|
+
mesh.castShadow = Boolean(shadows);
|
|
59314
|
+
mesh.receiveShadow = Boolean(shadows);
|
|
59315
|
+
|
|
59316
|
+
if (hasMaterial(mesh)) {
|
|
59317
|
+
var setUpMaterial = function setUpMaterial(material) {
|
|
59318
|
+
if (Lights$1.isUsingCSM()) {
|
|
59319
|
+
Lights$1.csm.setupMaterial(material);
|
|
59321
59320
|
}
|
|
59322
|
-
}
|
|
59323
|
-
}, {
|
|
59324
|
-
key: "getWorldTransform",
|
|
59325
|
-
value: function getWorldTransform() {
|
|
59326
|
-
var position = this.getBody().getWorldPosition(new Vector3$1());
|
|
59327
|
-
var quaternion = this.getBody().getWorldQuaternion(new Quaternion(0, 0, 0, 1));
|
|
59328
|
-
var rotation = new Euler(0, 0, 0, 'XYZ').setFromQuaternion(quaternion, 'XYZ');
|
|
59329
|
-
return {
|
|
59330
|
-
position: position,
|
|
59331
|
-
rotation: rotation,
|
|
59332
|
-
quaternion: quaternion
|
|
59333
|
-
};
|
|
59334
|
-
}
|
|
59335
|
-
}, {
|
|
59336
|
-
key: "translate",
|
|
59337
|
-
value: function translate(_ref7) {
|
|
59338
|
-
var _ref7$x = _ref7.x,
|
|
59339
|
-
x = _ref7$x === void 0 ? 0 : _ref7$x,
|
|
59340
|
-
_ref7$y = _ref7.y,
|
|
59341
|
-
y = _ref7$y === void 0 ? 0 : _ref7$y,
|
|
59342
|
-
_ref7$z = _ref7.z,
|
|
59343
|
-
z = _ref7$z === void 0 ? 0 : _ref7$z;
|
|
59344
59321
|
|
|
59345
|
-
if (
|
|
59346
|
-
|
|
59347
|
-
this.body.translateY(y);
|
|
59348
|
-
this.body.translateZ(z);
|
|
59322
|
+
if (material.map) {
|
|
59323
|
+
material.map.anisotropy = textureAnisotropy;
|
|
59349
59324
|
}
|
|
59350
|
-
}
|
|
59351
|
-
}, {
|
|
59352
|
-
key: "rotateTo",
|
|
59353
|
-
value: function rotateTo() {
|
|
59354
|
-
var _this6 = this;
|
|
59355
59325
|
|
|
59356
|
-
|
|
59357
|
-
|
|
59326
|
+
return material;
|
|
59327
|
+
};
|
|
59358
59328
|
|
|
59359
|
-
|
|
59360
|
-
|
|
59361
|
-
|
|
59362
|
-
|
|
59329
|
+
mesh.material = processMaterial(mesh.material, setUpMaterial);
|
|
59330
|
+
}
|
|
59331
|
+
};
|
|
59332
|
+
var isScene = function isScene(mesh) {
|
|
59333
|
+
return mesh.isScene;
|
|
59334
|
+
};
|
|
59363
59335
|
|
|
59364
|
-
|
|
59365
|
-
|
|
59366
|
-
|
|
59367
|
-
|
|
59368
|
-
|
|
59369
|
-
|
|
59370
|
-
|
|
59371
|
-
|
|
59336
|
+
var hasMaterial = function hasMaterial(mesh) {
|
|
59337
|
+
return Boolean(mesh.material);
|
|
59338
|
+
};
|
|
59339
|
+
var hasGeometry = function hasGeometry(mesh) {
|
|
59340
|
+
return Boolean(mesh.geometry);
|
|
59341
|
+
};
|
|
59342
|
+
var processMaterial = function processMaterial(material, callback) {
|
|
59343
|
+
return Array.isArray(material) ? material.map(callback) : callback(material);
|
|
59344
|
+
};
|
|
59345
|
+
var changeMaterialByName = function changeMaterialByName(name, mesh, materialOptions) {
|
|
59346
|
+
if (!hasMaterial(mesh)) return;
|
|
59347
|
+
|
|
59348
|
+
switch (name) {
|
|
59349
|
+
case MATERIALS.LAMBERT:
|
|
59350
|
+
return cloneMaterial(MeshLambertMaterial, mesh, materialOptions);
|
|
59351
|
+
|
|
59352
|
+
case MATERIALS.PHONG:
|
|
59353
|
+
return cloneMaterial(MeshPhongMaterial, mesh, materialOptions);
|
|
59354
|
+
|
|
59355
|
+
case MATERIALS.DEPTH:
|
|
59356
|
+
return cloneMaterial(MeshDepthMaterial, mesh, materialOptions);
|
|
59357
|
+
|
|
59358
|
+
case MATERIALS.STANDARD:
|
|
59359
|
+
return cloneMaterial(MeshStandardMaterial, mesh, materialOptions);
|
|
59360
|
+
|
|
59361
|
+
case MATERIALS.TOON:
|
|
59362
|
+
return cloneMaterial(ToonMaterial, mesh, materialOptions);
|
|
59363
|
+
|
|
59364
|
+
case MATERIALS.THREE_TOON:
|
|
59365
|
+
return cloneMaterial(MeshToonMaterial, mesh, materialOptions);
|
|
59366
|
+
|
|
59367
|
+
case MATERIALS.BASIC:
|
|
59368
|
+
default:
|
|
59369
|
+
return cloneMaterial(MeshBasicMaterial, mesh, materialOptions);
|
|
59370
|
+
}
|
|
59371
|
+
};
|
|
59372
|
+
|
|
59373
|
+
var cloneMaterial = function cloneMaterial(MeshMaterial, mesh) {
|
|
59374
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
59375
|
+
|
|
59376
|
+
var _cloneMaterial = function _cloneMaterial(material) {
|
|
59377
|
+
var clone = material.clone();
|
|
59378
|
+
var newMaterial = new MeshMaterial(_objectSpread2$1({
|
|
59379
|
+
map: clone.map,
|
|
59380
|
+
color: clone.color
|
|
59381
|
+
}, options));
|
|
59382
|
+
newMaterial.skinning = true;
|
|
59383
|
+
return newMaterial;
|
|
59384
|
+
};
|
|
59385
|
+
|
|
59386
|
+
mesh.material = processMaterial(mesh.material, _cloneMaterial);
|
|
59387
|
+
setUpLightsAndShadows(mesh);
|
|
59388
|
+
};
|
|
59389
|
+
|
|
59390
|
+
var disposeTextures = function disposeTextures(mesh) {
|
|
59391
|
+
if (hasMaterial(mesh)) {
|
|
59392
|
+
var _disposeTexture = function _disposeTexture(material) {
|
|
59393
|
+
Object.values(TEXTURES).forEach(function (key) {
|
|
59394
|
+
if (material[key]) {
|
|
59395
|
+
material[key].dispose();
|
|
59396
|
+
}
|
|
59372
59397
|
});
|
|
59373
|
-
}
|
|
59374
|
-
|
|
59375
|
-
|
|
59376
|
-
|
|
59377
|
-
|
|
59398
|
+
};
|
|
59399
|
+
|
|
59400
|
+
processMaterial(mesh.material, _disposeTexture);
|
|
59401
|
+
}
|
|
59402
|
+
};
|
|
59403
|
+
var disposeMaterial = function disposeMaterial(mesh) {
|
|
59404
|
+
if (hasMaterial(mesh)) {
|
|
59405
|
+
mesh.material.dispose && mesh.material.dispose();
|
|
59406
|
+
}
|
|
59407
|
+
};
|
|
59408
|
+
var disposeGeometry = function disposeGeometry(mesh) {
|
|
59409
|
+
if (hasGeometry(mesh)) {
|
|
59410
|
+
mesh.geometry.dispose && mesh.geometry.dispose();
|
|
59411
|
+
}
|
|
59412
|
+
};
|
|
59413
|
+
var prepareModel = function prepareModel(model) {
|
|
59414
|
+
setUpLightsAndShadows(model);
|
|
59415
|
+
model.traverse(function (mesh) {
|
|
59416
|
+
setUpLightsAndShadows(mesh);
|
|
59417
|
+
});
|
|
59418
|
+
return model;
|
|
59419
|
+
};var Entity = /*#__PURE__*/function (_EventDispatcher) {
|
|
59420
|
+
_inherits(Entity, _EventDispatcher);
|
|
59421
|
+
|
|
59422
|
+
var _super = _createSuper(Entity);
|
|
59423
|
+
|
|
59424
|
+
function Entity() {
|
|
59425
|
+
var _this;
|
|
59426
|
+
|
|
59427
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
59428
|
+
_ref$serializable = _ref.serializable,
|
|
59429
|
+
serializable = _ref$serializable === void 0 ? true : _ref$serializable,
|
|
59430
|
+
_ref$tag = _ref.tag,
|
|
59431
|
+
tag = _ref$tag === void 0 ? '' : _ref$tag,
|
|
59432
|
+
_ref$tags = _ref.tags,
|
|
59433
|
+
tags = _ref$tags === void 0 ? [] : _ref$tags;
|
|
59378
59434
|
|
|
59379
|
-
|
|
59380
|
-
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
59435
|
+
_classCallCheck(this, Entity);
|
|
59381
59436
|
|
|
59382
|
-
|
|
59383
|
-
x = _this$getPosition3.x,
|
|
59384
|
-
y = _this$getPosition3.y,
|
|
59385
|
-
z = _this$getPosition3.z;
|
|
59437
|
+
_this = _super.call(this);
|
|
59386
59438
|
|
|
59387
|
-
|
|
59388
|
-
|
|
59389
|
-
|
|
59390
|
-
y: y,
|
|
59391
|
-
z: z
|
|
59392
|
-
}, position).time(time).on('update', function (value) {
|
|
59393
|
-
return _this7.setPosition(value);
|
|
59394
|
-
}).on('complete', resolve);
|
|
59395
|
-
});
|
|
59396
|
-
}
|
|
59397
|
-
}, {
|
|
59398
|
-
key: "uuid",
|
|
59399
|
-
value: function uuid() {
|
|
59400
|
-
return this.body.uuid;
|
|
59401
|
-
}
|
|
59402
|
-
}, {
|
|
59403
|
-
key: "setId",
|
|
59404
|
-
value: function setId() {
|
|
59405
|
-
return this.body.id;
|
|
59406
|
-
}
|
|
59407
|
-
}, {
|
|
59408
|
-
key: "id",
|
|
59409
|
-
value: function id() {
|
|
59410
|
-
return this.body.id;
|
|
59411
|
-
}
|
|
59412
|
-
}, {
|
|
59413
|
-
key: "setVisible",
|
|
59414
|
-
value: function setVisible() {
|
|
59415
|
-
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
59416
|
-
this.getBody().visible = flag;
|
|
59417
|
-
}
|
|
59418
|
-
}, {
|
|
59419
|
-
key: "equals",
|
|
59420
|
-
value: function equals(entity) {
|
|
59421
|
-
try {
|
|
59422
|
-
return entity.uuid ? this.uuid() === entity.uuid() : false;
|
|
59423
|
-
} catch (e) {
|
|
59424
|
-
return false;
|
|
59425
|
-
}
|
|
59426
|
-
}
|
|
59427
|
-
}, {
|
|
59428
|
-
key: "setName",
|
|
59429
|
-
value: function setName(name) {
|
|
59430
|
-
this.name = name;
|
|
59431
|
-
}
|
|
59432
|
-
}, {
|
|
59433
|
-
key: "getName",
|
|
59434
|
-
value: function getName() {
|
|
59435
|
-
return this.name;
|
|
59436
|
-
}
|
|
59437
|
-
}, {
|
|
59438
|
-
key: "setData",
|
|
59439
|
-
value: function setData(key, value) {
|
|
59440
|
-
if (this.getBody().userData) {
|
|
59441
|
-
if (key && value) {
|
|
59442
|
-
this.getBody().userData[key] = value;
|
|
59443
|
-
} else {
|
|
59444
|
-
console.log(KEY_VALUE_IS_MISSING);
|
|
59445
|
-
}
|
|
59446
|
-
} else {
|
|
59447
|
-
console.log(USER_DATA_IS_MISSING);
|
|
59439
|
+
_defineProperty$1(_assertThisInitialized(_this), "getBodyByName", function (name) {
|
|
59440
|
+
if (name && _this.hasBody()) {
|
|
59441
|
+
return _this.getBody().getObjectByName(name);
|
|
59448
59442
|
}
|
|
59449
|
-
|
|
59450
|
-
|
|
59451
|
-
|
|
59452
|
-
|
|
59453
|
-
|
|
59454
|
-
|
|
59455
|
-
|
|
59456
|
-
|
|
59457
|
-
|
|
59458
|
-
|
|
59443
|
+
|
|
59444
|
+
console.warn(ELEMENT_NAME_NOT_PROVIDED);
|
|
59445
|
+
});
|
|
59446
|
+
|
|
59447
|
+
_defineProperty$1(_assertThisInitialized(_this), "addTag", function (tagName) {
|
|
59448
|
+
if (!tagName) return;
|
|
59449
|
+
|
|
59450
|
+
if (!_this.hasTag(tagName)) {
|
|
59451
|
+
_this.tags.push(tagName);
|
|
59452
|
+
|
|
59453
|
+
return true;
|
|
59459
59454
|
} else {
|
|
59460
|
-
console.log(
|
|
59455
|
+
console.log(TAG_ALREADY_EXISTS, tagName);
|
|
59456
|
+
return false;
|
|
59461
59457
|
}
|
|
59462
|
-
}
|
|
59463
|
-
|
|
59464
|
-
|
|
59465
|
-
|
|
59466
|
-
|
|
59467
|
-
|
|
59468
|
-
|
|
59469
|
-
|
|
59470
|
-
|
|
59471
|
-
|
|
59472
|
-
|
|
59473
|
-
|
|
59474
|
-
names: [],
|
|
59475
|
-
options: []
|
|
59476
|
-
});
|
|
59477
|
-
}
|
|
59478
|
-
}, {
|
|
59479
|
-
key: "toJSON",
|
|
59480
|
-
value: function toJSON() {
|
|
59481
|
-
if (this.isSerializable()) {
|
|
59458
|
+
});
|
|
59459
|
+
|
|
59460
|
+
_defineProperty$1(_assertThisInitialized(_this), "hasStateMachine", function () {
|
|
59461
|
+
return !!_this.stateMachine;
|
|
59462
|
+
});
|
|
59463
|
+
|
|
59464
|
+
_defineProperty$1(_assertThisInitialized(_this), "hasScripts", function () {
|
|
59465
|
+
return _this.scripts.length > 0;
|
|
59466
|
+
});
|
|
59467
|
+
|
|
59468
|
+
_defineProperty$1(_assertThisInitialized(_this), "parseScripts", function (list, options, enabled) {
|
|
59469
|
+
return list.map(function (script, i) {
|
|
59482
59470
|
return {
|
|
59483
|
-
|
|
59484
|
-
|
|
59485
|
-
|
|
59486
|
-
|
|
59487
|
-
tags: this.getTags()
|
|
59471
|
+
script: script,
|
|
59472
|
+
name: script.getName(),
|
|
59473
|
+
enabled: enabled,
|
|
59474
|
+
options: options[i]
|
|
59488
59475
|
};
|
|
59489
|
-
}
|
|
59490
|
-
}
|
|
59491
|
-
}], [{
|
|
59492
|
-
key: "create",
|
|
59493
|
-
value: function create() {
|
|
59494
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
59495
|
-
return new this(options);
|
|
59496
|
-
}
|
|
59497
|
-
}]);
|
|
59476
|
+
});
|
|
59477
|
+
});
|
|
59498
59478
|
|
|
59499
|
-
|
|
59500
|
-
|
|
59501
|
-
|
|
59479
|
+
_defineProperty$1(_assertThisInitialized(_this), "isMesh", function () {
|
|
59480
|
+
return _this.getEntityType() === ENTITY_TYPES.MESH;
|
|
59481
|
+
});
|
|
59502
59482
|
|
|
59503
|
-
|
|
59483
|
+
_defineProperty$1(_assertThisInitialized(_this), "isModel", function () {
|
|
59484
|
+
return _this.getEntityType() === ENTITY_TYPES.MODEL;
|
|
59485
|
+
});
|
|
59504
59486
|
|
|
59505
|
-
|
|
59506
|
-
|
|
59487
|
+
_defineProperty$1(_assertThisInitialized(_this), "isSprite", function () {
|
|
59488
|
+
return _this.getEntityType() === ENTITY_TYPES.SPRITE;
|
|
59489
|
+
});
|
|
59507
59490
|
|
|
59508
|
-
|
|
59491
|
+
_defineProperty$1(_assertThisInitialized(_this), "isLight", function () {
|
|
59492
|
+
return Object.values(ENTITY_TYPES.LIGHT).includes(_this.getEntityType());
|
|
59493
|
+
});
|
|
59509
59494
|
|
|
59510
|
-
|
|
59495
|
+
_defineProperty$1(_assertThisInitialized(_this), "isHelper", function () {
|
|
59496
|
+
return Object.values(ENTITY_TYPES.HELPER).includes(_this.getEntityType());
|
|
59497
|
+
});
|
|
59511
59498
|
|
|
59512
|
-
_this
|
|
59499
|
+
_defineProperty$1(_assertThisInitialized(_this), "isEffect", function () {
|
|
59500
|
+
return Object.values(ENTITY_TYPES.EFFECT).includes(_this.getEntityType());
|
|
59501
|
+
});
|
|
59513
59502
|
|
|
59514
|
-
_defineProperty$1(_assertThisInitialized(_this), "
|
|
59515
|
-
|
|
59516
|
-
|
|
59517
|
-
|
|
59503
|
+
_defineProperty$1(_assertThisInitialized(_this), "setQuaternion", function (_ref2) {
|
|
59504
|
+
var x = _ref2.x,
|
|
59505
|
+
y = _ref2.y,
|
|
59506
|
+
z = _ref2.z,
|
|
59507
|
+
w = _ref2.w;
|
|
59518
59508
|
|
|
59519
|
-
|
|
59520
|
-
type: type,
|
|
59521
|
-
action: action,
|
|
59522
|
-
direction: direction
|
|
59523
|
-
});
|
|
59524
|
-
};
|
|
59509
|
+
_this.body.quaternion.set(x, y, z, w);
|
|
59525
59510
|
});
|
|
59526
59511
|
|
|
59527
|
-
_this
|
|
59528
|
-
|
|
59529
|
-
|
|
59512
|
+
_defineProperty$1(_assertThisInitialized(_this), "setUuid", function (uuid) {
|
|
59513
|
+
if (uuid) {
|
|
59514
|
+
_this.body.uuid = uuid;
|
|
59515
|
+
}
|
|
59516
|
+
});
|
|
59530
59517
|
|
|
59531
|
-
_this.
|
|
59518
|
+
_this.scripts = [];
|
|
59519
|
+
_this.tags = [];
|
|
59520
|
+
_this.children = [];
|
|
59521
|
+
_this.isMage = true;
|
|
59522
|
+
_this.parent = false;
|
|
59523
|
+
_this.disposed = false;
|
|
59524
|
+
|
|
59525
|
+
_this.addTags([DEFAULT_TAG, tag].concat(_toConsumableArray(tags)));
|
|
59532
59526
|
|
|
59527
|
+
_this.serializable = serializable;
|
|
59533
59528
|
return _this;
|
|
59534
59529
|
}
|
|
59535
59530
|
|
|
59536
|
-
_createClass(
|
|
59537
|
-
key: "
|
|
59538
|
-
value: function
|
|
59539
|
-
|
|
59540
|
-
this.mixer.addEventListener('finished', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.FINISHED));
|
|
59541
|
-
}
|
|
59542
|
-
}, {
|
|
59543
|
-
key: "getAction",
|
|
59544
|
-
value: function getAction(id) {
|
|
59545
|
-
var action;
|
|
59546
|
-
|
|
59547
|
-
if (typeof id === 'number') {
|
|
59548
|
-
action = this.animations[id];
|
|
59549
|
-
} else if (typeof id === 'string') {
|
|
59550
|
-
action = AnimationClip.findByName(this.animations, id);
|
|
59551
|
-
}
|
|
59552
|
-
|
|
59553
|
-
return action;
|
|
59531
|
+
_createClass(Entity, [{
|
|
59532
|
+
key: "isSerializable",
|
|
59533
|
+
value: function isSerializable() {
|
|
59534
|
+
return !!this.serializable;
|
|
59554
59535
|
}
|
|
59555
59536
|
}, {
|
|
59556
|
-
key: "
|
|
59557
|
-
value: function
|
|
59558
|
-
return this.
|
|
59559
|
-
var name = _ref2.name;
|
|
59560
|
-
return name;
|
|
59561
|
-
});
|
|
59537
|
+
key: "isDisposed",
|
|
59538
|
+
value: function isDisposed() {
|
|
59539
|
+
return this.disposed;
|
|
59562
59540
|
}
|
|
59563
59541
|
}, {
|
|
59564
|
-
key: "
|
|
59565
|
-
value: function
|
|
59566
|
-
this.
|
|
59567
|
-
this.
|
|
59542
|
+
key: "reset",
|
|
59543
|
+
value: function reset() {
|
|
59544
|
+
this.scripts = [];
|
|
59545
|
+
this.children = [];
|
|
59546
|
+
this.isMage = true;
|
|
59547
|
+
this.parent = false;
|
|
59548
|
+
this.tags = [DEFAULT_TAG];
|
|
59568
59549
|
}
|
|
59569
59550
|
}, {
|
|
59570
|
-
key: "
|
|
59571
|
-
value: function
|
|
59572
|
-
|
|
59573
|
-
this.currentAction.stop();
|
|
59574
|
-
}
|
|
59575
|
-
|
|
59576
|
-
this.isPlaying = false;
|
|
59551
|
+
key: "hasBody",
|
|
59552
|
+
value: function hasBody() {
|
|
59553
|
+
return !!this.body;
|
|
59577
59554
|
}
|
|
59578
59555
|
}, {
|
|
59579
|
-
key: "
|
|
59580
|
-
value: function
|
|
59581
|
-
|
|
59582
|
-
var _options$loop = options.loop,
|
|
59583
|
-
loop = _options$loop === void 0 ? LoopRepeat : _options$loop;
|
|
59584
|
-
this.isPlaying = true;
|
|
59585
|
-
|
|
59586
|
-
if (this.currentAction) {
|
|
59587
|
-
this.fadeToAnimation(action, options);
|
|
59588
|
-
} else if (action) {
|
|
59589
|
-
this.currentAction = this.mixer.clipAction(action).setLoop(loop).play();
|
|
59590
|
-
} else {
|
|
59591
|
-
console.warn(ANIMATION_NOT_FOUND);
|
|
59592
|
-
}
|
|
59556
|
+
key: "getBody",
|
|
59557
|
+
value: function getBody() {
|
|
59558
|
+
return this.body;
|
|
59593
59559
|
}
|
|
59594
59560
|
}, {
|
|
59595
|
-
key: "
|
|
59596
|
-
value: function
|
|
59597
|
-
|
|
59598
|
-
_ref3$duration = _ref3.duration,
|
|
59599
|
-
duration = _ref3$duration === void 0 ? 0.2 : _ref3$duration,
|
|
59600
|
-
_ref3$loop = _ref3.loop,
|
|
59601
|
-
loop = _ref3$loop === void 0 ? LoopRepeat : _ref3$loop;
|
|
59602
|
-
|
|
59603
|
-
var previousAction = this.currentAction;
|
|
59604
|
-
this.currentAction = this.mixer.clipAction(action);
|
|
59605
|
-
|
|
59606
|
-
if (previousAction !== this.currentAction) {
|
|
59607
|
-
previousAction.fadeOut(duration);
|
|
59608
|
-
}
|
|
59609
|
-
|
|
59610
|
-
this.currentAction.reset().setEffectiveTimeScale(1).setEffectiveWeight(1).fadeIn(duration).setLoop(loop).play();
|
|
59561
|
+
key: "setBody",
|
|
59562
|
+
value: function setBody(body) {
|
|
59563
|
+
this.body = body;
|
|
59611
59564
|
}
|
|
59612
59565
|
}, {
|
|
59613
|
-
key: "
|
|
59614
|
-
value: function
|
|
59615
|
-
this.
|
|
59566
|
+
key: "hasParent",
|
|
59567
|
+
value: function hasParent() {
|
|
59568
|
+
return !!this.parent;
|
|
59616
59569
|
}
|
|
59617
|
-
}
|
|
59618
|
-
|
|
59619
|
-
|
|
59620
|
-
|
|
59621
|
-
|
|
59622
|
-
var Frustum = /*#__PURE__*/function () {
|
|
59623
|
-
function Frustum(data) {
|
|
59624
|
-
_classCallCheck(this, Frustum);
|
|
59625
|
-
|
|
59626
|
-
data = data || {};
|
|
59627
|
-
this.vertices = {
|
|
59628
|
-
near: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()],
|
|
59629
|
-
far: [new Vector3$1(), new Vector3$1(), new Vector3$1(), new Vector3$1()]
|
|
59630
|
-
};
|
|
59631
|
-
|
|
59632
|
-
if (data.projectionMatrix !== undefined) {
|
|
59633
|
-
this.setFromProjectionMatrix(data.projectionMatrix, data.maxFar || 10000);
|
|
59570
|
+
}, {
|
|
59571
|
+
key: "getParent",
|
|
59572
|
+
value: function getParent() {
|
|
59573
|
+
return this.parent;
|
|
59634
59574
|
}
|
|
59635
|
-
}
|
|
59636
|
-
|
|
59637
|
-
|
|
59638
|
-
|
|
59639
|
-
value: function setFromProjectionMatrix(projectionMatrix, maxFar) {
|
|
59640
|
-
var isOrthographic = projectionMatrix.elements[2 * 4 + 3] === 0;
|
|
59641
|
-
inverseProjectionMatrix.copy(projectionMatrix).invert(); // 3 --- 0 vertices.near/far order
|
|
59642
|
-
// | |
|
|
59643
|
-
// 2 --- 1
|
|
59644
|
-
// clip space spans from [-1, 1]
|
|
59645
|
-
|
|
59646
|
-
this.vertices.near[0].set(1, 1, -1);
|
|
59647
|
-
this.vertices.near[1].set(1, -1, -1);
|
|
59648
|
-
this.vertices.near[2].set(-1, -1, -1);
|
|
59649
|
-
this.vertices.near[3].set(-1, 1, -1);
|
|
59650
|
-
this.vertices.near.forEach(function (v) {
|
|
59651
|
-
v.applyMatrix4(inverseProjectionMatrix);
|
|
59652
|
-
});
|
|
59653
|
-
this.vertices.far[0].set(1, 1, 1);
|
|
59654
|
-
this.vertices.far[1].set(1, -1, 1);
|
|
59655
|
-
this.vertices.far[2].set(-1, -1, 1);
|
|
59656
|
-
this.vertices.far[3].set(-1, 1, 1);
|
|
59657
|
-
this.vertices.far.forEach(function (v) {
|
|
59658
|
-
v.applyMatrix4(inverseProjectionMatrix);
|
|
59659
|
-
var absZ = Math.abs(v.z);
|
|
59660
|
-
|
|
59661
|
-
if (isOrthographic) {
|
|
59662
|
-
v.z *= Math.min(maxFar / absZ, 1.0);
|
|
59663
|
-
} else {
|
|
59664
|
-
v.multiplyScalar(Math.min(maxFar / absZ, 1.0));
|
|
59665
|
-
}
|
|
59666
|
-
});
|
|
59667
|
-
return this.vertices;
|
|
59575
|
+
}, {
|
|
59576
|
+
key: "setParent",
|
|
59577
|
+
value: function setParent(parent) {
|
|
59578
|
+
this.parent = parent;
|
|
59668
59579
|
}
|
|
59669
59580
|
}, {
|
|
59670
|
-
key: "
|
|
59671
|
-
value: function
|
|
59672
|
-
|
|
59673
|
-
target.push(new Frustum());
|
|
59674
|
-
}
|
|
59581
|
+
key: "add",
|
|
59582
|
+
value: function add(child) {
|
|
59583
|
+
var _this2 = this;
|
|
59675
59584
|
|
|
59676
|
-
|
|
59585
|
+
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getBody();
|
|
59677
59586
|
|
|
59678
|
-
|
|
59679
|
-
var
|
|
59587
|
+
if (this.hasBody()) {
|
|
59588
|
+
var _add = function _add(toAdd) {
|
|
59589
|
+
if (toAdd instanceof Entity) {
|
|
59590
|
+
_this2.children.push(toAdd);
|
|
59680
59591
|
|
|
59681
|
-
|
|
59682
|
-
|
|
59683
|
-
|
|
59684
|
-
|
|
59685
|
-
} else {
|
|
59686
|
-
for (var _j = 0; _j < 4; _j++) {
|
|
59687
|
-
cascade.vertices.near[_j].lerpVectors(this.vertices.near[_j], this.vertices.far[_j], breaks[i - 1]);
|
|
59592
|
+
toAdd.setParent(_this2);
|
|
59593
|
+
container.add(toAdd.getBody());
|
|
59594
|
+
} else {
|
|
59595
|
+
console.log(ENTITY_CANT_ADD_NOT_ENTITY);
|
|
59688
59596
|
}
|
|
59689
|
-
}
|
|
59597
|
+
};
|
|
59690
59598
|
|
|
59691
|
-
if (
|
|
59692
|
-
|
|
59693
|
-
cascade.vertices.far[_j2].copy(this.vertices.far[_j2]);
|
|
59694
|
-
}
|
|
59599
|
+
if (Array.isArray(child)) {
|
|
59600
|
+
child.forEach(_add);
|
|
59695
59601
|
} else {
|
|
59696
|
-
|
|
59697
|
-
cascade.vertices.far[_j3].lerpVectors(this.vertices.near[_j3], this.vertices.far[_j3], breaks[i]);
|
|
59698
|
-
}
|
|
59602
|
+
_add(child);
|
|
59699
59603
|
}
|
|
59604
|
+
} else {
|
|
59605
|
+
console.log(ENTITY_NOT_SET);
|
|
59700
59606
|
}
|
|
59701
59607
|
}
|
|
59702
59608
|
}, {
|
|
59703
|
-
key: "
|
|
59704
|
-
value: function
|
|
59705
|
-
|
|
59706
|
-
|
|
59707
|
-
|
|
59708
|
-
}
|
|
59709
|
-
}
|
|
59710
|
-
}]);
|
|
59711
|
-
|
|
59712
|
-
return Frustum;
|
|
59713
|
-
}();var Shader$1 = {
|
|
59714
|
-
lights_fragment_begin:
|
|
59715
|
-
/* glsl */
|
|
59716
|
-
"\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n geometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n pointLight = pointLights[ i ];\n\n getPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n SpotLight spotLight;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n spotLight = spotLights[ i ];\n\n getSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n float linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n vec2 cascade;\n float cascadeCenter;\n float closestEdge;\n float margin;\n float csmx;\n float csmy;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n // NOTE: Depth gets larger away from the camera.\n // cascade.x is closer, cascade.y is further\n cascade = CSM_cascades[ i ];\n cascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n margin = 0.25 * pow( closestEdge, 2.0 );\n csmx = cascade.x - margin / 2.0;\n csmy = cascade.y + margin / 2.0;\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS && linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n float dist = min( linearDepth - csmx, csmy - linearDepth );\n float ratio = clamp( dist / margin, 0.0, 1.0 );\n if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) {\n\n vec3 prevColor = directLight.color;\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n }\n\n ReflectedLight prevLight = reflectedLight;\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n float blendRatio = shouldBlend ? ratio : 1.0;\n\n reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n }\n\n }\n #pragma unroll_loop_end\n #else\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #endif\n\n if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n directionalLight = directionalLights[ i ];\n\n getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n\n RE_Direct( directLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n RectAreaLight rectAreaLight;\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n }\n #pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n vec3 iblIrradiance = vec3( 0.0 );\n\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n irradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n #if ( NUM_HEMI_LIGHTS > 0 )\n\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n }\n #pragma unroll_loop_end\n\n #endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",
|
|
59717
|
-
lights_pars_begin:
|
|
59718
|
-
/* glsl */
|
|
59719
|
-
"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n " + ShaderChunk.lights_pars_begin
|
|
59720
|
-
};var _cameraToLightMatrix = new Matrix4();
|
|
59721
|
-
|
|
59722
|
-
var _lightSpaceFrustum = new Frustum();
|
|
59723
|
-
|
|
59724
|
-
var _center = new Vector3$1();
|
|
59725
|
-
|
|
59726
|
-
var _bbox = new Box3();
|
|
59727
|
-
|
|
59728
|
-
var _uniformArray = [];
|
|
59729
|
-
var _logArray = [];
|
|
59730
|
-
var DEFAULT_MAX_FAR = 100000;
|
|
59731
|
-
var DEFAULT_MODE = 'practical';
|
|
59732
|
-
var DEFAULT_SHADOWMAP_SIZE = 2048;
|
|
59733
|
-
var DEFAULT_CASCADE = 3;
|
|
59734
|
-
var DEFAULT_BIAS$3 = 0.000001;
|
|
59735
|
-
var DEFAULT_INTENSITY$5 = 1;
|
|
59736
|
-
var DEFAULT_NEAR$3 = 1;
|
|
59737
|
-
var DEFAULT_FAR$3 = 2000;
|
|
59738
|
-
var DEFAULT_MARGIN = 200;
|
|
59739
|
-
var CascadeShadowMaps = /*#__PURE__*/function () {
|
|
59740
|
-
function CascadeShadowMaps(_ref) {
|
|
59741
|
-
var _ref$camera = _ref.camera,
|
|
59742
|
-
camera = _ref$camera === void 0 ? Scene$1.getCameraBody() : _ref$camera,
|
|
59743
|
-
_ref$parent = _ref.parent,
|
|
59744
|
-
parent = _ref$parent === void 0 ? Scene$1.getScene() : _ref$parent,
|
|
59745
|
-
_ref$cascades = _ref.cascades,
|
|
59746
|
-
cascades = _ref$cascades === void 0 ? DEFAULT_CASCADE : _ref$cascades,
|
|
59747
|
-
_ref$maxFar = _ref.maxFar,
|
|
59748
|
-
maxFar = _ref$maxFar === void 0 ? DEFAULT_MAX_FAR : _ref$maxFar,
|
|
59749
|
-
_ref$mode = _ref.mode,
|
|
59750
|
-
mode = _ref$mode === void 0 ? DEFAULT_MODE : _ref$mode,
|
|
59751
|
-
_ref$shadowMapSize = _ref.shadowMapSize,
|
|
59752
|
-
shadowMapSize = _ref$shadowMapSize === void 0 ? DEFAULT_SHADOWMAP_SIZE : _ref$shadowMapSize,
|
|
59753
|
-
_ref$shadowBias = _ref.shadowBias,
|
|
59754
|
-
shadowBias = _ref$shadowBias === void 0 ? DEFAULT_BIAS$3 : _ref$shadowBias,
|
|
59755
|
-
_ref$lightDirection = _ref.lightDirection,
|
|
59756
|
-
lightDirection = _ref$lightDirection === void 0 ? new Vector3$1(1, -1, 1).normalize() : _ref$lightDirection,
|
|
59757
|
-
_ref$lightIntensity = _ref.lightIntensity,
|
|
59758
|
-
lightIntensity = _ref$lightIntensity === void 0 ? DEFAULT_INTENSITY$5 : _ref$lightIntensity,
|
|
59759
|
-
_ref$lightNear = _ref.lightNear,
|
|
59760
|
-
lightNear = _ref$lightNear === void 0 ? DEFAULT_NEAR$3 : _ref$lightNear,
|
|
59761
|
-
_ref$lightFar = _ref.lightFar,
|
|
59762
|
-
lightFar = _ref$lightFar === void 0 ? DEFAULT_FAR$3 : _ref$lightFar,
|
|
59763
|
-
_ref$lightMargin = _ref.lightMargin,
|
|
59764
|
-
lightMargin = _ref$lightMargin === void 0 ? DEFAULT_MARGIN : _ref$lightMargin,
|
|
59765
|
-
customSplitsCallback = _ref.customSplitsCallback;
|
|
59766
|
-
|
|
59767
|
-
_classCallCheck(this, CascadeShadowMaps);
|
|
59609
|
+
key: "isParentOf",
|
|
59610
|
+
value: function isParentOf(child) {
|
|
59611
|
+
var comparator = function comparator(child) {
|
|
59612
|
+
return !!child.getBody().getObjectById(child.id);
|
|
59613
|
+
};
|
|
59768
59614
|
|
|
59769
|
-
|
|
59770
|
-
|
|
59771
|
-
|
|
59772
|
-
|
|
59773
|
-
|
|
59774
|
-
this.shadowMapSize = shadowMapSize;
|
|
59775
|
-
this.shadowBias = shadowBias;
|
|
59776
|
-
this.lightDirection = lightDirection;
|
|
59777
|
-
this.lightIntensity = lightIntensity;
|
|
59778
|
-
this.lightNear = lightNear;
|
|
59779
|
-
this.lightFar = lightFar;
|
|
59780
|
-
this.lightMargin = lightMargin;
|
|
59781
|
-
this.customSplitsCallback = customSplitsCallback;
|
|
59782
|
-
this.fade = false;
|
|
59783
|
-
this.mainFrustum = new Frustum();
|
|
59784
|
-
this.frustums = [];
|
|
59785
|
-
this.breaks = [];
|
|
59786
|
-
this.lights = [];
|
|
59787
|
-
this.shaders = new Map();
|
|
59788
|
-
this.createLights();
|
|
59789
|
-
this.updateFrustums();
|
|
59790
|
-
this.injectInclude();
|
|
59791
|
-
}
|
|
59615
|
+
if (child.isMage) {
|
|
59616
|
+
comparator = function comparator(child) {
|
|
59617
|
+
return child.getBody().getObjectById(child.id());
|
|
59618
|
+
};
|
|
59619
|
+
}
|
|
59792
59620
|
|
|
59793
|
-
|
|
59794
|
-
|
|
59795
|
-
|
|
59796
|
-
|
|
59797
|
-
|
|
59798
|
-
|
|
59799
|
-
|
|
59800
|
-
|
|
59801
|
-
|
|
59802
|
-
light.shadow.camera.far = this.lightFar;
|
|
59803
|
-
light.shadow.bias = this.shadowBias;
|
|
59804
|
-
this.parent.add(light);
|
|
59805
|
-
this.parent.add(light.target);
|
|
59806
|
-
this.lights.push(light);
|
|
59621
|
+
return this.children.filter(comparator).length > 0;
|
|
59622
|
+
}
|
|
59623
|
+
}, {
|
|
59624
|
+
key: "has",
|
|
59625
|
+
value: function has(child) {
|
|
59626
|
+
if (child.isMage) {
|
|
59627
|
+
return this.equals(child) || this.isParentOf(child);
|
|
59628
|
+
} else {
|
|
59629
|
+
return !!this.getBody().getObjectById(child.id);
|
|
59807
59630
|
}
|
|
59808
59631
|
}
|
|
59809
59632
|
}, {
|
|
59810
|
-
key: "
|
|
59811
|
-
value: function
|
|
59812
|
-
|
|
59813
|
-
|
|
59814
|
-
|
|
59815
|
-
|
|
59633
|
+
key: "remove",
|
|
59634
|
+
value: function remove(element) {
|
|
59635
|
+
if (this.hasBody() && this.has(element)) {
|
|
59636
|
+
if (element.isMage) {
|
|
59637
|
+
this.body.remove(element.getBody());
|
|
59638
|
+
var index = this.children.findIndex(function (m) {
|
|
59639
|
+
return m.equals(element);
|
|
59640
|
+
});
|
|
59641
|
+
if (index) this.children.splice(index, 1);
|
|
59642
|
+
} else {
|
|
59643
|
+
this.body.remove(element.getBody());
|
|
59644
|
+
}
|
|
59645
|
+
}
|
|
59816
59646
|
}
|
|
59817
59647
|
}, {
|
|
59818
|
-
key: "
|
|
59819
|
-
value: function
|
|
59820
|
-
|
|
59648
|
+
key: "addTo",
|
|
59649
|
+
value: function addTo(target, childName) {
|
|
59650
|
+
if (target && target.isMage) {
|
|
59651
|
+
if (childName) {
|
|
59652
|
+
target.add(this, target.getBodyByName(childName));
|
|
59653
|
+
} else {
|
|
59654
|
+
target.add(this);
|
|
59655
|
+
}
|
|
59656
|
+
}
|
|
59657
|
+
}
|
|
59658
|
+
}, {
|
|
59659
|
+
key: "hasChildren",
|
|
59660
|
+
value: function hasChildren() {
|
|
59661
|
+
return this.children.length > 0;
|
|
59662
|
+
}
|
|
59663
|
+
}, {
|
|
59664
|
+
key: "getHierarchy",
|
|
59665
|
+
value: function getHierarchy() {
|
|
59666
|
+
return {
|
|
59667
|
+
element: this,
|
|
59668
|
+
children: this.children.map(function (e) {
|
|
59669
|
+
return e.getHierarchy();
|
|
59670
|
+
})
|
|
59671
|
+
};
|
|
59672
|
+
}
|
|
59673
|
+
}, {
|
|
59674
|
+
key: "addTags",
|
|
59675
|
+
value: function addTags() {
|
|
59676
|
+
var tags = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
59677
|
+
tags.forEach(this.addTag);
|
|
59678
|
+
}
|
|
59679
|
+
}, {
|
|
59680
|
+
key: "removeTag",
|
|
59681
|
+
value: function removeTag(tagName) {
|
|
59682
|
+
if (tagName === DEFAULT_TAG) {
|
|
59683
|
+
console.log(TAG_CANT_BE_REMOVED);
|
|
59684
|
+
return;
|
|
59685
|
+
}
|
|
59821
59686
|
|
|
59822
|
-
|
|
59823
|
-
|
|
59824
|
-
|
|
59825
|
-
|
|
59826
|
-
|
|
59827
|
-
|
|
59687
|
+
if (this.hasTag(tagName)) {
|
|
59688
|
+
this.tags.splice(this.tags.indexOf(tagName), 1);
|
|
59689
|
+
} else {
|
|
59690
|
+
console.log(TAG_NOT_EXISTING_REMOVAL);
|
|
59691
|
+
}
|
|
59692
|
+
}
|
|
59693
|
+
}, {
|
|
59694
|
+
key: "removeAllTags",
|
|
59695
|
+
value: function removeAllTags() {
|
|
59696
|
+
this.tags = [DEFAULT_TAG];
|
|
59697
|
+
}
|
|
59698
|
+
}, {
|
|
59699
|
+
key: "hasTag",
|
|
59700
|
+
value: function hasTag(tagName) {
|
|
59701
|
+
return this.tags.includes(tagName);
|
|
59702
|
+
}
|
|
59703
|
+
}, {
|
|
59704
|
+
key: "getTags",
|
|
59705
|
+
value: function getTags() {
|
|
59706
|
+
return this.tags;
|
|
59707
|
+
}
|
|
59708
|
+
}, {
|
|
59709
|
+
key: "disposeScripts",
|
|
59710
|
+
value: function disposeScripts() {
|
|
59711
|
+
if (this.hasScripts()) {
|
|
59712
|
+
var length = this.scripts.length;
|
|
59828
59713
|
|
|
59829
|
-
var
|
|
59830
|
-
|
|
59831
|
-
|
|
59832
|
-
|
|
59714
|
+
for (var i = 0; i < length; i++) {
|
|
59715
|
+
var _this$scripts$i = this.scripts[i],
|
|
59716
|
+
script = _this$scripts$i.script,
|
|
59717
|
+
enabled = _this$scripts$i.enabled;
|
|
59833
59718
|
|
|
59834
|
-
|
|
59835
|
-
|
|
59836
|
-
} else {
|
|
59837
|
-
point2 = nearVerts[2];
|
|
59838
|
-
}
|
|
59719
|
+
if (enabled) {
|
|
59720
|
+
script.onDispose();
|
|
59839
59721
|
|
|
59840
|
-
|
|
59722
|
+
script.__setStartedFlag(false);
|
|
59723
|
+
}
|
|
59841
59724
|
|
|
59842
|
-
|
|
59843
|
-
// expand the shadow extents by the fade margin if fade is enabled.
|
|
59844
|
-
var camera = this.camera;
|
|
59845
|
-
var far = Math.max(camera.far, this.maxFar);
|
|
59846
|
-
var linearDepth = frustum.vertices.far[0].z / (far - camera.near);
|
|
59847
|
-
var margin = 0.25 * Math.pow(linearDepth, 2.0) * (far - camera.near);
|
|
59848
|
-
squaredBBWidth += margin;
|
|
59725
|
+
delete this.scripts[i];
|
|
59849
59726
|
}
|
|
59850
|
-
|
|
59851
|
-
shadowCam.left = -squaredBBWidth / 2;
|
|
59852
|
-
shadowCam.right = squaredBBWidth / 2;
|
|
59853
|
-
shadowCam.top = squaredBBWidth / 2;
|
|
59854
|
-
shadowCam.bottom = -squaredBBWidth / 2;
|
|
59855
|
-
shadowCam.updateProjectionMatrix();
|
|
59856
59727
|
}
|
|
59857
59728
|
}
|
|
59858
59729
|
}, {
|
|
59859
|
-
key: "
|
|
59860
|
-
value: function
|
|
59861
|
-
var
|
|
59862
|
-
var far = Math.min(camera.far, this.maxFar);
|
|
59863
|
-
this.breaks.length = 0;
|
|
59864
|
-
|
|
59865
|
-
switch (this.mode) {
|
|
59866
|
-
case 'uniform':
|
|
59867
|
-
uniformSplit(this.cascades, camera.near, far, this.breaks);
|
|
59868
|
-
break;
|
|
59730
|
+
key: "start",
|
|
59731
|
+
value: function start() {
|
|
59732
|
+
var _this3 = this;
|
|
59869
59733
|
|
|
59870
|
-
|
|
59871
|
-
|
|
59872
|
-
|
|
59734
|
+
if (this.hasScripts()) {
|
|
59735
|
+
this.scripts.forEach(function (_ref3) {
|
|
59736
|
+
var script = _ref3.script,
|
|
59737
|
+
enabled = _ref3.enabled,
|
|
59738
|
+
options = _ref3.options;
|
|
59873
59739
|
|
|
59874
|
-
|
|
59875
|
-
|
|
59876
|
-
break;
|
|
59740
|
+
if (enabled) {
|
|
59741
|
+
script.start(_this3, options);
|
|
59877
59742
|
|
|
59878
|
-
|
|
59879
|
-
|
|
59880
|
-
|
|
59881
|
-
break;
|
|
59743
|
+
script.__setStartedFlag(true);
|
|
59744
|
+
}
|
|
59745
|
+
});
|
|
59882
59746
|
}
|
|
59747
|
+
}
|
|
59748
|
+
}, {
|
|
59749
|
+
key: "update",
|
|
59750
|
+
value: function update(dt) {
|
|
59751
|
+
if (this.hasScripts()) {
|
|
59752
|
+
this.scripts.forEach(function (_ref4) {
|
|
59753
|
+
var script = _ref4.script,
|
|
59754
|
+
enabled = _ref4.enabled;
|
|
59883
59755
|
|
|
59884
|
-
|
|
59885
|
-
|
|
59886
|
-
|
|
59887
|
-
}
|
|
59756
|
+
if (script && enabled) {
|
|
59757
|
+
script.update(dt);
|
|
59758
|
+
}
|
|
59759
|
+
});
|
|
59760
|
+
}
|
|
59761
|
+
}
|
|
59762
|
+
}, {
|
|
59763
|
+
key: "onPhysicsUpdate",
|
|
59764
|
+
value: function onPhysicsUpdate(dt) {
|
|
59765
|
+
if (this.hasScripts()) {
|
|
59766
|
+
this.scripts.forEach(function (_ref5) {
|
|
59767
|
+
var script = _ref5.script,
|
|
59768
|
+
enabled = _ref5.enabled;
|
|
59888
59769
|
|
|
59889
|
-
|
|
59770
|
+
if (script && enabled) {
|
|
59771
|
+
script.physicsUpdate(dt);
|
|
59772
|
+
}
|
|
59773
|
+
});
|
|
59890
59774
|
}
|
|
59775
|
+
}
|
|
59776
|
+
}, {
|
|
59777
|
+
key: "disposeBody",
|
|
59778
|
+
value: function disposeBody() {
|
|
59779
|
+
this.getBody().clear();
|
|
59891
59780
|
|
|
59892
|
-
|
|
59893
|
-
|
|
59894
|
-
|
|
59895
|
-
|
|
59781
|
+
if (this.getBody().dispose && !isScene(this.getBody())) {
|
|
59782
|
+
this.getBody().dispose();
|
|
59783
|
+
}
|
|
59784
|
+
}
|
|
59785
|
+
}, {
|
|
59786
|
+
key: "dispose",
|
|
59787
|
+
value: function dispose() {
|
|
59788
|
+
if (this.hasChildren()) {
|
|
59789
|
+
this.children.forEach(function (child) {
|
|
59790
|
+
child.dispose();
|
|
59791
|
+
});
|
|
59792
|
+
}
|
|
59896
59793
|
|
|
59897
|
-
|
|
59794
|
+
if (this.hasBody()) {
|
|
59795
|
+
this.stopStateMachine();
|
|
59796
|
+
this.disposeScripts();
|
|
59797
|
+
Scene$1.remove(this.getBody());
|
|
59798
|
+
this.disposeBody();
|
|
59898
59799
|
}
|
|
59899
59800
|
|
|
59900
|
-
|
|
59901
|
-
|
|
59902
|
-
|
|
59903
|
-
|
|
59904
|
-
|
|
59801
|
+
this.dispatchEvent({
|
|
59802
|
+
type: ENTITY_EVENTS.DISPOSE
|
|
59803
|
+
});
|
|
59804
|
+
this.reset();
|
|
59805
|
+
}
|
|
59806
|
+
}, {
|
|
59807
|
+
key: "addStateMachine",
|
|
59808
|
+
value: function addStateMachine(description) {
|
|
59809
|
+
var _this4 = this;
|
|
59905
59810
|
|
|
59906
|
-
|
|
59907
|
-
|
|
59908
|
-
|
|
59811
|
+
this.stateMachine = interpret(createMachine(description)).onTransition(function (state) {
|
|
59812
|
+
_this4.dispatchEvent({
|
|
59813
|
+
type: ENTITY_EVENTS.STATE_MACHINE.CHANGE,
|
|
59814
|
+
state: state
|
|
59815
|
+
});
|
|
59816
|
+
});
|
|
59817
|
+
|
|
59818
|
+
if (description.autostart) {
|
|
59819
|
+
this.startStateMachine();
|
|
59820
|
+
}
|
|
59821
|
+
}
|
|
59822
|
+
}, {
|
|
59823
|
+
key: "startStateMachine",
|
|
59824
|
+
value: function startStateMachine() {
|
|
59825
|
+
if (this.hasStateMachine()) {
|
|
59826
|
+
this.stateMachine.start();
|
|
59827
|
+
} else {
|
|
59828
|
+
console.log(STATE_MACHINE_NOT_AVAILABLE);
|
|
59829
|
+
}
|
|
59830
|
+
}
|
|
59831
|
+
}, {
|
|
59832
|
+
key: "stopStateMachine",
|
|
59833
|
+
value: function stopStateMachine() {
|
|
59834
|
+
if (this.hasStateMachine()) {
|
|
59835
|
+
this.stateMachine.stop();
|
|
59836
|
+
}
|
|
59837
|
+
}
|
|
59838
|
+
}, {
|
|
59839
|
+
key: "changeState",
|
|
59840
|
+
value: function changeState(event) {
|
|
59841
|
+
if (this.hasStateMachine()) {
|
|
59842
|
+
this.stateMachine.send(event);
|
|
59843
|
+
} else {
|
|
59844
|
+
console.log(STATE_MACHINE_NOT_AVAILABLE);
|
|
59845
|
+
}
|
|
59846
|
+
}
|
|
59847
|
+
}, {
|
|
59848
|
+
key: "getScript",
|
|
59849
|
+
value: function getScript(name) {
|
|
59850
|
+
var script = this.scripts.filter(function (script) {
|
|
59851
|
+
return script.name === name;
|
|
59852
|
+
})[0].script;
|
|
59909
59853
|
|
|
59910
|
-
|
|
59854
|
+
if (script) {
|
|
59855
|
+
return script;
|
|
59856
|
+
} else {
|
|
59857
|
+
console.warn(SCRIPT_NOT_FOUND);
|
|
59911
59858
|
}
|
|
59912
59859
|
}
|
|
59913
59860
|
}, {
|
|
59914
|
-
key: "
|
|
59915
|
-
value: function
|
|
59916
|
-
var
|
|
59917
|
-
var frustums = this.frustums;
|
|
59918
|
-
|
|
59919
|
-
for (var i = 0; i < frustums.length; i++) {
|
|
59920
|
-
var light = this.lights[i];
|
|
59921
|
-
var shadowCam = light.shadow.camera;
|
|
59922
|
-
var texelWidth = (shadowCam.right - shadowCam.left) / this.shadowMapSize;
|
|
59923
|
-
var texelHeight = (shadowCam.top - shadowCam.bottom) / this.shadowMapSize;
|
|
59924
|
-
light.shadow.camera.updateMatrixWorld(true);
|
|
59925
|
-
|
|
59926
|
-
_cameraToLightMatrix.multiplyMatrices(light.shadow.camera.matrixWorldInverse, camera.matrixWorld);
|
|
59861
|
+
key: "addScripts",
|
|
59862
|
+
value: function addScripts() {
|
|
59863
|
+
var _this5 = this;
|
|
59927
59864
|
|
|
59928
|
-
|
|
59929
|
-
|
|
59930
|
-
|
|
59865
|
+
var scripts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
59866
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
59867
|
+
var enabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
59868
|
+
var parsedScripts = this.parseScripts(scripts, options, enabled);
|
|
59869
|
+
this.scripts = [].concat(_toConsumableArray(this.scripts), [parsedScripts]);
|
|
59931
59870
|
|
|
59932
|
-
|
|
59871
|
+
if (enabled) {
|
|
59872
|
+
parsedScripts.forEach(function (parsed) {
|
|
59873
|
+
return parsed.start(_this5, parsed.options);
|
|
59874
|
+
});
|
|
59875
|
+
}
|
|
59876
|
+
}
|
|
59877
|
+
}, {
|
|
59878
|
+
key: "addScript",
|
|
59879
|
+
value: function addScript(name) {
|
|
59880
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
59881
|
+
var script = Scripts$1.get(name);
|
|
59882
|
+
var _options$enabled = options.enabled,
|
|
59883
|
+
enabled = _options$enabled === void 0 ? true : _options$enabled;
|
|
59933
59884
|
|
|
59934
|
-
|
|
59935
|
-
|
|
59885
|
+
if (script) {
|
|
59886
|
+
this.scripts.push({
|
|
59887
|
+
script: script,
|
|
59888
|
+
name: name,
|
|
59889
|
+
enabled: enabled,
|
|
59890
|
+
options: options
|
|
59891
|
+
});
|
|
59936
59892
|
|
|
59937
|
-
|
|
59893
|
+
if (enabled) {
|
|
59894
|
+
script.start(this, options);
|
|
59938
59895
|
}
|
|
59896
|
+
} else {
|
|
59897
|
+
console.log(SCRIPT_NOT_FOUND);
|
|
59898
|
+
}
|
|
59939
59899
|
|
|
59940
|
-
|
|
59941
|
-
|
|
59942
|
-
|
|
59943
|
-
|
|
59944
|
-
|
|
59945
|
-
|
|
59946
|
-
|
|
59947
|
-
|
|
59948
|
-
|
|
59949
|
-
|
|
59950
|
-
|
|
59951
|
-
|
|
59952
|
-
|
|
59900
|
+
return script;
|
|
59901
|
+
}
|
|
59902
|
+
}, {
|
|
59903
|
+
key: "enableScripts",
|
|
59904
|
+
value: function enableScripts() {
|
|
59905
|
+
this.scriptsEnabled = true;
|
|
59906
|
+
}
|
|
59907
|
+
}, {
|
|
59908
|
+
key: "disableScripts",
|
|
59909
|
+
value: function disableScripts() {
|
|
59910
|
+
this.scriptsEnabled = false;
|
|
59911
|
+
}
|
|
59912
|
+
}, {
|
|
59913
|
+
key: "setEntityType",
|
|
59914
|
+
value: function setEntityType(type) {
|
|
59915
|
+
if (FLAT_ENTITY_TYPES.includes(type)) {
|
|
59916
|
+
this.entityType = type;
|
|
59917
|
+
} else {
|
|
59918
|
+
console.log(ENTITY_TYPE_NOT_ALLOWED);
|
|
59919
|
+
this.entityType = ENTITY_TYPES.UNKNOWN;
|
|
59953
59920
|
}
|
|
59954
59921
|
}
|
|
59955
59922
|
}, {
|
|
59956
|
-
key: "
|
|
59957
|
-
value: function
|
|
59958
|
-
|
|
59959
|
-
ShaderChunk.lights_pars_begin = Shader$1.lights_pars_begin;
|
|
59923
|
+
key: "getEntityType",
|
|
59924
|
+
value: function getEntityType() {
|
|
59925
|
+
return this.entityType;
|
|
59960
59926
|
}
|
|
59961
59927
|
}, {
|
|
59962
|
-
key: "
|
|
59963
|
-
|
|
59964
|
-
|
|
59965
|
-
|
|
59966
|
-
|
|
59928
|
+
key: "addLight",
|
|
59929
|
+
// TODO: sounds should become entities
|
|
59930
|
+
// addSound(name, options) {
|
|
59931
|
+
// const { autoplay = false, ...opts } = options;
|
|
59932
|
+
// this.isPlayingSound = autoplay;
|
|
59933
|
+
// this.sound = new Sound(name, {
|
|
59934
|
+
// autoplay,
|
|
59935
|
+
// ...opts
|
|
59936
|
+
// });
|
|
59937
|
+
// this.sound.setTarget(this);
|
|
59938
|
+
// return this.sound;
|
|
59939
|
+
// }
|
|
59940
|
+
// addDirectionalSound(name, options) {
|
|
59941
|
+
// const { autoplay = false, ...opts } = options;
|
|
59942
|
+
// this.isPlayingSound = autoplay;
|
|
59943
|
+
// this.sound = new DirectionalSound(name, {
|
|
59944
|
+
// autoplay,
|
|
59945
|
+
// ...opts
|
|
59946
|
+
// });
|
|
59947
|
+
// this.sound.setTarget(this);
|
|
59948
|
+
// return this.sound;
|
|
59949
|
+
// }
|
|
59950
|
+
// addAmbientSound(name, options) {
|
|
59951
|
+
// const { autoplay = false, ...opts } = options;
|
|
59952
|
+
// this.isPlayingSound = autoplay;
|
|
59953
|
+
// this.sound = new AmbientSound(name, {
|
|
59954
|
+
// body: this.body,
|
|
59955
|
+
// autoplay,
|
|
59956
|
+
// ...opts
|
|
59957
|
+
// });
|
|
59958
|
+
// return this.sound;
|
|
59959
|
+
// }
|
|
59960
|
+
value: function addLight(light) {
|
|
59961
|
+
var _this$getPosition = this.getPosition(),
|
|
59962
|
+
x = _this$getPosition.x,
|
|
59963
|
+
y = _this$getPosition.y,
|
|
59964
|
+
z = _this$getPosition.z;
|
|
59967
59965
|
|
|
59968
|
-
|
|
59969
|
-
|
|
59966
|
+
light.setPosition({
|
|
59967
|
+
x: x,
|
|
59968
|
+
y: y,
|
|
59969
|
+
z: z
|
|
59970
|
+
});
|
|
59971
|
+
this.light = light;
|
|
59972
|
+
}
|
|
59973
|
+
}, {
|
|
59974
|
+
key: "playSound",
|
|
59975
|
+
value: function playSound() {
|
|
59976
|
+
if (this.sound && !this.isPlayingSound) {
|
|
59977
|
+
this.sound.play();
|
|
59978
|
+
this.isPlayingSound = true;
|
|
59970
59979
|
}
|
|
59971
|
-
|
|
59972
|
-
|
|
59973
|
-
|
|
59974
|
-
|
|
59975
|
-
|
|
59976
|
-
|
|
59977
|
-
|
|
59978
|
-
|
|
59979
|
-
|
|
59980
|
-
|
|
59981
|
-
|
|
59982
|
-
|
|
59983
|
-
|
|
59984
|
-
|
|
59985
|
-
|
|
59986
|
-
|
|
59987
|
-
};
|
|
59988
|
-
shaders.set(material, shader);
|
|
59980
|
+
}
|
|
59981
|
+
}, {
|
|
59982
|
+
key: "stopSound",
|
|
59983
|
+
value: function stopSound() {
|
|
59984
|
+
if (this.sound && this.isPlayingSound) {
|
|
59985
|
+
this.sound.stop();
|
|
59986
|
+
this.isPlayingSound = false;
|
|
59987
|
+
}
|
|
59988
|
+
}
|
|
59989
|
+
}, {
|
|
59990
|
+
key: "getScale",
|
|
59991
|
+
value: function getScale() {
|
|
59992
|
+
return {
|
|
59993
|
+
x: this.body.scale.x,
|
|
59994
|
+
y: this.body.scale.y,
|
|
59995
|
+
z: this.body.scale.z
|
|
59989
59996
|
};
|
|
59990
|
-
|
|
59991
|
-
shaders.set(material, null);
|
|
59992
59997
|
}
|
|
59993
59998
|
}, {
|
|
59994
|
-
key: "
|
|
59995
|
-
value: function
|
|
59996
|
-
|
|
59997
|
-
|
|
59998
|
-
shaders.forEach(function (shader, material) {
|
|
59999
|
-
if (shader !== null) {
|
|
60000
|
-
var uniforms = shader.uniforms;
|
|
60001
|
-
this.getExtendedBreaks(uniforms.CSM_cascades.value);
|
|
60002
|
-
uniforms.cameraNear.value = this.camera.near;
|
|
60003
|
-
uniforms.shadowFar.value = far;
|
|
60004
|
-
}
|
|
59999
|
+
key: "setScale",
|
|
60000
|
+
value: function setScale(howbig) {
|
|
60001
|
+
if (this.hasBody()) {
|
|
60002
|
+
var scale = _objectSpread2$1(_objectSpread2$1({}, this.getScale()), howbig);
|
|
60005
60003
|
|
|
60006
|
-
|
|
60007
|
-
|
|
60008
|
-
material.needsUpdate = true;
|
|
60009
|
-
} else if (this.fade && !('CSM_FADE' in material.defines)) {
|
|
60010
|
-
material.defines.CSM_FADE = '';
|
|
60011
|
-
material.needsUpdate = true;
|
|
60012
|
-
}
|
|
60013
|
-
}, this);
|
|
60004
|
+
this.body.scale.set(scale.x, scale.y, scale.z);
|
|
60005
|
+
}
|
|
60014
60006
|
}
|
|
60015
60007
|
}, {
|
|
60016
|
-
key: "
|
|
60017
|
-
value: function
|
|
60018
|
-
|
|
60019
|
-
|
|
60008
|
+
key: "getQuaternion",
|
|
60009
|
+
value: function getQuaternion() {
|
|
60010
|
+
if (this.hasBody()) {
|
|
60011
|
+
return this.getBody().quaternion.clone();
|
|
60012
|
+
}
|
|
60013
|
+
}
|
|
60014
|
+
}, {
|
|
60015
|
+
key: "getPosition",
|
|
60016
|
+
value: function getPosition() {
|
|
60017
|
+
return this.getBody().position.clone();
|
|
60018
|
+
}
|
|
60019
|
+
}, {
|
|
60020
|
+
key: "setPosition",
|
|
60021
|
+
value: function setPosition(where) {
|
|
60022
|
+
if (this.hasBody()) {
|
|
60023
|
+
var _this$getPosition2 = this.getPosition(),
|
|
60024
|
+
x = _this$getPosition2.x,
|
|
60025
|
+
y = _this$getPosition2.y,
|
|
60026
|
+
z = _this$getPosition2.z;
|
|
60027
|
+
|
|
60028
|
+
var position = _objectSpread2$1({
|
|
60029
|
+
x: x,
|
|
60030
|
+
y: y,
|
|
60031
|
+
z: z
|
|
60032
|
+
}, where);
|
|
60033
|
+
|
|
60034
|
+
this.body.position.set(position.x, position.y, position.z);
|
|
60020
60035
|
}
|
|
60036
|
+
}
|
|
60037
|
+
}, {
|
|
60038
|
+
key: "getRotation",
|
|
60039
|
+
value: function getRotation() {
|
|
60040
|
+
return this.getBody().rotation.clone();
|
|
60041
|
+
}
|
|
60042
|
+
}, {
|
|
60043
|
+
key: "setRotation",
|
|
60044
|
+
value: function setRotation(how) {
|
|
60045
|
+
if (this.hasBody()) {
|
|
60046
|
+
var _this$getRotation = this.getRotation(),
|
|
60047
|
+
x = _this$getRotation.x,
|
|
60048
|
+
y = _this$getRotation.y,
|
|
60049
|
+
z = _this$getRotation.z;
|
|
60021
60050
|
|
|
60022
|
-
|
|
60051
|
+
var rotation = _objectSpread2$1({
|
|
60052
|
+
x: x,
|
|
60053
|
+
y: y,
|
|
60054
|
+
z: z
|
|
60055
|
+
}, how);
|
|
60023
60056
|
|
|
60024
|
-
|
|
60025
|
-
var amount = this.breaks[i];
|
|
60026
|
-
var prev = this.breaks[i - 1] || 0;
|
|
60027
|
-
target[i].x = prev;
|
|
60028
|
-
target[i].y = amount;
|
|
60057
|
+
this.body.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
60029
60058
|
}
|
|
60030
60059
|
}
|
|
60031
60060
|
}, {
|
|
60032
|
-
key: "
|
|
60033
|
-
value: function
|
|
60034
|
-
this.
|
|
60035
|
-
this.
|
|
60036
|
-
|
|
60037
|
-
|
|
60061
|
+
key: "getWorldTransform",
|
|
60062
|
+
value: function getWorldTransform() {
|
|
60063
|
+
var position = this.getBody().getWorldPosition(new Vector3$1());
|
|
60064
|
+
var quaternion = this.getBody().getWorldQuaternion(new Quaternion(0, 0, 0, 1));
|
|
60065
|
+
var rotation = new Euler(0, 0, 0, 'XYZ').setFromQuaternion(quaternion, 'XYZ');
|
|
60066
|
+
return {
|
|
60067
|
+
position: position,
|
|
60068
|
+
rotation: rotation,
|
|
60069
|
+
quaternion: quaternion
|
|
60070
|
+
};
|
|
60038
60071
|
}
|
|
60039
60072
|
}, {
|
|
60040
|
-
key: "
|
|
60041
|
-
value: function
|
|
60042
|
-
|
|
60043
|
-
|
|
60073
|
+
key: "translate",
|
|
60074
|
+
value: function translate(_ref6) {
|
|
60075
|
+
var _ref6$x = _ref6.x,
|
|
60076
|
+
x = _ref6$x === void 0 ? 0 : _ref6$x,
|
|
60077
|
+
_ref6$y = _ref6.y,
|
|
60078
|
+
y = _ref6$y === void 0 ? 0 : _ref6$y,
|
|
60079
|
+
_ref6$z = _ref6.z,
|
|
60080
|
+
z = _ref6$z === void 0 ? 0 : _ref6$z;
|
|
60081
|
+
|
|
60082
|
+
if (this.hasBody()) {
|
|
60083
|
+
this.body.translateX(x);
|
|
60084
|
+
this.body.translateY(y);
|
|
60085
|
+
this.body.translateZ(z);
|
|
60044
60086
|
}
|
|
60045
60087
|
}
|
|
60046
60088
|
}, {
|
|
60047
|
-
key: "
|
|
60048
|
-
value: function
|
|
60049
|
-
var
|
|
60050
|
-
shaders.forEach(function (shader, material) {
|
|
60051
|
-
delete material.onBeforeCompile;
|
|
60052
|
-
delete material.defines.USE_CSM;
|
|
60053
|
-
delete material.defines.CSM_CASCADES;
|
|
60054
|
-
delete material.defines.CSM_FADE;
|
|
60089
|
+
key: "rotateTo",
|
|
60090
|
+
value: function rotateTo() {
|
|
60091
|
+
var _this6 = this;
|
|
60055
60092
|
|
|
60056
|
-
|
|
60057
|
-
|
|
60058
|
-
delete shader.uniforms.cameraNear;
|
|
60059
|
-
delete shader.uniforms.shadowFar;
|
|
60060
|
-
}
|
|
60093
|
+
var rotation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getRotation();
|
|
60094
|
+
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
60061
60095
|
|
|
60062
|
-
|
|
60096
|
+
var _this$getRotation2 = this.getRotation(),
|
|
60097
|
+
x = _this$getRotation2.x,
|
|
60098
|
+
y = _this$getRotation2.y,
|
|
60099
|
+
z = _this$getRotation2.z;
|
|
60100
|
+
|
|
60101
|
+
return new Promise(function (resolve) {
|
|
60102
|
+
return new Between({
|
|
60103
|
+
x: x,
|
|
60104
|
+
y: y,
|
|
60105
|
+
z: z
|
|
60106
|
+
}, rotation).time(time).on('update', function (value) {
|
|
60107
|
+
return !_this6.isDisposed() && _this6.setRotation(value);
|
|
60108
|
+
}).on('complete', resolve);
|
|
60063
60109
|
});
|
|
60064
|
-
shaders.clear();
|
|
60065
60110
|
}
|
|
60066
|
-
}
|
|
60111
|
+
}, {
|
|
60112
|
+
key: "goTo",
|
|
60113
|
+
value: function goTo() {
|
|
60114
|
+
var _this7 = this;
|
|
60067
60115
|
|
|
60068
|
-
|
|
60069
|
-
|
|
60070
|
-
var AMBIENTLIGHT = 'ambientlight';
|
|
60071
|
-
var SUNLIGHT = 'sunlight';
|
|
60072
|
-
var SPOTLIGHT = 'spotlight';
|
|
60073
|
-
var HEMISPHERELIGHT = 'hemisphere';
|
|
60074
|
-
var TIME_TO_UPDATE = 5;
|
|
60075
|
-
var Lights = /*#__PURE__*/function () {
|
|
60076
|
-
function Lights() {
|
|
60077
|
-
_classCallCheck(this, Lights);
|
|
60116
|
+
var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.getPosition();
|
|
60117
|
+
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
|
|
60078
60118
|
|
|
60079
|
-
|
|
60080
|
-
|
|
60081
|
-
|
|
60082
|
-
|
|
60083
|
-
this.numLights = 0;
|
|
60084
|
-
this.map = {};
|
|
60085
|
-
this.lights = [];
|
|
60086
|
-
this.csm = undefined;
|
|
60087
|
-
}
|
|
60119
|
+
var _this$getPosition3 = this.getPosition(),
|
|
60120
|
+
x = _this$getPosition3.x,
|
|
60121
|
+
y = _this$getPosition3.y,
|
|
60122
|
+
z = _this$getPosition3.z;
|
|
60088
60123
|
|
|
60089
|
-
|
|
60090
|
-
|
|
60091
|
-
|
|
60092
|
-
|
|
60124
|
+
return new Promise(function (resolve) {
|
|
60125
|
+
return new Between({
|
|
60126
|
+
x: x,
|
|
60127
|
+
y: y,
|
|
60128
|
+
z: z
|
|
60129
|
+
}, position).time(time).on('update', function (value) {
|
|
60130
|
+
return !_this7.isDisposed() && _this7.setPosition(value);
|
|
60131
|
+
}).on('complete', resolve);
|
|
60132
|
+
});
|
|
60093
60133
|
}
|
|
60094
60134
|
}, {
|
|
60095
|
-
key: "
|
|
60096
|
-
value: function
|
|
60097
|
-
|
|
60098
|
-
this.csm = new CascadeShadowMaps(options);
|
|
60135
|
+
key: "uuid",
|
|
60136
|
+
value: function uuid() {
|
|
60137
|
+
return this.body.uuid;
|
|
60099
60138
|
}
|
|
60100
60139
|
}, {
|
|
60101
|
-
key: "
|
|
60102
|
-
value: function
|
|
60103
|
-
this.
|
|
60140
|
+
key: "setId",
|
|
60141
|
+
value: function setId() {
|
|
60142
|
+
return this.body.id;
|
|
60104
60143
|
}
|
|
60105
60144
|
}, {
|
|
60106
|
-
key: "
|
|
60107
|
-
value: function
|
|
60108
|
-
|
|
60109
|
-
|
|
60145
|
+
key: "id",
|
|
60146
|
+
value: function id() {
|
|
60147
|
+
return this.body.id;
|
|
60148
|
+
}
|
|
60149
|
+
}, {
|
|
60150
|
+
key: "setVisible",
|
|
60151
|
+
value: function setVisible() {
|
|
60152
|
+
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
60153
|
+
this.getBody().visible = flag;
|
|
60154
|
+
}
|
|
60155
|
+
}, {
|
|
60156
|
+
key: "equals",
|
|
60157
|
+
value: function equals(entity) {
|
|
60158
|
+
try {
|
|
60159
|
+
return entity.uuid ? this.uuid() === entity.uuid() : false;
|
|
60160
|
+
} catch (e) {
|
|
60161
|
+
return false;
|
|
60110
60162
|
}
|
|
60111
|
-
|
|
60112
|
-
|
|
60113
|
-
|
|
60114
|
-
|
|
60115
|
-
|
|
60116
|
-
|
|
60117
|
-
|
|
60163
|
+
}
|
|
60164
|
+
}, {
|
|
60165
|
+
key: "setName",
|
|
60166
|
+
value: function setName(name) {
|
|
60167
|
+
this.name = name;
|
|
60168
|
+
}
|
|
60169
|
+
}, {
|
|
60170
|
+
key: "getName",
|
|
60171
|
+
value: function getName() {
|
|
60172
|
+
return this.name;
|
|
60173
|
+
}
|
|
60174
|
+
}, {
|
|
60175
|
+
key: "setData",
|
|
60176
|
+
value: function setData(key, value) {
|
|
60177
|
+
if (this.getBody().userData) {
|
|
60178
|
+
if (key && value) {
|
|
60179
|
+
this.getBody().userData[key] = value;
|
|
60180
|
+
} else {
|
|
60181
|
+
console.log(KEY_VALUE_IS_MISSING);
|
|
60182
|
+
}
|
|
60183
|
+
} else {
|
|
60184
|
+
console.log(USER_DATA_IS_MISSING);
|
|
60185
|
+
}
|
|
60186
|
+
}
|
|
60187
|
+
}, {
|
|
60188
|
+
key: "getData",
|
|
60189
|
+
value: function getData(key) {
|
|
60190
|
+
if (this.getBody().userData) {
|
|
60191
|
+
if (key) {
|
|
60192
|
+
return this.getBody().userData[key];
|
|
60193
|
+
} else {
|
|
60194
|
+
console.log(KEY_IS_MISSING);
|
|
60195
|
+
}
|
|
60196
|
+
} else {
|
|
60197
|
+
console.log(USER_DATA_IS_MISSING);
|
|
60118
60198
|
}
|
|
60119
60199
|
}
|
|
60200
|
+
}, {
|
|
60201
|
+
key: "mapScriptsToJSON",
|
|
60202
|
+
value: function mapScriptsToJSON() {
|
|
60203
|
+
this.scripts.reduce(function (acc, _ref7) {
|
|
60204
|
+
var name = _ref7.name,
|
|
60205
|
+
_ref7$options = _ref7.options,
|
|
60206
|
+
options = _ref7$options === void 0 ? {} : _ref7$options;
|
|
60207
|
+
acc.names.push(name);
|
|
60208
|
+
acc.options.push(options);
|
|
60209
|
+
return acc;
|
|
60210
|
+
}, {
|
|
60211
|
+
names: [],
|
|
60212
|
+
options: []
|
|
60213
|
+
});
|
|
60214
|
+
}
|
|
60120
60215
|
}, {
|
|
60121
60216
|
key: "toJSON",
|
|
60122
60217
|
value: function toJSON() {
|
|
60123
|
-
|
|
60124
|
-
|
|
60125
|
-
|
|
60126
|
-
|
|
60127
|
-
|
|
60128
|
-
|
|
60129
|
-
|
|
60130
|
-
|
|
60131
|
-
|
|
60132
|
-
}
|
|
60133
|
-
var Lights$1 = new Lights();var ToonShader = {
|
|
60134
|
-
uniforms: {
|
|
60135
|
-
"uDirLightPos": {
|
|
60136
|
-
type: "v3",
|
|
60137
|
-
value: new Vector3$1()
|
|
60138
|
-
},
|
|
60139
|
-
"uDirLightColor": {
|
|
60140
|
-
type: "c",
|
|
60141
|
-
value: new Color$1(0xffffff)
|
|
60142
|
-
},
|
|
60143
|
-
"uMaterialColor": {
|
|
60144
|
-
type: "c",
|
|
60145
|
-
value: new Color$1(0xffffff)
|
|
60146
|
-
},
|
|
60147
|
-
uKd: {
|
|
60148
|
-
type: "f",
|
|
60149
|
-
value: 1
|
|
60150
|
-
},
|
|
60151
|
-
uBorder: {
|
|
60152
|
-
type: "f",
|
|
60153
|
-
value: 0.4
|
|
60218
|
+
if (this.isSerializable()) {
|
|
60219
|
+
return {
|
|
60220
|
+
position: this.getPosition(),
|
|
60221
|
+
rotation: this.getRotation(),
|
|
60222
|
+
scale: this.getScale(),
|
|
60223
|
+
entityType: this.getEntityType(),
|
|
60224
|
+
scripts: this.mapScriptsToJSON(),
|
|
60225
|
+
tags: this.getTags()
|
|
60226
|
+
};
|
|
60227
|
+
}
|
|
60154
60228
|
}
|
|
60155
|
-
},
|
|
60156
|
-
|
|
60157
|
-
|
|
60158
|
-
|
|
60159
|
-
|
|
60160
|
-
|
|
60161
|
-
|
|
60162
|
-
};
|
|
60229
|
+
}], [{
|
|
60230
|
+
key: "create",
|
|
60231
|
+
value: function create() {
|
|
60232
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
60233
|
+
return new this(options);
|
|
60234
|
+
}
|
|
60235
|
+
}]);
|
|
60163
60236
|
|
|
60164
|
-
|
|
60165
|
-
|
|
60237
|
+
return Entity;
|
|
60238
|
+
}(EventDispatcher);var AnimationHandler = /*#__PURE__*/function (_EventDispatcher) {
|
|
60239
|
+
_inherits(AnimationHandler, _EventDispatcher);
|
|
60166
60240
|
|
|
60167
|
-
var _super = _createSuper(
|
|
60241
|
+
var _super = _createSuper(AnimationHandler);
|
|
60168
60242
|
|
|
60169
|
-
function
|
|
60243
|
+
function AnimationHandler(mesh) {
|
|
60170
60244
|
var _this;
|
|
60171
60245
|
|
|
60172
|
-
var
|
|
60173
|
-
light = _ref$light === void 0 ? {} : _ref$light,
|
|
60174
|
-
color = _ref.color;
|
|
60246
|
+
var animations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
60175
60247
|
|
|
60176
|
-
_classCallCheck(this,
|
|
60248
|
+
_classCallCheck(this, AnimationHandler);
|
|
60177
60249
|
|
|
60178
|
-
|
|
60179
|
-
var vertexShader = ToonShader.vertexShader,
|
|
60180
|
-
fragmentShader = ToonShader.fragmentShader;
|
|
60181
|
-
_this = _super.call(this, {
|
|
60182
|
-
uniforms: uniforms,
|
|
60183
|
-
vertexShader: vertexShader,
|
|
60184
|
-
fragmentShader: fragmentShader,
|
|
60185
|
-
flatShading: true
|
|
60186
|
-
});
|
|
60187
|
-
var position = light.position,
|
|
60188
|
-
lightColor = light.color;
|
|
60250
|
+
_this = _super.call(this);
|
|
60189
60251
|
|
|
60190
|
-
|
|
60191
|
-
|
|
60252
|
+
_defineProperty$1(_assertThisInitialized(_this), "getAnimationEventHandler", function (type) {
|
|
60253
|
+
return function (_ref) {
|
|
60254
|
+
var action = _ref.action,
|
|
60255
|
+
direction = _ref.direction;
|
|
60192
60256
|
|
|
60193
|
-
|
|
60194
|
-
|
|
60257
|
+
_this.dispatchEvent({
|
|
60258
|
+
type: type,
|
|
60259
|
+
action: action,
|
|
60260
|
+
direction: direction
|
|
60261
|
+
});
|
|
60262
|
+
};
|
|
60263
|
+
});
|
|
60195
60264
|
|
|
60196
|
-
_this.
|
|
60265
|
+
_this.mixer = new AnimationMixer(mesh);
|
|
60266
|
+
_this.animations = animations;
|
|
60267
|
+
_this.isPlaying = false;
|
|
60197
60268
|
|
|
60198
|
-
_this.
|
|
60269
|
+
_this.addEventsListeners();
|
|
60199
60270
|
|
|
60200
|
-
_this.side = DoubleSide;
|
|
60201
60271
|
return _this;
|
|
60202
60272
|
}
|
|
60203
60273
|
|
|
60204
|
-
|
|
60205
|
-
|
|
60206
|
-
|
|
60207
|
-
|
|
60208
|
-
|
|
60209
|
-
|
|
60210
|
-
|
|
60211
|
-
|
|
60274
|
+
_createClass(AnimationHandler, [{
|
|
60275
|
+
key: "addEventsListeners",
|
|
60276
|
+
value: function addEventsListeners() {
|
|
60277
|
+
this.mixer.addEventListener('loop', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.LOOP));
|
|
60278
|
+
this.mixer.addEventListener('finished', this.getAnimationEventHandler(ENTITY_EVENTS.ANIMATION.FINISHED));
|
|
60279
|
+
}
|
|
60280
|
+
}, {
|
|
60281
|
+
key: "getAction",
|
|
60282
|
+
value: function getAction(id) {
|
|
60283
|
+
var action;
|
|
60212
60284
|
|
|
60213
|
-
|
|
60214
|
-
|
|
60215
|
-
if (
|
|
60216
|
-
|
|
60285
|
+
if (typeof id === 'number') {
|
|
60286
|
+
action = this.animations[id];
|
|
60287
|
+
} else if (typeof id === 'string') {
|
|
60288
|
+
action = AnimationClip.findByName(this.animations, id);
|
|
60217
60289
|
}
|
|
60218
60290
|
|
|
60219
|
-
|
|
60220
|
-
|
|
60291
|
+
return action;
|
|
60292
|
+
}
|
|
60293
|
+
}, {
|
|
60294
|
+
key: "getAvailableAnimations",
|
|
60295
|
+
value: function getAvailableAnimations() {
|
|
60296
|
+
return this.animations.map(function (_ref2) {
|
|
60297
|
+
var name = _ref2.name;
|
|
60298
|
+
return name;
|
|
60299
|
+
});
|
|
60300
|
+
}
|
|
60301
|
+
}, {
|
|
60302
|
+
key: "stopAll",
|
|
60303
|
+
value: function stopAll() {
|
|
60304
|
+
this.mixer.stopAllAction();
|
|
60305
|
+
this.isPlaying = false;
|
|
60306
|
+
}
|
|
60307
|
+
}, {
|
|
60308
|
+
key: "stopCurrentAnimation",
|
|
60309
|
+
value: function stopCurrentAnimation() {
|
|
60310
|
+
if (this.currentAction) {
|
|
60311
|
+
this.currentAction.stop();
|
|
60221
60312
|
}
|
|
60222
60313
|
|
|
60223
|
-
|
|
60224
|
-
}
|
|
60225
|
-
|
|
60226
|
-
|
|
60227
|
-
|
|
60228
|
-
|
|
60229
|
-
|
|
60230
|
-
|
|
60231
|
-
|
|
60232
|
-
};
|
|
60233
|
-
var hasGeometry = function hasGeometry(mesh) {
|
|
60234
|
-
return Boolean(mesh.geometry);
|
|
60235
|
-
};
|
|
60236
|
-
var processMaterial = function processMaterial(material, callback) {
|
|
60237
|
-
return Array.isArray(material) ? material.map(callback) : callback(material);
|
|
60238
|
-
};
|
|
60239
|
-
var changeMaterialByName = function changeMaterialByName(name, mesh, materialOptions) {
|
|
60240
|
-
if (!hasMaterial(mesh)) return;
|
|
60241
|
-
|
|
60242
|
-
switch (name) {
|
|
60243
|
-
case MATERIALS.LAMBERT:
|
|
60244
|
-
return cloneMaterial(MeshLambertMaterial, mesh, materialOptions);
|
|
60245
|
-
|
|
60246
|
-
case MATERIALS.PHONG:
|
|
60247
|
-
return cloneMaterial(MeshPhongMaterial, mesh, materialOptions);
|
|
60248
|
-
|
|
60249
|
-
case MATERIALS.DEPTH:
|
|
60250
|
-
return cloneMaterial(MeshDepthMaterial, mesh, materialOptions);
|
|
60251
|
-
|
|
60252
|
-
case MATERIALS.STANDARD:
|
|
60253
|
-
return cloneMaterial(MeshStandardMaterial, mesh, materialOptions);
|
|
60254
|
-
|
|
60255
|
-
case MATERIALS.TOON:
|
|
60256
|
-
return cloneMaterial(ToonMaterial, mesh, materialOptions);
|
|
60257
|
-
|
|
60258
|
-
case MATERIALS.THREE_TOON:
|
|
60259
|
-
return cloneMaterial(MeshToonMaterial, mesh, materialOptions);
|
|
60260
|
-
|
|
60261
|
-
case MATERIALS.BASIC:
|
|
60262
|
-
default:
|
|
60263
|
-
return cloneMaterial(MeshBasicMaterial, mesh, materialOptions);
|
|
60264
|
-
}
|
|
60265
|
-
};
|
|
60314
|
+
this.isPlaying = false;
|
|
60315
|
+
}
|
|
60316
|
+
}, {
|
|
60317
|
+
key: "playAnimation",
|
|
60318
|
+
value: function playAnimation(id, options) {
|
|
60319
|
+
var action = this.getAction(id);
|
|
60320
|
+
var _options$loop = options.loop,
|
|
60321
|
+
loop = _options$loop === void 0 ? LoopRepeat : _options$loop;
|
|
60322
|
+
this.isPlaying = true;
|
|
60266
60323
|
|
|
60267
|
-
|
|
60268
|
-
|
|
60324
|
+
if (this.currentAction) {
|
|
60325
|
+
this.fadeToAnimation(action, options);
|
|
60326
|
+
} else if (action) {
|
|
60327
|
+
this.currentAction = this.mixer.clipAction(action).setLoop(loop).play();
|
|
60328
|
+
} else {
|
|
60329
|
+
console.warn(ANIMATION_NOT_FOUND);
|
|
60330
|
+
}
|
|
60331
|
+
}
|
|
60332
|
+
}, {
|
|
60333
|
+
key: "fadeToAnimation",
|
|
60334
|
+
value: function fadeToAnimation(action) {
|
|
60335
|
+
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
60336
|
+
_ref3$duration = _ref3.duration,
|
|
60337
|
+
duration = _ref3$duration === void 0 ? 0.2 : _ref3$duration,
|
|
60338
|
+
_ref3$loop = _ref3.loop,
|
|
60339
|
+
loop = _ref3$loop === void 0 ? LoopRepeat : _ref3$loop;
|
|
60269
60340
|
|
|
60270
|
-
|
|
60271
|
-
|
|
60272
|
-
var newMaterial = new MeshMaterial(_objectSpread2$1({
|
|
60273
|
-
map: clone.map,
|
|
60274
|
-
color: clone.color
|
|
60275
|
-
}, options));
|
|
60276
|
-
newMaterial.skinning = true;
|
|
60277
|
-
return newMaterial;
|
|
60278
|
-
};
|
|
60341
|
+
var previousAction = this.currentAction;
|
|
60342
|
+
this.currentAction = this.mixer.clipAction(action);
|
|
60279
60343
|
|
|
60280
|
-
|
|
60281
|
-
|
|
60282
|
-
}
|
|
60344
|
+
if (previousAction !== this.currentAction) {
|
|
60345
|
+
previousAction.fadeOut(duration);
|
|
60346
|
+
}
|
|
60283
60347
|
|
|
60284
|
-
|
|
60285
|
-
|
|
60286
|
-
|
|
60287
|
-
|
|
60288
|
-
|
|
60348
|
+
this.currentAction.reset().setEffectiveTimeScale(1).setEffectiveWeight(1).fadeIn(duration).setLoop(loop).play();
|
|
60349
|
+
}
|
|
60350
|
+
}, {
|
|
60351
|
+
key: "update",
|
|
60352
|
+
value: function update(dt) {
|
|
60353
|
+
this.mixer.update(dt);
|
|
60354
|
+
}
|
|
60355
|
+
}]);
|
|
60289
60356
|
|
|
60290
|
-
|
|
60291
|
-
|
|
60292
|
-
};
|
|
60293
|
-
var disposeMaterial = function disposeMaterial(mesh) {
|
|
60294
|
-
if (hasMaterial(mesh)) {
|
|
60295
|
-
mesh.material.dispose();
|
|
60296
|
-
}
|
|
60297
|
-
};
|
|
60298
|
-
var disposeGeometry = function disposeGeometry(mesh) {
|
|
60299
|
-
if (hasGeometry(mesh)) {
|
|
60300
|
-
mesh.geometry.dispose();
|
|
60301
|
-
}
|
|
60302
|
-
};
|
|
60303
|
-
var prepareModel = function prepareModel(model) {
|
|
60304
|
-
setUpLightsAndShadows(model);
|
|
60305
|
-
model.traverse(function (mesh) {
|
|
60306
|
-
setUpLightsAndShadows(mesh);
|
|
60307
|
-
});
|
|
60308
|
-
return model;
|
|
60309
|
-
};var _MATERIAL_TEXTURE_MAP;
|
|
60357
|
+
return AnimationHandler;
|
|
60358
|
+
}(EventDispatcher);var _MATERIAL_TEXTURE_MAP;
|
|
60310
60359
|
var MATERIAL_TEXTURE_MAP = (_MATERIAL_TEXTURE_MAP = {}, _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.BASIC, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.LAMBERT, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.PHONG, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.SPECULAR, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.DEPTH, [TEXTURES.ALPHA, TEXTURES.MAP, TEXTURES.DISPLACEMENT]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.STANDARD, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.ENV, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.EMISSIVE, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.NORMAL, TEXTURES.METALNESS, TEXTURES.ROUGHNESS]), _defineProperty$1(_MATERIAL_TEXTURE_MAP, MATERIALS.THREE_TOON, [TEXTURES.ALPHA, TEXTURES.AO, TEXTURES.BUMP, TEXTURES.DISPLACEMENT, TEXTURES.EMISSIVE, TEXTURES.GRADIENT, TEXTURES.LIGHT, TEXTURES.MAP, TEXTURES.NORMAL]), _MATERIAL_TEXTURE_MAP);
|
|
60311
60360
|
var isTextureMapAllowedForMaterial = function isTextureMapAllowedForMaterial(materialType, textureType) {
|
|
60312
60361
|
return MATERIAL_TEXTURE_MAP[materialType] && MATERIAL_TEXTURE_MAP[materialType].includes(textureType);
|
|
@@ -60976,7 +61025,7 @@ var Element = /*#__PURE__*/function (_Entity) {
|
|
|
60976
61025
|
|
|
60977
61026
|
return new Promise(function (resolve) {
|
|
60978
61027
|
return new Between(_this4.opacity, opacity).time(time).on('update', function (value) {
|
|
60979
|
-
return _this4.setOpacity(value);
|
|
61028
|
+
return !_this4.isDisposed() && _this4.setOpacity(value);
|
|
60980
61029
|
}).on('complete', resolve);
|
|
60981
61030
|
});
|
|
60982
61031
|
}
|
|
@@ -61013,19 +61062,21 @@ var Element = /*#__PURE__*/function (_Entity) {
|
|
|
61013
61062
|
}, {
|
|
61014
61063
|
key: "disposeBody",
|
|
61015
61064
|
value: function disposeBody() {
|
|
61016
|
-
|
|
61065
|
+
_get(_getPrototypeOf(Element.prototype), "disposeBody", this).call(this);
|
|
61066
|
+
|
|
61067
|
+
if (hasMaterial(this.getBody())) {
|
|
61017
61068
|
disposeTextures(this.getBody());
|
|
61018
61069
|
disposeMaterial(this.getBody());
|
|
61019
61070
|
disposeGeometry(this.getBody());
|
|
61020
|
-
} else {
|
|
61021
|
-
this.body.traverse(function (child) {
|
|
61022
|
-
if (hasMaterial(child)) {
|
|
61023
|
-
disposeTextures(child);
|
|
61024
|
-
disposeMaterial(child);
|
|
61025
|
-
disposeGeometry(child);
|
|
61026
|
-
}
|
|
61027
|
-
});
|
|
61028
61071
|
}
|
|
61072
|
+
|
|
61073
|
+
this.getBody().traverse(function (child) {
|
|
61074
|
+
if (hasMaterial(child)) {
|
|
61075
|
+
disposeTextures(child);
|
|
61076
|
+
disposeMaterial(child);
|
|
61077
|
+
disposeGeometry(child);
|
|
61078
|
+
}
|
|
61079
|
+
});
|
|
61029
61080
|
}
|
|
61030
61081
|
}, {
|
|
61031
61082
|
key: "update",
|
|
@@ -61046,11 +61097,6 @@ var Element = /*#__PURE__*/function (_Entity) {
|
|
|
61046
61097
|
value: function dispose() {
|
|
61047
61098
|
_get(_getPrototypeOf(Element.prototype), "dispose", this).call(this);
|
|
61048
61099
|
|
|
61049
|
-
if (this.hasBody()) {
|
|
61050
|
-
Scene$1.remove(this.getBody());
|
|
61051
|
-
this.disposeBody();
|
|
61052
|
-
}
|
|
61053
|
-
|
|
61054
61100
|
if (this.hasAnimationHandler()) {
|
|
61055
61101
|
this.removeAnimationHandlerListeners();
|
|
61056
61102
|
}
|
|
@@ -61063,7 +61109,6 @@ var Element = /*#__PURE__*/function (_Entity) {
|
|
|
61063
61109
|
if (this.isSerializable()) {
|
|
61064
61110
|
return _objectSpread2$1(_objectSpread2$1({}, _get(_getPrototypeOf(Element.prototype), "toJSON", this).call(this)), {}, {
|
|
61065
61111
|
body: this.body.toJSON(),
|
|
61066
|
-
scripts: this.mapScriptsToJSON(),
|
|
61067
61112
|
textures: this.textures
|
|
61068
61113
|
}, this.options);
|
|
61069
61114
|
}
|
|
@@ -73867,7 +73912,7 @@ var Light = /*#__PURE__*/function (_Entity) {
|
|
|
73867
73912
|
var intensity = this.getIntensity();
|
|
73868
73913
|
return new Promise(function (resolve) {
|
|
73869
73914
|
return new Between(intensity, value).time(time).on('update', function (value) {
|
|
73870
|
-
return _this2.setIntensity(value);
|
|
73915
|
+
return !_this2.isDisposed() && _this2.setIntensity(value);
|
|
73871
73916
|
}).on('complete', resolve);
|
|
73872
73917
|
});
|
|
73873
73918
|
}
|
|
@@ -76737,12 +76782,17 @@ var index$1=/*#__PURE__*/Object.freeze({__proto__:null,Emitter:k,Particle:P,Part
|
|
|
76737
76782
|
this.system.particleSystem.rotation.set(rotation.x, rotation.y, rotation.z);
|
|
76738
76783
|
}
|
|
76739
76784
|
}
|
|
76785
|
+
}, {
|
|
76786
|
+
key: "dispose",
|
|
76787
|
+
value: function dispose() {
|
|
76788
|
+
_get(_getPrototypeOf(ParticleEmitter.prototype), "dispose", this).call(this);
|
|
76789
|
+
}
|
|
76740
76790
|
}, {
|
|
76741
76791
|
key: "update",
|
|
76742
76792
|
value: function update(dt) {
|
|
76743
76793
|
_get(_getPrototypeOf(ParticleEmitter.prototype), "update", this).call(this, dt);
|
|
76744
76794
|
|
|
76745
|
-
if (this.hasSystem()) {
|
|
76795
|
+
if (this.hasSystem() && !this.isSystemDead()) {
|
|
76746
76796
|
this.system.update(dt);
|
|
76747
76797
|
}
|
|
76748
76798
|
|
|
@@ -76985,6 +77035,7 @@ var index$1=/*#__PURE__*/Object.freeze({__proto__:null,Emitter:k,Particle:P,Part
|
|
|
76985
77035
|
return ParticleEmitterGroup;
|
|
76986
77036
|
}(Entity);var _excluded$2 = ["initializers", "behaviours", "texture", "color", "rate"];
|
|
76987
77037
|
var DEFAULT_PARTICLE_COLOR = PALETTES.BASE.BLACK;
|
|
77038
|
+
var SYSTEM_DISPOSE_TIMEOUT = 700;
|
|
76988
77039
|
|
|
76989
77040
|
var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
76990
77041
|
_inherits(ProtonParticleEmitter, _ParticleEmitter);
|
|
@@ -76992,6 +77043,8 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
76992
77043
|
var _super = _createSuper(ProtonParticleEmitter);
|
|
76993
77044
|
|
|
76994
77045
|
function ProtonParticleEmitter() {
|
|
77046
|
+
var _this;
|
|
77047
|
+
|
|
76995
77048
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
76996
77049
|
|
|
76997
77050
|
_classCallCheck(this, ProtonParticleEmitter);
|
|
@@ -77015,7 +77068,17 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
77015
77068
|
rate: rate
|
|
77016
77069
|
}, rest);
|
|
77017
77070
|
|
|
77018
|
-
|
|
77071
|
+
_this = _super.call(this, parsedOptions);
|
|
77072
|
+
|
|
77073
|
+
_defineProperty$1(_assertThisInitialized(_this), "disposeSystem", function () {
|
|
77074
|
+
if (_this.hasSystem()) {
|
|
77075
|
+
_this.system.removeAllParticles();
|
|
77076
|
+
|
|
77077
|
+
_this.system.destroy();
|
|
77078
|
+
}
|
|
77079
|
+
});
|
|
77080
|
+
|
|
77081
|
+
return _this;
|
|
77019
77082
|
}
|
|
77020
77083
|
|
|
77021
77084
|
_createClass(ProtonParticleEmitter, [{
|
|
@@ -77043,7 +77106,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
77043
77106
|
}, {
|
|
77044
77107
|
key: "setSystem",
|
|
77045
77108
|
value: function setSystem() {
|
|
77046
|
-
var
|
|
77109
|
+
var _this2 = this;
|
|
77047
77110
|
|
|
77048
77111
|
var _this$options = this.options,
|
|
77049
77112
|
_this$options$initial = _this$options.initializers,
|
|
@@ -77056,7 +77119,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
77056
77119
|
this.system = new Proton.Emitter();
|
|
77057
77120
|
this.system.rate = rate;
|
|
77058
77121
|
initializers.forEach(function (initializer) {
|
|
77059
|
-
return
|
|
77122
|
+
return _this2.system.addInitialize(initializer);
|
|
77060
77123
|
});
|
|
77061
77124
|
|
|
77062
77125
|
if (texture) {
|
|
@@ -77064,7 +77127,7 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
77064
77127
|
}
|
|
77065
77128
|
|
|
77066
77129
|
behaviours.forEach(function (behaviour) {
|
|
77067
|
-
return
|
|
77130
|
+
return _this2.system.addBehaviour(behaviour);
|
|
77068
77131
|
});
|
|
77069
77132
|
}
|
|
77070
77133
|
}, {
|
|
@@ -77105,8 +77168,8 @@ var ProtonParticleEmitter = /*#__PURE__*/function (_ParticleEmitter) {
|
|
|
77105
77168
|
value: function dispose() {
|
|
77106
77169
|
_get(_getPrototypeOf(ProtonParticleEmitter.prototype), "dispose", this).call(this);
|
|
77107
77170
|
|
|
77108
|
-
this.
|
|
77109
|
-
this.
|
|
77171
|
+
this.stop();
|
|
77172
|
+
setTimeout(this.disposeSystem, SYSTEM_DISPOSE_TIMEOUT);
|
|
77110
77173
|
}
|
|
77111
77174
|
}]);
|
|
77112
77175
|
|
|
@@ -77449,7 +77512,14 @@ var Particles = /*#__PURE__*/function () {
|
|
|
77449
77512
|
}
|
|
77450
77513
|
}, {
|
|
77451
77514
|
key: "addParticleEmitter",
|
|
77452
|
-
value: function addParticleEmitter(
|
|
77515
|
+
value: function addParticleEmitter(emitter) {
|
|
77516
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
77517
|
+
console.warn(DEPRECATIONS.PARTICLES_ADD_PARTICLE_EMITTER);
|
|
77518
|
+
return this.add(emitter, options);
|
|
77519
|
+
}
|
|
77520
|
+
}, {
|
|
77521
|
+
key: "add",
|
|
77522
|
+
value: function add(_emitter) {
|
|
77453
77523
|
var _this2 = this;
|
|
77454
77524
|
|
|
77455
77525
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -77502,7 +77572,7 @@ var Particles = /*#__PURE__*/function () {
|
|
|
77502
77572
|
}
|
|
77503
77573
|
|
|
77504
77574
|
if (emitter.isSystemDead()) {
|
|
77505
|
-
this.toDispose.push(emitter.uuid);
|
|
77575
|
+
this.toDispose.push(emitter.uuid());
|
|
77506
77576
|
}
|
|
77507
77577
|
}
|
|
77508
77578
|
}, {
|