Advertisement
Guest User

Untitled

a guest
Dec 19th, 2024
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function animateImpulse(startCoord, endCoord, speed) {
  3.     return new Promise((resolve) => {
  4.        
  5.         post("Calling animateImpulse with:", startCoord, "to", endCoord, "speed:", speed, "\n");
  6.  
  7.         const gridshape = new JitterObject("jit.gl.gridshape", contextName);
  8.         gridshape.shape = "cone";
  9.         gridshape.color = [Math.random(), Math.random(), Math.random()];
  10.        
  11.         post("Created gridshape");
  12.  
  13.         const animNode = new JitterObject("jit.anim.node");
  14.         gridshape.anim = animNode.name;
  15.         animNode.movemode = "local";
  16.         animNode.scale = impulseScale;
  17.         animNode.position = startCoord;
  18.         animNode.lookat = endCoord;
  19.         animNode.direction = endCoord;
  20.  
  21.         post("Created jit.anim.node");
  22.  
  23.         const animDrive = new JitterObject("jit.anim.drive");
  24.         animDrive.targetname = animNode.name;
  25.  
  26.         post("Created jit.anim.drive\n");
  27.  
  28.         // Validate objects before connecting
  29.         if (!gridshape || !animDrive || !animNode) {
  30.             post("Failed to create gridshape or animPath.");
  31.             return resolve();
  32.         }
  33.    
  34.         animDrive.move(0, 0, speed);
  35.  
  36.         post("\nMoving node")
  37.  
  38.        /*  if (animNode.position[0] === endCoord[0] &&
  39.             animNode.position[1] === endCoord[1] &&
  40.             animNode.position[2] === endCoord[2]) {
  41.  
  42.             post("\nreached endCoord");
  43.  
  44.             gridshape.freepeer();
  45.             animPath.freepeer();
  46.             animNode.freepeer();
  47.             post("Cleaning and resolving")
  48.             resolve();
  49.         } */
  50.  
  51.         /* var listener = new JitterListener(animNode.getregisteredname(), callBackResolve);
  52.        
  53.         function callBackResolve(event) {
  54.             post(event.eventname);
  55.             if(event.subjectname.position = endCoord) {
  56.                 post("Animation ends")
  57.                 gridshape.freepeer();
  58.                 animDrive.freepeer();
  59.                 animNode.freepeer();
  60.                 post("Cleaning and resolving")
  61.                 resolve();
  62.             }
  63.         } */
  64.     });
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement