javascript - Using three.js and tween.js to change the position of an object -


i making first steps coding javascript , playing three.js too.

as can see here http://codepen.io/gnazoa/pen/bjobzz , if make click in box, change z position.

the problem when tween starts, , make click in box again, animation stops , starts again.

there not way avoid make click event again when tween has started? have suggestion?

this piece of made:

        function ondocumentmousedown(event) {            event.preventdefault();            mouse.x = (event.clientx / renderer.domelement.clientwidth) * 2 - 1;           mouse.y = -(event.clienty / renderer.domelement.clientheight) * 2 + 1;            raycaster.setfromcamera(mouse, camera);            var intersects = raycaster.intersectobjects(scene.children);            if (intersects.length > 0) {              new tween.tween(intersects[0].object.position).to({                 x: 0,                 y: 0,                 z: 1000               }, 50000)               .easing(tween.easing.elastic.out).start();              new tween.tween(intersects[0].object.rotation).to({                 x: 0,                 y: 2,                 z: 0               }, 50000)               .easing(tween.easing.elastic.out).start();            }         }  


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -