in packages/vega-deck.gl/src/presenter.ts [155:231]
present(sceneOrStage: Scene3d | Stage, height: number, width: number, config?: PresenterConfig) {
this.animationCancel();
let scene = sceneOrStage as Scene3d;
let stage: Stage;
let options: MarkStagerOptions = {
maxOrdinal: 0,
currAxis: null,
defaultCubeColor: this.style.defaultCubeColor,
assignCubeOrdinal: config?.onSceneRectAssignCubeOrdinal || (() => options.maxOrdinal++),
zAxisZindex: config?.zAxisZindex
};
//determine if this is a vega scene
if (scene.marktype) {
stage = createStage(scene.view);
sceneToStage(options, stage, scene);
} else {
stage = sceneOrStage as Stage;
}
if (!this.deckgl) {
const classes = createDeckGLClassesForPresenter({
doubleClickHandler: () => {
this.homeCamera();
}
});
this.OrbitControllerClass = classes.OrbitControllerClass;
const initialViewState = targetViewState(height, width, stage.view);
let glOptions: WebGLContextAttributes;
if (config && config.preserveDrawingBuffer) {
glOptions = { preserveDrawingBuffer: true };
}
const deckProps: Partial<DeckGLInternalProps> = {
glOptions,
height: null,
width: null,
effects: lightingEffects(),
layers: [],
onClick: config && config.onLayerClick,
views: [new base.deck.OrbitView({ controller: base.deck.OrbitController })],
initialViewState,
container: this.getElement(PresenterElement.gl) as HTMLCanvasElement,
getCursor: (interactiveState: InteractiveStateVegaDeckGL) => {
if (interactiveState.onText || interactiveState.onAxisSelection) {
return 'pointer';
} else if (interactiveState.onCube) {
return 'default';
} else {
return 'grab';
}
}
};
if (stage.backgroundColor) {
deckProps.style = { 'background-color': colorToString(stage.backgroundColor) };
}
this.deckgl = new classes.DeckGL_Class(deckProps);
}
let cubeCount = Math.max(this._last.cubeCount, stage.cubeData.length);
if (options.maxOrdinal) {
cubeCount = Math.max(cubeCount, options.maxOrdinal);
const empty: Partial<Cube> = {
isEmpty: true,
color: [0, 0, 0, 0] // possibly a bug in Deck.gl? set color to invisible.
};
stage.cubeData = patchCubeArray(cubeCount, empty, stage.cubeData as Cube[]);
}
this.setDeckProps(stage, height, width, cubeCount, config);
const a = getActiveElementInfo();
mount(LegendView({ legend: stage.legend, onClick: config && config.onLegendClick }), this.getElement(PresenterElement.legend));
setActiveElement(a);
if (config && config.onPresent) {
config.onPresent();
}
}