index.d.ts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. declare module 'babylonjs/shadows' {
  2. /**
  3. * Interface to implement to create a shadow generator compatible with BJS.
  4. */
  5. interface IShadowGenerator {
  6. getShadowMap(): Nullable<RenderTargetTexture>;
  7. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  8. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10. bindShadowLight(lightIndex: string, effect: Effect): void;
  11. getTransformMatrix(): Matrix;
  12. recreateShadowMap(): void;
  13. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  14. useInstances: boolean;
  15. }>): void;
  16. serialize(): any;
  17. dispose(): void;
  18. }
  19. class ShadowGenerator implements IShadowGenerator {
  20. private static _FILTER_NONE;
  21. private static _FILTER_EXPONENTIALSHADOWMAP;
  22. private static _FILTER_POISSONSAMPLING;
  23. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  24. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  25. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  26. static readonly FILTER_NONE: number;
  27. static readonly FILTER_POISSONSAMPLING: number;
  28. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  30. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  32. private _bias;
  33. bias: number;
  34. private _blurBoxOffset;
  35. blurBoxOffset: number;
  36. private _blurScale;
  37. blurScale: number;
  38. private _blurKernel;
  39. blurKernel: number;
  40. private _useKernelBlur;
  41. useKernelBlur: boolean;
  42. private _depthScale;
  43. depthScale: number;
  44. private _filter;
  45. filter: number;
  46. usePoissonSampling: boolean;
  47. useVarianceShadowMap: boolean;
  48. useBlurVarianceShadowMap: boolean;
  49. useExponentialShadowMap: boolean;
  50. useBlurExponentialShadowMap: boolean;
  51. useCloseExponentialShadowMap: boolean;
  52. useBlurCloseExponentialShadowMap: boolean;
  53. private _darkness;
  54. /**
  55. * Returns the darkness value (float).
  56. */
  57. getDarkness(): number;
  58. /**
  59. * Sets the ShadowGenerator darkness value (float <= 1.0).
  60. * Returns the ShadowGenerator.
  61. */
  62. setDarkness(darkness: number): ShadowGenerator;
  63. private _transparencyShadow;
  64. /**
  65. * Sets the ability to have transparent shadow (boolean).
  66. * Returns the ShadowGenerator.
  67. */
  68. setTransparencyShadow(hasShadow: boolean): ShadowGenerator;
  69. private _shadowMap;
  70. private _shadowMap2;
  71. /**
  72. * Returns a RenderTargetTexture object : the shadow map texture.
  73. */
  74. getShadowMap(): Nullable<RenderTargetTexture>;
  75. /**
  76. * Returns the most ready computed shadow map as a RenderTargetTexture object.
  77. */
  78. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79. /**
  80. * Helper function to add a mesh and its descendants to the list of shadow casters
  81. * @param mesh Mesh to add
  82. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  83. */
  84. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  85. /**
  86. * Helper function to remove a mesh and its descendants from the list of shadow casters
  87. * @param mesh Mesh to remove
  88. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89. */
  90. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  91. /**
  92. * Controls the extent to which the shadows fade out at the edge of the frustum
  93. * Used only by directionals and spots
  94. */
  95. frustumEdgeFalloff: number;
  96. private _light;
  97. /**
  98. * Returns the associated light object.
  99. */
  100. getLight(): IShadowLight;
  101. forceBackFacesOnly: boolean;
  102. private _scene;
  103. private _lightDirection;
  104. private _effect;
  105. private _viewMatrix;
  106. private _projectionMatrix;
  107. private _transformMatrix;
  108. private _cachedPosition;
  109. private _cachedDirection;
  110. private _cachedDefines;
  111. private _currentRenderID;
  112. private _downSamplePostprocess;
  113. private _boxBlurPostprocess;
  114. private _kernelBlurXPostprocess;
  115. private _kernelBlurYPostprocess;
  116. private _blurPostProcesses;
  117. private _mapSize;
  118. private _currentFaceIndex;
  119. private _currentFaceIndexCache;
  120. private _textureType;
  121. private _defaultTextureMatrix;
  122. /**
  123. * Creates a ShadowGenerator object.
  124. * A ShadowGenerator is the required tool to use the shadows.
  125. * Each light casting shadows needs to use its own ShadowGenerator.
  126. * Required parameters :
  127. * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024.
  128. * - `light`: the light object generating the shadows.
  129. * - `useFullFloatFirst`: by default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  130. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  131. */
  132. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  133. private _initializeGenerator();
  134. private _initializeShadowMap();
  135. private _initializeBlurRTTAndPostProcesses();
  136. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  137. private _renderSubMeshForShadowMap(subMesh);
  138. private _applyFilterValues();
  139. /**
  140. * Force shader compilation including textures ready check
  141. */
  142. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  143. useInstances: boolean;
  144. }>): void;
  145. /**
  146. * Boolean : true when the ShadowGenerator is finally computed.
  147. */
  148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149. /**
  150. * This creates the defines related to the standard BJS materials.
  151. */
  152. prepareDefines(defines: any, lightIndex: number): void;
  153. /**
  154. * This binds shadow lights related to the standard BJS materials.
  155. * It implies the unifroms available on the materials are the standard BJS ones.
  156. */
  157. bindShadowLight(lightIndex: string, effect: Effect): void;
  158. /**
  159. * Returns a Matrix object : the updated transformation matrix.
  160. */
  161. getTransformMatrix(): Matrix;
  162. recreateShadowMap(): void;
  163. private _disposeBlurPostProcesses();
  164. private _disposeRTTandPostProcesses();
  165. /**
  166. * Disposes the ShadowGenerator.
  167. * Returns nothing.
  168. */
  169. dispose(): void;
  170. /**
  171. * Serializes the ShadowGenerator and returns a serializationObject.
  172. */
  173. serialize(): any;
  174. /**
  175. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  176. */
  177. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  178. }
  179. }
  180. import {EffectFallbacks,EffectCreationOptions,Effect,Nullable,float,double,int,FloatArray,IndicesArray,KeyboardEventTypes,KeyboardInfo,KeyboardInfoPre,PointerEventTypes,PointerInfoBase,PointerInfoPre,PointerInfo,ToGammaSpace,ToLinearSpace,Epsilon,Color3,Color4,Vector2,Vector3,Vector4,ISize,Size,Quaternion,Matrix,Plane,Viewport,Frustum,Space,Axis,BezierCurve,Orientation,Angle,Arc2,Path2,Path3D,Curve3,PositionNormalVertex,PositionNormalTextureVertex,Tmp,Scalar,expandToProperty,serialize,serializeAsTexture,serializeAsColor3,serializeAsFresnelParameters,serializeAsVector2,serializeAsVector3,serializeAsMeshReference,serializeAsColorCurves,serializeAsColor4,serializeAsImageProcessingConfiguration,serializeAsQuaternion,SerializationHelper,EventState,Observer,MultiObserver,Observable,SmartArray,SmartArrayNoDuplicate,IAnimatable,LoadFileError,RetryStrategy,IFileRequest,Tools,PerfCounter,className,AsyncLoop,_AlphaState,_DepthCullingState,_StencilState,InstancingAttributeInfo,RenderTargetCreationOptions,EngineCapabilities,EngineOptions,IDisplayChangedEventArgs,Engine,Node,BoundingSphere,BoundingBox,ICullable,BoundingInfo,TransformNode,AbstractMesh,Light,Camera,RenderingManager,RenderingGroup,IDisposable,IActiveMeshCandidateProvider,RenderingGroupInfo,Scene,Buffer,VertexBuffer,InternalTexture,BaseTexture,Texture,_InstancesBatch,Mesh,BaseSubMesh,SubMesh,MaterialDefines,Material,UniformBuffer,IGetSetVerticesData,VertexData,Geometry,_PrimitiveGeometry,RibbonGeometry,BoxGeometry,SphereGeometry,DiscGeometry,CylinderGeometry,TorusGeometry,GroundGeometry,TiledGroundGeometry,PlaneGeometry,TorusKnotGeometry,PostProcessManager,PerformanceMonitor,RollingAverage,IImageProcessingConfigurationDefines,ImageProcessingConfiguration,ColorGradingTexture,ColorCurves,Behavior,MaterialHelper,PushMaterial,StandardMaterialDefines,StandardMaterial} from 'babylonjs/core';
  181. import {EngineInstrumentation,SceneInstrumentation,_TimeToken} from 'babylonjs/instrumentation';
  182. import {Particle,IParticleSystem,ParticleSystem,BoxParticleEmitter,ConeParticleEmitter,SphereParticleEmitter,SphereDirectedParticleEmitter,IParticleEmitterType} from 'babylonjs/particles';
  183. import {GPUParticleSystem} from 'babylonjs/gpuParticles';
  184. import {FramingBehavior,BouncingBehavior,AutoRotationBehavior} from 'babylonjs/cameraBehaviors';
  185. import {NullEngineOptions,NullEngine} from 'babylonjs/nullEngine';
  186. import {TextureTools} from 'babylonjs/textureTools';
  187. import {SolidParticle,ModelShape,DepthSortedParticle,SolidParticleSystem} from 'babylonjs/solidParticles';
  188. import {Collider,CollisionWorker,ICollisionCoordinator,SerializedMesh,SerializedSubMesh,SerializedGeometry,BabylonMessage,SerializedColliderToWorker,WorkerTaskType,WorkerReply,CollisionReplyPayload,InitPayload,CollidePayload,UpdatePayload,WorkerReplyType,CollisionCoordinatorWorker,CollisionCoordinatorLegacy} from 'babylonjs/collisions';
  189. import {IntersectionInfo,PickingInfo,Ray} from 'babylonjs/picking';
  190. import {SpriteManager,Sprite} from 'babylonjs/sprites';
  191. import {AnimationRange,AnimationEvent,PathCursor,Animation,TargetedAnimation,AnimationGroup,RuntimeAnimation,Animatable,IEasingFunction,EasingFunction,CircleEase,BackEase,BounceEase,CubicEase,ElasticEase,ExponentialEase,PowerEase,QuadraticEase,QuarticEase,QuinticEase,SineEase,BezierCurveEase} from 'babylonjs/animations';
  192. import {Condition,ValueCondition,PredicateCondition,StateCondition,Action,ActionEvent,ActionManager,InterpolateValueAction,SwitchBooleanAction,SetStateAction,SetValueAction,IncrementValueAction,PlayAnimationAction,StopAnimationAction,DoNothingAction,CombineAction,ExecuteCodeAction,SetParentAction,PlaySoundAction,StopSoundAction} from 'babylonjs/actions';
  193. import {GroundMesh,InstancedMesh,LinesMesh} from 'babylonjs/additionalMeshes';
  194. import {ShaderMaterial} from 'babylonjs/shaderMaterial';
  195. import {MeshBuilder} from 'babylonjs/meshBuilder';
  196. import {PBRBaseMaterial,PBRBaseSimpleMaterial,PBRMaterial,PBRMetallicRoughnessMaterial,PBRSpecularGlossinessMaterial} from 'babylonjs/pbrMaterial';
  197. import {CameraInputTypes,ICameraInput,CameraInputsMap,CameraInputsManager,TargetCamera} from 'babylonjs/targetCamera';
  198. import {ArcRotateCameraKeyboardMoveInput,ArcRotateCameraMouseWheelInput,ArcRotateCameraPointersInput,ArcRotateCameraInputsManager,ArcRotateCamera} from 'babylonjs/arcRotateCamera';
  199. import {FreeCameraMouseInput,FreeCameraKeyboardMoveInput,FreeCameraInputsManager,FreeCamera} from 'babylonjs/freeCamera';
  200. import {HemisphericLight} from 'babylonjs/hemisphericLight';
  201. import {IShadowLight,ShadowLight,PointLight} from 'babylonjs/pointLight';
  202. import {DirectionalLight} from 'babylonjs/directionalLight';
  203. import {SpotLight} from 'babylonjs/spotLight';
  204. import {CubeTexture,RenderTargetTexture,IMultiRenderTargetOptions,MultiRenderTarget,MirrorTexture,RefractionTexture,DynamicTexture,VideoTexture,RawTexture} from 'babylonjs/additionalTextures';
  205. import {AudioEngine,Sound,SoundTrack,Analyser} from 'babylonjs/audio';
  206. import {ILoadingScreen,DefaultLoadingScreen,SceneLoaderProgressEvent,ISceneLoaderPluginExtensions,ISceneLoaderPluginFactory,ISceneLoaderPlugin,ISceneLoaderPluginAsync,SceneLoader,FilesInput} from 'babylonjs/loader';
  207. import {StringDictionary} from 'babylonjs/stringDictionary';
  208. import {Tags,AndOrNotEvaluator} from 'babylonjs/userData';
  209. import {FresnelParameters} from 'babylonjs/fresnel';
  210. import {MultiMaterial} from 'babylonjs/multiMaterial';
  211. import {Database} from 'babylonjs/offline';
  212. import {FreeCameraTouchInput,TouchCamera} from 'babylonjs/touchCamera';
  213. import {ProceduralTexture,CustomProceduralTexture} from 'babylonjs/procedural';
  214. import {FreeCameraGamepadInput,ArcRotateCameraGamepadInput,GamepadManager,StickValues,GamepadButtonChanges,Gamepad,GenericPad,Xbox360Button,Xbox360Dpad,Xbox360Pad,PoseEnabledControllerType,MutableGamepadButton,ExtendedGamepadButton,PoseEnabledControllerHelper,PoseEnabledController,WebVRController,OculusTouchController,ViveController,GenericController,WindowsMotionController} from 'babylonjs/gamepad';
  215. import {FollowCamera,ArcFollowCamera,UniversalCamera,GamepadCamera} from 'babylonjs/additionalCameras';
  216. import {DepthRenderer} from 'babylonjs/depthRenderer';
  217. import {GeometryBufferRenderer} from 'babylonjs/geometryBufferRenderer';
  218. import {PostProcessOptions,PostProcess,PassPostProcess} from 'babylonjs/postProcesses';
  219. import {BlurPostProcess} from 'babylonjs/additionalPostProcess_blur';
  220. import {FxaaPostProcess} from 'babylonjs/additionalPostProcess_fxaa';
  221. import {HighlightsPostProcess} from 'babylonjs/additionalPostProcess_highlights';
  222. import {RefractionPostProcess,BlackAndWhitePostProcess,ConvolutionPostProcess,FilterPostProcess,VolumetricLightScatteringPostProcess,ColorCorrectionPostProcess,TonemappingOperator,TonemapPostProcess,DisplayPassPostProcess,ImageProcessingPostProcess} from 'babylonjs/additionalPostProcesses';
  223. import {PostProcessRenderPipelineManager,PostProcessRenderPass,PostProcessRenderEffect,PostProcessRenderPipeline} from 'babylonjs/renderingPipeline';
  224. import {SSAORenderingPipeline,SSAO2RenderingPipeline,LensRenderingPipeline,StandardRenderingPipeline} from 'babylonjs/additionalRenderingPipeline';
  225. import {DefaultRenderingPipeline} from 'babylonjs/defaultRenderingPipeline';
  226. import {Bone,BoneIKController,BoneLookController,Skeleton} from 'babylonjs/bones';
  227. import {SphericalPolynomial,SphericalHarmonics,CubeMapToSphericalPolynomialTools,CubeMapInfo,PanoramaToCubeMapTools,HDRInfo,HDRTools,HDRCubeTexture} from 'babylonjs/hdr';
  228. import {CSG} from 'babylonjs/csg';
  229. import {Polygon,PolygonMeshBuilder} from 'babylonjs/polygonMesh';
  230. import {LensFlare,LensFlareSystem} from 'babylonjs/lensFlares';
  231. import {PhysicsJointData,PhysicsJoint,DistanceJoint,MotorEnabledJoint,HingeJoint,Hinge2Joint,IMotorEnabledJoint,DistanceJointData,SpringJointData,PhysicsImpostorParameters,IPhysicsEnabledObject,PhysicsImpostor,PhysicsImpostorJoint,PhysicsEngine,IPhysicsEnginePlugin,PhysicsHelper,PhysicsRadialExplosionEvent,PhysicsGravitationalFieldEvent,PhysicsUpdraftEvent,PhysicsVortexEvent,PhysicsRadialImpulseFalloff,PhysicsUpdraftMode,PhysicsForceAndContactPoint,PhysicsRadialExplosionEventData,PhysicsGravitationalFieldEventData,PhysicsUpdraftEventData,PhysicsVortexEventData,CannonJSPlugin,OimoJSPlugin} from 'babylonjs/physics';
  232. import {TGATools,DDSInfo,DDSTools,KhronosTextureContainer} from 'babylonjs/textureFormats';
  233. import {Debug,RayHelper,DebugLayer,BoundingBoxRenderer} from 'babylonjs/debug';
  234. import {MorphTarget,MorphTargetManager} from 'babylonjs/morphTargets';
  235. import {IOctreeContainer,Octree,OctreeBlock} from 'babylonjs/octrees';
  236. import {SIMDHelper} from 'babylonjs/simd';
  237. import {VRDistortionCorrectionPostProcess,AnaglyphPostProcess,StereoscopicInterlacePostProcess,FreeCameraDeviceOrientationInput,ArcRotateCameraVRDeviceOrientationInput,VRCameraMetrics,DevicePose,PoseControlled,WebVROptions,WebVRFreeCamera,DeviceOrientationCamera,VRDeviceOrientationFreeCamera,VRDeviceOrientationGamepadCamera,VRDeviceOrientationArcRotateCamera,AnaglyphFreeCamera,AnaglyphArcRotateCamera,AnaglyphGamepadCamera,AnaglyphUniversalCamera,StereoscopicFreeCamera,StereoscopicArcRotateCamera,StereoscopicGamepadCamera,StereoscopicUniversalCamera,VRTeleportationOptions,VRExperienceHelperOptions,VRExperienceHelper} from 'babylonjs/vr';
  238. import {JoystickAxis,VirtualJoystick,VirtualJoysticksCamera,FreeCameraVirtualJoystickInput} from 'babylonjs/virtualJoystick';
  239. import {ISimplifier,ISimplificationSettings,SimplificationSettings,ISimplificationTask,SimplificationQueue,SimplificationType,DecimationTriangle,DecimationVertex,QuadraticMatrix,Reference,QuadraticErrorSimplification,MeshLODLevel,SceneOptimization,TextureOptimization,HardwareScalingOptimization,ShadowsOptimization,PostProcessesOptimization,LensFlaresOptimization,ParticlesOptimization,RenderTargetsOptimization,MergeMeshesOptimization,SceneOptimizerOptions,SceneOptimizer} from 'babylonjs/optimizations';
  240. import {OutlineRenderer,EdgesRenderer,IHighlightLayerOptions,HighlightLayer} from 'babylonjs/highlights';
  241. import {SceneSerializer} from 'babylonjs/serialization';
  242. import {AssetTaskState,AbstractAssetTask,IAssetsProgressEvent,AssetsProgressEvent,MeshAssetTask,TextFileAssetTask,BinaryFileAssetTask,ImageAssetTask,ITextureAssetTask,TextureAssetTask,CubeTextureAssetTask,HDRCubeTextureAssetTask,AssetsManager} from 'babylonjs/assetsManager';
  243. import {ReflectionProbe} from 'babylonjs/probes';
  244. import {BackgroundMaterial} from 'babylonjs/backgroundMaterial';
  245. import {Layer} from 'babylonjs/layer';
  246. import {IEnvironmentHelperOptions,EnvironmentHelper} from 'babylonjs/environmentHelper';