"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WebGL
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayerContainer = exports.Layer = void 0;
const core_bentley_1 = require("@itwin/core-bentley");
const Graphic_1 = require("./Graphic");
class GraphicWrapper extends Graphic_1.Graphic {
    constructor(graphic) {
        super();
        this.graphic = graphic;
    }
    dispose() {
        this.graphic.dispose();
    }
    get isDisposed() {
        return this.graphic.isDisposed;
    }
    get isPickable() {
        return this.graphic.isPickable;
    }
    collectStatistics(stats) {
        this.graphic.collectStatistics(stats);
    }
    unionRange(range) {
        this.graphic.unionRange(range);
    }
}
/** Within a single tile, contains graphics belonging to a single layer.
 * The same layer may appear in multiple tiles, both within the same tile tree and in other tile trees.
 * Within a single tile tree, all Layers are contained within the same LayerContainer.
 * @internal
 */
class Layer extends GraphicWrapper {
    constructor(graphic, layerId) {
        super(graphic);
        this.layerId = layerId;
        const pair = core_bentley_1.Id64.getUint32Pair(layerId);
        this._idLo = pair.lower;
        this._idHi = pair.upper;
    }
    getPriority(target) {
        return target.currentFeatureSymbologyOverrides.getSubCategoryPriority(this._idLo, this._idHi);
    }
    addCommands(commands) {
        commands.addLayerCommands(this);
    }
    addHiliteCommands(commands, pass) {
        commands.addHiliteLayerCommands(this.graphic, pass);
    }
}
exports.Layer = Layer;
/** Contains a GraphicBranch that can contain Layers, for a single model / tile-tree.
 * All geometry within the container has the same Z.
 * @internal
 */
class LayerContainer extends GraphicWrapper {
    constructor(graphic, drawAsOverlay, transparency, elevation) {
        super(graphic);
        this.elevation = elevation;
        if (drawAsOverlay)
            this.renderPass = 11 /* RenderPass.OverlayLayers */;
        else if (transparency > 0)
            this.renderPass = 7 /* RenderPass.TranslucentLayers */;
        else
            this.renderPass = 1 /* RenderPass.OpaqueLayers */; // ###TODO: What about layers containing naturally-transparent geometry?
    }
    addCommands(commands) {
        commands.processLayers(this);
    }
    addHiliteCommands(commands, pass) {
        commands.addHiliteLayerCommands(this.graphic, pass);
    }
}
exports.LayerContainer = LayerContainer;
//# sourceMappingURL=Layer.js.map