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 | 1368x 1368x 1368x 1368x 1368x 1368x 1368x 1368x 1368x 1x 2x 24x 2x 1x 1x 1343x 1343x 17x 17x 17x 17x 17x 17x 17x 17x 17x 5x 5x 17x 9x 17x 8x 17x 8x 17x 17x 17x 17x 1x 17x 17x 17x 17x 17x 1x 8x 1x 1x 1x 1343x 1343x | import BoundingRectangle from "../Core/BoundingRectangle.js";
import Color from "../Core/Color.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import ClearCommand from "../Renderer/ClearCommand.js";
import FramebufferManager from "../Renderer/FramebufferManager.js";
import PixelDatatype from "../Renderer/PixelDatatype.js";
import RenderState from "../Renderer/RenderState.js";
import PassThroughDepth from "../Shaders/PostProcessStages/PassThroughDepth.js";
/**
* @private
*/
function GlobeTranslucencyFramebuffer() {
this._framebuffer = new FramebufferManager({
depthStencil: true,
supportsDepthTexture: true,
});
this._packedDepthFramebuffer = new FramebufferManager();
this._renderState = undefined;
this._packedDepthCommand = undefined;
this._clearCommand = undefined;
this._viewport = new BoundingRectangle();
this._useScissorTest = false;
this._scissorRectangle = undefined;
this._useHdr = undefined;
}
Object.defineProperties(GlobeTranslucencyFramebuffer.prototype, {
// Exposed for testing
classificationTexture: {
get: function () {
return this._framebuffer.getColorTexture();
},
},
classificationFramebuffer: {
get: function () {
return this._framebuffer.framebuffer;
},
},
// Exposed for testing
packedDepthFramebuffer: {
get: function () {
return this._packedDepthFramebuffer.framebuffer;
},
},
depthStencilTexture: {
get: function () {
return this._framebuffer.getDepthStencilTexture();
},
},
// Exposed for testing
depthStencilRenderbuffer: {
get: function () {
return this._framebuffer.getDepthStencilRenderbuffer();
},
},
packedDepthTexture: {
get: function () {
return this._packedDepthFramebuffer.getColorTexture();
},
},
});
function destroyResources(globeTranslucency) {
globeTranslucency._framebuffer.destroy();
globeTranslucency._packedDepthFramebuffer.destroy();
}
function updateResources(globeTranslucency, context, width, height, hdr) {
const pixelDatatype = hdr
? context.halfFloatingPointTexture
? PixelDatatype.HALF_FLOAT
: PixelDatatype.FLOAT
: PixelDatatype.UNSIGNED_BYTE;
globeTranslucency._framebuffer.update(
context,
width,
height,
1,
pixelDatatype,
);
globeTranslucency._packedDepthFramebuffer.update(context, width, height);
}
function updateCommands(globeTranslucency, context, width, height, passState) {
globeTranslucency._viewport.width = width;
globeTranslucency._viewport.height = height;
const useScissorTest = !BoundingRectangle.equals(
globeTranslucency._viewport,
passState.viewport,
);
let updateScissor = useScissorTest !== globeTranslucency._useScissorTest;
globeTranslucency._useScissorTest = useScissorTest;
if (
!BoundingRectangle.equals(
globeTranslucency._scissorRectangle,
passState.viewport,
)
) {
globeTranslucency._scissorRectangle = BoundingRectangle.clone(
passState.viewport,
globeTranslucency._scissorRectangle,
);
updateScissor = true;
}
if (
!defined(globeTranslucency._renderState) ||
!BoundingRectangle.equals(
globeTranslucency._viewport,
globeTranslucency._renderState.viewport,
) ||
updateScissor
) {
globeTranslucency._renderState = RenderState.fromCache({
viewport: globeTranslucency._viewport,
scissorTest: {
enabled: globeTranslucency._useScissorTest,
rectangle: globeTranslucency._scissorRectangle,
},
});
}
if (!defined(globeTranslucency._packedDepthCommand)) {
globeTranslucency._packedDepthCommand = context.createViewportQuadCommand(
PassThroughDepth,
{
uniformMap: {
u_depthTexture: function () {
return globeTranslucency.depthStencilTexture;
},
},
owner: globeTranslucency,
},
);
}
if (!defined(globeTranslucency._clearCommand)) {
globeTranslucency._clearCommand = new ClearCommand({
color: new Color(0.0, 0.0, 0.0, 0.0),
depth: 1.0,
stencil: 0.0,
owner: globeTranslucency,
});
}
globeTranslucency._packedDepthCommand.framebuffer =
globeTranslucency._packedDepthFramebuffer.framebuffer;
globeTranslucency._packedDepthCommand.renderState =
globeTranslucency._renderState;
globeTranslucency._clearCommand.framebuffer =
globeTranslucency.classificationFramebuffer;
globeTranslucency._clearCommand.renderState = globeTranslucency._renderState;
}
GlobeTranslucencyFramebuffer.prototype.updateAndClear = function (
hdr,
viewport,
context,
passState,
) {
const width = viewport.width;
const height = viewport.height;
updateResources(this, context, width, height, hdr);
updateCommands(this, context, width, height, passState);
this._useHdr = hdr;
};
GlobeTranslucencyFramebuffer.prototype.clearClassification = function (
context,
passState,
) {
this._clearCommand.execute(context, passState);
};
GlobeTranslucencyFramebuffer.prototype.packDepth = function (
context,
passState,
) {
this._packedDepthCommand.execute(context, passState);
return this.packedDepthTexture;
};
GlobeTranslucencyFramebuffer.prototype.isDestroyed = function () {
return false;
};
GlobeTranslucencyFramebuffer.prototype.destroy = function () {
destroyResources(this);
return destroyObject(this);
};
export default GlobeTranslucencyFramebuffer;
|