Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions examples/webgl_animation_skinning_ik.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
followSphere: false,
turnHead: true,
ik_solver: true,
update: updateIK
};

scene = new THREE.Scene();
Expand All @@ -84,7 +85,7 @@
document.body.appendChild( stats.dom );

orbitControls = new OrbitControls( camera, renderer.domElement );
orbitControls.minDistance = .2;
orbitControls.minDistance = 0.2;
orbitControls.maxDistance = 1.5;
orbitControls.enableDamping = true;

Expand All @@ -105,8 +106,6 @@
if ( n.name === 'boule' ) OOI.sphere = n;
if ( n.name === 'Kira_Shirt_left' ) OOI.kira = n;

if ( n.isMesh ) n.frustumCulled = false;

} );
scene.add( gltf.scene );

Expand All @@ -121,11 +120,12 @@
OOI.sphere.material = mirrorSphereMaterial;

transformControls = new TransformControls( camera, renderer.domElement );
transformControls.size = .75;
transformControls.size = 0.75;
transformControls.showX = false;
transformControls.space = 'world';
transformControls.attach( OOI.target_hand_l );
scene.add( transformControls );

// disable orbitControls while using transformControls
transformControls.addEventListener( 'mouseDown', () => orbitControls.enabled = false );
transformControls.addEventListener( 'mouseUp', () => orbitControls.enabled = true );
Expand Down Expand Up @@ -157,7 +157,7 @@
gui.add( conf, 'followSphere' ).name( 'follow sphere' );
gui.add( conf, 'turnHead' ).name( 'turn head' );
gui.add( conf, 'ik_solver' ).name( 'IK auto update' );
gui.add( IKSolver, 'update' ).name( 'IK manual update()' );
gui.add( conf, 'update' ).name( 'IK manual update()' );
gui.open();

window.addEventListener( 'resize', onWindowResize, false );
Expand All @@ -179,7 +179,7 @@

// orbitControls follows the sphere
OOI.sphere.getWorldPosition( v0 );
orbitControls.target.lerp( v0, .1 );
orbitControls.target.lerp( v0, 0.1 );

}

Expand All @@ -194,7 +194,7 @@

if ( conf.ik_solver ) {

if ( IKSolver ) IKSolver.update();
updateIK();

}

Expand All @@ -207,6 +207,18 @@

}

function updateIK() {

if ( IKSolver ) IKSolver.update();

scene.traverse( function ( object ) {

if ( object.isSkinnedMesh ) object.computeBoundingSphere();

} );

}

function onWindowResize() {

camera.aspect = window.innerWidth / window.innerHeight;
Expand Down