sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🚨 Skimp | 25% Off until March 30 Buy Now

    Face to cam script for PDF3D

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 1.0k 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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement