Browse Source

Module augmentation

sebastien 6 năm trước cách đây
mục cha
commit
b52ea9569e

+ 5 - 0
src/Culling/Octrees/octreeSceneComponent.ts

@@ -5,6 +5,8 @@ import { AbstractMesh, SubMesh } from "Mesh";
 import { Collider } from "Collisions";
 import { Ray, Octree } from "Culling";
 import { SceneComponentConstants } from "sceneComponent";
+
+declare module "scene" {
     export interface Scene {
         /**
          * @hidden
@@ -27,6 +29,7 @@ import { SceneComponentConstants } from "sceneComponent";
          */
         createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
     }
+}
 
     Scene.prototype.createOrUpdateSelectionOctree = function(maxCapacity = 64, maxDepth = 2): Octree<AbstractMesh> {
         let component = this._getComponent(SceneComponentConstants.NAME_OCTREE);
@@ -55,6 +58,7 @@ import { SceneComponentConstants } from "sceneComponent";
         configurable: true
     });
 
+declare module "Mesh/AbstractMesh" {
     export interface AbstractMesh {
         /**
          * @hidden
@@ -73,6 +77,7 @@ import { SceneComponentConstants } from "sceneComponent";
          */
         createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
     }
+}
 
     /**
      * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.

+ 2 - 1
src/Debug/debugLayer.ts

@@ -5,6 +5,7 @@ import { Scene } from "scene";
     declare var INSPECTOR: any;
     // load the inspector using require, if not present in the global namespace.
 
+declare module "scene" {
     export interface Scene {
         /**
          * @hidden
@@ -18,7 +19,7 @@ import { Scene } from "scene";
          */
         debugLayer: DebugLayer;
     }
-
+}
     Object.defineProperty(Scene.prototype, "debugLayer", {
         get: function(this: Scene) {
             if (!this._debugLayer) {

+ 4 - 1
src/Engine/Extensions/engine.occlusionQuery.ts

@@ -23,6 +23,7 @@ import { _TimeToken } from "Instrumentation";
         public occlusionQueryAlgorithmType = AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
     }
 
+declare module "Engine/Engine" {
     export interface Engine {
         /**
          * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
@@ -100,6 +101,7 @@ import { _TimeToken } from "Instrumentation";
         /** @hidden */
         _getTimeQueryAvailability(query: WebGLQuery): any;
     }
+}
 
     Engine.prototype.createQuery = function(): WebGLQuery {
         return this._gl.createQuery();
@@ -272,6 +274,7 @@ import { _TimeToken } from "Instrumentation";
         return algorithmType === AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
     };
 
+declare module "Mesh/AbstractMesh" {
     export interface AbstractMesh {
         /**
          * Backing filed
@@ -321,7 +324,7 @@ import { _TimeToken } from "Instrumentation";
          */
         isOcclusionQueryInProgress: boolean;
     }
-
+}
     Object.defineProperty(AbstractMesh.prototype, "isOcclusionQueryInProgress", {
         get: function(this: AbstractMesh) {
             return this._occlusionDataStorage.isOcclusionQueryInProgress;

+ 3 - 0
src/Engine/Extensions/engine.transformFeedback.ts

@@ -1,6 +1,8 @@
 import { Nullable } from "types";
 import { Engine } from "Engine";
 import { _TimeToken } from "Instrumentation";
+
+declare module "Engine/Engine" {
     export interface Engine {
         /**
          * Creates a webGL transform feedback object
@@ -45,6 +47,7 @@ import { _TimeToken } from "Instrumentation";
          */
         bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
     }
+}
 
     Engine.prototype.createTransformFeedback = function(): WebGLTransformFeedback {
         return this._gl.createTransformFeedback();

+ 3 - 0
src/Gamepad/gamepadSceneComponent.ts

@@ -5,6 +5,8 @@ import {GamepadManager} from "Gamepad"
 import { SceneComponentConstants, ISceneComponent } from "sceneComponent";
 import { _TimeToken } from "Instrumentation";
 import { _DepthCullingState, _StencilState, _AlphaState } from "States";
+
+declare module "scene" {
     export interface Scene {
         /** @hidden */
         _gamepadManager: Nullable<GamepadManager>;
@@ -15,6 +17,7 @@ import { _DepthCullingState, _StencilState, _AlphaState } from "States";
          */
         gamepadManager: GamepadManager;
     }
+}
 
     Object.defineProperty(Scene.prototype, "gamepadManager", {
         get: function(this: Scene) {

+ 3 - 0
src/Helpers/sceneHelpers.ts

@@ -7,6 +7,8 @@ import { Mesh } from "Mesh";
 import { StandardMaterial, Texture, BaseTexture } from "Materials";
 import { HemisphericLight } from "Lights";
 import { IEnvironmentHelperOptions, EnvironmentHelper } from "./environmentHelper";
+
+declare module "scene" {
     export interface Scene {
         /**
          * Creates a default light for the scene.
@@ -68,6 +70,7 @@ import { IEnvironmentHelperOptions, EnvironmentHelper } from "./environmentHelpe
          */
         createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
     }
+}
 
     Scene.prototype.createDefaultLight = function(replace = false): void {
         // Dispose existing light in replace mode.

+ 2 - 0
src/Layer/effectLayerSceneComponent.ts

@@ -23,6 +23,7 @@ import { AssetContainer } from "assetContainer";
         }
     });
 
+declare module "abstractScene" {
     export interface AbstractScene {
         /**
          * The list of effect layers (highlights/glow) added to the scene
@@ -44,6 +45,7 @@ import { AssetContainer } from "assetContainer";
          */
         addEffectLayer(newEffectLayer: EffectLayer): void;
     }
+}
 
     AbstractScene.prototype.removeEffectLayer = function(toRemove: EffectLayer): number {
         var index = this.effectLayers.indexOf(toRemove);

+ 3 - 0
src/Layer/glowLayer.ts

@@ -9,6 +9,8 @@ import { RenderTargetTexture, Material, Texture, Effect } from "Materials";
 import { PostProcess, BlurPostProcess } from "PostProcess";
 import { EffectLayer } from "Layer";
 import { AbstractScene } from "abstractScene";
+
+declare module "abstractScene" {
     export interface AbstractScene {
         /**
          * Return a the first highlight layer of the scene with a given name.
@@ -17,6 +19,7 @@ import { AbstractScene } from "abstractScene";
          */
         getGlowLayerByName(name: string): Nullable<GlowLayer>;
     }
+}
 
     AbstractScene.prototype.getGlowLayerByName = function(name: string): Nullable<GlowLayer> {
         for (var index = 0; index < this.effectLayers.length; index++) {

+ 3 - 0
src/Layer/highlightLayer.ts

@@ -11,6 +11,8 @@ import { _TimeToken } from "Instrumentation";
 import { _DepthCullingState, _StencilState, _AlphaState } from "States";
 import { EffectLayer } from "Layer";
 import { AbstractScene } from "abstractScene";
+
+declare module "abstractScene" {
     export interface AbstractScene {
         /**
          * Return a the first highlight layer of the scene with a given name.
@@ -19,6 +21,7 @@ import { AbstractScene } from "abstractScene";
          */
         getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
     }
+}
 
     AbstractScene.prototype.getHighlightLayerByName = function(name: string): Nullable<HighlightLayer> {
         for (var index = 0; index < this.effectLayers.length; index++) {

+ 2 - 0
src/LensFlare/lensFlareSystemSceneComponent.ts

@@ -24,6 +24,7 @@ import { LensFlareSystem } from "LensFlare";
         }
     });
 
+declare module "abstractScene" {
     export interface AbstractScene {
         /**
          * The list of lens flare system added to the scene
@@ -58,6 +59,7 @@ import { LensFlareSystem } from "LensFlare";
          */
         getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
     }
+}
 
     AbstractScene.prototype.getLensFlareSystemByName = function(name: string): Nullable<LensFlareSystem> {
         for (var index = 0; index < this.lensFlareSystems.length; index++) {

+ 3 - 1
src/Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts

@@ -6,6 +6,8 @@ import { _TimeToken } from "Instrumentation";
 import { _DepthCullingState, _StencilState, _AlphaState } from "States";
 import { Layer } from "Layer";
 import { AbstractScene } from "abstractScene";
+
+declare module "abstractScene" {
     export interface AbstractScene {
         /**
          * The list of procedural textures added to the scene
@@ -13,7 +15,7 @@ import { AbstractScene } from "abstractScene";
          */
         proceduralTextures: Array<ProceduralTexture>;
     }
-
+}
     /**
      * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
      * in a given scene.

+ 5 - 1
src/Mesh/meshSimplificationSceneComponent.ts

@@ -1,6 +1,8 @@
 import { Scene } from "scene";
 import { Mesh, SimplificationQueue, ISimplificationSettings, SimplificationType } from "Mesh";
 import { SceneComponentConstants, ISceneComponent } from "sceneComponent";
+
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _simplificationQueue: SimplificationQueue;
@@ -11,7 +13,7 @@ import { SceneComponentConstants, ISceneComponent } from "sceneComponent";
          */
         simplificationQueue: SimplificationQueue;
     }
-
+}
     Object.defineProperty(Scene.prototype, "simplificationQueue", {
         get: function(this: Scene) {
             if (!this._simplificationQueue) {
@@ -31,6 +33,7 @@ import { SceneComponentConstants, ISceneComponent } from "sceneComponent";
         configurable: true
     });
 
+declare module "Mesh/Mesh" {
     export interface Mesh {
         /**
          * Simplify the mesh according to the given array of settings.
@@ -43,6 +46,7 @@ import { SceneComponentConstants, ISceneComponent } from "sceneComponent";
          */
         simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
     }
+}
 
     Mesh.prototype.simplify = function(settings: Array<ISimplificationSettings>, parallelProcessing: boolean = true, simplificationType: SimplificationType = SimplificationType.QUADRATIC, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh {
         this.getScene().simplificationQueue.addTask({

+ 4 - 0
src/Particles/particleSystemComponent.ts

@@ -34,6 +34,7 @@ import { SceneComponentConstants } from "sceneComponent";
         }
     });
 
+declare module "Engine/Engine" {
     export interface Engine {
         /**
          * Create an effect to use with particle systems.
@@ -50,6 +51,7 @@ import { SceneComponentConstants } from "sceneComponent";
         createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks,
             onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
     }
+}
 
     Engine.prototype.createEffectForParticles = function(fragmentName: string, uniformsNames: string[] = [], samplers: string[] = [], defines = "", fallbacks?: EffectFallbacks,
         onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect {
@@ -75,6 +77,7 @@ import { SceneComponentConstants } from "sceneComponent";
             samplers, defines, fallbacks, onCompiled, onError);
     };
 
+declare module "Mesh/Mesh" {
     export interface Mesh {
         /**
          * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
@@ -88,6 +91,7 @@ import { SceneComponentConstants } from "sceneComponent";
          */
         getHierarchyEmittedParticleSystems(): IParticleSystem[];
     }
+}
 
     Mesh.prototype.getEmittedParticleSystems = function(): IParticleSystem[] {
         var results = new Array<IParticleSystem>();

+ 5 - 0
src/Physics/physicsEngineComponent.ts

@@ -5,6 +5,8 @@ import { Mesh, AbstractMesh } from "Mesh";
 import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 import { IPhysicsEngine, IPhysicsEnginePlugin, PhysicsEngine, PhysicsImpostor, PhysicsJoint } from "Physics";
 import { Scene } from "scene";
+
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _physicsEngine: Nullable<IPhysicsEngine>;
@@ -50,6 +52,7 @@ import { Scene } from "scene";
          */
         onAfterPhysicsObservable: Observable<Scene>;
     }
+}
 
     /**
      * Gets the current physics engine
@@ -128,6 +131,7 @@ import { Scene } from "scene";
         }
     };
 
+declare module "Mesh/AbstractMesh" {
     export interface AbstractMesh {
         /** @hidden */
         _physicsImpostor: Nullable<PhysicsImpostor>;
@@ -167,6 +171,7 @@ import { Scene } from "scene";
         /** @hidden */
         _disposePhysicsObserver: Nullable<Observer<Node>>;
     }
+}
 
     Object.defineProperty(AbstractMesh.prototype, "physicsImpostor", {
         get: function(this: AbstractMesh) {

+ 3 - 0
src/PostProcess/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts

@@ -1,6 +1,8 @@
 import { ISceneComponent } from "sceneComponent";
 import { PostProcessRenderPipelineManager } from "PostProcess";
 import { Scene } from "scene";
+
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
@@ -12,6 +14,7 @@ import { Scene } from "scene";
          */
         readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
     }
+}
 
     Object.defineProperty(Scene.prototype, "postProcessRenderPipelineManager", {
         get: function(this: Scene) {

+ 2 - 0
src/Probes/reflectionProbe.ts

@@ -3,6 +3,7 @@ import { Matrix, Vector3 } from "Math";
 import { AbstractMesh } from "Mesh";
 import { Nullable } from "types";
 
+declare module "scene" {
     export interface Scene {
         /**
          * The list of reflection probes added to the scene
@@ -10,6 +11,7 @@ import { Nullable } from "types";
          */
         reflectionProbes: Array<ReflectionProbe>;
     }
+}
 
     /**
      * Class used to generate realtime reflection / refraction cube textures

+ 4 - 0
src/Rendering/boundingBoxRenderer.ts

@@ -7,6 +7,7 @@ import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 import { BoundingBox } from "Culling";
 import { ShaderMaterial, Material, Effect } from "Materials";
 
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _boundingBoxRenderer: BoundingBoxRenderer;
@@ -25,6 +26,7 @@ import { ShaderMaterial, Material, Effect } from "Materials";
          */
         getBoundingBoxRenderer(): BoundingBoxRenderer;
     }
+}
 
     Object.defineProperty(Scene.prototype, "forceShowBoundingBoxes", {
         get: function(this: Scene) {
@@ -50,6 +52,7 @@ import { ShaderMaterial, Material, Effect } from "Materials";
         return this._boundingBoxRenderer;
     };
 
+declare module "Mesh/AbstractMesh" {
     export interface AbstractMesh {
         /** @hidden (Backing field) */
         _showBoundingBox: boolean;
@@ -59,6 +62,7 @@ import { ShaderMaterial, Material, Effect } from "Materials";
          */
         showBoundingBox: boolean;
     }
+}
 
     Object.defineProperty(AbstractMesh.prototype, "showBoundingBox", {
         get: function(this: AbstractMesh) {

+ 2 - 0
src/Rendering/depthRendererSceneComponent.ts

@@ -7,6 +7,7 @@ import { Engine } from "Engine";
 import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 import { RenderTargetTexture } from "Materials";
 
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _depthRenderer: { [id: string]: DepthRenderer };
@@ -24,6 +25,7 @@ import { RenderTargetTexture } from "Materials";
          */
         disableDepthRenderer(camera?: Nullable<Camera>): void;
     }
+}
 
     Scene.prototype.enableDepthRenderer = function(camera?: Nullable<Camera>): DepthRenderer {
         camera = camera || this.activeCamera;

+ 2 - 0
src/Rendering/geometryBufferRendererSceneComponent.ts

@@ -5,6 +5,7 @@ import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 import { SmartArrayNoDuplicate } from "Tools";
 import { RenderTargetTexture } from "Materials";
 
+declare module "scene" {
     export interface Scene {
         /** @hidden (Backing field) */
         _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
@@ -26,6 +27,7 @@ import { RenderTargetTexture } from "Materials";
          */
         disableGeometryBufferRenderer(): void;
     }
+}
 
     Object.defineProperty(Scene.prototype, "geometryBufferRenderer", {
         get: function(this: Scene) {

+ 4 - 0
src/Rendering/outlineRenderer.ts

@@ -4,6 +4,7 @@ import { Engine } from "Particles";
 import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 import { Effect, Material } from "Materials";
 
+declare module "scene" {
     export interface Scene {
         /** @hidden */
         _outlineRenderer: OutlineRenderer;
@@ -14,6 +15,7 @@ import { Effect, Material } from "Materials";
          */
         getOutlineRenderer(): OutlineRenderer;
     }
+}
 
     /**
      * Gets the outline renderer associated with the scene
@@ -26,6 +28,7 @@ import { Effect, Material } from "Materials";
         return this._outlineRenderer;
     };
 
+declare module "Mesh/AbstractMesh" {
     export interface AbstractMesh {
         /** @hidden (Backing field) */
         _renderOutline: boolean;
@@ -43,6 +46,7 @@ import { Effect, Material } from "Materials";
          */
         renderOverlay: boolean;
     }
+}
 
     Object.defineProperty(AbstractMesh.prototype, "renderOutline", {
         get: function(this: AbstractMesh) {

+ 2 - 0
src/Sprites/spriteSceneComponent.ts

@@ -7,6 +7,7 @@ import { Camera } from "Cameras";
 import { PickingInfo } from "Collisions";
 import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
 
+declare module "scene" {
     export interface Scene {
         /** @hidden */
         _pointerOverSprite: Nullable<Sprite>;
@@ -69,6 +70,7 @@ import { ISceneComponent, SceneComponentConstants } from "sceneComponent";
          */
         getPointerOverSprite(): Nullable<Sprite>;
     }
+}
 
     Scene.prototype._internalPickSprites = function(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo> {
         if (!PickingInfo) {