MCPcopy
hub / github.com/visgl/deck.gl / render

Function render

modules/arcgis/src/commons.ts:154–250  ·  view source on GitHub ↗
(
  resources: RenderResources,
  viewport: {
    width: number;
    height: number;
    longitude: number;
    latitude: number;
    zoom: number;
    altitude?: number;
    pitch: number;
    bearing: number;
    views?: unknown;
    viewState?: unknown;
  }
)

Source from the content-addressed store, hash-verified

152}
153
154export function render(
155 resources: RenderResources,
156 viewport: {
157 width: number;
158 height: number;
159 longitude: number;
160 latitude: number;
161 zoom: number;
162 altitude?: number;
163 pitch: number;
164 bearing: number;
165 views?: unknown;
166 viewState?: unknown;
167 }
168) {
169 const {model, deck, fbo} = resources;
170 const device = model.device;
171 if (device instanceof WebGLDevice) {
172 // @ts-ignore device.getParametersWebGL should return `any` not `void`?
173 const rawScreenFbo: WebGLFramebuffer | null = device.getParametersWebGL(GL.FRAMEBUFFER_BINDING);
174 const {width, height, views, viewState, ...defaultViewState} = viewport;
175
176 /* global window */
177 const dpr = window.devicePixelRatio;
178 const pixelWidth = Math.round(width * dpr);
179 const pixelHeight = Math.round(height * dpr);
180
181 fbo.resize({width: pixelWidth, height: pixelHeight});
182
183 // luma's Framebuffer.resize() clones and destroys the color attachment texture when
184 // dimensions change, leaving the cached texture reference and the model sampler binding
185 // pointing at a destroyed GPU handle. Re-sync if the attachment was replaced.
186 const currentTexture =
187 (fbo.colorAttachments[0] as any).texture ?? (fbo.colorAttachments[0] as unknown as Texture);
188 if (currentTexture !== resources.texture) {
189 resources.texture = currentTexture;
190 (model as any).setBindings({deckglTexture: currentTexture});
191 }
192
193 // Pass CSS pixel dimensions — deck handles DPR internally. Passing physical
194 // pixels would double-apply DPR and project layer geometry off-screen.
195 // Without width/height, deck's viewport aspect diverges from ArcGIS's,
196 // causing the overlay to drift off the ground plane under tilt/rotation.
197 const deckProps: any = {
198 width,
199 height,
200 viewState: viewState || defaultViewState
201 };
202 if (views) {
203 deckProps.views = views;
204 }
205 deck.setProps(deckProps);
206 // redraw deck immediately into deckFbo
207 deck.redraw('arcgis');
208
209 // We overlay the texture on top of the map using the full-screen quad.
210 const {gl} = device;
211

Callers 15

renderFunction · 0.90
renderMethod · 0.90
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRemoveMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50
onRenderHTMLMethod · 0.50

Calls 6

blendFuncSeparateMethod · 0.80
resizeMethod · 0.65
setPropsMethod · 0.65
drawMethod · 0.65
redrawMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…