sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Face to cam script for PDF3D

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 861 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • juan974J Offline
      juan974
      last edited by juan974

      hi all,
      i m starting to use javascript for PDF3D, here is an example :
      tree always face, acrobat 8.1 minimum
      the goal is to clone sketchup with "face to camera" function.
      but as you can see in the attached PDF, each time the camera angle is around 0, the tree rotation of +180° if cam angle is positive and -180° if cam angle is negative.
      here is the code :

      
      runtime.setCurrentTool(runtime.TOOL_NAME_SPIN);
      myMouseHandlerPositonCam= new MouseEventHandler();
      myMouseHandlerPositonCam.onMouseMove= true;
       
      myMouseHandlerPositonCam.onEvent= function( event )
      {
      var VecteurCameraXPositonCam =((scene.cameras.getByIndex(0).targetPosition.x)-(scene.cameras.getBy Index(0).position.x));
      var VecteurCameraYPositonCam =((scene.cameras.getByIndex(0).targetPosition.y)-(scene.cameras.getBy Index(0).position.y));
      var VecteurCameraZPositonCam =((scene.cameras.getByIndex(0).targetPosition.z)-(scene.cameras.getBy Index(0).position.z));
      AngleCamPositonCam=Math.atan(VecteurCameraYPositonCam/VecteurCameraXPositonCam);
      
      for (var i=0; i < scene.meshes.count; i++)
      {
      var result = scene.meshes.getByIndex(i).name.indexOf("tree");
      if (result>-1)
        {
               {
                m1 = new Matrix4x4().rotateAboutZ(AngleCamPositonCam+Math.PI/2)
                scene.meshes.getByIndex(i).transform.set(m1);
                scene.meshes.getByIndex(i).renderMode = ("solid");
               }
        }
      }
       
      }    
      runtime.addEventHandler( myMouseHandlerPositonCam );
      
      

      i tried to add a condition :

      if AngleCam > 0
      then m1 = new Matrix4x4().rotateAboutZ(AngleCamPositonCam+Math.PI/2)
      else m1 = new Matrix4x4().rotateAboutZ(AngleCamPositonCam-Math.PI/2)

      but it doesn t work...
      any ideas?

      juan974 (Réunion island)
      website : http://sketchucation.com/click.php?url=http://www.tarn.us

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        bbCodes use square brackets [ code ] and [ /code ] not < code >

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • juan974J Offline
          juan974
          last edited by

          i'm a newbie in programming ...

          juan974 (Réunion island)
          website : http://sketchucation.com/click.php?url=http://www.tarn.us

          1 Reply Last reply Reply Quote 0
          • juan974J Offline
            juan974
            last edited by

            finally the problem was tan(alpha)=tan(alpha+180°)
            here the result... 😍

            juan974 (Réunion island)
            website : http://sketchucation.com/click.php?url=http://www.tarn.us

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement