Skip to content

Commit

Permalink
Fixed posture editor
Browse files Browse the repository at this point in the history
  • Loading branch information
boytchev committed Aug 10, 2024
1 parent 67ba948 commit 3135bb4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
11 changes: 6 additions & 5 deletions src/editor/posture-editor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "mannequin";
import { camera, controls, drawFrame, renderer } from "mannequin/scene.js";
import * as THREE from "three";
import { createStage, Male, Mannequin } from "mannequin";
import { camera, controls, renderer, scene, systemAnimate } from "mannequin/scene.js";
import { Torso } from "../organs/Torso.js";
import { Head } from "../organs/Head.js";
import { Pelvis } from "../organs/Pelvis.js";
Expand All @@ -17,7 +18,7 @@ const EPS = 0.00001;


// create a scene with a better shadow
createScene( animate );
createStage( animate );



Expand Down Expand Up @@ -246,7 +247,7 @@ btnRemoveModel.addEventListener( 'click', removeModel );

controls.addEventListener( 'start', function () {

renderer.setAnimationLoop( drawFrame );
renderer.setAnimationLoop( systemAnimate );

} );

Expand Down Expand Up @@ -373,7 +374,7 @@ function onPointerDown( event ) {

}

renderer.setAnimationLoop( drawFrame );
renderer.setAnimationLoop( systemAnimate );

}

Expand Down
30 changes: 16 additions & 14 deletions src/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ document.head.appendChild( meta );



var clock = new THREE.Clock();



function systemAnimate() {

if ( controls ) controls.update();

if ( stage.animationLoop ) stage.animationLoop( clock.getElapsedTime() );

renderer.render( scene, camera );

}



// initialize Three.js elements that are created by default
function initStage( ) {
Expand Down Expand Up @@ -61,19 +76,6 @@ function initStage( ) {
window.addEventListener( 'resize', onWindowResize, false );
onWindowResize();

var clock = new THREE.Clock();


function systemAnimate() {

if ( controls ) controls.update();

if ( stage.animationLoop ) stage.animationLoop( clock.getElapsedTime() );

renderer.render( scene, camera );

}

return {
renderer: renderer,
scene: scene,
Expand Down Expand Up @@ -174,4 +176,4 @@ function getStage( ) {



export { renderer, scene, camera, light, controls, createStage, getStage };
export { renderer, scene, camera, light, controls, createStage, getStage, systemAnimate, clock };

0 comments on commit 3135bb4

Please sign in to comment.