Skip to content

⬅️ Back to Table of Contents

📄 Sidebar.Geometry.BufferGeometry.js

📊 Analysis Summary

Metric Count
🔧 Functions 2
📦 Imports 5
📊 Variables & Constants 13

📚 Table of Contents

🛠️ File Location:

📂 editor/js/Sidebar.Geometry.BufferGeometry.js

📦 Imports

Name Source
UIRow ./libs/ui.js
UIText ./libs/ui.js
UISpan ./libs/ui.js
UIBreak ./libs/ui.js
UICheckbox ./libs/ui.js

Variables & Constants

Name Type Kind Value Exported
strings any let/var editor.strings
signals any let/var editor.signals
container UIRow let/var new UIRow()
geometry any let/var object.geometry
attributesRow UIRow let/var new UIRow()
index any let/var geometry.index
attributes any let/var geometry.attributes
attribute any let/var attributes[ name ]
morphAttributes any let/var geometry.morphAttributes
hasMorphTargets boolean let/var Object.keys( morphAttributes ).length > 0
rowMorphAttributes UIRow let/var new UIRow()
morphTargets any let/var morphAttributes[ name ]
rowMorphRelative UIRow let/var new UIRow()

Functions

SidebarGeometryBufferGeometry(editor: any): UIRow

Parameters:

  • editor any

Returns: UIRow

Calls:

  • container.clear
  • container.setDisplay
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass
  • strings.getKey
  • attributesRow.add
  • new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth
  • containerAttributes.add
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth
  • new UIText( editor.utils.formatNumber( index.count ) ).setFontSize
  • editor.utils.formatNumber
  • new UIText( name ).setWidth
  • new UIText( editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')' ).setFontSize
  • container.add
  • Object.keys
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass
  • rowMorphAttributes.add
  • containerMorphAttributes.add
  • new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass
  • rowMorphRelative.add
  • new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled
  • signals.objectSelected.add
  • signals.geometryChanged.add

Internal Comments:

// attributes (x2)
// morph targets (x2)
// morph attributes (x2)
// morph relative (x2)

Code
function SidebarGeometryBufferGeometry( editor ) {

    const strings = editor.strings;

    const signals = editor.signals;

    const container = new UIRow();

    function update( object ) {

        if ( object === null ) return; // objectSelected.dispatch( null )
        if ( object === undefined ) return;

        const geometry = object.geometry;

        if ( geometry ) {

            container.clear();
            container.setDisplay( 'block' );

            // attributes

            const attributesRow = new UIRow();

            const textAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass( 'Label' );
            attributesRow.add( textAttributes );

            const containerAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
            attributesRow.add( containerAttributes );

            const index = geometry.index;

            if ( index !== null ) {

                containerAttributes.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
                containerAttributes.add( new UIText( editor.utils.formatNumber( index.count ) ).setFontSize( '12px' ) );
                containerAttributes.add( new UIBreak() );

            }

            const attributes = geometry.attributes;

            for ( const name in attributes ) {

                const attribute = attributes[ name ];

                containerAttributes.add( new UIText( name ).setWidth( '80px' ) );
                containerAttributes.add( new UIText( editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
                containerAttributes.add( new UIBreak() );

            }

            container.add( attributesRow );

            // morph targets

            const morphAttributes = geometry.morphAttributes;
            const hasMorphTargets = Object.keys( morphAttributes ).length > 0;

            if ( hasMorphTargets === true ) {

                // morph attributes

                const rowMorphAttributes = new UIRow();

                const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass( 'Label' );
                rowMorphAttributes.add( textMorphAttributes );

                const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
                rowMorphAttributes.add( containerMorphAttributes );

                for ( const name in morphAttributes ) {

                    const morphTargets = morphAttributes[ name ];

                    containerMorphAttributes.add( new UIText( name ).setWidth( '80px' ) );
                    containerMorphAttributes.add( new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize( '12px' ) );
                    containerMorphAttributes.add( new UIBreak() );

                }

                container.add( rowMorphAttributes );

                // morph relative

                const rowMorphRelative = new UIRow();

                const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass( 'Label' );
                rowMorphRelative.add( textMorphRelative );

                const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
                rowMorphRelative.add( checkboxMorphRelative );

                container.add( rowMorphRelative );

            }

        } else {

            container.setDisplay( 'none' );

        }

    }

    signals.objectSelected.add( update );
    signals.geometryChanged.add( update );

    return container;

}

update(object: any): void

Parameters:

  • object any

Returns: void

Calls:

  • container.clear
  • container.setDisplay
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass
  • strings.getKey
  • attributesRow.add
  • new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth
  • containerAttributes.add
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth
  • new UIText( editor.utils.formatNumber( index.count ) ).setFontSize
  • editor.utils.formatNumber
  • new UIText( name ).setWidth
  • new UIText( editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')' ).setFontSize
  • container.add
  • Object.keys
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass
  • rowMorphAttributes.add
  • containerMorphAttributes.add
  • new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize
  • new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass
  • rowMorphRelative.add
  • new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled

Internal Comments:

// attributes (x2)
// morph targets (x2)
// morph attributes (x2)
// morph relative (x2)

Code
function update( object ) {

        if ( object === null ) return; // objectSelected.dispatch( null )
        if ( object === undefined ) return;

        const geometry = object.geometry;

        if ( geometry ) {

            container.clear();
            container.setDisplay( 'block' );

            // attributes

            const attributesRow = new UIRow();

            const textAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setClass( 'Label' );
            attributesRow.add( textAttributes );

            const containerAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
            attributesRow.add( containerAttributes );

            const index = geometry.index;

            if ( index !== null ) {

                containerAttributes.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
                containerAttributes.add( new UIText( editor.utils.formatNumber( index.count ) ).setFontSize( '12px' ) );
                containerAttributes.add( new UIBreak() );

            }

            const attributes = geometry.attributes;

            for ( const name in attributes ) {

                const attribute = attributes[ name ];

                containerAttributes.add( new UIText( name ).setWidth( '80px' ) );
                containerAttributes.add( new UIText( editor.utils.formatNumber( attribute.count ) + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
                containerAttributes.add( new UIBreak() );

            }

            container.add( attributesRow );

            // morph targets

            const morphAttributes = geometry.morphAttributes;
            const hasMorphTargets = Object.keys( morphAttributes ).length > 0;

            if ( hasMorphTargets === true ) {

                // morph attributes

                const rowMorphAttributes = new UIRow();

                const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setClass( 'Label' );
                rowMorphAttributes.add( textMorphAttributes );

                const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
                rowMorphAttributes.add( containerMorphAttributes );

                for ( const name in morphAttributes ) {

                    const morphTargets = morphAttributes[ name ];

                    containerMorphAttributes.add( new UIText( name ).setWidth( '80px' ) );
                    containerMorphAttributes.add( new UIText( editor.utils.formatNumber( morphTargets.length ) ).setFontSize( '12px' ) );
                    containerMorphAttributes.add( new UIBreak() );

                }

                container.add( rowMorphAttributes );

                // morph relative

                const rowMorphRelative = new UIRow();

                const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setClass( 'Label' );
                rowMorphRelative.add( textMorphRelative );

                const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
                rowMorphRelative.add( checkboxMorphRelative );

                container.add( rowMorphRelative );

            }

        } else {

            container.setDisplay( 'none' );

        }

    }