Skip to content

Commit

Permalink
Implemented Recursive hide( ) #29
Browse files Browse the repository at this point in the history
  • Loading branch information
boytchev committed Aug 18, 2024
1 parent 3258959 commit 653bd4b
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 47 deletions.
12 changes: 12 additions & 0 deletions docs/userguide-bg.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ man.l_nails.recolor( 'black' );

``` javascript
figure.joint.hide();
figure.joint.hide( true );
```

където *joint* е името на частта от тялото, която
Expand All @@ -499,6 +500,17 @@ man.l_arm.hide();
man.r_arm.hide();
```

Ако `hide` се използва с параметър `true`, тогава скриването
се прилага както а съответната част на тялото, така и на
всички подчинени части.

Показването на скрита част на тяло става с:

``` javascript
figure.joint.show();
figure.joint.show( true );
```

Частите на тялото са наследници на класа [`THREE.Object3D`](https://threejs.org/docs/#api/en/core/Object3D) и поддържат
неговите свойства и методи. Въпреки това, поради конструкцията
на скелета и свързването на ставите, мащабирането на част от
Expand Down
12 changes: 12 additions & 0 deletions docs/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ The method to hide a joint from a figure is:

``` javascript
figure.joint.hide();
figure.joint.hide( true );
```

where *joint* is the name of the body part to hide. Hidden body parts can still
Expand All @@ -430,6 +431,17 @@ man.l_arm.hide();
man.r_arm.hide();
```

If `hide` is used with parameter `true`, then hiding is applied to the body part
and all its subparts.

To show a hidden body part use:

``` javascript
figure.joint.show();
figure.joint.show( true );
```


Body parts are descendants of [`THREE.Object3D`](https://threejs.org/docs/#api/en/core/Object3D)
and support its properties and methods. However, due to the skeletal dependency
and joint attachment, scaling of a body part should be congruent along all axes,
Expand Down
4 changes: 1 addition & 3 deletions src/editor/posture-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import { GLTFExporter } from "three/addons/exporters/GLTFExporter.js";
const EPS = 0.00001;


//var mouseInterface = false;
//var touchInterface = false;


// create a scene with a better shadow
createStage( animate );
Expand Down Expand Up @@ -370,6 +367,7 @@ function onPointerDown( event ) {
if ( !cbMovX.checked && !cbMovY.checked && !cbMovZ.checked ) obj.imageWrapper.add( gauge );
gauge.position.y = ( obj instanceof Ankle ) ? 2 : 0;


processCheckBoxes();

}
Expand Down
76 changes: 38 additions & 38 deletions src/organs/Fingers.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,49 +72,49 @@ class Fingers extends Joint {
} // Fingers.recolor

// hide all fingers
hide( ) {

this.finger_0.hide( );
this.finger_1.hide( );
this.finger_2.hide( );
this.finger_3.hide( );
this.finger_4.hide( );

this.finger_0.mid.hide( );
this.finger_1.mid.hide( );
this.finger_2.mid.hide( );
this.finger_3.mid.hide( );
this.finger_4.mid.hide( );

this.finger_0.tip.hide( );
this.finger_1.tip.hide( );
this.finger_2.tip.hide( );
this.finger_3.tip.hide( );
this.finger_4.tip.hide( );
hide( recursive ) {

this.finger_0.hide( recursive );
this.finger_1.hide( recursive );
this.finger_2.hide( recursive );
this.finger_3.hide( recursive );
this.finger_4.hide( recursive );

this.finger_0.mid.hide( recursive );
this.finger_1.mid.hide( recursive );
this.finger_2.mid.hide( recursive );
this.finger_3.mid.hide( recursive );
this.finger_4.mid.hide( recursive );

this.finger_0.tip.hide( recursive );
this.finger_1.tip.hide( recursive );
this.finger_2.tip.hide( recursive );
this.finger_3.tip.hide( recursive );
this.finger_4.tip.hide( recursive );

}


// show all fingers
show( ) {

this.finger_0.show( );
this.finger_1.show( );
this.finger_2.show( );
this.finger_3.show( );
this.finger_4.show( );

this.finger_0.mid.show( );
this.finger_1.mid.show( );
this.finger_2.mid.show( );
this.finger_3.mid.show( );
this.finger_4.mid.show( );

this.finger_0.tip.show( );
this.finger_1.tip.show( );
this.finger_2.tip.show( );
this.finger_3.tip.show( );
this.finger_4.tip.show( );
show( recursive ) {

this.finger_0.show( recursive );
this.finger_1.show( recursive );
this.finger_2.show( recursive );
this.finger_3.show( recursive );
this.finger_4.show( recursive );

this.finger_0.mid.show( recursive );
this.finger_1.mid.show( recursive );
this.finger_2.mid.show( recursive );
this.finger_3.mid.show( recursive );
this.finger_4.mid.show( recursive );

this.finger_0.tip.show( recursive );
this.finger_1.tip.show( recursive );
this.finger_2.tip.show( recursive );
this.finger_3.tip.show( recursive );
this.finger_4.tip.show( recursive );

}

Expand Down
20 changes: 18 additions & 2 deletions src/organs/Joint.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,32 @@ class Joint extends THREE.Group {

}

hide() {
hide( recursive ) {

this.image.visible = false;

if ( recursive )
this.traverse( ( joint )=> {

if ( joint.image )
joint.hide();

} );

} // Joint.hide

show() {
show( recursive ) {

this.image.visible = true;

if ( recursive )
this.traverse( ( joint )=> {

if ( joint.image )
joint.show();

} );

} // Joint.show

// attach Object3D instance to the joint
Expand Down
8 changes: 4 additions & 4 deletions src/organs/Phalange.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class Phalange extends Joint {

}

hide( ) {
hide( recursive ) {

super.hide();
super.hide( recursive );
if ( this.nail ) this.nail.visible = false;

}

show( ) {
show( recursive ) {

super.show();
super.show( recursive );
if ( this.nail ) this.show.visible = false;

}
Expand Down

0 comments on commit 653bd4b

Please sign in to comment.