浏览代码

add collection

Vousk-prod 10 年之前
父节点
当前提交
1757ac2151
共有 3 个文件被更改,包括 62 次插入0 次删除
  1. 30 0
      Babylon/Tools/babylon.collection.js
  2. 31 0
      Babylon/Tools/babylon.collection.ts
  3. 1 0
      Tools/Gulp/gulpfile.js

+ 30 - 0
Babylon/Tools/babylon.collection.js

@@ -0,0 +1,30 @@
+var BABYLON;
+(function (BABYLON) {
+    var Collection = (function () {
+        function Collection() {
+            this.count = 0;
+            this.items = {};
+        }
+        Collection.prototype.add = function (key, item) {
+            if (this.items[key] != undefined) {
+                return undefined;
+            }
+            this.items[key] = item;
+            return ++this.count;
+        };
+        Collection.prototype.remove = function (key) {
+            if (this.items[key] == undefined) {
+                return undefined;
+            }
+            delete this.items[key];
+            return --this.count;
+        };
+        Collection.prototype.item = function (key) {
+            return this.items[key];
+        };
+        return Collection;
+    })();
+    BABYLON.Collection = Collection;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.collection.js.map

+ 31 - 0
Babylon/Tools/babylon.collection.ts

@@ -0,0 +1,31 @@
+module BABYLON {
+    export class Collection {
+        public count: number = 0;
+        public items: any;
+
+        constructor() {
+            this.items = {};
+        }
+
+        public add(key: string, item: any): number {        
+            if (this.items[key] != undefined) {
+                return undefined;
+            }
+            this.items[key] = item;
+            return ++this.count;
+        }
+     
+        public remove(key: string): number {
+            if (this.items[key] == undefined) {
+                return undefined;
+            }
+            delete this.items[key];
+            return --this.count;
+        }
+ 
+        public item(key: string): any {
+            return this.items[key];
+        }
+
+    }
+} 

+ 1 - 0
Tools/Gulp/gulpfile.js

@@ -61,6 +61,7 @@ gulp.task('scripts', ['shaders'] ,function() {
       '../../Babylon/Tools/babylon.tools.tga.js',
       '../../Babylon/Tools/babylon.tools.tga.js',
       '../../Babylon/Tools/babylon.tools.dds.js',
       '../../Babylon/Tools/babylon.tools.dds.js',
       '../../Babylon/Tools/babylon.smartArray.js',
       '../../Babylon/Tools/babylon.smartArray.js',
+      '../../Babylon/Tools/babylon.collection.js',
       '../../Babylon/Tools/babylon.tools.js',
       '../../Babylon/Tools/babylon.tools.js',
       '../../Babylon/babylon.engine.js',
       '../../Babylon/babylon.engine.js',
       '../../Babylon/babylon.node.js',
       '../../Babylon/babylon.node.js',