浏览代码

Fixing RawTexture

David Catuhe 10 年之前
父节点
当前提交
c516793fda

+ 4 - 0
Babylon/Debug/babylon.debugLayer.js

@@ -168,6 +168,10 @@
             };
         }
         DebugLayer.prototype._refreshMeshesTreeContent = function () {
+            while (this._treeSubsetDiv.hasChildNodes()) {
+                this._treeSubsetDiv.removeChild(this._treeSubsetDiv.lastChild);
+            }
+
             // Add meshes
             var sortedArray = this._scene.meshes.slice(0, this._scene.meshes.length);
 

文件差异内容过多而无法显示
+ 1 - 1
Babylon/Debug/babylon.debugLayer.js.map


+ 4 - 0
Babylon/Debug/babylon.debugLayer.ts

@@ -200,6 +200,10 @@
         }
 
         private _refreshMeshesTreeContent(): void {
+            while (this._treeSubsetDiv.hasChildNodes()) {
+                this._treeSubsetDiv.removeChild(this._treeSubsetDiv.lastChild);
+            }
+
             // Add meshes
             var sortedArray = this._scene.meshes.slice(0, this._scene.meshes.length);
 

+ 3 - 0
Babylon/Materials/Textures/babylon.rawTexture.js

@@ -15,6 +15,9 @@ var BABYLON;
             _super.call(this, null, scene, !generateMipMaps, invertY);
 
             this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode);
+
+            this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
         }
         // Statics
         RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {

+ 3 - 0
Babylon/Materials/Textures/babylon.rawTexture.ts

@@ -4,6 +4,9 @@
             super(null, scene, !generateMipMaps, invertY);
 
             this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode);
+
+            this.wrapU = Texture.CLAMP_ADDRESSMODE;
+            this.wrapV = Texture.CLAMP_ADDRESSMODE;
         }
 
         // Statics

+ 4 - 1
Babylon/Mesh/babylon.subMesh.js

@@ -114,7 +114,10 @@
                 var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
 
                 if (currentIntersectInfo) {
-                    if(currentIntersectInfo.distance < 0 ) continue;
+                    if (currentIntersectInfo.distance < 0) {
+                        continue;
+                    }
+
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
                         intersectInfo.faceId = index / 3;

+ 5 - 2
Babylon/Mesh/babylon.subMesh.ts

@@ -125,7 +125,10 @@
                 var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
 
                 if (currentIntersectInfo) {
-                    if(currentIntersectInfo.distance < 0 ) continue;
+                    if (currentIntersectInfo.distance < 0) {
+                        continue;
+                    }
+
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
                         intersectInfo.faceId = index / 3;
@@ -181,4 +184,4 @@
             return new BABYLON.SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
         }
     }
-}
+}

+ 0 - 5
Babylon/babylon.engine.js

@@ -1431,11 +1431,6 @@
         };
 
         Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode) {
-            if (width !== BABYLON.Tools.GetExponantOfTwo(width, this._caps.maxTextureSize) || height !== BABYLON.Tools.GetExponantOfTwo(height, this._caps.maxTextureSize)) {
-                BABYLON.Tools.Error("Unable to create a BABYLON.RawTexture with specified resolution. You must define power of 2 size.");
-                return null;
-            }
-
             var texture = this._gl.createTexture();
             this._gl.bindTexture(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));

+ 6 - 11
Babylon/babylon.engine.ts

@@ -321,7 +321,7 @@
     var cascadeLoad = (rootUrl: string, scene,
         onfinish: (images: HTMLImageElement[]) => void, extensions: string[]) => {
 
-        var loadedImages:any = [];
+        var loadedImages: any = [];
         loadedImages._internalCount = 0;
 
         for (var index = 0; index < 6; index++) {
@@ -806,7 +806,7 @@
         }
 
         public flushFramebuffer(): void {
-         //   this._gl.flush();
+            //   this._gl.flush();
         }
 
         public restoreDefaultFramebuffer(): void {
@@ -872,7 +872,7 @@
             var need32Bits = false;
 
             if (this._caps.uintIndices) {
-                
+
                 for (var index = 0; index < indices.length; index++) {
                     if (indices[index] > 65535) {
                         need32Bits = true;
@@ -939,7 +939,7 @@
                 }
             }
 
-            if (indexBuffer!= null && this._cachedIndexBuffer !== indexBuffer) {
+            if (indexBuffer != null && this._cachedIndexBuffer !== indexBuffer) {
                 this._cachedIndexBuffer = indexBuffer;
                 this._gl.bindBuffer(this._gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
                 this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
@@ -1380,7 +1380,7 @@
                     callback(buffer);
 
             } else if (isDDS) {
-                 callback = (data) => {
+                callback = (data) => {
                     var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) == 1);
@@ -1430,12 +1430,7 @@
             return texture;
         }
 
-        public createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY:boolean, samplingMode: number): WebGLTexture {
-
-            if (width !== Tools.GetExponantOfTwo(width, this._caps.maxTextureSize) || height !== Tools.GetExponantOfTwo(height, this._caps.maxTextureSize)) {
-                Tools.Error("Unable to create a BABYLON.RawTexture with specified resolution. You must define power of 2 size.");
-                return null;
-            }
+        public createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number): WebGLTexture {
 
             var texture = this._gl.createTexture();
             this._gl.bindTexture(this._gl.TEXTURE_2D, texture);

+ 11 - 5
babylon.2.0-alpha.debug.js

@@ -4794,11 +4794,6 @@ var BABYLON;
         };
 
         Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode) {
-            if (width !== BABYLON.Tools.GetExponantOfTwo(width, this._caps.maxTextureSize) || height !== BABYLON.Tools.GetExponantOfTwo(height, this._caps.maxTextureSize)) {
-                BABYLON.Tools.Error("Unable to create a BABYLON.RawTexture with specified resolution. You must define power of 2 size.");
-                return null;
-            }
-
             var texture = this._gl.createTexture();
             this._gl.bindTexture(this._gl.TEXTURE_2D, texture);
             this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, invertY === undefined ? 1 : (invertY ? 1 : 0));
@@ -12566,6 +12561,10 @@ var BABYLON;
                 var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
 
                 if (currentIntersectInfo) {
+                    if (currentIntersectInfo.distance < 0) {
+                        continue;
+                    }
+
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
                         intersectInfo.faceId = index / 3;
@@ -29614,6 +29613,10 @@ var BABYLON;
             };
         }
         DebugLayer.prototype._refreshMeshesTreeContent = function () {
+            while (this._treeSubsetDiv.hasChildNodes()) {
+                this._treeSubsetDiv.removeChild(this._treeSubsetDiv.lastChild);
+            }
+
             // Add meshes
             var sortedArray = this._scene.meshes.slice(0, this._scene.meshes.length);
 
@@ -30120,6 +30123,9 @@ var BABYLON;
             _super.call(this, null, scene, !generateMipMaps, invertY);
 
             this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode);
+
+            this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
+            this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
         }
         // Statics
         RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {

文件差异内容过多而无法显示
+ 10 - 10
babylon.2.0-alpha.js