Skip to content

Commit 7871d33

Browse files
Mugen87abernier
authored andcommitted
Editor: Add basic support for showing morph targets. (mrdoob#24084)
1 parent 10589be commit 7871d33

File tree

2 files changed

+66
-11
lines changed

2 files changed

+66
-11
lines changed

editor/js/Sidebar.Geometry.BufferGeometry.js

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UIRow, UIText, UISpan, UIBreak } from './libs/ui.js';
1+
import { UIRow, UIText, UISpan, UIBreak, UICheckbox } from './libs/ui.js';
22

33
function SidebarGeometryBufferGeometry( editor ) {
44

@@ -20,19 +20,23 @@ function SidebarGeometryBufferGeometry( editor ) {
2020
container.clear();
2121
container.setDisplay( 'block' );
2222

23-
const text = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setWidth( '90px' );
24-
container.add( text );
23+
// attributes
2524

26-
const container2 = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
27-
container.add( container2 );
25+
const attributesRow = new UIRow();
26+
27+
const textAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/attributes' ) ).setWidth( '90px' );
28+
attributesRow.add( textAttributes );
29+
30+
const containerAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
31+
attributesRow.add( containerAttributes );
2832

2933
const index = geometry.index;
3034

3135
if ( index !== null ) {
3236

33-
container2.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
34-
container2.add( new UIText( ( index.count ).format() ).setFontSize( '12px' ) );
35-
container2.add( new UIBreak() );
37+
containerAttributes.add( new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/index' ) ).setWidth( '80px' ) );
38+
containerAttributes.add( new UIText( ( index.count ).format() ).setFontSize( '12px' ) );
39+
containerAttributes.add( new UIBreak() );
3640

3741
}
3842

@@ -42,9 +46,54 @@ function SidebarGeometryBufferGeometry( editor ) {
4246

4347
const attribute = attributes[ name ];
4448

45-
container2.add( new UIText( name ).setWidth( '80px' ) );
46-
container2.add( new UIText( ( attribute.count ).format() + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
47-
container2.add( new UIBreak() );
49+
containerAttributes.add( new UIText( name ).setWidth( '80px' ) );
50+
containerAttributes.add( new UIText( ( attribute.count ).format() + ' (' + attribute.itemSize + ')' ).setFontSize( '12px' ) );
51+
containerAttributes.add( new UIBreak() );
52+
53+
}
54+
55+
container.add( attributesRow );
56+
57+
// morph targets
58+
59+
const morphAttributes = geometry.morphAttributes;
60+
const hasMorphTargets = Object.keys( morphAttributes ).length > 0;
61+
62+
if ( hasMorphTargets === true ) {
63+
64+
// morph attributes
65+
66+
const rowMorphAttributes = new UIRow();
67+
68+
const textMorphAttributes = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphAttributes' ) ).setWidth( '90px' );
69+
rowMorphAttributes.add( textMorphAttributes );
70+
71+
const containerMorphAttributes = new UISpan().setDisplay( 'inline-block' ).setVerticalAlign( 'middle' ).setWidth( '160px' );
72+
rowMorphAttributes.add( containerMorphAttributes );
73+
74+
for ( const name in morphAttributes ) {
75+
76+
const morphTargets = morphAttributes[ name ];
77+
78+
containerMorphAttributes.add( new UIText( name ).setWidth( '80px' ) );
79+
containerMorphAttributes.add( new UIText( ( morphTargets.length ).format() ).setFontSize( '12px' ) );
80+
containerMorphAttributes.add( new UIBreak() );
81+
82+
}
83+
84+
container.add( rowMorphAttributes );
85+
86+
// morph relative
87+
88+
const rowMorphRelative = new UIRow();
89+
90+
const textMorphRelative = new UIText( strings.getKey( 'sidebar/geometry/buffer_geometry/morphRelative' ) ).setWidth( '90px' );
91+
rowMorphRelative.add( textMorphRelative );
92+
93+
const checkboxMorphRelative = new UICheckbox().setValue( geometry.morphTargetsRelative ).setDisabled( true );
94+
rowMorphRelative.add( checkboxMorphRelative );
95+
96+
container.add( rowMorphRelative );
4897

4998
}
5099

editor/js/Strings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ function Strings( config ) {
144144

145145
'sidebar/geometry/buffer_geometry/attributes': 'Attributes',
146146
'sidebar/geometry/buffer_geometry/index': 'index',
147+
'sidebar/geometry/buffer_geometry/morphAttributes': 'Morph Attributes',
148+
'sidebar/geometry/buffer_geometry/morphRelative': 'Morph Relative',
147149

148150
'sidebar/geometry/capsule_geometry/radius': 'Radius',
149151
'sidebar/geometry/capsule_geometry/length': 'Length',
@@ -479,6 +481,8 @@ function Strings( config ) {
479481

480482
'sidebar/geometry/buffer_geometry/attributes': 'Attributs',
481483
'sidebar/geometry/buffer_geometry/index': 'index',
484+
'sidebar/geometry/buffer_geometry/morphAttributes': 'Morph Attributes',
485+
'sidebar/geometry/buffer_geometry/morphRelative': 'Morph Relative',
482486

483487
'sidebar/geometry/capsule_geometry/radius': 'Radius',
484488
'sidebar/geometry/capsule_geometry/length': 'Length',
@@ -814,6 +818,8 @@ function Strings( config ) {
814818

815819
'sidebar/geometry/buffer_geometry/attributes': '属性',
816820
'sidebar/geometry/buffer_geometry/index': '索引',
821+
'sidebar/geometry/buffer_geometry/morphAttributes': 'Morph Attributes',
822+
'sidebar/geometry/buffer_geometry/morphRelative': 'Morph Relative',
817823

818824
'sidebar/geometry/capsule_geometry/radius': '半径',
819825
'sidebar/geometry/capsule_geometry/length': '长度',

0 commit comments

Comments
 (0)