Two objects move synchronized issue (i think) #616
-
So i have this scenario : two aeroplanes fly side by side and in the same altitude . let's call them aeroplaneA and aeroplaneB . There are two phases of their movement : the first one is that aeroplaneA and aeroplaneB maintain the movement , the other one is that aeroplaneB change its altitude fly down 10 unit while maintain the Horizontal speed. let groupA = new Group();
let groupB = new Group();
const speed = 300;
const fullTime = 10;
let aeroplaneA_Tween = new TWEEN(aeroplaneA.position,groupA);
let aeroplaneB_Tween_phase_one = new TWEEN(aeroplaneB.position,groupB);
let aeroplaneB_Tween_phase_two = new TWEEN(aeroplaneB.position,groupB);
aeroplaneA_Tween.to({
z:aeroplaneA.position.z+speed*fullTime
},fullTime*1000);
aeroplaneB_Tween_phase_one.to({
z:aeroplaneB.position.z+speed*fullTime/2
},fullTime/2*1000);
aeroplaneB_Tween_phase_two.to({
y : aeroplaneB.position.y-10 ,
z : aeroplaneB.position.z+speed*fullTime/2
},fullTime/2*1000);
aeroplaneB_Tween_phase_one.chain(aeroplaneB_Tween.phase_two);
aeroplaneA_Tween.start();
aeroplaneB_Tween_phase_one.start();
......
function animate(){
groupA.update();
groupB.update();
...... //render canvas
requestAnimationFrame(animate);
} But the thing is , at the very beginning of the phase two , I can see clearly aeroplaneB is fly behind aeroplaneA , they suppose to fly side by side . I noticed the user guide provide a way to synchronize things , but i dont understand . var currentTime = player.currentTime
TWEEN.update(currentTime) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @AsDeadAsADodo. I am sorry for the late reply. I hope you have figured out a solution by now. But to answer the original question, you are creating both At the moment in time you execute that code to create your Tween instances, I think what you need is |
Beta Was this translation helpful? Give feedback.
Hello @AsDeadAsADodo. I am sorry for the late reply. I hope you have figured out a solution by now. But to answer the original question, you are creating both
aeroplaneB_Tween_phase_one
andaeroplaneB_Tween_phase_two
at the same time. This means that the destination value for Z, for both animations is the same:aeroplaneB.position.z+speed*fullTime/2
.At the moment in time you execute that code to create your Tween instances,
aeroplaneB.position.z+speed*fullTime/2
has the same value for both. That means, for both animations, the end result will be whateveraeroplaneB.position.z+speed*fullTime/2
was at the time you created the tweans.I think what you need is
aeroplaneB.position.z+speed*ful…