MCPcopy
hub / github.com/shuding/cobe / update

Function update

src/index.js:370–602  ·  view source on GitHub ↗

* Update state and trigger a re-render * @param {Object} state - State updates to apply

(state)

Source from the content-addressed store, hash-verified

368 * @param {Object} state - State updates to apply
369 */
370 function update(state) {
371 // Update state from provided values
372 if (state.phi != UNDEFINED) phi = state.phi
373 if (state.theta != UNDEFINED) theta = state.theta
374 if (state.markers) updateMarkers(state.markers)
375 if (state.arcs) updateArcs(state.arcs)
376
377 if (state.width && state.height) {
378 canvas.width = state.width * dpr
379 canvas.height = state.height * dpr
380 }
381
382 // Update appearance options
383 if (state.mapSamples != UNDEFINED) mapSamples = state.mapSamples
384 if (state.mapBrightness != UNDEFINED) mapBrightness = state.mapBrightness
385 if (state.mapBaseBrightness != UNDEFINED)
386 mapBaseBrightness = state.mapBaseBrightness
387 if (state.baseColor != UNDEFINED) baseColor = state.baseColor
388 if (state.markerColor != UNDEFINED) markerColor = state.markerColor
389 if (state.glowColor != UNDEFINED) glowColor = state.glowColor
390 if (state.arcColor != UNDEFINED) arcColor = state.arcColor
391 if (state.arcWidth != UNDEFINED) arcWidth = state.arcWidth
392 if (state.arcHeight != UNDEFINED) arcHeight = state.arcHeight
393 if (state.diffuse != UNDEFINED) diffuse = state.diffuse
394 if (state.dark != UNDEFINED) dark = state.dark
395 if (state.opacity != UNDEFINED) opacity = state.opacity
396 if (state.offset != UNDEFINED) offsetOpt = state.offset
397 if (state.scale != UNDEFINED) scaleOpt = state.scale
398 if (state.markerElevation != UNDEFINED)
399 markerElevation = state.markerElevation
400
401 // Update anchor positions
402 anchorManager.m(markers, project)
403 anchorManager.a(arcs, projectArcMidpoint)
404 anchorManager.s()
405
406 // Set viewport
407 gl.viewport(0, 0, canvas.width, canvas.height)
408 gl.clearColor(0, 0, 0, 0)
409 gl.clear(gl.COLOR_BUFFER_BIT)
410
411 // Enable blending for transparency
412 gl.enable(gl.BLEND)
413 gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
414
415 // === Pass 1: Globe ===
416 gl.useProgram(globeProgram)
417
418 // Bind quad buffer
419 gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer)
420 gl.enableVertexAttribArray(globePositionAttrib)
421 gl.vertexAttribPointer(globePositionAttrib, 2, gl.FLOAT, false, 0, 0)
422 // Reset divisor to 0 for non-instanced draw (may have been set by previous frame's instanced draws)
423 if (webgl2) {
424 gl.vertexAttribDivisor(globePositionAttrib, 0)
425 } else if (instExt) {
426 instExt.vertexAttribDivisorANGLE(globePositionAttrib, 0)
427 }

Callers 1

index.jsFile · 0.85

Calls 4

updateMarkersFunction · 0.85
updateArcsFunction · 0.85
setupInstancedAttributeFunction · 0.85
drawInstancedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…