Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function animateImpulse(startCoord, endCoord, speed) {
- return new Promise((resolve) => {
- post("Calling animateImpulse with:", startCoord, "to", endCoord, "speed:", speed, "\n");
- const gridshape = new JitterObject("jit.gl.gridshape", contextName);
- gridshape.shape = "cone";
- gridshape.color = [Math.random(), Math.random(), Math.random()];
- post("Created gridshape");
- const animNode = new JitterObject("jit.anim.node");
- gridshape.anim = animNode.name;
- animNode.movemode = "local";
- animNode.scale = impulseScale;
- animNode.position = startCoord;
- animNode.lookat = endCoord;
- animNode.direction = endCoord;
- post("Created jit.anim.node");
- const animDrive = new JitterObject("jit.anim.drive");
- animDrive.targetname = animNode.name;
- post("Created jit.anim.drive\n");
- // Validate objects before connecting
- if (!gridshape || !animDrive || !animNode) {
- post("Failed to create gridshape or animPath.");
- return resolve();
- }
- animDrive.move(0, 0, speed);
- post("\nMoving node")
- /* if (animNode.position[0] === endCoord[0] &&
- animNode.position[1] === endCoord[1] &&
- animNode.position[2] === endCoord[2]) {
- post("\nreached endCoord");
- gridshape.freepeer();
- animPath.freepeer();
- animNode.freepeer();
- post("Cleaning and resolving")
- resolve();
- } */
- /* var listener = new JitterListener(animNode.getregisteredname(), callBackResolve);
- function callBackResolve(event) {
- post(event.eventname);
- if(event.subjectname.position = endCoord) {
- post("Animation ends")
- gridshape.freepeer();
- animDrive.freepeer();
- animNode.freepeer();
- post("Cleaning and resolving")
- resolve();
- }
- } */
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement