forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSidebar.Geometry.BufferGeometry.js
115 lines (66 loc) · 3.21 KB
/
Sidebar.Geometry.BufferGeometry.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { UIRow, UIText, UISpan, UIBreak, UICheckbox } from './libs/ui.js';
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( ( index.count ).format() ).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( ( attribute.count ).format() + ' (' + 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( ( morphTargets.length ).format() ).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;
}
export { SidebarGeometryBufferGeometry };