From cbef3c60493c8b4b07e7067cf2036196ad96e1db Mon Sep 17 00:00:00 2001 From: 1chandu Date: Wed, 17 Apr 2019 08:05:17 -0700 Subject: [PATCH] Website: demo fixes (#1069) --- examples/core/texture-3d/app.js | 4 +++- examples/core/transform/app.js | 3 +-- modules/webgl/src/classes/texture.js | 12 ++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/core/texture-3d/app.js b/examples/core/texture-3d/app.js index ce09602a22..d4a5131fa5 100644 --- a/examples/core/texture-3d/app.js +++ b/examples/core/texture-3d/app.js @@ -158,7 +158,9 @@ export default class AppAnimationLoop extends AnimationLoop { } onFinalize({gl, cloud}) { - cloud.delete(); + if (cloud) { + cloud.delete(); + } } isSupported() { diff --git a/examples/core/transform/app.js b/examples/core/transform/app.js index 25ebef872f..29ec7df04c 100644 --- a/examples/core/transform/app.js +++ b/examples/core/transform/app.js @@ -239,8 +239,7 @@ export default class AppAnimationLoop extends AnimationLoop { colorBuffer, offsetBuffer, renderModel, - transform, - isDemoSupported + transform }; } /* eslint-enable max-statements */ diff --git a/modules/webgl/src/classes/texture.js b/modules/webgl/src/classes/texture.js index 349a7218f6..6ad602e789 100644 --- a/modules/webgl/src/classes/texture.js +++ b/modules/webgl/src/classes/texture.js @@ -147,7 +147,7 @@ export default class Texture extends Resource { }; const glSettings = Object.assign({}, DEFAULT_TEXTURE_SETTINGS, pixelStore); - if (this._isNPOT() && mipmaps) { + if (mipmaps && this._isNPOT()) { log.warn(`texture: ${this} is Non-Power-Of-Two, disabling mipmaping`)(); mipmaps = false; @@ -696,7 +696,15 @@ export default class Texture extends Resource { } _isNPOT() { - return !isWebGL2(this.gl) && (!isPowerOfTwo(this.width) || !isPowerOfTwo(this.height)); + if (isWebGL2(this.gl)) { + // NPOT restriction is only for WebGL1 + return false; + } + // Width and height not available, consider it is not NPOT texture + if (!this.width || !this.height) { + return false; + } + return !isPowerOfTwo(this.width) || !isPowerOfTwo(this.height); } // Update default settings which are not supported by NPOT textures.