* Present the Vega Scene, or Stage object using Deck.gl. * @param sceneOrStage Vega Scene object, or Stage object containing chart layout info. * @param height Height of the rendering area. * @param width Width of the rendering area. * @param config Optional presentation configu
(sceneOrStage: Scene3d | Stage, height: number, width: number, config?: PresenterConfig)
| 153 | * @param config Optional presentation configuration object. |
| 154 | */ |
| 155 | present(sceneOrStage: Scene3d | Stage, height: number, width: number, config?: PresenterConfig) { |
| 156 | this.animationCancel(); |
| 157 | const scene = sceneOrStage as Scene3d; |
| 158 | let stage: Stage; |
| 159 | const options: MarkStagerOptions = { |
| 160 | maxOrdinal: 0, |
| 161 | currAxis: null, |
| 162 | defaultCubeColor: this.style.defaultCubeColor, |
| 163 | assignCubeOrdinal: config?.onSceneRectAssignCubeOrdinal || (() => options.maxOrdinal++), |
| 164 | zAxisZindex: config?.zAxisZindex, |
| 165 | }; |
| 166 | //determine if this is a vega scene |
| 167 | if (scene.marktype) { |
| 168 | stage = createStage(scene.view); |
| 169 | sceneToStage(options, stage, scene); |
| 170 | } else { |
| 171 | stage = sceneOrStage as Stage; |
| 172 | } |
| 173 | if (!this.deckgl) { |
| 174 | const classes = createDeckGLClassesForPresenter({ |
| 175 | doubleClickHandler: () => { |
| 176 | this.homeCamera(); |
| 177 | }, |
| 178 | }); |
| 179 | this.OrbitControllerClass = classes.OrbitControllerClass; |
| 180 | |
| 181 | const initialViewState = targetViewState(height, width, stage.view); |
| 182 | |
| 183 | let glOptions: WebGLContextAttributes; |
| 184 | if (config && config.preserveDrawingBuffer) { |
| 185 | glOptions = { preserveDrawingBuffer: true }; |
| 186 | } |
| 187 | |
| 188 | const deckProps: Partial<DeckGLInternalProps> = { |
| 189 | glOptions, |
| 190 | height: null, |
| 191 | width: null, |
| 192 | effects: lightingEffects(), |
| 193 | layers: [], |
| 194 | onClick: config && config.onLayerClick, |
| 195 | views: [new base.deck.OrbitView({ controller: base.deck.OrbitController })], |
| 196 | initialViewState, |
| 197 | container: this.getElement(PresenterElement.gl) as HTMLCanvasElement, |
| 198 | getCursor: (interactiveState: InteractiveStateVegaDeckGL) => { |
| 199 | if (interactiveState.onText || interactiveState.onAxisSelection) { |
| 200 | return 'pointer'; |
| 201 | } else if (interactiveState.onCube) { |
| 202 | return 'default'; |
| 203 | } else { |
| 204 | return 'grab'; |
| 205 | } |
| 206 | }, |
| 207 | }; |
| 208 | if (stage.backgroundColor) { |
| 209 | deckProps.style = { 'background-color': colorToString(stage.backgroundColor) }; |
| 210 | } |
| 211 | this.deckgl = new classes.DeckGL_Class(deckProps); |
| 212 | } |
no test coverage detected