我在我的网页上使用THREE.js场景和图形对象。我知道,至少THREE.js利用WebGL。
我想利用现代化来检查当前浏览器与WebGL的兼容性,如果浏览器没有,则向用户提示一条消息。
当选择浏览器特性进行现代化测试时,我看到两个与我的目标相关的特性
WebGL :在浏览器中检测WebGL。
WebGl扩展:在WebGL中检测对OpenGL扩展的支持。如果支持true
扩展API,则将支持的扩展公开为子属性,例如:
因此,为了使THREE.js工作,我需要测试WebGL扩展WebGL和WebGL还是简单地只测试WebGL
发布于 2016-06-09 23:41:42
这取决于您是否使用需要扩展的特性。Three.js本身不需要任何扩展。某些事情,如阴影,可能运行更快,如果您的WEBGL_depth_texture
扩展。
如果你不知道你自己需要什么扩展,可以考虑插入一些代码来隐藏它们,看看你的应用程序是否还在运行。
示例:
// disable all extensions
WebGLRenderingContext.prototype.getExtension = function() {
return null;
}
WebGLRenderingContext.prototype.getSupportedExtensions = function() {
return [];
}
// now init three.js
如果您想要允许特定的扩展,您可以这样做
var allowedExtensions = [
"webgl_depth_texture",
"oes_texture_float",
];
WebGLRenderingContext.prototype.getExtension = function(origFn) {
return function(name) {
if (allowedExtensions.indexOf(name.ToLowerCase()) >= 0) {
return origFn.call(this, name);
}
return null;
};
}(WebGLRenderingContext.prototype.getExtension);
WebGLRenderingContext.prototype.getSupportedExtensions = function(origFn) {
return function() {
return origFn.call(this).filter(function(name) {
return allowedExtensions.indexOf(n) >= 0;
});
};
}(WebGLRenderingContext.prototype.getSupportedExtensions);
https://stackoverflow.com/questions/37734756
复制相似问题