Improve rendering context typing and speed
This commit is contained in:
parent
4629cfd469
commit
e53ca905af
1 changed files with 14 additions and 13 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import { Insights } from '../rendering/insights';
|
||||
|
||||
/** @internal */
|
||||
export type UniversalRenderingContext = WebGL2RenderingContext &
|
||||
WebGLRenderingContext & { isWebGL2: boolean };
|
||||
export type UniversalRenderingContext =
|
||||
| (WebGL2RenderingContext & { isWebGL2: true })
|
||||
| (WebGLRenderingContext & { isWebGL2: false });
|
||||
|
||||
/** @internal */
|
||||
export const getUniversalRenderingContext = (
|
||||
|
|
@ -43,14 +44,14 @@ export const getUniversalRenderingContext = (
|
|||
|
||||
const contextLostHandler = {
|
||||
get: function (target: UniversalRenderingContext, prop: string) {
|
||||
if (isDestroyed || target.isContextLost()) {
|
||||
isDestroyed = true;
|
||||
throw new Error('Context lost');
|
||||
}
|
||||
|
||||
const value = (target as any)[prop];
|
||||
|
||||
if (typeof value === 'function') {
|
||||
if (isDestroyed || target.isContextLost()) {
|
||||
isDestroyed = true;
|
||||
throw new Error('Context lost');
|
||||
}
|
||||
|
||||
return value.bind(target);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue