src/SceneHelper.js
/**
     * creates numbers according to the parameters. They are going to be displayed along the axis.
     * If the number object is already defined, only the texture and position will be updated for performance reasons
     * 
     * This function can create the numbers for all three axes and basically even more than that,
     * it's just a matter of how you define the position lamda function in the parameters
     * 
     * @param {number} numberCount how many numbers to display along the axis
     * @param {number} axisLen length of the axis
     * @param {number} axisNumber JSPLOT3D.XAXIS, JSPLOT3D.YAXIS or JSPLOT3D.ZAXIS
     * @param {number} min the vlaue of the lowest datapoint (as available in the dataframe)
     * @param {number} max the value of the highest datapoint (as available in the dataframe)
     * @param {boolean} animated true if the plot is animated
     * @return {object} with numbers populated group
     */
creates numbers according to the parameters. They are going to be displayed along the axis.
If the number object is already defined, only the texture and position will be updated for performance reasons

This function can create the numbers for all three axes and basically even more than that,
it's just a matter of how you define the position lamda function in the parameters


creates numbers according to the parameters . They are going to be displayed along the axis . If the number object is already defined only the texture and position will be updated for performance reasons This function can create the numbers for all three axes and basically even more than that it ' s just a matter of how you define the position lamda function in the parameters
updateNumbersAlongAxis(numberDensity, axisLen, axisNumber, min, max)
    {
        if(!this.axes)
            return
        let numbersGroupName = ([
            "xNumbers",
            "yNumbers",
            "zNumbers"
        ])[axisNumber-1]
        let numbersGroup = this[numbersGroupName]
        let offset2 = -0.075
        let position
        let align
        if(this.cameraMode == TOPCAMERA)
        {
            position = ([
                (value)=>{return new THREE.Vector3(value, -offset2, offset2)}, 
                ()=>{return new THREE.Vector3(0,0,0)}, 
                (value)=>{return new THREE.Vector3(offset2, -offset2, value)}  
            ])[axisNumber-1]
            align = ([
                "center", 
                "right", 
                "right"  
            ])[axisNumber-1]
        }
        else if(this.cameraMode == LEFTCAMERA)
        {
            position = ([
                ()=>{return new THREE.Vector3(0,0,0)},  (hidden)
                (value)=>{return new THREE.Vector3(offset2, value, offset2/2)}, 
                (value)=>{return new THREE.Vector3(offset2, offset2, value)}  
            ])[axisNumber-1]
            align = ([
                "center",  (hidden)
                "right", 
                "center"  
            ])[axisNumber-1]
        }
        else if(this.cameraMode == FRONTCAMERA)
        {
            position = ([
                (value)=>{return new THREE.Vector3(value, offset2, offset2)}, 
                (value)=>{return new THREE.Vector3(offset2, value, offset2/2)}, 
                ()=>{return new THREE.Vector3(0,0,0)}   (hidden)
            ])[axisNumber-1]
            align = ([
                "center", 
                "right", 
                "right"   (hidden)
            ])[axisNumber-1]
        }
        else
        {
            position = ([
                (value)=>{return new THREE.Vector3(value, -offset2, offset2)}, 
                (value)=>{return new THREE.Vector3(offset2, value, offset2/2)}, 
                (value)=>{return new THREE.Vector3(offset2, -offset2, value)}  
            ])[axisNumber-1]
            align = ([
                "center", 
                "right", 
                "right"  
            ])[axisNumber-1]
        }
        let numberCount = (numberDensity*axisLen)|0
        if(numbersGroup.children.length != numberCount)
        {
            this.disposeMesh(numbersGroup)
            this[numbersGroupName] = new THREE.Group()
            this[numbersGroupName].name = numbersGroupName
            numbersGroup = this[numbersGroupName]
        }
        let children = numbersGroup.children
        let index = 0
        let step = axisLen/numberCount
        for(let x = step; x <= axisLen; x += step)
        {
            let number = (max-min)/numberCount*(index+1) + min
            if(children[index] != undefined && children[index].originalNumber === number)
            {
                continue
            }
            let text = number.toPrecision(3)
            let pos = position(x)
            if(children.length - 1 < index) 
            {
                let textObject = this.placeLetter(text, pos, align)
                textObject.originalNumber = number
                numbersGroup.add(textObject)
            }
            else
            {
                this.updateLetterTextureOnSprite(children[index], text, align)
                children[index].originalNumber = number
                children[index].position.set(pos.x, pos.y, pos.z)
            }
            index ++
        }
        this.axes.add(numbersGroup)
        return numbersGroup
    }
updateNumbersAlongAxis ( numberDensity , axisLen , axisNumber , min , max ) { if ( ! this . axes ) return let numbersGroupName = ( [ "xNumbers" , "yNumbers" , "zNumbers" ] ) [ axisNumber - 1 ] let numbersGroup = this [ numbersGroupName ] let offset2 = - 0.075 let position let align if ( this . cameraMode == TOPCAMERA ) { position = ( [ ( value ) => { return new THREE . Vector3 ( value , - offset2 , offset2 ) } , ( ) => { return new THREE . Vector3 ( 0 , 0 , 0 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , - offset2 , value ) } ] ) [ axisNumber - 1 ] align = ( [ "center" , "right" , "right" ] ) [ axisNumber - 1 ] } else if ( this . cameraMode == LEFTCAMERA ) { position = ( [ ( ) => { return new THREE . Vector3 ( 0 , 0 , 0 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , value , offset2 / 2 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , offset2 , value ) } ] ) [ axisNumber - 1 ] align = ( [ "center" , "right" , "center" ] ) [ axisNumber - 1 ] } else if ( this . cameraMode == FRONTCAMERA ) { position = ( [ ( value ) => { return new THREE . Vector3 ( value , offset2 , offset2 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , value , offset2 / 2 ) } , ( ) => { return new THREE . Vector3 ( 0 , 0 , 0 ) } ] ) [ axisNumber - 1 ] align = ( [ "center" , "right" , "right" ] ) [ axisNumber - 1 ] } else { position = ( [ ( value ) => { return new THREE . Vector3 ( value , - offset2 , offset2 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , value , offset2 / 2 ) } , ( value ) => { return new THREE . Vector3 ( offset2 , - offset2 , value ) } ] ) [ axisNumber - 1 ] align = ( [ "center" , "right" , "right" ] ) [ axisNumber - 1 ] } let numberCount = ( numberDensity * axisLen ) | 0 if ( numbersGroup . children . length != numberCount ) { this . disposeMesh ( numbersGroup ) this [ numbersGroupName ] = new THREE . Group ( ) this [ numbersGroupName ] . name = numbersGroupName numbersGroup = this [ numbersGroupName ] } let children = numbersGroup . children let index = 0 let step = axisLen / numberCount for ( let x = step ; x <= axisLen ; x += step ) { let number = ( max - min ) / numberCount * ( index + 1 ) + min if ( children [ index ] != undefined && children [ index ] . originalNumber === number ) { continue } let text = number . toPrecision ( 3 ) let pos = position ( x ) if ( children . length - 1 < index ) { let textObject = this . placeLetter ( text , pos , align ) textObject . originalNumber = number numbersGroup . add ( textObject ) } else { this . updateLetterTextureOnSprite ( children [ index ] , text , align ) children [ index ] . originalNumber = number children [ index ] . position . set ( pos . x , pos . y , pos . z ) } index ++ } this . axes . add ( numbersGroup ) return numbersGroup }
creates numbers according to the parameters.
creates numbers according to the parameters .
//// Selecting parameters // get the group that contains the numbers according to axisNumber // select the function for updating the number position // x-Axis // y-Axis (hidden) // z-Axis // align of the text. the goal is to nicely align it with the axes // x-Axis // y-Axis (hidden) // z-Axis // x-Axis (hidden) // y-Axis // z-Axis // align of the text. the goal is to nicely align it with the axes // x-Axis (hidden) // y-Axis // z-Axis // x-Axis // y-Axis // z-Axis (hidden) // align of the text. the goal is to nicely align it with the axes // x-Axis // y-Axis // z-Axis (hidden) // unknown or DEFAULTCAMERA // x-Axis // y-Axis // z-Axis // align of the text. the goal is to nicely align it with the axes // x-Axis // y-Axis // z-Axis // until now there have been more or less numbers than numberCount apparently // so dispose the numbers and recreate them // load the numbers that have already been created at some point: // the numbers are stored as children inside a group. one group for each axes. (the groups are stored inside this.axes.children) // to access the children inside the group, use this index: // x is the value in terms of the position in the actual 3D space on the axis // step indicates how far away the numbers are in terms of the actual 3D space // the higher the index the higher the number // this is the number that is going to be displayed // max-min results in the range of numbers. divide it by the numberCount to get the step-size for each number // multiply it by index+1 to get this stepsize*2. example: min = 0.5, max = 1, numberCount = 3 // 0.5/3*1+0.5 = 0.666       0.5/3*2+0.5 = 0.833       0.5/3*3+0.5 = 1 // with 0.5 being left out because it would be where all three axis meet and there is not enough space for numbers // if the number didn't change, don't do anything // if children are not yet created // not yet defined: create from scratch // already defined: update texture and position // no need to check if there are numbers left over as children, because the amount of numbers (numberCount) only changes // when updating the dimensions, and when that happens the whole axes gets disposed