ソースを参照

Support for non-squared DDS
Scene.MinDeltaTime / Scene.MaxDeltaTime

David Catuhe 11 年 前
コミット
5fd1574f3d

+ 8 - 1
Babylon/Tools/babylon.tools.dds.js

@@ -182,7 +182,11 @@
                                 gl.texImage2D(sampler, i, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                             }
                         } else if (info.isLuminance) {
-                            dataLength = width * height;
+                            var unpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
+                            var unpaddedRowSize = width;
+                            var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
+                            dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
+
                             byteArray = DDSTools.GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
                             gl.texImage2D(sampler, i, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, byteArray);
                         } else {
@@ -193,6 +197,9 @@
                         dataOffset += dataLength;
                         width *= 0.5;
                         height *= 0.5;
+
+                        width = Math.max(1.0, width);
+                        height = Math.max(1.0, height);
                     }
                 }
             };

+ 8 - 1
Babylon/Tools/babylon.tools.dds.ts

@@ -218,7 +218,11 @@
                             gl.texImage2D(sampler, i, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, byteArray);
                         }
                     } else if (info.isLuminance) {
-                        dataLength = width * height;
+                        var unpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
+                        var unpaddedRowSize = width;
+                        var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
+                        dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
+
                         byteArray = DDSTools.GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
                         gl.texImage2D(sampler, i, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, byteArray);
                     } else {
@@ -229,6 +233,9 @@
                     dataOffset += dataLength;
                     width *= 0.5;
                     height *= 0.5;
+
+                    width = Math.max(1.0, width);
+                    height = Math.max(1.0, height);
                 }
             }
         }

+ 1 - 1
Babylon/babylon.engine.js

@@ -941,8 +941,8 @@
                     var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount - 1)) == 1);
-
                     prepareWebGLTexture(texture, _this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, function () {
+                        console.log("loading " + url);
                         BABYLON.Internals.DDSTools.UploadDDSLevels(_this._gl, _this.getCaps().s3tc, data, info, loadMipmap, 1);
                     }, samplingMode);
                 }, null, scene.database, true);

+ 1 - 1
Babylon/babylon.engine.ts

@@ -968,8 +968,8 @@
                     var info = BABYLON.Internals.DDSTools.GetDDSInfo(data);
 
                     var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && !noMipmap && ((info.width >> (info.mipmapCount -1)) == 1);
-
                     prepareWebGLTexture(texture, this._gl, scene, info.width, info.height, invertY, !loadMipmap, info.isFourCC, () => {
+                        console.log("loading " + url);
                         Internals.DDSTools.UploadDDSLevels(this._gl, this.getCaps().s3tc, data, info, loadMipmap, 1);
                     }, samplingMode);
                 }, null, scene.database, true);

+ 1 - 1
Babylon/babylon.scene.js

@@ -895,7 +895,7 @@
             }
 
             // Animations
-            var deltaTime = BABYLON.Tools.GetDeltaTime();
+            var deltaTime = Math.max(1.0, Math.min(BABYLON.Tools.GetDeltaTime(), 1000.0));
             this._animationRatio = deltaTime * (60.0 / 1000.0);
             this._animate();
 

+ 1 - 1
Babylon/babylon.scene.ts

@@ -962,7 +962,7 @@
             }
 
             // Animations
-            var deltaTime = BABYLON.Tools.GetDeltaTime();
+            var deltaTime = Math.max(1.0, Math.min(BABYLON.Tools.GetDeltaTime(), 1000.0));
             this._animationRatio = deltaTime * (60.0 / 1000.0);
             this._animate();
 

BIN
Exporters/3ds Max/Max2Babylon-0.7.3.zip


ファイルの差分が大きいため隠しています
+ 2 - 2
babylon.1.13-beta-debug.js


ファイルの差分が大きいため隠しています
+ 4 - 4
babylon.1.13-beta.js