babylon.engine.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. declare module BABYLON {
  2. class _DepthCullingState {
  3. private _isDepthTestDirty;
  4. private _isDepthMaskDirty;
  5. private _isDepthFuncDirty;
  6. private _isCullFaceDirty;
  7. private _isCullDirty;
  8. private _depthTest;
  9. private _depthMask;
  10. private _depthFunc;
  11. private _cull;
  12. private _cullFace;
  13. public isDirty : boolean;
  14. public cullFace : number;
  15. public cull : boolean;
  16. public depthFunc : number;
  17. public depthMask : boolean;
  18. public depthTest : boolean;
  19. public reset(): void;
  20. public apply(gl: WebGLRenderingContext): void;
  21. }
  22. class _AlphaState {
  23. private _isAlphaBlendDirty;
  24. private _isBlendFunctionParametersDirty;
  25. private _alphaBlend;
  26. private _blendFunctionParameters;
  27. public isDirty : boolean;
  28. public alphaBlend : boolean;
  29. public setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30. public reset(): void;
  31. public apply(gl: WebGLRenderingContext): void;
  32. }
  33. class EngineCapabilities {
  34. public maxTexturesImageUnits: number;
  35. public maxTextureSize: number;
  36. public maxCubemapTextureSize: number;
  37. public maxRenderTextureSize: number;
  38. public standardDerivatives: boolean;
  39. public s3tc: any;
  40. public textureFloat: boolean;
  41. public textureAnisotropicFilterExtension: any;
  42. public maxAnisotropy: number;
  43. public instancedArrays: any;
  44. public uintIndices: boolean;
  45. }
  46. class Engine {
  47. private static _ALPHA_DISABLE;
  48. private static _ALPHA_ADD;
  49. private static _ALPHA_COMBINE;
  50. private static _DELAYLOADSTATE_NONE;
  51. private static _DELAYLOADSTATE_LOADED;
  52. private static _DELAYLOADSTATE_LOADING;
  53. private static _DELAYLOADSTATE_NOTLOADED;
  54. private static _TEXTUREFORMAT_ALPHA;
  55. private static _TEXTUREFORMAT_LUMINANCE;
  56. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  57. private static _TEXTUREFORMAT_RGB;
  58. private static _TEXTUREFORMAT_RGBA;
  59. static ALPHA_DISABLE : number;
  60. static ALPHA_ADD : number;
  61. static ALPHA_COMBINE : number;
  62. static DELAYLOADSTATE_NONE : number;
  63. static DELAYLOADSTATE_LOADED : number;
  64. static DELAYLOADSTATE_LOADING : number;
  65. static DELAYLOADSTATE_NOTLOADED : number;
  66. static TEXTUREFORMAT_ALPHA : number;
  67. static TEXTUREFORMAT_LUMINANCE : number;
  68. static TEXTUREFORMAT_LUMINANCE_ALPHA : number;
  69. static TEXTUREFORMAT_RGB : number;
  70. static TEXTUREFORMAT_RGBA : number;
  71. static Version : string;
  72. static Epsilon: number;
  73. static CollisionsEpsilon: number;
  74. static ShadersRepository: string;
  75. public isFullscreen: boolean;
  76. public isPointerLock: boolean;
  77. public cullBackFaces: boolean;
  78. public renderEvenInBackground: boolean;
  79. public scenes: Scene[];
  80. private _gl;
  81. private _renderingCanvas;
  82. private _windowIsBackground;
  83. private _audioEngine;
  84. private _onBlur;
  85. private _onFocus;
  86. private _onFullscreenChange;
  87. private _onPointerLockChange;
  88. private _hardwareScalingLevel;
  89. private _caps;
  90. private _pointerLockRequested;
  91. private _alphaTest;
  92. private _resizeLoadingUI;
  93. private _loadingDiv;
  94. private _loadingTextDiv;
  95. private _loadingDivBackgroundColor;
  96. private _drawCalls;
  97. private _renderingQueueLaunched;
  98. private _activeRenderLoops;
  99. private fpsRange;
  100. private previousFramesDuration;
  101. private fps;
  102. private deltaTime;
  103. private _depthCullingState;
  104. private _alphaState;
  105. private _alphaMode;
  106. private _loadedTexturesCache;
  107. public _activeTexturesCache: BaseTexture[];
  108. private _currentEffect;
  109. private _compiledEffects;
  110. private _vertexAttribArrays;
  111. private _cachedViewport;
  112. private _cachedVertexBuffers;
  113. private _cachedIndexBuffer;
  114. private _cachedEffectForVertexBuffers;
  115. private _currentRenderTarget;
  116. private _canvasClientRect;
  117. private _uintIndicesCurrentlySet;
  118. private _workingCanvas;
  119. private _workingContext;
  120. constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: any);
  121. public getAudioEngine(): AudioEngine;
  122. public getAspectRatio(camera: Camera): number;
  123. public getRenderWidth(): number;
  124. public getRenderHeight(): number;
  125. public getRenderingCanvas(): HTMLCanvasElement;
  126. public getRenderingCanvasClientRect(): ClientRect;
  127. public setHardwareScalingLevel(level: number): void;
  128. public getHardwareScalingLevel(): number;
  129. public getLoadedTexturesCache(): WebGLTexture[];
  130. public getCaps(): EngineCapabilities;
  131. public drawCalls : number;
  132. public resetDrawCalls(): void;
  133. public setDepthFunctionToGreater(): void;
  134. public setDepthFunctionToGreaterOrEqual(): void;
  135. public setDepthFunctionToLess(): void;
  136. public setDepthFunctionToLessOrEqual(): void;
  137. public stopRenderLoop(renderFunction?: () => void): void;
  138. public _renderLoop(): void;
  139. public runRenderLoop(renderFunction: () => void): void;
  140. public switchFullscreen(requestPointerLock: boolean): void;
  141. public clear(color: any, backBuffer: boolean, depthStencil: boolean): void;
  142. public setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  143. public setDirectViewport(x: number, y: number, width: number, height: number): void;
  144. public beginFrame(): void;
  145. public endFrame(): void;
  146. public resize(): void;
  147. public setSize(width: number, height: number): void;
  148. public bindFramebuffer(texture: WebGLTexture): void;
  149. public unBindFramebuffer(texture: WebGLTexture): void;
  150. public flushFramebuffer(): void;
  151. public restoreDefaultFramebuffer(): void;
  152. private _resetVertexBufferBinding();
  153. public createVertexBuffer(vertices: number[]): WebGLBuffer;
  154. public createDynamicVertexBuffer(capacity: number): WebGLBuffer;
  155. public updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: any, offset?: number): void;
  156. private _resetIndexBufferBinding();
  157. public createIndexBuffer(indices: number[]): WebGLBuffer;
  158. public bindBuffers(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  159. public bindMultiBuffers(vertexBuffers: VertexBuffer[], indexBuffer: WebGLBuffer, effect: Effect): void;
  160. public _releaseBuffer(buffer: WebGLBuffer): boolean;
  161. public createInstancesBuffer(capacity: number): WebGLBuffer;
  162. public deleteInstancesBuffer(buffer: WebGLBuffer): void;
  163. public updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[]): void;
  164. public unBindInstancesBuffer(instancesBuffer: WebGLBuffer, offsetLocations: number[]): void;
  165. public applyStates(): void;
  166. public draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  167. public drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  168. public _releaseEffect(effect: Effect): void;
  169. public createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  170. public createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  171. public createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
  172. public getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  173. public getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  174. public enableEffect(effect: Effect): void;
  175. public setArray(uniform: WebGLUniformLocation, array: number[]): void;
  176. public setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  177. public setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  178. public setFloat(uniform: WebGLUniformLocation, value: number): void;
  179. public setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  180. public setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  181. public setBool(uniform: WebGLUniformLocation, bool: number): void;
  182. public setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  183. public setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  184. public setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  185. public setState(culling: boolean, force?: boolean): void;
  186. public setDepthBuffer(enable: boolean): void;
  187. public getDepthWrite(): boolean;
  188. public setDepthWrite(enable: boolean): void;
  189. public setColorWrite(enable: boolean): void;
  190. public setAlphaMode(mode: number): void;
  191. public getAlphaMode(): number;
  192. public setAlphaTesting(enable: boolean): void;
  193. public getAlphaTesting(): boolean;
  194. public wipeCaches(): void;
  195. public setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
  196. public createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
  197. public createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number): WebGLTexture;
  198. public createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): WebGLTexture;
  199. public updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean): void;
  200. public updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
  201. public createRenderTargetTexture(size: any, options: any): WebGLTexture;
  202. public createCubeTexture(rootUrl: string, scene: Scene, extensions: string[], noMipmap?: boolean): WebGLTexture;
  203. public _releaseTexture(texture: WebGLTexture): void;
  204. public bindSamplers(effect: Effect): void;
  205. public _bindTexture(channel: number, texture: WebGLTexture): void;
  206. public setTextureFromPostProcess(channel: number, postProcess: PostProcess): void;
  207. public setTexture(channel: number, texture: BaseTexture): void;
  208. public _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  209. public readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  210. public dispose(): void;
  211. public displayLoadingUI(): void;
  212. public loadingUIText : string;
  213. public loadingUIBackgroundColor : string;
  214. public hideLoadingUI(): void;
  215. public getFps(): number;
  216. public getDeltaTime(): number;
  217. private _measureFps();
  218. static isSupported(): boolean;
  219. }
  220. }