(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports", "./constants.js", "three"], factory); } else if (typeof exports !== "undefined") { factory(exports, require("./constants.js"), require("three")); } else { var mod = { exports: {} }; factory(mod.exports, global.constants, global.three); global.WebGPUBackground = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _constants, _three) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.default = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } var _clearAlpha; var _clearColor = new _three.Color(); var WebGPUBackground = /*#__PURE__*/function () { function WebGPUBackground(renderer) { _classCallCheck(this, WebGPUBackground); this.renderer = renderer; this.forceClear = false; } _createClass(WebGPUBackground, [{ key: "clear", value: function clear() { this.forceClear = true; } }, { key: "update", value: function update(scene) { var renderer = this.renderer; var background = scene.isScene === true ? scene.background : null; var forceClear = this.forceClear; if (background === null) { // no background settings, use clear color configuration from the renderer _clearColor.copy(renderer._clearColor); _clearAlpha = renderer._clearAlpha; } else if (background.isColor === true) { // background is an opaque color _clearColor.copy(background); _clearAlpha = 1; forceClear = true; } else { console.error('THREE.WebGPURenderer: Unsupported background configuration.', background); } // configure render pass descriptor var renderPassDescriptor = renderer._renderPassDescriptor; var colorAttachment = renderPassDescriptor.colorAttachments[0]; var depthStencilAttachment = renderPassDescriptor.depthStencilAttachment; if (renderer.autoClear === true || forceClear === true) { if (renderer.autoClearColor === true) { colorAttachment.loadValue = { r: _clearColor.r, g: _clearColor.g, b: _clearColor.b, a: _clearAlpha }; } else { colorAttachment.loadValue = _constants.GPULoadOp.Load; } if (renderer.autoClearDepth === true) { depthStencilAttachment.depthLoadValue = renderer._clearDepth; } else { depthStencilAttachment.depthLoadValue = _constants.GPULoadOp.Load; } if (renderer.autoClearStencil === true) { depthStencilAttachment.stencilLoadValue = renderer._clearStencil; } else { depthStencilAttachment.stencilLoadValue = _constants.GPULoadOp.Load; } } else { colorAttachment.loadValue = _constants.GPULoadOp.Load; depthStencilAttachment.depthLoadValue = _constants.GPULoadOp.Load; depthStencilAttachment.stencilLoadValue = _constants.GPULoadOp.Load; } this.forceClear = false; } }]); return WebGPUBackground; }(); var _default = WebGPUBackground; _exports.default = _default; });