{ "version": 3, "sources": ["../src/index.ts", "../src/lib/init.ts", "../src/utils/log.ts", "../src/debug/loggers.ts", "../src/debug/index.ts", "../src/utils/json-loader.ts", "../src/shaderlib/index.ts", "../src/shaderlib/misc/layer-uniforms.ts", "../src/shaderlib/misc/geometry.ts", "../src/shaderlib/project/project.ts", "../src/lib/constants.ts", "../src/shaderlib/project/project.glsl.ts", "../src/shaderlib/project/viewport-uniforms.ts", "../src/utils/memoize.ts", "../src/shaderlib/project32/project32.ts", "../src/shaderlib/shadow/shadow.ts", "../src/shaderlib/picking/picking.ts", "../src/effects/lighting/ambient-light.ts", "../src/effects/lighting/directional-light.ts", "../src/effects/lighting/lighting-effect.ts", "../src/passes/pass.ts", "../src/passes/layers-pass.ts", "../src/passes/shadow-pass.ts", "../src/utils/typed-array-manager.ts", "../src/utils/math-utils.ts", "../src/viewports/viewport.ts", "../src/viewports/web-mercator-viewport.ts", "../src/shaderlib/project/project-functions.ts", "../src/effects/lighting/point-light.ts", "../src/effects/lighting/camera-light.ts", "../src/effects/lighting/sun-light.ts", "../src/effects/post-process-effect.ts", "../src/passes/screen-pass.ts", "../src/passes/screen-pass-uniforms.ts", "../src/passes/pick-layers-pass.ts", "../src/lib/layer-manager.ts", "../src/lifecycle/constants.ts", "../src/utils/flatten.ts", "../src/lib/resource/resource.ts", "../src/lib/resource/resource-manager.ts", "../src/utils/deep-equal.ts", "../src/lib/view-manager.ts", "../src/utils/positions.ts", "../src/views/view.ts", "../src/controllers/map-controller.ts", "../src/transitions/transition.ts", "../src/controllers/transition-manager.ts", "../src/transitions/transition-interpolator.ts", "../src/utils/assert.ts", "../src/transitions/linear-interpolator.ts", "../src/controllers/controller.ts", "../src/controllers/view-state.ts", "../src/views/map-view.ts", "../src/lib/effect-manager.ts", "../src/passes/draw-layers-pass.ts", "../src/lib/deck-renderer.ts", "../src/lib/picking/query-object.ts", "../src/lib/picking/pick-info.ts", "../src/lib/deck-picker.ts", "../src/lib/widget-manager.ts", "../src/lib/tooltip.ts", "../src/lib/deck.ts", "../src/lib/attribute/data-column.ts", "../src/lib/attribute/gl-utils.ts", "../src/utils/iterable-utils.ts", "../src/utils/range.ts", "../src/lib/attribute/transition-settings.ts", "../src/lib/attribute/attribute.ts", "../src/transitions/gpu-interpolation-transition.ts", "../src/utils/array-utils.ts", "../src/transitions/gpu-transition-utils.ts", "../src/transitions/gpu-transition.ts", "../src/transitions/gpu-spring-transition.ts", "../src/lib/attribute/attribute-transition-manager.ts", "../src/lib/attribute/attribute-manager.ts", "../src/lib/layer.ts", "../src/transitions/cpu-interpolation-transition.ts", "../src/transitions/cpu-spring-transition.ts", "../src/lib/uniform-transition-manager.ts", "../src/lifecycle/props.ts", "../src/utils/count.ts", "../src/utils/shader.ts", "../src/utils/texture.ts", "../src/lifecycle/prop-types.ts", "../src/lifecycle/create-props.ts", "../src/lifecycle/component.ts", "../src/lifecycle/component-state.ts", "../src/lib/layer-state.ts", "../src/lib/composite-layer.ts", "../src/viewports/globe-viewport.ts", "../src/viewports/orbit-viewport.ts", "../src/viewports/orthographic-viewport.ts", "../src/viewports/first-person-viewport.ts", "../src/controllers/first-person-controller.ts", "../src/views/first-person-view.ts", "../src/controllers/orbit-controller.ts", "../src/views/orbit-view.ts", "../src/controllers/orthographic-controller.ts", "../src/views/orthographic-view.ts", "../src/controllers/globe-controller.ts", "../src/views/globe-view.ts", "../src/lib/layer-extension.ts", "../src/transitions/fly-to-interpolator.ts", "../src/utils/tesselator.ts", "../src/utils/apply-styles.ts"], "sourcesContent": ["// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable max-len */\n\n// Intialize globals, extract version\nexport {VERSION} from './lib/init';\n\n// Import shaderlib to make sure shader modules are initialized\nexport {getShaderAssembler} from './shaderlib/index';\n\n// Core Library\nexport {COORDINATE_SYSTEM, OPERATION, UNIT} from './lib/constants';\n\n// Effects\nexport {default as LightingEffect} from './effects/lighting/lighting-effect';\nexport {AmbientLight} from './effects/lighting/ambient-light';\nexport {DirectionalLight} from './effects/lighting/directional-light';\nexport {PointLight} from './effects/lighting/point-light';\nexport {default as _CameraLight} from './effects/lighting/camera-light';\nexport {default as _SunLight} from './effects/lighting/sun-light';\nexport {default as PostProcessEffect} from './effects/post-process-effect';\n\n// Passes\nexport {default as _LayersPass} from './passes/layers-pass';\nexport {default as _PickLayersPass} from './passes/pick-layers-pass';\n\n// Experimental Pure JS (non-React) bindings\nexport {default as Deck} from './lib/deck';\n\nexport {default as LayerManager} from './lib/layer-manager';\nexport {default as Attribute} from './lib/attribute/attribute';\nexport {default as AttributeManager} from './lib/attribute/attribute-manager';\nexport {default as Layer} from './lib/layer';\nexport {default as CompositeLayer} from './lib/composite-layer';\nexport {default as DeckRenderer} from './lib/deck-renderer';\n\n// Viewports\nexport {default as Viewport} from './viewports/viewport';\nexport {default as WebMercatorViewport} from './viewports/web-mercator-viewport';\nexport {default as _GlobeViewport} from './viewports/globe-viewport';\nexport {default as OrbitViewport} from './viewports/orbit-viewport';\nexport {default as OrthographicViewport} from './viewports/orthographic-viewport';\nexport {default as FirstPersonViewport} from './viewports/first-person-viewport';\n\n// Shader modules\nexport {\n picking,\n project,\n project32,\n gouraudLighting,\n phongLighting,\n shadow\n} from './shaderlib/index';\n\nexport {default as View} from './views/view';\nexport {default as MapView} from './views/map-view';\nexport {default as FirstPersonView} from './views/first-person-view';\nexport {default as OrbitView} from './views/orbit-view';\nexport {default as OrthographicView} from './views/orthographic-view';\nexport {default as _GlobeView} from './views/globe-view';\n\n// Controllers\nexport {default as Controller} from './controllers/controller';\nexport {default as MapController} from './controllers/map-controller';\nexport {default as _GlobeController} from './controllers/globe-controller';\nexport {default as FirstPersonController} from './controllers/first-person-controller';\nexport {default as OrbitController} from './controllers/orbit-controller';\nexport {default as OrthographicController} from './controllers/orthographic-controller';\n\n// Extensions interface\nexport {default as LayerExtension} from './lib/layer-extension';\n\n// Transitions\nexport {TRANSITION_EVENTS} from './controllers/transition-manager';\nexport {default as TransitionInterpolator} from './transitions/transition-interpolator';\nexport {default as LinearInterpolator} from './transitions/linear-interpolator';\nexport {default as FlyToInterpolator} from './transitions/fly-to-interpolator';\n\n// Layer utilities\nexport {default as log} from './utils/log';\nexport {default as assert} from './utils/assert';\nexport {createIterable} from './utils/iterable-utils';\nexport {fp64LowPart} from './utils/math-utils';\nexport {default as Tesselator} from './utils/tesselator'; // Export? move to luma.gl or math.gl?\n\n// Experimental utilities\nexport {fillArray as _fillArray, flatten as _flatten} from './utils/flatten'; // Export? move to luma.gl or math.gl?\nexport {count as _count} from './utils/count';\nexport {deepEqual as _deepEqual} from './utils/deep-equal';\nexport {default as _memoize} from './utils/memoize';\nexport {mergeShaders as _mergeShaders} from './utils/shader';\nexport {compareProps as _compareProps} from './lifecycle/props';\nexport {applyStyles as _applyStyles, removeStyles as _removeStyles} from './utils/apply-styles';\n\n// Types\nexport type {CoordinateSystem} from './lib/constants';\nexport type {MapViewState, MapViewProps} from './views/map-view';\nexport type {FirstPersonViewState, FirstPersonViewProps} from './views/first-person-view';\nexport type {OrbitViewState, OrbitViewProps} from './views/orbit-view';\nexport type {OrthographicViewState, OrthographicViewProps} from './views/orthographic-view';\nexport type {GlobeViewState, GlobeViewProps} from './views/globe-view';\nexport type {ChangeFlags} from './lib/layer-state';\nexport type {LayersList, LayerContext} from './lib/layer-manager';\nexport type {ViewStateMap} from './lib/view-manager';\nexport type {UpdateParameters} from './lib/layer';\nexport type {DeckProps} from './lib/deck';\nexport type {\n LayerProps,\n CompositeLayerProps,\n Accessor,\n AccessorContext,\n AccessorFunction,\n LayerData,\n LayerDataSource,\n Unit,\n Operation,\n Position,\n Color,\n TextureSource,\n Material\n} from './types/layer-props';\nexport type {DrawLayerParameters, FilterContext} from './passes/layers-pass';\nexport type {PickingInfo, GetPickingInfoParams} from './lib/picking/pick-info';\nexport type {ConstructorOf as _ConstructorOf} from './types/types';\nexport type {BinaryAttribute} from './lib/attribute/attribute';\nexport type {Effect, EffectContext, PreRenderOptions, PostRenderOptions} from './lib/effect';\nexport type {PickingUniforms, ProjectProps, ProjectUniforms} from './shaderlib/index';\nexport type {DefaultProps} from './lifecycle/prop-types';\nexport type {LayersPassRenderOptions} from './passes/layers-pass';\nexport type {Widget, WidgetPlacement} from './lib/widget-manager';\nexport type {LightingEffectProps} from './effects/lighting/lighting-effect';\nexport type {AmbientLightOptions} from './effects/lighting/ambient-light';\nexport type {DirectionalLightOptions} from './effects/lighting/directional-light';\nexport type {PointLightOptions} from './effects/lighting/point-light';\nexport type {SunLightOptions} from './effects/lighting/sun-light';\nexport type {\n ControllerProps,\n ViewStateChangeParameters,\n InteractionState\n} from './controllers/controller';\n\n// INTERNAL, DO NOT USE\n// @deprecated internal do not use\nexport {default as _Component} from './lifecycle/component';\n// @deprecated internal do not use\nexport {default as _ComponentState} from './lifecycle/component-state';\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {registerLoaders} from '@loaders.gl/core';\nimport {ImageLoader} from '@loaders.gl/images';\n\nimport log from '../utils/log';\nimport {register} from '../debug/index';\nimport jsonLoader from '../utils/json-loader';\n\ndeclare global {\n const __VERSION__: string;\n}\n\nfunction checkVersion() {\n // Version detection using typescript plugin.\n // Fallback for tests and SSR since global variable is defined by esbuild.\n const version =\n typeof __VERSION__ !== 'undefined'\n ? __VERSION__\n : globalThis.DECK_VERSION || 'untranspiled source';\n\n // Note: a `deck` object not created by deck.gl may exist in the global scope\n const existingVersion = globalThis.deck && globalThis.deck.VERSION;\n\n if (existingVersion && existingVersion !== version) {\n throw new Error(`deck.gl - multiple versions detected: ${existingVersion} vs ${version}`);\n }\n\n if (!existingVersion) {\n log.log(1, `deck.gl ${version}`)();\n\n globalThis.deck = {\n ...globalThis.deck,\n VERSION: version,\n version,\n log,\n // experimental\n _registerLoggers: register\n };\n\n registerLoaders([\n jsonLoader,\n // @ts-expect-error non-standard Loader format\n [ImageLoader, {imagebitmap: {premultiplyAlpha: 'none'}}]\n ]);\n }\n\n return version;\n}\n\nexport const VERSION = checkVersion();\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Log} from '@probe.gl/log';\n\nconst defaultLogger: Log = new Log({id: 'deck'});\n\nexport default defaultLogger;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Log} from '@probe.gl/log';\n\nconst logState: {\n attributeUpdateStart: number;\n attributeManagerUpdateStart: number;\n attributeUpdateMessages: string[];\n} = {\n attributeUpdateStart: -1,\n attributeManagerUpdateStart: -1,\n attributeUpdateMessages: []\n};\n\nconst LOG_LEVEL_MAJOR_UPDATE = 1; // Events with direct perf impact\nconst LOG_LEVEL_MINOR_UPDATE = 2; // Events that may affect perf\nconst LOG_LEVEL_UPDATE_DETAIL = 3;\nconst LOG_LEVEL_INFO = 4;\nconst LOG_LEVEL_DRAW = 2;\n\nexport const getLoggers = (log: Log): Record => ({\n /* Layer events */\n\n 'layer.changeFlag': (layer, key, flags) => {\n log.log(LOG_LEVEL_UPDATE_DETAIL, `${layer.id} ${key}: `, flags[key])();\n },\n\n 'layer.initialize': layer => {\n log.log(LOG_LEVEL_MAJOR_UPDATE, `Initializing ${layer}`)();\n },\n 'layer.update': (layer, needsUpdate) => {\n if (needsUpdate) {\n const flags = layer.getChangeFlags();\n log.log(\n LOG_LEVEL_MINOR_UPDATE,\n `Updating ${layer} because: ${Object.keys(flags)\n .filter(key => flags[key])\n .join(', ')}`\n )();\n } else {\n log.log(LOG_LEVEL_INFO, `${layer} does not need update`)();\n }\n },\n 'layer.matched': (layer, changed) => {\n if (changed) {\n log.log(LOG_LEVEL_INFO, `Matched ${layer}, state transfered`)();\n }\n },\n 'layer.finalize': layer => {\n log.log(LOG_LEVEL_MAJOR_UPDATE, `Finalizing ${layer}`)();\n },\n\n /* CompositeLayer events */\n\n 'compositeLayer.renderLayers': (layer, updated, subLayers) => {\n if (updated) {\n log.log(\n LOG_LEVEL_MINOR_UPDATE,\n `Composite layer rendered new subLayers ${layer}`,\n subLayers\n )();\n } else {\n log.log(LOG_LEVEL_INFO, `Composite layer reused subLayers ${layer}`, subLayers)();\n }\n },\n\n /* LayerManager events */\n\n 'layerManager.setLayers': (layerManager, updated, layers) => {\n if (updated) {\n log.log(LOG_LEVEL_MINOR_UPDATE, `Updating ${layers.length} deck layers`)();\n }\n },\n\n 'layerManager.activateViewport': (layerManager, viewport) => {\n log.log(LOG_LEVEL_UPDATE_DETAIL, 'Viewport changed', viewport)();\n },\n\n /* AttributeManager events */\n\n 'attributeManager.invalidate': (attributeManager, trigger, attributeNames) => {\n log.log(\n LOG_LEVEL_MAJOR_UPDATE,\n attributeNames\n ? `invalidated attributes ${attributeNames} (${trigger}) for ${attributeManager.id}`\n : `invalidated all attributes for ${attributeManager.id}`\n )();\n },\n\n 'attributeManager.updateStart': attributeManager => {\n logState.attributeUpdateMessages.length = 0;\n logState.attributeManagerUpdateStart = Date.now();\n },\n 'attributeManager.updateEnd': (attributeManager, numInstances) => {\n const timeMs = Math.round(Date.now() - logState.attributeManagerUpdateStart);\n log.groupCollapsed(\n LOG_LEVEL_MINOR_UPDATE,\n `Updated attributes for ${numInstances} instances in ${attributeManager.id} in ${timeMs}ms`\n )();\n for (const updateMessage of logState.attributeUpdateMessages) {\n log.log(LOG_LEVEL_UPDATE_DETAIL, updateMessage)();\n }\n log.groupEnd(LOG_LEVEL_MINOR_UPDATE)();\n },\n\n /* Attribute events */\n\n 'attribute.updateStart': attribute => {\n logState.attributeUpdateStart = Date.now();\n },\n 'attribute.allocate': (attribute, numInstances) => {\n const message = `${attribute.id} allocated ${numInstances}`;\n logState.attributeUpdateMessages.push(message);\n },\n 'attribute.updateEnd': (attribute, numInstances) => {\n const timeMs = Math.round(Date.now() - logState.attributeUpdateStart);\n const message = `${attribute.id} updated ${numInstances} in ${timeMs}ms`;\n logState.attributeUpdateMessages.push(message);\n },\n\n /* Render events */\n\n 'deckRenderer.renderLayers': (deckRenderer, renderStats, opts) => {\n const {pass, redrawReason, stats} = opts;\n for (const status of renderStats) {\n const {totalCount, visibleCount, compositeCount, pickableCount} = status;\n const primitiveCount = totalCount - compositeCount;\n const hiddenCount = primitiveCount - visibleCount;\n\n log.log(\n LOG_LEVEL_DRAW,\n `RENDER #${deckRenderer.renderCount} \\\n ${visibleCount} (of ${totalCount} layers) to ${pass} because ${redrawReason} \\\n (${hiddenCount} hidden, ${compositeCount} composite ${pickableCount} pickable)`\n )();\n\n if (stats) {\n stats.get('Redraw Layers').add(visibleCount);\n }\n }\n }\n});\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport deckLog from '../utils/log';\nimport {getLoggers} from './loggers';\n\n/* debug utility */\n\nlet loggers: Record = {};\n\n// Conditionally load default loggers in development mode\n// eslint-disable-next-line\nif (process.env.NODE_ENV !== 'production') {\n loggers = getLoggers(deckLog);\n}\n\nexport function register(handlers: Record): void {\n loggers = handlers;\n}\n\nexport default function debug(eventType: string, arg1?: any, arg2?: any, arg3?: any): void {\n if (deckLog.level > 0 && loggers[eventType]) {\n // Not using rest parameters to defeat perf hit from array construction\n loggers[eventType].call(null, arg1, arg2, arg3);\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Loader} from '@loaders.gl/loader-utils';\n\nfunction isJSON(text: string): boolean {\n const firstChar = text[0];\n const lastChar = text[text.length - 1];\n return (firstChar === '{' && lastChar === '}') || (firstChar === '[' && lastChar === ']');\n}\n\n// A light weight version instead of @loaders.gl/json (stream processing etc.)\nexport default {\n dataType: null as any,\n batchType: null as never,\n id: 'JSON',\n name: 'JSON',\n module: '',\n version: '',\n options: {},\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json', 'application/geo+json'],\n testText: isJSON,\n parseTextSync: JSON.parse\n} as Loader;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {ShaderAssembler} from '@luma.gl/shadertools';\n\nimport {gouraudLighting, phongLighting} from '@luma.gl/shadertools';\nimport {layerUniforms} from './misc/layer-uniforms';\nimport geometry from './misc/geometry';\nimport project from './project/project';\nimport project32 from './project32/project32';\nimport shadow from './shadow/shadow';\nimport picking from './picking/picking';\n\nconst DEFAULT_MODULES = [geometry];\n\nconst SHADER_HOOKS = [\n 'vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)',\n 'vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)',\n 'vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)',\n 'fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)'\n];\n\nexport function getShaderAssembler() {\n const shaderAssembler = ShaderAssembler.getDefaultShaderAssembler();\n\n for (const shaderModule of DEFAULT_MODULES) {\n shaderAssembler.addDefaultModule(shaderModule);\n }\n for (const shaderHook of SHADER_HOOKS) {\n shaderAssembler.addShaderHook(shaderHook);\n }\n\n return shaderAssembler;\n}\n\nexport {layerUniforms, picking, project, project32, gouraudLighting, phongLighting, shadow};\n\n// Useful for custom shader modules\nexport type {ProjectProps, ProjectUniforms} from './project/viewport-uniforms';\n\n// TODO - these should be imported from luma.gl\n/* eslint-disable camelcase */\nexport type PickingUniforms = {\n picking_uActive: boolean;\n picking_uAttribute: boolean;\n picking_uSelectedColor: [number, number, number];\n picking_uSelectedColorValid: boolean;\n picking_uHighlightColor: [number, number, number, number];\n};\n\nexport type LightingModuleSettings = {\n material:\n | boolean\n | {\n ambient?: number;\n diffuse?: number;\n shininess?: number;\n specularColor?: [number, number, number];\n };\n};\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport type {LayerProps} from '../../types/layer-props';\n\nconst uniformBlock = `\\\nuniform layerUniforms {\n uniform float opacity;\n} layer;\n`;\n\nexport type LayerUniforms = {\n opacity?: number;\n};\n\nexport const layerUniforms = {\n name: 'layer',\n vs: uniformBlock,\n fs: uniformBlock,\n getUniforms: (props: Partial) => {\n return {\n // apply gamma to opacity to make it visually \"linear\"\n // TODO - v10: use raw opacity?\n opacity: Math.pow(props.opacity!, 1 / 2.2)\n };\n },\n uniformTypes: {\n opacity: 'f32'\n }\n} as const satisfies ShaderModule;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\nconst defines = '#define SMOOTH_EDGE_RADIUS 0.5';\nconst vs = `\n${defines}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`;\n\nconst fs = `\n${defines}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`;\n\nexport default {name: 'geometry', vs, fs} as const satisfies ShaderModule;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {fp32, ShaderModule} from '@luma.gl/shadertools';\nimport geometry from '../misc/geometry';\nimport projectShader from './project.glsl';\nimport {getUniformsFromViewport} from './viewport-uniforms';\n\nimport type {ProjectProps, ProjectUniforms} from './viewport-uniforms';\n\nconst INITIAL_MODULE_OPTIONS = {};\n\nfunction getUniforms(opts: ProjectProps | {} = INITIAL_MODULE_OPTIONS) {\n if ('viewport' in opts) {\n return getUniformsFromViewport(opts);\n }\n return {};\n}\n\nexport default {\n name: 'project',\n dependencies: [fp32, geometry],\n vs: projectShader,\n getUniforms,\n uniformTypes: {\n wrapLongitude: 'f32',\n coordinateSystem: 'i32',\n commonUnitsPerMeter: 'vec3',\n projectionMode: 'i32',\n scale: 'f32',\n commonUnitsPerWorldUnit: 'vec3',\n commonUnitsPerWorldUnit2: 'vec3',\n center: 'vec4',\n modelMatrix: 'mat4x4',\n viewProjectionMatrix: 'mat4x4',\n viewportSize: 'vec2',\n devicePixelRatio: 'f32',\n focalDistance: 'f32',\n cameraPosition: 'vec3',\n coordinateOrigin: 'vec3',\n commonOrigin: 'vec3',\n pseudoMeters: 'f32'\n }\n // @ts-ignore TODO v9.1\n} as const satisfies ShaderModule;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Note: The numeric values here are matched by shader code in the\n// \"project\" and \"project64\" shader modules. Both places need to be\n// updated.\nimport log from '../utils/log';\nimport {Pan, InputDirection, Pinch, Tap} from 'mjolnir.js';\nimport type {PanRecognizerOptions, PinchRecognizerOptions, TapRecognizerOptions} from 'mjolnir.js';\n\n/**\n * The coordinate system that positions/dimensions are defined in.\n */\nexport const COORDINATE_SYSTEM = {\n /**\n * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise\n */\n DEFAULT: -1,\n /**\n * Positions are interpreted as [longitude, latitude, elevation]\n * longitude/latitude are in degrees, elevation is in meters.\n * Dimensions are in meters.\n */\n LNGLAT: 1,\n\n /**\n * Positions are interpreted as [x, y, z] in meter offsets from the coordinate origin.\n * Dimensions are in meters.\n */\n METER_OFFSETS: 2,\n\n /**\n * Positions are interpreted as [deltaLng, deltaLat, elevation] from the coordinate origin.\n * deltaLng/deltaLat are in degrees, elevation is in meters.\n * Dimensions are in meters.\n */\n LNGLAT_OFFSETS: 3,\n\n /**\n * Positions and dimensions are in the common units of the viewport.\n */\n CARTESIAN: 0\n} as const;\n\n// Enums cannot be directly exported as they are not transpiled correctly into ES5, see https://github.com/visgl/deck.gl/issues/7130\nexport type CoordinateSystem = -1 | 0 | 1 | 2 | 3;\n\n// Deprecated\n/* eslint-disable accessor-pairs */\nObject.defineProperty(COORDINATE_SYSTEM, 'IDENTITY', {\n get: () => {\n log.deprecated('COORDINATE_SYSTEM.IDENTITY', 'COORDINATE_SYSTEM.CARTESIAN')();\n return 0;\n }\n});\n/* eslint-enable accessor-pairs */\n\n/**\n * How coordinates are transformed from the world space into the common space.\n */\nexport const PROJECTION_MODE = {\n /**\n * Render geospatial data in Web Mercator projection\n */\n WEB_MERCATOR: 1,\n /**\n * Render geospatial data as a 3D globe\n */\n GLOBE: 2,\n\n /**\n * (Internal use only) Web Mercator projection at high zoom\n */\n WEB_MERCATOR_AUTO_OFFSET: 4,\n\n /**\n * No transformation\n */\n IDENTITY: 0\n} as const;\n\nexport const UNIT = {\n common: 0,\n meters: 1,\n pixels: 2\n} as const;\n\nexport const EVENT_HANDLERS: {[eventName: string]: string} = {\n click: 'onClick',\n panstart: 'onDragStart',\n panmove: 'onDrag',\n panend: 'onDragEnd'\n} as const;\n\nexport const RECOGNIZERS = {\n multipan: [Pan, {threshold: 10, direction: InputDirection.Vertical, pointers: 2}],\n pinch: [Pinch, {}, null, ['multipan']],\n pan: [Pan, {threshold: 1}, ['pinch'], ['multipan']],\n dblclick: [Tap, {event: 'dblclick', taps: 2}],\n click: [Tap, {event: 'click'}, null, ['dblclick']]\n} as const;\nexport type RecognizerOptions = {\n pinch?: Omit;\n multipan?: Omit;\n pan?: Omit;\n dblclick?: Omit;\n click?: Omit;\n};\n\n/**\n * @deprecated Use string constants directly\n */\nexport const OPERATION = {\n DRAW: 'draw',\n MASK: 'mask',\n TERRAIN: 'terrain'\n} as const;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {COORDINATE_SYSTEM, PROJECTION_MODE, UNIT} from '../../lib/constants';\n\n// We are generating these from the js code in constants.js\nconst COORDINATE_SYSTEM_GLSL_CONSTANTS = Object.keys(COORDINATE_SYSTEM)\n .map(key => `const int COORDINATE_SYSTEM_${key} = ${COORDINATE_SYSTEM[key]};`)\n .join('');\nconst PROJECTION_MODE_GLSL_CONSTANTS = Object.keys(PROJECTION_MODE)\n .map(key => `const int PROJECTION_MODE_${key} = ${PROJECTION_MODE[key]};`)\n .join('');\nconst UNIT_GLSL_CONSTANTS = Object.keys(UNIT)\n .map(key => `const int UNIT_${key.toUpperCase()} = ${UNIT[key]};`)\n .join('');\n\nexport default `\\\n${COORDINATE_SYSTEM_GLSL_CONSTANTS}\n${PROJECTION_MODE_GLSL_CONSTANTS}\n${UNIT_GLSL_CONSTANTS}\n\nuniform projectUniforms {\n bool wrapLongitude;\n int coordinateSystem;\n vec3 commonUnitsPerMeter;\n int projectionMode;\n float scale;\n vec3 commonUnitsPerWorldUnit;\n vec3 commonUnitsPerWorldUnit2;\n vec4 center;\n mat4 modelMatrix;\n mat4 viewProjectionMatrix;\n vec2 viewportSize;\n float devicePixelRatio;\n float focalDistance;\n vec3 cameraPosition;\n vec3 coordinateOrigin;\n vec3 commonOrigin;\n bool pseudoMeters;\n} project;\n\n\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0; // meters\nconst float GLOBE_RADIUS = 256.0;\n\n// returns an adjustment factor for uCommonUnitsPerMeter\nfloat project_size_at_latitude(float lat) {\n float y = clamp(lat, -89.9, 89.9);\n return 1.0 / cos(radians(y));\n}\n\nfloat project_size() {\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR &&\n project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\n project.pseudoMeters == false) {\n\n // uCommonUnitsPerMeter in low-zoom Web Mercator is non-linear\n // Adjust by 1 / cos(latitude)\n // If geometry.position (vertex in common space) is populated, use it\n // Otherwise use geometry.worldPosition (anchor in world space)\n \n if (geometry.position.w == 0.0) {\n return project_size_at_latitude(geometry.worldPosition.y);\n }\n\n // latitude from common y: 2.0 * (atan(exp(y / TILE_SIZE * 2.0 * PI - PI)) - PI / 4.0)\n // Taylor series of 1 / cos(latitude)\n // Max error < 0.003\n \n float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\n float y2 = y * y;\n float y4 = y2 * y2;\n float y6 = y4 * y2;\n return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n }\n return 1.0;\n}\n\nfloat project_size_at_latitude(float meters, float lat) {\n return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\n\n//\n// Scaling offsets - scales meters to \"world distance\"\n// Note the scalar version of project_size is for scaling the z component only\n//\nfloat project_size(float meters) {\n // For scatter relevant\n return meters * project.commonUnitsPerMeter.z * project_size();\n}\n\nvec2 project_size(vec2 meters) {\n return meters * project.commonUnitsPerMeter.xy * project_size();\n}\n\nvec3 project_size(vec3 meters) {\n return meters * project.commonUnitsPerMeter * project_size();\n}\n\nvec4 project_size(vec4 meters) {\n return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w);\n}\n\n// Get rotation matrix that aligns the z axis with the given up vector\n// Find 3 unit vectors ux, uy, uz that are perpendicular to each other and uz == up\nmat3 project_get_orientation_matrix(vec3 up) {\n vec3 uz = normalize(up);\n // Tangent on XY plane\n vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\n vec3 uy = cross(uz, ux);\n return mat3(ux, uy, uz);\n}\n\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n transform = project_get_orientation_matrix(commonPosition);\n return true;\n }\n return false;\n}\n\n//\n// Projecting normal - transform deltas from current coordinate system to\n// normals in the worldspace\n//\nvec3 project_normal(vec3 vector) {\n // Apply model matrix\n vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0);\n vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter);\n mat3 rotation;\n if (project_needs_rotation(geometry.position.xyz, rotation)) {\n n = rotation * n;\n }\n return n;\n}\n\nvec4 project_offset_(vec4 offset) {\n float dy = offset.y;\n vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy;\n return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\n\n//\n// Projecting positions - non-linear projection: lnglats => unit tile [0-1, 0-1]\n//\nvec2 project_mercator_(vec2 lnglat) {\n float x = lnglat.x;\n if (project.wrapLongitude) {\n x = mod(x + 180., 360.0) - 180.;\n }\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\nvec3 project_globe_(vec3 lnglatz) {\n float lambda = radians(lnglatz.x);\n float phi = radians(lnglatz.y);\n float cosPhi = cos(phi);\n float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\n\n return vec3(\n sin(lambda) * cosPhi,\n -cos(lambda) * cosPhi,\n sin(phi)\n ) * D;\n}\n\n//\n// Projects positions (defined by project.coordinateSystem) to common space (defined by project.projectionMode)\n//\nvec4 project_position(vec4 position, vec3 position64Low) {\n vec4 position_world = project.modelMatrix * position;\n\n // Work around for a Mac+NVIDIA bug https://github.com/visgl/deck.gl/issues/4145\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_mercator_(position_world.xy),\n project_size_at_latitude(position_world.z, position_world.y),\n position_world.w\n );\n }\n if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\n position_world.xyz += project.coordinateOrigin;\n }\n }\n if (project.projectionMode == PROJECTION_MODE_GLOBE) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n return vec4(\n project_globe_(position_world.xyz),\n position_world.w\n );\n }\n }\n if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\n if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\n if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) {\n // Too far from the projection center for offset mode to be accurate\n // Only use high parts\n return vec4(\n project_mercator_(position_world.xy) - project.commonOrigin.xy,\n project_size(position_world.z),\n position_world.w\n );\n }\n }\n }\n if (project.projectionMode == PROJECTION_MODE_IDENTITY ||\n (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\n project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\n // Subtract high part of 64 bit value. Convert remainder to float32, preserving precision.\n position_world.xyz -= project.coordinateOrigin;\n }\n\n // Translation is already added to the high parts\n return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0));\n}\n\nvec4 project_position(vec4 position) {\n return project_position(position, ZERO_64_LOW);\n}\n\nvec3 project_position(vec3 position, vec3 position64Low) {\n vec4 projected_position = project_position(vec4(position, 1.0), position64Low);\n return projected_position.xyz;\n}\n\nvec3 project_position(vec3 position) {\n vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\n return projected_position.xyz;\n}\n\nvec2 project_position(vec2 position) {\n vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\n return projected_position.xy;\n}\n\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\n return viewProjectionMatrix * position + center;\n}\n\n//\n// Projects from common space coordinates to clip space.\n// Uses project.viewProjectionMatrix\n//\nvec4 project_common_position_to_clipspace(vec4 position) {\n return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center);\n}\n\n// Returns a clip space offset that corresponds to a given number of screen pixels\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\n vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0;\n return offset * project.focalDistance;\n}\n\nfloat project_size_to_pixel(float meters) {\n return project_size(meters) * project.scale;\n}\nfloat project_size_to_pixel(float size, int unit) {\n if (unit == UNIT_METERS) return project_size_to_pixel(size);\n if (unit == UNIT_COMMON) return size * project.scale;\n // UNIT_PIXELS\n return size;\n}\nfloat project_pixel_size(float pixels) {\n return pixels / project.scale;\n}\nvec2 project_pixel_size(vec2 pixels) {\n return pixels / project.scale;\n}\n`;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable complexity, camelcase */\n\nimport {mat4, Matrix4Like, vec4} from '@math.gl/core';\n\nimport {COORDINATE_SYSTEM, PROJECTION_MODE} from '../../lib/constants';\n\nimport memoize from '../../utils/memoize';\n\nimport type Viewport from '../../viewports/viewport';\nimport type {CoordinateSystem} from '../../lib/constants';\n\ntype Vec3 = [number, number, number];\ntype Vec4 = [number, number, number, number];\n\n// To quickly set a vector to zero\nconst ZERO_VECTOR: Vec4 = [0, 0, 0, 0];\n// 4x4 matrix that drops 4th component of vector\nconst VECTOR_TO_POINT_MATRIX: Matrix4Like = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];\nconst IDENTITY_MATRIX: Matrix4Like = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\nconst DEFAULT_PIXELS_PER_UNIT2: Vec3 = [0, 0, 0];\nconst DEFAULT_COORDINATE_ORIGIN: Vec3 = [0, 0, 0];\n\nconst getMemoizedViewportUniforms = memoize(calculateViewportUniforms);\n\nexport function getOffsetOrigin(\n viewport: Viewport,\n coordinateSystem: CoordinateSystem,\n coordinateOrigin: Vec3 = DEFAULT_COORDINATE_ORIGIN\n): {\n geospatialOrigin: Vec3 | null;\n shaderCoordinateOrigin: Vec3;\n offsetMode: boolean;\n} {\n if (coordinateOrigin.length < 3) {\n coordinateOrigin = [coordinateOrigin[0], coordinateOrigin[1], 0];\n }\n\n let shaderCoordinateOrigin = coordinateOrigin;\n let geospatialOrigin: Vec3 | null;\n let offsetMode = true;\n\n if (\n coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS ||\n coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n geospatialOrigin = coordinateOrigin;\n } else {\n geospatialOrigin = viewport.isGeospatial\n ? // @ts-expect-error longitude and latitude are not defined on the base Viewport, but is expected on geospatial viewports\n [Math.fround(viewport.longitude), Math.fround(viewport.latitude), 0]\n : null;\n }\n\n switch (viewport.projectionMode) {\n case PROJECTION_MODE.WEB_MERCATOR:\n if (\n coordinateSystem === COORDINATE_SYSTEM.LNGLAT ||\n coordinateSystem === COORDINATE_SYSTEM.CARTESIAN\n ) {\n geospatialOrigin = [0, 0, 0];\n offsetMode = false;\n }\n break;\n\n case PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET:\n if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT) {\n // viewport center in world space\n // @ts-expect-error when using LNGLAT coordinates, we expect the viewport to be geospatial, in which case geospatialOrigin is defined\n shaderCoordinateOrigin = geospatialOrigin;\n } else if (coordinateSystem === COORDINATE_SYSTEM.CARTESIAN) {\n // viewport center in common space\n shaderCoordinateOrigin = [\n Math.fround(viewport.center[0]),\n Math.fround(viewport.center[1]),\n 0\n ];\n // Geospatial origin (wgs84) must match shaderCoordinateOrigin (common)\n geospatialOrigin = viewport.unprojectPosition(shaderCoordinateOrigin);\n shaderCoordinateOrigin[0] -= coordinateOrigin[0];\n shaderCoordinateOrigin[1] -= coordinateOrigin[1];\n shaderCoordinateOrigin[2] -= coordinateOrigin[2];\n }\n break;\n\n case PROJECTION_MODE.IDENTITY:\n shaderCoordinateOrigin = viewport.position.map(Math.fround) as Vec3;\n shaderCoordinateOrigin[2] = shaderCoordinateOrigin[2] || 0;\n break;\n\n case PROJECTION_MODE.GLOBE:\n offsetMode = false;\n geospatialOrigin = null;\n break;\n\n default:\n // Unknown projection mode\n offsetMode = false;\n }\n\n return {geospatialOrigin, shaderCoordinateOrigin, offsetMode};\n}\n\n// The code that utilizes Matrix4 does the same calculation as their mat4 counterparts,\n// has lower performance but provides error checking.\nfunction calculateMatrixAndOffset(\n viewport: Viewport,\n coordinateSystem: CoordinateSystem,\n coordinateOrigin: Vec3\n): {\n viewMatrix: Matrix4Like;\n viewProjectionMatrix: Matrix4Like;\n projectionCenter: Vec4;\n originCommon: Vec4;\n cameraPosCommon: Vec3;\n shaderCoordinateOrigin: Vec3;\n geospatialOrigin: Vec3 | null;\n} {\n const {viewMatrixUncentered, projectionMatrix} = viewport;\n let {viewMatrix, viewProjectionMatrix} = viewport;\n\n let projectionCenter = ZERO_VECTOR;\n let originCommon: Vec4 = ZERO_VECTOR;\n let cameraPosCommon: Vec3 = viewport.cameraPosition as Vec3;\n const {geospatialOrigin, shaderCoordinateOrigin, offsetMode} = getOffsetOrigin(\n viewport,\n coordinateSystem,\n coordinateOrigin\n );\n\n if (offsetMode) {\n // Calculate transformed projectionCenter (using 64 bit precision JS)\n // This is the key to offset mode precision\n // (avoids doing this addition in 32 bit precision in GLSL)\n // @ts-expect-error the 4th component is assigned below\n originCommon = viewport.projectPosition(geospatialOrigin || shaderCoordinateOrigin);\n\n cameraPosCommon = [\n cameraPosCommon[0] - originCommon[0],\n cameraPosCommon[1] - originCommon[1],\n cameraPosCommon[2] - originCommon[2]\n ];\n\n originCommon[3] = 1;\n\n // projectionCenter = new Matrix4(viewProjectionMatrix)\n // .transformVector([positionPixels[0], positionPixels[1], 0.0, 1.0]);\n projectionCenter = vec4.transformMat4([], originCommon, viewProjectionMatrix);\n\n // Always apply uncentered projection matrix if available (shader adds center)\n viewMatrix = viewMatrixUncentered || viewMatrix;\n\n // Zero out 4th coordinate (\"after\" model matrix) - avoids further translations\n // viewMatrix = new Matrix4(viewMatrixUncentered || viewMatrix)\n // .multiplyRight(VECTOR_TO_POINT_MATRIX);\n viewProjectionMatrix = mat4.multiply([], projectionMatrix, viewMatrix);\n viewProjectionMatrix = mat4.multiply([], viewProjectionMatrix, VECTOR_TO_POINT_MATRIX);\n }\n\n return {\n viewMatrix: viewMatrix as Matrix4Like,\n viewProjectionMatrix: viewProjectionMatrix as Matrix4Like,\n projectionCenter,\n originCommon,\n cameraPosCommon,\n shaderCoordinateOrigin,\n geospatialOrigin\n };\n}\n\nexport type ProjectUniforms = {\n coordinateSystem: number;\n projectionMode: number;\n coordinateOrigin: Vec3;\n commonOrigin: Vec3;\n center: Vec4;\n // Backward compatibility\n // TODO: remove in v9\n pseudoMeters: boolean;\n\n // Screen size\n viewportSize: [number, number];\n devicePixelRatio: number;\n\n focalDistance: number;\n commonUnitsPerMeter: Vec3;\n commonUnitsPerWorldUnit: Vec3;\n commonUnitsPerWorldUnit2: Vec3;\n /** 2^zoom */\n scale: number;\n wrapLongitude: boolean;\n\n viewProjectionMatrix: Matrix4Like;\n modelMatrix: Matrix4Like;\n\n // This is for lighting calculations\n cameraPosition: Vec3;\n};\n\nexport type ProjectProps = {\n viewport: Viewport;\n devicePixelRatio?: number;\n modelMatrix?: Matrix4Like | null;\n coordinateSystem?: CoordinateSystem;\n coordinateOrigin?: Vec3;\n autoWrapLongitude?: boolean;\n};\n\n/**\n * Returns uniforms for shaders based on current projection\n * includes: projection matrix suitable for shaders\n *\n * TODO - Ensure this works with any viewport, not just WebMercatorViewports\n *\n * @param {WebMercatorViewport} viewport -\n * @return {Float32Array} - 4x4 projection matrix that can be used in shaders\n */\nexport function getUniformsFromViewport({\n viewport,\n devicePixelRatio = 1,\n modelMatrix = null,\n // Match Layer.defaultProps\n coordinateSystem = COORDINATE_SYSTEM.DEFAULT,\n coordinateOrigin = DEFAULT_COORDINATE_ORIGIN,\n autoWrapLongitude = false\n}: ProjectProps): ProjectUniforms {\n if (coordinateSystem === COORDINATE_SYSTEM.DEFAULT) {\n coordinateSystem = viewport.isGeospatial\n ? COORDINATE_SYSTEM.LNGLAT\n : COORDINATE_SYSTEM.CARTESIAN;\n }\n\n const uniforms = getMemoizedViewportUniforms({\n viewport,\n devicePixelRatio,\n coordinateSystem,\n coordinateOrigin\n });\n\n uniforms.wrapLongitude = autoWrapLongitude;\n uniforms.modelMatrix = modelMatrix || IDENTITY_MATRIX;\n\n return uniforms;\n}\n\nfunction calculateViewportUniforms({\n viewport,\n devicePixelRatio,\n coordinateSystem,\n coordinateOrigin\n}: {\n viewport: Viewport;\n devicePixelRatio: number;\n coordinateSystem: CoordinateSystem;\n coordinateOrigin: Vec3;\n}): ProjectUniforms {\n const {\n projectionCenter,\n viewProjectionMatrix,\n originCommon,\n cameraPosCommon,\n shaderCoordinateOrigin,\n geospatialOrigin\n } = calculateMatrixAndOffset(viewport, coordinateSystem, coordinateOrigin);\n\n // Calculate projection pixels per unit\n const distanceScales = viewport.getDistanceScales();\n\n const viewportSize: [number, number] = [\n viewport.width * devicePixelRatio,\n viewport.height * devicePixelRatio\n ];\n\n // Distance at which screen pixels are projected.\n // Used to scale sizes in clipspace to match screen pixels.\n // When using Viewport class's default projection matrix, this yields 1 for orthographic\n // and `viewport.focalDistance` for perspective views\n const focalDistance =\n vec4.transformMat4([], [0, 0, -viewport.focalDistance, 1], viewport.projectionMatrix)[3] || 1;\n\n const uniforms: ProjectUniforms = {\n // Projection mode values\n coordinateSystem,\n projectionMode: viewport.projectionMode,\n coordinateOrigin: shaderCoordinateOrigin,\n commonOrigin: originCommon.slice(0, 3) as Vec3,\n center: projectionCenter,\n\n // Backward compatibility\n // TODO: remove in v9\n // @ts-expect-error _pseudoMeters is only defined on WebMercator viewport\n pseudoMeters: Boolean(viewport._pseudoMeters),\n\n // Screen size\n viewportSize,\n devicePixelRatio,\n\n focalDistance,\n commonUnitsPerMeter: distanceScales.unitsPerMeter as Vec3,\n commonUnitsPerWorldUnit: distanceScales.unitsPerMeter as Vec3,\n commonUnitsPerWorldUnit2: DEFAULT_PIXELS_PER_UNIT2,\n scale: viewport.scale, // This is the mercator scale (2 ** zoom)\n wrapLongitude: false,\n\n viewProjectionMatrix,\n modelMatrix: IDENTITY_MATRIX,\n\n // This is for lighting calculations\n cameraPosition: cameraPosCommon\n };\n\n if (geospatialOrigin) {\n // Get high-precision DistanceScales from geospatial viewport\n // TODO: stricter types in Viewport classes\n const distanceScalesAtOrigin = viewport.getDistanceScales(geospatialOrigin) as {\n unitsPerMeter: Vec3;\n metersPerUnit: Vec3;\n unitsPerMeter2: Vec3;\n unitsPerDegree: Vec3;\n degreesPerUnit: Vec3;\n unitsPerDegree2: Vec3;\n };\n switch (coordinateSystem) {\n case COORDINATE_SYSTEM.METER_OFFSETS:\n uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerMeter;\n uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerMeter2;\n break;\n\n case COORDINATE_SYSTEM.LNGLAT:\n case COORDINATE_SYSTEM.LNGLAT_OFFSETS:\n // @ts-expect-error _pseudoMeters only exists on WebMercatorView\n if (!viewport._pseudoMeters) {\n uniforms.commonUnitsPerMeter = distanceScalesAtOrigin.unitsPerMeter;\n }\n uniforms.commonUnitsPerWorldUnit = distanceScalesAtOrigin.unitsPerDegree;\n uniforms.commonUnitsPerWorldUnit2 = distanceScalesAtOrigin.unitsPerDegree2;\n break;\n\n // a.k.a \"preprojected\" positions\n case COORDINATE_SYSTEM.CARTESIAN:\n uniforms.commonUnitsPerWorldUnit = [1, 1, distanceScalesAtOrigin.unitsPerMeter[2]];\n uniforms.commonUnitsPerWorldUnit2 = [0, 0, distanceScalesAtOrigin.unitsPerMeter2[2]];\n break;\n\n default:\n break;\n }\n }\n\n return uniforms;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nfunction isEqual(a, b) {\n if (a === b) {\n return true;\n }\n if (Array.isArray(a)) {\n // Special treatment for arrays: compare 1-level deep\n // This is to support equality of matrix/coordinate props\n const len = a.length;\n if (!b || b.length !== len) {\n return false;\n }\n\n for (let i = 0; i < len; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n\n/**\n * Speed up consecutive function calls by caching the result of calls with identical input\n * https://en.wikipedia.org/wiki/Memoization\n * @param {function} compute - the function to be memoized\n */\nexport default function memoize(compute: (args: In) => Out): (args: In) => Out {\n let cachedArgs: any = {};\n let cachedResult: Out;\n\n return (args: In) => {\n for (const key in args) {\n if (!isEqual(args[key], cachedArgs[key])) {\n cachedResult = compute(args);\n cachedArgs = args;\n break;\n }\n }\n return cachedResult;\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport project from '../project/project';\n\nconst vs = `\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n`;\n\nexport default {\n name: 'project32',\n dependencies: [project],\n vs\n} as ShaderModule;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {COORDINATE_SYSTEM, PROJECTION_MODE} from '../../lib/constants';\nimport project from '../project/project';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport type {NumericArray} from '@math.gl/core';\nimport memoize from '../../utils/memoize';\nimport {pixelsToWorld} from '@math.gl/web-mercator';\n\nimport type {Texture} from '@luma.gl/core';\nimport {ShaderModule} from '@luma.gl/shadertools';\nimport type Viewport from '../../viewports/viewport';\nimport type {ProjectProps, ProjectUniforms} from '../project/viewport-uniforms';\n\nconst uniformBlock = /* glsl */ `\nuniform shadowUniforms {\n bool drawShadowMap;\n bool useShadowMap;\n vec4 color;\n highp int lightId;\n float lightCount;\n mat4 viewProjectionMatrix0;\n mat4 viewProjectionMatrix1;\n vec4 projectCenter0;\n vec4 projectCenter1;\n} shadow;\n`;\n\nconst vertex = /* glsl */ `\nconst int max_lights = 2;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n mat4 viewProjectionMatrices[max_lights];\n viewProjectionMatrices[0] = shadow.viewProjectionMatrix0;\n viewProjectionMatrices[1] = shadow.viewProjectionMatrix1;\n vec4 projectCenters[max_lights];\n projectCenters[0] = shadow.projectCenter0;\n projectCenters[1] = shadow.projectCenter1;\n\n if (shadow.drawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]);\n }\n if (shadow.useShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow.lightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n`;\n\nconst vs = `\n${uniformBlock}\n${vertex}\n`;\n\nconst fragment = /* glsl */ `\nconst int max_lights = 2;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow.drawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow.useShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow.lightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow.color.a / shadow.lightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n`;\n\nconst fs = `\n${uniformBlock}\n${fragment}\n`;\n\nconst getMemoizedViewportCenterPosition = memoize(getViewportCenterPosition);\nconst getMemoizedViewProjectionMatrices = memoize(getViewProjectionMatrices);\n\nconst DEFAULT_SHADOW_COLOR: NumberArray4 = [0, 0, 0, 1.0];\nconst VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];\n\nexport type ShadowModuleProps = {\n project: ProjectProps;\n shadowEnabled?: boolean;\n drawToShadowMap?: boolean;\n shadowMaps?: Texture[];\n dummyShadowMap: Texture;\n shadowColor?: NumberArray4;\n shadowMatrices?: Matrix4[];\n shadowLightId?: number;\n};\n\ntype ShadowModuleUniforms = {\n drawShadowMap: boolean;\n useShadowMap: boolean;\n color?: NumberArray4;\n lightId?: number;\n lightCount?: number;\n viewProjectionMatrix0?: NumberArray16;\n viewProjectionMatrix1?: NumberArray16;\n projectCenter0?: NumberArray4;\n projectCenter1?: NumberArray4;\n};\n\ntype ShadowModuleBindings = {\n shadow_uShadowMap0: Texture;\n shadow_uShadowMap1: Texture;\n};\n\nfunction screenToCommonSpace(xyz: number[], pixelUnprojectionMatrix: number[]): number[] {\n const [x, y, z] = xyz;\n const coord = pixelsToWorld([x, y, z], pixelUnprojectionMatrix);\n\n if (Number.isFinite(z)) {\n return coord;\n }\n return [coord[0], coord[1], 0];\n}\n\nfunction getViewportCenterPosition({\n viewport,\n center\n}: {\n viewport: Viewport;\n center: NumericArray;\n}): NumericArray {\n return new Matrix4(viewport.viewProjectionMatrix).invert().transform(center);\n}\n\nfunction getViewProjectionMatrices({\n viewport,\n shadowMatrices\n}: {\n viewport: Viewport;\n shadowMatrices: Matrix4[];\n}): Matrix4[] {\n const projectionMatrices: Matrix4[] = [];\n const pixelUnprojectionMatrix = viewport.pixelUnprojectionMatrix;\n const farZ = viewport.isGeospatial ? undefined : 1;\n const corners = [\n [0, 0, farZ], // top left ground\n [viewport.width, 0, farZ], // top right ground\n [0, viewport.height, farZ], // bottom left ground\n [viewport.width, viewport.height, farZ], // bottom right ground\n [0, 0, -1], // top left near\n [viewport.width, 0, -1], // top right near\n [0, viewport.height, -1], // bottom left near\n [viewport.width, viewport.height, -1] // bottom right near\n ].map(pixel =>\n // @ts-expect-error z may be undefined\n screenToCommonSpace(pixel, pixelUnprojectionMatrix)\n );\n\n for (const shadowMatrix of shadowMatrices) {\n const viewMatrix = shadowMatrix.clone().translate(new Vector3(viewport.center).negate());\n const positions = corners.map(corner => viewMatrix.transform(corner));\n const projectionMatrix = new Matrix4().ortho({\n left: Math.min(...positions.map(position => position[0])),\n right: Math.max(...positions.map(position => position[0])),\n bottom: Math.min(...positions.map(position => position[1])),\n top: Math.max(...positions.map(position => position[1])),\n near: Math.min(...positions.map(position => -position[2])),\n far: Math.max(...positions.map(position => -position[2]))\n });\n projectionMatrices.push(projectionMatrix.multiplyRight(shadowMatrix));\n }\n return projectionMatrices;\n}\n\n/* eslint-disable camelcase */\n\n// eslint-disable-next-line complexity\nfunction createShadowUniforms(\n opts: Partial\n): ShadowModuleBindings & ShadowModuleUniforms {\n const {shadowEnabled = true, project: projectProps} = opts;\n if (!shadowEnabled || !projectProps || !opts.shadowMatrices || !opts.shadowMatrices.length) {\n return {\n drawShadowMap: false,\n useShadowMap: false,\n shadow_uShadowMap0: opts.dummyShadowMap!,\n shadow_uShadowMap1: opts.dummyShadowMap!\n };\n }\n const projectUniforms = project.getUniforms(projectProps) as ProjectUniforms;\n const center = getMemoizedViewportCenterPosition({\n viewport: projectProps.viewport,\n center: projectUniforms.center\n });\n\n const projectCenters: NumericArray[] = [];\n const viewProjectionMatrices = getMemoizedViewProjectionMatrices({\n shadowMatrices: opts.shadowMatrices,\n viewport: projectProps.viewport\n }).slice();\n\n for (let i = 0; i < opts.shadowMatrices.length; i++) {\n const viewProjectionMatrix = viewProjectionMatrices[i];\n const viewProjectionMatrixCentered = viewProjectionMatrix\n .clone()\n .translate(new Vector3(projectProps.viewport.center).negate());\n\n if (\n projectUniforms.coordinateSystem === COORDINATE_SYSTEM.LNGLAT &&\n projectUniforms.projectionMode === PROJECTION_MODE.WEB_MERCATOR\n ) {\n viewProjectionMatrices[i] = viewProjectionMatrixCentered;\n projectCenters[i] = center;\n } else {\n viewProjectionMatrices[i] = viewProjectionMatrix\n .clone()\n .multiplyRight(VECTOR_TO_POINT_MATRIX);\n projectCenters[i] = viewProjectionMatrixCentered.transform(center);\n }\n }\n\n const uniforms: ShadowModuleUniforms & ShadowModuleBindings = {\n drawShadowMap: Boolean(opts.drawToShadowMap),\n useShadowMap: opts.shadowMaps ? opts.shadowMaps.length > 0 : false,\n color: opts.shadowColor || DEFAULT_SHADOW_COLOR,\n lightId: opts.shadowLightId || 0,\n lightCount: opts.shadowMatrices.length,\n shadow_uShadowMap0: opts.dummyShadowMap!,\n shadow_uShadowMap1: opts.dummyShadowMap!\n };\n\n for (let i = 0; i < viewProjectionMatrices.length; i++) {\n uniforms[`viewProjectionMatrix${i}`] = viewProjectionMatrices[i];\n uniforms[`projectCenter${i}`] = projectCenters[i];\n }\n\n for (let i = 0; i < 2; i++) {\n uniforms[`shadow_uShadowMap${i}`] =\n (opts.shadowMaps && opts.shadowMaps[i]) || opts.dummyShadowMap;\n }\n return uniforms;\n}\n\nexport default {\n name: 'shadow',\n dependencies: [project],\n vs,\n fs,\n inject: {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n position = shadow_setVertexPosition(geometry.position);\n `,\n 'fs:DECKGL_FILTER_COLOR': `\n color = shadow_filterShadowColor(color);\n `\n },\n getUniforms: createShadowUniforms,\n uniformTypes: {\n drawShadowMap: 'f32',\n useShadowMap: 'f32',\n color: 'vec4',\n lightId: 'i32',\n lightCount: 'f32',\n viewProjectionMatrix0: 'mat4x4',\n viewProjectionMatrix1: 'mat4x4',\n projectCenter0: 'vec4',\n projectCenter1: 'vec4'\n }\n} as const satisfies ShaderModule;\n\n// TODO replace with type from math.gl\ntype NumberArray4 = [number, number, number, number];\ntype NumberArray16 = [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n];\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {picking} from '@luma.gl/shadertools';\n\nexport default {\n ...picking,\n defaultUniforms: {...picking.defaultUniforms, useFloatColors: false},\n inject: {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n picking_setPickingColor(geometry.pickingColor);\n `,\n 'fs:DECKGL_FILTER_COLOR': {\n order: 99,\n injection: `\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n `\n }\n }\n};\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst DEFAULT_LIGHT_COLOR = [255, 255, 255] as [number, number, number];\nconst DEFAULT_LIGHT_INTENSITY = 1.0;\n\nlet idCount = 0;\n\nexport type AmbientLightOptions = {\n id?: string;\n /** Light color, [r, g, b] in the 0-255 range\n * @default [255, 255, 255]\n */\n color?: [number, number, number];\n /** Light intensity, higher number is brighter\n * @default 1.0\n */\n intensity?: number;\n};\n\nexport class AmbientLight {\n id: string;\n color: [number, number, number];\n intensity: number;\n type = 'ambient' as const;\n\n constructor(props: AmbientLightOptions = {}) {\n const {color = DEFAULT_LIGHT_COLOR} = props;\n const {intensity = DEFAULT_LIGHT_INTENSITY} = props;\n\n this.id = props.id || `ambient-${idCount++}`;\n this.color = color;\n this.intensity = intensity;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector3} from '@math.gl/core';\nimport type Layer from '../../lib/layer';\n\nconst DEFAULT_LIGHT_COLOR = [255, 255, 255] as [number, number, number];\nconst DEFAULT_LIGHT_INTENSITY = 1.0;\nconst DEFAULT_LIGHT_DIRECTION = [0.0, 0.0, -1.0] as [number, number, number];\n\nlet idCount = 0;\n\nexport type DirectionalLightOptions = {\n id?: string;\n /** Light color, [r, g, b] in the 0-255 range\n * @default [255, 255, 255]\n */\n color?: [number, number, number];\n /** Light intensity, higher number is brighter\n * @default 1.0\n */\n intensity?: number;\n /** Light direction in the common space\n * @default [0.0, 0.0, -1.0]\n */\n direction?: [number, number, number];\n /** (Experimental) render shadows cast by this light\n * @default false\n */\n _shadow?: boolean;\n};\n\nexport class DirectionalLight {\n id: string;\n color: [number, number, number];\n intensity: number;\n type = 'directional' as const;\n direction: [number, number, number];\n shadow: boolean;\n\n constructor(props: DirectionalLightOptions = {}) {\n const {color = DEFAULT_LIGHT_COLOR} = props;\n const {intensity = DEFAULT_LIGHT_INTENSITY} = props;\n const {direction = DEFAULT_LIGHT_DIRECTION} = props;\n const {_shadow = false} = props;\n\n this.id = props.id || `directional-${idCount++}`;\n this.color = color;\n this.intensity = intensity;\n this.type = 'directional';\n this.direction = new Vector3(direction).normalize().toArray() as [number, number, number];\n this.shadow = _shadow;\n }\n\n getProjectedLight(opts: {layer: Layer}): DirectionalLight {\n return this;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\nimport {Texture} from '@luma.gl/core';\nimport {AmbientLight} from './ambient-light';\nimport {DirectionalLight} from './directional-light';\nimport {PointLight} from './point-light';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport ShadowPass from '../../passes/shadow-pass';\nimport shadow from '../../shaderlib/shadow/shadow';\n\nimport type {LightingProps} from '@luma.gl/shadertools';\nimport type {ShadowModuleProps} from '../../shaderlib/shadow/shadow';\nimport type Layer from '../../lib/layer';\nimport type {Effect, EffectContext, PreRenderOptions} from '../../lib/effect';\n\nconst DEFAULT_AMBIENT_LIGHT_PROPS = {\n color: [255, 255, 255] as [number, number, number],\n intensity: 1.0\n};\nconst DEFAULT_DIRECTIONAL_LIGHT_PROPS = [\n {\n color: [255, 255, 255] as [number, number, number],\n intensity: 1.0,\n direction: [-1, 3, -1] as [number, number, number]\n },\n {\n color: [255, 255, 255] as [number, number, number],\n intensity: 0.9,\n direction: [1, -8, -2.5] as [number, number, number]\n }\n];\nconst DEFAULT_SHADOW_COLOR = [0, 0, 0, 200 / 255] as [number, number, number, number];\n\nexport type LightingEffectProps = Record;\n\n// Class to manage ambient, point and directional light sources in deck\nexport default class LightingEffect implements Effect {\n id = 'lighting-effect';\n props!: LightingEffectProps;\n shadowColor: [number, number, number, number] = DEFAULT_SHADOW_COLOR;\n context?: EffectContext;\n\n private shadow: boolean = false;\n private ambientLight?: AmbientLight;\n private directionalLights: DirectionalLight[] = [];\n private pointLights: PointLight[] = [];\n private shadowPasses: ShadowPass[] = [];\n private dummyShadowMap: Texture | null = null;\n private shadowMatrices?: Matrix4[];\n\n constructor(props: LightingEffectProps = {}) {\n this.setProps(props);\n }\n\n setup(context: EffectContext) {\n this.context = context;\n const {device, deck} = context;\n\n if (this.shadow && !this.dummyShadowMap) {\n this._createShadowPasses(device);\n\n deck._addDefaultShaderModule(shadow);\n\n this.dummyShadowMap = device.createTexture({\n width: 1,\n height: 1\n });\n }\n }\n\n setProps(props: LightingEffectProps) {\n this.ambientLight = undefined;\n this.directionalLights = [];\n this.pointLights = [];\n\n for (const key in props) {\n const lightSource = props[key];\n\n switch (lightSource.type) {\n case 'ambient':\n this.ambientLight = lightSource;\n break;\n\n case 'directional':\n this.directionalLights.push(lightSource);\n break;\n\n case 'point':\n this.pointLights.push(lightSource);\n break;\n default:\n }\n }\n this._applyDefaultLights();\n\n this.shadow = this.directionalLights.some(light => light.shadow);\n if (this.context) {\n // Create resources if necessary\n this.setup(this.context);\n }\n this.props = props;\n }\n\n preRender({layers, layerFilter, viewports, onViewportActive, views}: PreRenderOptions) {\n if (!this.shadow) return;\n\n // create light matrix every frame to make sure always updated from light source\n this.shadowMatrices = this._calculateMatrices();\n\n for (let i = 0; i < this.shadowPasses.length; i++) {\n const shadowPass = this.shadowPasses[i];\n shadowPass.render({\n layers,\n layerFilter,\n viewports,\n onViewportActive,\n views,\n shaderModuleProps: {\n shadow: {\n shadowLightId: i,\n dummyShadowMap: this.dummyShadowMap,\n shadowMatrices: this.shadowMatrices\n }\n }\n });\n }\n }\n\n getShaderModuleProps(layer: Layer, otherShaderModuleProps: Record) {\n const shadowProps = this.shadow\n ? ({\n project: otherShaderModuleProps.project,\n shadowMaps: this.shadowPasses.map(shadowPass => shadowPass.getShadowMap()),\n dummyShadowMap: this.dummyShadowMap!,\n shadowColor: this.shadowColor,\n shadowMatrices: this.shadowMatrices\n } satisfies ShadowModuleProps)\n : {};\n\n // when not rendering to screen, turn off lighting by adding empty light source object\n // lights shader module relies on the `lightSources` to turn on/off lighting\n const lightingProps: LightingProps = {\n enabled: true,\n ambientLight: this.ambientLight,\n directionalLights: this.directionalLights.map(directionalLight =>\n directionalLight.getProjectedLight({layer})\n ),\n pointLights: this.pointLights.map(pointLight => pointLight.getProjectedLight({layer}))\n };\n // @ts-expect-error material is not a Layer prop\n const materialProps = layer.props.material;\n\n return {\n shadow: shadowProps,\n lighting: lightingProps,\n phongMaterial: materialProps,\n gouraudMaterial: materialProps\n };\n }\n\n cleanup(context: EffectContext): void {\n for (const shadowPass of this.shadowPasses) {\n shadowPass.delete();\n }\n this.shadowPasses.length = 0;\n\n if (this.dummyShadowMap) {\n this.dummyShadowMap.destroy();\n this.dummyShadowMap = null;\n context.deck._removeDefaultShaderModule(shadow);\n }\n }\n\n private _calculateMatrices(): Matrix4[] {\n const lightMatrices: Matrix4[] = [];\n for (const light of this.directionalLights) {\n const viewMatrix = new Matrix4().lookAt({\n eye: new Vector3(light.direction).negate()\n });\n\n lightMatrices.push(viewMatrix);\n }\n return lightMatrices;\n }\n\n private _createShadowPasses(device: Device): void {\n for (let i = 0; i < this.directionalLights.length; i++) {\n const shadowPass = new ShadowPass(device);\n this.shadowPasses[i] = shadowPass;\n }\n }\n\n private _applyDefaultLights(): void {\n const {ambientLight, pointLights, directionalLights} = this;\n if (!ambientLight && pointLights.length === 0 && directionalLights.length === 0) {\n this.ambientLight = new AmbientLight(DEFAULT_AMBIENT_LIGHT_PROPS);\n this.directionalLights.push(\n new DirectionalLight(DEFAULT_DIRECTIONAL_LIGHT_PROPS[0]),\n new DirectionalLight(DEFAULT_DIRECTIONAL_LIGHT_PROPS[1])\n );\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\n\n/**\n * Base class for passes\n * @todo v9 - should the luma.gl RenderPass be owned by this class?\n * Currently owned by subclasses\n */\nexport default class Pass {\n /** string id, mainly for debugging */\n id: string;\n /** The luma.gl Device that this pass is associated with */\n device: Device;\n /** TODO v9 - inject prop types from parent */\n props: any;\n\n /** Create a new Pass instance */\n constructor(device: Device, props: {id: string} = {id: 'pass'}) {\n const {id} = props;\n this.id = id; // id of this pass\n this.device = device;\n this.props = {...props};\n }\n\n setProps(props): void {\n Object.assign(this.props, props);\n }\n\n render(params): void {} // eslint-disable-line @typescript-eslint/no-empty-function\n\n cleanup() {} // eslint-disable-line @typescript-eslint/no-empty-function\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Parameters, RenderPassParameters} from '@luma.gl/core';\nimport type {Framebuffer, RenderPass} from '@luma.gl/core';\n\nimport Pass from './pass';\nimport type Viewport from '../viewports/viewport';\nimport type View from '../views/view';\nimport type Layer from '../lib/layer';\nimport type {Effect} from '../lib/effect';\nimport type {ProjectProps} from '../shaderlib/project/viewport-uniforms';\nimport type {PickingProps} from '@luma.gl/shadertools';\n\nexport type Rect = {x: number; y: number; width: number; height: number};\n\nexport type LayersPassRenderOptions = {\n /** @deprecated TODO v9 recommend we rename this to framebuffer to minimize confusion */\n target?: Framebuffer | null;\n isPicking?: boolean;\n pass: string;\n layers: Layer[];\n viewports: Viewport[];\n onViewportActive?: (viewport: Viewport) => void;\n cullRect?: Rect;\n views?: Record;\n effects?: Effect[];\n /** If true, recalculates render index (z) from 0. Set to false if a stack of layers are rendered in multiple passes. */\n clearStack?: boolean;\n clearCanvas?: boolean;\n clearColor?: number[];\n colorMask?: number;\n scissorRect?: number[];\n layerFilter?: ((context: FilterContext) => boolean) | null;\n shaderModuleProps?: any;\n /** Stores returned results from Effect.preRender, for use downstream in the render pipeline */\n preRenderStats?: Record;\n};\n\nexport type DrawLayerParameters = {\n shouldDrawLayer: boolean;\n layerRenderIndex: number;\n shaderModuleProps: any;\n layerParameters: Parameters;\n};\n\nexport type FilterContext = {\n layer: Layer;\n viewport: Viewport;\n isPicking: boolean;\n renderPass: string;\n cullRect?: Rect;\n};\n\nexport type RenderStats = {\n totalCount: number;\n visibleCount: number;\n compositeCount: number;\n pickableCount: number;\n};\n\n/** A Pass that renders all layers */\nexport default class LayersPass extends Pass {\n _lastRenderIndex: number = -1;\n\n render(options: LayersPassRenderOptions): any {\n // @ts-expect-error TODO - assuming WebGL context\n const [width, height] = this.device.canvasContext.getDrawingBufferSize();\n\n // Explicitly specify clearColor and clearDepth, overriding render pass defaults.\n const clearCanvas = options.clearCanvas ?? true;\n const clearColor = options.clearColor ?? (clearCanvas ? [0, 0, 0, 0] : false);\n const clearDepth = clearCanvas ? 1 : false;\n const clearStencil = clearCanvas ? 0 : false;\n const colorMask = options.colorMask ?? 0xf;\n\n const parameters: RenderPassParameters = {viewport: [0, 0, width, height]};\n if (options.colorMask) {\n parameters.colorMask = colorMask;\n }\n if (options.scissorRect) {\n parameters.scissorRect = options.scissorRect as [number, number, number, number];\n }\n\n const renderPass = this.device.beginRenderPass({\n framebuffer: options.target,\n parameters,\n clearColor: clearColor as [number, number, number, number],\n clearDepth,\n clearStencil\n });\n\n try {\n return this._drawLayers(renderPass, options);\n } finally {\n renderPass.end();\n }\n }\n\n /** Draw a list of layers in a list of viewports */\n private _drawLayers(renderPass: RenderPass, options: LayersPassRenderOptions) {\n const {\n target,\n shaderModuleProps,\n viewports,\n views,\n onViewportActive,\n clearStack = true\n } = options;\n options.pass = options.pass || 'unknown';\n\n if (clearStack) {\n this._lastRenderIndex = -1;\n }\n\n const renderStats: RenderStats[] = [];\n\n for (const viewport of viewports) {\n const view = views && views[viewport.id];\n\n // Update context to point to this viewport\n onViewportActive?.(viewport);\n\n const drawLayerParams = this._getDrawLayerParams(viewport, options);\n\n // render this viewport\n const subViewports = viewport.subViewports || [viewport];\n for (const subViewport of subViewports) {\n const stats = this._drawLayersInViewport(\n renderPass,\n {\n target,\n shaderModuleProps,\n viewport: subViewport,\n view,\n pass: options.pass,\n layers: options.layers\n },\n drawLayerParams\n );\n renderStats.push(stats);\n }\n }\n return renderStats;\n }\n\n // When a viewport contains multiple subviewports (e.g. repeated web mercator map),\n // this is only done once for the parent viewport\n /* Resolve the parameters needed to draw each layer */\n protected _getDrawLayerParams(\n viewport: Viewport,\n {\n layers,\n pass,\n isPicking = false,\n layerFilter,\n cullRect,\n effects,\n shaderModuleProps\n }: LayersPassRenderOptions,\n /** Internal flag, true if only used to determine whether each layer should be drawn */\n evaluateShouldDrawOnly: boolean = false\n ): DrawLayerParameters[] {\n const drawLayerParams: DrawLayerParameters[] = [];\n const indexResolver = layerIndexResolver(this._lastRenderIndex + 1);\n const drawContext: FilterContext = {\n layer: layers[0],\n viewport,\n isPicking,\n renderPass: pass,\n cullRect\n };\n const layerFilterCache = {};\n for (let layerIndex = 0; layerIndex < layers.length; layerIndex++) {\n const layer = layers[layerIndex];\n // Check if we should draw layer\n const shouldDrawLayer = this._shouldDrawLayer(\n layer,\n drawContext,\n layerFilter,\n layerFilterCache\n );\n\n const layerParam = {shouldDrawLayer} as DrawLayerParameters;\n\n if (shouldDrawLayer && !evaluateShouldDrawOnly) {\n layerParam.shouldDrawLayer = true;\n\n // This is the \"logical\" index for ordering this layer in the stack\n // used to calculate polygon offsets\n // It can be the same as another layer\n layerParam.layerRenderIndex = indexResolver(layer, shouldDrawLayer);\n\n layerParam.shaderModuleProps = this._getShaderModuleProps(\n layer,\n effects,\n pass,\n shaderModuleProps\n );\n layerParam.layerParameters = {\n ...layer.context.deck?.props.parameters,\n ...this.getLayerParameters(layer, layerIndex, viewport)\n };\n }\n\n drawLayerParams[layerIndex] = layerParam;\n }\n return drawLayerParams;\n }\n\n // Draws a list of layers in one viewport\n // TODO - when picking we could completely skip rendering viewports that dont\n // intersect with the picking rect\n /* eslint-disable max-depth, max-statements */\n private _drawLayersInViewport(\n renderPass: RenderPass,\n {layers, shaderModuleProps: globalModuleParameters, pass, target, viewport, view},\n drawLayerParams: DrawLayerParameters[]\n ): RenderStats {\n const glViewport = getGLViewport(this.device, {\n shaderModuleProps: globalModuleParameters,\n target,\n viewport\n });\n\n if (view && view.props.clear) {\n const clearOpts = view.props.clear === true ? {color: true, depth: true} : view.props.clear;\n const clearRenderPass = this.device.beginRenderPass({\n framebuffer: target,\n parameters: {\n viewport: glViewport,\n scissorRect: glViewport\n },\n clearColor: clearOpts.color ? [0, 0, 0, 0] : false,\n clearDepth: clearOpts.depth ? 1 : false\n });\n clearRenderPass.end();\n }\n\n // render layers in normal colors\n const renderStatus = {\n totalCount: layers.length,\n visibleCount: 0,\n compositeCount: 0,\n pickableCount: 0\n };\n\n renderPass.setParameters({viewport: glViewport});\n\n // render layers in normal colors\n for (let layerIndex = 0; layerIndex < layers.length; layerIndex++) {\n const layer = layers[layerIndex] as Layer;\n const drawLayerParameters = drawLayerParams[layerIndex];\n const {shouldDrawLayer} = drawLayerParameters;\n\n // Calculate stats\n if (shouldDrawLayer && layer.props.pickable) {\n renderStatus.pickableCount++;\n }\n if (layer.isComposite) {\n renderStatus.compositeCount++;\n }\n if (layer.isDrawable && drawLayerParameters.shouldDrawLayer) {\n const {layerRenderIndex, shaderModuleProps, layerParameters} = drawLayerParameters;\n // Draw the layer\n renderStatus.visibleCount++;\n\n this._lastRenderIndex = Math.max(this._lastRenderIndex, layerRenderIndex);\n\n // overwrite layer.context.viewport with the sub viewport\n if (shaderModuleProps.project) {\n shaderModuleProps.project.viewport = viewport;\n }\n\n // TODO v9 - we are sending renderPass both as a parameter and through the context.\n // Long-term, it is likely better not to have user defined layer methods have to access\n // the \"global\" layer context.\n layer.context.renderPass = renderPass;\n\n try {\n layer._drawLayer({\n renderPass,\n shaderModuleProps,\n uniforms: {layerIndex: layerRenderIndex},\n parameters: layerParameters\n });\n } catch (err) {\n layer.raiseError(err as Error, `drawing ${layer} to ${pass}`);\n }\n }\n }\n\n return renderStatus;\n }\n /* eslint-enable max-depth, max-statements */\n\n /* Methods for subclass overrides */\n shouldDrawLayer(layer: Layer): boolean {\n return true;\n }\n\n protected getShaderModuleProps(\n layer: Layer,\n effects: Effect[] | undefined,\n otherShaderModuleProps: Record\n ): any {\n return null;\n }\n\n protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): Parameters {\n return layer.props.parameters;\n }\n\n /* Private */\n private _shouldDrawLayer(\n layer: Layer,\n drawContext: FilterContext,\n layerFilter: ((params: FilterContext) => boolean) | undefined | null,\n layerFilterCache: Record\n ) {\n const shouldDrawLayer = layer.props.visible && this.shouldDrawLayer(layer);\n\n if (!shouldDrawLayer) {\n return false;\n }\n\n drawContext.layer = layer;\n\n let parent = layer.parent;\n while (parent) {\n // @ts-ignore\n if (!parent.props.visible || !parent.filterSubLayer(drawContext)) {\n return false;\n }\n drawContext.layer = parent;\n parent = parent.parent;\n }\n\n if (layerFilter) {\n const rootLayerId = drawContext.layer.id;\n if (!(rootLayerId in layerFilterCache)) {\n layerFilterCache[rootLayerId] = layerFilter(drawContext);\n }\n if (!layerFilterCache[rootLayerId]) {\n return false;\n }\n }\n\n // If a layer is drawn, update its viewportChanged flag\n layer.activateViewport(drawContext.viewport);\n\n return true;\n }\n\n private _getShaderModuleProps(\n layer: Layer,\n effects: Effect[] | undefined,\n pass: string,\n overrides: any\n ): any {\n // @ts-expect-error TODO - assuming WebGL context\n const devicePixelRatio = this.device.canvasContext.cssToDeviceRatio();\n const layerProps = layer.internalState?.propsInTransition || layer.props;\n\n const shaderModuleProps = {\n layer: layerProps,\n picking: {\n isActive: false\n } satisfies PickingProps,\n project: {\n viewport: layer.context.viewport,\n devicePixelRatio,\n modelMatrix: layerProps.modelMatrix,\n coordinateSystem: layerProps.coordinateSystem,\n coordinateOrigin: layerProps.coordinateOrigin,\n autoWrapLongitude: layer.wrapLongitude\n } satisfies ProjectProps\n };\n\n if (effects) {\n for (const effect of effects) {\n mergeModuleParameters(\n shaderModuleProps,\n effect.getShaderModuleProps?.(layer, shaderModuleProps)\n );\n }\n }\n\n return mergeModuleParameters(\n shaderModuleProps,\n this.getShaderModuleProps(layer, effects, shaderModuleProps),\n overrides\n );\n }\n}\n\n// If the _index prop is defined, return a layer index that's relative to its parent\n// Otherwise return the index of the layer among all rendered layers\n// This is done recursively, i.e. if the user overrides a layer's default index,\n// all its descendants will be resolved relative to that index.\n// This implementation assumes that parent layers always appear before its children\n// which is true if the layer array comes from the LayerManager\nexport function layerIndexResolver(\n startIndex: number = 0,\n layerIndices: Record = {}\n): (layer: Layer, isDrawn: boolean) => number {\n const resolvers = {};\n\n const resolveLayerIndex = (layer, isDrawn) => {\n const indexOverride = layer.props._offset;\n const layerId = layer.id;\n const parentId = layer.parent && layer.parent.id;\n\n let index;\n\n if (parentId && !(parentId in layerIndices)) {\n // Populate layerIndices with the parent layer's index\n resolveLayerIndex(layer.parent, false);\n }\n\n if (parentId in resolvers) {\n const resolver = (resolvers[parentId] =\n resolvers[parentId] || layerIndexResolver(layerIndices[parentId], layerIndices));\n index = resolver(layer, isDrawn);\n resolvers[layerId] = resolver;\n } else if (Number.isFinite(indexOverride)) {\n index = indexOverride + (layerIndices[parentId] || 0);\n // Mark layer as needing its own resolver\n // We don't actually create it until it's used for the first time\n resolvers[layerId] = null;\n } else {\n index = startIndex;\n }\n\n if (isDrawn && index >= startIndex) {\n startIndex = index + 1;\n }\n\n layerIndices[layerId] = index;\n return index;\n };\n return resolveLayerIndex;\n}\n\n// Convert viewport top-left CSS coordinates to bottom up WebGL coordinates\nfunction getGLViewport(\n device: Device,\n {\n shaderModuleProps,\n target,\n viewport\n }: {\n shaderModuleProps: any;\n target?: Framebuffer;\n viewport: Viewport;\n }\n): [number, number, number, number] {\n const pixelRatio =\n shaderModuleProps?.project?.devicePixelRatio ??\n // @ts-expect-error TODO - assuming WebGL context\n device.canvasContext.cssToDeviceRatio();\n\n // Default framebuffer is used when writing to canvas\n // @ts-expect-error TODO - assuming WebGL context\n const [, drawingBufferHeight] = device.canvasContext.getDrawingBufferSize();\n const height = target ? target.height : drawingBufferHeight;\n\n // Convert viewport top-left CSS coordinates to bottom up WebGL coordinates\n const dimensions = viewport;\n return [\n dimensions.x * pixelRatio,\n height - (dimensions.y + dimensions.height) * pixelRatio,\n dimensions.width * pixelRatio,\n dimensions.height * pixelRatio\n ];\n}\n\nfunction mergeModuleParameters(\n target: Record,\n ...sources: Record[]\n): Record {\n for (const source of sources) {\n if (source) {\n for (const key in source) {\n if (target[key]) {\n Object.assign(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n }\n }\n return target;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Device, Framebuffer, Parameters, Texture} from '@luma.gl/core';\nimport type Layer from '../lib/layer';\nimport type Viewport from '../viewports/viewport';\nimport LayersPass from './layers-pass';\n\nexport default class ShadowPass extends LayersPass {\n fbo: Framebuffer;\n\n constructor(\n device: Device,\n props?: {\n id;\n }\n ) {\n super(device, props);\n\n // The shadowMap texture\n const shadowMap = device.createTexture({\n format: 'rgba8unorm',\n width: 1,\n height: 1,\n sampler: {\n minFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n },\n mipmaps: true\n });\n\n const depthBuffer = device.createTexture({\n format: 'depth16unorm',\n width: 1,\n height: 1,\n mipmaps: false\n });\n\n this.fbo = device.createFramebuffer({\n id: 'shadowmap',\n width: 1,\n height: 1,\n colorAttachments: [shadowMap],\n // Depth attachment has to be specified for depth test to work\n depthStencilAttachment: depthBuffer\n });\n }\n\n delete() {\n if (this.fbo) {\n this.fbo.destroy();\n this.fbo = null!;\n }\n }\n\n getShadowMap(): Texture {\n return this.fbo.colorAttachments[0].texture;\n }\n\n render(params) {\n const target = this.fbo;\n\n // @ts-expect-error TODO - assuming WebGL context\n const pixelRatio = this.device.canvasContext.cssToDeviceRatio();\n\n const viewport = params.viewports[0];\n const width = viewport.width * pixelRatio;\n const height = viewport.height * pixelRatio;\n const clearColor = [1, 1, 1, 1];\n if (width !== target.width || height !== target.height) {\n target.resize({width, height});\n }\n\n super.render({...params, clearColor, target, pass: 'shadow'});\n }\n\n protected getLayerParameters(\n layer: Layer<{}>,\n layerIndex: number,\n viewport: Viewport\n ): Parameters {\n return {\n ...layer.props.parameters,\n blend: false,\n depthWriteEnabled: true,\n depthCompare: 'less-equal'\n };\n }\n\n shouldDrawLayer(layer) {\n return layer.props.shadowEnabled !== false;\n }\n\n getShaderModuleProps(layer: Layer, effects: any, otherShaderModuleProps: Record) {\n return {\n shadow: {\n project: otherShaderModuleProps.project,\n drawToShadowMap: true\n }\n };\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {TypedArray, TypedArrayConstructor} from '../types/types';\n\nexport type TypedArrayManagerOptions = {\n overAlloc?: number;\n poolSize?: number;\n};\n\nexport class TypedArrayManager {\n private _pool: ArrayBuffer[] = [];\n opts: {\n overAlloc: number;\n poolSize: number;\n } = {overAlloc: 2, poolSize: 100};\n\n constructor(options: TypedArrayManagerOptions = {}) {\n this.setOptions(options);\n }\n\n setOptions(options: TypedArrayManagerOptions) {\n Object.assign(this.opts, options);\n }\n\n allocate(\n typedArray: T | null | undefined,\n count: number,\n {\n size = 1,\n type,\n padding = 0,\n copy = false,\n initialize = false,\n maxCount\n }: {\n size?: number;\n type?: TypedArrayConstructor;\n padding?: number;\n copy?: boolean;\n initialize?: boolean;\n maxCount?: number;\n }\n ): T {\n const Type =\n type || (typedArray && (typedArray.constructor as TypedArrayConstructor)) || Float32Array;\n\n const newSize = count * size + padding;\n if (ArrayBuffer.isView(typedArray)) {\n if (newSize <= typedArray.length) {\n return typedArray;\n }\n if (newSize * typedArray.BYTES_PER_ELEMENT <= typedArray.buffer.byteLength) {\n return new Type(typedArray.buffer, 0, newSize) as T;\n }\n }\n\n let maxSize: number = Infinity;\n if (maxCount) {\n maxSize = maxCount * size + padding;\n }\n\n const newArray = this._allocate(Type, newSize, initialize, maxSize);\n\n if (typedArray && copy) {\n newArray.set(typedArray);\n } else if (!initialize) {\n // Hack - always initialize the first 4 elements. NaNs crash the Attribute validation\n newArray.fill(0, 0, 4);\n }\n\n this._release(typedArray);\n return newArray as T;\n }\n\n release(typedArray: TypedArray | null | undefined) {\n this._release(typedArray);\n }\n\n private _allocate(\n Type: TypedArrayConstructor,\n size: number,\n initialize: boolean,\n maxSize: number\n ): TypedArray {\n // Allocate at least one element to ensure a valid buffer\n let sizeToAllocate = Math.max(Math.ceil(size * this.opts.overAlloc), 1);\n // Don't over allocate after certain specified number of elements\n if (sizeToAllocate > maxSize) {\n sizeToAllocate = maxSize;\n }\n\n // Check if available in pool\n const pool = this._pool;\n const byteLength = Type.BYTES_PER_ELEMENT * sizeToAllocate;\n const i = pool.findIndex(b => b.byteLength >= byteLength);\n if (i >= 0) {\n // Create a new array using an existing buffer\n const array = new Type(pool.splice(i, 1)[0], 0, sizeToAllocate);\n if (initialize) {\n // Viewing a buffer with a different type may create NaNs\n array.fill(0);\n }\n return array;\n }\n return new Type(sizeToAllocate);\n }\n\n private _release(typedArray: TypedArray | null | undefined): void {\n if (!ArrayBuffer.isView(typedArray)) {\n return;\n }\n const pool = this._pool;\n const {buffer} = typedArray;\n // Save the buffer of the released array into the pool\n // Sort buffers by size\n // TODO - implement binary search?\n const {byteLength} = buffer;\n const i = pool.findIndex(b => b.byteLength >= byteLength);\n if (i < 0) {\n pool.push(buffer);\n } else if (i > 0 || pool.length < this.opts.poolSize) {\n pool.splice(i, 0, buffer);\n }\n if (pool.length > this.opts.poolSize) {\n // Drop the smallest one\n pool.shift();\n }\n }\n}\n\nexport default new TypedArrayManager();\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Extensions to math.gl library. Intended to be folded back.\nimport typedArrayManager from './typed-array-manager';\nimport {Vector3, NumericArray} from '@math.gl/core';\n\nimport type {Matrix4} from '@math.gl/core';\n\n// Helper, avoids low-precision 32 bit matrices from gl-matrix mat4.create()\nexport function createMat4(): number[] {\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n}\n\nexport function mod(value: number, divisor: number): number {\n const modulus = value % divisor;\n return modulus < 0 ? divisor + modulus : modulus;\n}\n\n// Extract camera vectors (move to math library?)\nexport function getCameraPosition(\n viewMatrixInverse: Matrix4 | NumericArray\n): [number, number, number] {\n // Read the translation from the inverse view matrix\n return [viewMatrixInverse[12], viewMatrixInverse[13], viewMatrixInverse[14]];\n}\n\nexport type FrustumPlane = {\n distance: number;\n normal: Vector3;\n};\n\n// https://www.gamedevs.org/uploads/fast-extraction-viewing-frustum-planes-from-world-view-projection-matrix.pdf\nexport function getFrustumPlanes(viewProjectionMatrix: Matrix4 | NumericArray): {\n left: FrustumPlane;\n right: FrustumPlane;\n top: FrustumPlane;\n bottom: FrustumPlane;\n near: FrustumPlane;\n far: FrustumPlane;\n} {\n return {\n left: getFrustumPlane(\n viewProjectionMatrix[3] + viewProjectionMatrix[0],\n viewProjectionMatrix[7] + viewProjectionMatrix[4],\n viewProjectionMatrix[11] + viewProjectionMatrix[8],\n viewProjectionMatrix[15] + viewProjectionMatrix[12]\n ),\n right: getFrustumPlane(\n viewProjectionMatrix[3] - viewProjectionMatrix[0],\n viewProjectionMatrix[7] - viewProjectionMatrix[4],\n viewProjectionMatrix[11] - viewProjectionMatrix[8],\n viewProjectionMatrix[15] - viewProjectionMatrix[12]\n ),\n bottom: getFrustumPlane(\n viewProjectionMatrix[3] + viewProjectionMatrix[1],\n viewProjectionMatrix[7] + viewProjectionMatrix[5],\n viewProjectionMatrix[11] + viewProjectionMatrix[9],\n viewProjectionMatrix[15] + viewProjectionMatrix[13]\n ),\n top: getFrustumPlane(\n viewProjectionMatrix[3] - viewProjectionMatrix[1],\n viewProjectionMatrix[7] - viewProjectionMatrix[5],\n viewProjectionMatrix[11] - viewProjectionMatrix[9],\n viewProjectionMatrix[15] - viewProjectionMatrix[13]\n ),\n near: getFrustumPlane(\n viewProjectionMatrix[3] + viewProjectionMatrix[2],\n viewProjectionMatrix[7] + viewProjectionMatrix[6],\n viewProjectionMatrix[11] + viewProjectionMatrix[10],\n viewProjectionMatrix[15] + viewProjectionMatrix[14]\n ),\n far: getFrustumPlane(\n viewProjectionMatrix[3] - viewProjectionMatrix[2],\n viewProjectionMatrix[7] - viewProjectionMatrix[6],\n viewProjectionMatrix[11] - viewProjectionMatrix[10],\n viewProjectionMatrix[15] - viewProjectionMatrix[14]\n )\n };\n}\n\nconst scratchVector = new Vector3();\n\nfunction getFrustumPlane(a: number, b: number, c: number, d: number): FrustumPlane {\n scratchVector.set(a, b, c);\n const L = scratchVector.len();\n return {distance: d / L, normal: new Vector3(-a / L, -b / L, -c / L)};\n}\n\n/**\n * Calculate the low part of a WebGL 64 bit float\n * @param x {number} - the input float number\n * @returns {number} - the lower 32 bit of the number\n */\nexport function fp64LowPart(x: number): number {\n return x - Math.fround(x);\n}\n\nlet scratchArray;\n\n/**\n * Split a Float64Array into a double-length Float32Array\n * @param typedArray\n * @param options\n * @param options.size - per attribute size\n * @param options.startIndex - start index in the source array\n * @param options.endIndex - end index in the source array\n * @returns {} - high part, low part for each attribute:\n [1xHi, 1yHi, 1zHi, 1xLow, 1yLow, 1zLow, 2xHi, ...]\n */\nexport function toDoublePrecisionArray(\n typedArray: Float64Array,\n options: {size?: number; startIndex?: number; endIndex?: number}\n): Float32Array {\n const {size = 1, startIndex = 0} = options;\n\n const endIndex = options.endIndex !== undefined ? options.endIndex : typedArray.length;\n\n const count = (endIndex - startIndex) / size;\n scratchArray = typedArrayManager.allocate(scratchArray, count, {\n type: Float32Array,\n size: size * 2\n });\n\n let sourceIndex = startIndex;\n let targetIndex = 0;\n while (sourceIndex < endIndex) {\n for (let j = 0; j < size; j++) {\n const value = typedArray[sourceIndex++];\n scratchArray[targetIndex + j] = value;\n scratchArray[targetIndex + j + size] = fp64LowPart(value);\n }\n targetIndex += size * 2;\n }\n\n return scratchArray.subarray(0, count * size * 2);\n}\n\ntype LayerBounds = [number[], number[]];\nexport function mergeBounds(boundsList: (LayerBounds | null)[]): LayerBounds | null {\n let mergedBounds: LayerBounds | null = null;\n let isMerged = false;\n\n for (const bounds of boundsList) {\n /* eslint-disable-next-line no-continue */\n if (!bounds) continue;\n if (!mergedBounds) {\n mergedBounds = bounds;\n } else {\n if (!isMerged) {\n // Copy to avoid mutating input bounds\n mergedBounds = [\n [mergedBounds[0][0], mergedBounds[0][1]],\n [mergedBounds[1][0], mergedBounds[1][1]]\n ];\n isMerged = true;\n }\n\n mergedBounds[0][0] = Math.min(mergedBounds[0][0], bounds[0][0]);\n mergedBounds[0][1] = Math.min(mergedBounds[0][1], bounds[0][1]);\n mergedBounds[1][0] = Math.max(mergedBounds[1][0], bounds[1][0]);\n mergedBounds[1][1] = Math.max(mergedBounds[1][1], bounds[1][1]);\n }\n }\n\n return mergedBounds;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport log from '../utils/log';\nimport {createMat4, getCameraPosition, getFrustumPlanes, FrustumPlane} from '../utils/math-utils';\n\nimport {Matrix4, Vector3, equals, clamp, mat4} from '@math.gl/core';\n\nimport {\n getDistanceScales,\n getMeterZoom,\n lngLatToWorld,\n worldToLngLat,\n worldToPixels,\n pixelsToWorld\n} from '@math.gl/web-mercator';\n\nimport {PROJECTION_MODE} from '../lib/constants';\n\nexport type DistanceScales = {\n unitsPerMeter: number[];\n metersPerUnit: number[];\n};\n\nexport type Padding = {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n};\n\nexport type ViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** Longitude in degrees (geospatial only) */\n longitude?: number;\n /** Latitude in degrees (geospatial only) */\n latitude?: number;\n /** Viewport center in world space. If geospatial, refers to meter offsets from lng, lat */\n position?: number[];\n /** Zoom level */\n zoom?: number;\n /** Padding around the viewport, in pixels. */\n padding?: Padding | null;\n distanceScales?: DistanceScales;\n /** Model matrix of viewport center */\n modelMatrix?: number[] | null;\n /** Custom view matrix */\n viewMatrix?: number[];\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** Modifier of viewport scale. Corresponds to the number of pixels per common unit at zoom 0. */\n focalDistance?: number;\n /** Use orthographic projection */\n orthographic?: boolean;\n /** fovy in radians. If supplied, overrides fovy */\n fovyRadians?: number;\n /** fovy in degrees. */\n fovy?: number;\n /** Near plane of the projection matrix */\n near?: number;\n /** Far plane of the projection matrix */\n far?: number;\n};\n\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n\nconst IDENTITY = createMat4();\n\nconst ZERO_VECTOR = [0, 0, 0];\n\nconst DEFAULT_DISTANCE_SCALES: DistanceScales = {\n unitsPerMeter: [1, 1, 1],\n metersPerUnit: [1, 1, 1]\n};\n\n// / Helpers\nfunction createProjectionMatrix({\n width,\n height,\n orthographic,\n fovyRadians,\n focalDistance,\n padding,\n near,\n far\n}: {\n width: number;\n height: number;\n orthographic: boolean;\n fovyRadians: number;\n focalDistance: number;\n padding: Padding | null;\n near: number;\n far: number;\n}) {\n const aspect = width / height;\n const matrix = orthographic\n ? new Matrix4().orthographic({fovy: fovyRadians, aspect, focalDistance, near, far})\n : new Matrix4().perspective({fovy: fovyRadians, aspect, near, far});\n if (padding) {\n const {left = 0, right = 0, top = 0, bottom = 0} = padding;\n const offsetX = clamp((left + width - right) / 2, 0, width) - width / 2;\n const offsetY = clamp((top + height - bottom) / 2, 0, height) - height / 2;\n // pixels to clip space\n matrix[8] -= (offsetX * 2) / width;\n matrix[9] += (offsetY * 2) / height;\n }\n return matrix;\n}\n\n/**\n * Manages coordinate system transformations.\n *\n * Note: The Viewport is immutable in the sense that it only has accessors.\n * A new viewport instance should be created if any parameters have changed.\n */\nexport default class Viewport {\n static displayName = 'Viewport';\n\n /** Init parameters */\n\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n padding?: Padding | null;\n isGeospatial: boolean;\n zoom: number;\n focalDistance: number;\n position: number[];\n modelMatrix: number[] | null;\n\n /** Derived parameters */\n\n // `!` post-fix expression operator asserts that its operand is non-null and non-undefined in contexts\n // where the type checker is unable to conclude that fact.\n\n distanceScales: DistanceScales; /** scale factors between world space and common space */\n scale!: number; /** scale factor, equals 2^zoom */\n center!: number[]; /** viewport center in common space */\n cameraPosition!: number[]; /** Camera position in common space */\n projectionMatrix!: number[];\n viewMatrix!: number[];\n viewMatrixUncentered!: number[];\n viewMatrixInverse!: number[];\n viewProjectionMatrix!: number[];\n pixelProjectionMatrix!: number[];\n pixelUnprojectionMatrix!: number[];\n resolution?: number;\n\n private _frustumPlanes: {[name: string]: FrustumPlane} = {};\n\n // eslint-disable-next-line complexity\n constructor(opts: ViewportOptions = {}) {\n // @ts-ignore\n this.id = opts.id || this.constructor.displayName || 'viewport';\n\n this.x = opts.x || 0;\n this.y = opts.y || 0;\n // Silently allow apps to send in w,h = 0,0\n this.width = opts.width || 1;\n this.height = opts.height || 1;\n this.zoom = opts.zoom || 0;\n this.padding = opts.padding;\n this.distanceScales = opts.distanceScales || DEFAULT_DISTANCE_SCALES;\n this.focalDistance = opts.focalDistance || 1;\n this.position = opts.position || ZERO_VECTOR;\n this.modelMatrix = opts.modelMatrix || null;\n\n const {longitude, latitude} = opts;\n this.isGeospatial = Number.isFinite(latitude) && Number.isFinite(longitude);\n\n this._initProps(opts);\n this._initMatrices(opts);\n\n // Bind methods for easy access\n this.equals = this.equals.bind(this);\n this.project = this.project.bind(this);\n this.unproject = this.unproject.bind(this);\n this.projectPosition = this.projectPosition.bind(this);\n this.unprojectPosition = this.unprojectPosition.bind(this);\n this.projectFlat = this.projectFlat.bind(this);\n this.unprojectFlat = this.unprojectFlat.bind(this);\n }\n\n get subViewports(): Viewport[] | null {\n return null;\n }\n\n get metersPerPixel(): number {\n return this.distanceScales.metersPerUnit[2] / this.scale;\n }\n\n get projectionMode(): number {\n if (this.isGeospatial) {\n return this.zoom < 12\n ? PROJECTION_MODE.WEB_MERCATOR\n : PROJECTION_MODE.WEB_MERCATOR_AUTO_OFFSET;\n }\n return PROJECTION_MODE.IDENTITY;\n }\n\n // Two viewports are equal if width and height are identical, and if\n // their view and projection matrices are (approximately) equal.\n equals(viewport: Viewport): boolean {\n if (!(viewport instanceof Viewport)) {\n return false;\n }\n if (this === viewport) {\n return true;\n }\n\n return (\n viewport.width === this.width &&\n viewport.height === this.height &&\n viewport.scale === this.scale &&\n equals(viewport.projectionMatrix, this.projectionMatrix) &&\n equals(viewport.viewMatrix, this.viewMatrix)\n );\n // TODO - check distance scales?\n }\n\n /**\n * Projects xyz (possibly latitude and longitude) to pixel coordinates in window\n * using viewport projection parameters\n * - [longitude, latitude] to [x, y]\n * - [longitude, latitude, Z] => [x, y, z]\n * Note: By default, returns top-left coordinates for canvas/SVG type render\n *\n * @param {Array} lngLatZ - [lng, lat] or [lng, lat, Z]\n * @param {Object} opts - options\n * @param {Object} opts.topLeft=true - Whether projected coords are top left\n * @return {Array} - [x, y] or [x, y, z] in top left coords\n */\n project(xyz: number[], {topLeft = true}: {topLeft?: boolean} = {}): number[] {\n const worldPosition = this.projectPosition(xyz);\n const coord = worldToPixels(worldPosition, this.pixelProjectionMatrix);\n\n const [x, y] = coord;\n const y2 = topLeft ? y : this.height - y;\n return xyz.length === 2 ? [x, y2] : [x, y2, coord[2]];\n }\n\n /**\n * Unproject pixel coordinates on screen onto world coordinates,\n * (possibly [lon, lat]) on map.\n * - [x, y] => [lng, lat]\n * - [x, y, z] => [lng, lat, Z]\n * @param {Array} xyz -\n * @param {Object} opts - options\n * @param {Object} opts.topLeft=true - Whether origin is top left\n * @return {Array|null} - [lng, lat, Z] or [X, Y, Z]\n */\n unproject(\n xyz: number[],\n {topLeft = true, targetZ}: {topLeft?: boolean; targetZ?: number} = {}\n ): number[] {\n const [x, y, z] = xyz;\n\n const y2 = topLeft ? y : this.height - y;\n const targetZWorld = targetZ && targetZ * this.distanceScales.unitsPerMeter[2];\n const coord = pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix, targetZWorld);\n const [X, Y, Z] = this.unprojectPosition(coord);\n\n if (Number.isFinite(z)) {\n return [X, Y, Z];\n }\n return Number.isFinite(targetZ) ? [X, Y, targetZ as number] : [X, Y];\n }\n\n // NON_LINEAR PROJECTION HOOKS\n // Used for web meractor projection\n\n projectPosition(xyz: number[]): [number, number, number] {\n const [X, Y] = this.projectFlat(xyz);\n const Z = (xyz[2] || 0) * this.distanceScales.unitsPerMeter[2];\n return [X, Y, Z];\n }\n\n unprojectPosition(xyz: number[]): [number, number, number] {\n const [X, Y] = this.unprojectFlat(xyz);\n const Z = (xyz[2] || 0) * this.distanceScales.metersPerUnit[2];\n return [X, Y, Z];\n }\n\n /**\n * Project [lng,lat] on sphere onto [x,y] on 512*512 Mercator Zoom 0 tile.\n * Performs the nonlinear part of the web mercator projection.\n * Remaining projection is done with 4x4 matrices which also handles\n * perspective.\n * @param {Array} lngLat - [lng, lat] coordinates\n * Specifies a point on the sphere to project onto the map.\n * @return {Array} [x,y] coordinates.\n */\n projectFlat(xyz: number[]): [number, number] {\n if (this.isGeospatial) {\n // Shader clamps latitude to +-89.9, see /shaderlib/project/project.glsl.js\n // lngLatToWorld([0, -89.9])[1] = -317.9934163758329\n // lngLatToWorld([0, 89.9])[1] = 829.9934163758271\n const result = lngLatToWorld(xyz);\n result[1] = clamp(result[1], -318, 830);\n return result;\n }\n return xyz as [number, number];\n }\n\n /**\n * Unproject world point [x,y] on map onto {lat, lon} on sphere\n * @param {object|Vector} xy - object with {x,y} members\n * representing point on projected map plane\n * @return {GeoCoordinates} - object with {lat,lon} of point on sphere.\n * Has toArray method if you need a GeoJSON Array.\n * Per cartographic tradition, lat and lon are specified as degrees.\n */\n unprojectFlat(xyz: number[]): [number, number] {\n if (this.isGeospatial) {\n return worldToLngLat(xyz);\n }\n return xyz as [number, number];\n }\n\n /**\n * Get bounds of the current viewport\n * @return {Array} - [minX, minY, maxX, maxY]\n */\n getBounds(options: {z?: number} = {}): [number, number, number, number] {\n const unprojectOption = {targetZ: options.z || 0};\n\n const topLeft = this.unproject([0, 0], unprojectOption);\n const topRight = this.unproject([this.width, 0], unprojectOption);\n const bottomLeft = this.unproject([0, this.height], unprojectOption);\n const bottomRight = this.unproject([this.width, this.height], unprojectOption);\n\n return [\n Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),\n Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]),\n Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]),\n Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1])\n ];\n }\n\n getDistanceScales(coordinateOrigin?: number[]): DistanceScales {\n if (coordinateOrigin && this.isGeospatial) {\n return getDistanceScales({\n longitude: coordinateOrigin[0],\n latitude: coordinateOrigin[1],\n highPrecision: true\n });\n }\n return this.distanceScales;\n }\n\n containsPixel({\n x,\n y,\n width = 1,\n height = 1\n }: {\n x: number;\n y: number;\n width?: number;\n height?: number;\n }): boolean {\n return (\n x < this.x + this.width &&\n this.x < x + width &&\n y < this.y + this.height &&\n this.y < y + height\n );\n }\n\n // Extract frustum planes in common space\n getFrustumPlanes(): {\n left: FrustumPlane;\n right: FrustumPlane;\n bottom: FrustumPlane;\n top: FrustumPlane;\n near: FrustumPlane;\n far: FrustumPlane;\n } {\n if (this._frustumPlanes.near) {\n // @ts-ignore\n return this._frustumPlanes;\n }\n\n Object.assign(this._frustumPlanes, getFrustumPlanes(this.viewProjectionMatrix));\n\n // @ts-ignore\n return this._frustumPlanes;\n }\n\n // EXPERIMENTAL METHODS\n\n /**\n * Needed by panning and linear transition\n * Pan the viewport to place a given world coordinate at screen point [x, y]\n *\n * @param {Array} coords - world coordinates\n * @param {Array} pixel - [x,y] coordinates on screen\n * @return {Object} props of the new viewport\n */\n panByPosition(coords: number[], pixel: number[]): any {\n return null;\n }\n\n // INTERNAL METHODS\n\n /* eslint-disable complexity, max-statements */\n private _initProps(opts: ViewportOptions) {\n const longitude = opts.longitude as number;\n const latitude = opts.latitude as number;\n\n if (this.isGeospatial) {\n if (!Number.isFinite(opts.zoom)) {\n this.zoom = getMeterZoom({latitude}) + Math.log2(this.focalDistance);\n }\n this.distanceScales = opts.distanceScales || getDistanceScales({latitude, longitude});\n }\n const scale = Math.pow(2, this.zoom);\n this.scale = scale;\n\n const {position, modelMatrix} = opts;\n let meterOffset: number[] = ZERO_VECTOR;\n if (position) {\n meterOffset = modelMatrix\n ? (new Matrix4(modelMatrix).transformAsVector(position, []) as number[])\n : position;\n }\n\n if (this.isGeospatial) {\n // Determine camera center in common space\n const center = this.projectPosition([longitude, latitude, 0]);\n\n this.center = new Vector3(meterOffset)\n // Convert to pixels in current zoom\n .scale(this.distanceScales.unitsPerMeter)\n .add(center);\n } else {\n this.center = this.projectPosition(meterOffset);\n }\n }\n /* eslint-enable complexity, max-statements */\n\n private _initMatrices(opts: ViewportOptions) {\n const {\n // View matrix\n viewMatrix = IDENTITY,\n // Projection matrix\n projectionMatrix = null,\n\n // Projection matrix parameters, used if projectionMatrix not supplied\n orthographic = false,\n fovyRadians,\n fovy = 75,\n near = 0.1, // Distance of near clipping plane\n far = 1000, // Distance of far clipping plane\n padding = null, // Center offset in pixels\n focalDistance = 1\n } = opts;\n\n this.viewMatrixUncentered = viewMatrix;\n // Make a centered version of the matrix for projection modes without an offset\n this.viewMatrix = new Matrix4()\n // Apply the uncentered view matrix\n .multiplyRight(viewMatrix)\n // And center it\n .translate(new Vector3(this.center).negate());\n\n this.projectionMatrix =\n projectionMatrix ||\n createProjectionMatrix({\n width: this.width,\n height: this.height,\n orthographic,\n fovyRadians: fovyRadians || fovy * DEGREES_TO_RADIANS,\n focalDistance,\n padding,\n near,\n far\n });\n\n // Note: As usual, matrix operations should be applied in \"reverse\" order\n // since vectors will be multiplied in from the right during transformation\n const vpm = createMat4();\n mat4.multiply(vpm, vpm, this.projectionMatrix);\n mat4.multiply(vpm, vpm, this.viewMatrix);\n this.viewProjectionMatrix = vpm;\n\n // console.log('VPM', this.viewMatrix, this.projectionMatrix, this.viewProjectionMatrix);\n\n // Calculate inverse view matrix\n this.viewMatrixInverse = mat4.invert([], this.viewMatrix) || this.viewMatrix;\n\n // Decompose camera parameters\n this.cameraPosition = getCameraPosition(this.viewMatrixInverse);\n\n /*\n * Builds matrices that converts preprojected lngLats to screen pixels\n * and vice versa.\n * Note: Currently returns bottom-left coordinates!\n * Note: Starts with the GL projection matrix and adds steps to the\n * scale and translate that matrix onto the window.\n * Note: WebGL controls clip space to screen projection with gl.viewport\n * and does not need this step.\n */\n\n // matrix for conversion from world location to screen (pixel) coordinates\n const viewportMatrix = createMat4(); // matrix from NDC to viewport.\n const pixelProjectionMatrix = createMat4(); // matrix from world space to viewport.\n mat4.scale(viewportMatrix, viewportMatrix, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(viewportMatrix, viewportMatrix, [1, -1, 0]);\n mat4.multiply(pixelProjectionMatrix, viewportMatrix, this.viewProjectionMatrix);\n this.pixelProjectionMatrix = pixelProjectionMatrix;\n\n this.pixelUnprojectionMatrix = mat4.invert(createMat4(), this.pixelProjectionMatrix);\n if (!this.pixelUnprojectionMatrix) {\n log.warn('Pixel project matrix not invertible')();\n // throw new Error('Pixel project matrix not invertible');\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// View and Projection Matrix calculations for mapbox-js style\n// map view properties\nimport Viewport from './viewport';\n\nimport {\n pixelsToWorld,\n getViewMatrix,\n addMetersToLngLat,\n unitsPerMeter,\n getProjectionParameters,\n altitudeToFovy,\n fovyToAltitude,\n fitBounds,\n getBounds\n} from '@math.gl/web-mercator';\nimport {Padding} from './viewport';\n\nimport {Matrix4, clamp, vec2} from '@math.gl/core';\n\nexport type WebMercatorViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** Longitude in degrees */\n longitude?: number;\n /** Latitude in degrees */\n latitude?: number;\n /** Tilt of the camera in degrees */\n pitch?: number;\n /** Heading of the camera in degrees */\n bearing?: number;\n /** Camera altitude relative to the viewport height, legacy property used to control the FOV. Default `1.5` */\n altitude?: number;\n /** Camera fovy in degrees. If provided, overrides `altitude` */\n fovy?: number;\n /** Viewport center in world space. If geospatial, refers to meter offsets from lng, lat */\n position?: number[];\n /** Zoom level */\n zoom?: number;\n /** Padding around the viewport, in pixels. */\n padding?: Padding | null;\n /** Model matrix of viewport center */\n modelMatrix?: number[] | null;\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** Use orthographic projection */\n orthographic?: boolean;\n /** Scaler for the near plane, 1 unit equals to the height of the viewport. Default `0.1` */\n nearZMultiplier?: number;\n /** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1.01` */\n farZMultiplier?: number;\n /** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */\n nearZ?: number;\n /** Optionally override the far plane position. `farZMultiplier` is ignored if `farZ` is supplied. */\n farZ?: number;\n /** Render multiple copies of the world */\n repeat?: boolean;\n /** Internal use */\n worldOffset?: number;\n /** @deprecated Revert to approximated meter size calculation prior to v8.5 */\n legacyMeterSizes?: boolean;\n};\n\n/**\n * Manages transformations to/from WGS84 coordinates using the Web Mercator Projection.\n */\nexport default class WebMercatorViewport extends Viewport {\n static displayName = 'WebMercatorViewport';\n\n longitude: number;\n latitude: number;\n pitch: number;\n bearing: number;\n altitude: number;\n fovy: number;\n orthographic: boolean;\n\n /** Each sub viewport renders one copy of the world if repeat:true. The list is generated and cached on first request. */\n private _subViewports: WebMercatorViewport[] | null;\n /** @deprecated Revert to approximated meter size calculation prior to v8.5 */\n private _pseudoMeters: boolean;\n\n /* eslint-disable complexity, max-statements */\n constructor(opts: WebMercatorViewportOptions = {}) {\n const {\n latitude = 0,\n longitude = 0,\n zoom = 0,\n pitch = 0,\n bearing = 0,\n nearZMultiplier = 0.1,\n farZMultiplier = 1.01,\n nearZ,\n farZ,\n orthographic = false,\n projectionMatrix,\n\n repeat = false,\n worldOffset = 0,\n position,\n padding,\n\n // backward compatibility\n // TODO: remove in v9\n legacyMeterSizes = false\n } = opts;\n\n let {width, height, altitude = 1.5} = opts;\n const scale = Math.pow(2, zoom);\n\n // Silently allow apps to send in 0,0 to facilitate isomorphic render etc\n width = width || 1;\n height = height || 1;\n\n let fovy;\n let projectionParameters: any = null;\n if (projectionMatrix) {\n altitude = projectionMatrix[5] / 2;\n fovy = altitudeToFovy(altitude);\n } else {\n if (opts.fovy) {\n fovy = opts.fovy;\n altitude = fovyToAltitude(fovy);\n } else {\n fovy = altitudeToFovy(altitude);\n }\n\n let offset: [number, number] | undefined;\n if (padding) {\n const {top = 0, bottom = 0} = padding;\n offset = [0, clamp((top + height - bottom) / 2, 0, height) - height / 2];\n }\n\n projectionParameters = getProjectionParameters({\n width,\n height,\n scale,\n center: position && [0, 0, position[2] * unitsPerMeter(latitude)],\n offset,\n pitch,\n fovy,\n nearZMultiplier,\n farZMultiplier\n });\n\n if (Number.isFinite(nearZ)) {\n projectionParameters.near = nearZ;\n }\n if (Number.isFinite(farZ)) {\n projectionParameters.far = farZ;\n }\n }\n\n // The uncentered matrix allows us two move the center addition to the\n // shader (cheap) which gives a coordinate system that has its center in\n // the layer's center position. This makes rotations and other modelMatrx\n // transforms much more useful.\n let viewMatrixUncentered = getViewMatrix({\n height,\n pitch,\n bearing,\n scale,\n altitude\n });\n\n if (worldOffset) {\n const viewOffset = new Matrix4().translate([512 * worldOffset, 0, 0]);\n viewMatrixUncentered = viewOffset.multiplyLeft(viewMatrixUncentered);\n }\n\n super({\n ...opts,\n // x, y,\n width,\n height,\n\n // view matrix\n viewMatrix: viewMatrixUncentered,\n longitude,\n latitude,\n zoom,\n\n // projection matrix parameters\n ...projectionParameters,\n fovy,\n focalDistance: altitude\n });\n\n // Save parameters\n this.latitude = latitude;\n this.longitude = longitude;\n this.zoom = zoom;\n this.pitch = pitch;\n this.bearing = bearing;\n this.altitude = altitude;\n this.fovy = fovy;\n\n this.orthographic = orthographic;\n\n this._subViewports = repeat ? [] : null;\n this._pseudoMeters = legacyMeterSizes;\n\n Object.freeze(this);\n }\n /* eslint-enable complexity, max-statements */\n\n get subViewports(): WebMercatorViewport[] | null {\n if (this._subViewports && !this._subViewports.length) {\n // Cache sub viewports so that we only calculate them once\n const bounds = this.getBounds();\n\n const minOffset = Math.floor((bounds[0] + 180) / 360);\n const maxOffset = Math.ceil((bounds[2] - 180) / 360);\n\n for (let x = minOffset; x <= maxOffset; x++) {\n const offsetViewport = x\n ? new WebMercatorViewport({\n ...this,\n worldOffset: x\n })\n : this;\n this._subViewports.push(offsetViewport);\n }\n }\n return this._subViewports;\n }\n\n projectPosition(xyz: number[]): [number, number, number] {\n if (this._pseudoMeters) {\n // Backward compatibility\n return super.projectPosition(xyz);\n }\n const [X, Y] = this.projectFlat(xyz);\n const Z = (xyz[2] || 0) * unitsPerMeter(xyz[1]);\n return [X, Y, Z];\n }\n\n unprojectPosition(xyz: number[]): [number, number, number] {\n if (this._pseudoMeters) {\n // Backward compatibility\n return super.unprojectPosition(xyz);\n }\n const [X, Y] = this.unprojectFlat(xyz);\n const Z = (xyz[2] || 0) / unitsPerMeter(Y);\n return [X, Y, Z];\n }\n\n /**\n * Add a meter delta to a base lnglat coordinate, returning a new lnglat array\n *\n * Note: Uses simple linear approximation around the viewport center\n * Error increases with size of offset (roughly 1% per 100km)\n *\n * @param {[Number,Number]|[Number,Number,Number]) lngLatZ - base coordinate\n * @param {[Number,Number]|[Number,Number,Number]) xyz - array of meter deltas\n * @return {[Number,Number]|[Number,Number,Number]) array of [lng,lat,z] deltas\n */\n addMetersToLngLat(lngLatZ: number[], xyz: number[]): number[] {\n return addMetersToLngLat(lngLatZ, xyz);\n }\n\n panByPosition(coords: number[], pixel: number[]): WebMercatorViewportOptions {\n const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);\n const toLocation = this.projectFlat(coords);\n\n const translate = vec2.add([], toLocation, vec2.negate([], fromLocation));\n const newCenter = vec2.add([], this.center, translate);\n\n const [longitude, latitude] = this.unprojectFlat(newCenter);\n return {longitude, latitude};\n }\n\n getBounds(options: {z?: number} = {}): [number, number, number, number] {\n // @ts-ignore\n const corners = getBounds(this, options.z || 0);\n\n return [\n Math.min(corners[0][0], corners[1][0], corners[2][0], corners[3][0]),\n Math.min(corners[0][1], corners[1][1], corners[2][1], corners[3][1]),\n Math.max(corners[0][0], corners[1][0], corners[2][0], corners[3][0]),\n Math.max(corners[0][1], corners[1][1], corners[2][1], corners[3][1])\n ];\n }\n\n /**\n * Returns a new viewport that fit around the given rectangle.\n * Only supports non-perspective mode.\n */\n fitBounds(\n /** [[lon, lat], [lon, lat]] */\n bounds: [[number, number], [number, number]],\n options: {\n /** If not supplied, will use the current width of the viewport (default `1`) */\n width?: number;\n /** If not supplied, will use the current height of the viewport (default `1`) */\n height?: number;\n /** In degrees, 0.01 would be about 1000 meters */\n minExtent?: number;\n /** Max zoom level */\n maxZoom?: number;\n /** Extra padding in pixels */\n padding?: number | Required;\n /** Center shift in pixels */\n offset?: number[];\n } = {}\n ) {\n const {width, height} = this;\n const {longitude, latitude, zoom} = fitBounds({width, height, bounds, ...options});\n return new WebMercatorViewport({width, height, longitude, latitude, zoom});\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * Projection utils\n * TODO: move to Viewport class?\n */\nimport {COORDINATE_SYSTEM} from '../../lib/constants';\nimport {getOffsetOrigin} from './viewport-uniforms';\nimport WebMercatorViewport from '../../viewports/web-mercator-viewport';\n\nimport {vec3, vec4} from '@math.gl/core';\nimport {addMetersToLngLat} from '@math.gl/web-mercator';\n\nimport type {CoordinateSystem} from '../../lib/constants';\nimport type Viewport from '../../viewports/viewport';\nimport type {NumericArray} from '../../types/types';\n\nconst DEFAULT_COORDINATE_ORIGIN = [0, 0, 0];\n\n// In project.glsl, offset modes calculate z differently from LNG_LAT mode.\n// offset modes apply the y adjustment (unitsPerMeter2) when projecting z\n// LNG_LAT mode only use the linear scale.\nfunction lngLatZToWorldPosition(\n lngLatZ: [number, number, number],\n viewport: Viewport,\n offsetMode: boolean = false\n): [number, number, number] {\n const p = viewport.projectPosition(lngLatZ);\n\n // TODO - avoid using instanceof\n if (offsetMode && viewport instanceof WebMercatorViewport) {\n const [longitude, latitude, z = 0] = lngLatZ;\n const distanceScales = viewport.getDistanceScales([longitude, latitude]);\n p[2] = z * distanceScales.unitsPerMeter[2];\n }\n return p;\n}\n\nfunction normalizeParameters(opts: {\n viewport: Viewport;\n coordinateSystem: CoordinateSystem;\n coordinateOrigin: [number, number, number];\n modelMatrix?: NumericArray | null;\n fromCoordinateSystem?: CoordinateSystem;\n fromCoordinateOrigin?: [number, number, number];\n}): {\n viewport: Viewport;\n coordinateSystem: CoordinateSystem;\n coordinateOrigin: [number, number, number];\n modelMatrix?: NumericArray | null;\n fromCoordinateSystem: CoordinateSystem;\n fromCoordinateOrigin: [number, number, number];\n} {\n const {viewport, modelMatrix, coordinateOrigin} = opts;\n let {coordinateSystem, fromCoordinateSystem, fromCoordinateOrigin} = opts;\n\n if (coordinateSystem === COORDINATE_SYSTEM.DEFAULT) {\n coordinateSystem = viewport.isGeospatial\n ? COORDINATE_SYSTEM.LNGLAT\n : COORDINATE_SYSTEM.CARTESIAN;\n }\n\n if (fromCoordinateSystem === undefined) {\n fromCoordinateSystem = coordinateSystem;\n }\n if (fromCoordinateOrigin === undefined) {\n fromCoordinateOrigin = coordinateOrigin;\n }\n\n return {\n viewport,\n coordinateSystem,\n coordinateOrigin,\n modelMatrix,\n fromCoordinateSystem,\n fromCoordinateOrigin\n };\n}\n\n/** Get the common space position from world coordinates in the given coordinate system */\nexport function getWorldPosition(\n position: number[],\n {\n viewport,\n modelMatrix,\n coordinateSystem,\n coordinateOrigin,\n offsetMode\n }: {\n viewport: Viewport;\n modelMatrix?: NumericArray | null;\n coordinateSystem: CoordinateSystem;\n coordinateOrigin: [number, number, number];\n offsetMode?: boolean;\n }\n): [number, number, number] {\n let [x, y, z = 0] = position;\n\n if (modelMatrix) {\n [x, y, z] = vec4.transformMat4([], [x, y, z, 1.0], modelMatrix);\n }\n\n switch (coordinateSystem) {\n case COORDINATE_SYSTEM.LNGLAT:\n return lngLatZToWorldPosition([x, y, z], viewport, offsetMode);\n\n case COORDINATE_SYSTEM.LNGLAT_OFFSETS:\n return lngLatZToWorldPosition(\n [x + coordinateOrigin[0], y + coordinateOrigin[1], z + (coordinateOrigin[2] || 0)],\n viewport,\n offsetMode\n );\n\n case COORDINATE_SYSTEM.METER_OFFSETS:\n return lngLatZToWorldPosition(\n addMetersToLngLat(coordinateOrigin, [x, y, z]) as [number, number, number],\n viewport,\n offsetMode\n );\n\n case COORDINATE_SYSTEM.CARTESIAN:\n default:\n return viewport.isGeospatial\n ? [x + coordinateOrigin[0], y + coordinateOrigin[1], z + coordinateOrigin[2]]\n : viewport.projectPosition([x, y, z]);\n }\n}\n\n/**\n * Equivalent to project_position in project.glsl\n * projects a user supplied position to world position directly with or without\n * a reference coordinate system\n */\nexport function projectPosition(\n position: number[],\n params: {\n /** The current viewport */\n viewport: Viewport;\n /** The reference coordinate system used to align world position */\n coordinateSystem: CoordinateSystem;\n /** The reference coordinate origin used to align world position */\n coordinateOrigin: [number, number, number];\n /** The model matrix of the supplied position */\n modelMatrix?: NumericArray | null;\n /** The coordinate system that the supplied position is in. Default to the same as `coordinateSystem`. */\n fromCoordinateSystem?: CoordinateSystem;\n /** The coordinate origin that the supplied position is in. Default to the same as `coordinateOrigin`. */\n fromCoordinateOrigin?: [number, number, number];\n /** Whether to apply offset mode automatically as does the project shader module.\n * Offset mode places the origin of the common space at the given viewport's center. It is used in some use cases\n * to improve precision in the vertex shader due to the fp32 float limitation.\n * Use `autoOffset:false` if the returned position should not be dependent on the current viewport.\n * Default `true` */\n autoOffset?: boolean;\n }\n): [number, number, number] {\n const {\n viewport,\n coordinateSystem,\n coordinateOrigin,\n modelMatrix,\n fromCoordinateSystem,\n fromCoordinateOrigin\n } = normalizeParameters(params);\n const {autoOffset = true} = params;\n\n const {\n geospatialOrigin = DEFAULT_COORDINATE_ORIGIN,\n shaderCoordinateOrigin = DEFAULT_COORDINATE_ORIGIN,\n offsetMode = false\n } = autoOffset ? getOffsetOrigin(viewport, coordinateSystem, coordinateOrigin) : {};\n\n const worldPosition = getWorldPosition(position, {\n viewport,\n modelMatrix,\n coordinateSystem: fromCoordinateSystem,\n coordinateOrigin: fromCoordinateOrigin,\n offsetMode\n });\n\n if (offsetMode) {\n const positionCommonSpace = viewport.projectPosition(\n geospatialOrigin || shaderCoordinateOrigin\n );\n vec3.sub(worldPosition, worldPosition, positionCommonSpace);\n }\n\n return worldPosition;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {projectPosition} from '../../shaderlib/project/project-functions';\nimport {COORDINATE_SYSTEM} from '../../lib/constants';\n\nimport type Layer from '../../lib/layer';\n\nconst DEFAULT_LIGHT_COLOR = [255, 255, 255] as [number, number, number];\nconst DEFAULT_LIGHT_INTENSITY = 1.0;\nconst DEFAULT_ATTENUATION = [1, 0, 0] as [number, number, number];\nconst DEFAULT_LIGHT_POSITION = [0.0, 0.0, 1.0] as [number, number, number];\n\nlet idCount = 0;\n\nexport type PointLightOptions = {\n id?: string;\n /** Light color, [r, g, b] in the 0-255 range\n * @default [255, 255, 255]\n */\n color?: [number, number, number];\n /** Light intensity, higher number is brighter\n * @default 1.0\n */\n intensity?: number;\n /** Light position [x, y, z] in the common space\n * @default [0.0, 0.0, 1.0]\n */\n position?: [number, number, number];\n /** Light attenuation\n * @default [1.0, 0.0, 0.0]\n */\n attenuation?: [number, number, number];\n};\n\nexport class PointLight {\n id: string;\n color: [number, number, number];\n intensity: number;\n type = 'point' as const;\n position: [number, number, number];\n attenuation: [number, number, number];\n\n protected projectedLight: PointLight;\n\n constructor(props: PointLightOptions = {}) {\n const {color = DEFAULT_LIGHT_COLOR} = props;\n const {intensity = DEFAULT_LIGHT_INTENSITY} = props;\n const {position = DEFAULT_LIGHT_POSITION} = props;\n\n this.id = props.id || `point-${idCount++}`;\n this.color = color;\n this.intensity = intensity;\n this.type = 'point';\n this.position = position;\n this.attenuation = getAttenuation(props);\n this.projectedLight = {...this};\n }\n\n getProjectedLight({layer}: {layer: Layer}): PointLight {\n const {projectedLight} = this;\n const viewport = layer.context.viewport;\n const {coordinateSystem, coordinateOrigin} = layer.props;\n const position = projectPosition(this.position, {\n viewport,\n coordinateSystem,\n coordinateOrigin,\n fromCoordinateSystem: viewport.isGeospatial\n ? COORDINATE_SYSTEM.LNGLAT\n : COORDINATE_SYSTEM.CARTESIAN,\n fromCoordinateOrigin: [0, 0, 0]\n });\n projectedLight.color = this.color;\n projectedLight.intensity = this.intensity;\n projectedLight.position = position;\n return projectedLight;\n }\n}\n\nfunction getAttenuation(props: PointLightOptions): [number, number, number] {\n if (props.attenuation) {\n return props.attenuation;\n }\n return DEFAULT_ATTENUATION;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable camelcase */\nimport type {NumberArray16} from '@math.gl/types';\nimport {PointLight} from './point-light';\nimport {getUniformsFromViewport} from '../../shaderlib/project/viewport-uniforms';\nimport type Layer from '../../lib/layer';\n\nexport default class CameraLight extends PointLight {\n getProjectedLight({layer}: {layer: Layer}): PointLight {\n const {projectedLight} = this;\n const viewport = layer.context.viewport;\n const {coordinateSystem, coordinateOrigin, modelMatrix} = layer.props;\n const {cameraPosition} = getUniformsFromViewport({\n viewport,\n modelMatrix: modelMatrix as NumberArray16,\n coordinateSystem,\n coordinateOrigin\n });\n projectedLight.color = this.color;\n projectedLight.intensity = this.intensity;\n projectedLight.position = cameraPosition;\n return projectedLight;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {DirectionalLight} from './directional-light';\nimport {getSunDirection} from '@math.gl/sun';\n\nimport type Layer from '../../lib/layer';\n\nexport type SunLightOptions = {\n id?: string;\n /** Light color, [r, g, b] in the 0-255 range\n * @default [255, 255, 255]\n */\n color?: [number, number, number];\n /** Light intensity, higher number is brighter\n * @default 1.0\n */\n intensity?: number;\n /**\n * The time at which to position the sun. Either a Date object or a timestamp (milliseconds elapsed since unix time 0)\n */\n timestamp: number | Date;\n /** (Experimental) render shadows casted by this light\n * @default false\n */\n _shadow?: boolean;\n};\n\nexport default class SunLight extends DirectionalLight {\n timestamp: number | Date;\n\n constructor(opts: SunLightOptions) {\n super(opts);\n\n this.timestamp = opts.timestamp;\n }\n\n getProjectedLight({layer}: {layer: Layer}): DirectionalLight {\n const {viewport} = layer.context;\n const isGlobe = viewport.resolution && viewport.resolution > 0;\n\n if (isGlobe) {\n // Rotate vector to align with the direction of the globe projection (up at lon:0,lat:0 is [0, -1, 0])\n const [x, y, z] = getSunDirection(this.timestamp, 0, 0);\n this.direction = [x, -z, y];\n } else {\n // @ts-expect-error longitude and latitude are not defined on all viewports\n const {latitude, longitude} = viewport;\n this.direction = getSunDirection(this.timestamp, latitude, longitude) as [\n number,\n number,\n number\n ];\n }\n\n return this;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Framebuffer} from '@luma.gl/core';\nimport {initializeShaderModule, ShaderPass} from '@luma.gl/shadertools';\n\nimport ScreenPass from '../passes/screen-pass';\n\nimport type {Effect, EffectContext, PostRenderOptions} from '../lib/effect';\n\nexport default class PostProcessEffect implements Effect {\n id: string;\n props: ShaderPassT['props'];\n module: ShaderPassT;\n passes?: ScreenPass[];\n\n constructor(module: ShaderPassT, props: ShaderPassT['props']) {\n this.id = `${module.name}-pass`;\n this.props = props;\n initializeShaderModule(module);\n this.module = module;\n }\n\n setup({device}: EffectContext) {\n this.passes = createPasses(device, this.module, this.id);\n }\n\n setProps(props: ShaderPassT['props']) {\n this.props = props;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n preRender(): void {}\n\n postRender(params: PostRenderOptions): Framebuffer {\n const passes = this.passes!;\n\n const {target} = params;\n let inputBuffer = params.inputBuffer;\n let outputBuffer: Framebuffer | null = params.swapBuffer;\n\n for (let index = 0; index < passes.length; index++) {\n const isLastPass = index === passes.length - 1;\n const renderToTarget = target !== undefined && isLastPass;\n if (renderToTarget) {\n outputBuffer = target;\n }\n const clearCanvas = !renderToTarget || Boolean(params.clearCanvas);\n const moduleProps = {};\n const uniforms = this.module.passes![index].uniforms;\n moduleProps[this.module.name] = {...this.props, ...uniforms};\n passes[index].render({clearCanvas, inputBuffer, outputBuffer, moduleProps});\n\n const switchBuffer = outputBuffer as Framebuffer;\n outputBuffer = inputBuffer;\n inputBuffer = switchBuffer;\n }\n return inputBuffer;\n }\n\n cleanup(): void {\n if (this.passes) {\n for (const pass of this.passes) {\n pass.delete();\n }\n this.passes = undefined;\n }\n }\n}\n\nfunction createPasses(device: Device, module: ShaderPass, id: string): ScreenPass[] {\n return module.passes!.map((pass, index) => {\n const fs = getFragmentShaderForRenderPass(module, pass);\n const idn = `${id}-${index}`;\n return new ScreenPass(device, {id: idn, module, fs});\n });\n}\n\nconst FS_TEMPLATE_INPUTS = `\\\n#version 300 es\nuniform sampler2D texSrc;\n\nin vec2 position;\nin vec2 coordinate;\nin vec2 uv;\n\nout vec4 fragColor;\n`;\n\nconst FILTER_FS_TEMPLATE = (func: string) => `\\\n${FS_TEMPLATE_INPUTS}\nvoid main() {\n fragColor = texture(texSrc, coordinate);\n fragColor = ${func}(fragColor, screen.texSize, coordinate);\n}\n`;\n\nconst SAMPLER_FS_TEMPLATE = (func: string) => `\\\n${FS_TEMPLATE_INPUTS}\nvoid main() {\n fragColor = ${func}(texSrc, screen.texSize, coordinate);\n}\n`;\n\nfunction getFragmentShaderForRenderPass(\n module: ShaderPass,\n pass: NonNullable[0]\n): string {\n if (pass.filter) {\n const func = typeof pass.filter === 'string' ? pass.filter : `${module.name}_filterColor_ext`;\n return FILTER_FS_TEMPLATE(func);\n }\n\n if (pass.sampler) {\n const func = typeof pass.sampler === 'string' ? pass.sampler : `${module.name}_sampleColor`;\n return SAMPLER_FS_TEMPLATE(func);\n }\n\n // console.error(`${module.name} no fragment shader generated`);\n return '';\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Attribution: This class and the multipass system were inspired by\n// the THREE.js EffectComposer and *Pass classes\n\nimport type {Device, Framebuffer} from '@luma.gl/core';\nimport {ClipSpace} from '@luma.gl/engine';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport Pass from './pass';\nimport {ScreenProps, screenUniforms} from './screen-pass-uniforms';\n\ntype ScreenPassProps = {\n module: ShaderModule;\n fs: string;\n id: string;\n};\n\ntype ScreenPassRenderOptions = {\n clearCanvas?: boolean;\n inputBuffer: Framebuffer;\n outputBuffer: Framebuffer | null;\n moduleProps: ShaderModule['props'];\n};\n\n/** A base render pass. */\nexport default class ScreenPass extends Pass {\n model: ClipSpace;\n\n constructor(device: Device, props: ScreenPassProps) {\n super(device, props);\n const {module, fs, id} = props;\n const parameters = {depthWriteEnabled: false, depthCompare: 'always' as const};\n this.model = new ClipSpace(device, {id, fs, modules: [module, screenUniforms], parameters});\n }\n\n render(params: ScreenPassRenderOptions): void {\n this._renderPass(this.device, params);\n }\n\n delete() {\n this.model.destroy();\n this.model = null!;\n }\n\n // Private methods\n\n /**\n * Renders the pass.\n * This is an abstract method that should be overridden.\n * @param inputBuffer - Frame buffer that contains the result of the previous pass\n * @param outputBuffer - Frame buffer that serves as the output render target\n */\n protected _renderPass(device: Device, options: ScreenPassRenderOptions) {\n const {clearCanvas, inputBuffer, outputBuffer} = options;\n const texSize: [number, number] = [inputBuffer.width, inputBuffer.height];\n const screenProps: ScreenProps = {\n texSrc: inputBuffer.colorAttachments[0],\n texSize\n };\n this.model.shaderInputs.setProps({\n screen: screenProps,\n ...options.moduleProps\n });\n const renderPass = this.device.beginRenderPass({\n framebuffer: outputBuffer,\n parameters: {viewport: [0, 0, ...texSize]},\n clearColor: clearCanvas ? [0, 0, 0, 0] : false,\n clearDepth: 1\n });\n\n this.model.draw(renderPass);\n renderPass.end();\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {TextureView} from '@luma.gl/core';\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\nconst uniformBlock = `\\\nuniform screenUniforms {\n vec2 texSize;\n} screen;\n`;\n\nexport type ScreenProps = {\n texSrc: TextureView;\n texSize: [number, number];\n};\n\nexport const screenUniforms = {\n name: 'screen',\n fs: uniformBlock,\n uniformTypes: {\n texSize: 'vec2'\n }\n} as const satisfies ShaderModule;\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport LayersPass, {LayersPassRenderOptions, RenderStats, Rect} from './layers-pass';\nimport type {Framebuffer, Parameters, RenderPipelineParameters} from '@luma.gl/core';\nimport log from '../utils/log';\n\nimport type {Effect} from '../lib/effect';\nimport type Viewport from '../viewports/viewport';\nimport type Layer from '../lib/layer';\n\nconst PICKING_BLENDING: RenderPipelineParameters = {\n blendColorOperation: 'add',\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'zero',\n blendAlphaOperation: 'add',\n blendAlphaSrcFactor: 'constant-alpha',\n blendAlphaDstFactor: 'zero'\n};\n\ntype PickLayersPassRenderOptions = LayersPassRenderOptions & {\n pickingFBO: Framebuffer;\n deviceRect: Rect;\n pickZ: boolean;\n};\n\ntype EncodedPickingColors = {\n a: number;\n layer: Layer;\n viewports: Viewport[];\n};\n\nexport type PickingColorDecoder = (pickedColor: number[] | Uint8Array) =>\n | {\n pickedLayer: Layer;\n pickedViewports: Viewport[];\n pickedObjectIndex: number;\n }\n | undefined;\n\nexport default class PickLayersPass extends LayersPass {\n private pickZ?: boolean;\n private _colorEncoderState: {\n byLayer: Map;\n byAlpha: EncodedPickingColors[];\n } | null = null;\n\n render(props: LayersPassRenderOptions | PickLayersPassRenderOptions) {\n if ('pickingFBO' in props) {\n // When drawing into an off-screen buffer, use the alpha channel to encode layer index\n return this._drawPickingBuffer(props);\n }\n // When drawing to screen (debug mode), do not use the alpha channel so that result is always visible\n return super.render(props);\n }\n\n // Private\n // Draws list of layers and viewports into the picking buffer\n // Note: does not sample the buffer, that has to be done by the caller\n _drawPickingBuffer({\n layers,\n layerFilter,\n views,\n viewports,\n onViewportActive,\n pickingFBO,\n deviceRect: {x, y, width, height},\n cullRect,\n effects,\n pass = 'picking',\n pickZ,\n shaderModuleProps\n }: PickLayersPassRenderOptions): {\n decodePickingColor: PickingColorDecoder | null;\n stats: RenderStats;\n } {\n this.pickZ = pickZ;\n const colorEncoderState = this._resetColorEncoder(pickZ);\n const scissorRect = [x, y, width, height];\n\n // Make sure we clear scissor test and fbo bindings in case of exceptions\n // We are only interested in one pixel, no need to render anything else\n // Note that the callback here is called synchronously.\n // Set blend mode for picking\n // always overwrite existing pixel with [r,g,b,layerIndex]\n const renderStatus = super.render({\n target: pickingFBO,\n layers,\n layerFilter,\n views,\n viewports,\n onViewportActive,\n cullRect,\n effects: effects?.filter(e => e.useInPicking),\n pass,\n isPicking: true,\n shaderModuleProps,\n clearColor: [0, 0, 0, 0],\n colorMask: 0xf,\n scissorRect\n });\n\n // Clear the temp field\n this._colorEncoderState = null;\n const decodePickingColor = colorEncoderState && decodeColor.bind(null, colorEncoderState);\n return {decodePickingColor, stats: renderStatus};\n }\n\n shouldDrawLayer(layer: Layer): boolean {\n const {pickable, operation} = layer.props;\n return (\n (pickable && operation.includes('draw')) ||\n operation.includes('terrain') ||\n operation.includes('mask')\n );\n }\n\n protected getShaderModuleProps(\n layer: Layer,\n effects: Effect[] | undefined,\n otherShaderModuleProps: Record\n ): any {\n return {\n picking: {\n isActive: 1,\n isAttribute: this.pickZ\n },\n lighting: {enabled: false}\n };\n }\n\n protected getLayerParameters(layer: Layer, layerIndex: number, viewport: Viewport): Parameters {\n // TODO use Parameters type\n const pickParameters: any = {\n ...layer.props.parameters\n };\n const {pickable, operation} = layer.props;\n\n if (!this._colorEncoderState || operation.includes('terrain')) {\n pickParameters.blend = false;\n } else if (pickable && operation.includes('draw')) {\n Object.assign(pickParameters, PICKING_BLENDING);\n pickParameters.blend = true;\n // TODO: blendColor no longer part of luma.gl API\n pickParameters.blendColor = encodeColor(this._colorEncoderState, layer, viewport);\n }\n\n return pickParameters;\n }\n\n protected _resetColorEncoder(pickZ: boolean) {\n // Track encoded layer indices\n this._colorEncoderState = pickZ\n ? null\n : {\n byLayer: new Map(),\n byAlpha: []\n };\n // Temporarily store it on the instance so that it can be accessed by this.getLayerParameters\n return this._colorEncoderState;\n }\n}\n\n// Assign an unique alpha value for each pickable layer and track the encoding in the cache object\n// Returns normalized blend color\nfunction encodeColor(\n encoded: {\n byLayer: Map;\n byAlpha: EncodedPickingColors[];\n },\n layer: Layer,\n viewport: Viewport\n): number[] {\n const {byLayer, byAlpha} = encoded;\n let a;\n\n // Encode layerIndex in the alpha channel\n // TODO - combine small layers to better utilize the picking color space\n let entry = byLayer.get(layer);\n if (entry) {\n entry.viewports.push(viewport);\n a = entry.a;\n } else {\n a = byLayer.size + 1;\n if (a <= 255) {\n entry = {a, layer, viewports: [viewport]};\n byLayer.set(layer, entry);\n byAlpha[a] = entry;\n } else {\n log.warn('Too many pickable layers, only picking the first 255')();\n a = 0;\n }\n }\n return [0, 0, 0, a / 255];\n}\n\n// Given a picked color, retrieve the corresponding layer and viewports from cache\nfunction decodeColor(\n encoded: {\n byLayer: Map;\n byAlpha: EncodedPickingColors[];\n },\n pickedColor: number[] | Uint8Array\n):\n | {\n pickedLayer: Layer;\n pickedViewports: Viewport[];\n pickedObjectIndex: number;\n }\n | undefined {\n const entry = encoded.byAlpha[pickedColor[3]];\n return (\n entry && {\n pickedLayer: entry.layer,\n pickedViewports: entry.viewports,\n pickedObjectIndex: entry.layer.decodePickingColor(pickedColor)\n }\n );\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, RenderPass} from '@luma.gl/core';\nimport {Timeline} from '@luma.gl/engine';\nimport type {ShaderAssembler, ShaderModule} from '@luma.gl/shadertools';\nimport {getShaderAssembler, layerUniforms} from '../shaderlib/index';\nimport {LIFECYCLE} from '../lifecycle/constants';\nimport log from '../utils/log';\nimport debug from '../debug/index';\nimport {flatten} from '../utils/flatten';\nimport {Stats} from '@probe.gl/stats';\nimport ResourceManager from './resource/resource-manager';\n\nimport Viewport from '../viewports/viewport';\n\nimport type Layer from './layer';\nimport type CompositeLayer from './composite-layer';\nimport type Deck from './deck';\n\nconst TRACE_SET_LAYERS = 'layerManager.setLayers';\nconst TRACE_ACTIVATE_VIEWPORT = 'layerManager.activateViewport';\n\nexport type LayerContext = {\n layerManager: LayerManager;\n resourceManager: ResourceManager;\n deck?: Deck;\n device: Device;\n shaderAssembler: ShaderAssembler;\n defaultShaderModules: ShaderModule[];\n renderPass: RenderPass;\n stats: Stats;\n viewport: Viewport;\n timeline: Timeline;\n mousePosition: {x: number; y: number} | null;\n userData: any;\n onError?: (error: Error, source: Layer) => void;\n /** @deprecated Use context.device */\n gl: WebGL2RenderingContext;\n};\n\nexport type LayersList = (Layer | undefined | false | null | LayersList)[];\n\nexport type LayerManagerProps = {\n deck?: Deck;\n stats?: Stats;\n viewport?: Viewport;\n timeline?: Timeline;\n};\nexport default class LayerManager {\n layers: Layer[];\n context: LayerContext;\n resourceManager: ResourceManager;\n\n private _lastRenderedLayers: LayersList = [];\n private _needsRedraw: string | false = false;\n private _needsUpdate: string | false = false;\n private _nextLayers: LayersList | null = null;\n private _debug: boolean = false;\n // This flag is separate from _needsUpdate because it can be set during an update and should trigger another full update\n private _defaultShaderModulesChanged: boolean = false;\n\n /**\n * @param device\n * @param param1\n */\n // eslint-disable-next-line\n constructor(device: Device, props: LayerManagerProps) {\n const {deck, stats, viewport, timeline} = props || {};\n\n // Currently deck.gl expects the DeckGL.layers array to be different\n // whenever React rerenders. If the same layers array is used, the\n // LayerManager's diffing algorithm will generate a fatal error and\n // break the rendering.\n\n // `this._lastRenderedLayers` stores the UNFILTERED layers sent\n // down to LayerManager, so that `layers` reference can be compared.\n // If it's the same across two React render calls, the diffing logic\n // will be skipped.\n this.layers = [];\n this.resourceManager = new ResourceManager({device, protocol: 'deck://'});\n\n this.context = {\n mousePosition: null,\n userData: {},\n layerManager: this,\n device,\n // @ts-expect-error\n gl: device?.gl,\n deck,\n shaderAssembler: getShaderAssembler(),\n defaultShaderModules: [layerUniforms],\n renderPass: undefined!,\n stats: stats || new Stats({id: 'deck.gl'}),\n // Make sure context.viewport is not empty on the first layer initialization\n viewport: viewport || new Viewport({id: 'DEFAULT-INITIAL-VIEWPORT'}), // Current viewport, exposed to layers for project* function\n timeline: timeline || new Timeline(),\n resourceManager: this.resourceManager,\n onError: undefined\n };\n\n Object.seal(this);\n }\n\n /** Method to call when the layer manager is not needed anymore. */\n finalize() {\n this.resourceManager.finalize();\n // Finalize all layers\n for (const layer of this.layers) {\n this._finalizeLayer(layer);\n }\n }\n\n /** Check if a redraw is needed */\n needsRedraw(\n opts: {\n /** Reset redraw flags to false after the call */\n clearRedrawFlags: boolean;\n } = {clearRedrawFlags: false}\n ): string | false {\n let redraw = this._needsRedraw;\n if (opts.clearRedrawFlags) {\n this._needsRedraw = false;\n }\n\n // This layers list doesn't include sublayers, relying on composite layers\n for (const layer of this.layers) {\n // Call every layer to clear their flags\n const layerNeedsRedraw = layer.getNeedsRedraw(opts);\n redraw = redraw || layerNeedsRedraw;\n }\n\n return redraw;\n }\n\n /** Check if a deep update of all layers is needed */\n needsUpdate(): string | false {\n if (this._nextLayers && this._nextLayers !== this._lastRenderedLayers) {\n // New layers array may be the same as the old one if `setProps` is called by React\n return 'layers changed';\n }\n if (this._defaultShaderModulesChanged) {\n return 'shader modules changed';\n }\n return this._needsUpdate;\n }\n\n /** Layers will be redrawn (in next animation frame) */\n setNeedsRedraw(reason: string): void {\n this._needsRedraw = this._needsRedraw || reason;\n }\n\n /** Layers will be updated deeply (in next animation frame)\n Potentially regenerating attributes and sub layers */\n setNeedsUpdate(reason: string): void {\n this._needsUpdate = this._needsUpdate || reason;\n }\n\n /** Gets a list of currently rendered layers. Optionally filter by id. */\n getLayers({layerIds}: {layerIds?: string[]} = {}): Layer[] {\n // Filtering by layerId compares beginning of strings, so that sublayers will be included\n // Dependes on the convention of adding suffixes to the parent's layer name\n return layerIds\n ? this.layers.filter(layer => layerIds.find(layerId => layer.id.indexOf(layerId) === 0))\n : this.layers;\n }\n\n /** Set props needed for layer rendering and picking. */\n setProps(props: any): void {\n if ('debug' in props) {\n this._debug = props.debug;\n }\n\n // A way for apps to add data to context that can be accessed in layers\n if ('userData' in props) {\n this.context.userData = props.userData;\n }\n\n // New layers will be processed in `updateLayers` in the next update cycle\n if ('layers' in props) {\n this._nextLayers = props.layers;\n }\n\n if ('onError' in props) {\n this.context.onError = props.onError;\n }\n }\n\n /** Supply a new layer list, initiating sublayer generation and layer matching */\n setLayers(newLayers: LayersList, reason?: string): void {\n debug(TRACE_SET_LAYERS, this, reason, newLayers);\n\n this._lastRenderedLayers = newLayers;\n\n const flatLayers = flatten(newLayers, Boolean) as Layer[];\n\n for (const layer of flatLayers) {\n layer.context = this.context;\n }\n\n this._updateLayers(this.layers, flatLayers);\n }\n\n /** Update layers from last cycle if `setNeedsUpdate()` has been called */\n updateLayers(): void {\n // NOTE: For now, even if only some layer has changed, we update all layers\n // to ensure that layer id maps etc remain consistent even if different\n // sublayers are rendered\n const reason = this.needsUpdate();\n if (reason) {\n this.setNeedsRedraw(`updating layers: ${reason}`);\n // Force a full update\n this.setLayers(this._nextLayers || this._lastRenderedLayers, reason);\n }\n // Updated, clear the backlog\n this._nextLayers = null;\n }\n\n //\n // INTERNAL METHODS\n //\n\n /** Make a viewport \"current\" in layer context, updating viewportChanged flags */\n activateViewport = (viewport: Viewport) => {\n debug(TRACE_ACTIVATE_VIEWPORT, this, viewport);\n if (viewport) {\n this.context.viewport = viewport;\n }\n };\n\n /** Register a default shader module */\n addDefaultShaderModule(module: ShaderModule) {\n const {defaultShaderModules} = this.context;\n if (!defaultShaderModules.find(m => m.name === module.name)) {\n defaultShaderModules.push(module);\n this._defaultShaderModulesChanged = true;\n }\n }\n\n /** Deregister a default shader module */\n removeDefaultShaderModule(module: ShaderModule) {\n const {defaultShaderModules} = this.context;\n const i = defaultShaderModules.findIndex(m => m.name === module.name);\n if (i >= 0) {\n defaultShaderModules.splice(i, 1);\n this._defaultShaderModulesChanged = true;\n }\n }\n\n private _handleError(stage: string, error: Error, layer: Layer) {\n layer.raiseError(error, `${stage} of ${layer}`);\n }\n\n // TODO - mark layers with exceptions as bad and remove from rendering cycle?\n /** Match all layers, checking for caught errors\n to avoid having an exception in one layer disrupt other layers */\n private _updateLayers(oldLayers: Layer[], newLayers: Layer[]): void {\n // Create old layer map\n const oldLayerMap: {[layerId: string]: Layer | null} = {};\n for (const oldLayer of oldLayers) {\n if (oldLayerMap[oldLayer.id]) {\n log.warn(`Multiple old layers with same id ${oldLayer.id}`)();\n } else {\n oldLayerMap[oldLayer.id] = oldLayer;\n }\n }\n\n if (this._defaultShaderModulesChanged) {\n for (const layer of oldLayers) {\n layer.setNeedsUpdate();\n layer.setChangeFlags({extensionsChanged: true});\n }\n this._defaultShaderModulesChanged = false;\n }\n\n // Allocate array for generated layers\n const generatedLayers: Layer[] = [];\n\n // Match sublayers\n this._updateSublayersRecursively(newLayers, oldLayerMap, generatedLayers);\n\n // Finalize unmatched layers\n this._finalizeOldLayers(oldLayerMap);\n\n let needsUpdate: string | false = false;\n for (const layer of generatedLayers) {\n if (layer.hasUniformTransition()) {\n needsUpdate = `Uniform transition in ${layer}`;\n break;\n }\n }\n\n this._needsUpdate = needsUpdate;\n this.layers = generatedLayers;\n }\n\n /* eslint-disable complexity,max-statements */\n // Note: adds generated layers to `generatedLayers` array parameter\n private _updateSublayersRecursively(\n newLayers: Layer[],\n oldLayerMap: {[layerId: string]: Layer | null},\n generatedLayers: Layer[]\n ) {\n for (const newLayer of newLayers) {\n newLayer.context = this.context;\n\n // Given a new coming layer, find its matching old layer (if any)\n const oldLayer = oldLayerMap[newLayer.id];\n if (oldLayer === null) {\n // null, rather than undefined, means this id was originally there\n log.warn(`Multiple new layers with same id ${newLayer.id}`)();\n }\n // Remove the old layer from candidates, as it has been matched with this layer\n oldLayerMap[newLayer.id] = null;\n\n let sublayers: Layer[] | null = null;\n\n // We must not generate exceptions until after layer matching is complete\n try {\n if (this._debug && oldLayer !== newLayer) {\n newLayer.validateProps();\n }\n\n if (!oldLayer) {\n this._initializeLayer(newLayer);\n } else {\n this._transferLayerState(oldLayer, newLayer);\n this._updateLayer(newLayer);\n }\n generatedLayers.push(newLayer);\n\n // Call layer lifecycle method: render sublayers\n sublayers = newLayer.isComposite ? (newLayer as CompositeLayer).getSubLayers() : null;\n // End layer lifecycle method: render sublayers\n } catch (err) {\n this._handleError('matching', err as Error, newLayer); // Record first exception\n }\n\n if (sublayers) {\n this._updateSublayersRecursively(sublayers, oldLayerMap, generatedLayers);\n }\n }\n }\n /* eslint-enable complexity,max-statements */\n\n // Finalize any old layers that were not matched\n private _finalizeOldLayers(oldLayerMap: {[layerId: string]: Layer | null}): void {\n for (const layerId in oldLayerMap) {\n const layer = oldLayerMap[layerId];\n if (layer) {\n this._finalizeLayer(layer);\n }\n }\n }\n\n // / EXCEPTION SAFE LAYER ACCESS\n\n /** Safely initializes a single layer, calling layer methods */\n private _initializeLayer(layer: Layer): void {\n try {\n layer._initialize();\n layer.lifecycle = LIFECYCLE.INITIALIZED;\n } catch (err) {\n this._handleError('initialization', err as Error, layer);\n // TODO - what should the lifecycle state be here? LIFECYCLE.INITIALIZATION_FAILED?\n }\n }\n\n /** Transfer state from one layer to a newer version */\n private _transferLayerState(oldLayer: Layer, newLayer: Layer): void {\n newLayer._transferState(oldLayer);\n newLayer.lifecycle = LIFECYCLE.MATCHED;\n\n if (newLayer !== oldLayer) {\n oldLayer.lifecycle = LIFECYCLE.AWAITING_GC;\n }\n }\n\n /** Safely updates a single layer, cleaning all flags */\n private _updateLayer(layer: Layer): void {\n try {\n layer._update();\n } catch (err) {\n this._handleError('update', err as Error, layer);\n }\n }\n\n /** Safely finalizes a single layer, removing all resources */\n private _finalizeLayer(layer: Layer): void {\n this._needsRedraw = this._needsRedraw || `finalized ${layer}`;\n\n layer.lifecycle = LIFECYCLE.AWAITING_FINALIZATION;\n\n try {\n layer._finalize();\n layer.lifecycle = LIFECYCLE.FINALIZED;\n } catch (err) {\n this._handleError('finalization', err as Error, layer);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport const LIFECYCLE = {\n NO_STATE: 'Awaiting state',\n MATCHED: 'Matched. State transferred from previous layer',\n INITIALIZED: 'Initialized',\n AWAITING_GC: 'Discarded. Awaiting garbage collection',\n AWAITING_FINALIZATION: 'No longer matched. Awaiting garbage collection',\n FINALIZED: 'Finalized! Awaiting garbage collection'\n} as const;\n\nexport type Lifecycle = (typeof LIFECYCLE)[keyof typeof LIFECYCLE];\n\n/* Secret props keys */\n// Symbols are non-enumerable by default, does not show in for...in or Object.keys\n// but are copied with Object.assign \u00AF\\_(\u30C4)_/\u00AF\n// Supported everywhere except IE11, can be polyfilled with core-js\nexport const COMPONENT_SYMBOL: unique symbol = Symbol.for('component');\nexport const PROP_TYPES_SYMBOL: unique symbol = Symbol.for('propTypes');\nexport const DEPRECATED_PROPS_SYMBOL: unique symbol = Symbol.for('deprecatedProps');\nexport const ASYNC_DEFAULTS_SYMBOL: unique symbol = Symbol.for('asyncPropDefaults');\nexport const ASYNC_ORIGINAL_SYMBOL: unique symbol = Symbol.for('asyncPropOriginal');\nexport const ASYNC_RESOLVED_SYMBOL: unique symbol = Symbol.for('asyncPropResolved');\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\ntype NestedArray = (T | NestedArray)[];\n\n/**\n * Flattens a nested array into a single level array,\n * or a single value into an array with one value\n * @example flatten([[1, [2]], [3], 4]) => [1, 2, 3, 4]\n * @example flatten(1) => [1]\n * @param array The array to flatten.\n * @param filter= - Optional predicate called on each `value` to\n * determine if it should be included (pushed onto) the resulting array.\n * @return Returns the new flattened array (new array or `result` if provided)\n */\nexport function flatten(\n array: T | NestedArray,\n filter: (element: T) => boolean = () => true\n): T[] {\n // Wrap single object in array\n if (!Array.isArray(array)) {\n return filter(array) ? [array] : [];\n }\n // Deep flatten and filter the array\n return flattenArray(array, filter, []);\n}\n\n/** Deep flattens an array. Helper to `flatten`, see its parameters */\nfunction flattenArray(array: NestedArray, filter: (element: T) => boolean, result: T[]): T[] {\n let index = -1;\n while (++index < array.length) {\n const value = array[index];\n if (Array.isArray(value)) {\n flattenArray(value, filter, result);\n } else if (filter(value)) {\n result.push(value);\n }\n }\n return result;\n}\n\n/** Uses copyWithin to significantly speed up typed array value filling */\nexport function fillArray({target, source, start = 0, count = 1}) {\n const length = source.length;\n const total = count * length;\n let copied = 0;\n for (let i = start; copied < length; copied++) {\n target[i++] = source[copied];\n }\n\n while (copied < total) {\n // If we have copied less than half, copy everything we got\n // else copy remaining in one operation\n if (copied < total - copied) {\n target.copyWithin(start + copied, start, start + copied);\n copied *= 2;\n } else {\n target.copyWithin(start + copied, start, start + total - copied);\n copied = total;\n }\n }\n\n return target;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {load} from '@loaders.gl/core';\n\nimport type {ResourceManagerContext} from './resource-manager';\n\nexport type ResourceSubscriber = {\n onChange: (data: T | Promise) => void;\n};\n\nexport default class Resource {\n id: string;\n context: ResourceManagerContext;\n isLoaded!: boolean;\n persistent?: boolean;\n\n private _loadCount: number = 0;\n private _subscribers = new Set>();\n private _data!: T | Promise | string;\n private _loader?: Promise;\n private _error?: Error;\n private _content?: T;\n\n constructor(id: string, data: T | Promise | string, context: ResourceManagerContext) {\n this.id = id;\n this.context = context;\n\n this.setData(data);\n }\n\n // consumer: {onChange: Function}\n subscribe(consumer: ResourceSubscriber): void {\n this._subscribers.add(consumer);\n }\n\n unsubscribe(consumer: ResourceSubscriber): void {\n this._subscribers.delete(consumer);\n }\n\n inUse(): boolean {\n return this._subscribers.size > 0;\n }\n\n delete(): void {\n // Remove any resources created\n }\n\n getData(): T | Promise {\n return this.isLoaded\n ? this._error\n ? Promise.reject(this._error)\n : this._content!\n : this._loader!.then(() => this.getData());\n }\n\n setData(data: any, forceUpdate?: boolean) {\n if (data === this._data && !forceUpdate) {\n return;\n }\n this._data = data;\n const loadCount = ++this._loadCount;\n\n let loader = data;\n if (typeof data === 'string') {\n loader = load(data);\n }\n if (loader instanceof Promise) {\n this.isLoaded = false;\n this._loader = loader\n .then(result => {\n // check if source has changed\n if (this._loadCount === loadCount) {\n this.isLoaded = true;\n this._error = undefined;\n this._content = result;\n }\n })\n .catch(error => {\n if (this._loadCount === loadCount) {\n this.isLoaded = true;\n this._error = error || true;\n }\n });\n } else {\n this.isLoaded = true;\n this._error = undefined;\n this._content = data;\n }\n\n for (const subscriber of this._subscribers) {\n subscriber.onChange(this.getData());\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* global setTimeout */\nimport {Device} from '@luma.gl/core';\nimport Resource from './resource';\nimport type {ResourceSubscriber} from './resource';\n\nexport type ResourceManagerContext = {\n device: Device;\n resourceManager: ResourceManager;\n /** @deprecated */\n gl: WebGL2RenderingContext;\n};\n\ntype Consumer = Record;\n\nexport default class ResourceManager {\n protocol: string;\n\n private _context: ResourceManagerContext;\n private _resources: Record;\n private _consumers: Record;\n private _pruneRequest: number | null;\n\n constructor(props: {device: Device; protocol?: string}) {\n this.protocol = props.protocol || 'resource://';\n\n this._context = {\n device: props.device,\n // @ts-expect-error\n gl: props.device?.gl,\n resourceManager: this\n };\n this._resources = {};\n this._consumers = {};\n\n this._pruneRequest = null;\n }\n\n contains(resourceId: string): boolean {\n if (resourceId.startsWith(this.protocol)) {\n return true;\n }\n return resourceId in this._resources;\n }\n\n add({\n resourceId,\n data,\n forceUpdate = false,\n persistent = true\n }: {\n resourceId: string;\n data: any;\n forceUpdate?: boolean;\n persistent?: boolean;\n }) {\n let res = this._resources[resourceId];\n\n if (res) {\n res.setData(data, forceUpdate);\n } else {\n res = new Resource(resourceId, data, this._context);\n this._resources[resourceId] = res;\n }\n // persistent resources can only be removed by calling `remove`\n // non-persistent resources may be released when there are no more consumers\n res.persistent = persistent;\n }\n\n remove(resourceId: string): void {\n const res = this._resources[resourceId];\n\n if (res) {\n res.delete();\n delete this._resources[resourceId];\n }\n }\n\n unsubscribe({consumerId}: {consumerId: string}): void {\n const consumer = this._consumers[consumerId];\n if (consumer) {\n for (const requestId in consumer) {\n const request = consumer[requestId];\n const resource = this._resources[request.resourceId];\n if (resource) {\n resource.unsubscribe(request);\n }\n }\n delete this._consumers[consumerId];\n this.prune();\n }\n }\n\n subscribe({\n resourceId,\n onChange,\n consumerId,\n requestId = 'default'\n }: {\n resourceId: string;\n onChange: (data: T | Promise) => void;\n consumerId: string;\n requestId: string;\n }): T | Promise | undefined {\n const {_resources: resources, protocol} = this;\n if (resourceId.startsWith(protocol)) {\n resourceId = resourceId.replace(protocol, '');\n if (!resources[resourceId]) {\n // Add placeholder. When this resource becomes available, the consumer will be notified.\n this.add({resourceId, data: null, persistent: false});\n }\n }\n const res: Resource = resources[resourceId];\n this._track(consumerId, requestId, res, onChange);\n if (res) {\n return res.getData();\n }\n\n return undefined;\n }\n\n prune(): void {\n if (!this._pruneRequest) {\n // prune() may be called multiple times in the same animation frame.\n // Batch multiple requests together\n // @ts-ignore setTimeout returns NodeJS.Timeout in node\n this._pruneRequest = setTimeout(() => this._prune(), 0);\n }\n }\n\n finalize(): void {\n for (const key in this._resources) {\n this._resources[key].delete();\n }\n }\n\n private _track(\n consumerId: string,\n requestId: string,\n resource: Resource,\n onChange: (data: any) => void\n ) {\n const consumers = this._consumers;\n const consumer = (consumers[consumerId] = consumers[consumerId] || {});\n let request = consumer[requestId];\n\n const oldResource = request && request.resourceId && this._resources[request.resourceId];\n if (oldResource) {\n oldResource.unsubscribe(request);\n this.prune();\n }\n if (resource) {\n if (request) {\n request.onChange = onChange;\n request.resourceId = resource.id;\n } else {\n request = {\n onChange,\n resourceId: resource.id\n };\n }\n consumer[requestId] = request;\n resource.subscribe(request);\n }\n }\n\n private _prune(): void {\n this._pruneRequest = null;\n\n for (const key of Object.keys(this._resources)) {\n const res = this._resources[key];\n if (!res.persistent && !res.inUse()) {\n res.delete();\n delete this._resources[key];\n }\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/**\n * Fast partial deep equal for prop.\n *\n * @param a Prop\n * @param b Prop to compare against `a`\n * @param depth Depth to which to recurse in nested Objects/Arrays. Use 0 (default) for shallow comparison, -1 for infinite depth\n */\n/* eslint-disable complexity */\nexport function deepEqual(a: any, b: any, depth: number): boolean {\n if (a === b) {\n return true;\n }\n if (!depth || !a || !b) {\n return false;\n }\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i], depth - 1)) {\n return false;\n }\n }\n return true;\n }\n if (Array.isArray(b)) {\n return false;\n }\n if (typeof a === 'object' && typeof b === 'object') {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (const key of aKeys) {\n if (!b.hasOwnProperty(key)) {\n return false;\n }\n if (!deepEqual(a[key], b[key], depth - 1)) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {deepEqual} from '../utils/deep-equal';\nimport log from '../utils/log';\nimport {flatten} from '../utils/flatten';\n\nimport type Controller from '../controllers/controller';\nimport type {ViewStateChangeParameters, InteractionState} from '../controllers/controller';\nimport type Viewport from '../viewports/viewport';\nimport type View from '../views/view';\nimport type {Timeline} from '@luma.gl/engine';\nimport type {EventManager} from 'mjolnir.js';\nimport type {ConstructorOf} from '../types/types';\nimport type {default as MapView, MapViewState} from '../views/map-view';\n\nexport type ViewOrViews = View | View[] | null;\ntype ViewStateOf = ViewT extends View ? ViewStateT : never;\ntype OneOfViews = ViewsT extends null\n ? MapView\n : ViewsT extends View[]\n ? ViewsT[number]\n : ViewsT;\nexport type AnyViewStateOf = ViewStateOf>;\nexport type ViewStateMap = ViewsT extends null\n ? MapViewState\n : ViewsT extends View\n ? ViewStateOf\n : {[viewId: string]: AnyViewStateOf};\n\n/** This is a very lose type of all \"acceptable\" viewState\n * It's not good for type hinting but matches what may exist internally\n */\nexport type ViewStateObject =\n | ViewStateMap\n | AnyViewStateOf\n | {[viewId: string]: AnyViewStateOf};\n\n/** ViewManager props directly supplied by the user */\ntype ViewManagerProps = {\n views: ViewsT;\n viewState: ViewStateObject | null;\n onViewStateChange?: (params: ViewStateChangeParameters>) => void;\n onInteractionStateChange?: (state: InteractionState) => void;\n width?: number;\n height?: number;\n};\n\nexport default class ViewManager {\n width: number;\n height: number;\n views: View[];\n viewState: ViewStateObject;\n controllers: {[viewId: string]: Controller | null};\n timeline: Timeline;\n\n private _viewports: Viewport[];\n private _viewportMap: {[viewId: string]: Viewport};\n private _isUpdating: boolean;\n private _needsRedraw: string | false;\n private _needsUpdate: string | false;\n private _eventManager: EventManager;\n private _eventCallbacks: {\n onViewStateChange?: (params: ViewStateChangeParameters) => void;\n onInteractionStateChange?: (state: InteractionState) => void;\n };\n\n constructor(\n props: ViewManagerProps & {\n // Initial options\n timeline: Timeline;\n eventManager: EventManager;\n }\n ) {\n // List of view descriptors, gets re-evaluated when width/height changes\n this.views = [];\n this.width = 100;\n this.height = 100;\n this.viewState = {} as any;\n this.controllers = {};\n this.timeline = props.timeline;\n\n this._viewports = []; // Generated viewports\n this._viewportMap = {};\n this._isUpdating = false;\n this._needsRedraw = 'First render';\n this._needsUpdate = 'Initialize';\n\n this._eventManager = props.eventManager;\n this._eventCallbacks = {\n onViewStateChange: props.onViewStateChange,\n onInteractionStateChange: props.onInteractionStateChange\n };\n\n Object.seal(this);\n\n // Init with default map viewport\n this.setProps(props);\n }\n\n /** Remove all resources and event listeners */\n finalize(): void {\n for (const key in this.controllers) {\n const controller = this.controllers[key];\n if (controller) {\n controller.finalize();\n }\n }\n this.controllers = {};\n }\n\n /** Check if a redraw is needed */\n needsRedraw(\n opts: {\n /** Reset redraw flags to false */\n clearRedrawFlags?: boolean;\n } = {clearRedrawFlags: false}\n ): string | false {\n const redraw = this._needsRedraw;\n if (opts.clearRedrawFlags) {\n this._needsRedraw = false;\n }\n return redraw;\n }\n\n /** Mark the manager as dirty. Will rebuild all viewports and update controllers. */\n setNeedsUpdate(reason: string): void {\n this._needsUpdate = this._needsUpdate || reason;\n this._needsRedraw = this._needsRedraw || reason;\n }\n\n /** Checks each viewport for transition updates */\n updateViewStates(): void {\n for (const viewId in this.controllers) {\n const controller = this.controllers[viewId];\n if (controller) {\n controller.updateTransition();\n }\n }\n }\n\n /** Get a set of viewports for a given width and height\n * TODO - Intention is for deck.gl to autodeduce width and height and drop the need for props\n * @param rect (object, optional) - filter the viewports\n * + not provided - return all viewports\n * + {x, y} - only return viewports that contain this pixel\n * + {x, y, width, height} - only return viewports that overlap with this rectangle\n */\n getViewports(rect?: {x: number; y: number; width?: number; height?: number}): Viewport[] {\n if (rect) {\n return this._viewports.filter(viewport => viewport.containsPixel(rect));\n }\n return this._viewports;\n }\n\n /** Get a map of all views */\n getViews(): {[viewId: string]: View} {\n const viewMap = {};\n this.views.forEach(view => {\n viewMap[view.id] = view;\n });\n return viewMap;\n }\n\n /** Resolves a viewId string to a View */\n getView(viewId: string): View | undefined {\n return this.views.find(view => view.id === viewId);\n }\n\n /** Returns the viewState for a specific viewId. Matches the viewState by\n 1. view.viewStateId\n 2. view.id\n 3. root viewState\n then applies the view's filter if any */\n getViewState(viewOrViewId: string | View): AnyViewStateOf {\n const view: View | undefined =\n typeof viewOrViewId === 'string' ? this.getView(viewOrViewId) : viewOrViewId;\n // Backward compatibility: view state for single view\n const viewState = (view && this.viewState[view.getViewStateId()]) || this.viewState;\n return view ? view.filterViewState(viewState) : viewState;\n }\n\n getViewport(viewId: string): Viewport | undefined {\n return this._viewportMap[viewId];\n }\n\n /**\n * Unproject pixel coordinates on screen onto world coordinates,\n * (possibly [lon, lat]) on map.\n * - [x, y] => [lng, lat]\n * - [x, y, z] => [lng, lat, Z]\n * @param {Array} xyz -\n * @param {Object} opts - options\n * @param {Object} opts.topLeft=true - Whether origin is top left\n * @return {Array|null} - [lng, lat, Z] or [X, Y, Z]\n */\n unproject(xyz: number[], opts?: {topLeft?: boolean}): number[] | null {\n const viewports = this.getViewports();\n const pixel = {x: xyz[0], y: xyz[1]};\n for (let i = viewports.length - 1; i >= 0; --i) {\n const viewport = viewports[i];\n if (viewport.containsPixel(pixel)) {\n const p = xyz.slice();\n p[0] -= viewport.x;\n p[1] -= viewport.y;\n return viewport.unproject(p, opts);\n }\n }\n return null;\n }\n\n /** Update the manager with new Deck props */\n setProps(props: Partial>) {\n if (props.views) {\n this._setViews(props.views);\n }\n\n if (props.viewState) {\n this._setViewState(props.viewState);\n }\n\n if ('width' in props || 'height' in props) {\n this._setSize(props.width as number, props.height as number);\n }\n\n // Important: avoid invoking _update() inside itself\n // Nested updates result in unexpected side effects inside _rebuildViewports()\n // when using auto control in pure-js\n if (!this._isUpdating) {\n this._update();\n }\n }\n\n //\n // PRIVATE METHODS\n //\n\n private _update(): void {\n this._isUpdating = true;\n\n // Only rebuild viewports if the update flag is set\n if (this._needsUpdate) {\n this._needsUpdate = false;\n this._rebuildViewports();\n }\n\n // If viewport transition(s) are triggered during viewports update, controller(s)\n // will immediately call `onViewStateChange` which calls `viewManager.setProps` again.\n if (this._needsUpdate) {\n this._needsUpdate = false;\n this._rebuildViewports();\n }\n\n this._isUpdating = false;\n }\n\n private _setSize(width: number, height: number): void {\n if (width !== this.width || height !== this.height) {\n this.width = width;\n this.height = height;\n this.setNeedsUpdate('Size changed');\n }\n }\n\n // Update the view descriptor list and set change flag if needed\n // Does not actually rebuild the `Viewport`s until `getViewports` is called\n private _setViews(views: View[]): void {\n views = flatten(views, Boolean);\n\n const viewsChanged = this._diffViews(views, this.views);\n if (viewsChanged) {\n this.setNeedsUpdate('views changed');\n }\n\n this.views = views;\n }\n\n private _setViewState(viewState: ViewStateObject): void {\n if (viewState) {\n // depth = 3 when comparing viewStates: viewId.position.0\n const viewStateChanged = !deepEqual(viewState, this.viewState, 3);\n\n if (viewStateChanged) {\n this.setNeedsUpdate('viewState changed');\n }\n\n this.viewState = viewState;\n } else {\n log.warn('missing `viewState` or `initialViewState`')();\n }\n }\n\n private _createController(\n view: View,\n props: {id: string; type: ConstructorOf>}\n ): Controller {\n const Controller = props.type;\n\n const controller = new Controller({\n timeline: this.timeline,\n eventManager: this._eventManager,\n // Set an internal callback that calls the prop callback if provided\n onViewStateChange: this._eventCallbacks.onViewStateChange,\n onStateChange: this._eventCallbacks.onInteractionStateChange,\n makeViewport: viewState =>\n this.getView(view.id)?.makeViewport({\n viewState,\n width: this.width,\n height: this.height\n })\n });\n\n return controller;\n }\n\n private _updateController(\n view: View,\n viewState: AnyViewStateOf,\n viewport: Viewport | null,\n controller?: Controller | null\n ): Controller | null {\n const controllerProps = view.controller;\n if (controllerProps && viewport) {\n const resolvedProps = {\n ...viewState,\n ...controllerProps,\n id: view.id,\n x: viewport.x,\n y: viewport.y,\n width: viewport.width,\n height: viewport.height\n };\n\n // Create controller if not already existing or if the type of the\n // controller has changed.\n if (!controller || controller.constructor !== controllerProps.type) {\n controller = this._createController(view, resolvedProps);\n }\n if (controller) {\n controller.setProps(resolvedProps);\n }\n return controller;\n }\n return null;\n }\n\n // Rebuilds viewports from descriptors towards a certain window size\n private _rebuildViewports(): void {\n const {views} = this;\n\n const oldControllers = this.controllers;\n this._viewports = [];\n this.controllers = {};\n\n let invalidateControllers = false;\n // Create controllers in reverse order, so that views on top receive events first\n for (let i = views.length; i--; ) {\n const view = views[i];\n const viewState = this.getViewState(view);\n const viewport = view.makeViewport({viewState, width: this.width, height: this.height});\n\n let oldController = oldControllers[view.id];\n const hasController = Boolean(view.controller);\n if (hasController && !oldController) {\n // When a new controller is added, invalidate all controllers below it so that\n // events are registered in the correct order\n invalidateControllers = true;\n }\n if ((invalidateControllers || !hasController) && oldController) {\n // Remove and reattach invalidated controller\n oldController.finalize();\n oldController = null;\n }\n\n // Update the controller\n this.controllers[view.id] = this._updateController(view, viewState, viewport, oldController);\n\n if (viewport) {\n this._viewports.unshift(viewport);\n }\n }\n\n // Remove unused controllers\n for (const id in oldControllers) {\n const oldController = oldControllers[id];\n if (oldController && !this.controllers[id]) {\n oldController.finalize();\n }\n }\n\n this._buildViewportMap();\n }\n\n _buildViewportMap(): void {\n // Build a view id to view index\n this._viewportMap = {};\n this._viewports.forEach(viewport => {\n if (viewport.id) {\n // TODO - issue warning if multiple viewports use same id\n this._viewportMap[viewport.id] = this._viewportMap[viewport.id] || viewport;\n }\n });\n }\n\n // Check if viewport array has changed, returns true if any change\n // Note that descriptors can be the same\n _diffViews(newViews: View[], oldViews: View[]): boolean {\n if (newViews.length !== oldViews.length) {\n return true;\n }\n\n return newViews.some((_, i) => !newViews[i].equals(oldViews[i]));\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst PERCENT_OR_PIXELS_REGEX = /([0-9]+\\.?[0-9]*)(%|px)/;\n\nexport type Position = {\n position: number;\n relative: boolean;\n};\n\n// Takes a number or a string of formats `50%`, `33.3%` or `200px`\nexport function parsePosition(value: number | string): Position {\n switch (typeof value) {\n case 'number':\n return {\n position: value,\n relative: false\n };\n\n case 'string':\n const match = PERCENT_OR_PIXELS_REGEX.exec(value);\n if (match && match.length >= 3) {\n const relative = match[2] === '%';\n const position = parseFloat(match[1]);\n return {\n position: relative ? position / 100 : position,\n relative\n };\n }\n // fallthrough\n\n default:\n // eslint-disable-line\n throw new Error(`Could not parse position string ${value}`);\n }\n}\n\nexport function getPosition(position: Position, extent: number): number {\n return position.relative ? Math.round(position.position * extent) : position.position;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Viewport from '../viewports/viewport';\nimport {parsePosition, getPosition, Position} from '../utils/positions';\nimport {deepEqual} from '../utils/deep-equal';\nimport type Controller from '../controllers/controller';\nimport type {ControllerOptions} from '../controllers/controller';\nimport type {TransitionProps} from '../controllers/transition-manager';\nimport type {Padding} from '../viewports/viewport';\nimport type {ConstructorOf} from '../types/types';\n\nexport type CommonViewState = TransitionProps;\n\nexport type CommonViewProps = {\n /** A unique id of the view. In a multi-view use case, this is important for matching view states and place contents into this view. */\n id?: string;\n /** A relative (e.g. `'50%'`) or absolute position. Default `0`. */\n x?: number | string;\n /** A relative (e.g. `'50%'`) or absolute position. Default `0`. */\n y?: number | string;\n /** A relative (e.g. `'50%'`) or absolute extent. Default `'100%'`. */\n width?: number | string;\n /** A relative (e.g. `'50%'`) or absolute extent. Default `'100%'`. */\n height?: number | string;\n /** Padding around the view, expressed in either relative (e.g. `'50%'`) or absolute pixels. Default `null`. */\n padding?: {\n left?: number | string;\n right?: number | string;\n top?: number | string;\n bottom?: number | string;\n } | null;\n /** When using multiple views, set this flag to wipe the pixels drawn by other overlaping views */\n clear?: boolean;\n /** State of the view */\n viewState?:\n | string\n | ({\n id?: string;\n } & Partial);\n /** Options for viewport interactivity. */\n controller?:\n | null\n | boolean\n | ConstructorOf>\n | (ControllerOptions & {\n type?: ConstructorOf>;\n });\n};\n\nexport default abstract class View<\n ViewState extends CommonViewState = CommonViewState,\n ViewProps extends CommonViewProps = CommonViewProps\n> {\n id: string;\n abstract getViewportType(viewState: ViewState): ConstructorOf;\n protected abstract get ControllerType(): ConstructorOf>;\n\n private _x: Position;\n private _y: Position;\n private _width: Position;\n private _height: Position;\n private _padding: {\n left: Position;\n right: Position;\n top: Position;\n bottom: Position;\n } | null;\n\n readonly props: ViewProps;\n\n constructor(props: ViewProps) {\n const {id, x = 0, y = 0, width = '100%', height = '100%', padding = null} = props;\n\n // @ts-ignore\n this.id = id || this.constructor.displayName || 'view';\n\n this.props = {...props, id: this.id};\n\n // Extents\n this._x = parsePosition(x);\n this._y = parsePosition(y);\n this._width = parsePosition(width);\n this._height = parsePosition(height);\n this._padding = padding && {\n left: parsePosition(padding.left || 0),\n right: parsePosition(padding.right || 0),\n top: parsePosition(padding.top || 0),\n bottom: parsePosition(padding.bottom || 0)\n };\n\n // Bind methods for easy access\n this.equals = this.equals.bind(this);\n\n Object.seal(this);\n }\n\n equals(view: this): boolean {\n if (this === view) {\n return true;\n }\n\n // To correctly compare padding use depth=2\n return this.constructor === view.constructor && deepEqual(this.props, view.props, 2);\n }\n\n /** Make viewport from canvas dimensions and view state */\n makeViewport({width, height, viewState}: {width: number; height: number; viewState: ViewState}) {\n viewState = this.filterViewState(viewState);\n\n // Resolve relative viewport dimensions\n const viewportDimensions = this.getDimensions({width, height});\n if (!viewportDimensions.height || !viewportDimensions.width) {\n return null;\n }\n const ViewportType = this.getViewportType(viewState);\n return new ViewportType({...viewState, ...this.props, ...viewportDimensions});\n }\n\n getViewStateId(): string {\n const {viewState} = this.props;\n if (typeof viewState === 'string') {\n // if View.viewState is a string, return it\n return viewState;\n }\n return viewState?.id || this.id;\n }\n\n // Allows view to override (or completely define) viewState\n filterViewState(viewState: ViewState): ViewState {\n if (this.props.viewState && typeof this.props.viewState === 'object') {\n // If we have specified an id, then intent is to override,\n // If not, completely specify the view state\n if (!this.props.viewState.id) {\n return this.props.viewState as ViewState;\n }\n\n // Merge in all props from View's viewState, except id\n const newViewState = {...viewState};\n for (const key in this.props.viewState) {\n if (key !== 'id') {\n newViewState[key] = this.props.viewState[key];\n }\n }\n return newViewState;\n }\n\n return viewState;\n }\n\n /** Resolve the dimensions of the view from overall canvas dimensions */\n getDimensions({width, height}: {width: number; height: number}): {\n x: number;\n y: number;\n width: number;\n height: number;\n padding?: Padding;\n } {\n const dimensions: {\n x: number;\n y: number;\n width: number;\n height: number;\n padding?: Padding;\n } = {\n x: getPosition(this._x, width),\n y: getPosition(this._y, height),\n width: getPosition(this._width, width),\n height: getPosition(this._height, height)\n };\n\n if (this._padding) {\n dimensions.padding = {\n left: getPosition(this._padding.left, width),\n top: getPosition(this._padding.top, height),\n right: getPosition(this._padding.right, width),\n bottom: getPosition(this._padding.bottom, height)\n };\n }\n return dimensions;\n }\n\n // Used by sub classes to resolve controller props\n get controller(): (ControllerOptions & {type: ConstructorOf>}) | null {\n const opts = this.props.controller;\n\n if (!opts) {\n return null;\n }\n if (opts === true) {\n return {type: this.ControllerType};\n }\n if (typeof opts === 'function') {\n return {type: opts};\n }\n return {type: this.ControllerType, ...opts};\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {clamp} from '@math.gl/core';\nimport Controller, {ControllerProps} from './controller';\nimport ViewState from './view-state';\nimport {normalizeViewportProps} from '@math.gl/web-mercator';\nimport assert from '../utils/assert';\n\nimport LinearInterpolator from '../transitions/linear-interpolator';\nimport type Viewport from '../viewports/viewport';\n\nconst PITCH_MOUSE_THRESHOLD = 5;\nconst PITCH_ACCEL = 1.2;\n\nexport type MapStateProps = {\n /** Mapbox viewport properties */\n /** The width of the viewport */\n width: number;\n /** The height of the viewport */\n height: number;\n /** The latitude at the center of the viewport */\n latitude: number;\n /** The longitude at the center of the viewport */\n longitude: number;\n /** The tile zoom level of the map. */\n zoom: number;\n /** The bearing of the viewport in degrees */\n bearing?: number;\n /** The pitch of the viewport in degrees */\n pitch?: number;\n /**\n * Specify the altitude of the viewport camera\n * Unit: map heights, default 1.5\n * Non-public API, see https://github.com/mapbox/mapbox-gl-js/issues/1137\n */\n altitude?: number;\n /** Viewport position */\n position?: [number, number, number];\n\n /** Viewport constraints */\n maxZoom?: number;\n minZoom?: number;\n maxPitch?: number;\n minPitch?: number;\n\n /** Normalize viewport props to fit map height into viewport. Default `true` */\n normalize?: boolean;\n};\n\ntype MapStateInternal = {\n /** Interaction states, required to calculate change during transform */\n /* The point on map being grabbed when the operation first started */\n startPanLngLat?: [number, number];\n /* Center of the zoom when the operation first started */\n startZoomLngLat?: [number, number];\n /* Pointer position when rotation started */\n startRotatePos?: [number, number];\n /** Bearing when current perspective rotate operation started */\n startBearing?: number;\n /** Pitch when current perspective rotate operation started */\n startPitch?: number;\n /** Zoom when current zoom operation started */\n startZoom?: number;\n};\n\n/* Utils */\n\nexport class MapState extends ViewState {\n makeViewport: (props: Record) => Viewport;\n\n constructor(\n options: MapStateProps &\n MapStateInternal & {\n makeViewport: (props: Record) => Viewport;\n }\n ) {\n const {\n /** Mapbox viewport properties */\n /** The width of the viewport */\n width,\n /** The height of the viewport */\n height,\n /** The latitude at the center of the viewport */\n latitude,\n /** The longitude at the center of the viewport */\n longitude,\n /** The tile zoom level of the map. */\n zoom,\n /** The bearing of the viewport in degrees */\n bearing = 0,\n /** The pitch of the viewport in degrees */\n pitch = 0,\n /**\n * Specify the altitude of the viewport camera\n * Unit: map heights, default 1.5\n * Non-public API, see https://github.com/mapbox/mapbox-gl-js/issues/1137\n */\n altitude = 1.5,\n /** Viewport position */\n position = [0, 0, 0],\n\n /** Viewport constraints */\n maxZoom = 20,\n minZoom = 0,\n maxPitch = 60,\n minPitch = 0,\n\n /** Interaction states, required to calculate change during transform */\n /* The point on map being grabbed when the operation first started */\n startPanLngLat,\n /* Center of the zoom when the operation first started */\n startZoomLngLat,\n /* Pointer position when rotation started */\n startRotatePos,\n /** Bearing when current perspective rotate operation started */\n startBearing,\n /** Pitch when current perspective rotate operation started */\n startPitch,\n /** Zoom when current zoom operation started */\n startZoom,\n\n /** Normalize viewport props to fit map height into viewport */\n normalize = true\n } = options;\n\n assert(Number.isFinite(longitude)); // `longitude` must be supplied\n assert(Number.isFinite(latitude)); // `latitude` must be supplied\n assert(Number.isFinite(zoom)); // `zoom` must be supplied\n\n super(\n {\n width,\n height,\n latitude,\n longitude,\n zoom,\n bearing,\n pitch,\n altitude,\n maxZoom,\n minZoom,\n maxPitch,\n minPitch,\n normalize,\n position\n },\n {\n startPanLngLat,\n startZoomLngLat,\n startRotatePos,\n startBearing,\n startPitch,\n startZoom\n }\n );\n\n this.makeViewport = options.makeViewport;\n }\n\n /**\n * Start panning\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n panStart({pos}: {pos: [number, number]}): MapState {\n return this._getUpdatedState({\n startPanLngLat: this._unproject(pos)\n });\n }\n\n /**\n * Pan\n * @param {[Number, Number]} pos - position on screen where the pointer is\n * @param {[Number, Number], optional} startPos - where the pointer grabbed at\n * the start of the operation. Must be supplied of `panStart()` was not called\n */\n pan({pos, startPos}: {pos: [number, number]; startPos?: [number, number]}): MapState {\n const startPanLngLat = this.getState().startPanLngLat || this._unproject(startPos);\n\n if (!startPanLngLat) {\n return this;\n }\n\n const viewport = this.makeViewport(this.getViewportProps());\n const newProps = viewport.panByPosition(startPanLngLat, pos);\n\n return this._getUpdatedState(newProps);\n }\n\n /**\n * End panning\n * Must call if `panStart()` was called\n */\n panEnd(): MapState {\n return this._getUpdatedState({\n startPanLngLat: null\n });\n }\n\n /**\n * Start rotating\n * @param {[Number, Number]} pos - position on screen where the center is\n */\n rotateStart({pos}: {pos: [number, number]}): MapState {\n return this._getUpdatedState({\n startRotatePos: pos,\n startBearing: this.getViewportProps().bearing,\n startPitch: this.getViewportProps().pitch\n });\n }\n\n /**\n * Rotate\n * @param {[Number, Number]} pos - position on screen where the center is\n */\n rotate({\n pos,\n deltaAngleX = 0,\n deltaAngleY = 0\n }: {\n pos?: [number, number];\n deltaAngleX?: number;\n deltaAngleY?: number;\n }): MapState {\n const {startRotatePos, startBearing, startPitch} = this.getState();\n\n if (!startRotatePos || startBearing === undefined || startPitch === undefined) {\n return this;\n }\n let newRotation;\n if (pos) {\n newRotation = this._getNewRotation(pos, startRotatePos, startPitch, startBearing);\n } else {\n newRotation = {\n bearing: startBearing + deltaAngleX,\n pitch: startPitch + deltaAngleY\n };\n }\n return this._getUpdatedState(newRotation);\n }\n\n /**\n * End rotating\n * Must call if `rotateStart()` was called\n */\n rotateEnd(): MapState {\n return this._getUpdatedState({\n startBearing: null,\n startPitch: null\n });\n }\n\n /**\n * Start zooming\n * @param {[Number, Number]} pos - position on screen where the center is\n */\n zoomStart({pos}: {pos: [number, number]}): MapState {\n return this._getUpdatedState({\n startZoomLngLat: this._unproject(pos),\n startZoom: this.getViewportProps().zoom\n });\n }\n\n /**\n * Zoom\n * @param {[Number, Number]} pos - position on screen where the current center is\n * @param {[Number, Number]} startPos - the center position at\n * the start of the operation. Must be supplied of `zoomStart()` was not called\n * @param {Number} scale - a number between [0, 1] specifying the accumulated\n * relative scale.\n */\n zoom({\n pos,\n startPos,\n scale\n }: {\n pos: [number, number];\n startPos?: [number, number];\n scale: number;\n }): MapState {\n // Make sure we zoom around the current mouse position rather than map center\n let {startZoom, startZoomLngLat} = this.getState();\n\n if (!startZoomLngLat) {\n // We have two modes of zoom:\n // scroll zoom that are discrete events (transform from the current zoom level),\n // and pinch zoom that are continuous events (transform from the zoom level when\n // pinch started).\n // If startZoom state is defined, then use the startZoom state;\n // otherwise assume discrete zooming\n startZoom = this.getViewportProps().zoom;\n startZoomLngLat = this._unproject(startPos) || this._unproject(pos);\n }\n if (!startZoomLngLat) {\n return this;\n }\n\n const {maxZoom, minZoom} = this.getViewportProps();\n let zoom = (startZoom as number) + Math.log2(scale);\n zoom = clamp(zoom, minZoom, maxZoom);\n\n const zoomedViewport = this.makeViewport({...this.getViewportProps(), zoom});\n\n return this._getUpdatedState({\n zoom,\n ...zoomedViewport.panByPosition(startZoomLngLat, pos)\n });\n }\n\n /**\n * End zooming\n * Must call if `zoomStart()` was called\n */\n zoomEnd(): MapState {\n return this._getUpdatedState({\n startZoomLngLat: null,\n startZoom: null\n });\n }\n\n zoomIn(speed: number = 2): MapState {\n return this._zoomFromCenter(speed);\n }\n\n zoomOut(speed: number = 2): MapState {\n return this._zoomFromCenter(1 / speed);\n }\n\n moveLeft(speed: number = 100): MapState {\n return this._panFromCenter([speed, 0]);\n }\n\n moveRight(speed: number = 100): MapState {\n return this._panFromCenter([-speed, 0]);\n }\n\n moveUp(speed: number = 100): MapState {\n return this._panFromCenter([0, speed]);\n }\n\n moveDown(speed: number = 100): MapState {\n return this._panFromCenter([0, -speed]);\n }\n\n rotateLeft(speed: number = 15): MapState {\n return this._getUpdatedState({\n bearing: this.getViewportProps().bearing - speed\n });\n }\n\n rotateRight(speed: number = 15): MapState {\n return this._getUpdatedState({\n bearing: this.getViewportProps().bearing + speed\n });\n }\n\n rotateUp(speed: number = 10): MapState {\n return this._getUpdatedState({\n pitch: this.getViewportProps().pitch + speed\n });\n }\n\n rotateDown(speed: number = 10): MapState {\n return this._getUpdatedState({\n pitch: this.getViewportProps().pitch - speed\n });\n }\n\n shortestPathFrom(viewState: MapState): MapStateProps {\n // const endViewStateProps = new this.ControllerState(endProps).shortestPathFrom(startViewstate);\n const fromProps = viewState.getViewportProps();\n const props = {...this.getViewportProps()};\n const {bearing, longitude} = props;\n\n if (Math.abs(bearing - fromProps.bearing) > 180) {\n props.bearing = bearing < 0 ? bearing + 360 : bearing - 360;\n }\n if (Math.abs(longitude - fromProps.longitude) > 180) {\n props.longitude = longitude < 0 ? longitude + 360 : longitude - 360;\n }\n return props;\n }\n\n // Apply any constraints (mathematical or defined by _viewportProps) to map state\n applyConstraints(props: Required): Required {\n // Ensure zoom is within specified range\n const {maxZoom, minZoom, zoom} = props;\n props.zoom = clamp(zoom, minZoom, maxZoom);\n\n // Ensure pitch is within specified range\n const {maxPitch, minPitch, pitch} = props;\n props.pitch = clamp(pitch, minPitch, maxPitch);\n\n // Normalize viewport props to fit map height into viewport\n const {normalize = true} = props;\n if (normalize) {\n Object.assign(props, normalizeViewportProps(props));\n }\n\n return props;\n }\n\n /* Private methods */\n\n _zoomFromCenter(scale) {\n const {width, height} = this.getViewportProps();\n return this.zoom({\n pos: [width / 2, height / 2],\n scale\n });\n }\n\n _panFromCenter(offset) {\n const {width, height} = this.getViewportProps();\n return this.pan({\n startPos: [width / 2, height / 2],\n pos: [width / 2 + offset[0], height / 2 + offset[1]]\n });\n }\n\n _getUpdatedState(newProps): MapState {\n // @ts-ignore\n return new this.constructor({\n makeViewport: this.makeViewport,\n ...this.getViewportProps(),\n ...this.getState(),\n ...newProps\n });\n }\n\n _unproject(pos?: [number, number]): [number, number] | undefined {\n const viewport = this.makeViewport(this.getViewportProps());\n // @ts-ignore\n return pos && viewport.unproject(pos);\n }\n\n _getNewRotation(\n pos: [number, number],\n startPos: [number, number],\n startPitch: number,\n startBearing: number\n ): {\n pitch: number;\n bearing: number;\n } {\n const deltaX = pos[0] - startPos[0];\n const deltaY = pos[1] - startPos[1];\n const centerY = pos[1];\n const startY = startPos[1];\n const {width, height} = this.getViewportProps();\n\n const deltaScaleX = deltaX / width;\n let deltaScaleY = 0;\n\n if (deltaY > 0) {\n if (Math.abs(height - startY) > PITCH_MOUSE_THRESHOLD) {\n // Move from 0 to -1 as we drag upwards\n deltaScaleY = (deltaY / (startY - height)) * PITCH_ACCEL;\n }\n } else if (deltaY < 0) {\n if (startY > PITCH_MOUSE_THRESHOLD) {\n // Move from 0 to 1 as we drag upwards\n deltaScaleY = 1 - centerY / startY;\n }\n }\n // clamp deltaScaleY to [-1, 1] so that rotation is constrained between minPitch and maxPitch.\n // deltaScaleX does not need to be clamped as bearing does not have constraints.\n deltaScaleY = clamp(deltaScaleY, -1, 1);\n\n const {minPitch, maxPitch} = this.getViewportProps();\n\n const bearing = startBearing + 180 * deltaScaleX;\n let pitch = startPitch;\n if (deltaScaleY > 0) {\n // Gradually increase pitch\n pitch = startPitch + deltaScaleY * (maxPitch - startPitch);\n } else if (deltaScaleY < 0) {\n // Gradually decrease pitch\n pitch = startPitch - deltaScaleY * (minPitch - startPitch);\n }\n\n return {\n pitch,\n bearing\n };\n }\n}\n\nexport default class MapController extends Controller {\n ControllerState = MapState;\n\n transition = {\n transitionDuration: 300,\n transitionInterpolator: new LinearInterpolator({\n transitionProps: {\n compare: ['longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],\n required: ['longitude', 'latitude', 'zoom']\n }\n })\n };\n\n dragMode: 'pan' | 'rotate' = 'pan';\n\n setProps(props: ControllerProps & MapStateProps) {\n props.position = props.position || [0, 0, 0];\n const oldProps = this.props;\n\n super.setProps(props);\n\n const dimensionChanged = !oldProps || oldProps.height !== props.height;\n if (dimensionChanged) {\n // Dimensions changed, normalize the props\n this.updateViewport(\n new this.ControllerState({\n makeViewport: this.makeViewport,\n ...props,\n ...this.state\n })\n );\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Timeline} from '@luma.gl/engine';\n\nexport type TransitionSettings = {\n duration: number;\n onStart?: (transition: Transition) => void;\n onUpdate?: (transition: Transition) => void;\n onInterrupt?: (transition: Transition) => void;\n onEnd?: (transition: Transition) => void;\n};\n\nexport default class Transition {\n private _inProgress: boolean = false;\n private _handle: number | null = null;\n private _timeline: Timeline;\n\n time: number = 0;\n // @ts-expect-error\n settings: TransitionSettings & {fromValue; toValue; duration; easing; damping; stiffness} = {\n duration: 0\n };\n\n /**\n * @params timeline {Timeline}\n */\n constructor(timeline: Timeline) {\n this._timeline = timeline;\n }\n\n /* Public API */\n get inProgress(): boolean {\n return this._inProgress;\n }\n\n /**\n * (re)start this transition.\n * @params props {object} - optional overriding props. see constructor\n */\n start(settings: TransitionSettings) {\n this.cancel();\n // @ts-expect-error\n this.settings = settings;\n this._inProgress = true;\n this.settings.onStart?.(this);\n }\n\n /**\n * end this transition if it is in progress.\n */\n end() {\n if (this._inProgress) {\n this._timeline.removeChannel(this._handle as number);\n this._handle = null;\n this._inProgress = false;\n this.settings.onEnd?.(this);\n }\n }\n\n /**\n * cancel this transition if it is in progress.\n */\n cancel() {\n if (this._inProgress) {\n this.settings.onInterrupt?.(this);\n this._timeline.removeChannel(this._handle as number);\n this._handle = null;\n this._inProgress = false;\n }\n }\n\n /**\n * update this transition. Returns `true` if updated.\n */\n update() {\n if (!this._inProgress) {\n return false;\n }\n\n // It is important to initialize the handle during `update` instead of `start`.\n // The CPU time that the `start` frame takes should not be counted towards the duration.\n // On the other hand, `update` always happens during a render cycle. The clock starts when the\n // transition is rendered for the first time.\n if (this._handle === null) {\n const {_timeline: timeline, settings} = this;\n this._handle = timeline.addChannel({\n delay: timeline.getTime(),\n duration: settings.duration\n });\n }\n\n this.time = this._timeline.getTime(this._handle);\n // Call subclass method\n this._onUpdate();\n // Call user callback\n this.settings.onUpdate?.(this);\n\n // This only works if `settings.duration` is set\n // Spring transition must call `end` manually\n if (this._timeline.isFinished(this._handle)) {\n this.end();\n }\n return true;\n }\n\n /* Private API */\n\n protected _onUpdate() {\n // for subclass override\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Transition, {TransitionSettings as BaseTransitionSettings} from '../transitions/transition';\nimport TransitionInterpolator from '../transitions/transition-interpolator';\nimport type {IViewState} from './view-state';\n\nimport type {Timeline} from '@luma.gl/engine';\nimport type {InteractionState} from './controller';\n\nconst noop = () => {};\n\n// Enums cannot be directly exported as they are not transpiled correctly into ES5, see https://github.com/visgl/deck.gl/issues/7130\nexport const TRANSITION_EVENTS = {\n BREAK: 1,\n SNAP_TO_END: 2,\n IGNORE: 3\n} as const;\n\ntype TransitionEvent = 1 | 2 | 3;\n\nexport type TransitionProps = {\n /** Transition duration in milliseconds, default value 0, implies no transition. When using `FlyToInterpolator`, it can also be set to `'auto'`. */\n transitionDuration?: number | 'auto';\n /** An interpolator object that defines the transition behavior between two viewports. */\n transitionInterpolator?: TransitionInterpolator;\n /** Easing function that can be used to achieve effects like \"Ease-In-Cubic\", \"Ease-Out-Cubic\", etc. Default value performs Linear easing. */\n transitionEasing?: (t: number) => number;\n /** Controls how to process a new view state change that occurs during an existing transition. */\n transitionInterruption?: TransitionEvent;\n /** Callback fired when requested transition starts. */\n onTransitionStart?: (transition: Transition) => void;\n /** Callback fired when requested transition is interrupted. */\n onTransitionInterrupt?: (transition: Transition) => void;\n /** Callback fired when requested transition ends. */\n onTransitionEnd?: (transition: Transition) => void;\n};\n\nconst DEFAULT_EASING = t => t;\nconst DEFAULT_INTERRUPTION = TRANSITION_EVENTS.BREAK;\n\ntype TransitionSettings = BaseTransitionSettings & {\n interpolator: TransitionInterpolator;\n easing: (t: number) => number;\n interruption: TransitionEvent;\n startProps: Record;\n endProps: Record;\n};\n\nexport default class TransitionManager> {\n getControllerState: (props: any) => ControllerState;\n props?: TransitionProps;\n propsInTransition: Record | null;\n transition: Transition;\n onViewStateChange: (params: {\n viewState: Record;\n oldViewState: Record;\n }) => void;\n onStateChange: (state: InteractionState) => void;\n\n constructor(opts: {\n timeline: Timeline;\n getControllerState: (props: any) => ControllerState;\n onViewStateChange?: (params: {\n viewState: Record;\n oldViewState: Record;\n }) => void;\n onStateChange?: (state: InteractionState) => void;\n }) {\n this.getControllerState = opts.getControllerState;\n this.propsInTransition = null;\n this.transition = new Transition(opts.timeline);\n\n this.onViewStateChange = opts.onViewStateChange || noop;\n this.onStateChange = opts.onStateChange || noop;\n }\n\n finalize(): void {\n this.transition.cancel();\n }\n\n // Returns current transitioned viewport.\n getViewportInTransition(): Record | null {\n return this.propsInTransition;\n }\n\n // Process the vewiport change, either ignore or trigger a new transition.\n // Return true if a new transition is triggered, false otherwise.\n processViewStateChange(nextProps: TransitionProps) {\n let transitionTriggered = false;\n const currentProps = this.props;\n // Set this.props here as '_triggerTransition' calls '_updateViewport' that uses this.props.\n this.props = nextProps;\n\n // NOTE: Be cautious re-ordering statements in this function.\n if (!currentProps || this._shouldIgnoreViewportChange(currentProps, nextProps)) {\n return false;\n }\n\n if (this._isTransitionEnabled(nextProps)) {\n let startProps = currentProps;\n if (this.transition.inProgress) {\n // @ts-expect-error\n const {interruption, endProps} = this.transition.settings as TransitionSettings;\n startProps = {\n ...currentProps,\n ...(interruption === TRANSITION_EVENTS.SNAP_TO_END\n ? endProps\n : this.propsInTransition || currentProps)\n };\n }\n\n this._triggerTransition(startProps, nextProps);\n\n transitionTriggered = true;\n } else {\n this.transition.cancel();\n }\n\n return transitionTriggered;\n }\n\n updateTransition() {\n this.transition.update();\n }\n\n // Helper methods\n\n _isTransitionEnabled(props: TransitionProps): boolean {\n const {transitionDuration, transitionInterpolator} = props;\n return (\n ((transitionDuration as number) > 0 || transitionDuration === 'auto') &&\n Boolean(transitionInterpolator)\n );\n }\n\n _isUpdateDueToCurrentTransition(props: TransitionProps): boolean {\n if (this.transition.inProgress && this.propsInTransition) {\n // @ts-expect-error\n return (this.transition.settings as TransitionSettings).interpolator.arePropsEqual(\n props,\n this.propsInTransition\n );\n }\n return false;\n }\n\n _shouldIgnoreViewportChange(currentProps: TransitionProps, nextProps: TransitionProps): boolean {\n if (this.transition.inProgress) {\n // @ts-expect-error\n const transitionSettings = this.transition.settings as TransitionSettings;\n // Ignore update if it is requested to be ignored\n return (\n transitionSettings.interruption === TRANSITION_EVENTS.IGNORE ||\n // Ignore update if it is due to current active transition.\n this._isUpdateDueToCurrentTransition(nextProps)\n );\n }\n if (this._isTransitionEnabled(nextProps)) {\n // Ignore if none of the viewport props changed.\n return (nextProps.transitionInterpolator as TransitionInterpolator).arePropsEqual(\n currentProps,\n nextProps\n );\n }\n return true;\n }\n\n _triggerTransition(startProps: TransitionProps, endProps: TransitionProps): void {\n const startViewstate = this.getControllerState(startProps);\n const endViewStateProps = this.getControllerState(endProps).shortestPathFrom(startViewstate);\n\n // update transitionDuration for 'auto' mode\n const transitionInterpolator = endProps.transitionInterpolator as TransitionInterpolator;\n const duration = transitionInterpolator.getDuration\n ? transitionInterpolator.getDuration(startProps, endProps)\n : (endProps.transitionDuration as number);\n\n if (duration === 0) {\n return;\n }\n\n const initialProps = transitionInterpolator.initializeProps(startProps, endViewStateProps);\n\n this.propsInTransition = {};\n const transitionSettings: TransitionSettings = {\n duration,\n easing: endProps.transitionEasing || DEFAULT_EASING,\n interpolator: transitionInterpolator,\n interruption: endProps.transitionInterruption || DEFAULT_INTERRUPTION,\n\n startProps: initialProps.start,\n endProps: initialProps.end,\n\n onStart: endProps.onTransitionStart,\n onUpdate: this._onTransitionUpdate,\n onInterrupt: this._onTransitionEnd(endProps.onTransitionInterrupt),\n onEnd: this._onTransitionEnd(endProps.onTransitionEnd)\n };\n this.transition.start(transitionSettings);\n\n this.onStateChange({inTransition: true});\n\n this.updateTransition();\n }\n\n _onTransitionEnd(callback?: (transition: Transition) => void) {\n return transition => {\n this.propsInTransition = null;\n\n this.onStateChange({\n inTransition: false,\n isZooming: false,\n isPanning: false,\n isRotating: false\n });\n\n callback?.(transition);\n };\n }\n\n _onTransitionUpdate = transition => {\n // NOTE: Be cautious re-ordering statements in this function.\n const {\n time,\n settings: {interpolator, startProps, endProps, duration, easing}\n } = transition;\n const t = easing(time / duration);\n const viewport = interpolator.interpolateProps(startProps, endProps, t);\n\n // This gurantees all props (e.g. bearing, longitude) are normalized\n // So when viewports are compared they are in same range.\n this.propsInTransition = this.getControllerState({\n ...this.props,\n ...viewport\n }).getViewportProps();\n\n this.onViewStateChange({\n viewState: this.propsInTransition,\n oldViewState: this.props as TransitionProps\n });\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {equals} from '@math.gl/core';\nimport assert from '../utils/assert';\n\nexport default abstract class TransitionInterpolator {\n protected _propsToCompare: string[];\n protected _propsToExtract: string[];\n protected _requiredProps?: string[];\n\n /**\n * @param opts {array|object}\n * @param opts.compare {array} - prop names used in equality check\n * @param opts.extract {array} - prop names needed for interpolation\n * @param opts.required {array} - prop names that must be supplied\n * alternatively, supply one list of prop names as `opts` if all of the above are the same.\n */\n constructor(opts: {compare: string[]; extract?: string[]; required?: string[]}) {\n const {compare, extract, required} = opts;\n\n this._propsToCompare = compare;\n this._propsToExtract = extract || compare;\n this._requiredProps = required;\n }\n\n /**\n * Checks if two sets of props need transition in between\n * @param currentProps {object} - a list of viewport props\n * @param nextProps {object} - a list of viewport props\n * @returns {bool} - true if two props are equivalent\n */\n arePropsEqual(currentProps: Record, nextProps: Record): boolean {\n for (const key of this._propsToCompare) {\n if (\n !(key in currentProps) ||\n !(key in nextProps) ||\n !equals(currentProps[key], nextProps[key])\n ) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Called before transition starts to validate/pre-process start and end props\n * @param startProps {object} - a list of starting viewport props\n * @param endProps {object} - a list of target viewport props\n * @returns {Object} {start, end} - start and end props to be passed\n * to `interpolateProps`\n */\n initializeProps(\n startProps: Record,\n endProps: Record\n ): {\n start: Record;\n end: Record;\n } {\n const startViewStateProps = {};\n const endViewStateProps = {};\n\n for (const key of this._propsToExtract) {\n if (key in startProps || key in endProps) {\n startViewStateProps[key] = startProps[key];\n endViewStateProps[key] = endProps[key];\n }\n }\n\n this._checkRequiredProps(startViewStateProps);\n this._checkRequiredProps(endViewStateProps);\n\n return {start: startViewStateProps, end: endViewStateProps};\n }\n\n /**\n * Returns viewport props in transition\n * @param startProps {object} - a list of starting viewport props\n * @param endProps {object} - a list of target viewport props\n * @param t {number} - a time factor between [0, 1]\n * @returns {object} - a list of interpolated viewport props\n */\n abstract interpolateProps(\n startProps: Record,\n endProps: Record,\n t: number\n ): Record;\n\n /**\n * Returns transition duration\n * @param startProps {object} - a list of starting viewport props\n * @param endProps {object} - a list of target viewport props\n * @returns {Number} - transition duration in milliseconds\n */\n getDuration(startProps: Record, endProps: Record): number {\n return endProps.transitionDuration;\n }\n\n _checkRequiredProps(props) {\n if (!this._requiredProps) {\n return;\n }\n\n this._requiredProps.forEach(propName => {\n const value = props[propName];\n assert(\n Number.isFinite(value) || Array.isArray(value),\n `${propName} is required for transition`\n );\n });\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\nexport default function assert(condition: any, message?: string): asserts condition {\n if (!condition) {\n throw new Error(message || 'deck.gl: assertion failed.');\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport TransitionInterpolator from './transition-interpolator';\nimport {lerp} from '@math.gl/core';\n\nimport type Viewport from '../viewports/viewport';\n\nconst DEFAULT_PROPS = ['longitude', 'latitude', 'zoom', 'bearing', 'pitch'];\nconst DEFAULT_REQUIRED_PROPS = ['longitude', 'latitude', 'zoom'];\n\ntype PropsWithAnchor = {\n around?: number[];\n aroundPosition?: number[];\n [key: string]: any;\n};\n\n/**\n * Performs linear interpolation of two view states.\n */\nexport default class LinearInterpolator extends TransitionInterpolator {\n opts: {\n around?: number[];\n makeViewport?: (props: Record) => Viewport;\n };\n\n /**\n * @param {Object} opts\n * @param {Array} opts.transitionProps - list of props to apply linear transition to.\n * @param {Array} opts.around - a screen point to zoom/rotate around.\n * @param {Function} opts.makeViewport - construct a viewport instance with given props.\n */\n constructor(\n opts:\n | string[]\n | {\n transitionProps?:\n | string[]\n | {\n compare: string[];\n extract?: string[];\n required?: string[];\n };\n around?: number[];\n makeViewport?: (props: Record) => Viewport;\n } = {}\n ) {\n // Backward compatibility\n const transitionProps = Array.isArray(opts) ? opts : opts.transitionProps;\n\n const normalizedOpts = Array.isArray(opts) ? {} : opts;\n normalizedOpts.transitionProps = Array.isArray(transitionProps)\n ? {\n compare: transitionProps,\n required: transitionProps\n }\n : transitionProps || {\n compare: DEFAULT_PROPS,\n required: DEFAULT_REQUIRED_PROPS\n };\n\n super(normalizedOpts.transitionProps);\n this.opts = normalizedOpts;\n }\n\n initializeProps(\n startProps: Record,\n endProps: Record\n ): {\n start: PropsWithAnchor;\n end: PropsWithAnchor;\n } {\n const result = super.initializeProps(startProps, endProps);\n\n const {makeViewport, around} = this.opts;\n if (makeViewport && around) {\n const startViewport = makeViewport(startProps);\n const endViewport = makeViewport(endProps);\n const aroundPosition = startViewport.unproject(around);\n result.start.around = around;\n Object.assign(result.end, {\n around: endViewport.project(aroundPosition),\n aroundPosition,\n width: endProps.width,\n height: endProps.height\n });\n }\n\n return result;\n }\n\n interpolateProps(\n startProps: PropsWithAnchor,\n endProps: PropsWithAnchor,\n t: number\n ): Record {\n const propsInTransition = {};\n for (const key of this._propsToExtract) {\n propsInTransition[key] = lerp(startProps[key] || 0, endProps[key] || 0, t);\n }\n\n if (endProps.aroundPosition && this.opts.makeViewport) {\n // Linear transition should be performed in common space\n const viewport = this.opts.makeViewport({...endProps, ...propsInTransition});\n Object.assign(\n propsInTransition,\n viewport.panByPosition(\n endProps.aroundPosition,\n // anchor point in current screen coordinates\n lerp(startProps.around as number[], endProps.around as number[], t) as number[]\n )\n );\n }\n return propsInTransition;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable max-statements, complexity */\nimport TransitionManager, {TransitionProps} from './transition-manager';\nimport LinearInterpolator from '../transitions/linear-interpolator';\nimport {IViewState} from './view-state';\nimport {ConstructorOf} from '../types/types';\n\nimport type Viewport from '../viewports/viewport';\n\nimport type {EventManager, MjolnirEvent, MjolnirGestureEvent, MjolnirWheelEvent, MjolnirKeyEvent} from 'mjolnir.js';\nimport type {Timeline} from '@luma.gl/engine';\n\nconst NO_TRANSITION_PROPS = {\n transitionDuration: 0\n} as const;\n\nconst DEFAULT_INERTIA = 300;\nconst INERTIA_EASING = t => 1 - (1 - t) * (1 - t);\n\nconst EVENT_TYPES = {\n WHEEL: ['wheel'],\n PAN: ['panstart', 'panmove', 'panend'],\n PINCH: ['pinchstart', 'pinchmove', 'pinchend'],\n MULTI_PAN: ['multipanstart', 'multipanmove', 'multipanend'],\n DOUBLE_CLICK: ['dblclick'],\n KEYBOARD: ['keydown']\n} as const;\n\n/** Configuration of how user input is handled */\nexport type ControllerOptions = {\n /** Enable zooming with mouse wheel. Default `true`. */\n scrollZoom?: boolean | {\n /** Scaler that translates wheel delta to the change of viewport scale. Default `0.01`. */\n speed?: number;\n /** Smoothly transition to the new zoom. If enabled, will provide a slightly lagged but smoother experience. Default `false`. */\n smooth?: boolean\n };\n /** Enable panning with pointer drag. Default `true` */\n dragPan?: boolean;\n /** Enable rotating with pointer drag. Default `true` */\n dragRotate?: boolean;\n /** Enable zooming with double click. Default `true` */\n doubleClickZoom?: boolean;\n /** Enable zooming with multi-touch. Default `true` */\n touchZoom?: boolean;\n /** Enable rotating with multi-touch. Use two-finger rotating gesture for horizontal and three-finger swiping gesture for vertical rotation. Default `false` */\n touchRotate?: boolean;\n /** Enable interaction with keyboard. Default `true`. */\n keyboard?:\n | boolean\n | {\n /** Speed of zoom using +/- keys. Default `2` */\n zoomSpeed?: number;\n /** Speed of movement using arrow keys, in pixels. */\n moveSpeed?: number;\n /** Speed of rotation using shift + left/right arrow keys, in degrees. Default 15. */\n rotateSpeedX?: number;\n /** Speed of rotation using shift + up/down arrow keys, in degrees. Default 10. */\n rotateSpeedY?: number;\n };\n /** Drag behavior without pressing function keys, one of `pan` and `rotate`. */\n dragMode?: 'pan' | 'rotate';\n /** Enable inertia after panning/pinching. If a number is provided, indicates the duration of time over which the velocity reduces to zero, in milliseconds. Default `false`. */\n inertia?: boolean | number;\n};\n\nexport type ControllerProps = {\n /** Identifier of the controller */\n id: string;\n /** Viewport x position */\n x: number;\n /** Viewport y position */\n y: number;\n /** Viewport width */\n width: number;\n /** Viewport height */\n height: number;\n} & ControllerOptions & TransitionProps;\n\n/** The state of a controller */\nexport type InteractionState = {\n /** If the view state is in transition */\n inTransition?: boolean;\n /** If the user is dragging */\n isDragging?: boolean;\n /** If the view is being panned, either from user input or transition */\n isPanning?: boolean;\n /** If the view is being rotated, either from user input or transition */\n isRotating?: boolean;\n /** If the view is being zoomed, either from user input or transition */\n isZooming?: boolean;\n}\n\n/** Parameters passed to the onViewStateChange callback */\nexport type ViewStateChangeParameters = {\n viewId: string;\n /** The next view state, either from user input or transition */\n viewState: ViewStateT;\n /** Object describing the nature of the view state change */\n interactionState: InteractionState;\n /** The current view state */\n oldViewState?: ViewStateT;\n}\n\nconst pinchEventWorkaround: any = {};\n\nexport default abstract class Controller> {\n abstract get ControllerState(): ConstructorOf;\n abstract get transition(): TransitionProps;\n\n // @ts-expect-error (2564) - not assigned in the constructor\n protected props: ControllerProps;\n protected state: Record = {};\n\n protected transitionManager: TransitionManager;\n protected eventManager: EventManager;\n protected onViewStateChange: (params: ViewStateChangeParameters) => void;\n protected onStateChange: (state: InteractionState) => void;\n protected makeViewport: (opts: Record) => Viewport\n\n private _controllerState?: ControllerState;\n private _events: Record = {};\n private _interactionState: InteractionState = {\n isDragging: false\n };\n private _customEvents: string[] = [];\n private _eventStartBlocked: any = null;\n private _panMove: boolean = false;\n\n protected invertPan: boolean = false;\n protected dragMode: 'pan' | 'rotate' = 'rotate';\n protected inertia: number = 0;\n protected scrollZoom: boolean | {speed?: number; smooth?: boolean} = true;\n protected dragPan: boolean = true;\n protected dragRotate: boolean = true;\n protected doubleClickZoom: boolean = true;\n protected touchZoom: boolean = true;\n protected touchRotate: boolean = false;\n protected keyboard:\n | boolean\n | {\n zoomSpeed?: number; // speed of zoom using +/- keys. Default 2.\n moveSpeed?: number; // speed of movement using arrow keys, in pixels.\n rotateSpeedX?: number; // speed of rotation using shift + left/right arrow keys, in degrees. Default 15.\n rotateSpeedY?: number; // speed of rotation using shift + up/down arrow keys, in degrees. Default 10.\n } = true;\n\n constructor(opts: {\n timeline: Timeline,\n eventManager: EventManager;\n makeViewport: (opts: Record) => Viewport;\n onViewStateChange: (params: ViewStateChangeParameters) => void;\n onStateChange: (state: InteractionState) => void;\n }) {\n this.transitionManager = new TransitionManager({\n ...opts,\n getControllerState: props => new this.ControllerState(props),\n onViewStateChange: this._onTransition.bind(this),\n onStateChange: this._setInteractionState.bind(this)\n });\n\n this.handleEvent = this.handleEvent.bind(this);\n\n this.eventManager = opts.eventManager;\n this.onViewStateChange = opts.onViewStateChange || (() => {});\n this.onStateChange = opts.onStateChange || (() => {});\n this.makeViewport = opts.makeViewport;\n }\n\n set events(customEvents) {\n this.toggleEvents(this._customEvents, false);\n this.toggleEvents(customEvents, true);\n this._customEvents = customEvents;\n // Make sure default events are not overwritten\n if (this.props) {\n this.setProps(this.props);\n }\n }\n\n finalize() {\n for (const eventName in this._events) {\n if (this._events[eventName]) {\n // @ts-ignore (2345) event type string cannot be assifned to enum\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.eventManager?.off(eventName, this.handleEvent);\n }\n }\n this.transitionManager.finalize();\n }\n\n /**\n * Callback for events\n */\n handleEvent(event: MjolnirEvent) {\n // Force recalculate controller state\n this._controllerState = undefined;\n const eventStartBlocked = this._eventStartBlocked;\n\n switch (event.type) {\n case 'panstart':\n return eventStartBlocked ? false : this._onPanStart(event);\n case 'panmove':\n return this._onPan(event);\n case 'panend':\n return this._onPanEnd(event);\n case 'pinchstart':\n return eventStartBlocked ? false : this._onPinchStart(event);\n case 'pinchmove':\n return this._onPinch(event);\n case 'pinchend':\n return this._onPinchEnd(event);\n case 'multipanstart':\n return eventStartBlocked ? false : this._onMultiPanStart(event);\n case 'multipanmove':\n return this._onMultiPan(event);\n case 'multipanend':\n return this._onMultiPanEnd(event);\n case 'dblclick':\n return this._onDoubleClick(event);\n case 'wheel':\n return this._onWheel(event as MjolnirWheelEvent);\n case 'keydown':\n return this._onKeyDown(event as MjolnirKeyEvent);\n default:\n return false;\n }\n }\n\n /* Event utils */\n // Event object: http://hammerjs.github.io/api/#event-object\n get controllerState(): ControllerState {\n this._controllerState = this._controllerState || new this.ControllerState({\n makeViewport: this.makeViewport,\n ...this.props,\n ...this.state\n });\n return this._controllerState ;\n }\n\n getCenter(event: MjolnirGestureEvent | MjolnirWheelEvent) : [number, number] {\n const {x, y} = this.props;\n const {offsetCenter} = event;\n return [offsetCenter.x - x, offsetCenter.y - y];\n }\n\n isPointInBounds(pos: [number, number], event: MjolnirEvent): boolean {\n const {width, height} = this.props;\n if (event && event.handled) {\n return false;\n }\n\n const inside = pos[0] >= 0 && pos[0] <= width && pos[1] >= 0 && pos[1] <= height;\n if (inside && event) {\n event.stopPropagation();\n }\n return inside;\n }\n\n isFunctionKeyPressed(event: MjolnirEvent): boolean {\n const {srcEvent} = event;\n return Boolean(srcEvent.metaKey || srcEvent.altKey || srcEvent.ctrlKey || srcEvent.shiftKey);\n }\n\n isDragging(): boolean {\n return this._interactionState.isDragging || false;\n }\n\n // When a multi-touch event ends, e.g. pinch, not all pointers are lifted at the same time.\n // This triggers a brief `pan` event.\n // Calling this method will temporarily disable *start events to avoid conflicting transitions.\n blockEvents(timeout: number): void {\n /* global setTimeout */\n const timer = setTimeout(() => {\n if (this._eventStartBlocked === timer) {\n this._eventStartBlocked = null;\n }\n }, timeout);\n this._eventStartBlocked = timer;\n }\n\n /**\n * Extract interactivity options\n */\n setProps(props: ControllerProps) {\n if (props.dragMode) {\n this.dragMode = props.dragMode;\n }\n this.props = props;\n\n if (!('transitionInterpolator' in props)) {\n // Add default transition interpolator\n props.transitionInterpolator = this._getTransitionProps().transitionInterpolator;\n }\n\n this.transitionManager.processViewStateChange(props);\n\n const {inertia} = props;\n this.inertia = Number.isFinite(inertia) ? (inertia as number) : (inertia === true ? DEFAULT_INERTIA : 0);\n\n // TODO - make sure these are not reset on every setProps\n const {\n scrollZoom = true,\n dragPan = true,\n dragRotate = true,\n doubleClickZoom = true,\n touchZoom = true,\n touchRotate = false,\n keyboard = true\n } = props;\n\n // Register/unregister events\n const isInteractive = Boolean(this.onViewStateChange);\n this.toggleEvents(EVENT_TYPES.WHEEL, isInteractive && scrollZoom);\n // We always need the pan events to set the correct isDragging state, even if dragPan & dragRotate are both false\n this.toggleEvents(EVENT_TYPES.PAN, isInteractive);\n this.toggleEvents(EVENT_TYPES.PINCH, isInteractive && (touchZoom || touchRotate));\n this.toggleEvents(EVENT_TYPES.MULTI_PAN, isInteractive && touchRotate);\n this.toggleEvents(EVENT_TYPES.DOUBLE_CLICK, isInteractive && doubleClickZoom);\n this.toggleEvents(EVENT_TYPES.KEYBOARD, isInteractive && keyboard);\n\n // Interaction toggles\n this.scrollZoom = scrollZoom;\n this.dragPan = dragPan;\n this.dragRotate = dragRotate;\n this.doubleClickZoom = doubleClickZoom;\n this.touchZoom = touchZoom;\n this.touchRotate = touchRotate;\n this.keyboard = keyboard;\n }\n\n updateTransition() {\n this.transitionManager.updateTransition();\n }\n\n toggleEvents(eventNames, enabled) {\n if (this.eventManager) {\n eventNames.forEach(eventName => {\n if (this._events[eventName] !== enabled) {\n this._events[eventName] = enabled;\n if (enabled) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.eventManager.on(eventName, this.handleEvent);\n } else {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this.eventManager.off(eventName, this.handleEvent);\n }\n }\n });\n }\n }\n\n // Private Methods\n\n /* Callback util */\n // formats map state and invokes callback function\n protected updateViewport(newControllerState: ControllerState, extraProps: Record | null = null, interactionState: InteractionState = {}) {\n const viewState = {...newControllerState.getViewportProps(), ...extraProps};\n\n // TODO - to restore diffing, we need to include interactionState\n const changed = this.controllerState !== newControllerState;\n // const oldViewState = this.controllerState.getViewportProps();\n // const changed = Object.keys(viewState).some(key => oldViewState[key] !== viewState[key]);\n\n this.state = newControllerState.getState();\n this._setInteractionState(interactionState);\n\n if (changed) {\n const oldViewState = this.controllerState && this.controllerState.getViewportProps();\n if (this.onViewStateChange) {\n this.onViewStateChange({viewState, interactionState: this._interactionState, oldViewState, viewId: this.props.id});\n }\n }\n }\n\n private _onTransition(params: {viewState: Record, oldViewState: Record}) {\n this.onViewStateChange({...params, interactionState: this._interactionState, viewId: this.props.id});\n }\n\n private _setInteractionState(newStates: InteractionState) {\n Object.assign(this._interactionState, newStates);\n this.onStateChange(this._interactionState);\n }\n\n /* Event handlers */\n // Default handler for the `panstart` event.\n protected _onPanStart(event: MjolnirGestureEvent): boolean {\n const pos = this.getCenter(event);\n if (!this.isPointInBounds(pos, event)) {\n return false;\n }\n let alternateMode = this.isFunctionKeyPressed(event) || event.rightButton || false;\n if (this.invertPan || this.dragMode === 'pan') {\n // invertPan is replaced by props.dragMode, keeping for backward compatibility\n alternateMode = !alternateMode;\n }\n const newControllerState = this.controllerState[alternateMode ? 'panStart' : 'rotateStart']({\n pos\n });\n this._panMove = alternateMode;\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {isDragging: true});\n return true;\n }\n\n // Default handler for the `panmove` and `panend` event.\n protected _onPan(event: MjolnirGestureEvent): boolean {\n if (!this.isDragging()) {\n return false;\n }\n return this._panMove ? this._onPanMove(event) : this._onPanRotate(event);\n }\n\n protected _onPanEnd(event: MjolnirGestureEvent): boolean {\n if (!this.isDragging()) {\n return false;\n }\n return this._panMove ? this._onPanMoveEnd(event) : this._onPanRotateEnd(event);\n }\n\n // Default handler for panning to move.\n // Called by `_onPan` when panning without function key pressed.\n protected _onPanMove(event: MjolnirGestureEvent): boolean {\n if (!this.dragPan) {\n return false;\n }\n const pos = this.getCenter(event);\n const newControllerState = this.controllerState.pan({pos});\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {\n isDragging: true,\n isPanning: true\n });\n return true;\n }\n\n protected _onPanMoveEnd(event: MjolnirGestureEvent): boolean {\n const {inertia} = this;\n if (this.dragPan && inertia && event.velocity) {\n const pos = this.getCenter(event);\n const endPos: [number, number] = [\n pos[0] + (event.velocityX * inertia) / 2,\n pos[1] + (event.velocityY * inertia) / 2\n ];\n const newControllerState = this.controllerState.pan({pos: endPos}).panEnd();\n this.updateViewport(\n newControllerState,\n {\n ...this._getTransitionProps(),\n transitionDuration: inertia,\n transitionEasing: INERTIA_EASING\n },\n {\n isDragging: false,\n isPanning: true\n }\n );\n } else {\n const newControllerState = this.controllerState.panEnd();\n this.updateViewport(newControllerState, null, {\n isDragging: false,\n isPanning: false\n });\n }\n return true;\n }\n\n // Default handler for panning to rotate.\n // Called by `_onPan` when panning with function key pressed.\n protected _onPanRotate(event: MjolnirGestureEvent): boolean {\n if (!this.dragRotate) {\n return false;\n }\n\n const pos = this.getCenter(event);\n const newControllerState = this.controllerState.rotate({pos});\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {\n isDragging: true,\n isRotating: true\n });\n return true;\n }\n\n protected _onPanRotateEnd(event): boolean {\n const {inertia} = this;\n if (this.dragRotate && inertia && event.velocity) {\n const pos = this.getCenter(event);\n const endPos: [number, number] = [\n pos[0] + (event.velocityX * inertia) / 2,\n pos[1] + (event.velocityY * inertia) / 2\n ];\n const newControllerState = this.controllerState.rotate({pos: endPos}).rotateEnd();\n this.updateViewport(\n newControllerState,\n {\n ...this._getTransitionProps(),\n transitionDuration: inertia,\n transitionEasing: INERTIA_EASING\n },\n {\n isDragging: false,\n isRotating: true\n }\n );\n } else {\n const newControllerState = this.controllerState.rotateEnd();\n this.updateViewport(newControllerState, null, {\n isDragging: false,\n isRotating: false\n });\n }\n return true;\n }\n\n // Default handler for the `wheel` event.\n protected _onWheel(event: MjolnirWheelEvent): boolean {\n if (!this.scrollZoom) {\n return false;\n }\n\n const pos = this.getCenter(event);\n if (!this.isPointInBounds(pos, event)) {\n return false;\n }\n event.srcEvent.preventDefault();\n\n const {speed = 0.01, smooth = false} = this.scrollZoom === true ? {} : this.scrollZoom;\n const {delta} = event;\n\n // Map wheel delta to relative scale\n let scale = 2 / (1 + Math.exp(-Math.abs(delta * speed)));\n if (delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const newControllerState = this.controllerState.zoom({pos, scale});\n this.updateViewport(\n newControllerState,\n {...this._getTransitionProps({around: pos}), transitionDuration: smooth ? 250 : 1},\n {\n isZooming: true,\n isPanning: true\n }\n );\n return true;\n }\n\n protected _onMultiPanStart(event: MjolnirGestureEvent): boolean {\n const pos = this.getCenter(event);\n if (!this.isPointInBounds(pos, event)) {\n return false;\n }\n const newControllerState = this.controllerState.rotateStart({pos});\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {isDragging: true});\n return true;\n }\n\n protected _onMultiPan(event: MjolnirGestureEvent): boolean {\n if (!this.touchRotate) {\n return false;\n }\n if (!this.isDragging()) {\n return false;\n }\n\n const pos = this.getCenter(event);\n pos[0] -= event.deltaX;\n\n const newControllerState = this.controllerState.rotate({pos});\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {\n isDragging: true,\n isRotating: true\n });\n return true;\n }\n\n protected _onMultiPanEnd(event: MjolnirGestureEvent): boolean {\n if (!this.isDragging()) {\n return false;\n }\n const {inertia} = this;\n if (this.touchRotate && inertia && event.velocityY) {\n const pos = this.getCenter(event);\n const endPos: [number, number] = [pos[0], (pos[1] += (event.velocityY * inertia) / 2)];\n const newControllerState = this.controllerState.rotate({pos: endPos});\n this.updateViewport(\n newControllerState,\n {\n ...this._getTransitionProps(),\n transitionDuration: inertia,\n transitionEasing: INERTIA_EASING\n },\n {\n isDragging: false,\n isRotating: true\n }\n );\n this.blockEvents(inertia);\n } else {\n const newControllerState = this.controllerState.rotateEnd();\n this.updateViewport(newControllerState, null, {\n isDragging: false,\n isRotating: false\n });\n }\n return true;\n }\n\n // Default handler for the `pinchstart` event.\n protected _onPinchStart(event: MjolnirGestureEvent): boolean {\n const pos = this.getCenter(event);\n if (!this.isPointInBounds(pos, event)) {\n return false;\n }\n\n const newControllerState = this.controllerState.zoomStart({pos}).rotateStart({pos});\n // hack - hammer's `rotation` field doesn't seem to produce the correct angle\n pinchEventWorkaround._startPinchRotation = event.rotation;\n pinchEventWorkaround._lastPinchEvent = event;\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {isDragging: true});\n return true;\n }\n\n // Default handler for the `pinchmove` and `pinchend` events.\n protected _onPinch(event: MjolnirGestureEvent): boolean {\n if (!this.touchZoom && !this.touchRotate) {\n return false;\n }\n if (!this.isDragging()) {\n return false;\n }\n\n let newControllerState = this.controllerState;\n if (this.touchZoom) {\n const {scale} = event;\n const pos = this.getCenter(event);\n newControllerState = newControllerState.zoom({pos, scale});\n }\n if (this.touchRotate) {\n const {rotation} = event;\n newControllerState = newControllerState.rotate({\n deltaAngleX: pinchEventWorkaround._startPinchRotation - rotation\n });\n }\n\n this.updateViewport(newControllerState, NO_TRANSITION_PROPS, {\n isDragging: true,\n isPanning: this.touchZoom,\n isZooming: this.touchZoom,\n isRotating: this.touchRotate\n });\n pinchEventWorkaround._lastPinchEvent = event;\n return true;\n }\n\n protected _onPinchEnd(event: MjolnirGestureEvent): boolean {\n if (!this.isDragging()) {\n return false;\n }\n const {inertia} = this;\n const {_lastPinchEvent} = pinchEventWorkaround;\n if (this.touchZoom && inertia && _lastPinchEvent && event.scale !== _lastPinchEvent.scale) {\n const pos = this.getCenter(event);\n let newControllerState = this.controllerState.rotateEnd();\n const z = Math.log2(event.scale);\n const velocityZ =\n (z - Math.log2(_lastPinchEvent.scale)) / (event.deltaTime - _lastPinchEvent.deltaTime);\n const endScale = Math.pow(2, z + (velocityZ * inertia) / 2);\n newControllerState = newControllerState.zoom({pos, scale: endScale}).zoomEnd();\n\n this.updateViewport(\n newControllerState,\n {\n ...this._getTransitionProps({around: pos}),\n transitionDuration: inertia,\n transitionEasing: INERTIA_EASING\n },\n {\n isDragging: false,\n isPanning: this.touchZoom,\n isZooming: this.touchZoom,\n isRotating: false\n }\n );\n this.blockEvents(inertia);\n } else {\n const newControllerState = this.controllerState.zoomEnd().rotateEnd();\n this.updateViewport(newControllerState, null, {\n isDragging: false,\n isPanning: false,\n isZooming: false,\n isRotating: false\n });\n }\n pinchEventWorkaround._startPinchRotation = null;\n pinchEventWorkaround._lastPinchEvent = null;\n return true;\n }\n\n // Default handler for the `dblclick` event.\n protected _onDoubleClick(event: MjolnirGestureEvent): boolean {\n if (!this.doubleClickZoom) {\n return false;\n }\n const pos = this.getCenter(event);\n if (!this.isPointInBounds(pos, event)) {\n return false;\n }\n\n const isZoomOut = this.isFunctionKeyPressed(event);\n\n const newControllerState = this.controllerState.zoom({pos, scale: isZoomOut ? 0.5 : 2});\n this.updateViewport(newControllerState, this._getTransitionProps({around: pos}), {\n isZooming: true,\n isPanning: true\n });\n this.blockEvents(100);\n return true;\n }\n\n // Default handler for the `keydown` event\n protected _onKeyDown(event: MjolnirKeyEvent): boolean {\n if (!this.keyboard) {\n return false;\n }\n const funcKey = this.isFunctionKeyPressed(event);\n // @ts-ignore\n const {zoomSpeed, moveSpeed, rotateSpeedX, rotateSpeedY} = this.keyboard === true ? {} : this.keyboard;\n const {controllerState} = this;\n let newControllerState;\n const interactionState: InteractionState = {};\n\n switch (event.srcEvent.code) {\n case 'Minus':\n newControllerState = funcKey\n ? controllerState.zoomOut(zoomSpeed).zoomOut(zoomSpeed)\n : controllerState.zoomOut(zoomSpeed);\n interactionState.isZooming = true;\n break;\n case 'Equal':\n newControllerState = funcKey\n ? controllerState.zoomIn(zoomSpeed).zoomIn(zoomSpeed)\n : controllerState.zoomIn(zoomSpeed);\n interactionState.isZooming = true;\n break;\n case 'ArrowLeft':\n if (funcKey) {\n newControllerState = controllerState.rotateLeft(rotateSpeedX);\n interactionState.isRotating = true;\n } else {\n newControllerState = controllerState.moveLeft(moveSpeed);\n interactionState.isPanning = true;\n }\n break;\n case 'ArrowRight':\n if (funcKey) {\n newControllerState = controllerState.rotateRight(rotateSpeedX);\n interactionState.isRotating = true;\n } else {\n newControllerState = controllerState.moveRight(moveSpeed);\n interactionState.isPanning = true;\n }\n break;\n case 'ArrowUp':\n if (funcKey) {\n newControllerState = controllerState.rotateUp(rotateSpeedY);\n interactionState.isRotating = true;\n } else {\n newControllerState = controllerState.moveUp(moveSpeed);\n interactionState.isPanning = true;\n }\n break;\n case 'ArrowDown':\n if (funcKey) {\n newControllerState = controllerState.rotateDown(rotateSpeedY);\n interactionState.isRotating = true;\n } else {\n newControllerState = controllerState.moveDown(moveSpeed);\n interactionState.isPanning = true;\n }\n break;\n default:\n return false;\n }\n this.updateViewport(newControllerState, this._getTransitionProps(), interactionState);\n return true;\n }\n\n protected _getTransitionProps(opts?: any): TransitionProps {\n const {transition} = this;\n\n if (!transition || !transition.transitionInterpolator) {\n return NO_TRANSITION_PROPS;\n }\n\n // Enables Transitions on double-tap and key-down events.\n return opts\n ? {\n ...transition,\n transitionInterpolator: new LinearInterpolator({\n ...opts,\n ...(transition.transitionInterpolator as LinearInterpolator).opts,\n makeViewport: this.controllerState.makeViewport\n })\n }\n : transition;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type Viewport from '../viewports/viewport';\n\nexport default abstract class ViewState<\n T,\n Props extends Record,\n State extends Record\n> implements IViewState\n{\n private _viewportProps: Required;\n private _state: State;\n\n constructor(props: Required, state: State) {\n this._viewportProps = this.applyConstraints(props);\n this._state = state;\n }\n\n getViewportProps(): Required {\n return this._viewportProps;\n }\n\n getState(): State {\n return this._state;\n }\n\n abstract applyConstraints(props: Required): Required;\n\n abstract shortestPathFrom(viewState: T): Props;\n\n abstract panStart(params: {pos: [number, number]}): T;\n abstract pan({pos, startPos}: {pos: [number, number]; startPos?: [number, number]}): T;\n abstract panEnd(): T;\n\n abstract rotateStart(params: {pos: [number, number]}): T;\n abstract rotate(params: {pos?: [number, number]; deltaAngleX?: number; deltaAngleY: number}): T;\n abstract rotateEnd(): T;\n\n abstract zoomStart({pos}: {pos: [number, number]}): T;\n abstract zoom({\n pos,\n startPos,\n scale\n }: {\n pos: [number, number];\n startPos?: [number, number];\n scale: number;\n }): T;\n abstract zoomEnd(): T;\n\n abstract zoomIn(speed?: number): T;\n abstract zoomOut(speed?: number): T;\n\n abstract moveLeft(speed?: number): T;\n abstract moveRight(speed?: number): T;\n abstract moveUp(speed?: number): T;\n abstract moveDown(speed?: number): T;\n\n abstract rotateLeft(speed?: number): T;\n abstract rotateRight(speed?: number): T;\n abstract rotateUp(speed?: number): T;\n abstract rotateDown(speed?: number): T;\n}\n\nexport interface IViewState {\n makeViewport?: (props: Record) => Viewport;\n\n getViewportProps(): Record;\n\n getState(): Record;\n\n shortestPathFrom(viewState: T): Record;\n\n panStart(params: {pos: [number, number]}): T;\n pan({pos, startPos}: {pos: [number, number]; startPos?: [number, number]}): T;\n panEnd(): T;\n\n rotateStart(params: {pos: [number, number]}): T;\n rotate(params: {pos?: [number, number]; deltaAngleX?: number; deltaAngleY?: number}): T;\n rotateEnd(): T;\n\n zoomStart({pos}: {pos: [number, number]}): T;\n zoom({\n pos,\n startPos,\n scale\n }: {\n pos: [number, number];\n startPos?: [number, number];\n scale: number;\n }): T;\n zoomEnd(): T;\n\n zoomIn(speed?: number): T;\n zoomOut(speed?: number): T;\n\n moveLeft(speed?: number): T;\n moveRight(speed?: number): T;\n moveUp(speed?: number): T;\n moveDown(speed?: number): T;\n\n rotateLeft(speed?: number): T;\n rotateRight(speed?: number): T;\n rotateUp(speed?: number): T;\n rotateDown(speed?: number): T;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport View, {CommonViewState, CommonViewProps} from './view';\nimport WebMercatorViewport from '../viewports/web-mercator-viewport';\nimport MapController from '../controllers/map-controller';\n\nimport type {NumericArray} from '../types/types';\n\nexport type MapViewState = {\n /** Longitude of the map center */\n longitude: number;\n /** Latitude of the map center */\n latitude: number;\n /** Zoom level */\n zoom: number;\n /** Pitch (tilt) of the map, in degrees. `0` looks top down */\n pitch?: number;\n /** Bearing (rotation) of the map, in degrees. `0` is north up */\n bearing?: number;\n /** Min zoom, default `0` */\n minZoom?: number;\n /** Max zoom, default `20` */\n maxZoom?: number;\n /** Min pitch, default `0` */\n minPitch?: number;\n /** Max pitch, default `60` */\n maxPitch?: number;\n /** Viewport center offsets from lng, lat in meters */\n position?: number[];\n /** The near plane position */\n nearZ?: number;\n /** The far plane position */\n farZ?: number;\n} & CommonViewState;\n\nexport type MapViewProps = {\n /** Whether to render multiple copies of the map at low zoom levels. Default `false`. */\n repeat?: boolean;\n /** Scaler for the near plane, 1 unit equals to the height of the viewport. Default to `0.1`. Overwrites the `near` parameter. */\n nearZMultiplier?: number;\n /** Scaler for the far plane, 1 unit equals to the distance from the camera to the top edge of the screen. Default to `1.01`. Overwrites the `far` parameter. */\n farZMultiplier?: number;\n /** Custom projection matrix */\n projectionMatrix?: NumericArray;\n /** Field of view covered by the camera, in the perspective case. In degrees. If not supplied, will be calculated from `altitude`. */\n fovy?: number;\n /** Distance of the camera relative to viewport height. Default `1.5`. */\n altitude?: number;\n /** Whether to create an orthographic or perspective projection matrix. Default is `false` (perspective projection). */\n orthographic?: boolean;\n} & CommonViewProps;\n\nexport default class MapView extends View {\n static displayName = 'MapView';\n\n constructor(props: MapViewProps = {}) {\n super(props);\n }\n\n getViewportType() {\n return WebMercatorViewport;\n }\n\n get ControllerType() {\n return MapController;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {deepEqual} from '../utils/deep-equal';\nimport LightingEffect from '../effects/lighting/lighting-effect';\nimport type {Effect, EffectContext} from './effect';\n\nconst DEFAULT_LIGHTING_EFFECT = new LightingEffect();\n\n/** Sort two effects. Returns 0 if equal, negative if e1 < e2, positive if e1 > e2 */\nfunction compareEffects(e1: Effect, e2: Effect): number {\n const o1 = e1.order ?? Infinity;\n const o2 = e2.order ?? Infinity;\n return o1 - o2;\n}\n\nexport default class EffectManager {\n effects: Effect[];\n private _resolvedEffects: Effect[] = [];\n /** Effect instances and order preference pairs, sorted by order */\n private _defaultEffects: Effect[] = [];\n private _needsRedraw: false | string;\n private _context: EffectContext;\n\n constructor(context: EffectContext) {\n this.effects = [];\n this._context = context;\n this._needsRedraw = 'Initial render';\n this._setEffects([]);\n }\n\n /**\n * Register a new default effect, i.e. an effect presents regardless of user supplied props.effects\n */\n addDefaultEffect(effect: Effect) {\n const defaultEffects = this._defaultEffects;\n if (!defaultEffects.find(e => e.id === effect.id)) {\n const index = defaultEffects.findIndex(e => compareEffects(e, effect) > 0);\n if (index < 0) {\n defaultEffects.push(effect);\n } else {\n defaultEffects.splice(index, 0, effect);\n }\n effect.setup(this._context);\n this._setEffects(this.effects);\n }\n }\n\n setProps(props) {\n if ('effects' in props) {\n // Compare effects against each other shallowly\n if (!deepEqual(props.effects, this.effects, 1)) {\n this._setEffects(props.effects);\n }\n }\n }\n\n needsRedraw(opts = {clearRedrawFlags: false}): false | string {\n const redraw = this._needsRedraw;\n if (opts.clearRedrawFlags) {\n this._needsRedraw = false;\n }\n return redraw;\n }\n\n getEffects() {\n return this._resolvedEffects;\n }\n\n private _setEffects(effects: Effect[]) {\n const oldEffectsMap: Record = {};\n for (const effect of this.effects) {\n oldEffectsMap[effect.id] = effect;\n }\n\n const nextEffects: Effect[] = [];\n for (const effect of effects) {\n const oldEffect = oldEffectsMap[effect.id];\n let effectToAdd = effect;\n if (oldEffect && oldEffect !== effect) {\n if (oldEffect.setProps) {\n oldEffect.setProps(effect.props);\n effectToAdd = oldEffect;\n } else {\n oldEffect.cleanup(this._context);\n }\n } else if (!oldEffect) {\n effect.setup(this._context);\n }\n nextEffects.push(effectToAdd);\n delete oldEffectsMap[effect.id];\n }\n for (const removedEffectId in oldEffectsMap) {\n oldEffectsMap[removedEffectId].cleanup(this._context);\n }\n this.effects = nextEffects;\n\n this._resolvedEffects = nextEffects.concat(this._defaultEffects);\n // Special case for lighting: only add default instance if no LightingEffect is specified\n if (!effects.some(effect => effect instanceof LightingEffect)) {\n this._resolvedEffects.push(DEFAULT_LIGHTING_EFFECT);\n }\n this._needsRedraw = 'effects changed';\n }\n\n finalize() {\n for (const effect of this._resolvedEffects) {\n effect.cleanup(this._context);\n }\n\n this.effects.length = 0;\n this._resolvedEffects.length = 0;\n this._defaultEffects.length = 0;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport LayersPass from './layers-pass';\n\nexport default class DrawLayersPass extends LayersPass {\n shouldDrawLayer(layer) {\n const {operation} = layer.props;\n return operation.includes('draw') || operation.includes('terrain');\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\nimport {Framebuffer} from '@luma.gl/core';\nimport debug from '../debug/index';\nimport DrawLayersPass from '../passes/draw-layers-pass';\nimport PickLayersPass from '../passes/pick-layers-pass';\n\nimport type Layer from './layer';\nimport type Viewport from '../viewports/viewport';\nimport type View from '../views/view';\nimport type {Effect, PostRenderOptions} from './effect';\nimport type {LayersPassRenderOptions, FilterContext} from '../passes/layers-pass';\n\nconst TRACE_RENDER_LAYERS = 'deckRenderer.renderLayers';\n\ntype LayerFilter = ((context: FilterContext) => boolean) | null;\n\nexport default class DeckRenderer {\n device: Device;\n layerFilter: LayerFilter;\n drawPickingColors: boolean;\n drawLayersPass: DrawLayersPass;\n pickLayersPass: PickLayersPass;\n\n private renderCount: number;\n private _needsRedraw: string | false;\n private renderBuffers: Framebuffer[];\n private lastPostProcessEffect: string | null;\n\n constructor(device: Device) {\n this.device = device;\n this.layerFilter = null;\n this.drawPickingColors = false;\n this.drawLayersPass = new DrawLayersPass(device);\n this.pickLayersPass = new PickLayersPass(device);\n this.renderCount = 0;\n this._needsRedraw = 'Initial render';\n this.renderBuffers = [];\n this.lastPostProcessEffect = null;\n }\n\n setProps(props: {layerFilter: LayerFilter; drawPickingColors: boolean}) {\n if (this.layerFilter !== props.layerFilter) {\n this.layerFilter = props.layerFilter;\n this._needsRedraw = 'layerFilter changed';\n }\n\n if (this.drawPickingColors !== props.drawPickingColors) {\n this.drawPickingColors = props.drawPickingColors;\n this._needsRedraw = 'drawPickingColors changed';\n }\n }\n\n renderLayers(opts: {\n pass: string;\n layers: Layer[];\n viewports: Viewport[];\n views: {[viewId: string]: View};\n onViewportActive: (viewport: Viewport) => void;\n effects: Effect[];\n target?: Framebuffer | null;\n layerFilter?: LayerFilter;\n clearStack?: boolean;\n clearCanvas?: boolean;\n }) {\n if (!opts.viewports.length) {\n return;\n }\n\n const layerPass = this.drawPickingColors ? this.pickLayersPass : this.drawLayersPass;\n\n const renderOpts: LayersPassRenderOptions = {\n layerFilter: this.layerFilter,\n isPicking: this.drawPickingColors,\n ...opts\n };\n\n if (renderOpts.effects) {\n this._preRender(renderOpts.effects, renderOpts);\n }\n\n const outputBuffer = this.lastPostProcessEffect ? this.renderBuffers[0] : renderOpts.target;\n if (this.lastPostProcessEffect) {\n renderOpts.clearColor = [0, 0, 0, 0];\n renderOpts.clearCanvas = true;\n }\n const renderStats = layerPass.render({...renderOpts, target: outputBuffer});\n\n if (renderOpts.effects) {\n this._postRender(renderOpts.effects, renderOpts);\n }\n\n this.renderCount++;\n\n debug(TRACE_RENDER_LAYERS, this, renderStats, opts);\n }\n\n needsRedraw(opts: {clearRedrawFlags: boolean} = {clearRedrawFlags: false}): string | false {\n const redraw = this._needsRedraw;\n if (opts.clearRedrawFlags) {\n this._needsRedraw = false;\n }\n return redraw;\n }\n\n finalize() {\n const {renderBuffers} = this;\n for (const buffer of renderBuffers) {\n buffer.delete();\n }\n renderBuffers.length = 0;\n }\n\n private _preRender(effects: Effect[], opts: LayersPassRenderOptions) {\n this.lastPostProcessEffect = null;\n opts.preRenderStats = opts.preRenderStats || {};\n\n for (const effect of effects) {\n opts.preRenderStats[effect.id] = effect.preRender(opts);\n if (effect.postRender) {\n this.lastPostProcessEffect = effect.id;\n }\n }\n\n if (this.lastPostProcessEffect) {\n this._resizeRenderBuffers();\n }\n }\n\n private _resizeRenderBuffers() {\n const {renderBuffers} = this;\n const size = this.device.canvasContext!.getDrawingBufferSize();\n if (renderBuffers.length === 0) {\n [0, 1].map(i => {\n const texture = this.device.createTexture({\n sampler: {minFilter: 'linear', magFilter: 'linear'}\n });\n renderBuffers.push(\n this.device.createFramebuffer({\n id: `deck-renderbuffer-${i}`,\n colorAttachments: [texture]\n })\n );\n });\n }\n for (const buffer of renderBuffers) {\n buffer.resize(size);\n }\n }\n\n private _postRender(effects: Effect[], opts: LayersPassRenderOptions) {\n const {renderBuffers} = this;\n const params: PostRenderOptions = {\n ...opts,\n inputBuffer: renderBuffers[0],\n swapBuffer: renderBuffers[1]\n };\n for (const effect of effects) {\n if (effect.postRender) {\n // If not the last post processing effect, unset the target so that\n // it only renders between the swap buffers\n params.target = effect.id === this.lastPostProcessEffect ? opts.target : undefined;\n const buffer = effect.postRender(params);\n // Buffer cannot be null if target is unset\n params.inputBuffer = buffer!;\n params.swapBuffer = buffer === renderBuffers[0] ? renderBuffers[1] : renderBuffers[0];\n }\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport log from '../../utils/log';\nimport type Layer from '../layer';\nimport type Viewport from '../../viewports/viewport';\nimport type {PickingColorDecoder} from '../../passes/pick-layers-pass';\n\nexport type PickedPixel = {\n pickedColor: Uint8Array | null;\n pickedLayer?: Layer;\n pickedViewports?: Viewport[];\n pickedX?: number;\n pickedY?: number;\n pickedObjectIndex: number;\n};\n\nconst NO_PICKED_OBJECT = {\n pickedColor: null,\n pickedObjectIndex: -1\n};\n\n/* eslint-disable max-depth, max-statements */\n/**\n * Pick at a specified pixel with a tolerance radius\n * Returns the closest object to the pixel in shape `{pickedColor, pickedLayer, pickedObjectIndex}`\n */\nexport function getClosestObject({\n pickedColors,\n decodePickingColor,\n deviceX,\n deviceY,\n deviceRadius,\n deviceRect\n}: {\n pickedColors: Uint8Array;\n decodePickingColor: PickingColorDecoder;\n deviceX: number;\n deviceY: number;\n deviceRadius: number;\n deviceRect: {x: number; y: number; width: number; height: number};\n}): PickedPixel {\n // Traverse all pixels in picking results and find the one closest to the supplied\n // [deviceX, deviceY]\n const {x, y, width, height} = deviceRect;\n let minSquareDistanceToCenter = deviceRadius * deviceRadius;\n let closestPixelIndex = -1;\n let i = 0;\n\n for (let row = 0; row < height; row++) {\n const dy = row + y - deviceY;\n const dy2 = dy * dy;\n\n if (dy2 > minSquareDistanceToCenter) {\n // skip this row\n i += 4 * width;\n } else {\n for (let col = 0; col < width; col++) {\n // Decode picked layer from color\n const pickedLayerIndex = pickedColors[i + 3] - 1;\n\n if (pickedLayerIndex >= 0) {\n const dx = col + x - deviceX;\n const d2 = dx * dx + dy2;\n\n if (d2 <= minSquareDistanceToCenter) {\n minSquareDistanceToCenter = d2;\n closestPixelIndex = i;\n }\n }\n i += 4;\n }\n }\n }\n\n if (closestPixelIndex >= 0) {\n // Decode picked object index from color\n const pickedColor = pickedColors.slice(closestPixelIndex, closestPixelIndex + 4);\n const pickedObject = decodePickingColor(pickedColor);\n if (pickedObject) {\n const dy = Math.floor(closestPixelIndex / 4 / width);\n const dx = closestPixelIndex / 4 - dy * width;\n return {\n ...pickedObject,\n pickedColor,\n pickedX: x + dx,\n pickedY: y + dy\n };\n }\n log.error('Picked non-existent layer. Is picking buffer corrupt?')();\n }\n return NO_PICKED_OBJECT;\n}\n\n/**\n * Examines a picking buffer for unique colors\n * Returns array of unique objects in shape `{x, y, pickedColor, pickedLayer, pickedObjectIndex}`\n */\nexport function getUniqueObjects({\n pickedColors,\n decodePickingColor\n}: {\n pickedColors: Uint8Array;\n decodePickingColor: PickingColorDecoder;\n}): PickedPixel[] {\n const uniqueColors = new Map();\n\n // Traverse all pixels in picking results and get unique colors\n if (pickedColors) {\n for (let i = 0; i < pickedColors.length; i += 4) {\n // Decode picked layer from color\n const pickedLayerIndex = pickedColors[i + 3] - 1;\n\n if (pickedLayerIndex >= 0) {\n const pickedColor = pickedColors.slice(i, i + 4);\n const colorKey = pickedColor.join(',');\n // eslint-disable-next-line\n if (!uniqueColors.has(colorKey)) {\n const pickedObject = decodePickingColor(pickedColor);\n // eslint-disable-next-line\n if (pickedObject) {\n uniqueColors.set(colorKey, {\n ...pickedObject,\n color: pickedColor\n });\n } else {\n log.error('Picked non-existent layer. Is picking buffer corrupt?')();\n }\n }\n }\n }\n }\n\n return Array.from(uniqueColors.values());\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type Layer from '../layer';\nimport type Viewport from '../../viewports/viewport';\nimport type {PickedPixel} from './query-object';\n\nexport type PickingInfo = ExtraInfo & {\n color: Uint8Array | null;\n layer: Layer | null;\n sourceLayer?: Layer | null;\n viewport?: Viewport;\n index: number;\n picked: boolean;\n object?: DataT;\n x: number;\n y: number;\n pixel?: [number, number];\n coordinate?: number[];\n devicePixel?: [number, number];\n pixelRatio: number;\n};\n\nexport interface GetPickingInfoParams {\n info: PickingInfo;\n mode: string;\n sourceLayer: Layer | null;\n}\n\n/** Generates some basic information of the picking action: x, y, coordinates etc.\n * Regardless if anything is picked\n */\nexport function getEmptyPickingInfo({\n pickInfo,\n viewports,\n pixelRatio,\n x,\n y,\n z\n}: {\n pickInfo?: PickedPixel;\n viewports: Viewport[];\n pixelRatio: number;\n x: number;\n y: number;\n z?: number;\n}): PickingInfo {\n // If more than one viewports are used in the picking pass, locate the viewport that\n // drew the picked pixel\n let pickedViewport = viewports[0];\n if (viewports.length > 1) {\n // Find the viewport that contain the picked pixel\n pickedViewport = getViewportFromCoordinates(pickInfo?.pickedViewports || viewports, {x, y});\n }\n let coordinate: number[] | undefined;\n if (pickedViewport) {\n const point = [x - pickedViewport.x, y - pickedViewport.y];\n if (z !== undefined) {\n point[2] = z;\n }\n coordinate = pickedViewport.unproject(point);\n }\n\n return {\n color: null,\n layer: null,\n viewport: pickedViewport,\n index: -1,\n picked: false,\n x,\n y,\n pixel: [x, y],\n coordinate,\n devicePixel:\n pickInfo && 'pickedX' in pickInfo\n ? [pickInfo.pickedX as number, pickInfo.pickedY as number]\n : undefined,\n pixelRatio\n };\n}\n\n/* eslint-disable max-depth */\n/** Generates the picking info of a picking operation */\nexport function processPickInfo(opts: {\n pickInfo: PickedPixel;\n lastPickedInfo: {\n index: number;\n layerId: string | null;\n info: PickingInfo | null;\n };\n mode: string;\n layers: Layer[];\n viewports: Viewport[];\n pixelRatio: number;\n x: number;\n y: number;\n z?: number;\n}): Map {\n const {pickInfo, lastPickedInfo, mode, layers} = opts;\n const {pickedColor, pickedLayer, pickedObjectIndex} = pickInfo;\n\n const affectedLayers = pickedLayer ? [pickedLayer] : [];\n\n if (mode === 'hover') {\n // only invoke onHover events if picked object has changed\n const lastPickedPixelIndex = lastPickedInfo.index;\n const lastPickedLayerId = lastPickedInfo.layerId;\n const pickedLayerId = pickedLayer ? pickedLayer.props.id : null;\n\n // proceed only if picked object changed\n if (pickedLayerId !== lastPickedLayerId || pickedObjectIndex !== lastPickedPixelIndex) {\n if (pickedLayerId !== lastPickedLayerId) {\n // We cannot store a ref to lastPickedLayer in the context because\n // the state of an outdated layer is no longer valid\n // and the props may have changed\n const lastPickedLayer = layers.find(layer => layer.props.id === lastPickedLayerId);\n if (lastPickedLayer) {\n // Let leave event fire before enter event\n affectedLayers.unshift(lastPickedLayer);\n }\n }\n\n // Update layer manager context\n lastPickedInfo.layerId = pickedLayerId;\n lastPickedInfo.index = pickedObjectIndex;\n lastPickedInfo.info = null;\n }\n }\n\n const baseInfo = getEmptyPickingInfo(opts);\n\n // Use a Map to store all picking infos.\n // The following two forEach loops are the result of\n // https://github.com/visgl/deck.gl/issues/443\n // Please be very careful when changing this pattern\n const infos = new Map();\n\n // Make sure infos always contain something even if no layer is affected\n infos.set(null, baseInfo);\n\n affectedLayers.forEach(layer => {\n let info = {...baseInfo};\n\n if (layer === pickedLayer) {\n info.color = pickedColor;\n info.index = pickedObjectIndex;\n info.picked = true;\n }\n\n info = getLayerPickingInfo({layer, info, mode});\n const rootLayer = info.layer as Layer;\n\n if (layer === pickedLayer && mode === 'hover') {\n lastPickedInfo.info = info;\n }\n\n // This guarantees that there will be only one copy of info for\n // one composite layer\n infos.set(rootLayer.id, info);\n\n if (mode === 'hover') {\n rootLayer.updateAutoHighlight(info);\n }\n });\n\n return infos;\n}\n\n/** Walk up the layer composite chain to populate the info object */\nexport function getLayerPickingInfo({\n layer,\n info,\n mode\n}: {\n layer: Layer;\n info: PickingInfo;\n mode: string;\n}): PickingInfo {\n while (layer && info) {\n // For a composite layer, sourceLayer will point to the sublayer\n // where the event originates from.\n // It provides additional context for the composite layer's\n // getPickingInfo() method to populate the info object\n const sourceLayer = info.layer || null;\n info.sourceLayer = sourceLayer;\n info.layer = layer;\n // layer.pickLayer() function requires a non-null ```layer.state```\n // object to function properly. So the layer referenced here\n // must be the \"current\" layer, not an \"out-dated\" / \"invalidated\" layer\n info = layer.getPickingInfo({info, mode, sourceLayer});\n layer = layer.parent as Layer;\n }\n return info;\n}\n\n/** Indentifies which viewport, if any corresponds to x and y\n If multiple viewports contain the target pixel, last viewport drawn is returend\n Returns first viewport if no match */\nfunction getViewportFromCoordinates(\n viewports: Viewport[],\n pixel: {x: number; y: number}\n): Viewport {\n // find the last viewport that contains the pixel\n for (let i = viewports.length - 1; i >= 0; i--) {\n const viewport = viewports[i];\n if (viewport.containsPixel(pixel)) {\n return viewport;\n }\n }\n return viewports[0];\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\nimport PickLayersPass, {PickingColorDecoder} from '../passes/pick-layers-pass';\nimport {getClosestObject, getUniqueObjects, PickedPixel} from './picking/query-object';\nimport {\n processPickInfo,\n getLayerPickingInfo,\n getEmptyPickingInfo,\n PickingInfo\n} from './picking/pick-info';\n\nimport type {Framebuffer} from '@luma.gl/core';\nimport type {FilterContext, Rect} from '../passes/layers-pass';\nimport type Layer from './layer';\nimport type {Effect} from './effect';\nimport type View from '../views/view';\nimport type Viewport from '../viewports/viewport';\n\nexport type PickByPointOptions = {\n x: number;\n y: number;\n radius?: number;\n depth?: number;\n mode?: string;\n unproject3D?: boolean;\n};\n\nexport type PickByRectOptions = {\n x: number;\n y: number;\n width?: number;\n height?: number;\n mode?: string;\n maxObjects?: number | null;\n};\n\ntype PickOperationContext = {\n layers: Layer[];\n views: Record;\n viewports: Viewport[];\n onViewportActive: (viewport: Viewport) => void;\n effects: Effect[];\n};\n\n/** Manages picking in a Deck context */\nexport default class DeckPicker {\n device: Device;\n pickingFBO?: Framebuffer;\n depthFBO?: Framebuffer;\n pickLayersPass: PickLayersPass;\n layerFilter?: (context: FilterContext) => boolean;\n\n /** Identifiers of the previously picked object, for callback tracking and auto highlight */\n lastPickedInfo: {\n index: number;\n layerId: string | null;\n info: PickingInfo | null;\n };\n\n _pickable: boolean = true;\n\n constructor(device: Device) {\n this.device = device;\n this.pickLayersPass = new PickLayersPass(device);\n this.lastPickedInfo = {\n index: -1,\n layerId: null,\n info: null\n };\n }\n\n setProps(props: any): void {\n if ('layerFilter' in props) {\n this.layerFilter = props.layerFilter;\n }\n\n if ('_pickable' in props) {\n this._pickable = props._pickable;\n }\n }\n\n finalize() {\n if (this.pickingFBO) {\n this.pickingFBO.destroy();\n }\n if (this.depthFBO) {\n this.depthFBO.destroy();\n }\n }\n\n /** Pick the closest info at given coordinate */\n pickObject(opts: PickByPointOptions & PickOperationContext) {\n return this._pickClosestObject(opts);\n }\n\n /** Get all unique infos within a bounding box */\n pickObjects(opts: PickByRectOptions & PickOperationContext) {\n return this._pickVisibleObjects(opts);\n }\n\n // Returns a new picking info object by assuming the last picked object is still picked\n getLastPickedObject({x, y, layers, viewports}, lastPickedInfo = this.lastPickedInfo.info) {\n const lastPickedLayerId = lastPickedInfo && lastPickedInfo.layer && lastPickedInfo.layer.id;\n const lastPickedViewportId =\n lastPickedInfo && lastPickedInfo.viewport && lastPickedInfo.viewport.id;\n const layer = lastPickedLayerId ? layers.find(l => l.id === lastPickedLayerId) : null;\n const viewport =\n (lastPickedViewportId && viewports.find(v => v.id === lastPickedViewportId)) || viewports[0];\n const coordinate = viewport && viewport.unproject([x - viewport.x, y - viewport.y]);\n\n const info = {\n x,\n y,\n viewport,\n coordinate,\n layer\n };\n\n return {...lastPickedInfo, ...info};\n }\n\n // Private\n\n /** Ensures that picking framebuffer exists and matches the canvas size */\n _resizeBuffer() {\n // Create a frame buffer if not already available\n if (!this.pickingFBO) {\n this.pickingFBO = this.device.createFramebuffer({\n colorAttachments: ['rgba8unorm'],\n depthStencilAttachment: 'depth16unorm'\n });\n\n if (this.device.isTextureFormatRenderable('rgba32float')) {\n const depthFBO = this.device.createFramebuffer({\n colorAttachments: ['rgba32float'],\n depthStencilAttachment: 'depth16unorm'\n });\n this.depthFBO = depthFBO;\n }\n }\n\n // Resize it to current canvas size (this is a noop if size hasn't changed)\n const {canvas} = this.device.getDefaultCanvasContext();\n this.pickingFBO?.resize({width: canvas.width, height: canvas.height});\n this.depthFBO?.resize({width: canvas.width, height: canvas.height});\n }\n\n /** Preliminary filtering of the layers list. Skid picking pass if no layer is pickable. */\n _getPickable(layers: Layer[]): Layer[] | null {\n if (this._pickable === false) {\n return null;\n }\n const pickableLayers = layers.filter(\n layer => this.pickLayersPass.shouldDrawLayer(layer) && !layer.isComposite\n );\n return pickableLayers.length ? pickableLayers : null;\n }\n\n /** Pick the closest object at the given coordinate */\n // eslint-disable-next-line max-statements,complexity\n _pickClosestObject({\n layers,\n views,\n viewports,\n x,\n y,\n radius = 0,\n depth = 1,\n mode = 'query',\n unproject3D,\n onViewportActive,\n effects\n }: PickByPointOptions & PickOperationContext): {\n result: PickingInfo[];\n emptyInfo: PickingInfo;\n } {\n // @ts-expect-error TODO - assuming WebGL context\n const pixelRatio = this.device.canvasContext.cssToDeviceRatio();\n\n const pickableLayers = this._getPickable(layers);\n\n if (!pickableLayers || viewports.length === 0) {\n return {\n result: [],\n emptyInfo: getEmptyPickingInfo({viewports, x, y, pixelRatio})\n };\n }\n\n this._resizeBuffer();\n\n // Convert from canvas top-left to WebGL bottom-left coordinates\n // Top-left coordinates [x, y] to bottom-left coordinates [deviceX, deviceY]\n // And compensate for pixelRatio\n // @ts-expect-error TODO - assuming WebGL context\n const devicePixelRange = this.device.canvasContext.cssToDevicePixels([x, y], true);\n const devicePixel = [\n devicePixelRange.x + Math.floor(devicePixelRange.width / 2),\n devicePixelRange.y + Math.floor(devicePixelRange.height / 2)\n ];\n\n const deviceRadius = Math.round(radius * pixelRatio);\n const {width, height} = this.pickingFBO as Framebuffer;\n const deviceRect = this._getPickingRect({\n deviceX: devicePixel[0],\n deviceY: devicePixel[1],\n deviceRadius,\n deviceWidth: width,\n deviceHeight: height\n });\n\n const cullRect: Rect = {\n x: x - radius,\n y: y - radius,\n width: radius * 2 + 1,\n height: radius * 2 + 1\n };\n\n let infos: Map;\n const result: PickingInfo[] = [];\n const affectedLayers = new Set();\n\n for (let i = 0; i < depth; i++) {\n let pickInfo: PickedPixel;\n\n if (deviceRect) {\n const pickedResult = this._drawAndSample({\n layers: pickableLayers,\n views,\n viewports,\n onViewportActive,\n deviceRect,\n cullRect,\n effects,\n pass: `picking:${mode}`\n });\n\n pickInfo = getClosestObject({\n ...pickedResult,\n deviceX: devicePixel[0],\n deviceY: devicePixel[1],\n deviceRadius,\n deviceRect\n });\n } else {\n pickInfo = {\n pickedColor: null,\n pickedObjectIndex: -1\n };\n }\n\n let z;\n if (pickInfo.pickedLayer && unproject3D && this.depthFBO) {\n const {pickedColors: pickedColors2} = this._drawAndSample(\n {\n layers: [pickInfo.pickedLayer],\n views,\n viewports,\n onViewportActive,\n deviceRect: {\n x: pickInfo.pickedX as number,\n y: pickInfo.pickedY as number,\n width: 1,\n height: 1\n },\n cullRect,\n effects,\n pass: `picking:${mode}:z`\n },\n true\n );\n // picked value is in common space (pixels) from the camera target (viewport.position)\n // convert it to meters from the ground\n if (pickedColors2[3]) {\n z = pickedColors2[0];\n }\n }\n\n // Only exclude if we need to run picking again.\n // We need to run picking again if an object is detected AND\n // we have not exhausted the requested depth.\n if (pickInfo.pickedLayer && i + 1 < depth) {\n affectedLayers.add(pickInfo.pickedLayer);\n pickInfo.pickedLayer.disablePickingIndex(pickInfo.pickedObjectIndex);\n }\n\n // This logic needs to run even if no object is picked.\n infos = processPickInfo({\n pickInfo,\n lastPickedInfo: this.lastPickedInfo,\n mode,\n layers: pickableLayers,\n viewports,\n x,\n y,\n z,\n pixelRatio\n });\n\n for (const info of infos.values()) {\n if (info.layer) {\n result.push(info);\n }\n }\n\n // If no object is picked stop.\n if (!pickInfo.pickedColor) {\n break;\n }\n }\n\n // reset only affected buffers\n for (const layer of affectedLayers) {\n layer.restorePickingColors();\n }\n\n return {result, emptyInfo: infos!.get(null) as PickingInfo};\n }\n\n /** Pick all objects within the given bounding box */\n _pickVisibleObjects({\n layers,\n views,\n viewports,\n x,\n y,\n width = 1,\n height = 1,\n mode = 'query',\n maxObjects = null,\n onViewportActive,\n effects\n }: PickByRectOptions & PickOperationContext): PickingInfo[] {\n const pickableLayers = this._getPickable(layers);\n\n if (!pickableLayers || viewports.length === 0) {\n return [];\n }\n\n this._resizeBuffer();\n\n // Convert from canvas top-left to WebGL bottom-left coordinates\n // And compensate for pixelRatio\n // @ts-expect-error TODO - assuming WebGL context\n const pixelRatio = this.device.canvasContext.cssToDeviceRatio();\n // @ts-expect-error TODO - assuming WebGL context\n const leftTop = this.device.canvasContext.cssToDevicePixels([x, y], true);\n\n // take left and top (y inverted in device pixels) from start location\n const deviceLeft = leftTop.x;\n const deviceTop = leftTop.y + leftTop.height;\n\n // take right and bottom (y inverted in device pixels) from end location\n // @ts-expect-error TODO - assuming WebGL context\n const rightBottom = this.device.canvasContext.cssToDevicePixels([x + width, y + height], true);\n const deviceRight = rightBottom.x + rightBottom.width;\n const deviceBottom = rightBottom.y;\n\n const deviceRect = {\n x: deviceLeft,\n y: deviceBottom,\n // deviceTop and deviceRight represent the first pixel outside the desired rect\n width: deviceRight - deviceLeft,\n height: deviceTop - deviceBottom\n };\n\n const pickedResult = this._drawAndSample({\n layers: pickableLayers,\n views,\n viewports,\n onViewportActive,\n deviceRect,\n cullRect: {x, y, width, height},\n effects,\n pass: `picking:${mode}`\n });\n\n const pickInfos = getUniqueObjects(pickedResult);\n\n // `getUniqueObjects` dedup by picked color\n // However different picked color may be linked to the same picked object, e.g. stroke and fill of the same polygon\n // picked from different sub layers of a GeoJsonLayer\n // Here after resolving the picked index with `layer.getPickingInfo`, we need to dedup again by unique picked objects\n const uniquePickedObjects = new Map>();\n const uniqueInfos: PickingInfo[] = [];\n\n const limitMaxObjects = Number.isFinite(maxObjects);\n\n for (let i = 0; i < pickInfos.length; i++) {\n if (limitMaxObjects && uniqueInfos.length >= maxObjects!) {\n break;\n }\n const pickInfo = pickInfos[i];\n let info: PickingInfo = {\n color: pickInfo.pickedColor,\n layer: null,\n index: pickInfo.pickedObjectIndex,\n picked: true,\n x,\n y,\n pixelRatio\n };\n\n info = getLayerPickingInfo({layer: pickInfo.pickedLayer as Layer, info, mode});\n // info.layer is always populated because it's a picked pixel\n const pickedLayerId = info.layer!.id;\n if (!uniquePickedObjects.has(pickedLayerId)) {\n uniquePickedObjects.set(pickedLayerId, new Set());\n }\n const uniqueObjectsInLayer = uniquePickedObjects.get(pickedLayerId) as Set;\n // info.object may be null if the layer is using non-iterable data.\n // Fall back to using index as identifier.\n const pickedObjectKey = info.object ?? info.index;\n if (!uniqueObjectsInLayer.has(pickedObjectKey)) {\n uniqueObjectsInLayer.add(pickedObjectKey);\n uniqueInfos.push(info);\n }\n }\n\n return uniqueInfos;\n }\n\n /** Renders layers into the picking buffer with picking colors and read the pixels. */\n _drawAndSample(params: {\n deviceRect: Rect;\n pass: string;\n layers: Layer[];\n views: Record;\n viewports: Viewport[];\n onViewportActive: (viewport: Viewport) => void;\n cullRect?: Rect;\n effects: Effect[];\n }): {\n pickedColors: Uint8Array;\n decodePickingColor: PickingColorDecoder;\n };\n\n /** Renders layers into the picking buffer with encoded z values and read the pixels. */\n _drawAndSample(\n params: {\n deviceRect: Rect;\n pass: string;\n layers: Layer[];\n views: Record;\n viewports: Viewport[];\n onViewportActive: (viewport: Viewport) => void;\n cullRect?: Rect;\n effects: Effect[];\n },\n pickZ: true\n ): {\n pickedColors: Float32Array;\n decodePickingColor: null;\n };\n\n _drawAndSample(\n {\n layers,\n views,\n viewports,\n onViewportActive,\n deviceRect,\n cullRect,\n effects,\n pass\n }: {\n deviceRect: Rect;\n pass: string;\n layers: Layer[];\n views: Record;\n viewports: Viewport[];\n onViewportActive: (viewport: Viewport) => void;\n cullRect?: Rect;\n effects: Effect[];\n },\n pickZ: boolean = false\n ): {\n pickedColors: Uint8Array | Float32Array;\n decodePickingColor: PickingColorDecoder | null;\n } {\n const pickingFBO = pickZ ? this.depthFBO : this.pickingFBO;\n const opts = {\n layers,\n layerFilter: this.layerFilter,\n views,\n viewports,\n onViewportActive,\n pickingFBO,\n deviceRect,\n cullRect,\n effects,\n pass,\n pickZ,\n preRenderStats: {}\n };\n\n for (const effect of effects) {\n if (effect.useInPicking) {\n opts.preRenderStats[effect.id] = effect.preRender(opts);\n }\n }\n\n const {decodePickingColor} = this.pickLayersPass.render(opts);\n\n // Read from an already rendered picking buffer\n // Returns an Uint8ClampedArray of picked pixels\n const {x, y, width, height} = deviceRect;\n const pickedColors = new (pickZ ? Float32Array : Uint8Array)(width * height * 4);\n this.device.readPixelsToArrayWebGL(pickingFBO as Framebuffer, {\n sourceX: x,\n sourceY: y,\n sourceWidth: width,\n sourceHeight: height,\n target: pickedColors\n });\n\n return {pickedColors, decodePickingColor};\n }\n\n // Calculate a picking rect centered on deviceX and deviceY and clipped to device\n // Returns null if pixel is outside of device\n _getPickingRect({\n deviceX,\n deviceY,\n deviceRadius,\n deviceWidth,\n deviceHeight\n }: {\n deviceX: number;\n deviceY: number;\n deviceRadius: number;\n deviceWidth: number;\n deviceHeight: number;\n }): Rect | null {\n // Create a box of size `radius * 2 + 1` centered at [deviceX, deviceY]\n const x = Math.max(0, deviceX - deviceRadius);\n const y = Math.max(0, deviceY - deviceRadius);\n const width = Math.min(deviceWidth, deviceX + deviceRadius + 1) - x;\n const height = Math.min(deviceHeight, deviceY + deviceRadius + 1) - y;\n\n // x, y out of bounds.\n if (width <= 0 || height <= 0) {\n return null;\n }\n\n return {x, y, width, height};\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type Deck from './deck';\nimport type Viewport from '../viewports/viewport';\nimport type {PickingInfo} from './picking/pick-info';\nimport type {MjolnirPointerEvent, MjolnirGestureEvent} from 'mjolnir.js';\nimport type Layer from './layer';\n\nimport {EVENT_HANDLERS} from './constants';\nimport {deepEqual} from '../utils/deep-equal';\n\nexport interface Widget {\n /** Unique identifier of the widget. */\n id: string;\n /** Widget prop types. */\n props: PropsT;\n /**\n * The view id that this widget is being attached to. Default `null`.\n * If assigned, this widget will only respond to events occurred inside the specific view that matches this id.\n */\n viewId?: string | null;\n /** Widget positioning within the view. Default 'top-left'. */\n placement?: WidgetPlacement;\n\n // Populated by core when mounted\n _element?: HTMLDivElement | null;\n\n // Lifecycle hooks\n /** Called when the widget is added to a Deck instance.\n * @returns an optional UI element that should be appended to the Deck container */\n onAdd: (params: {\n /** The Deck instance that the widget is attached to */\n deck: Deck;\n /** The id of the view that the widget is attached to */\n viewId: string | null;\n }) => HTMLDivElement | null;\n /** Called when the widget is removed */\n onRemove?: () => void;\n /** Called to update widget options */\n setProps: (props: Partial) => void;\n\n // Optional event hooks\n /** Called when the containing view is changed */\n onViewportChange?: (viewport: Viewport) => void;\n /** Called when the containing view is redrawn */\n onRedraw?: (params: {viewports: Viewport[]; layers: Layer[]}) => void;\n /** Called when a hover event occurs */\n onHover?: (info: PickingInfo, event: MjolnirPointerEvent) => void;\n /** Called when a click event occurs */\n onClick?: (info: PickingInfo, event: MjolnirGestureEvent) => void;\n /** Called when a drag event occurs */\n onDrag?: (info: PickingInfo, event: MjolnirGestureEvent) => void;\n /** Called when a dragstart event occurs */\n onDragStart?: (info: PickingInfo, event: MjolnirGestureEvent) => void;\n /** Called when a dragend event occurs */\n onDragEnd?: (info: PickingInfo, event: MjolnirGestureEvent) => void;\n}\n\nconst PLACEMENTS = {\n 'top-left': {top: 0, left: 0},\n 'top-right': {top: 0, right: 0},\n 'bottom-left': {bottom: 0, left: 0},\n 'bottom-right': {bottom: 0, right: 0},\n fill: {top: 0, left: 0, bottom: 0, right: 0}\n} as const;\nconst DEFAULT_PLACEMENT = 'top-left';\n\nexport type WidgetPlacement = keyof typeof PLACEMENTS;\n\nconst ROOT_CONTAINER_ID = '__root';\n\nexport class WidgetManager {\n deck: Deck;\n parentElement?: HTMLElement | null;\n\n /** Widgets added via the imperative API */\n private defaultWidgets: Widget[] = [];\n /** Widgets received from the declarative API */\n private widgets: Widget[] = [];\n /** Resolved widgets from both imperative and declarative APIs */\n private resolvedWidgets: Widget[] = [];\n\n /** Mounted HTML containers */\n private containers: {[id: string]: HTMLDivElement} = {};\n /** Viewport provided to widget on redraw */\n private lastViewports: {[id: string]: Viewport} = {};\n\n constructor({deck, parentElement}: {deck: Deck; parentElement?: HTMLElement | null}) {\n this.deck = deck;\n this.parentElement = parentElement;\n }\n\n getWidgets(): Widget[] {\n return this.resolvedWidgets;\n }\n\n /** Declarative API to configure widgets */\n setProps(props: {widgets?: Widget[]}) {\n if (props.widgets && !deepEqual(props.widgets, this.widgets, 1)) {\n this._setWidgets(props.widgets);\n }\n }\n\n finalize() {\n for (const widget of this.getWidgets()) {\n this._remove(widget);\n }\n this.defaultWidgets.length = 0;\n this.resolvedWidgets.length = 0;\n for (const id in this.containers) {\n this.containers[id].remove();\n }\n }\n\n /** Imperative API. Widgets added this way are not affected by the declarative prop. */\n addDefault(widget: Widget) {\n if (!this.defaultWidgets.find(w => w.id === widget.id)) {\n this._add(widget);\n this.defaultWidgets.push(widget);\n // Update widget list\n this._setWidgets(this.widgets);\n }\n }\n\n /** Resolve widgets from the declarative prop */\n private _setWidgets(nextWidgets: Widget[]) {\n const oldWidgetMap: Record = {};\n\n for (const widget of this.resolvedWidgets) {\n oldWidgetMap[widget.id] = widget;\n }\n // Clear and rebuild the list\n this.resolvedWidgets.length = 0;\n\n // Add all default widgets\n for (const widget of this.defaultWidgets) {\n oldWidgetMap[widget.id] = null;\n this.resolvedWidgets.push(widget);\n }\n\n for (let widget of nextWidgets) {\n const oldWidget = oldWidgetMap[widget.id];\n if (!oldWidget) {\n // Widget is new\n this._add(widget);\n } else if (\n // Widget placement changed\n oldWidget.viewId !== widget.viewId ||\n oldWidget.placement !== widget.placement\n ) {\n this._remove(oldWidget);\n this._add(widget);\n } else if (widget !== oldWidget) {\n // Widget props changed\n oldWidget.setProps(widget.props);\n widget = oldWidget;\n }\n\n // mark as matched\n oldWidgetMap[widget.id] = null;\n this.resolvedWidgets.push(widget);\n }\n\n for (const id in oldWidgetMap) {\n const oldWidget = oldWidgetMap[id];\n if (oldWidget) {\n // No longer exists\n this._remove(oldWidget);\n }\n }\n this.widgets = nextWidgets;\n }\n\n private _add(widget: Widget) {\n const {viewId = null, placement = DEFAULT_PLACEMENT} = widget;\n const element = widget.onAdd({deck: this.deck, viewId});\n\n if (element) {\n this._getContainer(viewId, placement).append(element);\n }\n widget._element = element;\n }\n\n private _remove(widget: Widget) {\n widget.onRemove?.();\n\n if (widget._element) {\n widget._element.remove();\n }\n widget._element = undefined;\n }\n\n /* global document */\n private _getContainer(viewId: string | null, placement: WidgetPlacement): HTMLDivElement {\n const containerId = viewId || ROOT_CONTAINER_ID;\n let viewContainer = this.containers[containerId];\n if (!viewContainer) {\n viewContainer = document.createElement('div');\n viewContainer.style.pointerEvents = 'none';\n viewContainer.style.position = 'absolute';\n viewContainer.style.overflow = 'hidden';\n this.parentElement?.append(viewContainer);\n this.containers[containerId] = viewContainer;\n }\n let container = viewContainer.querySelector(`.${placement}`);\n if (!container) {\n container = document.createElement('div');\n container.className = placement;\n container.style.position = 'absolute';\n container.style.zIndex = '2';\n Object.assign(container.style, PLACEMENTS[placement]);\n viewContainer.append(container);\n }\n return container;\n }\n\n private _updateContainers() {\n const canvasWidth = this.deck.width;\n const canvasHeight = this.deck.height;\n for (const id in this.containers) {\n const viewport = this.lastViewports[id] || null;\n const visible = id === ROOT_CONTAINER_ID || viewport;\n\n const container = this.containers[id];\n if (visible) {\n container.style.display = 'block';\n // Align the container with the view\n container.style.left = `${viewport ? viewport.x : 0}px`;\n container.style.top = `${viewport ? viewport.y : 0}px`;\n container.style.width = `${viewport ? viewport.width : canvasWidth}px`;\n container.style.height = `${viewport ? viewport.height : canvasHeight}px`;\n } else {\n container.style.display = 'none';\n }\n }\n }\n\n onRedraw({viewports, layers}: {viewports: Viewport[]; layers: Layer[]}) {\n const viewportsById: {[id: string]: Viewport} = viewports.reduce((acc, v) => {\n acc[v.id] = v;\n return acc;\n }, {});\n\n for (const widget of this.getWidgets()) {\n const {viewId} = widget;\n if (viewId) {\n // Attached to a specific view\n const viewport = viewportsById[viewId];\n if (viewport) {\n if (widget.onViewportChange) {\n widget.onViewportChange(viewport);\n }\n widget.onRedraw?.({viewports: [viewport], layers});\n }\n } else {\n // Not attached to a specific view\n if (widget.onViewportChange) {\n for (const viewport of viewports) {\n widget.onViewportChange(viewport);\n }\n }\n widget.onRedraw?.({viewports, layers});\n }\n }\n this.lastViewports = viewportsById;\n this._updateContainers();\n }\n\n onHover(info: PickingInfo, event: MjolnirPointerEvent) {\n for (const widget of this.getWidgets()) {\n const {viewId} = widget;\n if (!viewId || viewId === info.viewport?.id) {\n widget.onHover?.(info, event);\n }\n }\n }\n\n onEvent(info: PickingInfo, event: MjolnirGestureEvent) {\n const eventHandlerProp = EVENT_HANDLERS[event.type];\n if (!eventHandlerProp) {\n return;\n }\n for (const widget of this.getWidgets()) {\n const {viewId} = widget;\n if (!viewId || viewId === info.viewport?.id) {\n widget[eventHandlerProp]?.(info, event);\n }\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Widget, WidgetPlacement} from './widget-manager';\nimport type {PickingInfo} from './picking/pick-info';\nimport type Viewport from '../viewports/viewport';\nimport type Deck from './deck';\n\n/* global document */\nconst defaultStyle: Partial = {\n zIndex: '1',\n position: 'absolute',\n pointerEvents: 'none',\n color: '#a0a7b4',\n backgroundColor: '#29323c',\n padding: '10px',\n top: '0',\n left: '0',\n display: 'none'\n};\n\nexport type TooltipContent =\n | null\n | string\n | {\n text?: string;\n html?: string;\n className?: string;\n style?: Partial;\n };\n\nexport default class Tooltip implements Widget {\n id = 'default-tooltip';\n placement: WidgetPlacement = 'fill';\n props = {};\n isVisible: boolean = false;\n deck?: Deck;\n element?: HTMLDivElement;\n lastViewport?: Viewport;\n\n onAdd({deck}: {deck: Deck}): HTMLDivElement {\n const el = document.createElement('div');\n el.className = 'deck-tooltip';\n Object.assign(el.style, defaultStyle);\n\n this.deck = deck;\n this.element = el;\n\n return el;\n }\n\n onRemove() {\n this.deck = undefined;\n this.element = undefined;\n }\n\n setProps() {}\n\n onViewportChange(viewport: Viewport) {\n if (this.isVisible && viewport.id === this.lastViewport?.id && viewport !== this.lastViewport) {\n // Camera has moved, clear tooltip\n this.setTooltip(null);\n }\n }\n\n onHover(info: PickingInfo) {\n const {deck} = this;\n const getTooltip = deck && deck.props.getTooltip;\n if (!getTooltip) {\n return;\n }\n const displayInfo = getTooltip(info);\n this.lastViewport = info.viewport;\n this.setTooltip(displayInfo, info.x, info.y);\n }\n\n setTooltip(displayInfo: TooltipContent, x?: number, y?: number): void {\n const el = this.element;\n if (!el) {\n return;\n }\n\n if (typeof displayInfo === 'string') {\n el.innerText = displayInfo;\n } else if (!displayInfo) {\n this.isVisible = false;\n el.style.display = 'none';\n return;\n } else {\n if (displayInfo.text) {\n el.innerText = displayInfo.text;\n }\n if (displayInfo.html) {\n el.innerHTML = displayInfo.html;\n }\n if (displayInfo.className) {\n el.className = displayInfo.className;\n }\n }\n this.isVisible = true;\n el.style.display = 'block';\n el.style.transform = `translate(${x}px, ${y}px)`;\n\n if (displayInfo && typeof displayInfo === 'object' && 'style' in displayInfo) {\n Object.assign(el.style, displayInfo.style);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport LayerManager from './layer-manager';\nimport ViewManager from './view-manager';\nimport MapView from '../views/map-view';\nimport EffectManager from './effect-manager';\nimport DeckRenderer from './deck-renderer';\nimport DeckPicker from './deck-picker';\nimport {WidgetManager, Widget} from './widget-manager';\nimport Tooltip from './tooltip';\nimport log from '../utils/log';\nimport {deepEqual} from '../utils/deep-equal';\nimport typedArrayManager from '../utils/typed-array-manager';\nimport {VERSION} from './init';\n\nimport {luma} from '@luma.gl/core';\nimport {WebGLDevice, webgl2Adapter} from '@luma.gl/webgl';\nimport {Timeline} from '@luma.gl/engine';\nimport {AnimationLoop} from '@luma.gl/engine';\nimport {GL} from '@luma.gl/constants';\nimport type {Device, DeviceProps, Framebuffer, Parameters} from '@luma.gl/core';\nimport type {ShaderModule} from '@luma.gl/shadertools';\n\nimport {Stats} from '@probe.gl/stats';\nimport {EventManager} from 'mjolnir.js';\n\nimport assert from '../utils/assert';\nimport {EVENT_HANDLERS, RECOGNIZERS, RecognizerOptions} from './constants';\n\nimport type {Effect} from './effect';\nimport type {FilterContext} from '../passes/layers-pass';\nimport type Layer from './layer';\nimport type View from '../views/view';\nimport type Viewport from '../viewports/viewport';\nimport type {EventManagerOptions, MjolnirGestureEvent, MjolnirPointerEvent} from 'mjolnir.js';\nimport type {TypedArrayManagerOptions} from '../utils/typed-array-manager';\nimport type {ViewStateChangeParameters, InteractionState} from '../controllers/controller';\nimport type {PickingInfo} from './picking/pick-info';\nimport type {PickByPointOptions, PickByRectOptions} from './deck-picker';\nimport type {LayersList} from './layer-manager';\nimport type {TooltipContent} from './tooltip';\nimport type {ViewStateMap, AnyViewStateOf, ViewOrViews, ViewStateObject} from './view-manager';\nimport {CreateDeviceProps} from '@luma.gl/core';\n\n/* global document */\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nfunction noop() {}\n\nconst getCursor = ({isDragging}) => (isDragging ? 'grabbing' : 'grab');\n\nexport type DeckMetrics = {\n fps: number;\n setPropsTime: number;\n updateAttributesTime: number;\n framesRedrawn: number;\n pickTime: number;\n pickCount: number;\n gpuTime: number;\n gpuTimePerFrame: number;\n cpuTime: number;\n cpuTimePerFrame: number;\n bufferMemory: number;\n textureMemory: number;\n renderbufferMemory: number;\n gpuMemory: number;\n};\n\ntype CursorState = {\n /** Whether the cursor is over a pickable object */\n isHovering: boolean;\n /** Whether the cursor is down */\n isDragging: boolean;\n};\n\nexport type DeckProps = {\n /** Id of this Deck instance */\n id?: string;\n /** Width of the canvas, a number in pixels or a valid CSS string.\n * @default `'100%'`\n */\n width?: string | number | null;\n /** Height of the canvas, a number in pixels or a valid CSS string.\n * @default `'100%'`\n */\n height?: string | number | null;\n /** Additional CSS styles for the canvas. */\n style?: Partial | null;\n\n /** Controls the resolution of drawing buffer used for rendering.\n * @default `true` (use browser devicePixelRatio)\n */\n useDevicePixels?: boolean | number;\n /** Extra pixels around the pointer to include while picking.\n * @default `0`\n */\n pickingRadius?: number;\n\n /** WebGL parameters to be set before each frame is rendered. */\n parameters?: Parameters;\n /** If supplied, will be called before a layer is drawn to determine whether it should be rendered. */\n layerFilter?: ((context: FilterContext) => boolean) | null;\n\n /** The container to append the auto-created canvas to.\n * @default `document.body`\n */\n parent?: HTMLDivElement | null;\n\n /** The canvas to render into.\n * Can be either a HTMLCanvasElement or the element id.\n * Will be auto-created if not supplied.\n */\n canvas?: HTMLCanvasElement | string | null;\n\n /** Use an existing luma.gl GPU device. @note If not supplied, a new device will be created using props.deviceProps */\n device?: Device | null;\n\n /** A new device will be created using these props, assuming that an existing device is not supplied using props.device) */\n deviceProps?: CreateDeviceProps;\n\n /** WebGL context @deprecated Use props.deviceProps.webgl. Also note that preserveDrawingBuffers is true by default */\n gl?: WebGL2RenderingContext | null;\n\n /**\n * The array of Layer instances to be rendered.\n * Nested arrays are accepted, as well as falsy values (`null`, `false`, `undefined`)\n */\n layers?: LayersList;\n /** The array of effects to be rendered. A lighting effect will be added if an empty array is supplied. */\n effects?: Effect[];\n /** A single View instance, or an array of `View` instances.\n * @default `new MapView()`\n */\n views?: ViewsT;\n /** Options for viewport interactivity, e.g. pan, rotate and zoom with mouse, touch and keyboard.\n * This is a shorthand for defining interaction with the `views` prop if you are using the default view (i.e. a single `MapView`)\n */\n controller?: View['props']['controller'];\n /**\n * An object that describes the view state for each view in the `views` prop.\n * Use if the camera state should be managed external to the `Deck` instance.\n */\n viewState?: ViewStateMap | null;\n /**\n * If provided, the `Deck` instance will track camera state changes automatically,\n * with `initialViewState` as its initial settings.\n */\n initialViewState?: ViewStateMap | null;\n\n /** Allow browser default touch actions.\n * @default `'none'`\n */\n touchAction?: EventManagerOptions['touchAction'];\n /**\n * Optional mjolnir.js recognizer options\n */\n eventRecognizerOptions?: RecognizerOptions;\n\n /** (Experimental) Render to a custom frame buffer other than to screen. */\n _framebuffer?: Framebuffer | null;\n /** (Experimental) Forces deck.gl to redraw layers every animation frame. */\n _animate?: boolean;\n /** (Experimental) If set to `false`, force disables all picking features, disregarding the `pickable` prop set in any layer. */\n _pickable?: boolean;\n /** (Experimental) Fine-tune attribute memory usage. See documentation for details. */\n _typedArrayManagerProps?: TypedArrayManagerOptions;\n /** An array of Widget instances to be added to the parent element. */\n widgets?: Widget[];\n\n /** Called once the GPU Device has been initiated. */\n onDeviceInitialized?: (device: Device) => void;\n /** @deprecated Called once the WebGL context has been initiated. */\n onWebGLInitialized?: (gl: WebGL2RenderingContext) => void;\n /** Called when the canvas resizes. */\n onResize?: (dimensions: {width: number; height: number}) => void;\n /** Called when the user has interacted with the deck.gl canvas, e.g. using mouse, touch or keyboard. */\n onViewStateChange?: >(\n params: ViewStateChangeParameters\n ) => ViewStateT | null | void;\n /** Called when the user has interacted with the deck.gl canvas, e.g. using mouse, touch or keyboard. */\n onInteractionStateChange?: (state: InteractionState) => void;\n /** Called just before the canvas rerenders. */\n onBeforeRender?: (context: {device: Device; gl: WebGL2RenderingContext}) => void;\n /** Called right after the canvas rerenders. */\n onAfterRender?: (context: {device: Device; gl: WebGL2RenderingContext}) => void;\n /** Called once after gl context and all Deck components are created. */\n onLoad?: () => void;\n /** Called if deck.gl encounters an error.\n * If this callback is set to `null`, errors are silently ignored.\n * @default `console.error`\n */\n onError?: ((error: Error, layer?: Layer) => void) | null;\n /** Called when the pointer moves over the canvas. */\n onHover?: ((info: PickingInfo, event: MjolnirPointerEvent) => void) | null;\n /** Called when clicking on the canvas. */\n onClick?: ((info: PickingInfo, event: MjolnirGestureEvent) => void) | null;\n /** Called when the user starts dragging on the canvas. */\n onDragStart?: ((info: PickingInfo, event: MjolnirGestureEvent) => void) | null;\n /** Called when dragging the canvas. */\n onDrag?: ((info: PickingInfo, event: MjolnirGestureEvent) => void) | null;\n /** Called when the user releases from dragging the canvas. */\n onDragEnd?: ((info: PickingInfo, event: MjolnirGestureEvent) => void) | null;\n\n /** (Experimental) Replace the default redraw procedure */\n _customRender?: ((reason: string) => void) | null;\n /** (Experimental) Called once every second with performance metrics. */\n _onMetrics?: ((metrics: DeckMetrics) => void) | null;\n\n /** A custom callback to retrieve the cursor type. */\n getCursor?: (state: CursorState) => string;\n /** Callback that takes a hovered-over point and renders a tooltip. */\n getTooltip?: ((info: PickingInfo) => TooltipContent) | null;\n\n /** (Debug) Flag to enable WebGL debug mode. Requires importing `@luma.gl/debug`. */\n debug?: boolean;\n /** (Debug) Render the picking buffer to screen. */\n drawPickingColors?: boolean;\n};\n\nconst defaultProps: DeckProps = {\n id: '',\n width: '100%',\n height: '100%',\n style: null,\n viewState: null,\n initialViewState: null,\n pickingRadius: 0,\n layerFilter: null,\n parameters: {},\n parent: null,\n device: null,\n deviceProps: {type: 'webgl'} as DeviceProps,\n gl: null,\n canvas: null,\n layers: [],\n effects: [],\n views: null,\n controller: null, // Rely on external controller, e.g. react-map-gl\n useDevicePixels: true,\n touchAction: 'none',\n eventRecognizerOptions: {},\n _framebuffer: null,\n _animate: false,\n _pickable: true,\n _typedArrayManagerProps: {},\n _customRender: null,\n widgets: [],\n\n onDeviceInitialized: noop,\n onWebGLInitialized: noop,\n onResize: noop,\n onViewStateChange: noop,\n onInteractionStateChange: noop,\n onBeforeRender: noop,\n onAfterRender: noop,\n onLoad: noop,\n onError: (error: Error) => log.error(error.message, error.cause)(),\n onHover: null,\n onClick: null,\n onDragStart: null,\n onDrag: null,\n onDragEnd: null,\n _onMetrics: null,\n\n getCursor,\n getTooltip: null,\n\n debug: false,\n drawPickingColors: false\n};\n\n/* eslint-disable max-statements */\nexport default class Deck {\n static defaultProps = defaultProps;\n // This is used to defeat tree shaking of init.js\n // https://github.com/visgl/deck.gl/issues/3213\n static VERSION = VERSION;\n\n readonly props: Required>;\n readonly width: number = 0;\n readonly height: number = 0;\n // Allows attaching arbitrary data to the instance\n readonly userData: Record = {};\n\n protected device: Device | null = null;\n\n protected canvas: HTMLCanvasElement | null = null;\n protected viewManager: ViewManager | null = null;\n protected layerManager: LayerManager | null = null;\n protected effectManager: EffectManager | null = null;\n protected deckRenderer: DeckRenderer | null = null;\n protected deckPicker: DeckPicker | null = null;\n protected eventManager: EventManager | null = null;\n protected widgetManager: WidgetManager | null = null;\n protected tooltip: Tooltip | null = null;\n protected animationLoop: AnimationLoop | null = null;\n\n /** Internal view state if no callback is supplied */\n protected viewState: ViewStateObject | null;\n protected cursorState: CursorState = {\n isHovering: false,\n isDragging: false\n };\n\n protected stats = new Stats({id: 'deck.gl'});\n protected metrics: DeckMetrics = {\n fps: 0,\n setPropsTime: 0,\n updateAttributesTime: 0,\n framesRedrawn: 0,\n pickTime: 0,\n pickCount: 0,\n gpuTime: 0,\n gpuTimePerFrame: 0,\n cpuTime: 0,\n cpuTimePerFrame: 0,\n bufferMemory: 0,\n textureMemory: 0,\n renderbufferMemory: 0,\n gpuMemory: 0\n };\n private _metricsCounter: number = 0;\n\n private _needsRedraw: false | string = 'Initial render';\n private _pickRequest: {\n mode: string;\n event: MjolnirPointerEvent | null;\n x: number;\n y: number;\n radius: number;\n } = {\n mode: 'hover',\n x: -1,\n y: -1,\n radius: 0,\n event: null\n };\n\n /**\n * Pick and store the object under the pointer on `pointerdown`.\n * This object is reused for subsequent `onClick` and `onDrag*` callbacks.\n */\n private _lastPointerDownInfo: PickingInfo | null = null;\n\n constructor(props: DeckProps) {\n // @ts-ignore views\n this.props = {...defaultProps, ...props};\n props = this.props;\n\n if (props.viewState && props.initialViewState) {\n log.warn(\n 'View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.'\n )();\n }\n this.viewState = this.props.initialViewState;\n\n // See if we already have a device\n if (props.device) {\n this.device = props.device;\n }\n\n let deviceOrPromise: Device | Promise | null = this.device;\n\n // Attach a new luma.gl device to a WebGL2 context if supplied\n if (!deviceOrPromise && props.gl) {\n if (props.gl instanceof WebGLRenderingContext) {\n log.error('WebGL1 context not supported.')();\n }\n deviceOrPromise = webgl2Adapter.attach(props.gl);\n }\n\n // Create a new device\n if (!deviceOrPromise) {\n // Create the \"best\" device supported from the registered adapters\n deviceOrPromise = luma.createDevice({\n type: 'best-available',\n adapters: [webgl2Adapter],\n ...props.deviceProps,\n createCanvasContext: {\n canvas: this._createCanvas(props),\n useDevicePixels: this.props.useDevicePixels,\n // TODO v9.2 - replace AnimationLoop's `autoResizeDrawingBuffer` with CanvasContext's `autoResize`\n autoResize: false\n }\n });\n }\n\n this.animationLoop = this._createAnimationLoop(deviceOrPromise, props);\n\n this.setProps(props);\n\n // UNSAFE/experimental prop: only set at initialization to avoid performance hit\n if (props._typedArrayManagerProps) {\n typedArrayManager.setOptions(props._typedArrayManagerProps);\n }\n\n this.animationLoop.start();\n }\n\n /** Stop rendering and dispose all resources */\n finalize() {\n this.animationLoop?.stop();\n this.animationLoop?.destroy();\n this.animationLoop = null;\n this._lastPointerDownInfo = null;\n\n this.layerManager?.finalize();\n this.layerManager = null;\n\n this.viewManager?.finalize();\n this.viewManager = null;\n\n this.effectManager?.finalize();\n this.effectManager = null;\n\n this.deckRenderer?.finalize();\n this.deckRenderer = null;\n\n this.deckPicker?.finalize();\n this.deckPicker = null;\n\n this.eventManager?.destroy();\n this.eventManager = null;\n\n this.widgetManager?.finalize();\n this.widgetManager = null;\n\n if (!this.props.canvas && !this.props.device && !this.props.gl && this.canvas) {\n // remove internally created canvas\n this.canvas.parentElement?.removeChild(this.canvas);\n this.canvas = null;\n }\n }\n\n /** Partially update props */\n setProps(props: DeckProps): void {\n this.stats.get('setProps Time').timeStart();\n\n if ('onLayerHover' in props) {\n log.removed('onLayerHover', 'onHover')();\n }\n if ('onLayerClick' in props) {\n log.removed('onLayerClick', 'onClick')();\n }\n if (\n props.initialViewState &&\n // depth = 3 when comparing viewStates: viewId.position.0\n !deepEqual(this.props.initialViewState, props.initialViewState, 3)\n ) {\n // Overwrite internal view state\n this.viewState = props.initialViewState;\n }\n\n // Merge with existing props\n Object.assign(this.props, props);\n\n // Update CSS size of canvas\n this._setCanvasSize(this.props);\n\n // We need to overwrite CSS style width and height with actual, numeric values\n const resolvedProps: Required & {\n width: number;\n height: number;\n views: View[];\n viewState: ViewStateObject | null;\n } = Object.create(this.props);\n Object.assign(resolvedProps, {\n views: this._getViews(),\n width: this.width,\n height: this.height,\n viewState: this._getViewState()\n });\n\n // Update the animation loop\n this.animationLoop?.setProps(resolvedProps);\n\n // If initialized, update sub manager props\n if (this.layerManager) {\n this.viewManager!.setProps(resolvedProps);\n // Make sure that any new layer gets initialized with the current viewport\n this.layerManager.activateViewport(this.getViewports()[0]);\n this.layerManager.setProps(resolvedProps);\n this.effectManager!.setProps(resolvedProps);\n this.deckRenderer!.setProps(resolvedProps);\n this.deckPicker!.setProps(resolvedProps);\n this.widgetManager!.setProps(resolvedProps);\n }\n\n this.stats.get('setProps Time').timeEnd();\n }\n\n // Public API\n\n /**\n * Check if a redraw is needed\n * @returns `false` or a string summarizing the redraw reason\n */\n needsRedraw(\n opts: {\n /** Reset the redraw flag afterwards. Default `true` */\n clearRedrawFlags: boolean;\n } = {clearRedrawFlags: false}\n ): false | string {\n if (!this.layerManager) {\n // Not initialized or already finalized\n return false;\n }\n if (this.props._animate) {\n return 'Deck._animate';\n }\n\n let redraw: false | string = this._needsRedraw;\n\n if (opts.clearRedrawFlags) {\n this._needsRedraw = false;\n }\n\n const viewManagerNeedsRedraw = this.viewManager!.needsRedraw(opts);\n const layerManagerNeedsRedraw = this.layerManager.needsRedraw(opts);\n const effectManagerNeedsRedraw = this.effectManager!.needsRedraw(opts);\n const deckRendererNeedsRedraw = this.deckRenderer!.needsRedraw(opts);\n\n redraw =\n redraw ||\n viewManagerNeedsRedraw ||\n layerManagerNeedsRedraw ||\n effectManagerNeedsRedraw ||\n deckRendererNeedsRedraw;\n return redraw;\n }\n\n /**\n * Redraw the GL context\n * @param reason If not provided, only redraw if deemed necessary. Otherwise redraw regardless of internal states.\n * @returns\n */\n redraw(reason?: string): void {\n if (!this.layerManager) {\n // Not yet initialized\n return;\n }\n // Check if we need to redraw\n let redrawReason = this.needsRedraw({clearRedrawFlags: true});\n // User-supplied should take precedent, however the redraw flags get cleared regardless\n redrawReason = reason || redrawReason;\n\n if (!redrawReason) {\n return;\n }\n\n this.stats.get('Redraw Count').incrementCount();\n if (this.props._customRender) {\n this.props._customRender(redrawReason);\n } else {\n this._drawLayers(redrawReason);\n }\n }\n\n /** Flag indicating that the Deck instance has initialized its resources and it's safe to call public methods. */\n get isInitialized(): boolean {\n return this.viewManager !== null;\n }\n\n /** Get a list of views that are currently rendered */\n getViews(): View[] {\n assert(this.viewManager);\n return this.viewManager.views;\n }\n\n /** Get a list of viewports that are currently rendered.\n * @param rect If provided, only returns viewports within the given bounding box.\n */\n getViewports(rect?: {x: number; y: number; width?: number; height?: number}): Viewport[] {\n assert(this.viewManager);\n return this.viewManager.getViewports(rect);\n }\n\n /** Get the current canvas element. */\n getCanvas(): HTMLCanvasElement | null {\n return this.canvas;\n }\n\n /** Query the object rendered on top at a given point */\n pickObject(opts: {\n /** x position in pixels */\n x: number;\n /** y position in pixels */\n y: number;\n /** Radius of tolerance in pixels. Default `0`. */\n radius?: number;\n /** A list of layer ids to query from. If not specified, then all pickable and visible layers are queried. */\n layerIds?: string[];\n /** If `true`, `info.coordinate` will be a 3D point by unprojecting the `x, y` screen coordinates onto the picked geometry. Default `false`. */\n unproject3D?: boolean;\n }): PickingInfo | null {\n const infos = this._pick('pickObject', 'pickObject Time', opts).result;\n return infos.length ? infos[0] : null;\n }\n\n /* Query all rendered objects at a given point */\n pickMultipleObjects(opts: {\n /** x position in pixels */\n x: number;\n /** y position in pixels */\n y: number;\n /** Radius of tolerance in pixels. Default `0`. */\n radius?: number;\n /** Specifies the max number of objects to return. Default `10`. */\n depth?: number;\n /** A list of layer ids to query from. If not specified, then all pickable and visible layers are queried. */\n layerIds?: string[];\n /** If `true`, `info.coordinate` will be a 3D point by unprojecting the `x, y` screen coordinates onto the picked geometry. Default `false`. */\n unproject3D?: boolean;\n }): PickingInfo[] {\n opts.depth = opts.depth || 10;\n return this._pick('pickObject', 'pickMultipleObjects Time', opts).result;\n }\n\n /* Query all objects rendered on top within a bounding box */\n pickObjects(opts: {\n /** Left of the bounding box in pixels */\n x: number;\n /** Top of the bounding box in pixels */\n y: number;\n /** Width of the bounding box in pixels. Default `1` */\n width?: number;\n /** Height of the bounding box in pixels. Default `1` */\n height?: number;\n /** A list of layer ids to query from. If not specified, then all pickable and visible layers are queried. */\n layerIds?: string[];\n /** If specified, limits the number of objects that can be returned. */\n maxObjects?: number | null;\n }): PickingInfo[] {\n return this._pick('pickObjects', 'pickObjects Time', opts);\n }\n\n /** Experimental\n * Add a global resource for sharing among layers\n */\n _addResources(\n resources: {\n [id: string]: any;\n },\n forceUpdate = false\n ) {\n for (const id in resources) {\n this.layerManager!.resourceManager.add({resourceId: id, data: resources[id], forceUpdate});\n }\n }\n\n /** Experimental\n * Remove a global resource\n */\n _removeResources(resourceIds: string[]) {\n for (const id of resourceIds) {\n this.layerManager!.resourceManager.remove(id);\n }\n }\n\n /** Experimental\n * Register a default effect. Effects will be sorted by order, those with a low order will be rendered first\n */\n _addDefaultEffect(effect: Effect) {\n this.effectManager!.addDefaultEffect(effect);\n }\n\n _addDefaultShaderModule(module: ShaderModule>) {\n this.layerManager!.addDefaultShaderModule(module);\n }\n\n _removeDefaultShaderModule(module: ShaderModule>) {\n this.layerManager?.removeDefaultShaderModule(module);\n }\n\n // Private Methods\n\n private _pick(\n method: 'pickObject',\n statKey: string,\n opts: PickByPointOptions & {layerIds?: string[]}\n ): {\n result: PickingInfo[];\n emptyInfo: PickingInfo;\n };\n private _pick(\n method: 'pickObjects',\n statKey: string,\n opts: PickByRectOptions & {layerIds?: string[]}\n ): PickingInfo[];\n\n private _pick(\n method: 'pickObject' | 'pickObjects',\n statKey: string,\n opts: (PickByPointOptions | PickByRectOptions) & {layerIds?: string[]}\n ) {\n assert(this.deckPicker);\n\n const {stats} = this;\n\n stats.get('Pick Count').incrementCount();\n stats.get(statKey).timeStart();\n\n const infos = this.deckPicker[method]({\n // layerManager, viewManager and effectManager are always defined if deckPicker is\n layers: this.layerManager!.getLayers(opts),\n views: this.viewManager!.getViews(),\n viewports: this.getViewports(opts),\n onViewportActive: this.layerManager!.activateViewport,\n effects: this.effectManager!.getEffects(),\n ...opts\n });\n\n stats.get(statKey).timeEnd();\n\n return infos;\n }\n\n /** Resolve props.canvas to element */\n private _createCanvas(props: DeckProps): HTMLCanvasElement {\n let canvas = props.canvas;\n\n // TODO EventManager should accept element id\n if (typeof canvas === 'string') {\n canvas = document.getElementById(canvas) as HTMLCanvasElement;\n assert(canvas);\n }\n\n if (!canvas) {\n canvas = document.createElement('canvas');\n canvas.id = props.id || 'deckgl-overlay';\n const parent = props.parent || document.body;\n parent.appendChild(canvas);\n }\n\n Object.assign(canvas.style, props.style);\n\n return canvas;\n }\n\n /** Updates canvas width and/or height, if provided as props */\n private _setCanvasSize(props: Required>): void {\n if (!this.canvas) {\n return;\n }\n\n const {width, height} = props;\n // Set size ONLY if props are being provided, otherwise let canvas be layouted freely\n if (width || width === 0) {\n const cssWidth = Number.isFinite(width) ? `${width}px` : (width as string);\n this.canvas.style.width = cssWidth;\n }\n if (height || height === 0) {\n const cssHeight = Number.isFinite(height) ? `${height}px` : (height as string);\n // Note: position==='absolute' required for height 100% to work\n this.canvas.style.position = props.style?.position || 'absolute';\n this.canvas.style.height = cssHeight;\n }\n }\n\n /** If canvas size has changed, reads out the new size and update */\n private _updateCanvasSize(): void {\n const {canvas} = this;\n if (!canvas) {\n return;\n }\n // Fallback to width/height when clientWidth/clientHeight are undefined (OffscreenCanvas).\n const newWidth = canvas.clientWidth ?? canvas.width;\n const newHeight = canvas.clientHeight ?? canvas.height;\n if (newWidth !== this.width || newHeight !== this.height) {\n // @ts-expect-error private assign to read-only property\n this.width = newWidth;\n // @ts-expect-error private assign to read-only property\n this.height = newHeight;\n this.viewManager?.setProps({width: newWidth, height: newHeight});\n // Make sure that any new layer gets initialized with the current viewport\n this.layerManager?.activateViewport(this.getViewports()[0]);\n this.props.onResize({width: newWidth, height: newHeight});\n }\n }\n\n private _createAnimationLoop(\n deviceOrPromise: Device | Promise,\n props: DeckProps\n ): AnimationLoop {\n const {\n // width,\n // height,\n gl,\n // debug,\n onError,\n // onBeforeRender,\n // onAfterRender,\n useDevicePixels\n } = props;\n\n return new AnimationLoop({\n device: deviceOrPromise,\n useDevicePixels,\n // TODO v9\n autoResizeDrawingBuffer: !gl, // do not auto resize external context\n autoResizeViewport: false,\n // @ts-expect-error luma.gl needs to accept Promise return value\n onInitialize: context => this._setDevice(context.device),\n\n onRender: this._onRenderFrame.bind(this),\n // @ts-expect-error typing mismatch: AnimationLoop does not accept onError:null\n onError\n\n // onBeforeRender,\n // onAfterRender,\n });\n }\n\n // Get the most relevant view state: props.viewState, if supplied, shadows internal viewState\n // TODO: For backwards compatibility ensure numeric width and height is added to the viewState\n private _getViewState(): ViewStateObject | null {\n return this.props.viewState || this.viewState;\n }\n\n // Get the view descriptor list\n private _getViews(): View[] {\n const {views} = this.props;\n const normalizedViews: View[] = Array.isArray(views)\n ? views\n : // If null, default to a full screen map view port\n views\n ? [views]\n : [new MapView({id: 'default-view'})];\n if (normalizedViews.length && this.props.controller) {\n // Backward compatibility: support controller prop\n normalizedViews[0].props.controller = this.props.controller;\n }\n return normalizedViews;\n }\n\n private _onContextLost() {\n const {onError} = this.props;\n if (this.animationLoop && onError) {\n onError(new Error('WebGL context is lost'));\n }\n }\n\n // The `pointermove` event may fire multiple times in between two animation frames,\n // it's a waste of time to run picking without rerender. Instead we save the last pick\n // request and only do it once on the next animation frame.\n /** Internal use only: event handler for pointerdown */\n _onPointerMove = (event: MjolnirPointerEvent) => {\n const {_pickRequest} = this;\n if (event.type === 'pointerleave') {\n _pickRequest.x = -1;\n _pickRequest.y = -1;\n _pickRequest.radius = 0;\n } else if (event.leftButton || event.rightButton) {\n // Do not trigger onHover callbacks if mouse button is down.\n return;\n } else {\n const pos = event.offsetCenter;\n // Do not trigger callbacks when click/hover position is invalid. Doing so will cause a\n // assertion error when attempting to unproject the position.\n if (!pos) {\n return;\n }\n _pickRequest.x = pos.x;\n _pickRequest.y = pos.y;\n _pickRequest.radius = this.props.pickingRadius;\n }\n\n if (this.layerManager) {\n this.layerManager.context.mousePosition = {x: _pickRequest.x, y: _pickRequest.y};\n }\n\n _pickRequest.event = event;\n };\n\n /** Actually run picking */\n private _pickAndCallback() {\n const {_pickRequest} = this;\n\n if (_pickRequest.event) {\n // Perform picking\n const {result, emptyInfo} = this._pick('pickObject', 'pickObject Time', _pickRequest);\n this.cursorState.isHovering = result.length > 0;\n\n // There are 4 possible scenarios:\n // result is [outInfo, pickedInfo] (moved from one pickable layer to another)\n // result is [outInfo] (moved outside of a pickable layer)\n // result is [pickedInfo] (moved into or over a pickable layer)\n // result is [] (nothing is or was picked)\n //\n // `layer.props.onHover` should be called on all affected layers (out/over)\n // `deck.props.onHover` should be called with the picked info if any, or empty info otherwise\n // `deck.props.getTooltip` should be called with the picked info if any, or empty info otherwise\n\n // Execute callbacks\n let pickedInfo = emptyInfo;\n let handled = false;\n for (const info of result) {\n pickedInfo = info;\n handled = info.layer?.onHover(info, _pickRequest.event) || handled;\n }\n if (!handled) {\n this.props.onHover?.(pickedInfo, _pickRequest.event);\n this.widgetManager!.onHover(pickedInfo, _pickRequest.event);\n }\n\n // Clear pending pickRequest\n _pickRequest.event = null;\n }\n }\n\n private _updateCursor(): void {\n const container = this.props.parent || this.canvas;\n if (container) {\n container.style.cursor = this.props.getCursor(this.cursorState);\n }\n }\n\n private _setDevice(device: Device) {\n this.device = device;\n\n if (!this.animationLoop) {\n // finalize() has been called\n return;\n }\n\n // if external context...\n if (!this.canvas) {\n this.canvas = this.device.canvasContext?.canvas as HTMLCanvasElement;\n // TODO v9\n // ts-expect-error - Currently luma.gl v9 does not expose these options\n // All WebGLDevice contexts are instrumented, but it seems the device\n // should have a method to start state tracking even if not enabled?\n // instrumentGLContext(this.device.gl, {enable: true, copyState: true});\n }\n\n if (this.device instanceof WebGLDevice) {\n this.device.setParametersWebGL({\n blend: true,\n blendFunc: [GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA, GL.ONE, GL.ONE_MINUS_SRC_ALPHA],\n polygonOffsetFill: true,\n depthTest: true,\n depthFunc: GL.LEQUAL\n });\n }\n\n this.props.onDeviceInitialized(this.device);\n if (this.device instanceof WebGLDevice) {\n // Legacy callback - warn?\n this.props.onWebGLInitialized(this.device.gl);\n }\n\n // timeline for transitions\n const timeline = new Timeline();\n timeline.play();\n this.animationLoop.attachTimeline(timeline);\n\n this.eventManager = new EventManager(this.props.parent || this.canvas, {\n touchAction: this.props.touchAction,\n recognizers: Object.keys(RECOGNIZERS).map((eventName: string) => {\n // Resolve recognizer settings\n const [RecognizerConstructor, defaultOptions, recognizeWith, requestFailure] =\n RECOGNIZERS[eventName];\n const optionsOverride = this.props.eventRecognizerOptions?.[eventName];\n const options = {...defaultOptions, ...optionsOverride, event: eventName};\n return {\n recognizer: new RecognizerConstructor(options),\n recognizeWith,\n requestFailure\n };\n }),\n events: {\n pointerdown: this._onPointerDown,\n pointermove: this._onPointerMove,\n pointerleave: this._onPointerMove\n }\n });\n for (const eventType in EVENT_HANDLERS) {\n this.eventManager.on(eventType, this._onEvent);\n }\n\n this.viewManager = new ViewManager({\n timeline,\n eventManager: this.eventManager,\n onViewStateChange: this._onViewStateChange.bind(this),\n onInteractionStateChange: this._onInteractionStateChange.bind(this),\n views: this._getViews(),\n viewState: this._getViewState(),\n width: this.width,\n height: this.height\n });\n\n // viewManager must be initialized before layerManager\n // layerManager depends on viewport created by viewManager.\n const viewport = this.viewManager.getViewports()[0];\n\n // Note: avoid React setState due GL animation loop / setState timing issue\n this.layerManager = new LayerManager(this.device, {\n deck: this,\n stats: this.stats,\n viewport,\n timeline\n });\n\n this.effectManager = new EffectManager({\n deck: this,\n device: this.device\n });\n\n this.deckRenderer = new DeckRenderer(this.device);\n\n this.deckPicker = new DeckPicker(this.device);\n\n this.widgetManager = new WidgetManager({\n deck: this,\n parentElement: this.canvas?.parentElement\n });\n this.widgetManager.addDefault(new Tooltip());\n\n this.setProps(this.props);\n\n this._updateCanvasSize();\n this.props.onLoad();\n }\n\n /** Internal only: default render function (redraw all layers and views) */\n _drawLayers(\n redrawReason: string,\n renderOptions?: {\n target?: Framebuffer;\n layerFilter?: (context: FilterContext) => boolean;\n layers?: Layer[];\n viewports?: Viewport[];\n views?: {[viewId: string]: View};\n pass?: string;\n effects?: Effect[];\n clearStack?: boolean;\n clearCanvas?: boolean;\n }\n ) {\n const {device, gl} = this.layerManager!.context;\n\n this.props.onBeforeRender({device, gl});\n\n const opts = {\n target: this.props._framebuffer,\n layers: this.layerManager!.getLayers(),\n viewports: this.viewManager!.getViewports(),\n onViewportActive: this.layerManager!.activateViewport,\n views: this.viewManager!.getViews(),\n pass: 'screen',\n effects: this.effectManager!.getEffects(),\n ...renderOptions\n };\n this.deckRenderer?.renderLayers(opts);\n\n if (opts.pass === 'screen') {\n // This method could be called when drawing to picking buffer, texture etc.\n // Only when drawing to screen, update all widgets (UI components)\n this.widgetManager!.onRedraw({\n viewports: opts.viewports,\n layers: opts.layers\n });\n }\n\n this.props.onAfterRender({device, gl});\n }\n\n // Callbacks\n\n private _onRenderFrame() {\n this._getFrameStats();\n\n // Log perf stats every second\n if (this._metricsCounter++ % 60 === 0) {\n this._getMetrics();\n this.stats.reset();\n log.table(4, this.metrics)();\n\n // Experimental: report metrics\n if (this.props._onMetrics) {\n this.props._onMetrics(this.metrics);\n }\n }\n\n this._updateCanvasSize();\n\n this._updateCursor();\n\n // Update layers if needed (e.g. some async prop has loaded)\n // Note: This can trigger a redraw\n this.layerManager!.updateLayers();\n\n // Perform picking request if any\n this._pickAndCallback();\n\n // Redraw if necessary\n this.redraw();\n\n // Update viewport transition if needed\n // Note: this can trigger `onViewStateChange`, and affect layers\n // We want to defer these changes to the next frame\n if (this.viewManager) {\n this.viewManager.updateViewStates();\n }\n }\n\n // Callbacks\n\n private _onViewStateChange(params: ViewStateChangeParameters & {viewId: string}) {\n // Let app know that view state is changing, and give it a chance to change it\n const viewState = this.props.onViewStateChange(params) || params.viewState;\n\n // If initialViewState was set on creation, auto track position\n if (this.viewState) {\n this.viewState = {...this.viewState, [params.viewId]: viewState};\n if (!this.props.viewState) {\n // Apply internal view state\n if (this.viewManager) {\n this.viewManager.setProps({viewState: this.viewState});\n }\n }\n }\n }\n\n private _onInteractionStateChange(interactionState: InteractionState) {\n this.cursorState.isDragging = interactionState.isDragging || false;\n this.props.onInteractionStateChange(interactionState);\n }\n\n /** Internal use only: event handler for click & drag */\n _onEvent = (event: MjolnirGestureEvent) => {\n const eventHandlerProp = EVENT_HANDLERS[event.type];\n const pos = event.offsetCenter;\n\n if (!eventHandlerProp || !pos || !this.layerManager) {\n return;\n }\n\n // Reuse last picked object\n const layers = this.layerManager.getLayers();\n const info = this.deckPicker!.getLastPickedObject(\n {\n x: pos.x,\n y: pos.y,\n layers,\n viewports: this.getViewports(pos)\n },\n this._lastPointerDownInfo\n ) as PickingInfo;\n\n const {layer} = info;\n const layerHandler = layer && (layer[eventHandlerProp] || layer.props[eventHandlerProp]);\n const rootHandler = this.props[eventHandlerProp];\n let handled = false;\n\n if (layerHandler) {\n handled = layerHandler.call(layer, info, event);\n }\n if (!handled) {\n rootHandler?.(info, event);\n this.widgetManager!.onEvent(info, event);\n }\n };\n\n /** Internal use only: evnet handler for pointerdown */\n _onPointerDown = (event: MjolnirPointerEvent) => {\n const pos = event.offsetCenter;\n const pickedInfo = this._pick('pickObject', 'pickObject Time', {\n x: pos.x,\n y: pos.y,\n radius: this.props.pickingRadius\n });\n this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;\n };\n\n private _getFrameStats(): void {\n const {stats} = this;\n stats.get('frameRate').timeEnd();\n stats.get('frameRate').timeStart();\n\n // Get individual stats from luma.gl so reset works\n const animationLoopStats = this.animationLoop!.stats;\n stats.get('GPU Time').addTime(animationLoopStats.get('GPU Time').lastTiming);\n stats.get('CPU Time').addTime(animationLoopStats.get('CPU Time').lastTiming);\n }\n\n private _getMetrics(): void {\n const {metrics, stats} = this;\n metrics.fps = stats.get('frameRate').getHz();\n metrics.setPropsTime = stats.get('setProps Time').time;\n metrics.updateAttributesTime = stats.get('Update Attributes').time;\n metrics.framesRedrawn = stats.get('Redraw Count').count;\n metrics.pickTime =\n stats.get('pickObject Time').time +\n stats.get('pickMultipleObjects Time').time +\n stats.get('pickObjects Time').time;\n metrics.pickCount = stats.get('Pick Count').count;\n\n // Luma stats\n metrics.gpuTime = stats.get('GPU Time').time;\n metrics.cpuTime = stats.get('CPU Time').time;\n metrics.gpuTimePerFrame = stats.get('GPU Time').getAverageTime();\n metrics.cpuTimePerFrame = stats.get('CPU Time').getAverageTime();\n\n const memoryStats = luma.stats.get('Memory Usage');\n metrics.bufferMemory = memoryStats.get('Buffer Memory').count;\n metrics.textureMemory = memoryStats.get('Texture Memory').count;\n metrics.renderbufferMemory = memoryStats.get('Renderbuffer Memory').count;\n metrics.gpuMemory = memoryStats.get('GPU Memory').count;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable complexity */\nimport type {Device} from '@luma.gl/core';\nimport {Buffer, BufferLayout, BufferAttributeLayout, VertexType} from '@luma.gl/core';\n\nimport {\n typedArrayFromDataType,\n getBufferAttributeLayout,\n getStride,\n dataTypeFromTypedArray\n} from './gl-utils';\nimport typedArrayManager from '../../utils/typed-array-manager';\nimport {toDoublePrecisionArray} from '../../utils/math-utils';\nimport log from '../../utils/log';\n\nimport type {TypedArray, NumericArray, TypedArrayConstructor} from '../../types/types';\n\nexport type DataType = Exclude;\nexport type LogicalDataType = DataType | 'float64';\n\nexport type BufferAccessor = {\n /** Vertex data type. */\n type?: DataType;\n /** The number of elements per vertex attribute. */\n size?: number;\n /** Offset of the first vertex attribute into the buffer, in bytes. */\n offset?: number;\n /** The offset between the beginning of consecutive vertex attributes, in bytes. */\n stride?: number;\n};\n\nexport type ShaderAttributeOptions = Partial & {\n offset: number;\n stride: number;\n vertexOffset?: number;\n elementOffset?: number;\n};\n\nfunction resolveShaderAttribute(\n baseAccessor: DataColumnSettings,\n shaderAttributeOptions: Partial\n): ShaderAttributeOptions {\n if (shaderAttributeOptions.offset) {\n log.removed('shaderAttribute.offset', 'vertexOffset, elementOffset')();\n }\n\n // All shader attributes share the parent's stride\n const stride = getStride(baseAccessor);\n // `vertexOffset` is used to access the neighboring vertex's value\n // e.g. `nextPositions` in polygon\n const vertexOffset =\n shaderAttributeOptions.vertexOffset !== undefined\n ? shaderAttributeOptions.vertexOffset\n : baseAccessor.vertexOffset || 0;\n // `elementOffset` is defined when shader attribute's size is smaller than the parent's\n // e.g. `translations` in transform matrix\n const elementOffset = shaderAttributeOptions.elementOffset || 0;\n const offset =\n // offsets defined by the attribute\n vertexOffset * stride +\n elementOffset * baseAccessor.bytesPerElement +\n // offsets defined by external buffers if any\n (baseAccessor.offset || 0);\n\n return {\n ...shaderAttributeOptions,\n offset,\n stride\n };\n}\n\nfunction resolveDoublePrecisionShaderAttributes(\n baseAccessor: DataColumnSettings,\n shaderAttributeOptions: Partial\n): {\n high: ShaderAttributeOptions;\n low: ShaderAttributeOptions;\n} {\n const resolvedOptions = resolveShaderAttribute(baseAccessor, shaderAttributeOptions);\n\n return {\n high: resolvedOptions,\n low: {\n ...resolvedOptions,\n offset: resolvedOptions.offset + baseAccessor.size * 4\n }\n };\n}\n\nexport type DataColumnOptions = Options &\n Omit & {\n id?: string;\n vertexOffset?: number;\n fp64?: boolean;\n /** Vertex data type.\n * @default 'float32'\n */\n type?: LogicalDataType;\n /** Internal API, use `type` instead */\n logicalType?: LogicalDataType;\n isIndexed?: boolean;\n defaultValue?: number | number[];\n };\n\nexport type DataColumnSettings = DataColumnOptions & {\n type: DataType;\n size: number;\n logicalType?: LogicalDataType;\n normalized: boolean;\n bytesPerElement: number;\n defaultValue: number[];\n defaultType: TypedArrayConstructor;\n};\n\ntype DataColumnInternalState = State & {\n externalBuffer: Buffer | null;\n bufferAccessor: DataColumnSettings;\n allocatedValue: TypedArray | null;\n numInstances: number;\n bounds: [number[], number[]] | null;\n constant: boolean;\n};\n\nexport default class DataColumn {\n device: Device;\n id: string;\n size: number;\n settings: DataColumnSettings;\n value: NumericArray | null;\n doublePrecision: boolean;\n\n protected _buffer: Buffer | null = null;\n protected state: DataColumnInternalState;\n\n /* eslint-disable max-statements */\n constructor(device: Device, opts: DataColumnOptions, state: State) {\n this.device = device;\n this.id = opts.id || '';\n this.size = opts.size || 1;\n\n const logicalType = opts.logicalType || opts.type;\n const doublePrecision = logicalType === 'float64';\n\n let {defaultValue} = opts;\n defaultValue = Number.isFinite(defaultValue)\n ? [defaultValue]\n : defaultValue || new Array(this.size).fill(0);\n\n let bufferType: DataType;\n if (doublePrecision) {\n bufferType = 'float32';\n } else if (!logicalType && opts.isIndexed) {\n bufferType = 'uint32';\n } else {\n bufferType = logicalType || 'float32';\n }\n\n // This is the attribute type defined by the layer\n // If an external buffer is provided, this.type may be overwritten\n // But we always want to use defaultType for allocation\n let defaultType = typedArrayFromDataType(logicalType || bufferType);\n this.doublePrecision = doublePrecision;\n\n // `fp64: false` tells a double-precision attribute to allocate Float32Arrays\n // by default when using auto-packing. This is more efficient in use cases where\n // high precision is unnecessary, but the `64Low` attribute is still required\n // by the shader.\n if (doublePrecision && opts.fp64 === false) {\n defaultType = Float32Array;\n }\n\n this.value = null;\n this.settings = {\n ...opts,\n defaultType,\n defaultValue: defaultValue as number[],\n logicalType,\n type: bufferType,\n normalized: bufferType.includes('norm'),\n size: this.size,\n bytesPerElement: defaultType.BYTES_PER_ELEMENT\n };\n this.state = {\n ...state,\n externalBuffer: null,\n bufferAccessor: this.settings,\n allocatedValue: null,\n numInstances: 0,\n bounds: null,\n constant: false\n };\n }\n /* eslint-enable max-statements */\n\n get isConstant(): boolean {\n return this.state.constant;\n }\n\n get buffer(): Buffer {\n return this._buffer!;\n }\n\n get byteOffset(): number {\n const accessor = this.getAccessor();\n if (accessor.vertexOffset) {\n return accessor.vertexOffset * getStride(accessor);\n }\n return 0;\n }\n\n get numInstances(): number {\n return this.state.numInstances;\n }\n\n set numInstances(n: number) {\n this.state.numInstances = n;\n }\n\n delete(): void {\n if (this._buffer) {\n this._buffer.delete();\n this._buffer = null;\n }\n typedArrayManager.release(this.state.allocatedValue);\n }\n\n getBuffer(): Buffer | null {\n if (this.state.constant) {\n return null;\n }\n return this.state.externalBuffer || this._buffer;\n }\n\n getValue(\n attributeName: string = this.id,\n options: Partial | null = null\n ): Record {\n const result: Record = {};\n if (this.state.constant) {\n const value = this.value as TypedArray;\n if (options) {\n const shaderAttributeDef = resolveShaderAttribute(this.getAccessor(), options);\n const offset = shaderAttributeDef.offset / value.BYTES_PER_ELEMENT;\n const size = shaderAttributeDef.size || this.size;\n result[attributeName] = value.subarray(offset, offset + size);\n } else {\n result[attributeName] = value;\n }\n } else {\n result[attributeName] = this.getBuffer();\n }\n if (this.doublePrecision) {\n if (this.value instanceof Float64Array) {\n result[`${attributeName}64Low`] = result[attributeName];\n } else {\n // Disable fp64 low part\n result[`${attributeName}64Low`] = new Float32Array(this.size);\n }\n }\n return result;\n }\n\n protected _getBufferLayout(\n attributeName: string = this.id,\n options: Partial | null = null\n ): BufferLayout {\n const accessor = this.getAccessor();\n const attributes: BufferAttributeLayout[] = [];\n const result: BufferLayout = {\n name: this.id,\n byteStride: getStride(accessor),\n attributes\n };\n\n if (this.doublePrecision) {\n const doubleShaderAttributeDefs = resolveDoublePrecisionShaderAttributes(\n accessor,\n options || {}\n );\n attributes.push(\n getBufferAttributeLayout(attributeName, {...accessor, ...doubleShaderAttributeDefs.high}),\n getBufferAttributeLayout(`${attributeName}64Low`, {\n ...accessor,\n ...doubleShaderAttributeDefs.low\n })\n );\n } else if (options) {\n const shaderAttributeDef = resolveShaderAttribute(accessor, options);\n attributes.push(\n getBufferAttributeLayout(attributeName, {...accessor, ...shaderAttributeDef})\n );\n } else {\n attributes.push(getBufferAttributeLayout(attributeName, accessor));\n }\n return result;\n }\n\n setAccessor(accessor: DataColumnSettings) {\n this.state.bufferAccessor = accessor;\n }\n\n getAccessor(): DataColumnSettings {\n return this.state.bufferAccessor;\n }\n\n // Returns [min: Array(size), max: Array(size)]\n /* eslint-disable max-depth */\n getBounds(): [number[], number[]] | null {\n if (this.state.bounds) {\n return this.state.bounds;\n }\n let result: [number[], number[]] | null = null;\n if (this.state.constant && this.value) {\n const min = Array.from(this.value);\n result = [min, min];\n } else {\n const {value, numInstances, size} = this;\n const len = numInstances * size;\n if (value && len && value.length >= len) {\n const min = new Array(size).fill(Infinity);\n const max = new Array(size).fill(-Infinity);\n for (let i = 0; i < len; ) {\n for (let j = 0; j < size; j++) {\n const v = value[i++];\n if (v < min[j]) min[j] = v;\n if (v > max[j]) max[j] = v;\n }\n }\n result = [min, max];\n }\n }\n this.state.bounds = result;\n return result;\n }\n\n // returns true if success\n // eslint-disable-next-line max-statements\n setData(\n data:\n | TypedArray\n | Buffer\n | ({\n constant?: boolean;\n value?: NumericArray;\n buffer?: Buffer;\n /** Set to `true` if supplying float values to a unorm attribute */\n normalized?: boolean;\n } & Partial)\n ): boolean {\n const {state} = this;\n\n let opts: {\n constant?: boolean;\n value?: NumericArray;\n buffer?: Buffer;\n } & Partial;\n if (ArrayBuffer.isView(data)) {\n opts = {value: data};\n } else if (data instanceof Buffer) {\n opts = {buffer: data};\n } else {\n opts = data;\n }\n\n const accessor: DataColumnSettings = {...this.settings, ...opts};\n\n if (ArrayBuffer.isView(opts.value)) {\n if (!opts.type) {\n // Deduce data type\n const is64Bit = this.doublePrecision && opts.value instanceof Float64Array;\n if (is64Bit) {\n accessor.type = 'float32';\n } else {\n const type = dataTypeFromTypedArray(opts.value);\n accessor.type = accessor.normalized ? (type.replace('int', 'norm') as DataType) : type;\n }\n }\n accessor.bytesPerElement = opts.value.BYTES_PER_ELEMENT;\n accessor.stride = getStride(accessor);\n }\n\n state.bounds = null; // clear cached bounds\n\n if (opts.constant) {\n // set constant\n let value = opts.value;\n value = this._normalizeValue(value, [], 0);\n if (this.settings.normalized) {\n value = this.normalizeConstant(value);\n }\n const hasChanged = !state.constant || !this._areValuesEqual(value, this.value);\n\n if (!hasChanged) {\n return false;\n }\n state.externalBuffer = null;\n state.constant = true;\n this.value = ArrayBuffer.isView(value) ? value : new Float32Array(value);\n } else if (opts.buffer) {\n const buffer = opts.buffer;\n state.externalBuffer = buffer;\n state.constant = false;\n this.value = opts.value || null;\n } else if (opts.value) {\n this._checkExternalBuffer(opts);\n\n let value = opts.value as TypedArray;\n state.externalBuffer = null;\n state.constant = false;\n this.value = value;\n\n let {buffer} = this;\n const stride = getStride(accessor);\n const byteOffset = (accessor.vertexOffset || 0) * stride;\n\n if (this.doublePrecision && value instanceof Float64Array) {\n value = toDoublePrecisionArray(value, accessor);\n }\n if (this.settings.isIndexed) {\n const ArrayType = this.settings.defaultType;\n if (value.constructor !== ArrayType) {\n // Cast the index buffer to expected type\n value = new ArrayType(value);\n }\n }\n\n // A small over allocation is used as safety margin\n // Shader attributes may try to access this buffer with bigger offsets\n const requiredBufferSize = value.byteLength + byteOffset + stride * 2;\n if (!buffer || buffer.byteLength < requiredBufferSize) {\n buffer = this._createBuffer(requiredBufferSize);\n }\n\n buffer.write(value, byteOffset);\n }\n\n this.setAccessor(accessor);\n\n return true;\n }\n\n updateSubBuffer(\n opts: {\n startOffset?: number;\n endOffset?: number;\n } = {}\n ): void {\n this.state.bounds = null; // clear cached bounds\n\n const value = this.value as TypedArray;\n const {startOffset = 0, endOffset} = opts;\n this.buffer.write(\n this.doublePrecision && value instanceof Float64Array\n ? toDoublePrecisionArray(value, {\n size: this.size,\n startIndex: startOffset,\n endIndex: endOffset\n })\n : value.subarray(startOffset, endOffset),\n startOffset * value.BYTES_PER_ELEMENT + this.byteOffset\n );\n }\n\n allocate(numInstances: number, copy: boolean = false): boolean {\n const {state} = this;\n const oldValue = state.allocatedValue;\n\n // Allocate at least one element to ensure a valid buffer\n const value = typedArrayManager.allocate(oldValue, numInstances + 1, {\n size: this.size,\n type: this.settings.defaultType,\n copy\n });\n\n this.value = value;\n\n const {byteOffset} = this;\n let {buffer} = this;\n\n if (!buffer || buffer.byteLength < value.byteLength + byteOffset) {\n buffer = this._createBuffer(value.byteLength + byteOffset);\n if (copy && oldValue) {\n // Upload the full existing attribute value to the GPU, so that updateBuffer\n // can choose to only update a partial range.\n // TODO - copy old buffer to new buffer on the GPU\n buffer.write(\n oldValue instanceof Float64Array ? toDoublePrecisionArray(oldValue, this) : oldValue,\n byteOffset\n );\n }\n }\n\n state.allocatedValue = value;\n state.constant = false;\n state.externalBuffer = null;\n this.setAccessor(this.settings);\n return true;\n }\n\n // PRIVATE HELPER METHODS\n protected _checkExternalBuffer(opts: {value?: NumericArray; normalized?: boolean}): void {\n const {value} = opts;\n if (!ArrayBuffer.isView(value)) {\n throw new Error(`Attribute ${this.id} value is not TypedArray`);\n }\n const ArrayType = this.settings.defaultType;\n\n let illegalArrayType = false;\n if (this.doublePrecision) {\n // not 32bit or 64bit\n illegalArrayType = value.BYTES_PER_ELEMENT < 4;\n }\n if (illegalArrayType) {\n throw new Error(`Attribute ${this.id} does not support ${value.constructor.name}`);\n }\n if (!(value instanceof ArrayType) && this.settings.normalized && !('normalized' in opts)) {\n log.warn(`Attribute ${this.id} is normalized`)();\n }\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer\n normalizeConstant(value: NumericArray): NumericArray {\n /* eslint-disable complexity */\n switch (this.settings.type) {\n case 'snorm8':\n // normalize [-128, 127] to [-1, 1]\n return new Float32Array(value).map(x => ((x + 128) / 255) * 2 - 1);\n\n case 'snorm16':\n // normalize [-32768, 32767] to [-1, 1]\n return new Float32Array(value).map(x => ((x + 32768) / 65535) * 2 - 1);\n\n case 'unorm8':\n // normalize [0, 255] to [0, 1]\n return new Float32Array(value).map(x => x / 255);\n\n case 'unorm16':\n // normalize [0, 65535] to [0, 1]\n return new Float32Array(value).map(x => x / 65535);\n\n default:\n // No normalization for gl.FLOAT and gl.HALF_FLOAT\n return value;\n }\n }\n\n /* check user supplied values and apply fallback */\n protected _normalizeValue(value: any, out: NumericArray, start: number): NumericArray {\n const {defaultValue, size} = this.settings;\n\n if (Number.isFinite(value)) {\n out[start] = value;\n return out;\n }\n if (!value) {\n let i = size;\n while (--i >= 0) {\n out[start + i] = defaultValue[i];\n }\n return out;\n }\n\n // Important - switch cases are 5x more performant than a for loop!\n /* eslint-disable no-fallthrough, default-case */\n switch (size) {\n case 4:\n out[start + 3] = Number.isFinite(value[3]) ? value[3] : defaultValue[3];\n case 3:\n out[start + 2] = Number.isFinite(value[2]) ? value[2] : defaultValue[2];\n case 2:\n out[start + 1] = Number.isFinite(value[1]) ? value[1] : defaultValue[1];\n case 1:\n out[start + 0] = Number.isFinite(value[0]) ? value[0] : defaultValue[0];\n break;\n\n default:\n // In the rare case where the attribute size > 4, do it the slow way\n // This is used for e.g. transform matrices\n let i = size;\n while (--i >= 0) {\n out[start + i] = Number.isFinite(value[i]) ? value[i] : defaultValue[i];\n }\n }\n\n return out;\n }\n\n protected _areValuesEqual(value1: any, value2: any): boolean {\n if (!value1 || !value2) {\n return false;\n }\n const {size} = this;\n for (let i = 0; i < size; i++) {\n if (value1[i] !== value2[i]) {\n return false;\n }\n }\n return true;\n }\n\n protected _createBuffer(byteLength: number): Buffer {\n if (this._buffer) {\n this._buffer.destroy();\n }\n\n const {isIndexed, type} = this.settings;\n this._buffer = this.device.createBuffer({\n ...this._buffer?.props,\n id: this.id,\n usage: isIndexed ? Buffer.INDEX : Buffer.VERTEX,\n indexType: isIndexed ? (type as 'uint16' | 'uint32') : undefined,\n byteLength\n });\n\n return this._buffer;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {getTypedArrayFromDataType, getDataTypeFromTypedArray} from '@luma.gl/core';\nimport type {BufferAttributeLayout, VertexFormat} from '@luma.gl/core';\nimport type {TypedArrayConstructor} from '../../types/types';\nimport type {BufferAccessor, DataColumnSettings, LogicalDataType} from './data-column';\n\nexport function typedArrayFromDataType(type: LogicalDataType): TypedArrayConstructor {\n // Sorted in some order of likelihood to reduce amount of comparisons\n switch (type) {\n case 'float64':\n return Float64Array;\n case 'uint8':\n case 'unorm8':\n return Uint8ClampedArray;\n default:\n return getTypedArrayFromDataType(type);\n }\n}\n\nexport const dataTypeFromTypedArray = getDataTypeFromTypedArray;\n\nexport function getBufferAttributeLayout(\n name: string,\n accessor: BufferAccessor\n): BufferAttributeLayout {\n return {\n attribute: name,\n // @ts-expect-error Not all combinations are valid vertex formats; it's up to DataColumn to ensure\n format:\n (accessor.size as number) > 1\n ? (`${accessor.type}x${accessor.size}` as VertexFormat)\n : accessor.type,\n byteOffset: accessor.offset || 0\n // Note stride is set on the top level\n };\n}\n\nexport function getStride(accessor: DataColumnSettings): number {\n return accessor.stride || accessor.size * accessor.bytesPerElement;\n}\n\nexport function bufferLayoutEqual(\n accessor1: DataColumnSettings,\n accessor2: DataColumnSettings\n) {\n return (\n accessor1.type === accessor2.type &&\n accessor1.size === accessor2.size &&\n getStride(accessor1) === getStride(accessor2) &&\n (accessor1.offset || 0) === (accessor2.offset || 0)\n );\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {NumericArray} from '../types/types';\nimport type {AccessorFunction} from '../types/layer-props';\n\nconst EMPTY_ARRAY = [];\nconst placeholderArray = [];\n\n/*\n * Create an Iterable\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\n * and a \"context\" tracker from the given data\n */\nexport function createIterable(\n data,\n startRow = 0,\n endRow = Infinity\n): {\n iterable: Iterable;\n objectInfo: {\n index: number;\n data: any;\n target: any[];\n };\n} {\n let iterable: Iterable = EMPTY_ARRAY;\n\n const objectInfo = {\n index: -1,\n data,\n // visitor can optionally utilize this to avoid constructing a new array for every object\n target: []\n };\n\n if (!data) {\n iterable = EMPTY_ARRAY;\n } else if (typeof data[Symbol.iterator] === 'function') {\n // data is already an iterable\n iterable = data;\n } else if (data.length > 0) {\n placeholderArray.length = data.length;\n iterable = placeholderArray;\n }\n\n if (startRow > 0 || Number.isFinite(endRow)) {\n iterable = (Array.isArray(iterable) ? iterable : Array.from(iterable)).slice(startRow, endRow);\n objectInfo.index = startRow - 1;\n }\n\n return {iterable, objectInfo};\n}\n\n/*\n * Returns true if data is an async iterable object\n */\nexport function isAsyncIterable(data): boolean {\n return data && data[Symbol.asyncIterator];\n}\n\n/*\n * Create an accessor function from a flat buffer that yields the value at each object index\n */\nexport function getAccessorFromBuffer(\n typedArray,\n options: {\n size: number;\n stride?: number;\n offset?: number;\n startIndices?: NumericArray;\n nested?: boolean;\n }\n): AccessorFunction {\n const {size, stride, offset, startIndices, nested} = options;\n const bytesPerElement = typedArray.BYTES_PER_ELEMENT;\n const elementStride = stride ? stride / bytesPerElement : size;\n const elementOffset = offset ? offset / bytesPerElement : 0;\n const vertexCount = Math.floor((typedArray.length - elementOffset) / elementStride);\n\n return (_, {index, target}) => {\n if (!startIndices) {\n const sourceIndex = index * elementStride + elementOffset;\n for (let j = 0; j < size; j++) {\n target[j] = typedArray[sourceIndex + j];\n }\n return target;\n }\n const startIndex = startIndices[index];\n const endIndex = startIndices[index + 1] || vertexCount;\n let result;\n\n if (nested) {\n result = new Array(endIndex - startIndex);\n for (let i = startIndex; i < endIndex; i++) {\n const sourceIndex = i * elementStride + elementOffset;\n target = new Array(size);\n for (let j = 0; j < size; j++) {\n target[j] = typedArray[sourceIndex + j];\n }\n result[i - startIndex] = target;\n }\n } else if (elementStride === size) {\n result = typedArray.subarray(\n startIndex * size + elementOffset,\n endIndex * size + elementOffset\n );\n } else {\n result = new typedArray.constructor((endIndex - startIndex) * size);\n let targetIndex = 0;\n for (let i = startIndex; i < endIndex; i++) {\n const sourceIndex = i * elementStride + elementOffset;\n for (let j = 0; j < size; j++) {\n result[targetIndex++] = typedArray[sourceIndex + j];\n }\n }\n }\n\n return result;\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/*\n * range (Array)\n * + start (Number) - the start index (incl.)\n * + end (Number) - the end index (excl.)\n * rangeList (Array) - array of sorted, combined ranges\n */\nexport const EMPTY = [];\nexport const FULL = [[0, Infinity]];\n\n// Insert a range into a range collection\nexport function add(rangeList, range) {\n // Noop if range collection already covers all\n if (rangeList === FULL) {\n return rangeList;\n }\n\n // Validate the input range\n if (range[0] < 0) {\n range[0] = 0;\n }\n if (range[0] >= range[1]) {\n return rangeList;\n }\n\n // TODO - split off to tree-shakable Range class\n const newRangeList: number[] = [];\n const len = rangeList.length;\n let insertPosition = 0;\n\n for (let i = 0; i < len; i++) {\n const range0 = rangeList[i];\n\n if (range0[1] < range[0]) {\n // the current range is to the left of the new range\n newRangeList.push(range0);\n insertPosition = i + 1;\n } else if (range0[0] > range[1]) {\n // the current range is to the right of the new range\n newRangeList.push(range0);\n } else {\n range = [Math.min(range0[0], range[0]), Math.max(range0[1], range[1])];\n }\n }\n newRangeList.splice(insertPosition, 0, range);\n return newRangeList;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {NumericArray} from '../../types/types';\n\nexport interface TransitionSettings {\n type: string;\n /** Callback to get the value that the entering vertices are transitioning from. */\n enter?: (toValue: NumericArray, chunk?: NumericArray) => NumericArray;\n /** Callback when the transition is started */\n onStart?: () => void;\n /** Callback when the transition is done */\n onEnd?: () => void;\n /** Callback when the transition is interrupted */\n onInterrupt?: () => void;\n}\n\nexport type InterpolationTransitionSettings = TransitionSettings & {\n type?: 'interpolation';\n /** Duration of the transition animation, in milliseconds */\n duration: number;\n /** Easing function that maps a value from [0, 1] to [0, 1], see [http://easings.net/](http://easings.net/) */\n easing?: (t: number) => number;\n};\n\nexport type SpringTransitionSettings = TransitionSettings & {\n type: 'spring';\n /** \"Tension\" factor for the spring */\n stiffness: number;\n /** \"Friction\" factor that counteracts the spring's acceleration */\n damping: number;\n};\n\nconst DEFAULT_TRANSITION_SETTINGS = {\n interpolation: {\n duration: 0,\n easing: t => t\n },\n spring: {\n stiffness: 0.05,\n damping: 0.5\n }\n};\n\nexport function normalizeTransitionSettings(\n userSettings: number | InterpolationTransitionSettings | SpringTransitionSettings,\n layerSettings?: boolean | Partial\n): TransitionSettings | null {\n if (!userSettings) {\n return null;\n }\n if (Number.isFinite(userSettings)) {\n userSettings = {type: 'interpolation', duration: userSettings as number};\n }\n const type = (userSettings as TransitionSettings).type || 'interpolation';\n return {\n ...DEFAULT_TRANSITION_SETTINGS[type],\n ...(layerSettings as TransitionSettings),\n ...(userSettings as TransitionSettings),\n type\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable complexity */\nimport DataColumn, {\n DataColumnOptions,\n ShaderAttributeOptions,\n BufferAccessor,\n DataColumnSettings\n} from './data-column';\nimport assert from '../../utils/assert';\nimport {createIterable, getAccessorFromBuffer} from '../../utils/iterable-utils';\nimport {fillArray} from '../../utils/flatten';\nimport * as range from '../../utils/range';\nimport {bufferLayoutEqual} from './gl-utils';\nimport {normalizeTransitionSettings, TransitionSettings} from './transition-settings';\nimport type {Device, Buffer, BufferLayout} from '@luma.gl/core';\n\nimport type {NumericArray, TypedArray} from '../../types/types';\n\nexport type Accessor = (\n object: DataType,\n context: {\n data: any;\n index: number;\n target: number[];\n }\n) => ReturnType;\n\nexport type Updater = (\n attribute: Attribute,\n {\n data,\n startRow,\n endRow,\n props,\n numInstances\n }: {\n data: any;\n startRow: number;\n endRow: number;\n props: any;\n numInstances: number;\n }\n) => void;\n\nexport type AttributeOptions = DataColumnOptions<{\n transition?: boolean | Partial;\n stepMode?: 'vertex' | 'instance' | 'dynamic';\n noAlloc?: boolean;\n update?: Updater;\n accessor?: Accessor | string | string[];\n transform?: (value: any) => any;\n shaderAttributes?: Record>;\n}>;\n\nexport type BinaryAttribute = Partial & {value?: TypedArray; buffer?: Buffer};\n\ntype AttributeInternalState = {\n startIndices: NumericArray | null;\n /** Legacy: external binary supplied via attribute name */\n lastExternalBuffer: TypedArray | Buffer | BinaryAttribute | null;\n /** External binary supplied via accessor name */\n binaryValue: TypedArray | Buffer | BinaryAttribute | null;\n binaryAccessor: Accessor | null;\n needsUpdate: string | boolean;\n needsRedraw: string | boolean;\n layoutChanged: boolean;\n updateRanges: number[][];\n};\n\nexport default class Attribute extends DataColumn {\n /** Legacy approach to set attribute value - read `isConstant` instead for attribute state */\n constant: boolean = false;\n\n constructor(device: Device, opts: AttributeOptions) {\n super(device, opts, {\n startIndices: null,\n lastExternalBuffer: null,\n binaryValue: null,\n binaryAccessor: null,\n needsUpdate: true,\n needsRedraw: false,\n layoutChanged: false,\n updateRanges: range.FULL\n });\n\n // eslint-disable-next-line\n this.settings.update = opts.update || (opts.accessor ? this._autoUpdater : undefined);\n\n Object.seal(this.settings);\n Object.seal(this.state);\n\n // Check all fields and generate helpful error messages\n this._validateAttributeUpdaters();\n }\n\n get startIndices(): NumericArray | null {\n return this.state.startIndices;\n }\n\n set startIndices(layout: NumericArray | null) {\n this.state.startIndices = layout;\n }\n\n needsUpdate(): string | boolean {\n return this.state.needsUpdate;\n }\n\n needsRedraw({clearChangedFlags = false}: {clearChangedFlags?: boolean} = {}): string | boolean {\n const needsRedraw = this.state.needsRedraw;\n this.state.needsRedraw = needsRedraw && !clearChangedFlags;\n return needsRedraw;\n }\n\n layoutChanged(): boolean {\n return this.state.layoutChanged;\n }\n\n setAccessor(accessor: DataColumnSettings) {\n this.state.layoutChanged ||= !bufferLayoutEqual(accessor, this.getAccessor());\n super.setAccessor(accessor);\n }\n\n getUpdateTriggers(): string[] {\n const {accessor} = this.settings;\n\n // Backards compatibility: allow attribute name to be used as update trigger key\n return [this.id].concat((typeof accessor !== 'function' && accessor) || []);\n }\n\n supportsTransition(): boolean {\n return Boolean(this.settings.transition);\n }\n\n // Resolve transition settings object if transition is enabled, otherwise `null`\n getTransitionSetting(opts: Record): TransitionSettings | null {\n if (!opts || !this.supportsTransition()) {\n return null;\n }\n const {accessor} = this.settings;\n // TODO: have the layer resolve these transition settings itself?\n const layerSettings = this.settings.transition;\n // these are the transition settings passed in by the user\n const userSettings = Array.isArray(accessor)\n ? // @ts-ignore\n opts[accessor.find(a => opts[a])]\n : // @ts-ignore\n opts[accessor];\n\n // Shorthand: use duration instead of parameter object\n return normalizeTransitionSettings(userSettings, layerSettings);\n }\n\n setNeedsUpdate(reason: string = this.id, dataRange?: {startRow?: number; endRow?: number}): void {\n this.state.needsUpdate = this.state.needsUpdate || reason;\n this.setNeedsRedraw(reason);\n if (dataRange) {\n const {startRow = 0, endRow = Infinity} = dataRange;\n this.state.updateRanges = range.add(this.state.updateRanges, [startRow, endRow]);\n } else {\n this.state.updateRanges = range.FULL;\n }\n }\n\n clearNeedsUpdate(): void {\n this.state.needsUpdate = false;\n this.state.updateRanges = range.EMPTY;\n }\n\n setNeedsRedraw(reason: string = this.id): void {\n this.state.needsRedraw = this.state.needsRedraw || reason;\n }\n\n allocate(numInstances: number): boolean {\n const {state, settings} = this;\n\n if (settings.noAlloc) {\n // Data is provided through a Buffer object.\n return false;\n }\n\n if (settings.update) {\n super.allocate(numInstances, state.updateRanges !== range.FULL);\n return true;\n }\n\n return false;\n }\n\n updateBuffer({\n numInstances,\n data,\n props,\n context\n }: {\n numInstances: number;\n data: any;\n props: any;\n context: any;\n }): boolean {\n if (!this.needsUpdate()) {\n return false;\n }\n\n const {\n state: {updateRanges},\n settings: {update, noAlloc}\n } = this;\n\n let updated = true;\n if (update) {\n // Custom updater - typically for non-instanced layers\n for (const [startRow, endRow] of updateRanges) {\n update.call(context, this, {data, startRow, endRow, props, numInstances});\n }\n if (!this.value) {\n // no value was assigned during update\n } else if (\n this.constant ||\n !this.buffer ||\n this.buffer.byteLength < (this.value as TypedArray).byteLength + this.byteOffset\n ) {\n this.setData({\n value: this.value,\n constant: this.constant\n });\n // Setting attribute.constant in updater is a legacy approach that interferes with allocation in the next cycle\n // Respect it here but reset after use\n this.constant = false;\n } else {\n for (const [startRow, endRow] of updateRanges) {\n const startOffset = Number.isFinite(startRow) ? this.getVertexOffset(startRow) : 0;\n const endOffset = Number.isFinite(endRow)\n ? this.getVertexOffset(endRow)\n : noAlloc || !Number.isFinite(numInstances)\n ? this.value.length\n : numInstances * this.size;\n\n super.updateSubBuffer({startOffset, endOffset});\n }\n }\n this._checkAttributeArray();\n } else {\n updated = false;\n }\n\n this.clearNeedsUpdate();\n this.setNeedsRedraw();\n\n return updated;\n }\n\n // Use generic value\n // Returns true if successful\n setConstantValue(value?: NumericArray): boolean {\n if (value === undefined || typeof value === 'function') {\n return false;\n }\n\n const hasChanged = this.setData({constant: true, value});\n\n if (hasChanged) {\n this.setNeedsRedraw();\n }\n this.clearNeedsUpdate();\n return true;\n }\n\n // Use external buffer\n // Returns true if successful\n // eslint-disable-next-line max-statements\n setExternalBuffer(buffer?: TypedArray | Buffer | BinaryAttribute): boolean {\n const {state} = this;\n\n if (!buffer) {\n state.lastExternalBuffer = null;\n return false;\n }\n\n this.clearNeedsUpdate();\n\n if (state.lastExternalBuffer === buffer) {\n return true;\n }\n state.lastExternalBuffer = buffer;\n this.setNeedsRedraw();\n this.setData(buffer);\n return true;\n }\n\n // Binary value is a typed array packed from mapping the source data with the accessor\n // If the returned value from the accessor is the same as the attribute value, set it directly\n // Otherwise use the auto updater for transform/normalization\n setBinaryValue(\n buffer?: TypedArray | Buffer | BinaryAttribute,\n startIndices: NumericArray | null = null\n ): boolean {\n const {state, settings} = this;\n\n if (!buffer) {\n state.binaryValue = null;\n state.binaryAccessor = null;\n return false;\n }\n\n if (settings.noAlloc) {\n // Let the layer handle this\n return false;\n }\n\n if (state.binaryValue === buffer) {\n this.clearNeedsUpdate();\n return true;\n }\n state.binaryValue = buffer;\n this.setNeedsRedraw();\n\n const needsUpdate = settings.transform || startIndices !== this.startIndices;\n\n if (needsUpdate) {\n if (ArrayBuffer.isView(buffer)) {\n buffer = {value: buffer};\n }\n const binaryValue = buffer as BinaryAttribute;\n assert(ArrayBuffer.isView(binaryValue.value), `invalid ${settings.accessor}`);\n const needsNormalize = Boolean(binaryValue.size) && binaryValue.size !== this.size;\n\n state.binaryAccessor = getAccessorFromBuffer(binaryValue.value, {\n size: binaryValue.size || this.size,\n stride: binaryValue.stride,\n offset: binaryValue.offset,\n startIndices: startIndices as NumericArray,\n nested: needsNormalize\n });\n // Fall through to auto updater\n return false;\n }\n\n this.clearNeedsUpdate();\n this.setData(buffer);\n return true;\n }\n\n getVertexOffset(row: number): number {\n const {startIndices} = this;\n const vertexIndex = startIndices\n ? row < startIndices.length\n ? startIndices[row]\n : this.numInstances\n : row;\n return vertexIndex * this.size;\n }\n\n getValue(): Record {\n const shaderAttributeDefs = this.settings.shaderAttributes;\n const result = super.getValue();\n if (!shaderAttributeDefs) {\n return result;\n }\n for (const shaderAttributeName in shaderAttributeDefs) {\n Object.assign(\n result,\n super.getValue(shaderAttributeName, shaderAttributeDefs[shaderAttributeName])\n );\n }\n return result;\n }\n\n /** Generate WebGPU-style buffer layout descriptor from this attribute */\n getBufferLayout(\n /** A luma.gl Model-shaped object that supplies additional hint to attribute resolution */\n modelInfo?: {isInstanced?: boolean}\n ): BufferLayout {\n // Clear change flag\n this.state.layoutChanged = false;\n\n const shaderAttributeDefs = this.settings.shaderAttributes;\n const result: BufferLayout = super._getBufferLayout();\n const {stepMode} = this.settings;\n if (stepMode === 'dynamic') {\n // If model info is provided, use isInstanced flag to determine step mode\n // If no model info is provided, assume it's an instanced model (most common use case)\n result.stepMode = modelInfo ? (modelInfo.isInstanced ? 'instance' : 'vertex') : 'instance';\n } else {\n result.stepMode = stepMode ?? 'vertex';\n }\n\n if (!shaderAttributeDefs) {\n return result;\n }\n\n for (const shaderAttributeName in shaderAttributeDefs) {\n const map = super._getBufferLayout(\n shaderAttributeName,\n shaderAttributeDefs[shaderAttributeName]\n );\n // @ts-ignore\n result.attributes.push(...map.attributes);\n }\n return result;\n }\n\n /* eslint-disable max-depth, max-statements */\n private _autoUpdater(\n attribute: Attribute,\n {\n data,\n startRow,\n endRow,\n props,\n numInstances\n }: {\n data: any;\n startRow: number;\n endRow: number;\n props: any;\n numInstances: number;\n }\n ): void {\n if (attribute.constant) {\n return;\n }\n const {settings, state, value, size, startIndices} = attribute;\n\n const {accessor, transform} = settings;\n const accessorFunc: Accessor =\n state.binaryAccessor ||\n // @ts-ignore\n (typeof accessor === 'function' ? accessor : props[accessor]);\n\n assert(typeof accessorFunc === 'function', `accessor \"${accessor}\" is not a function`);\n\n let i = attribute.getVertexOffset(startRow);\n const {iterable, objectInfo} = createIterable(data, startRow, endRow);\n for (const object of iterable) {\n objectInfo.index++;\n\n let objectValue = accessorFunc(object, objectInfo);\n if (transform) {\n // transform callbacks could be bound to a particular layer instance.\n // always point `this` to the current layer.\n objectValue = transform.call(this, objectValue);\n }\n\n if (startIndices) {\n const numVertices =\n (objectInfo.index < startIndices.length - 1\n ? startIndices[objectInfo.index + 1]\n : numInstances) - startIndices[objectInfo.index];\n if (objectValue && Array.isArray(objectValue[0])) {\n let startIndex = i;\n for (const item of objectValue) {\n attribute._normalizeValue(item, value as TypedArray, startIndex);\n startIndex += size;\n }\n } else if (objectValue && objectValue.length > size) {\n (value as TypedArray).set(objectValue, i);\n } else {\n attribute._normalizeValue(objectValue, objectInfo.target, 0);\n fillArray({\n target: value,\n source: objectInfo.target,\n start: i,\n count: numVertices\n });\n }\n i += numVertices * size;\n } else {\n attribute._normalizeValue(objectValue, value as TypedArray, i);\n i += size;\n }\n }\n }\n /* eslint-enable max-depth, max-statements */\n\n // Validate deck.gl level fields\n private _validateAttributeUpdaters() {\n const {settings} = this;\n\n // Check that 'update' is a valid function\n const hasUpdater = settings.noAlloc || typeof settings.update === 'function';\n if (!hasUpdater) {\n throw new Error(`Attribute ${this.id} missing update or accessor`);\n }\n }\n\n // check that the first few elements of the attribute are reasonable\n /* eslint-disable no-fallthrough */\n private _checkAttributeArray() {\n const {value} = this;\n const limit = Math.min(4, this.size);\n if (value && value.length >= limit) {\n let valid = true;\n switch (limit) {\n case 4:\n valid = valid && Number.isFinite(value[3]);\n case 3:\n valid = valid && Number.isFinite(value[2]);\n case 2:\n valid = valid && Number.isFinite(value[1]);\n case 1:\n valid = valid && Number.isFinite(value[0]);\n break;\n default:\n valid = false;\n }\n\n if (!valid) {\n throw new Error(`Illegal attribute generated for ${this.id}`);\n }\n }\n }\n /* eslint-enable no-fallthrough */\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device} from '@luma.gl/core';\nimport {Timeline, BufferTransform} from '@luma.gl/engine';\nimport {fp64arithmetic} from '@luma.gl/shadertools';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {GL} from '@luma.gl/constants';\nimport Attribute from '../lib/attribute/attribute';\nimport {\n getAttributeTypeFromSize,\n cycleBuffers,\n padBuffer,\n matchBuffer,\n getFloat32VertexFormat\n} from './gpu-transition-utils';\nimport {GPUTransitionBase} from './gpu-transition';\n\nimport type {InterpolationTransitionSettings} from '../lib/attribute/transition-settings';\nimport type {TypedArray} from '../types/types';\n\nexport default class GPUInterpolationTransition extends GPUTransitionBase {\n type = 'interpolation';\n\n private transform: BufferTransform;\n\n constructor({\n device,\n attribute,\n timeline\n }: {\n device: Device;\n attribute: Attribute;\n timeline: Timeline;\n }) {\n super({device, attribute, timeline});\n this.transform = getTransform(device, attribute);\n }\n\n override start(transitionSettings: InterpolationTransitionSettings, numInstances: number): void {\n const prevLength = this.currentLength;\n const prevStartIndices = this.currentStartIndices;\n\n super.start(transitionSettings, numInstances, transitionSettings.duration);\n\n if (transitionSettings.duration <= 0) {\n this.transition.cancel();\n return;\n }\n\n const {buffers, attribute} = this;\n // Alternate between two buffers when new transitions start.\n // Last destination buffer is used as an attribute (from state),\n // And the other buffer is now the current buffer.\n cycleBuffers(buffers);\n\n buffers[0] = padBuffer({\n device: this.device,\n buffer: buffers[0],\n attribute,\n fromLength: prevLength,\n toLength: this.currentLength,\n fromStartIndices: prevStartIndices,\n getData: transitionSettings.enter\n });\n buffers[1] = matchBuffer({\n device: this.device,\n source: buffers[0],\n target: buffers[1]\n });\n\n this.setBuffer(buffers[1]);\n\n const {transform} = this;\n const model = transform.model;\n let vertexCount = Math.floor(this.currentLength / attribute.size);\n if (useFp64(attribute)) {\n vertexCount /= 2;\n }\n model.setVertexCount(vertexCount);\n if (attribute.isConstant) {\n model.setAttributes({aFrom: buffers[0]});\n model.setConstantAttributes({aTo: attribute.value as TypedArray});\n } else {\n model.setAttributes({\n aFrom: buffers[0],\n aTo: attribute.getBuffer()!\n });\n }\n transform.transformFeedback.setBuffers({vCurrent: buffers[1]});\n }\n\n onUpdate() {\n const {duration, easing} = this.settings!;\n const {time} = this.transition;\n let t = time / duration;\n if (easing) {\n t = easing(t);\n }\n const {model} = this.transform;\n const interpolationProps: InterpolationProps = {time: t};\n model.shaderInputs.setProps({interpolation: interpolationProps});\n\n this.transform.run({discard: true});\n }\n\n override delete() {\n super.delete();\n this.transform.destroy();\n }\n}\n\nconst uniformBlock = `\\\nuniform interpolationUniforms {\n float time;\n} interpolation;\n`;\n\ntype InterpolationProps = {time: number};\n\nconst interpolationUniforms = {\n name: 'interpolation',\n vs: uniformBlock,\n uniformTypes: {\n time: 'f32'\n }\n} as const satisfies ShaderModule;\n\nconst vs = `\\\n#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vCurrent;\n\nvoid main(void) {\n vCurrent = mix(aFrom, aTo, interpolation.time);\n gl_Position = vec4(0.0);\n}\n`;\nconst vs64 = `\\\n#version 300 es\n#define SHADER_NAME interpolation-transition-vertex-shader\n\nin ATTRIBUTE_TYPE aFrom;\nin ATTRIBUTE_TYPE aFrom64Low;\nin ATTRIBUTE_TYPE aTo;\nin ATTRIBUTE_TYPE aTo64Low;\nout ATTRIBUTE_TYPE vCurrent;\nout ATTRIBUTE_TYPE vCurrent64Low;\n\nvec2 mix_fp64(vec2 a, vec2 b, float x) {\n vec2 range = sub_fp64(b, a);\n return sum_fp64(a, mul_fp64(range, vec2(x, 0.0)));\n}\n\nvoid main(void) {\n for (int i=0; i NumericArray;\n /** start index */\n start?: number;\n /** end index */\n end?: number;\n}): void {\n const {source, target, start = 0, size, getData} = options;\n const end = options.end || target.length;\n\n const sourceLength = source.length;\n const targetLength = end - start;\n\n if (sourceLength > targetLength) {\n target.set(source.subarray(0, targetLength), start);\n return;\n }\n\n target.set(source, start);\n\n if (!getData) {\n return;\n }\n\n // source is not large enough to fill target space, call `getData` to get filler data\n let i = sourceLength;\n while (i < targetLength) {\n const datum = getData(i, source);\n for (let j = 0; j < size; j++) {\n target[start + i] = datum[j] || 0;\n i++;\n }\n }\n}\n\n/*\n * The padArray function stretches a source array to the size of a target array.\n The arrays can have internal structures (like the attributes of PathLayer and\n SolidPolygonLayer), defined by the optional sourceStartIndices and targetStartIndices parameters.\n If the target array is larger, the getData callback is used to fill in the blanks.\n */\nexport function padArray({\n source,\n target,\n size,\n getData,\n sourceStartIndices,\n targetStartIndices\n}: {\n /** original data */\n source: TypedArray;\n /** output data */\n target: TypedArray;\n /** length per datum */\n size: number;\n /** callback to get new data when source is short */\n getData: (index: number, context: NumericArray) => NumericArray;\n /** subdivision of the original data in [object0StartIndex, object1StartIndex, ...] */\n sourceStartIndices?: NumericArray | null;\n /** subdivision of the output data in [object0StartIndex, object1StartIndex, ...] */\n targetStartIndices?: NumericArray | null;\n}): TypedArray {\n if (!sourceStartIndices || !targetStartIndices) {\n // Flat arrays\n padArrayChunk({\n source,\n target,\n size,\n getData\n });\n return target;\n }\n\n // Arrays have internal structure\n let sourceIndex = 0;\n let targetIndex = 0;\n const getChunkData = getData && ((i, chunk) => getData(i + targetIndex, chunk));\n\n const n = Math.min(sourceStartIndices.length, targetStartIndices.length);\n\n for (let i = 1; i < n; i++) {\n const nextSourceIndex = sourceStartIndices[i] * size;\n const nextTargetIndex = targetStartIndices[i] * size;\n\n padArrayChunk({\n source: source.subarray(sourceIndex, nextSourceIndex),\n target,\n start: targetIndex,\n end: nextTargetIndex,\n size,\n getData: getChunkData\n });\n\n sourceIndex = nextSourceIndex;\n targetIndex = nextTargetIndex;\n }\n\n if (targetIndex < target.length) {\n padArrayChunk({\n // @ts-ignore\n source: [],\n target,\n start: targetIndex,\n size,\n getData: getChunkData\n });\n }\n\n return target;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Buffer, VertexFormat} from '@luma.gl/core';\nimport {padArray} from '../utils/array-utils';\nimport {NumericArray, TypedArray, TypedArrayConstructor} from '../types/types';\nimport Attribute from '../lib/attribute/attribute';\nimport {GL} from '@luma.gl/constants';\n\n/** Create a new empty attribute with the same settings: type, shader layout etc. */\nexport function cloneAttribute(attribute: Attribute): Attribute {\n // `attribute.settings` is the original options passed when constructing the attribute.\n // This ensures that we set the proper `doublePrecision` flag and shader attributes.\n const {device, settings, value} = attribute;\n const newAttribute = new Attribute(device, settings);\n // Placeholder value - necessary for generating the correct buffer layout\n newAttribute.setData({\n value: value instanceof Float64Array ? new Float64Array(0) : new Float32Array(0),\n normalized: settings.normalized\n });\n return newAttribute;\n}\n\n/** Returns the GLSL attribute type for the given number of float32 components. */\nexport function getAttributeTypeFromSize(size: number): string {\n switch (size) {\n case 1:\n return 'float';\n case 2:\n return 'vec2';\n case 3:\n return 'vec3';\n case 4:\n return 'vec4';\n default:\n throw new Error(`No defined attribute type for size \"${size}\"`);\n }\n}\n\n/** Returns the {@link VertexFormat} for the given number of float32 components. */\nexport function getFloat32VertexFormat(size: number): VertexFormat {\n switch (size) {\n case 1:\n return 'float32';\n case 2:\n return 'float32x2';\n case 3:\n return 'float32x3';\n case 4:\n return 'float32x4';\n default:\n throw new Error('invalid type size');\n }\n}\n\nexport function cycleBuffers(buffers: Buffer[]): void {\n buffers.push(buffers.shift() as Buffer);\n}\n\nexport function getAttributeBufferLength(attribute: Attribute, numInstances: number): number {\n const {doublePrecision, settings, value, size} = attribute;\n const multiplier = doublePrecision && value instanceof Float64Array ? 2 : 1;\n let maxVertexOffset = 0;\n const {shaderAttributes} = attribute.settings;\n if (shaderAttributes) {\n for (const shaderAttribute of Object.values(shaderAttributes)) {\n maxVertexOffset = Math.max(maxVertexOffset, shaderAttribute.vertexOffset ?? 0);\n }\n }\n return (\n (settings.noAlloc ? (value as NumericArray).length : (numInstances + maxVertexOffset) * size) *\n multiplier\n );\n}\n\nexport function matchBuffer({\n device,\n source,\n target\n}: {\n device: Device;\n source: Buffer;\n target?: Buffer;\n}): Buffer {\n if (!target || target.byteLength < source.byteLength) {\n target?.destroy();\n target = device.createBuffer({\n byteLength: source.byteLength,\n usage: source.usage\n });\n }\n return target;\n}\n\n/* eslint-disable complexity */\n// This helper is used when transitioning attributes from a set of values in one buffer layout\n// to a set of values in a different buffer layout. (Buffer layouts are used when attribute values\n// within a buffer should be grouped for drawElements, like the Polygon layer.) For example, a\n// buffer layout of [3, 4] might have data [A1, A2, A3, B1, B2, B3, B4]. If it needs to transition\n// to a buffer layout of [4, 2], it should produce a buffer, using the transition setting's `enter`\n// function, that looks like this: [A1, A2, A3, A4 (user `enter` fn), B1, B2, 0]. Note: the final\n// 0 in this buffer is because we never shrink buffers, only grow them, for performance reasons.\n//\n// padBuffer may return either the original buffer, or a new buffer if the size of the original\n// was insufficient. Callers are responsible for disposing of the original buffer if needed.\nexport function padBuffer({\n device,\n buffer,\n attribute,\n fromLength,\n toLength,\n fromStartIndices,\n getData = x => x\n}: {\n device: Device;\n buffer?: Buffer;\n attribute: Attribute;\n fromLength: number;\n toLength: number;\n fromStartIndices?: NumericArray | null;\n getData?: (toValue: NumericArray, chunk?: NumericArray) => NumericArray;\n}): Buffer {\n // TODO: move the precisionMultiplier logic to the attribute when retrieving\n // its `size` and `elementOffset`?\n const precisionMultiplier =\n attribute.doublePrecision && attribute.value instanceof Float64Array ? 2 : 1;\n const size = attribute.size * precisionMultiplier;\n const byteOffset = attribute.byteOffset;\n // Transform feedback can only write to float varyings\n // Attributes of format unorm8/uint8 (1 byte per element) etc will be padded to float32 (4 bytes per element)\n const targetByteOffset =\n attribute.settings.bytesPerElement < 4\n ? (byteOffset / attribute.settings.bytesPerElement) * 4\n : byteOffset;\n const toStartIndices = attribute.startIndices;\n const hasStartIndices = fromStartIndices && toStartIndices;\n const isConstant = attribute.isConstant;\n\n // check if buffer needs to be padded\n if (!hasStartIndices && buffer && fromLength >= toLength) {\n return buffer;\n }\n\n const ArrayType =\n attribute.value instanceof Float64Array\n ? Float32Array\n : ((attribute.value as TypedArray).constructor as TypedArrayConstructor);\n const toData = isConstant\n ? (attribute.value as TypedArray)\n : // TODO(v9.1): Avoid non-portable synchronous reads.\n new ArrayType(\n attribute\n .getBuffer()!\n .readSyncWebGL(byteOffset, toLength * ArrayType.BYTES_PER_ELEMENT).buffer\n );\n if (attribute.settings.normalized && !isConstant) {\n const getter = getData;\n getData = (value, chunk) => attribute.normalizeConstant(getter(value, chunk));\n }\n\n const getMissingData = isConstant\n ? (i: number, chunk: NumericArray) => getData(toData, chunk)\n : (i: number, chunk: NumericArray) =>\n getData(toData.subarray(i + byteOffset, i + byteOffset + size), chunk);\n\n // TODO(v9.1): Avoid non-portable synchronous reads.\n const source = buffer\n ? new Float32Array(buffer.readSyncWebGL(targetByteOffset, fromLength * 4).buffer)\n : new Float32Array(0);\n const target = new Float32Array(toLength);\n padArray({\n source,\n target,\n sourceStartIndices: fromStartIndices,\n targetStartIndices: toStartIndices,\n size,\n getData: getMissingData\n });\n\n if (!buffer || buffer.byteLength < target.byteLength + targetByteOffset) {\n buffer?.destroy();\n buffer = device.createBuffer({\n byteLength: target.byteLength + targetByteOffset,\n usage: GL.DYNAMIC_COPY\n });\n }\n buffer.write(target, targetByteOffset);\n return buffer;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Transition from './transition';\nimport {cloneAttribute, getAttributeBufferLength} from './gpu-transition-utils';\n\nimport type {Device, Buffer} from '@luma.gl/core';\nimport type {Timeline} from '@luma.gl/engine';\nimport type Attribute from '../lib/attribute/attribute';\nimport type {TransitionSettings} from '../lib/attribute/transition-settings';\nimport type {NumericArray} from '../types/types';\n\nexport interface GPUTransition {\n get type(): string;\n get inProgress(): boolean;\n get attributeInTransition(): Attribute;\n\n /** Called when an attribute's values have changed and we need to start animating towards the new values */\n start(transitionSettings: TransitionSettings, numInstances: number): void;\n /** Called while transition is in progress */\n update(): boolean;\n /** Called when transition is interrupted */\n cancel(): void;\n /** Called when transition is disposed */\n delete(): void;\n}\n\nexport abstract class GPUTransitionBase\n implements GPUTransition\n{\n abstract get type(): string;\n\n device: Device;\n attribute: Attribute;\n transition: Transition;\n settings?: SettingsT;\n /** The attribute that holds the buffer in transition */\n attributeInTransition: Attribute;\n protected buffers: Buffer[] = [];\n /** The vertex count of the last buffer.\n * Buffer may be larger than the actual length we want to use\n * because we only reallocate buffers when they grow, not when they shrink,\n * due to performance costs */\n protected currentLength: number = 0;\n /** The start indices of the last buffer. */\n protected currentStartIndices: NumericArray | null;\n\n constructor({\n device,\n attribute,\n timeline\n }: {\n device: Device;\n attribute: Attribute;\n timeline: Timeline;\n }) {\n this.device = device;\n this.transition = new Transition(timeline);\n this.attribute = attribute;\n this.attributeInTransition = cloneAttribute(attribute);\n this.currentStartIndices = attribute.startIndices;\n }\n\n get inProgress(): boolean {\n return this.transition.inProgress;\n }\n\n start(transitionSettings: SettingsT, numInstances: number, duration: number = Infinity) {\n this.settings = transitionSettings;\n this.currentStartIndices = this.attribute.startIndices;\n this.currentLength = getAttributeBufferLength(this.attribute, numInstances);\n this.transition.start({...transitionSettings, duration});\n }\n\n update(): boolean {\n const updated = this.transition.update();\n if (updated) {\n this.onUpdate();\n }\n return updated;\n }\n\n abstract onUpdate(): void;\n\n protected setBuffer(buffer: Buffer) {\n this.attributeInTransition.setData({\n buffer,\n normalized: this.attribute.settings.normalized,\n // Retain placeholder value to generate correct shader layout\n value: this.attributeInTransition.value as NumericArray\n });\n }\n\n cancel(): void {\n this.transition.cancel();\n }\n\n delete(): void {\n this.cancel();\n for (const buffer of this.buffers) {\n buffer.destroy();\n }\n this.buffers.length = 0;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Device, Framebuffer, Texture} from '@luma.gl/core';\nimport {Timeline, BufferTransform} from '@luma.gl/engine';\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {\n padBuffer,\n matchBuffer,\n getAttributeTypeFromSize,\n getFloat32VertexFormat,\n cycleBuffers\n} from './gpu-transition-utils';\nimport Attribute from '../lib/attribute/attribute';\nimport {GPUTransitionBase} from './gpu-transition';\n\nimport type {SpringTransitionSettings} from '../lib/attribute/transition-settings';\nimport type {TypedArray} from '../types/types';\n\nexport default class GPUSpringTransition extends GPUTransitionBase {\n type = 'spring';\n\n private texture: Texture;\n private framebuffer: Framebuffer;\n private transform: BufferTransform;\n\n constructor({\n device,\n attribute,\n timeline\n }: {\n device: Device;\n attribute: Attribute;\n timeline: Timeline;\n }) {\n super({device, attribute, timeline});\n this.texture = getTexture(device);\n this.framebuffer = getFramebuffer(device, this.texture);\n this.transform = getTransform(device, attribute);\n }\n\n override start(transitionSettings: SpringTransitionSettings, numInstances: number): void {\n const prevLength = this.currentLength;\n const prevStartIndices = this.currentStartIndices;\n super.start(transitionSettings, numInstances);\n\n const {buffers, attribute} = this;\n\n for (let i = 0; i < 2; i++) {\n buffers[i] = padBuffer({\n device: this.device,\n buffer: buffers[i],\n attribute,\n fromLength: prevLength,\n toLength: this.currentLength,\n fromStartIndices: prevStartIndices,\n getData: transitionSettings.enter\n });\n }\n buffers[2] = matchBuffer({\n device: this.device,\n source: buffers[0],\n target: buffers[2]\n });\n\n this.setBuffer(buffers[1]);\n\n const {model} = this.transform;\n model.setVertexCount(Math.floor(this.currentLength / attribute.size));\n if (attribute.isConstant) {\n model.setConstantAttributes({aTo: attribute.value as TypedArray});\n } else {\n model.setAttributes({aTo: attribute.getBuffer()!});\n }\n }\n\n onUpdate() {\n const {buffers, transform, framebuffer, transition} = this;\n\n const settings = this.settings as SpringTransitionSettings;\n\n transform.model.setAttributes({\n aPrev: buffers[0],\n aCur: buffers[1]\n });\n transform.transformFeedback.setBuffers({vNext: buffers[2]});\n const springProps: SpringProps = {\n stiffness: settings.stiffness,\n damping: settings.damping\n };\n transform.model.shaderInputs.setProps({spring: springProps});\n transform.run({\n framebuffer,\n discard: false,\n parameters: {viewport: [0, 0, 1, 1]},\n clearColor: [0, 0, 0, 0]\n });\n\n cycleBuffers(buffers);\n this.setBuffer(buffers[1]);\n\n const isTransitioning = this.device.readPixelsToArrayWebGL(framebuffer)[0] > 0;\n\n if (!isTransitioning) {\n transition.end();\n }\n }\n\n override delete() {\n super.delete();\n this.transform.destroy();\n this.texture.destroy();\n this.framebuffer.destroy();\n }\n}\n\nconst uniformBlock = `\\\nuniform springUniforms {\n float damping;\n float stiffness;\n} spring;\n`;\n\ntype SpringProps = {\n damping: number;\n stiffness: number;\n};\n\nconst springUniforms = {\n name: 'spring',\n vs: uniformBlock,\n uniformTypes: {\n damping: 'f32',\n stiffness: 'f32'\n }\n} as const satisfies ShaderModule;\n\nconst vs = `\\\n#version 300 es\n#define SHADER_NAME spring-transition-vertex-shader\n\n#define EPSILON 0.00001\n\nin ATTRIBUTE_TYPE aPrev;\nin ATTRIBUTE_TYPE aCur;\nin ATTRIBUTE_TYPE aTo;\nout ATTRIBUTE_TYPE vNext;\nout float vIsTransitioningFlag;\n\nATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) {\n ATTRIBUTE_TYPE velocity = cur - prev;\n ATTRIBUTE_TYPE delta = dest - cur;\n ATTRIBUTE_TYPE force = delta * spring.stiffness;\n ATTRIBUTE_TYPE resistance = velocity * spring.damping;\n return force - resistance + velocity + cur;\n}\n\nvoid main(void) {\n bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON;\n vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0;\n\n vNext = getNextValue(aCur, aPrev, aTo);\n gl_Position = vec4(0, 0, 0, 1);\n gl_PointSize = 100.0;\n}\n`;\n\nconst fs = `\\\n#version 300 es\n#define SHADER_NAME spring-transition-is-transitioning-fragment-shader\n\nin float vIsTransitioningFlag;\n\nout vec4 fragColor;\n\nvoid main(void) {\n if (vIsTransitioningFlag == 0.0) {\n discard;\n }\n fragColor = vec4(1.0);\n}`;\n\nfunction getTransform(device: Device, attribute: Attribute): BufferTransform {\n const attributeType = getAttributeTypeFromSize(attribute.size);\n const format = getFloat32VertexFormat(attribute.size);\n return new BufferTransform(device, {\n vs,\n fs,\n bufferLayout: [\n {name: 'aPrev', format},\n {name: 'aCur', format},\n {name: 'aTo', format: attribute.getBufferLayout().attributes![0].format}\n ],\n varyings: ['vNext'],\n modules: [springUniforms],\n defines: {ATTRIBUTE_TYPE: attributeType},\n parameters: {\n depthCompare: 'always',\n blendColorOperation: 'max',\n blendColorSrcFactor: 'one',\n blendColorDstFactor: 'one',\n blendAlphaOperation: 'max',\n blendAlphaSrcFactor: 'one',\n blendAlphaDstFactor: 'one'\n }\n });\n}\n\nfunction getTexture(device: Device): Texture {\n return device.createTexture({\n data: new Uint8Array(4),\n format: 'rgba8unorm',\n mipmaps: false,\n width: 1,\n height: 1\n });\n}\n\nfunction getFramebuffer(device: Device, texture: Texture): Framebuffer {\n return device.createFramebuffer({\n id: 'spring-transition-is-transitioning-framebuffer',\n width: 1,\n height: 1,\n colorAttachments: [texture]\n });\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// deck.gl, MIT license\n\nimport GPUInterpolationTransition from '../../transitions/gpu-interpolation-transition';\nimport GPUSpringTransition from '../../transitions/gpu-spring-transition';\nimport log from '../../utils/log';\n\nimport type {Device} from '@luma.gl/core';\nimport type {Timeline} from '@luma.gl/engine';\nimport type {GPUTransition} from '../../transitions/gpu-transition';\nimport type {ConstructorOf} from '../../types/types';\nimport type Attribute from './attribute';\nimport type {TransitionSettings} from './transition-settings';\n\nconst TRANSITION_TYPES: Record> = {\n interpolation: GPUInterpolationTransition,\n spring: GPUSpringTransition\n};\n\nexport default class AttributeTransitionManager {\n id: string;\n\n private device: Device;\n private timeline?: Timeline;\n\n private transitions: {[id: string]: GPUTransition};\n private needsRedraw: boolean;\n private numInstances: number;\n\n constructor(\n device: Device,\n {\n id,\n timeline\n }: {\n id: string;\n timeline?: Timeline;\n }\n ) {\n if (!device) throw new Error('AttributeTransitionManager is constructed without device');\n this.id = id;\n this.device = device;\n this.timeline = timeline;\n\n this.transitions = {};\n this.needsRedraw = false;\n this.numInstances = 1;\n }\n\n finalize(): void {\n for (const attributeName in this.transitions) {\n this._removeTransition(attributeName);\n }\n }\n\n /* Public methods */\n\n // Called when attribute manager updates\n // Check the latest attributes for updates.\n update({\n attributes,\n transitions,\n numInstances\n }: {\n attributes: {[id: string]: Attribute};\n transitions: any;\n numInstances: number;\n }): void {\n // Transform class will crash if elementCount is 0\n this.numInstances = numInstances || 1;\n\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const settings = attribute.getTransitionSetting(transitions);\n\n // this attribute might not support transitions?\n if (!settings) continue; // eslint-disable-line no-continue\n this._updateAttribute(attributeName, attribute, settings);\n }\n\n for (const attributeName in this.transitions) {\n const attribute = attributes[attributeName];\n if (!attribute || !attribute.getTransitionSetting(transitions)) {\n // Animated attribute has been removed\n this._removeTransition(attributeName);\n }\n }\n }\n\n // Returns `true` if attribute is transition-enabled\n hasAttribute(attributeName: string): boolean {\n const transition = this.transitions[attributeName];\n return transition && transition.inProgress;\n }\n\n // Get all the animated attributes\n getAttributes(): {[id: string]: Attribute} {\n const animatedAttributes = {};\n\n for (const attributeName in this.transitions) {\n const transition = this.transitions[attributeName];\n if (transition.inProgress) {\n animatedAttributes[attributeName] = transition.attributeInTransition;\n }\n }\n\n return animatedAttributes;\n }\n\n /* eslint-disable max-statements */\n // Called every render cycle, run transform feedback\n // Returns `true` if anything changes\n run(): boolean {\n if (this.numInstances === 0) {\n return false;\n }\n\n for (const attributeName in this.transitions) {\n const updated = this.transitions[attributeName].update();\n if (updated) {\n this.needsRedraw = true;\n }\n }\n\n const needsRedraw = this.needsRedraw;\n this.needsRedraw = false;\n return needsRedraw;\n }\n /* eslint-enable max-statements */\n\n /* Private methods */\n private _removeTransition(attributeName: string): void {\n this.transitions[attributeName].delete();\n delete this.transitions[attributeName];\n }\n\n // Check an attributes for updates\n // Returns a transition object if a new transition is triggered.\n private _updateAttribute(\n attributeName: string,\n attribute: Attribute,\n settings: TransitionSettings\n ): void {\n const transition = this.transitions[attributeName];\n // an attribute can change transition type when it updates\n // let's remove the transition when that happens so we can create the new transition type\n // TODO: when switching transition types, make sure to carry over the attribute's\n // previous buffers, currentLength, startIndices, etc, to be used as the starting point\n // for the next transition\n let isNew = !transition || transition.type !== settings.type;\n\n if (isNew) {\n if (transition) {\n this._removeTransition(attributeName);\n }\n\n const TransitionType = TRANSITION_TYPES[settings.type];\n if (TransitionType) {\n this.transitions[attributeName] = new TransitionType({\n attribute,\n timeline: this.timeline,\n device: this.device\n });\n } else {\n log.error(`unsupported transition type '${settings.type}'`)();\n isNew = false;\n }\n }\n\n if (isNew || attribute.needsRedraw()) {\n this.needsRedraw = true;\n this.transitions[attributeName].start(settings, this.numInstances);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable guard-for-in */\nimport Attribute, {AttributeOptions} from './attribute';\nimport log from '../../utils/log';\nimport memoize from '../../utils/memoize';\nimport {mergeBounds} from '../../utils/math-utils';\nimport debug from '../../debug/index';\nimport {NumericArray} from '../../types/types';\n\nimport AttributeTransitionManager from './attribute-transition-manager';\n\nimport type {Device, BufferLayout} from '@luma.gl/core';\nimport type {Stats} from '@probe.gl/stats';\nimport type {Timeline} from '@luma.gl/engine';\n\nconst TRACE_INVALIDATE = 'attributeManager.invalidate';\nconst TRACE_UPDATE_START = 'attributeManager.updateStart';\nconst TRACE_UPDATE_END = 'attributeManager.updateEnd';\nconst TRACE_ATTRIBUTE_UPDATE_START = 'attribute.updateStart';\nconst TRACE_ATTRIBUTE_ALLOCATE = 'attribute.allocate';\nconst TRACE_ATTRIBUTE_UPDATE_END = 'attribute.updateEnd';\n\nexport default class AttributeManager {\n /**\n * @classdesc\n * Automated attribute generation and management. Suitable when a set of\n * vertex shader attributes are generated by iteration over a data array,\n * and updates to these attributes are needed either when the data itself\n * changes, or when other data relevant to the calculations change.\n *\n * - First the application registers descriptions of its dynamic vertex\n * attributes using AttributeManager.add().\n * - Then, when any change that affects attributes is detected by the\n * application, the app will call AttributeManager.invalidate().\n * - Finally before it renders, it calls AttributeManager.update() to\n * ensure that attributes are automatically rebuilt if anything has been\n * invalidated.\n *\n * The application provided update functions describe how attributes\n * should be updated from a data array and are expected to traverse\n * that data array (or iterable) and fill in the attribute's typed array.\n *\n * Note that the attribute manager intentionally does not do advanced\n * change detection, but instead makes it easy to build such detection\n * by offering the ability to \"invalidate\" each attribute separately.\n */\n id: string;\n device: Device;\n attributes: Record;\n updateTriggers: {[name: string]: string[]};\n needsRedraw: string | boolean;\n userData: any;\n\n private stats?: Stats;\n private attributeTransitionManager: AttributeTransitionManager;\n private mergeBoundsMemoized: any = memoize(mergeBounds);\n\n constructor(\n device: Device,\n {\n id = 'attribute-manager',\n stats,\n timeline\n }: {\n id?: string;\n stats?: Stats;\n timeline?: Timeline;\n } = {}\n ) {\n this.id = id;\n this.device = device;\n\n this.attributes = {};\n\n this.updateTriggers = {};\n this.needsRedraw = true;\n\n this.userData = {};\n this.stats = stats;\n\n this.attributeTransitionManager = new AttributeTransitionManager(device, {\n id: `${id}-transitions`,\n timeline\n });\n\n // For debugging sanity, prevent uninitialized members\n Object.seal(this);\n }\n\n finalize() {\n for (const attributeName in this.attributes) {\n this.attributes[attributeName].delete();\n }\n this.attributeTransitionManager.finalize();\n }\n\n // Returns the redraw flag, optionally clearing it.\n // Redraw flag will be set if any attributes attributes changed since\n // flag was last cleared.\n //\n // @param {String} [clearRedrawFlags=false] - whether to clear the flag\n // @return {false|String} - reason a redraw is needed.\n getNeedsRedraw(opts: {clearRedrawFlags?: boolean} = {clearRedrawFlags: false}): string | false {\n const redraw = this.needsRedraw;\n this.needsRedraw = this.needsRedraw && !opts.clearRedrawFlags;\n return redraw && this.id;\n }\n\n // Sets the redraw flag.\n // @param {Boolean} redraw=true\n setNeedsRedraw() {\n this.needsRedraw = true;\n }\n\n // Adds attributes\n add(attributes: {[id: string]: AttributeOptions}) {\n this._add(attributes);\n }\n\n // Adds attributes\n addInstanced(attributes: {[id: string]: AttributeOptions}) {\n this._add(attributes, {stepMode: 'instance'});\n }\n\n /**\n * Removes attributes\n * Takes an array of attribute names and delete them from\n * the attribute map if they exists\n *\n * @example\n * attributeManager.remove(['position']);\n *\n * @param {Object} attributeNameArray - attribute name array (see above)\n */\n remove(attributeNameArray: string[]) {\n for (const name of attributeNameArray) {\n if (this.attributes[name] !== undefined) {\n this.attributes[name].delete();\n delete this.attributes[name];\n }\n }\n }\n\n // Marks an attribute for update\n invalidate(triggerName: string, dataRange?: {startRow?: number; endRow?: number}) {\n const invalidatedAttributes = this._invalidateTrigger(triggerName, dataRange);\n // For performance tuning\n debug(TRACE_INVALIDATE, this, triggerName, invalidatedAttributes);\n }\n\n invalidateAll(dataRange?: {startRow?: number; endRow?: number}) {\n for (const attributeName in this.attributes) {\n this.attributes[attributeName].setNeedsUpdate(attributeName, dataRange);\n }\n // For performance tuning\n debug(TRACE_INVALIDATE, this, 'all');\n }\n\n // Ensure all attribute buffers are updated from props or data.\n // eslint-disable-next-line complexity\n update({\n data,\n numInstances,\n startIndices = null,\n transitions,\n props = {},\n buffers = {},\n context = {}\n }: {\n data: any;\n numInstances: number;\n startIndices?: NumericArray | null;\n transitions: any;\n props: any;\n buffers: any;\n context: any;\n }) {\n // keep track of whether some attributes are updated\n let updated = false;\n\n debug(TRACE_UPDATE_START, this);\n if (this.stats) {\n this.stats.get('Update Attributes').timeStart();\n }\n\n for (const attributeName in this.attributes) {\n const attribute = this.attributes[attributeName];\n const accessorName = attribute.settings.accessor;\n attribute.startIndices = startIndices;\n attribute.numInstances = numInstances;\n\n if (props[attributeName]) {\n log.removed(`props.${attributeName}`, `data.attributes.${attributeName}`)();\n }\n\n if (attribute.setExternalBuffer(buffers[attributeName])) {\n // Step 1: try update attribute directly from external buffers\n } else if (\n attribute.setBinaryValue(\n typeof accessorName === 'string' ? buffers[accessorName] : undefined,\n data.startIndices\n )\n ) {\n // Step 2: try set packed value from external typed array\n } else if (\n typeof accessorName === 'string' &&\n !buffers[accessorName] &&\n attribute.setConstantValue(props[accessorName])\n ) {\n // Step 3: try set constant value from props\n // Note: if buffers[accessorName] is supplied, ignore props[accessorName]\n // This may happen when setBinaryValue falls through to use the auto updater\n } else if (attribute.needsUpdate()) {\n // Step 4: update via updater callback\n updated = true;\n this._updateAttribute({\n attribute,\n numInstances,\n data,\n props,\n context\n });\n }\n\n this.needsRedraw = this.needsRedraw || attribute.needsRedraw();\n }\n\n if (updated) {\n // Only initiate alloc/update (and logging) if actually needed\n debug(TRACE_UPDATE_END, this, numInstances);\n }\n\n if (this.stats) {\n this.stats.get('Update Attributes').timeEnd();\n }\n\n this.attributeTransitionManager.update({\n attributes: this.attributes,\n numInstances,\n transitions\n });\n }\n\n // Update attribute transition to the current timestamp\n // Returns `true` if any transition is in progress\n updateTransition() {\n const {attributeTransitionManager} = this;\n const transitionUpdated = attributeTransitionManager.run();\n this.needsRedraw = this.needsRedraw || transitionUpdated;\n return transitionUpdated;\n }\n\n /**\n * Returns all attribute descriptors\n * Note: Format matches luma.gl Model/Program.setAttributes()\n * @return {Object} attributes - descriptors\n */\n getAttributes(): {[id: string]: Attribute} {\n return {...this.attributes, ...this.attributeTransitionManager.getAttributes()};\n }\n\n /**\n * Computes the spatial bounds of a given set of attributes\n */\n getBounds(attributeNames: string[]) {\n const bounds = attributeNames.map(attributeName => this.attributes[attributeName]?.getBounds());\n return this.mergeBoundsMemoized(bounds);\n }\n\n /**\n * Returns changed attribute descriptors\n * This indicates which WebGLBuffers need to be updated\n * @return {Object} attributes - descriptors\n */\n getChangedAttributes(opts: {clearChangedFlags?: boolean} = {clearChangedFlags: false}): {\n [id: string]: Attribute;\n } {\n const {attributes, attributeTransitionManager} = this;\n\n const changedAttributes = {...attributeTransitionManager.getAttributes()};\n\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n if (attribute.needsRedraw(opts) && !attributeTransitionManager.hasAttribute(attributeName)) {\n changedAttributes[attributeName] = attribute;\n }\n }\n\n return changedAttributes;\n }\n\n /** Generate WebGPU-style buffer layout descriptors from all attributes */\n getBufferLayouts(\n /** A luma.gl Model-shaped object that supplies additional hint to attribute resolution */\n modelInfo?: {\n /** Whether the model is instanced */\n isInstanced?: boolean;\n }\n ): BufferLayout[] {\n return Object.values(this.getAttributes()).map(attribute =>\n attribute.getBufferLayout(modelInfo)\n );\n }\n\n // PRIVATE METHODS\n\n /** Register new attributes */\n private _add(\n /** A map from attribute name to attribute descriptors */\n attributes: {[id: string]: AttributeOptions},\n /** Additional attribute settings to pass to all attributes */\n overrideOptions?: Partial\n ) {\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n\n const props: AttributeOptions = {\n ...attribute,\n id: attributeName,\n size: (attribute.isIndexed && 1) || attribute.size || 1,\n ...overrideOptions\n };\n\n // Initialize the attribute descriptor, with WebGL and metadata fields\n this.attributes[attributeName] = new Attribute(this.device, props);\n }\n\n this._mapUpdateTriggersToAttributes();\n }\n\n // build updateTrigger name to attribute name mapping\n private _mapUpdateTriggersToAttributes() {\n const triggers: {[name: string]: string[]} = {};\n\n for (const attributeName in this.attributes) {\n const attribute = this.attributes[attributeName];\n attribute.getUpdateTriggers().forEach(triggerName => {\n if (!triggers[triggerName]) {\n triggers[triggerName] = [];\n }\n triggers[triggerName].push(attributeName);\n });\n }\n\n this.updateTriggers = triggers;\n }\n\n private _invalidateTrigger(\n triggerName: string,\n dataRange?: {startRow?: number; endRow?: number}\n ): string[] {\n const {attributes, updateTriggers} = this;\n const invalidatedAttributes = updateTriggers[triggerName];\n\n if (invalidatedAttributes) {\n invalidatedAttributes.forEach(name => {\n const attribute = attributes[name];\n if (attribute) {\n attribute.setNeedsUpdate(attribute.id, dataRange);\n }\n });\n }\n return invalidatedAttributes;\n }\n\n private _updateAttribute(opts: {\n attribute: Attribute;\n numInstances: number;\n data: any;\n props: any;\n context: any;\n }) {\n const {attribute, numInstances} = opts;\n debug(TRACE_ATTRIBUTE_UPDATE_START, attribute);\n\n if (attribute.constant) {\n // The attribute is flagged as constant outside of an update cycle\n // Skip allocation and updater call\n // @ts-ignore value can be set to an array by user but always cast to typed array during attribute update\n attribute.setConstantValue(attribute.value);\n return;\n }\n\n if (attribute.allocate(numInstances)) {\n debug(TRACE_ATTRIBUTE_ALLOCATE, attribute, numInstances);\n }\n\n // Calls update on any buffers that need update\n const updated = attribute.updateBuffer(opts);\n if (updated) {\n this.needsRedraw = true;\n debug(TRACE_ATTRIBUTE_UPDATE_END, attribute, numInstances);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable react/no-direct-mutation-state */\nimport {Buffer, Parameters as LumaParameters, TypedArray} from '@luma.gl/core';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {COORDINATE_SYSTEM} from './constants';\nimport AttributeManager from './attribute/attribute-manager';\nimport UniformTransitionManager from './uniform-transition-manager';\nimport {diffProps, validateProps} from '../lifecycle/props';\nimport {LIFECYCLE, Lifecycle} from '../lifecycle/constants';\nimport {count} from '../utils/count';\nimport log from '../utils/log';\nimport debug from '../debug/index';\nimport assert from '../utils/assert';\nimport memoize from '../utils/memoize';\nimport {mergeShaders} from '../utils/shader';\nimport {projectPosition, getWorldPosition} from '../shaderlib/project/project-functions';\nimport typedArrayManager from '../utils/typed-array-manager';\n\nimport Component from '../lifecycle/component';\nimport LayerState, {ChangeFlags} from './layer-state';\n\nimport {worldToPixels} from '@math.gl/web-mercator';\n\nimport {load} from '@loaders.gl/core';\n\nimport type {Loader} from '@loaders.gl/loader-utils';\nimport type {CoordinateSystem} from './constants';\nimport type Attribute from './attribute/attribute';\nimport type {Model} from '@luma.gl/engine';\nimport type {PickingInfo, GetPickingInfoParams} from './picking/pick-info';\nimport type Viewport from '../viewports/viewport';\nimport type {NumericArray} from '../types/types';\nimport type {DefaultProps} from '../lifecycle/prop-types';\nimport type {LayerData, LayerProps} from '../types/layer-props';\nimport type {LayerContext} from './layer-manager';\nimport type {BinaryAttribute} from './attribute/attribute';\nimport {RenderPass} from '@luma.gl/core';\nimport {PickingProps} from '@luma.gl/shadertools';\n\nconst TRACE_CHANGE_FLAG = 'layer.changeFlag';\nconst TRACE_INITIALIZE = 'layer.initialize';\nconst TRACE_UPDATE = 'layer.update';\nconst TRACE_FINALIZE = 'layer.finalize';\nconst TRACE_MATCHED = 'layer.matched';\n\nconst MAX_PICKING_COLOR_CACHE_SIZE = 2 ** 24 - 1;\n\nconst EMPTY_ARRAY = Object.freeze([]);\n\n// Only compare the same two viewports once\nconst areViewportsEqual = memoize(\n ({oldViewport, viewport}: {oldViewport: Viewport; viewport: Viewport}): boolean => {\n return oldViewport.equals(viewport);\n }\n);\n\nlet pickingColorCache = new Uint8ClampedArray(0);\n\nconst defaultProps: DefaultProps = {\n // data: Special handling for null, see below\n data: {type: 'data', value: EMPTY_ARRAY, async: true},\n dataComparator: {type: 'function', value: null, optional: true},\n _dataDiff: {\n type: 'function',\n // @ts-ignore __diff is not defined on data\n value: data => data && data.__diff,\n optional: true\n },\n dataTransform: {type: 'function', value: null, optional: true},\n onDataLoad: {type: 'function', value: null, optional: true},\n onError: {type: 'function', value: null, optional: true},\n fetch: {\n type: 'function',\n value: (\n url: string,\n {\n propName,\n layer,\n loaders,\n loadOptions,\n signal\n }: {\n propName: string;\n layer: LayerT;\n loaders?: Loader[];\n loadOptions?: any;\n signal?: AbortSignal;\n }\n ) => {\n const {resourceManager} = layer.context;\n loadOptions = loadOptions || layer.getLoadOptions();\n loaders = loaders || layer.props.loaders;\n if (signal) {\n loadOptions = {\n ...loadOptions,\n fetch: {\n ...loadOptions?.fetch,\n signal\n }\n };\n }\n\n let inResourceManager = resourceManager.contains(url);\n\n if (!inResourceManager && !loadOptions) {\n // If there is no layer-specific load options, then attempt to cache this resource in the data manager\n resourceManager.add({resourceId: url, data: load(url, loaders), persistent: false});\n inResourceManager = true;\n }\n if (inResourceManager) {\n return resourceManager.subscribe({\n resourceId: url,\n onChange: data => layer.internalState?.reloadAsyncProp(propName, data),\n consumerId: layer.id,\n requestId: propName\n });\n }\n\n return load(url, loaders, loadOptions);\n }\n },\n updateTriggers: {}, // Update triggers: a core change detection mechanism in deck.gl\n\n visible: true,\n pickable: false,\n opacity: {type: 'number', min: 0, max: 1, value: 1},\n operation: 'draw',\n\n onHover: {type: 'function', value: null, optional: true},\n onClick: {type: 'function', value: null, optional: true},\n onDragStart: {type: 'function', value: null, optional: true},\n onDrag: {type: 'function', value: null, optional: true},\n onDragEnd: {type: 'function', value: null, optional: true},\n\n coordinateSystem: COORDINATE_SYSTEM.DEFAULT,\n coordinateOrigin: {type: 'array', value: [0, 0, 0], compare: true},\n modelMatrix: {type: 'array', value: null, compare: true, optional: true},\n wrapLongitude: false,\n positionFormat: 'XYZ',\n colorFormat: 'RGBA',\n\n parameters: {type: 'object', value: {}, optional: true, compare: 2},\n loadOptions: {type: 'object', value: null, optional: true, ignore: true},\n transitions: null,\n extensions: [],\n loaders: {type: 'array', value: [], optional: true, ignore: true},\n\n // Offset depth based on layer index to avoid z-fighting.\n // Negative values pull layer towards the camera\n // https://www.opengl.org/archives/resources/faq/technical/polygonoffset.htm\n getPolygonOffset: {\n type: 'function',\n value: ({layerIndex}) => [0, -layerIndex * 100]\n },\n\n // Selection/Highlighting\n highlightedObjectIndex: null,\n autoHighlight: false,\n highlightColor: {type: 'accessor', value: [0, 0, 128, 128]}\n};\n\nexport type UpdateParameters = {\n props: LayerT['props'];\n oldProps: LayerT['props'];\n context: LayerContext;\n changeFlags: ChangeFlags;\n};\n\ntype DrawOptions = {\n renderPass: RenderPass;\n shaderModuleProps: any;\n uniforms: any;\n parameters: any;\n context: LayerContext;\n};\n\ntype SharedLayerState = {\n [key: string]: unknown;\n};\n\nexport default abstract class Layer extends Component<\n PropsT & Required\n> {\n static defaultProps: DefaultProps = defaultProps;\n static layerName: string = 'Layer';\n\n static override get componentName() {\n return Object.prototype.hasOwnProperty.call(this, 'layerName') ? this.layerName : '';\n }\n\n internalState: LayerState | null = null;\n lifecycle: Lifecycle = LIFECYCLE.NO_STATE; // Helps track and debug the life cycle of the layers\n\n // context and state can technically be null before a layer is initialized/matched.\n // However, they are most extensively accessed in a layer's lifecycle methods, where they are always defined.\n // Checking for null state constantly in layer implementation is unnecessarily verbose.\n context!: LayerContext; // Will reference layer manager's context, contains state shared by layers\n state!: SharedLayerState; // Will be set to the shared layer state object during layer matching\n\n parent: Layer | null = null;\n\n get root(): Layer {\n // eslint-disable-next-line\n let layer: Layer = this;\n while (layer.parent) {\n layer = layer.parent;\n }\n return layer;\n }\n\n toString(): string {\n const className = (this.constructor as typeof Layer).layerName || this.constructor.name;\n return `${className}({id: '${this.props.id}'})`;\n }\n\n // Public API for users\n\n /** Projects a point with current view state from the current layer's coordinate system to screen */\n project(xyz: number[]): number[] {\n assert(this.internalState);\n const viewport = this.internalState.viewport || this.context.viewport;\n\n const worldPosition = getWorldPosition(xyz, {\n viewport,\n modelMatrix: this.props.modelMatrix,\n coordinateOrigin: this.props.coordinateOrigin,\n coordinateSystem: this.props.coordinateSystem\n });\n const [x, y, z] = worldToPixels(worldPosition, viewport.pixelProjectionMatrix);\n return xyz.length === 2 ? [x, y] : [x, y, z];\n }\n\n /** Unprojects a screen pixel to the current view's default coordinate system\n Note: this does not reverse `project`. */\n unproject(xy: number[]): number[] {\n assert(this.internalState);\n const viewport = this.internalState.viewport || this.context.viewport;\n return viewport.unproject(xy);\n }\n\n /** Projects a point with current view state from the current layer's coordinate system to the world space */\n projectPosition(\n xyz: number[],\n params?: {\n /** The viewport to use */\n viewport?: Viewport;\n /** The coordinate system that the supplied position is in. Default to the same as `coordinateSystem`. */\n fromCoordinateSystem?: CoordinateSystem;\n /** The coordinate origin that the supplied position is in. Default to the same as `coordinateOrigin`. */\n fromCoordinateOrigin?: [number, number, number];\n /** Whether to apply offset mode automatically as does the project shader module.\n * Offset mode places the origin of the common space at the given viewport's center. It is used in some use cases\n * to improve precision in the vertex shader due to the fp32 float limitation.\n * Use `autoOffset:false` if the returned position should not be dependent on the current viewport.\n * Default `true` */\n autoOffset?: boolean;\n }\n ): [number, number, number] {\n assert(this.internalState);\n const viewport = this.internalState.viewport || this.context.viewport;\n\n return projectPosition(xyz, {\n viewport,\n modelMatrix: this.props.modelMatrix,\n coordinateOrigin: this.props.coordinateOrigin,\n coordinateSystem: this.props.coordinateSystem,\n ...params\n });\n }\n\n // Public API for custom layer implementation\n\n /** `true` if this layer renders other layers */\n get isComposite(): boolean {\n return false;\n }\n\n /** `true` if the layer renders to screen */\n get isDrawable(): boolean {\n return true;\n }\n\n /** Updates selected state members and marks the layer for redraw */\n setState(partialState: any): void {\n this.setChangeFlags({stateChanged: true});\n Object.assign(this.state, partialState);\n this.setNeedsRedraw();\n }\n\n /** Sets the redraw flag for this layer, will trigger a redraw next animation frame */\n setNeedsRedraw(): void {\n if (this.internalState) {\n this.internalState.needsRedraw = true;\n }\n }\n\n /** Mark this layer as needs a deep update */\n setNeedsUpdate() {\n if (this.internalState) {\n this.context.layerManager.setNeedsUpdate(String(this));\n this.internalState.needsUpdate = true;\n }\n }\n\n /** Returns true if all async resources are loaded */\n get isLoaded(): boolean {\n return this.internalState ? !this.internalState.isAsyncPropLoading() : false;\n }\n\n /** Returns true if using shader-based WGS84 longitude wrapping */\n get wrapLongitude(): boolean {\n return this.props.wrapLongitude;\n }\n\n /** @deprecated Returns true if the layer is visible in the picking pass */\n isPickable(): boolean {\n return this.props.pickable && this.props.visible;\n }\n\n /** Returns an array of models used by this layer, can be overriden by layer subclass */\n getModels(): Model[] {\n const state = this.state as {\n models?: Model[];\n model: Model;\n };\n return (state && (state.models || (state.model && [state.model]))) || [];\n }\n\n /** Update shader input parameters */\n setShaderModuleProps(...props: Parameters): void {\n for (const model of this.getModels()) {\n model.shaderInputs.setProps(...props);\n }\n }\n\n /** Returns the attribute manager of this layer */\n getAttributeManager(): AttributeManager | null {\n return this.internalState && this.internalState.attributeManager;\n }\n\n /** Returns the most recent layer that matched to this state\n (When reacting to an async event, this layer may no longer be the latest) */\n getCurrentLayer(): Layer | null {\n return this.internalState && this.internalState.layer;\n }\n\n /** Returns the default parse options for async props */\n getLoadOptions(): any {\n return this.props.loadOptions;\n }\n\n use64bitPositions(): boolean {\n const {coordinateSystem} = this.props;\n return (\n coordinateSystem === COORDINATE_SYSTEM.DEFAULT ||\n coordinateSystem === COORDINATE_SYSTEM.LNGLAT ||\n coordinateSystem === COORDINATE_SYSTEM.CARTESIAN\n );\n }\n\n // Event handling\n onHover(info: PickingInfo, pickingEvent): boolean {\n if (this.props.onHover) {\n return this.props.onHover(info, pickingEvent) || false;\n }\n return false;\n }\n\n onClick(info: PickingInfo, pickingEvent): boolean {\n if (this.props.onClick) {\n return this.props.onClick(info, pickingEvent) || false;\n }\n return false;\n }\n\n // Returns the picking color that doesn't match any subfeature\n // Use if some graphics do not belong to any pickable subfeature\n // @return {Array} - a black color\n nullPickingColor() {\n return [0, 0, 0];\n }\n\n // Returns the picking color that doesn't match any subfeature\n // Use if some graphics do not belong to any pickable subfeature\n encodePickingColor(i, target: number[] = []): [number, number, number] {\n target[0] = (i + 1) & 255;\n target[1] = ((i + 1) >> 8) & 255;\n target[2] = (((i + 1) >> 8) >> 8) & 255;\n return target as [number, number, number];\n }\n\n // Returns the index corresponding to a picking color that doesn't match any subfeature\n // @param {Uint8Array} color - color array to be decoded\n // @return {Array} - the decoded picking color\n decodePickingColor(color) {\n assert(color instanceof Uint8Array);\n const [i1, i2, i3] = color;\n // 1 was added to seperate from no selection\n const index = i1 + i2 * 256 + i3 * 65536 - 1;\n return index;\n }\n\n /** Deduces number of instances. Intention is to support:\n - Explicit setting of numInstances\n - Auto-deduction for ES6 containers that define a size member\n - Auto-deduction for Classic Arrays via the built-in length attribute\n - Auto-deduction via arrays */\n getNumInstances(): number {\n // First Check if app has provided an explicit value\n if (Number.isFinite(this.props.numInstances)) {\n return this.props.numInstances as number;\n }\n\n // Second check if the layer has set its own value\n if (this.state && this.state.numInstances !== undefined) {\n return this.state.numInstances as number;\n }\n\n // Use container library to get a count for any ES6 container or object\n return count(this.props.data);\n }\n\n /** Buffer layout describes how many attribute values are packed for each data object\n The default (null) is one value each object.\n Some data formats (e.g. paths, polygons) have various length. Their buffer layout\n is in the form of [L0, L1, L2, ...] */\n getStartIndices(): NumericArray | null {\n // First Check if startIndices is provided as an explicit value\n if (this.props.startIndices) {\n return this.props.startIndices;\n }\n\n // Second check if the layer has set its own value\n if (this.state && this.state.startIndices) {\n return this.state.startIndices as NumericArray;\n }\n\n return null;\n }\n\n // Default implementation\n getBounds(): [number[], number[]] | null {\n return this.getAttributeManager()?.getBounds(['positions', 'instancePositions']);\n }\n\n // / LIFECYCLE METHODS - overridden by the layer subclasses\n\n /** Called once to set up the initial state. Layers can create WebGL resources here. */\n abstract initializeState(context: LayerContext): void;\n\n getShaders(shaders: any): any {\n shaders = mergeShaders(shaders, {\n disableWarnings: true,\n modules: this.context.defaultShaderModules\n });\n for (const extension of this.props.extensions) {\n shaders = mergeShaders(shaders, extension.getShaders.call(this, extension));\n }\n return shaders;\n }\n\n /** Controls if updateState should be called. By default returns true if any prop has changed */\n shouldUpdateState(params: UpdateParameters>): boolean {\n return params.changeFlags.propsOrDataChanged;\n }\n\n /** Default implementation, all attributes will be invalidated and updated when data changes */\n // eslint-disable-next-line complexity\n updateState(params: UpdateParameters>): void {\n const attributeManager = this.getAttributeManager();\n const {dataChanged} = params.changeFlags;\n if (dataChanged && attributeManager) {\n if (Array.isArray(dataChanged)) {\n // is partial update\n for (const dataRange of dataChanged) {\n attributeManager.invalidateAll(dataRange);\n }\n } else {\n attributeManager.invalidateAll();\n }\n }\n\n // Enable/disable picking buffer\n if (attributeManager) {\n const {props} = params;\n const hasPickingBuffer = this.internalState!.hasPickingBuffer;\n const needsPickingBuffer =\n Number.isInteger(props.highlightedObjectIndex) ||\n props.pickable ||\n props.extensions.some(extension => extension.getNeedsPickingBuffer.call(this, extension));\n\n // Only generate picking buffer if needed\n if (hasPickingBuffer !== needsPickingBuffer) {\n this.internalState!.hasPickingBuffer = needsPickingBuffer;\n const {pickingColors, instancePickingColors} = attributeManager.attributes;\n const pickingColorsAttribute = pickingColors || instancePickingColors;\n if (pickingColorsAttribute) {\n if (needsPickingBuffer && pickingColorsAttribute.constant) {\n pickingColorsAttribute.constant = false;\n attributeManager.invalidate(pickingColorsAttribute.id);\n }\n if (!pickingColorsAttribute.value && !needsPickingBuffer) {\n pickingColorsAttribute.constant = true;\n pickingColorsAttribute.value = [0, 0, 0];\n }\n }\n }\n }\n }\n\n /** Called once when layer is no longer matched and state will be discarded. Layers can destroy WebGL resources here. */\n finalizeState(context: LayerContext): void {\n for (const model of this.getModels()) {\n model.destroy();\n }\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.finalize();\n }\n if (this.context) {\n this.context.resourceManager.unsubscribe({consumerId: this.id});\n }\n if (this.internalState) {\n this.internalState.uniformTransitions.clear();\n this.internalState.finalize();\n }\n }\n\n // If state has a model, draw it with supplied uniforms\n draw(opts: DrawOptions) {\n for (const model of this.getModels()) {\n model.draw(opts.renderPass);\n }\n }\n\n // called to populate the info object that is passed to the event handler\n // @return null to cancel event\n getPickingInfo({info, mode, sourceLayer}: GetPickingInfoParams) {\n const {index} = info;\n\n if (index >= 0) {\n // If props.data is an indexable array, get the object\n if (Array.isArray(this.props.data)) {\n info.object = this.props.data[index];\n }\n }\n\n return info;\n }\n\n // END LIFECYCLE METHODS\n\n // / INTERNAL METHODS - called by LayerManager, DeckRenderer and DeckPicker\n\n /** (Internal) Propagate an error event through the system */\n raiseError(error: Error, message: string): void {\n if (message) {\n // Duplicating error message for backward compatibility, see #7986\n // TODO - revisit in v9\n error = new Error(`${message}: ${error.message}`, {cause: error});\n }\n if (!this.props.onError?.(error)) {\n this.context?.onError?.(error, this);\n }\n }\n\n /** (Internal) Checks if this layer needs redraw */\n getNeedsRedraw(\n opts: {\n /** Reset redraw flags to false after the check */\n clearRedrawFlags: boolean;\n } = {clearRedrawFlags: false}\n ): string | false {\n return this._getNeedsRedraw(opts);\n }\n\n /** (Internal) Checks if this layer needs a deep update */\n needsUpdate(): boolean {\n if (!this.internalState) {\n return false;\n }\n\n // Call subclass lifecycle method\n return (\n this.internalState.needsUpdate ||\n this.hasUniformTransition() ||\n this.shouldUpdateState(this._getUpdateParams())\n );\n // End lifecycle method\n }\n\n /** Checks if this layer has ongoing uniform transition */\n hasUniformTransition(): boolean {\n return this.internalState?.uniformTransitions.active || false;\n }\n\n /** Called when this layer is rendered into the given viewport */\n activateViewport(viewport: Viewport): void {\n if (!this.internalState) {\n return;\n }\n\n const oldViewport = this.internalState.viewport;\n this.internalState.viewport = viewport;\n\n if (!oldViewport || !areViewportsEqual({oldViewport, viewport})) {\n this.setChangeFlags({viewportChanged: true});\n\n if (this.isComposite) {\n if (this.needsUpdate()) {\n // Composite layers may add/remove sublayers on viewport change\n // Because we cannot change the layers list during a draw cycle, we don't want to update sublayers right away\n // This will not call update immediately, but mark the layerManager as needs update on the next frame\n this.setNeedsUpdate();\n }\n } else {\n this._update();\n }\n }\n }\n\n /** Default implementation of attribute invalidation, can be redefined */\n protected invalidateAttribute(name = 'all'): void {\n const attributeManager = this.getAttributeManager();\n if (!attributeManager) {\n return;\n }\n\n if (name === 'all') {\n attributeManager.invalidateAll();\n } else {\n attributeManager.invalidate(name);\n }\n }\n\n /** Send updated attributes to the WebGL model */\n protected updateAttributes(changedAttributes: {[id: string]: Attribute}) {\n // If some buffer layout changed\n let bufferLayoutChanged = false;\n for (const id in changedAttributes) {\n if (changedAttributes[id].layoutChanged()) {\n bufferLayoutChanged = true;\n }\n }\n\n for (const model of this.getModels()) {\n this._setModelAttributes(model, changedAttributes, bufferLayoutChanged);\n }\n }\n\n /** Recalculate any attributes if needed */\n protected _updateAttributes(): void {\n const attributeManager = this.getAttributeManager();\n if (!attributeManager) {\n return;\n }\n const props = this.props;\n\n // Figure out data length\n const numInstances = this.getNumInstances();\n const startIndices = this.getStartIndices();\n\n attributeManager.update({\n data: props.data,\n numInstances,\n startIndices,\n props,\n transitions: props.transitions,\n // @ts-ignore (TS2339) property attribute is not present on some acceptable data types\n buffers: props.data.attributes,\n context: this\n });\n\n const changedAttributes = attributeManager.getChangedAttributes({clearChangedFlags: true});\n this.updateAttributes(changedAttributes);\n }\n\n /** Update attribute transitions. This is called in drawLayer, no model updates required. */\n private _updateAttributeTransition() {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.updateTransition();\n }\n }\n\n /** Update uniform (prop) transitions. This is called in updateState, may result in model updates. */\n private _updateUniformTransition(): Layer['props'] {\n // @ts-ignore (TS2339) internalState is alwasy defined when this method is called\n const {uniformTransitions} = this.internalState;\n if (uniformTransitions.active) {\n // clone props\n const propsInTransition = uniformTransitions.update();\n const props = Object.create(this.props);\n for (const key in propsInTransition) {\n Object.defineProperty(props, key, {value: propsInTransition[key]});\n }\n return props;\n }\n return this.props;\n }\n\n /** Updater for the automatically populated instancePickingColors attribute */\n protected calculateInstancePickingColors(\n attribute: Attribute,\n {numInstances}: {numInstances: number}\n ) {\n if (attribute.constant) {\n return;\n }\n\n // calculateInstancePickingColors always generates the same sequence.\n // pickingColorCache saves the largest generated sequence for reuse\n const cacheSize = Math.floor(pickingColorCache.length / 4);\n\n // Record when using the picking buffer cache, so that layers can always point at the most recently allocated cache\n // @ts-ignore (TS2531) internalState is always defined when this method is called\n this.internalState.usesPickingColorCache = true;\n\n if (cacheSize < numInstances) {\n if (numInstances > MAX_PICKING_COLOR_CACHE_SIZE) {\n log.warn(\n 'Layer has too many data objects. Picking might not be able to distinguish all objects.'\n )();\n }\n\n pickingColorCache = typedArrayManager.allocate(pickingColorCache, numInstances, {\n size: 4,\n copy: true,\n maxCount: Math.max(numInstances, MAX_PICKING_COLOR_CACHE_SIZE)\n });\n\n // If the attribute is larger than the cache, resize the cache and populate the missing chunk\n const newCacheSize = Math.floor(pickingColorCache.length / 4);\n const pickingColor: [number, number, number] = [0, 0, 0];\n for (let i = cacheSize; i < newCacheSize; i++) {\n this.encodePickingColor(i, pickingColor);\n pickingColorCache[i * 4 + 0] = pickingColor[0];\n pickingColorCache[i * 4 + 1] = pickingColor[1];\n pickingColorCache[i * 4 + 2] = pickingColor[2];\n pickingColorCache[i * 4 + 3] = 0;\n }\n }\n\n attribute.value = pickingColorCache.subarray(0, numInstances * 4);\n }\n\n /** Apply changed attributes to model */\n protected _setModelAttributes(\n model: Model,\n changedAttributes: {\n [id: string]: Attribute;\n },\n bufferLayoutChanged = false\n ) {\n if (!Object.keys(changedAttributes).length) {\n return;\n }\n\n if (bufferLayoutChanged) {\n // AttributeManager is always defined when this method is called\n const attributeManager = this.getAttributeManager()!;\n model.setBufferLayout(attributeManager.getBufferLayouts(model));\n // All attributes must be reset after buffer layout change\n changedAttributes = attributeManager.getAttributes();\n }\n\n // @ts-ignore luma.gl type issue\n const excludeAttributes = model.userData?.excludeAttributes || {};\n const attributeBuffers: Record = {};\n const constantAttributes: Record = {};\n\n for (const name in changedAttributes) {\n if (excludeAttributes[name]) {\n continue;\n }\n const values = changedAttributes[name].getValue();\n for (const attributeName in values) {\n const value = values[attributeName];\n if (value instanceof Buffer) {\n if (changedAttributes[name].settings.isIndexed) {\n model.setIndexBuffer(value);\n } else {\n attributeBuffers[attributeName] = value;\n }\n } else if (value) {\n constantAttributes[attributeName] = value;\n }\n }\n }\n // TODO - update buffer map?\n model.setAttributes(attributeBuffers);\n model.setConstantAttributes(constantAttributes);\n }\n\n /** (Internal) Sets the picking color at the specified index to null picking color. Used for multi-depth picking.\n This method may be overriden by layer implementations */\n disablePickingIndex(objectIndex: number) {\n const data = this.props.data as LayerData;\n if (!('attributes' in data)) {\n this._disablePickingIndex(objectIndex);\n return;\n }\n\n // @ts-ignore (TS2531) this method is only called internally with attributeManager defined\n const {pickingColors, instancePickingColors} = this.getAttributeManager().attributes;\n const colors = pickingColors || instancePickingColors;\n const externalColorAttribute =\n colors && data.attributes && (data.attributes[colors.id] as BinaryAttribute);\n if (externalColorAttribute && externalColorAttribute.value) {\n const values = externalColorAttribute.value;\n const objectColor = this.encodePickingColor(objectIndex);\n for (let index = 0; index < data.length; index++) {\n const i = colors.getVertexOffset(index);\n if (\n values[i] === objectColor[0] &&\n values[i + 1] === objectColor[1] &&\n values[i + 2] === objectColor[2]\n ) {\n this._disablePickingIndex(index);\n }\n }\n } else {\n this._disablePickingIndex(objectIndex);\n }\n }\n\n // TODO - simplify subclassing interface\n protected _disablePickingIndex(objectIndex: number): void {\n // @ts-ignore (TS2531) this method is only called internally with attributeManager defined\n const {pickingColors, instancePickingColors} = this.getAttributeManager().attributes;\n const colors = pickingColors || instancePickingColors;\n if (!colors) {\n return;\n }\n\n const start = colors.getVertexOffset(objectIndex);\n const end = colors.getVertexOffset(objectIndex + 1);\n\n // Fill the sub buffer with 0s, 1 byte per element\n colors.buffer.write(new Uint8Array(end - start), start);\n }\n\n /** (Internal) Re-enable all picking indices after multi-depth picking */\n restorePickingColors(): void {\n // @ts-ignore (TS2531) this method is only called internally with attributeManager defined\n const {pickingColors, instancePickingColors} = this.getAttributeManager().attributes;\n const colors = pickingColors || instancePickingColors;\n if (!colors) {\n return;\n }\n // The picking color cache may have been freed and then reallocated. This ensures we read from the currently allocated cache.\n if (\n // @ts-ignore (TS2531) this method is only called internally with internalState defined\n this.internalState.usesPickingColorCache &&\n (colors.value as Uint8ClampedArray).buffer !== pickingColorCache.buffer\n ) {\n colors.value = pickingColorCache.subarray(0, (colors.value as Uint8ClampedArray).length);\n }\n colors.updateSubBuffer({startOffset: 0});\n }\n\n /* eslint-disable max-statements */\n /* (Internal) Called by layer manager when a new layer is found */\n _initialize() {\n assert(!this.internalState); // finalized layer cannot be reused\n assert(Number.isFinite(this.props.coordinateSystem)); // invalid coordinateSystem\n\n debug(TRACE_INITIALIZE, this);\n\n const attributeManager = this._getAttributeManager();\n\n if (attributeManager) {\n // All instanced layers get instancePickingColors attribute by default\n // Their shaders can use it to render a picking scene\n // TODO - this slightly slows down non instanced layers\n attributeManager.addInstanced({\n instancePickingColors: {\n type: 'uint8',\n size: 4,\n noAlloc: true,\n // Updaters are always called with `this` pointing to the layer\n // eslint-disable-next-line @typescript-eslint/unbound-method\n update: this.calculateInstancePickingColors\n }\n });\n }\n\n this.internalState = new LayerState({\n attributeManager,\n layer: this\n });\n this._clearChangeFlags(); // populate this.internalState.changeFlags\n\n this.state = {};\n // for backwards compatibility with older layers\n // TODO - remove in next release\n /* eslint-disable accessor-pairs */\n Object.defineProperty(this.state, 'attributeManager', {\n get: () => {\n log.deprecated('layer.state.attributeManager', 'layer.getAttributeManager()')();\n return attributeManager;\n }\n });\n /* eslint-enable accessor-pairs */\n\n this.internalState.uniformTransitions = new UniformTransitionManager(this.context.timeline);\n this.internalState.onAsyncPropUpdated = this._onAsyncPropUpdated.bind(this);\n\n // Ensure any async props are updated\n this.internalState.setAsyncProps(this.props);\n\n // Call subclass lifecycle methods\n this.initializeState(this.context);\n\n // Initialize extensions\n for (const extension of this.props.extensions) {\n extension.initializeState.call(this, this.context, extension);\n }\n // End subclass lifecycle methods\n\n // initializeState callback tends to clear state\n this.setChangeFlags({\n dataChanged: 'init',\n propsChanged: 'init',\n viewportChanged: true,\n extensionsChanged: true\n });\n\n this._update();\n }\n\n /** (Internal) Called by layer manager to transfer state from an old layer */\n _transferState(oldLayer: Layer): void {\n debug(TRACE_MATCHED, this, this === oldLayer);\n\n const {state, internalState} = oldLayer;\n\n if (this === oldLayer) {\n return;\n }\n\n // Move internalState\n this.internalState = internalState as LayerState;\n\n // Move state\n this.state = state;\n // We keep the state ref on old layers to support async actions\n // oldLayer.state = null;\n\n // Ensure any async props are updated\n this.internalState.setAsyncProps(this.props);\n\n this._diffProps(this.props, this.internalState.getOldProps() as Layer['props']);\n }\n\n /** (Internal) Called by layer manager when a new layer is added or an existing layer is matched with a new instance */\n _update(): void {\n // Call subclass lifecycle method\n const stateNeedsUpdate = this.needsUpdate();\n // End lifecycle method\n debug(TRACE_UPDATE, this, stateNeedsUpdate);\n\n if (!stateNeedsUpdate) {\n return;\n }\n\n const currentProps = this.props;\n const context = this.context;\n const internalState = this.internalState as LayerState;\n\n const currentViewport = context.viewport;\n const propsInTransition = this._updateUniformTransition();\n internalState.propsInTransition = propsInTransition;\n // Overwrite this.context.viewport during update to use the last activated viewport on this layer\n // In multi-view applications, a layer may only be drawn in one of the views\n // Which would make the \"active\" viewport different from the shared context\n context.viewport = internalState.viewport || currentViewport;\n // Overwrite this.props during update to use in-transition prop values\n this.props = propsInTransition;\n\n try {\n const updateParams = this._getUpdateParams();\n const oldModels = this.getModels();\n\n // Safely call subclass lifecycle methods\n if (context.device) {\n this.updateState(updateParams);\n } else {\n try {\n this.updateState(updateParams);\n } catch (error) {\n // ignore error if gl context is missing\n }\n }\n // Execute extension updates\n for (const extension of this.props.extensions) {\n extension.updateState.call(this, updateParams, extension);\n }\n\n this.setNeedsRedraw();\n // Check if attributes need recalculation\n this._updateAttributes();\n\n const modelChanged = this.getModels()[0] !== oldModels[0];\n this._postUpdate(updateParams, modelChanged);\n // End subclass lifecycle methods\n } finally {\n // Restore shared context\n context.viewport = currentViewport;\n this.props = currentProps;\n this._clearChangeFlags();\n internalState.needsUpdate = false;\n internalState.resetOldProps();\n }\n }\n /* eslint-enable max-statements */\n\n /** (Internal) Called by manager when layer is about to be disposed \n Note: not guaranteed to be called on application shutdown */\n _finalize(): void {\n debug(TRACE_FINALIZE, this);\n\n // Call subclass lifecycle method\n this.finalizeState(this.context);\n // Finalize extensions\n for (const extension of this.props.extensions) {\n extension.finalizeState.call(this, this.context, extension);\n }\n }\n\n // Calculates uniforms\n _drawLayer({\n renderPass,\n shaderModuleProps = null,\n uniforms = {},\n parameters = {}\n }: {\n renderPass: RenderPass;\n shaderModuleProps: any;\n uniforms: any;\n parameters: LumaParameters;\n }): void {\n this._updateAttributeTransition();\n\n const currentProps = this.props;\n const context = this.context;\n // Overwrite this.props during redraw to use in-transition prop values\n // `internalState.propsInTransition` could be missing if `updateState` failed\n // @ts-ignore (TS2339) internalState is alwasy defined when this method is called\n this.props = this.internalState.propsInTransition || currentProps;\n\n try {\n // TODO/ib - hack move to luma Model.draw\n if (shaderModuleProps) {\n this.setShaderModuleProps(shaderModuleProps);\n }\n\n // Apply polygon offset to avoid z-fighting\n // TODO - move to draw-layers\n const {getPolygonOffset} = this.props;\n const offsets = (getPolygonOffset && getPolygonOffset(uniforms)) || [0, 0];\n\n if (context.device instanceof WebGLDevice) {\n context.device.setParametersWebGL({polygonOffset: offsets});\n }\n\n for (const model of this.getModels()) {\n model.setParameters(parameters);\n }\n\n // Call subclass lifecycle method\n if (context.device instanceof WebGLDevice) {\n context.device.withParametersWebGL(parameters, () => {\n const opts: DrawOptions = {renderPass, shaderModuleProps, uniforms, parameters, context};\n\n // extensions\n for (const extension of this.props.extensions) {\n extension.draw.call(this, opts, extension);\n }\n\n this.draw(opts);\n });\n } else {\n const opts: DrawOptions = {renderPass, shaderModuleProps, uniforms, parameters, context};\n\n // extensions\n for (const extension of this.props.extensions) {\n extension.draw.call(this, opts, extension);\n }\n\n this.draw(opts);\n }\n } finally {\n this.props = currentProps;\n }\n\n // End lifecycle method\n }\n\n // Helper methods\n /** Returns the current change flags */\n getChangeFlags(): ChangeFlags | undefined {\n return this.internalState?.changeFlags;\n }\n\n /* eslint-disable complexity */\n /** Dirty some change flags, will be handled by updateLayer */\n setChangeFlags(flags: Partial): void {\n if (!this.internalState) {\n return;\n }\n const {changeFlags} = this.internalState;\n\n /* eslint-disable no-fallthrough, max-depth */\n for (const key in flags) {\n if (flags[key]) {\n let flagChanged = false;\n switch (key) {\n case 'dataChanged':\n // changeFlags.dataChanged may be `false`, a string (reason) or an array of ranges\n const dataChangedReason = flags[key];\n const prevDataChangedReason = changeFlags[key];\n if (dataChangedReason && Array.isArray(prevDataChangedReason)) {\n // Merge partial updates\n changeFlags.dataChanged = Array.isArray(dataChangedReason)\n ? prevDataChangedReason.concat(dataChangedReason)\n : dataChangedReason;\n flagChanged = true;\n }\n\n default:\n if (!changeFlags[key]) {\n changeFlags[key] = flags[key];\n flagChanged = true;\n }\n }\n if (flagChanged) {\n debug(TRACE_CHANGE_FLAG, this, key, flags);\n }\n }\n }\n /* eslint-enable no-fallthrough, max-depth */\n\n // Update composite flags\n const propsOrDataChanged = Boolean(\n changeFlags.dataChanged ||\n changeFlags.updateTriggersChanged ||\n changeFlags.propsChanged ||\n changeFlags.extensionsChanged\n );\n changeFlags.propsOrDataChanged = propsOrDataChanged;\n changeFlags.somethingChanged =\n propsOrDataChanged || changeFlags.viewportChanged || changeFlags.stateChanged;\n }\n /* eslint-enable complexity */\n\n /** Clear all changeFlags, typically after an update */\n private _clearChangeFlags(): void {\n // @ts-ignore TS2531 this method can only be called internally with internalState assigned\n this.internalState.changeFlags = {\n dataChanged: false,\n propsChanged: false,\n updateTriggersChanged: false,\n viewportChanged: false,\n stateChanged: false,\n extensionsChanged: false,\n propsOrDataChanged: false,\n somethingChanged: false\n };\n }\n\n /** Compares the layers props with old props from a matched older layer\n and extracts change flags that describe what has change so that state\n can be update correctly with minimal effort */\n private _diffProps(newProps: Layer['props'], oldProps: Layer['props']) {\n const changeFlags = diffProps(newProps, oldProps);\n\n // iterate over changedTriggers\n if (changeFlags.updateTriggersChanged) {\n for (const key in changeFlags.updateTriggersChanged) {\n if (changeFlags.updateTriggersChanged[key]) {\n this.invalidateAttribute(key);\n }\n }\n }\n\n // trigger uniform transitions\n if (changeFlags.transitionsChanged) {\n for (const key in changeFlags.transitionsChanged) {\n // prop changed and transition is enabled\n // @ts-ignore (TS2531) internalState is always defined when this method is called\n this.internalState.uniformTransitions.add(\n key,\n oldProps[key],\n newProps[key],\n newProps.transitions?.[key]\n );\n }\n }\n\n return this.setChangeFlags(changeFlags);\n }\n\n /** (Internal) called by layer manager to perform extra props validation (in development only) */\n validateProps(): void {\n validateProps(this.props);\n }\n\n /** (Internal) Called by deck picker when the hovered object changes to update the auto highlight */\n updateAutoHighlight(info: PickingInfo): void {\n if (this.props.autoHighlight && !Number.isInteger(this.props.highlightedObjectIndex)) {\n this._updateAutoHighlight(info);\n }\n }\n\n // May be overriden by subclasses\n\n // TODO - simplify subclassing interface\n /** Update picking module parameters to highlight the hovered object */\n protected _updateAutoHighlight(info: PickingInfo): void {\n const picking: PickingProps = {\n // @ts-ignore\n highlightedObjectColor: info.picked ? info.color : null\n };\n const {highlightColor} = this.props;\n if (info.picked && typeof highlightColor === 'function') {\n // @ts-ignore\n picking.highlightColor = highlightColor(info);\n }\n this.setShaderModuleProps({picking});\n // setShaderModuleProps does not trigger redraw\n this.setNeedsRedraw();\n }\n\n /** Create new attribute manager */\n protected _getAttributeManager(): AttributeManager | null {\n const context = this.context;\n return new AttributeManager(context.device, {\n id: this.props.id,\n stats: context.stats,\n timeline: context.timeline\n });\n }\n\n // Private methods\n\n /** Called after updateState to perform common tasks */\n protected _postUpdate(updateParams: UpdateParameters>, forceUpdate: boolean) {\n const {props, oldProps} = updateParams;\n\n // Note: Automatic instance count update only works for single layers\n const model = this.state.model as Model | undefined;\n if (model?.isInstanced) {\n model.setInstanceCount(this.getNumInstances());\n }\n\n // Set picking module parameters to match props\n const {autoHighlight, highlightedObjectIndex, highlightColor} = props;\n if (\n forceUpdate ||\n oldProps.autoHighlight !== autoHighlight ||\n oldProps.highlightedObjectIndex !== highlightedObjectIndex ||\n oldProps.highlightColor !== highlightColor\n ) {\n const picking: PickingProps = {};\n\n if (Array.isArray(highlightColor)) {\n picking.highlightColor = highlightColor as [number, number, number];\n }\n\n // highlightedObjectIndex will overwrite any settings from auto highlighting.\n // Do not reset unless the value has changed.\n if (\n forceUpdate ||\n oldProps.autoHighlight !== autoHighlight ||\n highlightedObjectIndex !== oldProps.highlightedObjectIndex\n ) {\n picking.highlightedObjectColor =\n Number.isFinite(highlightedObjectIndex) && (highlightedObjectIndex as number) >= 0\n ? this.encodePickingColor(highlightedObjectIndex)\n : null;\n }\n\n this.setShaderModuleProps({picking});\n }\n }\n\n private _getUpdateParams(): UpdateParameters> {\n return {\n props: this.props,\n // @ts-ignore TS2531 this method can only be called internally with internalState assigned\n oldProps: this.internalState.getOldProps() as PropsT,\n context: this.context,\n // @ts-ignore TS2531 this method can only be called internally with internalState assigned\n changeFlags: this.internalState.changeFlags\n };\n }\n\n /** Checks state of attributes and model */\n private _getNeedsRedraw(opts: {clearRedrawFlags: boolean}): string | false {\n // this method may be called by the render loop as soon a the layer\n // has been created, so guard against uninitialized state\n if (!this.internalState) {\n return false;\n }\n\n let redraw: string | false = false;\n redraw = redraw || (this.internalState.needsRedraw && this.id);\n\n // TODO - is attribute manager needed? - Model should be enough.\n const attributeManager = this.getAttributeManager();\n const attributeManagerNeedsRedraw = attributeManager\n ? attributeManager.getNeedsRedraw(opts)\n : false;\n redraw = redraw || attributeManagerNeedsRedraw;\n\n if (redraw) {\n for (const extension of this.props.extensions) {\n extension.onNeedsRedraw.call(this, extension);\n }\n }\n\n this.internalState.needsRedraw = this.internalState.needsRedraw && !opts.clearRedrawFlags;\n return redraw;\n }\n\n /** Callback when asyn prop is loaded */\n private _onAsyncPropUpdated(): void {\n // @ts-ignore TS2531 this method can only be called internally with internalState assigned\n this._diffProps(this.props, this.internalState.getOldProps());\n this.setNeedsUpdate();\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {lerp} from '@math.gl/core';\nimport Transition from './transition';\n\nexport default class CPUInterpolationTransition extends Transition {\n _value;\n\n get value() {\n return this._value;\n }\n\n _onUpdate() {\n const {\n time,\n settings: {fromValue, toValue, duration, easing}\n } = this;\n const t = easing(time / duration);\n this._value = lerp(fromValue, toValue, t);\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Transition from './transition';\n\nconst EPSILON = 1e-5;\n\n/*\n * Calculate the next value in the spring transition\n * @param prev {Number} - previous value\n * @param cur {Number} - current value\n * @param dest {Number} - destination value\n * @param damping {Number}\n * @param stiffness {Number}\n */\nfunction updateSpringElement(\n prev: number,\n cur: number,\n dest: number,\n damping: number,\n stiffness: number\n): number {\n const velocity = cur - prev;\n const delta = dest - cur;\n const spring = delta * stiffness;\n const damper = -velocity * damping;\n return spring + damper + velocity + cur;\n}\n\n/*\n * Calculate the next value in the spring transition\n * @param prev {Number|Array} - previous value\n * @param cur {Number|Array} - current value\n * @param dest {Number|Array} - destination value\n * @param damping {Number}\n * @param stiffness {Number}\n */\nfunction updateSpring(prev: number, cur: number, dest: number, damping: number, stiffness: number);\nfunction updateSpring(\n prev: number[],\n cur: number[],\n dest: number[],\n damping: number,\n stiffness: number\n): number[];\n\nfunction updateSpring(\n prev: number | number[],\n cur: number | number[],\n dest: number | number[],\n damping: number,\n stiffness: number\n): number | number[] {\n if (Array.isArray(dest)) {\n const next: number[] = [];\n for (let i = 0; i < dest.length; i++) {\n next[i] = updateSpringElement(prev[i], cur[i], dest[i], damping, stiffness);\n }\n return next;\n }\n return updateSpringElement(prev as number, cur as number, dest, damping, stiffness);\n}\n\n/*\n * Calculate the distance between two numbers or two vectors\n */\nfunction distance(value1, value2) {\n if (Array.isArray(value1)) {\n let distanceSquare = 0;\n for (let i = 0; i < value1.length; i++) {\n const d = value1[i] - value2[i];\n distanceSquare += d * d;\n }\n return Math.sqrt(distanceSquare);\n }\n return Math.abs(value1 - value2);\n}\n\nexport default class CPUSpringTransition extends Transition {\n _prevValue;\n _currValue;\n\n get value() {\n return this._currValue;\n }\n\n _onUpdate() {\n // TODO - use timeline\n // const {time} = this;\n\n const {fromValue, toValue, damping, stiffness} = this.settings;\n const {_prevValue = fromValue, _currValue = fromValue} = this;\n let nextValue = updateSpring(_prevValue, _currValue, toValue, damping, stiffness);\n const delta = distance(nextValue, toValue);\n const velocity = distance(nextValue, _currValue);\n\n if (delta < EPSILON && velocity < EPSILON) {\n nextValue = toValue;\n this.end();\n }\n\n this._prevValue = _currValue;\n this._currValue = nextValue;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {normalizeTransitionSettings} from './attribute/transition-settings';\nimport CPUInterpolationTransition from '../transitions/cpu-interpolation-transition';\nimport CPUSpringTransition from '../transitions/cpu-spring-transition';\nimport log from '../utils/log';\n\nconst TRANSITION_TYPES = {\n interpolation: CPUInterpolationTransition,\n spring: CPUSpringTransition\n};\n\nexport default class UniformTransitionManager {\n transitions = new Map();\n timeline;\n\n constructor(timeline) {\n this.timeline = timeline;\n }\n\n get active() {\n return this.transitions.size > 0;\n }\n\n add(key, fromValue, toValue, settings) {\n const {transitions} = this;\n if (transitions.has(key)) {\n const transition = transitions.get(key);\n // value may not be available if `update()` has not been called. Fallback to `fromValue`\n const {value = transition.settings.fromValue} = transition;\n // start from interrupted position\n fromValue = value;\n this.remove(key);\n }\n\n settings = normalizeTransitionSettings(settings);\n if (!settings) {\n return;\n }\n\n const TransitionType = TRANSITION_TYPES[settings.type];\n if (!TransitionType) {\n log.error(`unsupported transition type '${settings.type}'`)();\n return;\n }\n const transition = new TransitionType(this.timeline);\n transition.start({\n ...settings,\n fromValue,\n toValue\n });\n transitions.set(key, transition);\n }\n\n remove(key) {\n const {transitions} = this;\n if (transitions.has(key)) {\n transitions.get(key).cancel();\n transitions.delete(key);\n }\n }\n\n update() {\n const propsInTransition = {};\n\n for (const [key, transition] of this.transitions) {\n transition.update();\n propsInTransition[key] = transition.value;\n if (!transition.inProgress) {\n // transition ended\n this.remove(key);\n }\n }\n\n return propsInTransition;\n }\n\n clear() {\n for (const key of this.transitions.keys()) {\n this.remove(key);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {PROP_TYPES_SYMBOL} from './constants';\n\nexport function validateProps(props) {\n const propTypes = props[PROP_TYPES_SYMBOL];\n\n for (const propName in propTypes) {\n const propType = propTypes[propName];\n const {validate} = propType;\n if (validate && !validate(props[propName], propType)) {\n throw new Error(`Invalid prop ${propName}: ${props[propName]}`);\n }\n }\n}\n\n// Returns an object with \"change flags\", either false or strings indicating reason for change\nexport function diffProps(\n props,\n oldProps\n): {\n dataChanged: string | false | {startRow: number; endRow?: number}[];\n propsChanged: string | false;\n updateTriggersChanged: Record | false;\n extensionsChanged: boolean;\n transitionsChanged: Record | false;\n} {\n // First check if any props have changed (ignore props that will be examined separately)\n const propsChangedReason = compareProps({\n newProps: props,\n oldProps,\n propTypes: props[PROP_TYPES_SYMBOL],\n ignoreProps: {data: null, updateTriggers: null, extensions: null, transitions: null}\n });\n\n // Now check if any data related props have changed\n const dataChangedReason = diffDataProps(props, oldProps);\n\n // Check update triggers to determine if any attributes need regeneration\n // Note - if data has changed, all attributes will need regeneration, so skip this step\n let updateTriggersChangedReason: false | string | Record = false;\n if (!dataChangedReason) {\n updateTriggersChangedReason = diffUpdateTriggers(props, oldProps);\n }\n\n return {\n dataChanged: dataChangedReason,\n propsChanged: propsChangedReason,\n updateTriggersChanged: updateTriggersChangedReason,\n extensionsChanged: diffExtensions(props, oldProps),\n transitionsChanged: diffTransitions(props, oldProps)\n };\n}\n\nfunction diffTransitions(props, oldProps): false | Record {\n if (!props.transitions) {\n return false;\n }\n const result: Record = {};\n const propTypes = props[PROP_TYPES_SYMBOL];\n let changed = false;\n\n for (const key in props.transitions) {\n const propType = propTypes[key];\n const type = propType && propType.type;\n const isTransitionable = type === 'number' || type === 'color' || type === 'array';\n if (isTransitionable && comparePropValues(props[key], oldProps[key], propType)) {\n result[key] = true;\n changed = true;\n }\n }\n return changed ? result : false;\n}\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * @param {Object} opt.oldProps - object with old key/value pairs\n * @param {Object} opt.newProps - object with new key/value pairs\n * @param {Object} opt.ignoreProps={} - object, keys that should not be compared\n * @returns {null|String} - null when values of all keys are strictly equal.\n * if unequal, returns a string explaining what changed.\n */\n/* eslint-disable max-statements, max-depth, complexity */\n/*\n * Note: for better performance, this function assumes that both oldProps and newProps\n inherit the same prototype (defaultProps). That is, if neither object contains own\n property , assume `oldProps.` and `newProps.` are equal.\n */\nexport function compareProps({\n newProps,\n oldProps,\n ignoreProps = {},\n propTypes = {},\n triggerName = 'props'\n}): string | false {\n // shallow equality => deep equality\n if (oldProps === newProps) {\n return false;\n }\n\n // TODO - do we need these checks? Should never happen...\n if (typeof newProps !== 'object' || newProps === null) {\n return `${triggerName} changed shallowly`;\n }\n\n if (typeof oldProps !== 'object' || oldProps === null) {\n return `${triggerName} changed shallowly`;\n }\n\n // Compare explicitly defined new props against old/default values\n for (const key of Object.keys(newProps)) {\n if (!(key in ignoreProps)) {\n if (!(key in oldProps)) {\n return `${triggerName}.${key} added`;\n }\n const changed = comparePropValues(newProps[key], oldProps[key], propTypes[key]);\n if (changed) {\n return `${triggerName}.${key} ${changed}`;\n }\n }\n }\n\n // Test if any old props have been dropped\n for (const key of Object.keys(oldProps)) {\n if (!(key in ignoreProps)) {\n if (!(key in newProps)) {\n return `${triggerName}.${key} dropped`;\n }\n if (!Object.hasOwnProperty.call(newProps, key)) {\n // Compare dropped old prop against default value\n const changed = comparePropValues(newProps[key], oldProps[key], propTypes[key]);\n if (changed) {\n return `${triggerName}.${key} ${changed}`;\n }\n }\n }\n }\n\n return false;\n}\n/* eslint-enable max-statements, max-depth, complexity */\n\n// HELPERS\nfunction comparePropValues(newProp, oldProp, propType) {\n // If prop type has an equal function, invoke it\n let equal = propType && propType.equal;\n if (equal && !equal(newProp, oldProp, propType)) {\n return 'changed deeply';\n }\n\n if (!equal) {\n // If object has an equals function, invoke it\n equal = newProp && oldProp && newProp.equals;\n if (equal && !equal.call(newProp, oldProp)) {\n return 'changed deeply';\n }\n }\n\n if (!equal && oldProp !== newProp) {\n return 'changed shallowly';\n }\n\n return null;\n}\n\n// The comparison of the data prop requires special handling\n// the dataComparator should be used if supplied\nfunction diffDataProps(props, oldProps): string | false | {startRow: number; endRow?: number}[] {\n if (oldProps === null) {\n return 'oldProps is null, initial diff';\n }\n\n let dataChanged: string | false | {startRow: number; endRow?: number}[] = false;\n // Support optional app defined comparison of data\n const {dataComparator, _dataDiff} = props;\n if (dataComparator) {\n if (!dataComparator(props.data, oldProps.data)) {\n dataChanged = 'Data comparator detected a change';\n }\n // Otherwise, do a shallow equal on props\n } else if (props.data !== oldProps.data) {\n dataChanged = 'A new data container was supplied';\n }\n if (dataChanged && _dataDiff) {\n dataChanged = _dataDiff(props.data, oldProps.data) || dataChanged;\n }\n\n return dataChanged;\n}\n\n// Checks if any update triggers have changed\n// also calls callback to invalidate attributes accordingly.\nfunction diffUpdateTriggers(props, oldProps): Record | false {\n if (oldProps === null) {\n return {all: true};\n }\n\n // If the 'all' updateTrigger fires, ignore testing others\n if ('all' in props.updateTriggers) {\n const diffReason = diffUpdateTrigger(props, oldProps, 'all');\n if (diffReason) {\n return {all: true};\n }\n }\n\n const reason: Record = {};\n let changed = false;\n // If the 'all' updateTrigger didn't fire, need to check all others\n for (const triggerName in props.updateTriggers) {\n if (triggerName !== 'all') {\n const diffReason = diffUpdateTrigger(props, oldProps, triggerName);\n if (diffReason) {\n reason[triggerName] = true;\n changed = true;\n }\n }\n }\n\n return changed ? reason : false;\n}\n\n// Returns true if any extensions have changed\nfunction diffExtensions(props, oldProps): boolean {\n if (oldProps === null) {\n return true;\n }\n\n const oldExtensions = oldProps.extensions;\n const {extensions} = props;\n\n if (extensions === oldExtensions) {\n return false;\n }\n if (!oldExtensions || !extensions) {\n return true;\n }\n if (extensions.length !== oldExtensions.length) {\n return true;\n }\n for (let i = 0; i < extensions.length; i++) {\n if (!extensions[i].equals(oldExtensions[i])) {\n return true;\n }\n }\n return false;\n}\n\nfunction diffUpdateTrigger(props, oldProps, triggerName) {\n let newTriggers = props.updateTriggers[triggerName];\n newTriggers = newTriggers === undefined || newTriggers === null ? {} : newTriggers;\n let oldTriggers = oldProps.updateTriggers[triggerName];\n oldTriggers = oldTriggers === undefined || oldTriggers === null ? {} : oldTriggers;\n const diffReason = compareProps({\n oldProps: oldTriggers,\n newProps: newTriggers,\n triggerName\n });\n return diffReason;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst ERR_NOT_OBJECT = 'count(): argument not an object';\nconst ERR_NOT_CONTAINER = 'count(): argument not a container';\n\n/**\n * Deduces numer of elements in a JavaScript container.\n * - Auto-deduction for ES6 containers that define a count() method\n * - Auto-deduction for ES6 containers that define a size member\n * - Auto-deduction for Classic Arrays via the built-in length attribute\n * - Also handles objects, although note that this an O(N) operation\n */\nexport function count(container: any): number {\n if (!isObject(container)) {\n throw new Error(ERR_NOT_OBJECT);\n }\n\n // Check if ES6 collection \"count\" function is available\n if (typeof container.count === 'function') {\n return container.count();\n }\n\n // Check if ES6 collection \"size\" attribute is set\n if (Number.isFinite(container.size)) {\n return container.size;\n }\n\n // Check if array length attribute is set\n // Note: checking this last since some ES6 collections (Immutable.js)\n // emit profuse warnings when trying to access `length` attribute\n if (Number.isFinite(container.length)) {\n return container.length;\n }\n\n // Note that getting the count of an object is O(N)\n if (isPlainObject(container)) {\n return Object.keys(container).length;\n }\n\n throw new Error(ERR_NOT_CONTAINER);\n}\n\n/**\n * Checks if argument is a plain object (not a class or array etc)\n * @param {*} value - JavaScript value to be tested\n * @return {Boolean} - true if argument is a plain JavaScript object\n */\nfunction isPlainObject(value) {\n return value !== null && typeof value === 'object' && value.constructor === Object;\n}\n\n/**\n * Checks if argument is an indexable object (not a primitive value, nor null)\n * @param {*} value - JavaScript value to be tested\n * @return {Boolean} - true if argument is a JavaScript object\n */\nfunction isObject(value) {\n return value !== null && typeof value === 'object';\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// Merge two luma.gl shader descriptors\nexport function mergeShaders(target, source) {\n if (!source) {\n return target;\n }\n const result = {...target, ...source};\n\n if ('defines' in source) {\n result.defines = {...target.defines, ...source.defines};\n }\n if ('modules' in source) {\n result.modules = (target.modules || []).concat(source.modules);\n\n // Hack: prject32 and project64 cannot co-exist\n if (source.modules.some(module => module.name === 'project64')) {\n const index = result.modules.findIndex(module => module.name === 'project32');\n if (index >= 0) {\n result.modules.splice(index, 1);\n }\n }\n }\n if ('inject' in source) {\n if (!target.inject) {\n result.inject = source.inject;\n } else {\n const mergedInjection = {...target.inject};\n for (const key in source.inject) {\n mergedInjection[key] = (mergedInjection[key] || '') + source.inject[key];\n }\n result.inject = mergedInjection;\n }\n }\n return result;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Device, Texture, SamplerProps} from '@luma.gl/core';\n\nconst DEFAULT_TEXTURE_PARAMETERS: SamplerProps = {\n minFilter: 'linear',\n mipmapFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n};\n\n// Track the textures that are created by us. They need to be released when they are no longer used.\nconst internalTextures: Record = {};\n\n/**\n *\n * @param owner\n * @param device\n * @param image could be one of:\n * - Texture\n * - Browser object: Image, ImageData, ImageData, HTMLCanvasElement, HTMLVideoElement, ImageBitmap\n * - Plain object: {width: , height: , data: }\n * @param parameters\n * @returns\n */\nexport function createTexture(\n owner: string,\n device: Device,\n image: any,\n sampler: SamplerProps\n): Texture | null {\n if (image instanceof Texture) {\n return image;\n } else if (image.constructor && image.constructor.name !== 'Object') {\n // Browser object\n image = {data: image};\n }\n\n let samplerParameters: SamplerProps | null = null;\n if (image.compressed) {\n samplerParameters = {\n minFilter: 'linear',\n mipmapFilter: image.data.length > 1 ? 'nearest' : 'linear'\n };\n }\n\n const texture = device.createTexture({\n ...image,\n sampler: {\n ...DEFAULT_TEXTURE_PARAMETERS,\n ...samplerParameters,\n ...sampler\n },\n mipmaps: true\n });\n // Track this texture\n internalTextures[texture.id] = owner;\n return texture;\n}\n\nexport function destroyTexture(owner: string, texture: Texture) {\n if (!texture || !(texture instanceof Texture)) {\n return;\n }\n // Only delete the texture if requested by the same layer that created it\n if (internalTextures[texture.id] === owner) {\n texture.delete();\n delete internalTextures[texture.id];\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {createTexture, destroyTexture} from '../utils/texture';\nimport {deepEqual} from '../utils/deep-equal';\n\nimport type Component from './component';\nimport type {Color, TextureSource} from '../types/layer-props';\nimport type Layer from '../lib/layer';\nimport type {SamplerProps} from '@luma.gl/core';\n\ntype BasePropType = {\n value: ValueT;\n async?: boolean;\n validate?: (value: any, propType: PropType) => boolean;\n equal?: (value1: ValueT, value2: ValueT, propType: PropType) => boolean;\n};\n\n/**\n * Normalized prop type definition\n */\nexport type PropType = BasePropType & {\n type: string;\n name: string;\n transform?: (value: any, propType: PropType, component: Component) => any;\n release?: (value: any, propType: PropType, component: Component) => void;\n};\n\ntype DefaultProp =\n | T\n | DeprecatedProp\n | BooleanPropType\n | NumberPropType\n | ColorPropType\n | ImagePropType\n | DataPropType\n | ArrayPropType\n | ObjectPropType\n | AccessorPropType\n | FunctionPropType;\n\nexport type DefaultProps = {\n [propName in keyof PropsT]?: DefaultProp[propName]>;\n};\n\ntype BooleanPropType = BasePropType & {\n type: 'boolean';\n};\ntype NumberPropType = BasePropType & {\n type: 'number';\n min?: number;\n max?: number;\n};\ntype ColorPropType = BasePropType & {\n type: 'color';\n optional?: boolean;\n};\ntype ArrayPropType = BasePropType & {\n type: 'array';\n optional?: boolean;\n /** Ignore change in the prop value.\n * @default false\n */\n ignore?: boolean;\n /** Deep-compare two prop values. Only used if `ignore: false`.\n * When a number is supplied, used as the depth of deep-comparison. 0 is equivalent to shallow comparison, -1 is infinite depth\n * When a boolean is supplied, `true` is equivalent to `1` (shallow compare all child fields)\n * @default false\n */\n compare?: boolean | number;\n};\ntype AccessorPropType = BasePropType & {\n type: 'accessor';\n};\ntype FunctionPropType = BasePropType & {\n type: 'function';\n optional?: boolean;\n /** @deprecated use `ignore` instead */\n compare?: boolean;\n /** Ignore change in the prop value.\n * @default true\n */\n ignore?: boolean;\n};\ntype DataPropType = BasePropType & {\n type: 'data';\n};\ntype ImagePropType = BasePropType & {\n type: 'image';\n parameters?: SamplerProps;\n};\ntype ObjectPropType = BasePropType & {\n type: 'object';\n optional?: boolean;\n /** Ignore change in the prop value.\n * @default false\n */\n ignore?: boolean;\n /** Deep-compare two prop values. Only used if `ignore: false`.\n * When a number is supplied, used as the depth of deep-comparison. 0 is equivalent to shallow comparison, -1 is infinite depth\n * When a boolean is supplied, `true` is equivalent to `1` (shallow compare all child fields)\n * @default false\n */\n compare?: boolean | number;\n};\ntype DeprecatedProp = {\n deprecatedFor?: string | string[];\n};\ntype PropTypeDef =\n | DeprecatedProp\n | boolean\n | BooleanPropType\n | number\n | NumberPropType\n | string\n | DataPropType\n | number[]\n | ColorPropType\n | ArrayPropType\n | AccessorPropType\n | FunctionPropType\n | ImagePropType\n | ObjectPropType\n | null;\n\nconst TYPE_DEFINITIONS = {\n boolean: {\n validate(value, propType: BooleanPropType) {\n return true;\n },\n equal(value1, value2, propType: BooleanPropType) {\n return Boolean(value1) === Boolean(value2);\n }\n },\n number: {\n validate(value, propType: NumberPropType) {\n return (\n Number.isFinite(value) &&\n (!('max' in propType) || value <= propType.max!) &&\n (!('min' in propType) || value >= propType.min!)\n );\n }\n },\n color: {\n validate(value, propType: ColorPropType) {\n return (\n (propType.optional && !value) ||\n (isArray(value) && (value.length === 3 || value.length === 4))\n );\n },\n equal(value1, value2, propType: ColorPropType) {\n return deepEqual(value1, value2, 1);\n }\n },\n accessor: {\n validate(value, propType: AccessorPropType) {\n const valueType = getTypeOf(value);\n return valueType === 'function' || valueType === getTypeOf(propType.value);\n },\n equal(value1, value2, propType: AccessorPropType) {\n if (typeof value2 === 'function') {\n return true;\n }\n return deepEqual(value1, value2, 1);\n }\n },\n array: {\n validate(value, propType: ArrayPropType) {\n return (propType.optional && !value) || isArray(value);\n },\n equal(value1, value2, propType: ArrayPropType) {\n const {compare} = propType;\n const depth = Number.isInteger(compare as unknown) ? (compare as number) : compare ? 1 : 0;\n return compare ? deepEqual(value1, value2, depth) : value1 === value2;\n }\n },\n object: {\n equal(value1, value2, propType: ObjectPropType) {\n if (propType.ignore) {\n return true;\n }\n const {compare} = propType;\n const depth = Number.isInteger(compare as unknown) ? (compare as number) : compare ? 1 : 0;\n return compare ? deepEqual(value1, value2, depth) : value1 === value2;\n }\n },\n function: {\n validate(value, propType: FunctionPropType) {\n return (propType.optional && !value) || typeof value === 'function';\n },\n equal(value1, value2, propType: FunctionPropType) {\n // Backward compatibility - {compare: true} and {ignore: false} are equivalent\n const shouldIgnore = !propType.compare && propType.ignore !== false;\n return shouldIgnore || value1 === value2;\n }\n },\n data: {\n transform: (value, propType: DataPropType, component) => {\n if (!value) {\n return value;\n }\n const {dataTransform} = component.props;\n if (dataTransform) {\n return dataTransform(value);\n }\n // Detect loaders.gl v4 table format\n if (\n typeof value.shape === 'string' &&\n value.shape.endsWith('-table') &&\n Array.isArray(value.data)\n ) {\n return value.data;\n }\n return value;\n }\n },\n image: {\n transform: (value, propType: ImagePropType, component) => {\n const context = (component as Layer).context;\n if (!context || !context.device) {\n return null;\n }\n return createTexture(component.id, context.device, value, {\n ...propType.parameters,\n ...component.props.textureParameters\n });\n },\n release: (value, propType: ImagePropType, component) => {\n destroyTexture(component.id, value);\n }\n }\n} as const;\n\nexport function parsePropTypes(propDefs: Record): {\n propTypes: Record;\n defaultProps: Record;\n deprecatedProps: Record;\n} {\n const propTypes = {};\n const defaultProps = {};\n const deprecatedProps = {};\n\n for (const [propName, propDef] of Object.entries(propDefs)) {\n const deprecated = (propDef as DeprecatedProp)?.deprecatedFor;\n if (deprecated) {\n deprecatedProps[propName] = Array.isArray(deprecated) ? deprecated : [deprecated];\n } else {\n const propType = parsePropType(propName, propDef);\n propTypes[propName] = propType;\n defaultProps[propName] = propType.value;\n }\n }\n return {propTypes, defaultProps, deprecatedProps};\n}\n\n// Parses one property definition entry. Either contains:\n// * a valid prop type object ({type, ...})\n// * or just a default value, in which case type and name inference is used\nfunction parsePropType(name: string, propDef: PropTypeDef): PropType {\n switch (getTypeOf(propDef)) {\n case 'object':\n return normalizePropDefinition(name, propDef);\n\n case 'array':\n return normalizePropDefinition(name, {type: 'array', value: propDef, compare: false});\n\n case 'boolean':\n return normalizePropDefinition(name, {type: 'boolean', value: propDef});\n\n case 'number':\n return normalizePropDefinition(name, {type: 'number', value: propDef});\n\n case 'function':\n // return guessFunctionType(name, propDef);\n return normalizePropDefinition(name, {type: 'function', value: propDef, compare: true});\n\n default:\n return {name, type: 'unknown', value: propDef};\n }\n}\n\nfunction normalizePropDefinition(name, propDef): PropType {\n if (!('type' in propDef)) {\n if (!('value' in propDef)) {\n // If no type and value this object is likely the value\n return {name, type: 'object', value: propDef};\n }\n return {name, type: getTypeOf(propDef.value), ...propDef};\n }\n return {name, ...TYPE_DEFINITIONS[propDef.type], ...propDef};\n}\n\nfunction isArray(value: any): boolean {\n return Array.isArray(value) || ArrayBuffer.isView(value);\n}\n\n// improved version of javascript typeof that can distinguish arrays and null values\nfunction getTypeOf(value: any): string {\n if (isArray(value)) {\n return 'array';\n }\n if (value === null) {\n return 'null';\n }\n return typeof value;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport log from '../utils/log';\nimport {isAsyncIterable} from '../utils/iterable-utils';\nimport {parsePropTypes} from './prop-types';\nimport {\n COMPONENT_SYMBOL,\n PROP_TYPES_SYMBOL,\n DEPRECATED_PROPS_SYMBOL,\n ASYNC_ORIGINAL_SYMBOL,\n ASYNC_RESOLVED_SYMBOL,\n ASYNC_DEFAULTS_SYMBOL\n} from './constants';\nimport {StatefulComponentProps} from './component';\nimport Component from './component';\n\n// Create a property object\nexport function createProps(\n component: Component,\n propObjects: Partial[]\n): StatefulComponentProps {\n // Resolve extension value\n let extensions: any[] | undefined;\n for (let i = propObjects.length - 1; i >= 0; i--) {\n const props = propObjects[i];\n if ('extensions' in props) {\n // @ts-expect-error TS(2339) extensions not defined\n extensions = props.extensions;\n }\n }\n\n // Create a new prop object with empty default props object\n const propsPrototype = getPropsPrototype(component.constructor, extensions);\n // The true default props object will be found later\n const propsInstance = Object.create(propsPrototype);\n\n // Props need a back pointer to the owning component\n propsInstance[COMPONENT_SYMBOL] = component;\n // The supplied (original) values for those async props that are set to url strings or Promises.\n // In this case, the actual (i.e. resolved) values are looked up from component.internalState\n propsInstance[ASYNC_ORIGINAL_SYMBOL] = {};\n // Note: the actual (resolved) values for props that are NOT set to urls or Promises.\n // in this case the values are served directly from this map\n propsInstance[ASYNC_RESOLVED_SYMBOL] = {};\n\n // \"Copy\" all sync props\n for (let i = 0; i < propObjects.length; ++i) {\n const props = propObjects[i];\n // Do not use Object.assign here to avoid Symbols in props overwriting our private fields\n // This might happen if one of the arguments is another props instance\n for (const key in props) {\n propsInstance[key] = props[key];\n }\n }\n\n // Props must be immutable\n Object.freeze(propsInstance);\n\n return propsInstance;\n}\n\nconst MergedDefaultPropsCacheKey = '_mergedDefaultProps';\n\n// Return precalculated defaultProps and propType objects if available\n// build them if needed\nfunction getPropsPrototype(componentClass, extensions?: any[]) {\n // Bail out if we're not looking at a component - for two reasons:\n // 1. There's no reason for an ancestor of component to have props\n // 2. If we don't bail out, we'll follow the prototype chain all the way back to the global\n // function prototype and add _mergedDefaultProps to it, which may break other frameworks\n // (e.g. the react-three-fiber reconciler)\n if (!(componentClass instanceof Component.constructor)) return {};\n\n // A string that uniquely identifies the extensions involved\n let cacheKey = MergedDefaultPropsCacheKey;\n if (extensions) {\n for (const extension of extensions) {\n const ExtensionClass = extension.constructor;\n if (ExtensionClass) {\n cacheKey += `:${ExtensionClass.extensionName || ExtensionClass.name}`;\n }\n }\n }\n\n const defaultProps = getOwnProperty(componentClass, cacheKey);\n if (!defaultProps) {\n return (componentClass[cacheKey] = createPropsPrototypeAndTypes(\n componentClass,\n extensions || []\n ));\n }\n return defaultProps;\n}\n\n// Build defaultProps and propType objects by walking component prototype chain\nfunction createPropsPrototypeAndTypes(\n componentClass,\n extensions: any[]\n): Record | null {\n const parent = componentClass.prototype;\n if (!parent) {\n return null;\n }\n\n const parentClass = Object.getPrototypeOf(componentClass);\n const parentDefaultProps = getPropsPrototype(parentClass);\n\n // Parse propTypes from Component.defaultProps\n const componentDefaultProps = getOwnProperty(componentClass, 'defaultProps') || {};\n const componentPropDefs = parsePropTypes(componentDefaultProps);\n\n // Merged default props object. Order: parent, self, extensions\n const defaultProps: any = Object.assign(\n Object.create(null),\n parentDefaultProps,\n componentPropDefs.defaultProps\n );\n // Merged prop type definitions. Order: parent, self, extensions\n const propTypes = Object.assign(\n Object.create(null),\n parentDefaultProps?.[PROP_TYPES_SYMBOL],\n componentPropDefs.propTypes\n );\n // Merged deprecation list. Order: parent, self, extensions\n const deprecatedProps = Object.assign(\n Object.create(null),\n parentDefaultProps?.[DEPRECATED_PROPS_SYMBOL],\n componentPropDefs.deprecatedProps\n );\n\n for (const extension of extensions) {\n const extensionDefaultProps = getPropsPrototype(extension.constructor);\n if (extensionDefaultProps) {\n Object.assign(defaultProps, extensionDefaultProps);\n Object.assign(propTypes, extensionDefaultProps[PROP_TYPES_SYMBOL]);\n Object.assign(deprecatedProps, extensionDefaultProps[DEPRECATED_PROPS_SYMBOL]);\n }\n }\n\n // Create any necessary property descriptors and create the default prop object\n // Assign merged default props\n createPropsPrototype(defaultProps, componentClass);\n\n // Add getters/setters for async props\n addAsyncPropsToPropPrototype(defaultProps, propTypes);\n\n // Add setters for deprecated props\n addDeprecatedPropsToPropPrototype(defaultProps, deprecatedProps);\n\n // Store the precalculated props\n defaultProps[PROP_TYPES_SYMBOL] = propTypes;\n defaultProps[DEPRECATED_PROPS_SYMBOL] = deprecatedProps;\n\n // Backwards compatibility\n // TODO: remove access of hidden property from the rest of the code base\n if (extensions.length === 0 && !hasOwnProperty(componentClass, '_propTypes')) {\n componentClass._propTypes = propTypes;\n }\n return defaultProps;\n}\n\n// Builds a pre-merged default props object that component props can inherit from\nfunction createPropsPrototype(defaultProps, componentClass) {\n // Avoid freezing `id` prop\n const id = getComponentName(componentClass);\n\n Object.defineProperties(defaultProps, {\n // `id` is treated specially because layer might need to override it\n id: {\n writable: true,\n value: id\n }\n });\n}\n\nfunction addDeprecatedPropsToPropPrototype(defaultProps, deprecatedProps) {\n for (const propName in deprecatedProps) {\n /* eslint-disable accessor-pairs */\n Object.defineProperty(defaultProps, propName, {\n enumerable: false,\n set(newValue) {\n const nameStr = `${this.id}: ${propName}`;\n\n for (const newPropName of deprecatedProps[propName]) {\n if (!hasOwnProperty(this, newPropName)) {\n this[newPropName] = newValue;\n }\n }\n\n log.deprecated(nameStr, deprecatedProps[propName].join('/'))();\n }\n });\n /* eslint-enable accessor-pairs */\n }\n}\n\n// Create descriptors for overridable props\nfunction addAsyncPropsToPropPrototype(defaultProps, propTypes) {\n const defaultValues = {};\n\n const descriptors = {};\n\n // Move async props into shadow values\n for (const propName in propTypes) {\n const propType = propTypes[propName];\n const {name, value} = propType;\n\n // Note: async is ES7 keyword, can't destructure\n if (propType.async) {\n defaultValues[name] = value;\n descriptors[name] = getDescriptorForAsyncProp(name);\n }\n }\n\n // Default \"resolved\" values for async props, returned if value not yet resolved/set.\n defaultProps[ASYNC_DEFAULTS_SYMBOL] = defaultValues;\n // Shadowed object, just to make sure \"early indexing\" into the instance does not fail\n defaultProps[ASYNC_ORIGINAL_SYMBOL] = {};\n\n Object.defineProperties(defaultProps, descriptors);\n}\n\n// Helper: Configures getter and setter for one async prop\nfunction getDescriptorForAsyncProp(name) {\n return {\n enumerable: true,\n // Save the provided value for async props in a special map\n set(newValue) {\n if (\n typeof newValue === 'string' ||\n newValue instanceof Promise ||\n isAsyncIterable(newValue)\n ) {\n this[ASYNC_ORIGINAL_SYMBOL][name] = newValue;\n } else {\n this[ASYNC_RESOLVED_SYMBOL][name] = newValue;\n }\n },\n // Only the component's state knows the true value of async prop\n get() {\n if (this[ASYNC_RESOLVED_SYMBOL]) {\n // Prop value isn't async, so just return it\n if (name in this[ASYNC_RESOLVED_SYMBOL]) {\n const value = this[ASYNC_RESOLVED_SYMBOL][name];\n\n return value || this[ASYNC_DEFAULTS_SYMBOL][name];\n }\n\n if (name in this[ASYNC_ORIGINAL_SYMBOL]) {\n // It's an async prop value: look into component state\n const state = this[COMPONENT_SYMBOL] && this[COMPONENT_SYMBOL].internalState;\n if (state && state.hasAsyncProp(name)) {\n return state.getAsyncProp(name) || this[ASYNC_DEFAULTS_SYMBOL][name];\n }\n }\n }\n\n // the prop is not supplied, or\n // component not yet initialized/matched, return the component's default value for the prop\n return this[ASYNC_DEFAULTS_SYMBOL][name];\n }\n };\n}\n\n// HELPER METHODS\n\nfunction hasOwnProperty(object, prop) {\n return Object.prototype.hasOwnProperty.call(object, prop);\n}\n\n// Constructors have their super class constructors as prototypes\nfunction getOwnProperty(object, prop) {\n return hasOwnProperty(object, prop) && object[prop];\n}\n\nfunction getComponentName(componentClass) {\n const componentName = componentClass.componentName;\n if (!componentName) {\n log.warn(`${componentClass.name}.componentName not specified`)();\n }\n return componentName || componentClass.name;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {\n COMPONENT_SYMBOL,\n PROP_TYPES_SYMBOL,\n ASYNC_ORIGINAL_SYMBOL,\n ASYNC_RESOLVED_SYMBOL,\n ASYNC_DEFAULTS_SYMBOL\n} from './constants';\nimport {PropType} from './prop-types';\nimport {createProps} from './create-props';\n\nlet counter = 0;\n\nexport type StatefulComponentProps = PropsT & {\n id: string;\n [COMPONENT_SYMBOL]: Component;\n [PROP_TYPES_SYMBOL]: Record;\n [ASYNC_DEFAULTS_SYMBOL]: Partial;\n [ASYNC_ORIGINAL_SYMBOL]: Partial;\n [ASYNC_RESOLVED_SYMBOL]: Partial;\n};\n\nexport default class Component {\n static componentName: string = 'Component';\n static defaultProps: Readonly<{}> = {};\n\n id: string;\n props: StatefulComponentProps;\n count: number;\n\n constructor(...propObjects: Partial[]) {\n // Merge supplied props with default props and freeze them.\n /* eslint-disable prefer-spread */\n this.props = createProps(this, propObjects);\n /* eslint-enable prefer-spread */\n\n this.id = this.props.id; // The layer's id, used for matching with layers from last render cycle\n this.count = counter++; // Keep track of how many layer instances you are generating\n }\n\n // clone this layer with modified props\n clone(newProps: Partial) {\n const {props} = this;\n\n // Async props cannot be copied with Object.assign, copy them separately\n const asyncProps: Partial = {};\n\n // See async props definition in create-props.js\n for (const key in props[ASYNC_DEFAULTS_SYMBOL]) {\n if (key in props[ASYNC_RESOLVED_SYMBOL]) {\n asyncProps[key] = props[ASYNC_RESOLVED_SYMBOL][key];\n } else if (key in props[ASYNC_ORIGINAL_SYMBOL]) {\n asyncProps[key] = props[ASYNC_ORIGINAL_SYMBOL][key];\n }\n }\n\n // Some custom layer implementation may not support multiple arguments in the constructor\n // @ts-ignore\n return new this.constructor({...props, ...asyncProps, ...newProps});\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {isAsyncIterable} from '../utils/iterable-utils';\nimport {\n COMPONENT_SYMBOL,\n PROP_TYPES_SYMBOL,\n ASYNC_ORIGINAL_SYMBOL,\n ASYNC_RESOLVED_SYMBOL,\n ASYNC_DEFAULTS_SYMBOL\n} from './constants';\nimport type Component from './component';\nimport {PropType} from './prop-types';\n\nconst EMPTY_PROPS = Object.freeze({});\n\n/** Internal state of an async prop */\ntype AsyncPropState = {\n /** The prop type definition from component.defaultProps, if exists */\n type: PropType | null;\n /** Supplied prop value (can be url/promise, not visible to the component) */\n lastValue: any;\n /** Resolved prop value (valid data, can be \"shown\" to the component) */\n resolvedValue: any;\n /** How many loads have been issued */\n pendingLoadCount: number;\n /** Latest resolved load, (earlier loads will be ignored) */\n resolvedLoadCount: number;\n};\n\nexport default class ComponentState {\n /** The component that this state instance belongs to. `null` if this state has been finalized. */\n component: ComponentT | null;\n onAsyncPropUpdated: (propName: string, value: any) => void;\n\n private asyncProps: Partial>;\n private oldProps: ComponentT['props'] | null;\n private oldAsyncProps: ComponentT['props'] | null;\n\n constructor(component: ComponentT) {\n this.component = component;\n this.asyncProps = {}; // Prop values that the layer sees\n this.onAsyncPropUpdated = () => {};\n this.oldProps = null; // Last props before update\n this.oldAsyncProps = null; // Last props before update, with async values copied.\n }\n\n finalize() {\n for (const propName in this.asyncProps) {\n const asyncProp = this.asyncProps[propName];\n if (asyncProp && asyncProp.type && asyncProp.type.release) {\n // Release any resources created by transforms\n asyncProp.type.release(\n asyncProp.resolvedValue,\n asyncProp.type,\n this.component as Component\n );\n }\n }\n this.asyncProps = {};\n this.component = null;\n this.resetOldProps();\n }\n\n /* Layer-facing props API */\n\n getOldProps(): ComponentT['props'] | typeof EMPTY_PROPS {\n return this.oldAsyncProps || this.oldProps || EMPTY_PROPS;\n }\n\n resetOldProps() {\n this.oldAsyncProps = null;\n this.oldProps = this.component ? this.component.props : null;\n }\n\n // Checks if a prop is overridden\n hasAsyncProp(propName: string): boolean {\n return propName in this.asyncProps;\n }\n\n // Returns value of an overriden prop\n getAsyncProp(propName: string): any {\n const asyncProp = this.asyncProps[propName];\n return asyncProp && asyncProp.resolvedValue;\n }\n\n isAsyncPropLoading(propName?: string): boolean {\n if (propName) {\n const asyncProp = this.asyncProps[propName];\n return Boolean(\n asyncProp &&\n asyncProp.pendingLoadCount > 0 &&\n asyncProp.pendingLoadCount !== asyncProp.resolvedLoadCount\n );\n }\n for (const key in this.asyncProps) {\n if (this.isAsyncPropLoading(key)) {\n return true;\n }\n }\n return false;\n }\n\n // Without changing the original prop value, swap out the data resolution under the hood\n reloadAsyncProp(propName: string, value: any) {\n this._watchPromise(propName, Promise.resolve(value));\n }\n\n // Updates all async/overridden props (when new props come in)\n // Checks if urls have changed, starts loading, or removes override\n setAsyncProps(props: ComponentT['props']) {\n this.component = (props[COMPONENT_SYMBOL] as ComponentT) || this.component;\n\n // NOTE: prop param and default values are only support for testing\n const resolvedValues = props[ASYNC_RESOLVED_SYMBOL] || {};\n const originalValues = props[ASYNC_ORIGINAL_SYMBOL] || props;\n const defaultValues = props[ASYNC_DEFAULTS_SYMBOL] || {};\n\n // TODO - use async props from the layer's prop types\n for (const propName in resolvedValues) {\n const value = resolvedValues[propName];\n this._createAsyncPropData(propName, defaultValues[propName]);\n this._updateAsyncProp(propName, value);\n // Use transformed value\n resolvedValues[propName] = this.getAsyncProp(propName);\n }\n\n for (const propName in originalValues) {\n const value = originalValues[propName];\n // Makes sure a record exists for this prop\n this._createAsyncPropData(propName, defaultValues[propName]);\n this._updateAsyncProp(propName, value);\n }\n }\n\n /* Placeholder methods for subclassing */\n\n protected _fetch(propName: string, url: string): any {\n return null;\n }\n\n protected _onResolve(propName: string, value: any) {} // eslint-disable-line @typescript-eslint/no-empty-function\n\n protected _onError(propName: string, error: Error) {} // eslint-disable-line @typescript-eslint/no-empty-function\n\n // Intercept strings (URLs) and Promises and activates loading and prop rewriting\n private _updateAsyncProp(propName: string, value: any) {\n if (!this._didAsyncInputValueChange(propName, value)) {\n return;\n }\n\n // interpret value string as url and start a new load tracked by a promise\n if (typeof value === 'string') {\n value = this._fetch(propName, value);\n }\n\n // interprets promise and track the \"loading\"\n if (value instanceof Promise) {\n this._watchPromise(propName, value);\n return;\n }\n\n if (isAsyncIterable(value)) {\n this._resolveAsyncIterable(propName, value); // eslint-disable-line @typescript-eslint/no-floating-promises\n return;\n }\n\n // else, normal, non-async value. Just store value for now\n this._setPropValue(propName, value);\n }\n\n // Whenever async props are changing, we need to make a copy of oldProps\n // otherwise the prop rewriting will affect the value both in props and oldProps.\n // While the copy is relatively expensive, this only happens on load completion.\n private _freezeAsyncOldProps() {\n if (!this.oldAsyncProps && this.oldProps) {\n // 1. inherit all synchronous props from oldProps\n // 2. reconfigure the async prop descriptors to fixed values\n this.oldAsyncProps = Object.create(this.oldProps);\n for (const propName in this.asyncProps) {\n Object.defineProperty(this.oldAsyncProps, propName, {\n enumerable: true,\n value: this.oldProps[propName]\n });\n }\n }\n }\n\n // Checks if an input value actually changed (to avoid reloading/rewatching promises/urls)\n private _didAsyncInputValueChange(propName: string, value: any): boolean {\n // @ts-ignore\n const asyncProp: AsyncPropState = this.asyncProps[propName];\n if (value === asyncProp.resolvedValue || value === asyncProp.lastValue) {\n return false;\n }\n asyncProp.lastValue = value;\n return true;\n }\n\n // Set normal, non-async value\n private _setPropValue(propName: string, value: any) {\n // Save the current value before overwriting so that diffProps can access both\n this._freezeAsyncOldProps();\n\n const asyncProp = this.asyncProps[propName];\n if (asyncProp) {\n value = this._postProcessValue(asyncProp, value);\n asyncProp.resolvedValue = value;\n asyncProp.pendingLoadCount++;\n asyncProp.resolvedLoadCount = asyncProp.pendingLoadCount;\n }\n }\n\n // Set a just resolved async value, calling onAsyncPropUpdates if value changes asynchronously\n private _setAsyncPropValue(propName: string, value: any, loadCount: number) {\n // Only update if loadCount is larger or equal to resolvedLoadCount\n // otherwise a more recent load has already completed\n const asyncProp = this.asyncProps[propName];\n if (asyncProp && loadCount >= asyncProp.resolvedLoadCount && value !== undefined) {\n // Save the current value before overwriting so that diffProps can access both\n this._freezeAsyncOldProps();\n\n asyncProp.resolvedValue = value;\n asyncProp.resolvedLoadCount = loadCount;\n\n // Call callback to inform listener\n this.onAsyncPropUpdated(propName, value);\n }\n }\n\n // Tracks a promise, sets the prop when loaded, handles load count\n private _watchPromise(propName: string, promise: Promise) {\n const asyncProp = this.asyncProps[propName];\n if (asyncProp) {\n asyncProp.pendingLoadCount++;\n const loadCount = asyncProp.pendingLoadCount;\n promise\n .then(data => {\n if (!this.component) {\n // This component state has been finalized\n return;\n }\n data = this._postProcessValue(asyncProp, data);\n this._setAsyncPropValue(propName, data, loadCount);\n this._onResolve(propName, data);\n })\n .catch(error => {\n this._onError(propName, error);\n });\n }\n }\n\n private async _resolveAsyncIterable(\n propName: string,\n iterable: AsyncIterable\n ): Promise {\n if (propName !== 'data') {\n // we only support data as async iterable\n this._setPropValue(propName, iterable);\n return;\n }\n\n const asyncProp = this.asyncProps[propName];\n if (!asyncProp) {\n return;\n }\n\n asyncProp.pendingLoadCount++;\n const loadCount = asyncProp.pendingLoadCount;\n let data: any[] = [];\n let count = 0;\n\n for await (const chunk of iterable) {\n if (!this.component) {\n // This component state has been finalized\n return;\n }\n\n // @ts-expect-error (2339) dataTransform is not decared in base component props\n const {dataTransform} = this.component.props;\n if (dataTransform) {\n data = dataTransform(chunk, data) as any[];\n } else {\n data = data.concat(chunk);\n }\n\n // Used by the default _dataDiff function\n Object.defineProperty(data, '__diff', {\n enumerable: false,\n value: [{startRow: count, endRow: data.length}]\n });\n\n count = data.length;\n this._setAsyncPropValue(propName, data, loadCount);\n }\n\n this._onResolve(propName, data);\n }\n\n // Give the app a chance to post process the loaded data\n private _postProcessValue(asyncProp: AsyncPropState, value: any) {\n const propType = asyncProp.type;\n if (propType && this.component) {\n if (propType.release) {\n propType.release(asyncProp.resolvedValue, propType, this.component);\n }\n if (propType.transform) {\n return propType.transform(value, propType, this.component);\n }\n }\n return value;\n }\n\n // Creating an asyncProp record if needed\n private _createAsyncPropData(propName: string, defaultValue: any) {\n const asyncProp = this.asyncProps[propName];\n if (!asyncProp) {\n const propTypes = this.component && this.component.props[PROP_TYPES_SYMBOL];\n // assert(defaultValue !== undefined);\n this.asyncProps[propName] = {\n type: propTypes && propTypes[propName],\n lastValue: null,\n resolvedValue: defaultValue,\n pendingLoadCount: 0,\n resolvedLoadCount: 0\n };\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// deck.gl, MIT license\nimport ComponentState from '../lifecycle/component-state';\n\nimport type Layer from './layer';\nimport type AttributeManager from './attribute/attribute-manager';\nimport type Viewport from '../viewports/viewport';\nimport type UniformTransitionManager from './uniform-transition-manager';\n\nexport type ChangeFlags = {\n // Primary changeFlags, can be strings stating reason for change\n dataChanged: string | false | {startRow: number; endRow?: number}[];\n propsChanged: string | false;\n updateTriggersChanged: Record | false;\n extensionsChanged: boolean;\n viewportChanged: boolean;\n stateChanged: boolean;\n\n // Derived changeFlags\n propsOrDataChanged: boolean;\n somethingChanged: boolean;\n};\n\nexport default class LayerState extends ComponentState {\n attributeManager: AttributeManager | null;\n needsRedraw: boolean;\n needsUpdate: boolean;\n /**\n * Sublayers rendered in a previous cycle\n */\n subLayers: Layer[] | null;\n /**\n * If the layer is using the shared instancedPickingColors buffer\n */\n usesPickingColorCache: boolean;\n /**\n * If the layer has picking buffer (pickingColors or instancePickingColors)\n */\n hasPickingBuffer?: boolean;\n /**\n * Dirty flags of the layer's props and state\n */\n changeFlags!: ChangeFlags;\n\n /** The last viewport rendered by this layer */\n viewport?: Viewport;\n\n uniformTransitions!: UniformTransitionManager;\n /** Populated during uniform transition to replace user-supplied values */\n propsInTransition?: LayerT['props'];\n\n constructor({\n attributeManager,\n layer\n }: {\n attributeManager: AttributeManager | null;\n layer: LayerT;\n }) {\n super(layer);\n this.attributeManager = attributeManager;\n this.needsRedraw = true;\n this.needsUpdate = true;\n this.subLayers = null;\n this.usesPickingColorCache = false;\n }\n\n get layer(): LayerT | null {\n return this.component;\n }\n\n /* Override base Component methods with Layer-specific handling */\n\n protected _fetch(propName, url: string) {\n const layer = this.layer;\n const fetch = layer?.props.fetch;\n if (fetch) {\n return fetch(url, {propName, layer});\n }\n return super._fetch(propName, url);\n }\n\n protected _onResolve(propName: string, value: any) {\n const layer = this.layer;\n if (layer) {\n const onDataLoad = layer.props.onDataLoad;\n if (propName === 'data' && onDataLoad) {\n onDataLoad(value, {propName, layer});\n }\n }\n }\n\n protected _onError(propName: string, error: Error) {\n const layer = this.layer;\n if (layer) {\n layer.raiseError(error, `loading ${propName} of ${this.layer}`);\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Layer, {UpdateParameters} from './layer';\nimport debug from '../debug/index';\nimport {flatten} from '../utils/flatten';\n\nimport type AttributeManager from './attribute/attribute-manager';\nimport type {PickingInfo, GetPickingInfoParams} from './picking/pick-info';\nimport type {FilterContext} from '../passes/layers-pass';\nimport type {LayersList, LayerContext} from './layer-manager';\nimport type {CompositeLayerProps, Accessor, AccessorContext} from '../types/layer-props';\nimport {ConstructorOf} from '../types/types';\nimport {PROP_TYPES_SYMBOL} from '../lifecycle/constants';\n\nconst TRACE_RENDER_LAYERS = 'compositeLayer.renderLayers';\n\nexport default abstract class CompositeLayer extends Layer<\n PropsT & Required\n> {\n static layerName: string = 'CompositeLayer';\n\n /** `true` if this layer renders other layers */\n get isComposite(): boolean {\n return true;\n }\n\n /** `true` if the layer renders to screen */\n get isDrawable(): boolean {\n return false;\n }\n\n /** Returns true if all async resources are loaded */\n get isLoaded(): boolean {\n return super.isLoaded && this.getSubLayers().every(layer => layer.isLoaded);\n }\n\n /** Return last rendered sub layers */\n getSubLayers(): Layer[] {\n return (this.internalState && this.internalState.subLayers) || [];\n }\n\n // initializeState is usually not needed for composite layers\n // Provide empty definition to disable check for missing definition\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n initializeState(context: LayerContext): void {}\n\n /** Updates selected state members and marks the composite layer to need rerender */\n setState(updateObject: any): void {\n super.setState(updateObject);\n // Trigger a layer update\n // Although conceptually layer.draw and compositeLayer.renderLayers are equivalent,\n // they are executed during different lifecycles.\n // draw can be called without calling updateState (e.g. most viewport changes),\n // while renderLayers can only be called during a recursive layer update.\n this.setNeedsUpdate();\n }\n\n /** called to augment the info object that is bubbled up from a sublayer\n override Layer.getPickingInfo() because decoding / setting uniform do\n not apply to a composite layer. */\n getPickingInfo({info}: GetPickingInfoParams): PickingInfo {\n const {object} = info;\n const isDataWrapped =\n object && object.__source && object.__source.parent && object.__source.parent.id === this.id;\n\n if (!isDataWrapped) {\n return info;\n }\n\n // override object with picked data\n info.object = object.__source.object;\n info.index = object.__source.index;\n\n return info;\n }\n\n // Implement to generate subLayers\n abstract renderLayers(): Layer | null | LayersList;\n\n /**\n * Filters sub layers at draw time. Return true if the sub layer should be drawn.\n */\n filterSubLayer(context: FilterContext): boolean {\n return true;\n }\n\n /** Returns true if sub layer needs to be rendered */\n protected shouldRenderSubLayer(subLayerId: string, data: any): boolean {\n return data && data.length;\n }\n\n /** Returns sub layer class for a specific sublayer */\n protected getSubLayerClass(\n subLayerId: string,\n DefaultLayerClass: ConstructorOf\n ): ConstructorOf {\n const {_subLayerProps: overridingProps} = this.props;\n\n return (\n (overridingProps &&\n overridingProps[subLayerId] &&\n (overridingProps[subLayerId].type as ConstructorOf)) ||\n DefaultLayerClass\n );\n }\n\n /** When casting user data into another format to pass to sublayers,\n add reference to the original object and object index */\n protected getSubLayerRow(row: T, sourceObject: any, sourceObjectIndex: number): T {\n // @ts-ignore (TS2339) adding undefined property\n row.__source = {\n parent: this,\n object: sourceObject,\n index: sourceObjectIndex\n };\n return row;\n }\n\n /** Some composite layers cast user data into another format before passing to sublayers\n We need to unwrap them before calling the accessor so that they see the original data\n objects */\n protected getSubLayerAccessor(accessor: Accessor): Accessor {\n if (typeof accessor === 'function') {\n const objectInfo: AccessorContext = {\n index: -1,\n // @ts-ignore accessing resolved data\n data: this.props.data,\n target: []\n };\n return (x: any, i: AccessorContext) => {\n if (x && x.__source) {\n objectInfo.index = x.__source.index;\n // @ts-ignore (TS2349) Out is never a function\n return accessor(x.__source.object as In, objectInfo);\n }\n // @ts-ignore (TS2349) Out is never a function\n return accessor(x as In, i);\n };\n }\n return accessor;\n }\n\n /** Returns sub layer props for a specific sublayer */\n // eslint-disable-next-line complexity\n protected getSubLayerProps(\n sublayerProps: {\n id?: string;\n updateTriggers?: Record;\n [propName: string]: any;\n } = {}\n ): any {\n const {\n opacity,\n pickable,\n visible,\n parameters,\n getPolygonOffset,\n highlightedObjectIndex,\n autoHighlight,\n highlightColor,\n coordinateSystem,\n coordinateOrigin,\n wrapLongitude,\n positionFormat,\n modelMatrix,\n extensions,\n fetch,\n operation,\n _subLayerProps: overridingProps\n } = this.props;\n const newProps = {\n id: '',\n updateTriggers: {},\n opacity,\n pickable,\n visible,\n parameters,\n getPolygonOffset,\n highlightedObjectIndex,\n autoHighlight,\n highlightColor,\n coordinateSystem,\n coordinateOrigin,\n wrapLongitude,\n positionFormat,\n modelMatrix,\n extensions,\n fetch,\n operation\n };\n\n const overridingSublayerProps =\n overridingProps && sublayerProps.id && overridingProps[sublayerProps.id];\n const overridingSublayerTriggers =\n overridingSublayerProps && overridingSublayerProps.updateTriggers;\n const sublayerId = sublayerProps.id || 'sublayer';\n\n if (overridingSublayerProps) {\n const propTypes = this.props[PROP_TYPES_SYMBOL];\n const subLayerPropTypes = sublayerProps.type ? sublayerProps.type._propTypes : {};\n for (const key in overridingSublayerProps) {\n const propType = subLayerPropTypes[key] || propTypes[key];\n // eslint-disable-next-line\n if (propType && propType.type === 'accessor') {\n overridingSublayerProps[key] = this.getSubLayerAccessor(overridingSublayerProps[key]);\n }\n }\n }\n\n Object.assign(\n newProps,\n sublayerProps,\n // experimental feature that allows users to override sublayer props via parent layer prop\n overridingSublayerProps\n );\n newProps.id = `${this.props.id}-${sublayerId}`;\n newProps.updateTriggers = {\n all: this.props.updateTriggers?.all,\n ...sublayerProps.updateTriggers,\n ...overridingSublayerTriggers\n };\n\n // Pass through extension props\n // @ts-ignore (TS2532) extensions is always defined after merging with default props\n for (const extension of extensions) {\n const passThroughProps = extension.getSubLayerProps.call(this, extension);\n if (passThroughProps) {\n Object.assign(newProps, passThroughProps, {\n updateTriggers: Object.assign(newProps.updateTriggers, passThroughProps.updateTriggers)\n });\n }\n }\n\n return newProps;\n }\n\n /** Update sub layers to highlight the hovered object */\n protected _updateAutoHighlight(info: PickingInfo): void {\n for (const layer of this.getSubLayers()) {\n layer.updateAutoHighlight(info);\n }\n }\n\n /** Override base Layer method */\n protected _getAttributeManager(): AttributeManager | null {\n return null;\n }\n\n /** (Internal) Called after an update to rerender sub layers */\n protected _postUpdate(updateParams: UpdateParameters, forceUpdate: boolean) {\n // @ts-ignore (TS2531) this method is only called internally when internalState is defined\n let subLayers = this.internalState.subLayers as Layer[];\n const shouldUpdate = !subLayers || this.needsUpdate();\n if (shouldUpdate) {\n const subLayersList = this.renderLayers();\n // Flatten the returned array, removing any null, undefined or false\n // this allows layers to render sublayers conditionally\n // (see CompositeLayer.renderLayers docs)\n subLayers = flatten(subLayersList, Boolean) as Layer[];\n // @ts-ignore (TS2531) this method is only called internally when internalState is defined\n this.internalState.subLayers = subLayers;\n }\n debug(TRACE_RENDER_LAYERS, this, shouldUpdate, subLayers);\n\n // populate reference to parent layer (this layer)\n // NOTE: needs to be done even when reusing layers as the parent may have changed\n for (const layer of subLayers) {\n layer.parent = this;\n }\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Matrix4} from '@math.gl/core';\nimport Viewport from './viewport';\nimport {PROJECTION_MODE} from '../lib/constants';\nimport {altitudeToFovy, fovyToAltitude} from '@math.gl/web-mercator';\nimport {MAX_LATITUDE} from '@math.gl/web-mercator';\n\nimport {vec3, vec4} from '@math.gl/core';\n\nconst DEGREES_TO_RADIANS = Math.PI / 180;\nconst RADIANS_TO_DEGREES = 180 / Math.PI;\nconst EARTH_RADIUS = 6370972;\nconst GLOBE_RADIUS = 256;\n\nfunction getDistanceScales() {\n const unitsPerMeter = GLOBE_RADIUS / EARTH_RADIUS;\n const unitsPerDegree = (Math.PI / 180) * GLOBE_RADIUS;\n\n return {\n unitsPerMeter: [unitsPerMeter, unitsPerMeter, unitsPerMeter],\n unitsPerMeter2: [0, 0, 0],\n metersPerUnit: [1 / unitsPerMeter, 1 / unitsPerMeter, 1 / unitsPerMeter],\n unitsPerDegree: [unitsPerDegree, unitsPerDegree, unitsPerMeter],\n unitsPerDegree2: [0, 0, 0],\n degreesPerUnit: [1 / unitsPerDegree, 1 / unitsPerDegree, 1 / unitsPerMeter]\n };\n}\n\nexport type GlobeViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** Longitude in degrees */\n longitude?: number;\n /** Latitude in degrees */\n latitude?: number;\n /** Camera altitude relative to the viewport height, used to control the FOV. Default `1.5` */\n altitude?: number;\n /* Meter offsets of the viewport center from lng, lat */\n position?: number[];\n /** Zoom level */\n zoom?: number;\n /** Use orthographic projection */\n orthographic?: boolean;\n /** Camera fovy in degrees. If provided, overrides `altitude` */\n fovy?: number;\n /** Scaler for the near plane, 1 unit equals to the height of the viewport. Default `0.5` */\n nearZMultiplier?: number;\n /** Scaler for the far plane, 1 unit equals to the distance from the camera to the edge of the screen. Default `1` */\n farZMultiplier?: number;\n /** Optionally override the near plane position. `nearZMultiplier` is ignored if `nearZ` is supplied. */\n nearZ?: number;\n /** Optionally override the far plane position. `farZMultiplier` is ignored if `farZ` is supplied. */\n farZ?: number;\n /** The resolution at which to turn flat features into 3D meshes, in degrees. Smaller numbers will generate more detailed mesh. Default `10` */\n resolution?: number;\n};\n\nexport default class GlobeViewport extends Viewport {\n longitude!: number;\n latitude!: number;\n resolution!: number;\n\n constructor(opts: GlobeViewportOptions = {}) {\n const {\n longitude = 0,\n zoom = 0,\n // Matches Maplibre defaults\n // https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L632-L633\n nearZMultiplier = 0.5,\n farZMultiplier = 1,\n resolution = 10\n } = opts;\n\n let {latitude = 0, height, altitude = 1.5, fovy} = opts;\n\n // Clamp to web mercator limit to prevent bad inputs\n latitude = Math.max(Math.min(latitude, MAX_LATITUDE), -MAX_LATITUDE);\n\n height = height || 1;\n if (fovy) {\n altitude = fovyToAltitude(fovy);\n } else {\n fovy = altitudeToFovy(altitude);\n }\n // Exagerate distance by latitude to match the Web Mercator distortion\n // The goal is that globe and web mercator projection results converge at high zoom\n // https://github.com/maplibre/maplibre-gl-js/blob/f8ab4b48d59ab8fe7b068b102538793bbdd4c848/src/geo/projection/globe_transform.ts#L575-L577\n const scaleAdjust = 1 / Math.PI / Math.cos((latitude * Math.PI) / 180);\n const scale = Math.pow(2, zoom) * scaleAdjust;\n const nearZ = opts.nearZ ?? nearZMultiplier;\n const farZ = opts.farZ ?? (altitude + (GLOBE_RADIUS * 2 * scale) / height) * farZMultiplier;\n\n // Calculate view matrix\n const viewMatrix = new Matrix4().lookAt({eye: [0, -altitude, 0], up: [0, 0, 1]});\n viewMatrix.rotateX(latitude * DEGREES_TO_RADIANS);\n viewMatrix.rotateZ(-longitude * DEGREES_TO_RADIANS);\n viewMatrix.scale(scale / height);\n\n super({\n ...opts,\n // x, y, width,\n height,\n\n // view matrix\n viewMatrix,\n longitude,\n latitude,\n zoom,\n\n // projection matrix parameters\n distanceScales: getDistanceScales(),\n fovy,\n focalDistance: altitude,\n near: nearZ,\n far: farZ\n });\n\n this.scale = scale;\n this.latitude = latitude;\n this.longitude = longitude;\n this.resolution = resolution;\n }\n\n get projectionMode() {\n return PROJECTION_MODE.GLOBE;\n }\n\n getDistanceScales() {\n return this.distanceScales;\n }\n\n getBounds(options: {z?: number} = {}): [number, number, number, number] {\n const unprojectOption = {targetZ: options.z || 0};\n\n const left = this.unproject([0, this.height / 2], unprojectOption);\n const top = this.unproject([this.width / 2, 0], unprojectOption);\n const right = this.unproject([this.width, this.height / 2], unprojectOption);\n const bottom = this.unproject([this.width / 2, this.height], unprojectOption);\n\n if (right[0] < this.longitude) right[0] += 360;\n if (left[0] > this.longitude) left[0] -= 360;\n\n return [\n Math.min(left[0], right[0], top[0], bottom[0]),\n Math.min(left[1], right[1], top[1], bottom[1]),\n Math.max(left[0], right[0], top[0], bottom[0]),\n Math.max(left[1], right[1], top[1], bottom[1])\n ];\n }\n\n unproject(\n xyz: number[],\n {topLeft = true, targetZ}: {topLeft?: boolean; targetZ?: number} = {}\n ): number[] {\n const [x, y, z] = xyz;\n\n const y2 = topLeft ? y : this.height - y;\n const {pixelUnprojectionMatrix} = this;\n\n let coord;\n if (Number.isFinite(z)) {\n // Has depth component\n coord = transformVector(pixelUnprojectionMatrix, [x, y2, z, 1]);\n } else {\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that line that intersects with the sphere\n const coord0 = transformVector(pixelUnprojectionMatrix, [x, y2, -1, 1]);\n const coord1 = transformVector(pixelUnprojectionMatrix, [x, y2, 1, 1]);\n\n const lt = ((targetZ || 0) / EARTH_RADIUS + 1) * GLOBE_RADIUS;\n const lSqr = vec3.sqrLen(vec3.sub([], coord0, coord1));\n const l0Sqr = vec3.sqrLen(coord0);\n const l1Sqr = vec3.sqrLen(coord1);\n const sSqr = (4 * l0Sqr * l1Sqr - (lSqr - l0Sqr - l1Sqr) ** 2) / 16;\n const dSqr = (4 * sSqr) / lSqr;\n const r0 = Math.sqrt(l0Sqr - dSqr);\n const dr = Math.sqrt(Math.max(0, lt * lt - dSqr));\n const t = (r0 - dr) / Math.sqrt(lSqr);\n\n coord = vec3.lerp([], coord0, coord1, t);\n }\n const [X, Y, Z] = this.unprojectPosition(coord);\n\n if (Number.isFinite(z)) {\n return [X, Y, Z];\n }\n return Number.isFinite(targetZ) ? [X, Y, targetZ as number] : [X, Y];\n }\n\n projectPosition(xyz: number[]): [number, number, number] {\n const [lng, lat, Z = 0] = xyz;\n const lambda = lng * DEGREES_TO_RADIANS;\n const phi = lat * DEGREES_TO_RADIANS;\n const cosPhi = Math.cos(phi);\n const D = (Z / EARTH_RADIUS + 1) * GLOBE_RADIUS;\n\n return [Math.sin(lambda) * cosPhi * D, -Math.cos(lambda) * cosPhi * D, Math.sin(phi) * D];\n }\n\n unprojectPosition(xyz: number[]): [number, number, number] {\n const [x, y, z] = xyz;\n const D = vec3.len(xyz);\n const phi = Math.asin(z / D);\n const lambda = Math.atan2(x, -y);\n\n const lng = lambda * RADIANS_TO_DEGREES;\n const lat = phi * RADIANS_TO_DEGREES;\n const Z = (D / GLOBE_RADIUS - 1) * EARTH_RADIUS;\n return [lng, lat, Z];\n }\n\n projectFlat(xyz: number[]): [number, number] {\n return xyz as [number, number];\n }\n\n unprojectFlat(xyz: number[]): [number, number] {\n return xyz as [number, number];\n }\n\n panByPosition(coords: number[], pixel: number[]): GlobeViewportOptions {\n const fromPosition = this.unproject(pixel);\n return {\n longitude: coords[0] - fromPosition[0] + this.longitude,\n latitude: coords[1] - fromPosition[1] + this.latitude\n };\n }\n}\n\nfunction transformVector(matrix: number[], vector: number[]): number[] {\n const result = vec4.transformMat4([], vector, matrix);\n vec4.scale(result, result, 1 / result[3]);\n return result;\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Viewport from '../viewports/viewport';\n\nimport {Matrix4} from '@math.gl/core';\nimport {pixelsToWorld, fovyToAltitude} from '@math.gl/web-mercator';\n\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n\nfunction getViewMatrix({\n height,\n focalDistance,\n orbitAxis,\n rotationX,\n rotationOrbit,\n zoom\n}: {\n height: number;\n focalDistance: number;\n orbitAxis: 'Y' | 'Z';\n rotationX: number;\n rotationOrbit: number;\n zoom: number;\n}): Matrix4 {\n // We position the camera so that one common space unit (world space unit scaled by zoom)\n // at the target maps to one screen pixel.\n // This is a similar technique to that used in web mercator projection\n // By doing so we are able to convert between common space and screen space sizes efficiently\n // in the vertex shader.\n const up = orbitAxis === 'Z' ? [0, 0, 1] : [0, 1, 0];\n const eye = orbitAxis === 'Z' ? [0, -focalDistance, 0] : [0, 0, focalDistance];\n\n const viewMatrix = new Matrix4().lookAt({eye, up});\n\n viewMatrix.rotateX(rotationX * DEGREES_TO_RADIANS);\n if (orbitAxis === 'Z') {\n viewMatrix.rotateZ(rotationOrbit * DEGREES_TO_RADIANS);\n } else {\n viewMatrix.rotateY(rotationOrbit * DEGREES_TO_RADIANS);\n }\n\n // When height increases, we need to increase the distance from the camera to the target to\n // keep the 1:1 mapping. However, this also changes the projected depth of each position by\n // moving them further away between the near/far plane.\n // Without modifying the default near/far planes, we instead scale down the common space to\n // remove the distortion to the depth field.\n const projectionScale = Math.pow(2, zoom) / height;\n viewMatrix.scale(projectionScale);\n\n return viewMatrix;\n}\n\nexport type OrbitViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** Axis with 360 degrees rotating freedom, either `'Y'` or `'Z'`, default to `'Z'`. */\n orbitAxis?: 'Y' | 'Z';\n /** The world position at the center of the viewport. Default `[0, 0, 0]`. */\n target?: [number, number, number];\n /** The zoom level of the viewport. `zoom: 0` maps one unit distance to one pixel on screen, and increasing `zoom` by `1` scales the same object to twice as large. Default `0`. */\n zoom?: number;\n /** Rotating angle around orbit axis. Default `0`. */\n rotationOrbit?: number;\n /** Rotating angle around orbit axis. Default `0`. */\n rotationX?: number;\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** Field of view covered by camera, in the perspective case. In degrees. Default `50`. */\n fovy?: number;\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Whether to create an orthographic or perspective projection matrix. Default is `false` (perspective projection). */\n orthographic?: boolean;\n};\n\nexport default class OrbitViewport extends Viewport {\n projectedCenter: number[];\n\n constructor(props: OrbitViewportOptions) {\n const {\n height,\n\n projectionMatrix,\n\n fovy = 50, // For setting camera position\n orbitAxis = 'Z', // Orbit axis with 360 degrees rotating freedom, can only be 'Y' or 'Z'\n target = [0, 0, 0], // Which point is camera looking at, default origin\n\n rotationX = 0, // Rotating angle around X axis\n rotationOrbit = 0, // Rotating angle around orbit axis\n\n zoom = 0\n } = props;\n\n const focalDistance = projectionMatrix ? projectionMatrix[5] / 2 : fovyToAltitude(fovy);\n\n super({\n ...props,\n // in case viewState contains longitude/latitude values,\n // make sure that the base Viewport class does not treat this as a geospatial viewport\n longitude: undefined,\n viewMatrix: getViewMatrix({\n height: height || 1,\n focalDistance,\n orbitAxis,\n rotationX,\n rotationOrbit,\n zoom\n }),\n fovy,\n focalDistance,\n position: target,\n zoom\n });\n\n this.projectedCenter = this.project(this.center);\n }\n\n unproject(xyz: number[], {topLeft = true}: {topLeft?: boolean} = {}): [number, number, number] {\n const [x, y, z = this.projectedCenter[2]] = xyz;\n\n const y2 = topLeft ? y : this.height - y;\n const [X, Y, Z] = pixelsToWorld([x, y2, z], this.pixelUnprojectionMatrix);\n return [X, Y, Z];\n }\n\n panByPosition(coords: number[], pixel: number[]): OrbitViewportOptions {\n const p0 = this.project(coords);\n const nextCenter = [\n this.width / 2 + p0[0] - pixel[0],\n this.height / 2 + p0[1] - pixel[1],\n this.projectedCenter[2]\n ];\n return {\n target: this.unproject(nextCenter)\n };\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Viewport from '../viewports/viewport';\n\nimport {Matrix4, clamp, vec2} from '@math.gl/core';\nimport {pixelsToWorld} from '@math.gl/web-mercator';\n\nimport type {Padding} from './viewport';\n\nconst viewMatrix = new Matrix4().lookAt({eye: [0, 0, 1]});\n\nfunction getProjectionMatrix({\n width,\n height,\n near,\n far,\n padding\n}: {\n width: number;\n height: number;\n near: number;\n far: number;\n padding: Padding | null;\n}) {\n let left = -width / 2;\n let right = width / 2;\n let bottom = -height / 2;\n let top = height / 2;\n if (padding) {\n const {left: l = 0, right: r = 0, top: t = 0, bottom: b = 0} = padding;\n const offsetX = clamp((l + width - r) / 2, 0, width) - width / 2;\n const offsetY = clamp((t + height - b) / 2, 0, height) - height / 2;\n left -= offsetX;\n right -= offsetX;\n bottom += offsetY;\n top += offsetY;\n }\n\n return new Matrix4().ortho({\n left,\n right,\n bottom,\n top,\n near,\n far\n });\n}\n\nexport type OrthographicViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** The world position at the center of the viewport. Default `[0, 0, 0]`. */\n target?: [number, number, number] | [number, number];\n /** The zoom level of the viewport. `zoom: 0` maps one unit distance to one pixel on screen, and increasing `zoom` by `1` scales the same object to twice as large.\n * To apply independent zoom levels to the X and Y axes, supply an array `[zoomX, zoomY]`. Default `0`. */\n zoom?: number | [number, number];\n /** Padding around the viewport, in pixels. */\n padding?: Padding | null;\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Whether to use top-left coordinates (`true`) or bottom-left coordinates (`false`). Default `true`. */\n flipY?: boolean;\n};\n\nexport default class OrthographicViewport extends Viewport {\n constructor(props: OrthographicViewportOptions) {\n const {\n width,\n height,\n near = 0.1,\n far = 1000,\n zoom = 0,\n target = [0, 0, 0],\n padding = null,\n flipY = true\n } = props;\n const zoomX = Array.isArray(zoom) ? zoom[0] : zoom;\n const zoomY = Array.isArray(zoom) ? zoom[1] : zoom;\n const zoom_ = Math.min(zoomX, zoomY);\n const scale = Math.pow(2, zoom_);\n\n let distanceScales;\n if (zoomX !== zoomY) {\n const scaleX = Math.pow(2, zoomX);\n const scaleY = Math.pow(2, zoomY);\n\n distanceScales = {\n unitsPerMeter: [scaleX / scale, scaleY / scale, 1],\n metersPerUnit: [scale / scaleX, scale / scaleY, 1]\n };\n }\n\n super({\n ...props,\n // in case viewState contains longitude/latitude values,\n // make sure that the base Viewport class does not treat this as a geospatial viewport\n longitude: undefined,\n position: target,\n viewMatrix: viewMatrix.clone().scale([scale, scale * (flipY ? -1 : 1), scale]),\n projectionMatrix: getProjectionMatrix({\n width: width || 1,\n height: height || 1,\n padding,\n near,\n far\n }),\n zoom: zoom_,\n distanceScales\n });\n }\n\n projectFlat([X, Y]: number[]): [number, number] {\n const {unitsPerMeter} = this.distanceScales;\n return [X * unitsPerMeter[0], Y * unitsPerMeter[1]];\n }\n\n unprojectFlat([x, y]: number[]): [number, number] {\n const {metersPerUnit} = this.distanceScales;\n return [x * metersPerUnit[0], y * metersPerUnit[1]];\n }\n\n /* Needed by LinearInterpolator */\n panByPosition(coords: number[], pixel: number[]): OrthographicViewportOptions {\n const fromLocation = pixelsToWorld(pixel, this.pixelUnprojectionMatrix);\n const toLocation = this.projectFlat(coords);\n\n const translate = vec2.add([], toLocation, vec2.negate([], fromLocation));\n const newCenter = vec2.add([], this.center, translate);\n\n return {target: this.unprojectFlat(newCenter)};\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Viewport from '../viewports/viewport';\nimport {getMeterZoom} from '@math.gl/web-mercator';\nimport {Matrix4, _SphericalCoordinates as SphericalCoordinates} from '@math.gl/core';\n\nexport type FirstPersonViewportOptions = {\n /** Name of the viewport */\n id?: string;\n /** Left offset from the canvas edge, in pixels */\n x?: number;\n /** Top offset from the canvas edge, in pixels */\n y?: number;\n /** Viewport width in pixels */\n width?: number;\n /** Viewport height in pixels */\n height?: number;\n /** Longitude of the camera, in the geospatial case. */\n longitude?: number;\n /** Latitude of the camera, in the geospatial case. */\n latitude?: number;\n /** Meter offsets of the camera from the lng-lat anchor point. Default `[0, 0, 0]`. */\n position?: [number, number, number];\n /** Bearing (heading) of the camera in degrees. Default `0` (north). */\n bearing?: number;\n /** Pitch (tilt) of the camera in degrees. Default `0` (horizontal). */\n pitch?: number;\n /** Transform applied to the camera position and direction */\n modelMatrix?: number[] | null;\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** The up direction, default positive z axis. */\n up?: [number, number, number];\n /** Field of view covered by camera, in degrees. Default `75`. */\n fovy?: number;\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Modifier of viewport scale. Corresponds to the number of pixels per meter. Default `1`. */\n focalDistance?: number;\n};\n\nexport default class FirstPersonViewport extends Viewport {\n longitude?: number;\n latitude?: number;\n\n constructor(props: FirstPersonViewportOptions) {\n // TODO - push direction handling into Matrix4.lookAt\n const {longitude, latitude, modelMatrix, bearing = 0, pitch = 0, up = [0, 0, 1]} = props;\n\n // Always calculate direction from bearing and pitch\n const spherical = new SphericalCoordinates({\n bearing,\n // Avoid \"pixel project matrix not invertible\" error\n pitch: pitch === -90 ? 0.0001 : 90 + pitch\n });\n const dir = spherical.toVector3().normalize();\n\n // Direction is relative to model coordinates, of course\n const center = modelMatrix ? new Matrix4(modelMatrix).transformAsVector(dir) : dir;\n\n // Just the direction. All the positioning is done in viewport.js\n const zoom = Number.isFinite(latitude) ? getMeterZoom({latitude: latitude as number}) : 0;\n const scale = Math.pow(2, zoom);\n const viewMatrix = new Matrix4().lookAt({eye: [0, 0, 0], center, up}).scale(scale);\n\n super({\n ...props,\n zoom,\n viewMatrix\n });\n\n this.latitude = latitude;\n this.longitude = longitude;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport Controller from './controller';\nimport ViewState from './view-state';\nimport {mod} from '../utils/math-utils';\nimport type Viewport from '../viewports/viewport';\nimport LinearInterpolator from '../transitions/linear-interpolator';\n\nimport {Vector3, _SphericalCoordinates as SphericalCoordinates, clamp} from '@math.gl/core';\n\nconst MOVEMENT_SPEED = 20;\nconst PAN_SPEED = 500;\n\ntype FirstPersonStateProps = {\n width: number;\n height: number;\n\n position?: number[];\n bearing?: number;\n pitch?: number;\n\n // Geospatial anchor\n longitude?: number | null;\n latitude?: number | null;\n\n maxPitch?: number;\n minPitch?: number;\n};\n\ntype FirstPersonStateInternal = {\n startRotatePos?: [number, number];\n startBearing?: number;\n startPitch?: number;\n startZoomPosition?: number[];\n startPanPos?: [number, number];\n startPanPosition?: number[];\n};\n\nclass FirstPersonState extends ViewState<\n FirstPersonState,\n FirstPersonStateProps,\n FirstPersonStateInternal\n> {\n makeViewport: (props: Record) => Viewport;\n\n constructor(\n options: FirstPersonStateProps &\n FirstPersonStateInternal & {\n makeViewport: (props: Record) => Viewport;\n }\n ) {\n const {\n /* Viewport arguments */\n width, // Width of viewport\n height, // Height of viewport\n\n // Position and orientation\n position = [0, 0, 0], // typically in meters from anchor point\n\n bearing = 0, // Rotation around y axis\n pitch = 0, // Rotation around x axis\n\n // Geospatial anchor\n longitude = null,\n latitude = null,\n\n maxPitch = 90,\n minPitch = -90,\n\n // Model state when the rotate operation first started\n startRotatePos,\n startBearing,\n startPitch,\n startZoomPosition,\n startPanPos,\n startPanPosition\n } = options;\n\n super(\n {\n width,\n height,\n position,\n bearing,\n pitch,\n longitude,\n latitude,\n maxPitch,\n minPitch\n },\n {\n startRotatePos,\n startBearing,\n startPitch,\n startZoomPosition,\n startPanPos,\n startPanPosition\n }\n );\n\n this.makeViewport = options.makeViewport;\n }\n\n /* Public API */\n\n /**\n * Start panning\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n panStart({pos}): FirstPersonState {\n const {position} = this.getViewportProps();\n return this._getUpdatedState({\n startPanPos: pos,\n startPanPosition: position\n });\n }\n\n /**\n * Pan\n * @param {[Number, Number]} pos - position on screen where the pointer is\n */\n pan({pos}): FirstPersonState {\n if (!pos) {\n return this;\n }\n const {startPanPos = [0, 0], startPanPosition = [0, 0]} = this.getState();\n const {width, height, bearing, pitch} = this.getViewportProps();\n const deltaScaleX = (PAN_SPEED * (pos[0] - startPanPos[0])) / width;\n const deltaScaleY = (PAN_SPEED * (pos[1] - startPanPos[1])) / height;\n\n const up = new SphericalCoordinates({bearing, pitch});\n const forward = new SphericalCoordinates({bearing, pitch: -90});\n const yDirection = up.toVector3().normalize();\n const xDirection = forward.toVector3().cross(yDirection).normalize();\n\n return this._getUpdatedState({\n position: new Vector3(startPanPosition)\n .add(xDirection.scale(deltaScaleX))\n .add(yDirection.scale(deltaScaleY))\n });\n }\n\n /**\n * End panning\n * Must call if `panStart()` was called\n */\n panEnd(): FirstPersonState {\n return this._getUpdatedState({\n startPanPos: null,\n startPanPosition: null\n });\n }\n\n /**\n * Start rotating\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n rotateStart({pos}: {pos: [number, number]}): FirstPersonState {\n return this._getUpdatedState({\n startRotatePos: pos,\n startBearing: this.getViewportProps().bearing,\n startPitch: this.getViewportProps().pitch\n });\n }\n\n /**\n * Rotate\n * @param {[Number, Number]} pos - position on screen where the pointer is\n */\n rotate({\n pos,\n deltaAngleX = 0,\n deltaAngleY = 0\n }: {\n pos?: [number, number];\n deltaAngleX?: number;\n deltaAngleY: number;\n }): FirstPersonState {\n const {startRotatePos, startBearing, startPitch} = this.getState();\n const {width, height} = this.getViewportProps();\n\n if (!startRotatePos || startBearing === undefined || startPitch === undefined) {\n return this;\n }\n\n let newRotation;\n if (pos) {\n const deltaScaleX = (pos[0] - startRotatePos[0]) / width;\n const deltaScaleY = (pos[1] - startRotatePos[1]) / height;\n newRotation = {\n bearing: startBearing - deltaScaleX * 180,\n pitch: startPitch - deltaScaleY * 90\n };\n } else {\n newRotation = {\n bearing: startBearing - deltaAngleX,\n pitch: startPitch - deltaAngleY\n };\n }\n\n return this._getUpdatedState(newRotation);\n }\n\n /**\n * End rotating\n * Must call if `rotateStart()` was called\n */\n rotateEnd(): FirstPersonState {\n return this._getUpdatedState({\n startRotatePos: null,\n startBearing: null,\n startPitch: null\n });\n }\n\n /**\n * Start zooming\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n zoomStart(): FirstPersonState {\n return this._getUpdatedState({\n startZoomPosition: this.getViewportProps().position\n });\n }\n\n /**\n * Zoom\n * @param {[Number, Number]} pos - position on screen where the current center is\n * @param {[Number, Number]} startPos - the center position at\n * the start of the operation. Must be supplied of `zoomStart()` was not called\n * @param {Number} scale - a number between [0, 1] specifying the accumulated\n * relative scale.\n */\n zoom({pos, scale}: {pos: [number, number]; scale: number}): FirstPersonState {\n const viewportProps = this.getViewportProps();\n const startZoomPosition = this.getState().startZoomPosition || viewportProps.position;\n const viewport = this.makeViewport(viewportProps);\n const {projectionMatrix, width} = viewport;\n const fovxRadians = 2.0 * Math.atan(1.0 / projectionMatrix[0]);\n const angle = fovxRadians * (pos[0] / width - 0.5);\n\n const direction = this.getDirection(true);\n return this._move(\n direction.rotateZ({radians: -angle}),\n Math.log2(scale) * MOVEMENT_SPEED,\n startZoomPosition\n );\n }\n\n /**\n * End zooming\n * Must call if `zoomStart()` was called\n */\n zoomEnd(): FirstPersonState {\n return this._getUpdatedState({\n startZoomPosition: null\n });\n }\n\n moveLeft(speed: number = MOVEMENT_SPEED): FirstPersonState {\n const direction = this.getDirection(true);\n return this._move(direction.rotateZ({radians: Math.PI / 2}), speed);\n }\n\n moveRight(speed: number = MOVEMENT_SPEED): FirstPersonState {\n const direction = this.getDirection(true);\n return this._move(direction.rotateZ({radians: -Math.PI / 2}), speed);\n }\n\n // forward\n moveUp(speed: number = MOVEMENT_SPEED): FirstPersonState {\n const direction = this.getDirection(true);\n return this._move(direction, speed);\n }\n\n // backward\n moveDown(speed: number = MOVEMENT_SPEED): FirstPersonState {\n const direction = this.getDirection(true);\n return this._move(direction.negate(), speed);\n }\n\n rotateLeft(speed: number = 15): FirstPersonState {\n return this._getUpdatedState({\n bearing: this.getViewportProps().bearing - speed\n });\n }\n\n rotateRight(speed: number = 15): FirstPersonState {\n return this._getUpdatedState({\n bearing: this.getViewportProps().bearing + speed\n });\n }\n\n rotateUp(speed: number = 10): FirstPersonState {\n return this._getUpdatedState({\n pitch: this.getViewportProps().pitch + speed\n });\n }\n\n rotateDown(speed: number = 10): FirstPersonState {\n return this._getUpdatedState({\n pitch: this.getViewportProps().pitch - speed\n });\n }\n\n zoomIn(speed: number = MOVEMENT_SPEED): FirstPersonState {\n return this._move(new Vector3(0, 0, 1), speed);\n }\n\n zoomOut(speed: number = MOVEMENT_SPEED): FirstPersonState {\n return this._move(new Vector3(0, 0, -1), speed);\n }\n\n // shortest path between two view states\n shortestPathFrom(viewState: FirstPersonState) {\n const fromProps = viewState.getViewportProps();\n const props = {...this.getViewportProps()};\n const {bearing, longitude} = props;\n\n if (Math.abs(bearing - fromProps.bearing) > 180) {\n props.bearing = bearing < 0 ? bearing + 360 : bearing - 360;\n }\n if (\n longitude !== null &&\n fromProps.longitude !== null &&\n Math.abs(longitude - fromProps.longitude) > 180\n ) {\n props.longitude = longitude < 0 ? longitude + 360 : longitude - 360;\n }\n return props;\n }\n\n /* Private methods */\n _move(\n direction: Vector3,\n speed: number,\n fromPosition: number[] = this.getViewportProps().position\n ) {\n const delta = direction.scale(speed);\n return this._getUpdatedState({\n position: new Vector3(fromPosition).add(delta)\n });\n }\n\n getDirection(use2D: boolean = false): Vector3 {\n const spherical = new SphericalCoordinates({\n bearing: this.getViewportProps().bearing,\n pitch: use2D ? 90 : 90 + this.getViewportProps().pitch\n });\n const direction = spherical.toVector3().normalize();\n return direction;\n }\n\n _getUpdatedState(newProps: Record): FirstPersonState {\n // Update _viewportProps\n return new FirstPersonState({\n makeViewport: this.makeViewport,\n ...this.getViewportProps(),\n ...this.getState(),\n ...newProps\n });\n }\n\n // Apply any constraints (mathematical or defined by _viewportProps) to map state\n applyConstraints(props: Required): Required {\n // Ensure pitch and zoom are within specified range\n const {pitch, maxPitch, minPitch, longitude, bearing} = props;\n props.pitch = clamp(pitch, minPitch, maxPitch);\n\n // Normalize degrees\n if (longitude !== null && (longitude < -180 || longitude > 180)) {\n props.longitude = mod(longitude + 180, 360) - 180;\n }\n if (bearing < -180 || bearing > 180) {\n props.bearing = mod(bearing + 180, 360) - 180;\n }\n\n return props;\n }\n}\n\nexport default class FirstPersonController extends Controller {\n ControllerState = FirstPersonState;\n\n transition = {\n transitionDuration: 300,\n transitionInterpolator: new LinearInterpolator(['position', 'pitch', 'bearing'])\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport View, {CommonViewState, CommonViewProps} from './view';\nimport FirstPersonViewport from '../viewports/first-person-viewport';\nimport FirstPersonController from '../controllers/first-person-controller';\n\nexport type FirstPersonViewState = {\n /** Longitude of the camera, in the geospatial case. */\n longitude?: number;\n /** Latitude of the camera, in the geospatial case. */\n latitude?: number;\n /** Meter offsets of the camera from the lng-lat anchor point. Default `[0, 0, 0]`. */\n position?: [number, number, number];\n /** Bearing (heading) of the camera in degrees. Default `0` (north). */\n bearing?: number;\n /** Pitch (tilt) of the camera in degrees. Default `0` (horizontal). */\n pitch?: number;\n /** Min pitch angle. Default `-90` (up). */\n minPitch?: number;\n /** Max pitch angle. Default `90` (down). */\n maxPitch?: number;\n /** Transform applied to the camera position and direction */\n modelMatrix?: number[] | null;\n} & CommonViewState;\n\nexport type FirstPersonViewProps = {\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** Field of view covered by camera, in degrees. Default `75`. */\n fovy?: number;\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Modifier of viewport scale. Corresponds to the number of pixels per meter. Default `1`. */\n focalDistance?: number;\n} & CommonViewProps;\n\nexport default class FirstPersonView extends View {\n static displayName = 'FirstPersonView';\n\n constructor(props: FirstPersonViewProps = {}) {\n super(props);\n }\n\n getViewportType() {\n return FirstPersonViewport;\n }\n\n get ControllerType() {\n return FirstPersonController;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {clamp} from '@math.gl/core';\nimport Controller from './controller';\nimport ViewState from './view-state';\nimport {mod} from '../utils/math-utils';\n\nimport type Viewport from '../viewports/viewport';\nimport LinearInterpolator from '../transitions/linear-interpolator';\n\nexport type OrbitStateProps = {\n width: number;\n height: number;\n target?: number[];\n zoom?: number | number[];\n rotationX?: number;\n rotationOrbit?: number;\n\n /** Viewport constraints */\n maxZoom?: number;\n minZoom?: number;\n minRotationX?: number;\n maxRotationX?: number;\n};\n\ntype OrbitStateInternal = {\n startPanPosition?: number[];\n startRotatePos?: number[];\n startRotationX?: number;\n startRotationOrbit?: number;\n startZoomPosition?: number[];\n startZoom?: number | number[];\n};\n\nexport class OrbitState extends ViewState {\n makeViewport: (props: Record) => Viewport;\n\n constructor(\n options: OrbitStateProps &\n OrbitStateInternal & {\n makeViewport: (props: Record) => Viewport;\n }\n ) {\n const {\n /* Viewport arguments */\n width, // Width of viewport\n height, // Height of viewport\n rotationX = 0, // Rotation around x axis\n rotationOrbit = 0, // Rotation around orbit axis\n target = [0, 0, 0],\n zoom = 0,\n\n /* Viewport constraints */\n minRotationX = -90,\n maxRotationX = 90,\n minZoom = -Infinity,\n maxZoom = Infinity,\n\n /** Interaction states, required to calculate change during transform */\n // Model state when the pan operation first started\n startPanPosition,\n // Model state when the rotate operation first started\n startRotatePos,\n startRotationX,\n startRotationOrbit,\n // Model state when the zoom operation first started\n startZoomPosition,\n startZoom\n } = options;\n\n super(\n {\n width,\n height,\n rotationX,\n rotationOrbit,\n target,\n zoom,\n minRotationX,\n maxRotationX,\n minZoom,\n maxZoom\n },\n {\n startPanPosition,\n startRotatePos,\n startRotationX,\n startRotationOrbit,\n startZoomPosition,\n startZoom\n }\n );\n\n this.makeViewport = options.makeViewport;\n }\n\n /**\n * Start panning\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n panStart({pos}: {pos: [number, number]}): OrbitState {\n return this._getUpdatedState({\n startPanPosition: this._unproject(pos)\n });\n }\n\n /**\n * Pan\n * @param {[Number, Number]} pos - position on screen where the pointer is\n */\n pan({pos, startPosition}: {pos: [number, number]; startPosition?: number[]}): OrbitState {\n const startPanPosition = this.getState().startPanPosition || startPosition;\n\n if (!startPanPosition) {\n return this;\n }\n\n const viewport = this.makeViewport(this.getViewportProps());\n const newProps = viewport.panByPosition(startPanPosition, pos);\n\n return this._getUpdatedState(newProps);\n }\n\n /**\n * End panning\n * Must call if `panStart()` was called\n */\n panEnd(): OrbitState {\n return this._getUpdatedState({\n startPanPosition: null\n });\n }\n\n /**\n * Start rotating\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n rotateStart({pos}: {pos: [number, number]}): OrbitState {\n return this._getUpdatedState({\n startRotatePos: pos,\n startRotationX: this.getViewportProps().rotationX,\n startRotationOrbit: this.getViewportProps().rotationOrbit\n });\n }\n\n /**\n * Rotate\n * @param {[Number, Number]} pos - position on screen where the pointer is\n */\n rotate({\n pos,\n deltaAngleX = 0,\n deltaAngleY = 0\n }: {\n pos?: [number, number];\n deltaAngleX?: number;\n deltaAngleY?: number;\n }): OrbitState {\n const {startRotatePos, startRotationX, startRotationOrbit} = this.getState();\n const {width, height} = this.getViewportProps();\n\n if (!startRotatePos || startRotationX === undefined || startRotationOrbit === undefined) {\n return this;\n }\n\n let newRotation;\n if (pos) {\n let deltaScaleX = (pos[0] - startRotatePos[0]) / width;\n const deltaScaleY = (pos[1] - startRotatePos[1]) / height;\n\n if (startRotationX < -90 || startRotationX > 90) {\n // When looking at the \"back\" side of the scene, invert horizontal drag\n // so that the camera movement follows user input\n deltaScaleX *= -1;\n }\n newRotation = {\n rotationX: startRotationX + deltaScaleY * 180,\n rotationOrbit: startRotationOrbit + deltaScaleX * 180\n };\n } else {\n newRotation = {\n rotationX: startRotationX + deltaAngleY,\n rotationOrbit: startRotationOrbit + deltaAngleX\n };\n }\n\n return this._getUpdatedState(newRotation);\n }\n\n /**\n * End rotating\n * Must call if `rotateStart()` was called\n */\n rotateEnd(): OrbitState {\n return this._getUpdatedState({\n startRotationX: null,\n startRotationOrbit: null\n });\n }\n\n // shortest path between two view states\n shortestPathFrom(viewState: OrbitState): OrbitStateProps {\n const fromProps = viewState.getViewportProps();\n const props = {...this.getViewportProps()};\n const {rotationOrbit} = props;\n\n if (Math.abs(rotationOrbit - fromProps.rotationOrbit) > 180) {\n props.rotationOrbit = rotationOrbit < 0 ? rotationOrbit + 360 : rotationOrbit - 360;\n }\n\n return props;\n }\n\n /**\n * Start zooming\n * @param {[Number, Number]} pos - position on screen where the pointer grabs\n */\n zoomStart({pos}: {pos: [number, number]}): OrbitState {\n return this._getUpdatedState({\n startZoomPosition: this._unproject(pos),\n startZoom: this.getViewportProps().zoom\n });\n }\n\n /**\n * Zoom\n * @param {[Number, Number]} pos - position on screen where the current target is\n * @param {[Number, Number]} startPos - the target position at\n * the start of the operation. Must be supplied of `zoomStart()` was not called\n * @param {Number} scale - a number between [0, 1] specifying the accumulated\n * relative scale.\n */\n zoom({\n pos,\n startPos,\n scale\n }: {\n pos: [number, number];\n startPos?: [number, number];\n scale: number;\n }): OrbitState {\n let {startZoom, startZoomPosition} = this.getState();\n if (!startZoomPosition) {\n // We have two modes of zoom:\n // scroll zoom that are discrete events (transform from the current zoom level),\n // and pinch zoom that are continuous events (transform from the zoom level when\n // pinch started).\n // If startZoom state is defined, then use the startZoom state;\n // otherwise assume discrete zooming\n startZoom = this.getViewportProps().zoom;\n startZoomPosition = this._unproject(startPos) || this._unproject(pos);\n }\n if (!startZoomPosition) {\n return this;\n }\n const newZoom = this._calculateNewZoom({scale, startZoom});\n const zoomedViewport = this.makeViewport({...this.getViewportProps(), zoom: newZoom});\n\n return this._getUpdatedState({\n zoom: newZoom,\n ...zoomedViewport.panByPosition(startZoomPosition, pos)\n });\n }\n\n /**\n * End zooming\n * Must call if `zoomStart()` was called\n */\n zoomEnd(): OrbitState {\n return this._getUpdatedState({\n startZoomPosition: null,\n startZoom: null\n });\n }\n\n zoomIn(speed: number = 2): OrbitState {\n return this._getUpdatedState({\n zoom: this._calculateNewZoom({scale: speed})\n });\n }\n\n zoomOut(speed: number = 2): OrbitState {\n return this._getUpdatedState({\n zoom: this._calculateNewZoom({scale: 1 / speed})\n });\n }\n\n moveLeft(speed: number = 50): OrbitState {\n return this._panFromCenter([-speed, 0]);\n }\n\n moveRight(speed: number = 50): OrbitState {\n return this._panFromCenter([speed, 0]);\n }\n\n moveUp(speed: number = 50): OrbitState {\n return this._panFromCenter([0, -speed]);\n }\n\n moveDown(speed: number = 50): OrbitState {\n return this._panFromCenter([0, speed]);\n }\n\n rotateLeft(speed: number = 15): OrbitState {\n return this._getUpdatedState({\n rotationOrbit: this.getViewportProps().rotationOrbit - speed\n });\n }\n\n rotateRight(speed: number = 15): OrbitState {\n return this._getUpdatedState({\n rotationOrbit: this.getViewportProps().rotationOrbit + speed\n });\n }\n\n rotateUp(speed: number = 10): OrbitState {\n return this._getUpdatedState({\n rotationX: this.getViewportProps().rotationX - speed\n });\n }\n\n rotateDown(speed: number = 10): OrbitState {\n return this._getUpdatedState({\n rotationX: this.getViewportProps().rotationX + speed\n });\n }\n\n /* Private methods */\n\n _unproject(pos?: number[]): number[] | undefined {\n const viewport = this.makeViewport(this.getViewportProps());\n // @ts-ignore\n return pos && viewport.unproject(pos);\n }\n\n // Calculates new zoom\n _calculateNewZoom({\n scale,\n startZoom\n }: {\n scale: number;\n startZoom?: number | number[];\n }): number | number[] {\n const {maxZoom, minZoom} = this.getViewportProps();\n if (startZoom === undefined) {\n startZoom = this.getViewportProps().zoom;\n }\n const zoom = (startZoom as number) + Math.log2(scale);\n return clamp(zoom, minZoom, maxZoom);\n }\n\n _panFromCenter(offset) {\n const {width, height, target} = this.getViewportProps();\n return this.pan({\n startPosition: target,\n pos: [width / 2 + offset[0], height / 2 + offset[1]]\n });\n }\n\n _getUpdatedState(newProps): OrbitState {\n // @ts-ignore\n return new this.constructor({\n makeViewport: this.makeViewport,\n ...this.getViewportProps(),\n ...this.getState(),\n ...newProps\n });\n }\n\n // Apply any constraints (mathematical or defined by _viewportProps) to map state\n applyConstraints(props: Required): Required {\n // Ensure zoom is within specified range\n const {maxZoom, minZoom, zoom, maxRotationX, minRotationX, rotationOrbit} = props;\n\n props.zoom = Array.isArray(zoom)\n ? [clamp(zoom[0], minZoom, maxZoom), clamp(zoom[1], minZoom, maxZoom)]\n : clamp(zoom, minZoom, maxZoom);\n\n props.rotationX = clamp(props.rotationX, minRotationX, maxRotationX);\n if (rotationOrbit < -180 || rotationOrbit > 180) {\n props.rotationOrbit = mod(rotationOrbit + 180, 360) - 180;\n }\n\n return props;\n }\n}\n\nexport default class OrbitController extends Controller {\n ControllerState = OrbitState;\n\n transition = {\n transitionDuration: 300,\n transitionInterpolator: new LinearInterpolator({\n transitionProps: {\n compare: ['target', 'zoom', 'rotationX', 'rotationOrbit'],\n required: ['target', 'zoom']\n }\n })\n };\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport View, {CommonViewState, CommonViewProps} from './view';\nimport OrbitViewport from '../viewports/orbit-viewport';\nimport OrbitController from '../controllers/orbit-controller';\n\nexport type OrbitViewState = {\n /** The world position at the center of the viewport. Default `[0, 0, 0]`. */\n target: [number, number, number];\n /** The zoom level of the viewport. `zoom: 0` maps one unit distance to one pixel on screen, and increasing `zoom` by `1` scales the same object to twice as large. Default `0`. */\n zoom: number;\n /** Rotating angle around orbit axis. Default `0`. */\n rotationOrbit?: number;\n /** Rotating angle around orbit axis. Default `0`. */\n rotationX?: number;\n /** The min zoom level of the viewport. Default `-Infinity`. */\n minZoom?: number;\n /** The max zoom level of the viewport. Default `Infinity`. */\n maxZoom?: number;\n /** The min rotating angle around X axis. Default `-90`. */\n minRotationX?: number;\n /** The max rotating angle around X axis. Default `90`. */\n maxRotationX?: number;\n} & CommonViewState;\n\nexport type OrbitViewProps = {\n /** Axis with 360 degrees rotating freedom, either `'Y'` or `'Z'`, default to `'Z'`. */\n orbitAxis?: 'Y' | 'Z';\n /** Custom projection matrix */\n projectionMatrix?: number[];\n /** Field of view covered by camera, in the perspective case. In degrees. Default `50`. */\n fovy?: number;\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Whether to create an orthographic or perspective projection matrix. Default is `false` (perspective projection). */\n orthographic?: boolean;\n} & CommonViewProps;\n\nexport default class OrbitView extends View {\n static displayName = 'OrbitView';\n\n constructor(props: OrbitViewProps = {}) {\n super(props);\n this.props.orbitAxis = props.orbitAxis || 'Z';\n }\n\n getViewportType() {\n return OrbitViewport;\n }\n\n get ControllerType() {\n return OrbitController;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {clamp} from '@math.gl/core';\nimport Controller from './controller';\nimport {OrbitState} from './orbit-controller';\nimport LinearInterpolator from '../transitions/linear-interpolator';\n\nclass OrthographicState extends OrbitState {\n zoomAxis: 'X' | 'Y' | 'all';\n\n constructor(props) {\n super(props);\n\n this.zoomAxis = props.zoomAxis || 'all';\n }\n\n _calculateNewZoom({scale, startZoom}) {\n const {maxZoom, minZoom} = this.getViewportProps();\n if (startZoom === undefined) {\n startZoom = this.getViewportProps().zoom;\n }\n let deltaZoom = Math.log2(scale);\n if (Array.isArray(startZoom)) {\n let [newZoomX, newZoomY] = startZoom;\n switch (this.zoomAxis) {\n case 'X':\n // Scale x only\n newZoomX = clamp(newZoomX + deltaZoom, minZoom, maxZoom);\n break;\n case 'Y':\n // Scale y only\n newZoomY = clamp(newZoomY + deltaZoom, minZoom, maxZoom);\n break;\n default:\n // Lock aspect ratio\n let z = Math.min(newZoomX + deltaZoom, newZoomY + deltaZoom);\n if (z < minZoom) {\n deltaZoom += minZoom - z;\n }\n z = Math.max(newZoomX + deltaZoom, newZoomY + deltaZoom);\n if (z > maxZoom) {\n deltaZoom += maxZoom - z;\n }\n newZoomX += deltaZoom;\n newZoomY += deltaZoom;\n }\n return [newZoomX, newZoomY];\n }\n // Ignore `zoomAxis`\n // `LinearTransitionInterpolator` does not support interpolation between a number and an array\n // So if zoom is a number (legacy use case), new zoom still has to be a number\n return clamp(startZoom + deltaZoom, minZoom, maxZoom);\n }\n}\n\nexport default class OrthographicController extends Controller {\n ControllerState = OrthographicState;\n transition = {\n transitionDuration: 300,\n transitionInterpolator: new LinearInterpolator(['target', 'zoom'])\n };\n dragMode: 'pan' | 'rotate' = 'pan';\n\n _onPanRotate() {\n // No rotation in orthographic view\n return false;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport View, {CommonViewState, CommonViewProps} from './view';\nimport OrthographicViewport from '../viewports/orthographic-viewport';\nimport OrthographicController from '../controllers/orthographic-controller';\n\nexport type OrthographicViewState = {\n /** The world position at the center of the viewport. Default `[0, 0, 0]`. */\n target?: [number, number, number] | [number, number];\n /** The zoom level of the viewport. `zoom: 0` maps one unit distance to one pixel on screen, and increasing `zoom` by `1` scales the same object to twice as large.\n * To apply independent zoom levels to the X and Y axes, supply an array `[zoomX, zoomY]`. Default `0`. */\n zoom?: number | [number, number];\n /** The min zoom level of the viewport. Default `-Infinity`. */\n minZoom?: number;\n /** The max zoom level of the viewport. Default `Infinity`. */\n maxZoom?: number;\n} & CommonViewState;\n\nexport type OrthographicViewProps = {\n /** Distance of near clipping plane. Default `0.1`. */\n near?: number;\n /** Distance of far clipping plane. Default `1000`. */\n far?: number;\n /** Whether to use top-left coordinates (`true`) or bottom-left coordinates (`false`). Default `true`. */\n flipY?: boolean;\n} & CommonViewProps;\n\nexport default class OrthographicView extends View {\n static displayName = 'OrthographicView';\n\n constructor(props: OrthographicViewProps = {}) {\n super(props);\n }\n\n getViewportType() {\n return OrthographicViewport;\n }\n\n get ControllerType() {\n return OrthographicController;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {clamp} from '@math.gl/core';\nimport Controller, {ControllerProps} from './controller';\n\nimport {MapState, MapStateProps} from './map-controller';\nimport {mod} from '../utils/math-utils';\nimport LinearInterpolator from '../transitions/linear-interpolator';\n\nimport {MAX_LATITUDE} from '@math.gl/web-mercator';\n\nclass GlobeState extends MapState {\n // Apply any constraints (mathematical or defined by _viewportProps) to map state\n applyConstraints(props: Required): Required {\n // Ensure zoom is within specified range\n const {maxZoom, minZoom, zoom} = props;\n props.zoom = clamp(zoom, minZoom, maxZoom);\n\n const {longitude, latitude} = props;\n if (longitude < -180 || longitude > 180) {\n props.longitude = mod(longitude + 180, 360) - 180;\n }\n props.latitude = clamp(latitude, -MAX_LATITUDE, MAX_LATITUDE);\n\n return props;\n }\n}\n\nexport default class GlobeController extends Controller {\n ControllerState = GlobeState;\n\n transition = {\n transitionDuration: 300,\n transitionInterpolator: new LinearInterpolator(['longitude', 'latitude', 'zoom'])\n };\n\n dragMode: 'pan' | 'rotate' = 'pan';\n\n setProps(props: ControllerProps) {\n super.setProps(props);\n\n // TODO - support pitching?\n this.dragRotate = false;\n this.touchRotate = false;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport View, {CommonViewState, CommonViewProps} from './view';\nimport GlobeViewport from '../viewports/globe-viewport';\nimport WebMercatorViewport from '../viewports/web-mercator-viewport';\nimport GlobeController from '../controllers/globe-controller';\n\nexport type GlobeViewState = {\n /** Longitude of the map center */\n longitude: number;\n /** Latitude of the map center */\n latitude: number;\n /** Zoom level */\n zoom: number;\n /** Min zoom, default `0` */\n minZoom?: number;\n /** Max zoom, default `20` */\n maxZoom?: number;\n /** The near plane position */\n nearZ?: number;\n /** The far plane position */\n farZ?: number;\n} & CommonViewState;\n\nexport type GlobeViewProps = {\n /** The resolution at which to turn flat features into 3D meshes, in degrees. Smaller numbers will generate more detailed mesh. Default `10`. */\n resolution?: number;\n /** Scaler for the near plane, 1 unit equals to the height of the viewport. Default to `0.1`. Overwrites the `near` parameter. */\n nearZMultiplier?: number;\n /** Scaler for the far plane, 1 unit equals to the distance from the camera to the top edge of the screen. Default to `1.01`. Overwrites the `far` parameter. */\n farZMultiplier?: number;\n /** Distance of the camera relative to viewport height. Default `1.5`. */\n altitude?: number;\n} & CommonViewProps;\n\nexport default class GlobeView extends View {\n static displayName = 'GlobeView';\n\n constructor(props: GlobeViewProps = {}) {\n super(props);\n }\n\n getViewportType(viewState: GlobeViewState) {\n return viewState.zoom > 12 ? WebMercatorViewport : GlobeViewport;\n }\n\n get ControllerType() {\n return GlobeController;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {deepEqual} from '../utils/deep-equal';\nimport type Layer from './layer';\nimport type CompositeLayer from './composite-layer';\nimport type {UpdateParameters} from './layer';\nimport type {LayerContext} from './layer-manager';\n\nexport default abstract class LayerExtension {\n static defaultProps = {};\n static extensionName = 'LayerExtension';\n\n static get componentName() {\n return Object.prototype.hasOwnProperty.call(this, 'extensionName') ? this.extensionName : '';\n }\n\n opts!: OptionsT;\n\n constructor(opts?: OptionsT) {\n if (opts) {\n this.opts = opts;\n }\n }\n\n /** Returns true if two extensions are equivalent */\n equals(extension: LayerExtension): boolean {\n if (this === extension) {\n return true;\n }\n\n // Compare extensions shallowly\n return this.constructor === extension.constructor && deepEqual(this.opts, extension.opts, 1);\n }\n\n /** Only called if attached to a primitive layer */\n getShaders(this: Layer, extension: this): any {\n return null;\n }\n\n /** Only called if attached to a CompositeLayer */\n getSubLayerProps(this: CompositeLayer, extension: this): any {\n const {defaultProps} = extension.constructor as typeof LayerExtension;\n const newProps = {\n updateTriggers: {}\n };\n\n /* eslint-disable max-depth */\n for (const key in defaultProps) {\n if (key in this.props) {\n const propDef = defaultProps[key];\n const propValue = this.props[key];\n newProps[key] = propValue;\n if (propDef && propDef.type === 'accessor') {\n newProps.updateTriggers[key] = this.props.updateTriggers[key];\n if (typeof propValue === 'function') {\n newProps[key] = this.getSubLayerAccessor(propValue);\n }\n }\n }\n }\n /* eslint-enable max-depth */\n return newProps;\n }\n\n /* eslint-disable @typescript-eslint/no-empty-function */\n initializeState(this: Layer, context: LayerContext, extension: this): void {}\n\n updateState(this: Layer, params: UpdateParameters, extension: this): void {}\n\n onNeedsRedraw(this: Layer, extension: this): void {}\n\n getNeedsPickingBuffer(this: Layer, extension: this): boolean {\n return false;\n }\n\n draw(this: Layer, params: any, extension: this): void {}\n\n finalizeState(this: Layer, context: LayerContext, extension: this): void {}\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport TransitionInterpolator from './transition-interpolator';\nimport {lerp} from '@math.gl/core';\n\nimport {flyToViewport, getFlyToDuration} from '@math.gl/web-mercator';\n\nconst LINEARLY_INTERPOLATED_PROPS = {\n bearing: 0,\n pitch: 0,\n position: [0, 0, 0]\n};\nconst DEFAULT_OPTS = {\n speed: 1.2,\n curve: 1.414\n};\n\n/**\n * This class adapts mapbox-gl-js Map#flyTo animation so it can be used in\n * react/redux architecture.\n * mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.\n * It implements \u201CSmooth and efficient zooming and panning.\u201D algorithm by\n * \"Jarke J. van Wijk and Wim A.A. Nuij\"\n */\nexport default class FlyToInterpolator extends TransitionInterpolator {\n opts: {\n curve: number;\n speed: number;\n screenSpeed?: number;\n maxDuration?: number;\n };\n\n constructor(\n opts: {\n /** The zooming \"curve\" that will occur along the flight path. Default 1.414 */\n curve?: number;\n /** The average speed of the animation defined in relation to `options.curve`, it linearly affects the duration, higher speed returns smaller durations and vice versa. Default 1.2 */\n speed?: number;\n /** The average speed of the animation measured in screenfuls per second. Similar to `opts.speed` it linearly affects the duration, when specified `opts.speed` is ignored. */\n screenSpeed?: number;\n /** Maximum duration in milliseconds, if calculated duration exceeds this value, `0` is returned. */\n maxDuration?: number;\n } = {}\n ) {\n super({\n compare: ['longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],\n extract: ['width', 'height', 'longitude', 'latitude', 'zoom', 'bearing', 'pitch', 'position'],\n required: ['width', 'height', 'latitude', 'longitude', 'zoom']\n });\n this.opts = {...DEFAULT_OPTS, ...opts};\n }\n\n interpolateProps(startProps, endProps, t) {\n const viewport = flyToViewport(startProps, endProps, t, this.opts);\n\n // Linearly interpolate 'bearing', 'pitch' and 'position'.\n // If they are not supplied, they are interpreted as zeros in viewport calculation\n // (fallback defined in WebMercatorViewport)\n // Because there is no guarantee that the current controller's ViewState normalizes\n // these props, safe guard is needed to avoid generating NaNs\n for (const key in LINEARLY_INTERPOLATED_PROPS) {\n viewport[key] = lerp(\n startProps[key] || LINEARLY_INTERPOLATED_PROPS[key],\n endProps[key] || LINEARLY_INTERPOLATED_PROPS[key],\n t\n );\n }\n\n return viewport;\n }\n\n // computes the transition duration\n getDuration(startProps, endProps) {\n let {transitionDuration} = endProps;\n if (transitionDuration === 'auto') {\n // auto calculate duration based on start and end props\n transitionDuration = getFlyToDuration(startProps, endProps, this.opts);\n }\n return transitionDuration;\n }\n}\n", "// deck.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {createIterable, getAccessorFromBuffer} from './iterable-utils';\nimport defaultTypedArrayManager from './typed-array-manager';\nimport assert from './assert';\n\nimport {Buffer} from '@luma.gl/core';\n\nimport type {BinaryAttribute} from '../lib/attribute/attribute';\nimport type {TypedArray} from '../types/types';\nimport type {AccessorFunction} from '../types/layer-props';\nimport type {TypedArrayManager} from './typed-array-manager';\n\ntype ExternalBuffer = TypedArray | Buffer | BinaryAttribute;\n\ntype TesselatorOptions = ExtraOptionsT & {\n attributes?: Record;\n getGeometry?: AccessorFunction;\n data?: any;\n buffers?: Record;\n geometryBuffer?: ExternalBuffer;\n positionFormat?: 'XY' | 'XYZ';\n dataChanged?: {startRow: number; endRow?: number}[] | string | false;\n normalize?: boolean;\n};\n\nexport type GeometryUpdateContext = {\n vertexStart: number;\n indexStart: number;\n geometrySize: number;\n geometryIndex: number;\n};\n\nexport default abstract class Tesselator {\n opts: TesselatorOptions;\n typedArrayManager: TypedArrayManager;\n indexStarts: number[] = [0];\n vertexStarts: number[] = [0];\n vertexCount: number = 0;\n instanceCount: number = 0;\n attributes: Record;\n\n protected _attributeDefs: any;\n protected data: any;\n protected getGeometry?: AccessorFunction | null;\n protected geometryBuffer?: ExternalBuffer;\n protected buffers!: Record;\n protected positionSize!: number;\n protected normalize!: boolean;\n\n constructor(opts: TesselatorOptions) {\n const {attributes = {}} = opts;\n\n this.typedArrayManager = defaultTypedArrayManager;\n this.attributes = {};\n this._attributeDefs = attributes;\n this.opts = opts;\n\n this.updateGeometry(opts);\n }\n\n /* Public methods */\n updateGeometry(opts: TesselatorOptions): void {\n Object.assign(this.opts, opts);\n const {\n data,\n buffers = {},\n getGeometry,\n geometryBuffer,\n positionFormat,\n dataChanged,\n normalize = true\n } = this.opts;\n this.data = data;\n this.getGeometry = getGeometry;\n this.positionSize =\n // @ts-ignore (2339) when geometryBuffer is a luma Buffer, size falls back to positionFormat\n (geometryBuffer && geometryBuffer.size) || (positionFormat === 'XY' ? 2 : 3);\n this.buffers = buffers;\n this.normalize = normalize;\n\n // Handle external logical value\n if (geometryBuffer) {\n assert(data.startIndices); // binary data missing startIndices\n this.getGeometry = this.getGeometryFromBuffer(geometryBuffer);\n\n if (!normalize) {\n // skip packing and set attribute value directly\n // TODO - avoid mutating user-provided object\n buffers.vertexPositions = geometryBuffer;\n }\n }\n this.geometryBuffer = buffers.vertexPositions;\n\n if (Array.isArray(dataChanged)) {\n // is partial update\n for (const dataRange of dataChanged as {startRow: number; endRow?: number}[]) {\n this._rebuildGeometry(dataRange);\n }\n } else {\n this._rebuildGeometry();\n }\n }\n\n updatePartialGeometry({startRow, endRow}: {startRow: number; endRow: number}): void {\n this._rebuildGeometry({startRow, endRow});\n }\n\n // Subclass interface\n\n /** Convert geometry to a uniform shape */\n protected abstract normalizeGeometry(geometry: GeometryT): NormalizedGeometryT;\n\n /** Update the positions buffer of a single geometry */\n protected abstract updateGeometryAttributes(\n geometry: NormalizedGeometryT | null,\n context: GeometryUpdateContext\n );\n\n /** Get the number of vertices in a geometry */\n protected abstract getGeometrySize(geometry: NormalizedGeometryT): number;\n\n protected getGeometryFromBuffer(\n geometryBuffer: ExternalBuffer\n ): AccessorFunction | null {\n const value = (geometryBuffer as BinaryAttribute).value || geometryBuffer;\n if (!ArrayBuffer.isView(value)) {\n // Cannot read binary geometries\n return null;\n }\n\n // @ts-ignore (2322) NumericArray not assignable to GeometryT\n return getAccessorFromBuffer(value, {\n size: this.positionSize,\n offset: (geometryBuffer as BinaryAttribute).offset,\n stride: (geometryBuffer as BinaryAttribute).stride,\n startIndices: this.data.startIndices\n });\n }\n\n /* Private utility methods */\n private _allocate(instanceCount: number, copy: boolean): void {\n // allocate attributes\n const {attributes, buffers, _attributeDefs, typedArrayManager} = this;\n for (const name in _attributeDefs) {\n if (name in buffers) {\n // Use external buffer\n typedArrayManager.release(attributes[name]);\n attributes[name] = null;\n } else {\n const def = _attributeDefs[name];\n // If dataRange is supplied, this is a partial update.\n // In case we need to reallocate the typed array, it will need the old values copied\n // before performing partial update.\n def.copy = copy;\n\n attributes[name] = typedArrayManager.allocate(attributes[name], instanceCount, def);\n }\n }\n }\n\n /**\n * Visit all objects\n * `data` is expected to be an iterable consistent with the base Layer expectation\n */\n private _forEachGeometry(\n visitor: (geometry: GeometryT | null, index: number) => void,\n startRow: number,\n endRow: number\n ): void {\n const {data, getGeometry} = this;\n const {iterable, objectInfo} = createIterable(data, startRow, endRow);\n for (const object of iterable) {\n objectInfo.index++;\n const geometry = getGeometry ? getGeometry(object, objectInfo) : null;\n visitor(geometry, objectInfo.index);\n }\n }\n\n /* eslint-disable complexity,max-statements */\n private _rebuildGeometry(dataRange?: {startRow: number; endRow?: number}): void {\n if (!this.data) {\n return;\n }\n\n let {indexStarts, vertexStarts, instanceCount} = this;\n const {data, geometryBuffer} = this;\n const {startRow = 0, endRow = Infinity} = dataRange || {};\n\n const normalizedData: Record = {};\n\n if (!dataRange) {\n // Full update - regenerate buffer layout from scratch\n indexStarts = [0];\n vertexStarts = [0];\n }\n if (this.normalize || !geometryBuffer) {\n this._forEachGeometry(\n (geometry: GeometryT | null, dataIndex: number) => {\n const normalizedGeometry = geometry && this.normalizeGeometry(geometry);\n normalizedData[dataIndex] = normalizedGeometry;\n vertexStarts[dataIndex + 1] =\n vertexStarts[dataIndex] +\n (normalizedGeometry ? this.getGeometrySize(normalizedGeometry) : 0);\n },\n startRow,\n endRow\n );\n // count instances\n instanceCount = vertexStarts[vertexStarts.length - 1];\n } else {\n // assume user provided data is already normalized\n vertexStarts = data.startIndices;\n instanceCount = vertexStarts[data.length] || 0;\n\n if (ArrayBuffer.isView(geometryBuffer)) {\n instanceCount = instanceCount || geometryBuffer.length / this.positionSize;\n } else if (geometryBuffer instanceof Buffer) {\n const byteStride = this.positionSize * 4;\n instanceCount = instanceCount || geometryBuffer.byteLength / byteStride;\n } else if (geometryBuffer.buffer) {\n const byteStride = geometryBuffer.stride || this.positionSize * 4;\n instanceCount = instanceCount || geometryBuffer.buffer.byteLength / byteStride;\n } else if (geometryBuffer.value) {\n const bufferValue = geometryBuffer.value;\n const elementStride =\n // @ts-ignore (2339) if stride is not specified, will fall through to positionSize\n geometryBuffer.stride / bufferValue.BYTES_PER_ELEMENT || this.positionSize;\n instanceCount = instanceCount || bufferValue.length / elementStride;\n }\n }\n\n // allocate attributes\n this._allocate(instanceCount, Boolean(dataRange));\n\n this.indexStarts = indexStarts;\n this.vertexStarts = vertexStarts;\n this.instanceCount = instanceCount;\n\n // @ts-ignore (2739) context will be populated in the loop\n const context: GeometryUpdateContext = {};\n\n this._forEachGeometry(\n (geometry: GeometryT | null, dataIndex: number) => {\n const normalizedGeometry =\n normalizedData[dataIndex] || (geometry as unknown as NormalizedGeometryT);\n context.vertexStart = vertexStarts[dataIndex];\n context.indexStart = indexStarts[dataIndex];\n const vertexEnd =\n dataIndex < vertexStarts.length - 1 ? vertexStarts[dataIndex + 1] : instanceCount;\n context.geometrySize = vertexEnd - vertexStarts[dataIndex];\n context.geometryIndex = dataIndex;\n this.updateGeometryAttributes(normalizedGeometry, context);\n },\n startRow,\n endRow\n );\n\n this.vertexCount = indexStarts[indexStarts.length - 1];\n }\n}\n", "export function applyStyles(element: HTMLElement, style?: Partial): void {\n if (style) {\n Object.entries(style).map(([key, value]) => {\n if (key.startsWith('--')) {\n // Assume CSS variable\n element.style.setProperty(key, value as string);\n } else {\n // Assume camelCase\n element.style[key] = value;\n }\n });\n }\n}\n\nexport function removeStyles(element: HTMLElement, style?: Partial): void {\n if (style) {\n Object.keys(style).map(key => {\n if (key.startsWith('--')) {\n // Assume CSS variable\n element.style.removeProperty(key);\n }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AAgB;AAGrB,UAAM,UAAiC,CAAA;AAEvC,SAAK,iBACH,CAAC,UAA4B,cAAqB;AAChD,YAAM,qBACJ,eAAe,SAAS,KAAM;AAChC,cAAQ,cAAc,aAAa,SAAS;AAC5C,cAAQ,aAAa,YAAY,SAAS;AAC1C,YAAM,YACJ,YAAY,aAAa,SAAS,IAAI,aAAa,YAAY,CAAC,IAAI;AACtE,cAAQ,eAAe,YAAY,aAAa,SAAS;AACzD,cAAQ,gBAAgB;AACxB,WAAK,yBAAyB,oBAAoB,OAAO;IAC3D,GACA,UACA,MAAM;AAGR,SAAK,cAAc,YAAY,YAAY,SAAS,CAAC;EACvD;;;;ACrQI,SAAU,YAAY,SAAsB,OAAoC;AACpF,MAAI,OAAO;AACT,WAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAK;AACzC,UAAI,IAAI,WAAW,IAAI,GAAG;AAExB,gBAAQ,MAAM,YAAY,KAAK,KAAe;MAChD,OAAO;AAEL,gBAAQ,MAAM,GAAG,IAAI;MACvB;IACF,CAAC;EACH;AACF;AAEM,SAAU,aAAa,SAAsB,OAAoC;AACrF,MAAI,OAAO;AACT,WAAO,KAAK,KAAK,EAAE,IAAI,SAAM;AAC3B,UAAI,IAAI,WAAW,IAAI,GAAG;AAExB,gBAAQ,MAAM,eAAe,GAAG;MAClC,OAAO;AAEL,gBAAQ,MAAM,GAAG,IAAI;MACvB;IACF,CAAC;EACH;AACF;", "names": ["import_shadertools", "import_core", "viewMatrix", "vs", "import_core", "uniformBlock", "vs", "fs", "VECTOR_TO_POINT_MATRIX", "viewMatrix", "import_shadertools", "import_core", "DEFAULT_LIGHT_COLOR", "DEFAULT_LIGHT_INTENSITY", "idCount", "import_core", "DEFAULT_SHADOW_COLOR", "viewMatrix", "count", "import_core", "count", "import_core", "import_web_mercator", "ZERO_VECTOR", "viewMatrix", "import_web_mercator", "import_core", "import_core", "import_web_mercator", "DEFAULT_COORDINATE_ORIGIN", "DEFAULT_LIGHT_COLOR", "DEFAULT_LIGHT_INTENSITY", "idCount", "import_shadertools", "uniformBlock", "module", "fs", "module", "fs", "import_engine", "count", "import_core", "viewport", "module", "Controller", "import_core", "import_core", "import_core", "import_web_mercator", "import_core", "import_engine", "import_constants", "import_stats", "import_mjolnir", "noop", "module", "_a", "import_core", "import_core", "import_engine", "import_shadertools", "import_constants", "import_constants", "uniformBlock", "vs", "import_engine", "getTransform", "uniformBlock", "vs", "fs", "import_core", "import_webgl", "import_core", "TRANSITION_TYPES", "transition", "module", "import_core", "defaultProps", "defaultProps", "count", "import_web_mercator", "import_core", "EMPTY_ARRAY", "defaultProps", "picking", "TRACE_RENDER_LAYERS", "import_core", "import_web_mercator", "import_core", "DEGREES_TO_RADIANS", "getDistanceScales", "unitsPerMeter", "viewMatrix", "import_core", "import_web_mercator", "DEGREES_TO_RADIANS", "getViewMatrix", "viewMatrix", "import_core", "import_web_mercator", "unitsPerMeter", "import_web_mercator", "import_core", "SphericalCoordinates", "viewMatrix", "import_core", "SphericalCoordinates", "import_core", "import_core", "import_core", "import_web_mercator", "defaultProps", "import_core", "import_web_mercator", "import_core"] }