Closed EthanZhong closed 3 years ago
这个是官方的问题,不知道可否帮忙解决。测试THREE是解决了这个问题。看了点THREE 的源码,模范测试好像还是不行。
export function wrapperContext(canvas) { if (typeof canvas.getContext2 != 'function') { canvas.getContextOrigin = canvas.getContext; canvas.getContext2 = function(type = 'webgl', options = null) { type = 'webgl'; options = options || { alpha: true, depth: true, stencil: true, antialias: true, premultipliedAlpha: true, preserveDrawingBuffer: false, powerPreference: 'default', failIfMajorPerformanceCaveat: false, xrCompatible: true }; var gl = canvas.getContextOrigin(type, options); //gl.clearColor(0, 0, 0, 0); //gl.clear(gl.COLOR_BUFFER_BIT); return gl; } canvas.getContext = function(type, options) { var gl = canvas.getContext2(type, options); gl.fillRect = function() {} gl.fillStyle = ''; gl.drawImage = function() {} gl.getImageData = function() {} return gl; } } }
这个是官方的问题,不知道可否帮忙解决。测试THREE是解决了这个问题。看了点THREE 的源码,模范测试好像还是不行。
export function wrapperContext(canvas) { if (typeof canvas.getContext2 != 'function') { canvas.getContextOrigin = canvas.getContext; canvas.getContext2 = function(type = 'webgl', options = null) { type = 'webgl'; options = options || { alpha: true, depth: true, stencil: true, antialias: true, premultipliedAlpha: true, preserveDrawingBuffer: false, powerPreference: 'default', failIfMajorPerformanceCaveat: false, xrCompatible: true }; var gl = canvas.getContextOrigin(type, options); //gl.clearColor(0, 0, 0, 0); //gl.clear(gl.COLOR_BUFFER_BIT); return gl; } canvas.getContext = function(type, options) { var gl = canvas.getContext2(type, options); gl.fillRect = function() {} gl.fillStyle = ''; gl.drawImage = function() {} gl.getImageData = function() {} return gl; } } }