WebGLContextEvent
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
Giao diện WebGLContextEvent là một phần của WebGL API và là giao diện cho một sự kiện được tạo ra để phản hồi với sự thay đổi trạng thái của ngữ cảnh kết xuất WebGL.
Hàm khởi tạo
WebGLContextEvent()-
Tạo một đối tượng
WebGLContextEventmới.
Thuộc tính phiên bản
Giao diện này kế thừa các thuộc tính từ giao diện cha Event.
WebGLContextEvent.statusMessage-
Một thuộc tính chỉ đọc chứa thông tin bổ sung về sự kiện.
Phương thức phiên bản
Giao diện này không định nghĩa bất kỳ phương thức riêng nào, nhưng kế thừa các phương thức từ giao diện cha Event.
Ví dụ
Với sự trợ giúp của tiện ích mở rộng WEBGL_lose_context, bạn có thể mô phỏng các sự kiện webglcontextlost và webglcontextrestored:
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
canvas.addEventListener("webglcontextlost", (e) => {
console.log(e);
});
gl.getExtension("WEBGL_lose_context").loseContext();
// WebGLContextEvent event with type "webglcontextlost" is logged.
Thông số kỹ thuật
| Specification |
|---|
| WebGL Specification> # 5.15> |