فهرست منبع

Allow build configuration to reference external libraries

David Catuhe 8 سال پیش
والد
کامیت
9a29373890

+ 5 - 3
Tools/Gulp/config.json

@@ -26,7 +26,7 @@
         ],
         "minimal": ["standardMaterial", "freeCamera", "hemisphericLight"],
         "minimalWithBuilder": ["meshBuilder", "standardMaterial", "freeCamera", "hemisphericLight"],
-        "minimalViewer": [
+        "minimalGLTFViewer": [
                 "animations", "arcRotateCamera", "additionalTextures", "textureFormats",
                 "shadows", "pointLight", "directionalLight", "spotLight",
                 "multiMaterial", "pbrMaterial",
@@ -34,9 +34,11 @@
                 "additionalPostProcess_blur", "additionalPostProcess_fxaa", "additionalPostProcess_highlights", 
                 "additionalPostProcess_imageProcessing", "colorCurves", "defaultRenderingPipeline", "imageProcessing",
                 "debug", "textureTools", "hdr",
-                "loader"
+                "loader",
+                "materialsLibrary/babylon.gridMaterial.js",
+                "loaders/babylon.glTFFileLoader.js"
         ],
-        "distributed": ["minimalViewer"]
+        "distributed": ["minimalGLTFViewer"]
     },
     "workloads" :
     {

+ 6 - 1
Tools/Gulp/gulpfile.js

@@ -89,7 +89,12 @@ function determineFilesToProcess(kind) {
     for (var index = 0; index < buildConfiguration.length; index++) {
         var dependencyName = buildConfiguration[index];
         var dependency = config.workloads[dependencyName];
-        processDependency(kind, dependency, filesToLoad);
+
+        if (dependency) {
+            processDependency(kind, dependency, filesToLoad);
+        } else if (kind === "files") { // direct file link
+            filesToLoad.push("../../dist/preview release/" + dependencyName);
+        }
     }
 
     if (kind === "shaderIncludes") {

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 7681 - 7628
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 7681 - 7628
dist/preview release/babylon.module.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 18132 - 0
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 35 - 0
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 52417 - 0
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 18134 - 0
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 6996 - 6943
dist/preview release/customConfigurations/minimalViewer/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 28 - 28
dist/preview release/customConfigurations/minimalViewer/babylon.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 302 - 128
dist/preview release/customConfigurations/minimalViewer/babylon.max.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 6996 - 6943
dist/preview release/customConfigurations/minimalViewer/babylon.module.d.ts


+ 3 - 2
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -371,11 +371,12 @@
             for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
                     var particleSystem = scene.particleSystems[particleIndex];
 
-                    if (!particleSystem.isStarted() || !particleSystem.emitter || !particleSystem.emitter.position || !particleSystem.emitter.isEnabled()) {
+                    let emitter: any = particleSystem.emitter;
+                    if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
                         continue;
                     }
 
-                    if (currentRenderList.indexOf(particleSystem.emitter) >= 0) {
+                    if (currentRenderList.indexOf(emitter) >= 0) {
                         this._renderingManager.dispatchParticles(particleSystem);
                     }
                 }

+ 7 - 5
src/Mesh/babylon.mesh.ts

@@ -1215,8 +1215,8 @@
         /**
          * Returns an array populated with ParticleSystem objects whose the mesh is the emitter. 
          */
-        public getEmittedParticleSystems(): ParticleSystem[] {
-            var results = new Array<ParticleSystem>();
+        public getEmittedParticleSystems(): IParticleSystem[] {
+            var results = new Array<IParticleSystem>();
             for (var index = 0; index < this.getScene().particleSystems.length; index++) {
                 var particleSystem = this.getScene().particleSystems[index];
                 if (particleSystem.emitter === this) {
@@ -1229,14 +1229,16 @@
         /**
          * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
          */
-        public getHierarchyEmittedParticleSystems(): ParticleSystem[] {
-            var results = new Array<ParticleSystem>();
+        public getHierarchyEmittedParticleSystems(): IParticleSystem[] {
+            var results = new Array<IParticleSystem>();
             var descendants = this.getDescendants();
             descendants.push(this);
 
             for (var index = 0; index < this.getScene().particleSystems.length; index++) {
                 var particleSystem = this.getScene().particleSystems[index];
-                if (descendants.indexOf(particleSystem.emitter) !== -1) {
+                let emitter: any = particleSystem.emitter;
+
+                if (emitter.position && descendants.indexOf(emitter) !== -1) {
                     results.push(particleSystem);
                 }
             }

+ 56 - 0
src/Particles/babylon.gpuParticleSystem.ts

@@ -0,0 +1,56 @@
+module BABYLON {
+    export class GPUParticleSystem implements IDisposable, IParticleSystem {
+        // Members
+        public id: string;
+        public emitter = null;        
+        public renderingGroupId = 0;        
+        public layerMask: number = 0x0FFFFFFF;
+
+        private _scene: Scene;
+
+        /**
+        * An event triggered when the system is disposed.
+        * @type {BABYLON.Observable}
+        */
+        public onDisposeObservable = new Observable<GPUParticleSystem>();
+
+
+        public isStarted(): boolean {
+            return false;
+        }        
+
+        constructor(public name: string, capacity: number, scene: Scene) {
+            this.id = name;
+            this._scene = scene || Engine.LastCreatedScene;
+
+            scene.particleSystems.push(this);
+        }
+
+        public animate(): void {
+
+        }
+
+        public render(): void {
+
+        }
+
+        public dispose(): void {
+            var index = this._scene.particleSystems.indexOf(this);
+            if (index > -1) {
+                this._scene.particleSystems.splice(index, 1);
+            }
+
+            // Callback
+            this.onDisposeObservable.notifyObservers(this);
+            this.onDisposeObservable.clear();
+        }
+
+        //TODO: Clone / Parse / serialize
+        public clone(name: string, newEmitter: any): GPUParticleSystem {
+            return null;
+        }
+
+        public serialize(): any {
+        }
+    }
+}

+ 30 - 10
src/Particles/babylon.particleSystem.ts

@@ -9,7 +9,21 @@
         return ((random * (max - min)) + min);
     }
 
-    export class ParticleSystem implements IDisposable, IAnimatable {
+    export interface IParticleSystem {
+        id: string;
+        name: string;
+        emitter: AbstractMesh | Vector3;        
+        renderingGroupId: number;
+        layerMask: number;
+        isStarted(): boolean;  
+        animate(): void;   
+        render();  
+        dispose(): void; 
+        clone(name: string, newEmitter: any): IParticleSystem;
+        serialize(): any;
+    }
+
+    export class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
         // Statics
         public static BLENDMODE_ONEONE = 0;
         public static BLENDMODE_STANDARD = 1;
@@ -19,7 +33,7 @@
 
         public id: string;
         public renderingGroupId = 0;
-        public emitter = null;
+        public emitter: AbstractMesh | Vector3 = null;
         public emitRate = 10;
         public manualEmitCount = -1;
         public updateSpeed = 0.01;
@@ -239,10 +253,12 @@
             // Add new ones
             var worldMatrix;
 
-            if (this.emitter.position) {
-                worldMatrix = this.emitter.getWorldMatrix();
+            if ((<AbstractMesh>this.emitter).position) {
+                var emitterMesh = (<AbstractMesh>this.emitter);
+                worldMatrix = emitterMesh.getWorldMatrix();
             } else {
-                worldMatrix = Matrix.Translation(this.emitter.x, this.emitter.y, this.emitter.z);
+                var emitterPosition = (<Vector3>this.emitter);
+                worldMatrix = Matrix.Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
             }
             var particle: Particle;
             for (var index = 0; index < newParticles; index++) {
@@ -441,7 +457,9 @@
 
             // Remove from scene
             var index = this._scene.particleSystems.indexOf(this);
-            this._scene.particleSystems.splice(index, 1);
+            if (index > -1) {
+                this._scene.particleSystems.splice(index, 1);
+            }
 
             // Callback
             this.onDisposeObservable.notifyObservers(this);
@@ -485,11 +503,13 @@
             serializationObject.id = this.id;
 
             // Emitter
-            if (this.emitter.position) {
-                serializationObject.emitterId = this.emitter.id;
+            if ((<AbstractMesh>this.emitter).position) {
+                var emitterMesh = (<AbstractMesh>this.emitter);
+                serializationObject.emitterId = emitterMesh.id;
             } else {
-                serializationObject.emitter = this.emitter.asArray();
-            }
+                var emitterPosition = (<Vector3>this.emitter);
+                serializationObject.emitter = emitterPosition.asArray();
+            }       
 
             serializationObject.capacity = this.getCapacity();
 

+ 5 - 3
src/Rendering/babylon.renderingGroup.ts

@@ -4,7 +4,7 @@
         private _opaqueSubMeshes = new SmartArray<SubMesh>(256);
         private _transparentSubMeshes = new SmartArray<SubMesh>(256);
         private _alphaTestSubMeshes = new SmartArray<SubMesh>(256);
-        private _particleSystems = new SmartArray<ParticleSystem>(256);
+        private _particleSystems = new SmartArray<IParticleSystem>(256);
         private _spriteManagers = new SmartArray<SpriteManager>(256);        
         private _activeVertices: number;
 
@@ -301,7 +301,7 @@
             this._spriteManagers.push(spriteManager);
         }
 
-        public dispatchParticles(particleSystem: ParticleSystem) {
+        public dispatchParticles(particleSystem: IParticleSystem) {
             this._particleSystems.push(particleSystem);
         }
 
@@ -319,7 +319,9 @@
                 if ((activeCamera.layerMask & particleSystem.layerMask) === 0) {
                     continue;
                 }
-                if (!particleSystem.emitter.position || !activeMeshes || activeMeshes.indexOf(particleSystem.emitter) !== -1) {
+
+                let emitter: any = particleSystem.emitter;
+                if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
                     this._scene._activeParticles.addCount(particleSystem.render(), false);
                 }
             }

+ 1 - 1
src/Rendering/babylon.renderingManager.ts

@@ -163,7 +163,7 @@
             this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
         }
 
-        public dispatchParticles(particleSystem: ParticleSystem) {
+        public dispatchParticles(particleSystem: IParticleSystem) {
             var renderingGroupId = particleSystem.renderingGroupId || 0;
 
             this._prepareRenderingGroup(renderingGroupId);

+ 7 - 6
src/babylon.scene.ts

@@ -595,7 +595,7 @@
 
         // Particles
         public particlesEnabled = true;
-        public particleSystems = new Array<ParticleSystem>();
+        public particleSystems = new Array<IParticleSystem>();
 
         // Sprites
         public spritesEnabled = true;
@@ -728,7 +728,7 @@
         private _activeMeshes = new SmartArray<Mesh>(256);
         private _processedMaterials = new SmartArray<Material>(256);
         private _renderTargets = new SmartArray<RenderTargetTexture>(256);
-        public _activeParticleSystems = new SmartArray<ParticleSystem>(256);
+        public _activeParticleSystems = new SmartArray<IParticleSystem>(256);
         private _activeSkeletons = new SmartArray<Skeleton>(32);
         private _softwareSkinnedMeshes = new SmartArray<Mesh>(32);
 
@@ -2117,9 +2117,9 @@
         /**
          * get a particle system by id
          * @param id {number} the particle system id
-         * @return {BABYLON.ParticleSystem|null} the corresponding system or null if none found.
+         * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
          */
-        public getParticleSystemByID(id: string): ParticleSystem {
+        public getParticleSystemByID(id: string): IParticleSystem {
             for (var index = 0; index < this.particleSystems.length; index++) {
                 if (this.particleSystems[index].id === id) {
                     return this.particleSystems[index];
@@ -2569,11 +2569,12 @@
                 for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
                     var particleSystem = this.particleSystems[particleIndex];
 
-                    if (!particleSystem.isStarted()) {
+                    if (!particleSystem.isStarted() || !particleSystem.emitter) {
                         continue;
                     }
 
-                    if (!particleSystem.emitter.position || (particleSystem.emitter && particleSystem.emitter.isEnabled())) {
+                    let emitter = <any>particleSystem.emitter;
+                    if (!emitter.position || emitter.isEnabled()) {
                         this._activeParticleSystems.push(particleSystem);
                         particleSystem.animate();
                         this._renderingManager.dispatchParticles(particleSystem);