UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

26 lines (25 loc) 770 B
"use strict"; export class ViewerWebGLController { constructor(viewer) { this.viewer = viewer; } init() { const canvas = this.viewer.canvas(); if (canvas) { canvas.onwebglcontextlost = this._on_webglcontextlost.bind(this); canvas.onwebglcontextrestored = this._on_webglcontextrestored.bind(this); } } _on_webglcontextlost() { console.warn("context lost at frame", this.viewer.scene().frame()); if (this.request_animation_frame_id) { cancelAnimationFrame(this.request_animation_frame_id); } else { console.warn("request_animation_frame_id not initialized"); } console.warn("not canceled", this.request_animation_frame_id); } _on_webglcontextrestored() { console.log("context restored"); } }