Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | 1375x 1375x 1375x 1375x 1375x 1375x 1375x 1375x 1x 6x 5x 1x 1x 12x 12x 12x 12x 10x 10x 10x 10x 10x 10x 10x 1x 1x 1x 1x 1x 1x 1x 3x 1x 1352x 1352x 1352x | import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import PixelFormat from "../Core/PixelFormat.js";
import Color from "../Core/Color.js";
import PixelDatatype from "../Renderer/PixelDatatype.js";
import FramebufferManager from "../Renderer/FramebufferManager.js";
import ClearCommand from "../Renderer/ClearCommand.js";
/**
* Creates and manages framebuffers for edge visibility rendering.
*
* @param {Object} options Object with the following properties:
*
* @alias EdgeFramebuffer
* @constructor
*
* @private
*/
function EdgeFramebuffer(options) {
options = options || {};
// Create framebuffer manager with multiple render targets (MRT)
// Color attachment 0: edge color output (visualization / debug)
// Color attachment 1: R: edge type, G: featureId (metadata / ids)
// Color attachment 2: packed depth (czm_packDepth) for edge fragments
this._framebufferManager = new FramebufferManager({
colorAttachmentsLength: 3, // MRT: Color + ID + Depth (packed RGBA)
createColorAttachments: true,
depthStencil: true,
supportsDepthTexture: true,
color: true,
});
this._framebuffer = undefined;
this._colorTexture = undefined;
this._idTexture = undefined;
this._depthTexture = undefined; // packed depth color attachment (location = 2)
this._depthStencilTexture = undefined;
this._clearCommand = new ClearCommand({
color: new Color(0.0, 0.0, 0.0, 0.0),
depth: 1.0,
stencil: 0,
owner: this,
});
}
Object.defineProperties(EdgeFramebuffer.prototype, {
/**
* Gets the framebuffer for edge rendering.
* @memberof EdgeFramebuffer.prototype
* @type {Framebuffer}
* @readonly
*/
framebuffer: {
get: function () {
return this._framebuffer;
},
},
/**
* Gets the color texture.
* @memberof EdgeFramebuffer.prototype
* @type {Texture}
* @readonly
*/
colorTexture: {
get: function () {
return this._colorTexture;
},
},
/**
* Gets the ID texture.
* @memberof EdgeFramebuffer.prototype
* @type {Texture}
* @readonly
*/
idTexture: {
get: function () {
return this._idTexture;
},
},
/**
* Gets the packed depth texture written during the edge pass.
* @memberof EdgeFramebuffer.prototype
* @type {Texture}
* @readonly
*/
depthTexture: {
get: function () {
return this._depthTexture;
},
},
/**
* Gets the depth-stencil texture.
* @memberof EdgeFramebuffer.prototype
* @type {Texture}
* @readonly
*/
depthStencilTexture: {
get: function () {
return this._depthStencilTexture;
},
},
});
/**
* Updates the framebuffer.
*
* @param {Context} context The context.
* @param {Viewport} viewport The viewport.
* @param {boolean} hdr Whether HDR is enabled.
* @param {Texture} [existingColorTexture] Optional existing color texture to reuse.
* @param {Texture} [existingDepthTexture] Optional existing depth texture to reuse.
*
* @returns {boolean} True if the framebuffer was updated; otherwise, false.
*/
EdgeFramebuffer.prototype.update = function (
context,
viewport,
hdr,
existingColorTexture,
existingDepthTexture,
) {
const width = viewport.width;
const height = viewport.height;
const pixelDatatype = hdr
? context.halfFloatingPointTexture
? PixelDatatype.HALF_FLOAT
: PixelDatatype.FLOAT
: PixelDatatype.UNSIGNED_BYTE;
const changed = this._framebufferManager.update(
context,
width,
height,
1, // No MSAA
pixelDatatype,
PixelFormat.RGBA,
);
// Always assign framebuffer if FramebufferManager has one
Eif (this._framebufferManager.framebuffer) {
this._framebuffer = this._framebufferManager.framebuffer;
// Get the textures from the framebuffer manager or use existing ones
this._colorTexture = defined(existingColorTexture)
? existingColorTexture
: this._framebufferManager.getColorTexture(0); // Color attachment 0
this._idTexture = this._framebufferManager.getColorTexture(1); // Color attachment 1: ID texture
this._depthTexture = this._framebufferManager.getColorTexture(2); // Color attachment 2: packed depth
this._depthStencilTexture = defined(existingDepthTexture)
? existingDepthTexture
: this._framebufferManager.getDepthStencilTexture();
}
return changed;
};
/**
* Clears the framebuffer using ClearCommand.
* @deprecated Use getClearCommand() instead for proper MRT clearing.
*
* @param {Context} context The context.
* @param {PassState} passState The pass state.
* @param {Color} clearColor The clear color.
*/
EdgeFramebuffer.prototype.clear = function (context, passState, clearColor) {
const clearCommand = this.getClearCommand(clearColor);
clearCommand.execute(context, passState);
};
/**
* Gets the clear command for this framebuffer.
*
* @param {Color} [clearColor] The clear color to use. If undefined, uses the default.
* @returns {ClearCommand} The clear command.
*/
EdgeFramebuffer.prototype.getClearCommand = function (clearColor) {
this._clearCommand.framebuffer = this._framebuffer;
Iif (defined(clearColor)) {
Color.clone(clearColor, this._clearCommand.color);
}
return this._clearCommand;
};
/**
* Gets the edge framebuffer, creating it if necessary.
*
* @param {Context} context The context.
* @param {Viewport} viewport The viewport.
* @param {Texture} [existingColorTexture] Optional existing color texture to reuse.
* @param {Texture} [existingDepthTexture] Optional existing depth texture to reuse.
*
* @returns {Framebuffer} The edge framebuffer.
*/
EdgeFramebuffer.prototype.getFramebuffer = function (
context,
viewport,
existingColorTexture,
existingDepthTexture,
) {
this.update(
context,
viewport,
false,
existingColorTexture,
existingDepthTexture,
);
return this._framebuffer;
};
/**
* Returns true if this object was destroyed; otherwise, false.
*
* @returns {boolean} True if this object was destroyed; otherwise, false.
*/
EdgeFramebuffer.prototype.isDestroyed = function () {
return false;
};
/**
* Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
* release of WebGL resources, instead of relying on the garbage collector to destroy this object.
* <br /><br />
* Once an object is destroyed, it should not be used; calling any function other than
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
* assign the return value (<code>undefined</code>) to the object as done in the example.
*
* @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
*/
EdgeFramebuffer.prototype.destroy = function () {
this._framebufferManager =
this._framebufferManager && this._framebufferManager.destroy();
this._clearCommand = undefined;
return destroyObject(this);
};
export default EdgeFramebuffer;
|