<commit_before>/**
 * @file Picking Controls
 * @author <NAME> <<EMAIL>>
 * @private
 */


import PickingProxy from "./picking-proxy.js";


/**
 * Picking controls
 */
class PickingControls{

    constructor( stage/*, params*/ ){

        this.stage = stage;
        this.viewer = stage.viewer;

    }

    /**
     * get picking data
     * @param {Number} x - canvas x coordinate
     * @param {Number} y - canvas y coordinate
     * @return {PickingProxy|undefined} picking proxy
     */
    pick( x, y ){

        const pickingData = this.viewer.pick( x, y );

        if( pickingData.picker &&
            pickingData.picker.type !== "ignore" &&
            pickingData.pid !== undefined
        ){
            return new PickingProxy( pickingData, this.stage );
        }

    }

}


export default PickingControls;
<commit_msg>safeguard against wrong pid (is due to color interpolation)<commit_after>/**
 * @file Picking Controls
 * @author <NAME> <<EMAIL>>
 * @private
 */


import PickingProxy from "./picking-proxy.js";


/**
 * Picking controls
 */
class PickingControls{

    constructor( stage/*, params*/ ){

        this.stage = stage;
        this.viewer = stage.viewer;

    }

    /**
     * get picking data
     * @param {Number} x - canvas x coordinate
     * @param {Number} y - canvas y coordinate
     * @return {PickingProxy|undefined} picking proxy
     */
    pick( x, y ){

        const pickingData = this.viewer.pick( x, y );

        if( pickingData.picker &&
            pickingData.picker.type !== "ignore" &&
            pickingData.pid !== undefined
        ){
            if( pickingData.pid < pickingData.picker.array.length ){
                return new PickingProxy( pickingData, this.stage );
            }else{
                console.error( "pid > picker.array.length" );
            }
        }

    }

}


export default PickingControls;

{'fraction_non_alphanumeric': 0.12858660998937302, 'fraction_numerical': 0.0, 'mean_word_length': 2.0370967741935484, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082122', 'n_tokens_mistral': 562, 'n_tokens_neox': 537, 'n_words': 143}