Javascript function to rotate an object around its axis

Hello,
I wonder if it is possible to rotate an object around its axis (eg 45 ° rotation)?
I want to make this rotation with a button and a Javascript code!
Is it possible? if so, have a track for me to start?
thank you

Possible, yes - but you will need some basic knowledge of how 3D matrix transformations work if you want to do anything complex.
The code to rotate a node in a 3D scene by 45 degrees on the X axis is
myNode.transform.rotateAboutXInPlace(Math.PI/4)

Similar Messages

  • Rotate a Object Around Center Axis

    Hey peoples, new to flash here.  I'm using CS3 with ActionScript 3.0.  What I want is simple, and I've done some searching but nothing that can get me the right results.  I'm going to post a link that does exactly what I want:
    http://www.newgrounds.com/dump/item/d25a3dd46f2ff49f2ec892c425cbbd1e
    This rotates the circular object around a center point in a way that you can distort the object yet is still remains turning in a circular motion.  A simple motion tween rotating the image will only work if the object is perfectly round, so distorting the object to make it more straight or curved won't work with a simple tween.  I want to do exactly what is happening here (with my own object), is there some AS3 behind the scenes here making this turn on a center point??  Thanks for the help

    Yes, but I still don't know what you mean by the parent child relationship.  Lets say I use a simple rotate line like:
    objectname.rotation = 360;
    That should spin it, but how do I spin it correctly if the object is skewed like in the bottom right picture of my example?

  • After Effect CC: Custom JavaScript functions of a flashplayer object return no value

    Hi
    With AfterEffects CC scripting it looks like custom JavaScript functions of a flashplayer object return no value when invoked from ActionScript code
    This can be seen in the sample script shipped with ExtendScript Toolkit named ActionScriptDemo.jsx:
    Create a flashplayer object in a JSX file with a custom getJavaScriptNumber function:
    var flashPlayer = flashPalette.add("flashplayer", cBounds);
    flashPlayer.getJavaScriptNumber = function() {
              return 12345;
    Invoke the custom getJavaScriptNumber function from ActionScript code of an .MXML file:
    public function requestJavaScriptNumber():void{
              var res:int = ExternalInterface.call("getJavaScriptNumber");
              estkNumber = res;
    The ExternalInterface.call("getJavaScriptNumber") call return no value
    Any idea or a suggested workaround??
    Thanks, Erez.

    I wonder if this was intentional on Adobe's part.  It seems rather odd that it just "broke" with the upgrade to CC.
    I was thinking of a way to display a "web page" within an ExtendScript dialog / window, and thought that I could use Flash / ActionScript to do just that and then display that within the dialog.  It seems, now, that it is just a bad idea because the API for ExternalInterface is broken--I would need two-way communication between the Flash object presenting the webpage and the ExtendScript ScriptUI Panel.
    Is there a workaround for this?
    Thanks,
    Arie

  • How to rotate 3D objects around the edge of another 3D object

    Hi everyone:
    I am trying to create an image of a human finger with 3D picture control, but in a simpler way. I intended to use three square boxes which are created by using Create Box VI.. Then I use Translate Invoke Node to line them up one after another. Then, I use Rotation Invoke Node to manipulate the rotation of the second and the third box. But, here are the problems.
    The first problem: How can I rotate the second box(Green box) around the edge of the first box(Red box), so that when the green box rotates, it doesn't overlap with the red box. I want it to be the same with the blue box, so that the blue box rotates around the edge of the green box. 
    The second problem: At the moment, the third box(Blue box) is rotating around the origin of the first box(Red box), how can I change it so that the blue box rotates around the edge of the second box(Green box). 
    I have attached the VI to this post. Please could anyone help me.
    Thanks very much
    Tommy Yip
    Attachments:
    Original design.vi ‏26 KB

    Hi Tommy,
    To get rid of the overlapping boxes one thing you could alter the position of the green box as the angle is increased, the green box could move right on its X axis and rotate on the XY plane so it bevels round the red box in accordance with the angle you give. This would require some playing around however to get the values just right.
    Have you had any success or updates since your first post?
    Regards,
    Ben B.
    Applications Engineer
    National Instruments UK & Ireland
    "I've looked into the reset button, the science is impossible!"

  • Record simple rotate of object on Z axis Options

    Hi,
    Using CS4. Is it possible to automatically record an object
    turning
    360 on the Z axis? At the moment, I am turning the object a
    couple of
    degrees (using 3d Rotation tool), pressing Insert Keyframe,
    then
    turning the object a little bit more, then Insert Keyframe
    again, etc.
    But it's just a simple 360 rotation - it must be possible to
    do this
    automatically?
    Thanks.

    Well, I'm getting closer but I'm not there yet.
    I found out how to use this expression which seems to do what I want but only for a single object sway.  If I could randomize this and put it on all of the items it would be pretty close.  Here's the expression:
    Math.sin(time*2)*1;
    This has two problems.  First it appears to start  swaying at the begining of the comp instead of the comp starting with the object already swaying.  I might be wrong on this.
    The other problem I already mentioned.  I don't know how to randomize this so each additional object has a random sway.  I at least found out how to attach the stay to a slider:
    Math.sin(time*2)*thisComp.layer("new slider control").effect("SwayAmmount")("Slider");
    I am able to set the slider at 1 and then to stop it I set it to 0.  I don't think this has a real ease or inertia, but it's ok I guess.
    But again, no random options.  I've searched high and low to understand the random function.  I found: "random()" but I need it to freeze at a random number.  I found "seedRandom(x,true)" but all directions I can find for that talk only about possition in the comp.  I've given up trying to translate this from position.
    Here's the closest I've come, but honestly I'm not even sure that it's a real function...
    seedRandom(3,true);
    RanNum = random(-2,4)
    Math.sin(time*(RanNum))*thisComp.layer("new slider control").effect("SwayAmmount")("Slider");
    This again links to the slider.  It DOES randomize somewhat and is better than nothing.  But surely there is a "correct" way which I am completely overlooking.  Using this method all layers sway left to right (fairly similarlily).  I would love to have some begin right to left, random...
    Any thoughts?
    Thanks!
    -Stephen

  • Click, animate rotation of Object by +90° via AS3?

    I have a button that will rotate an object in its parent by 90 degrees every time its clicked:
    b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
    function rotateCW(event:MouseEvent):void
    Object(this).parent.module.rotation += 90;
    Which is fine, but I think it would be a nice touch if the object's rotation were animated.
    I tried this:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
    function rotateCW(event:MouseEvent):void
    var rCW:Tween = new Tween(Object(this).parent.module, "rotate", Strong.easeOut, 0, +90, .5, true);
    ... but it does nothing at all, I am guessing that "rotate" is a property option, I can find no documentation for that, only x, y, their scale and alpha.
    I'm sure this has been done by many, can anyone offer a helpful clue as to how this function would be properly coded?
    Thanks!

    Thats brilliant, I tweaked it a little; replaced the 0 with the current angle of the clip) and now it works perfectly:
    var rCW:Tween;
    b_rotate_CW.addEventListener(MouseEvent.CLICK, rotateCW);
    function rotateCW(event:MouseEvent):void
    rCW = new Tween(Object(this).parent.module, "rotation", Strong.easeOut, Object(this).parent.module.rotation, Object(this).parent.module.rotation+90, .5, true);
    Who would have known you could use a target path in place of a value?
    Where can everyone learn AS3 as you know it?
    Thank you again for your immense help!

  • Rotation of objects

    I'm trying to move objects from A to B  (Round photos on a background of a map). During its way from A to B the object is shrinking. So far no problem. But my intention was to rotate the object on its "journey".
    But I didn't found a clue to work with anchor points, so the object is flying around an unknown anchor point (visible on the screenshot) instead of just turning in circles.
    I enclose two screenprints for your information.
    Am I asking too much?
    Not clear yet? I'll try to explain furher.
    Rob

    Rob,
    This is described in the help file and manual (page 258+). Select the clip in the timeline so it shows in the program monitor, select the motion effect in the effect controls panel and then adjust the anchor point by adjusting the figures in your screenshots by dragging left of right for both horizontal and vertical position. You can keyframe the anchor points so it flows nicely with the other keyframes you have set.

  • Calling a javascript function from an Applet

    I am trying to make an applet that works on as many browsers as possible, so I am sticking to Version JCK 1.1
    I am trying to call pass the javascript function into a URL object like this
    URL url = new URL("javascript:" + function, "_self");but I keep getting a MalformedURLException. I've read some of the other comments, but they all say to use the netscape.javascript package and the JSObject class, but I can't find that object anywhere inside the API posted on Sun's website.
    Any help would be greatly appreciated.

    To access JavaScript methods, properties, and data structures from your Java applet, import the Netscape javascript package:
    import netscape.javascript.*
    public class myApplet extends Applet
    {   public void init()
    {     /* Use the following syntax to call JavaScript methods:*/
    JSObject.getWindow().eval("expression")
    /*expression is a JavaScript expression that evaluates to a JavaScript method call. */ }

  • Swinging/Rotating an object in AE 5.5

    Hi all,
    I have a question about something that I am trying to achieve in AE5,5.
    I have a clip that I would like to 'rotate' into the frame and was wondering how I could do this. If I might explain:
    If you can imagine the action of a clapperboard, you might have an idea of the effect I'm trying to attain.Essentially, I'd like the clip to start offscreen on the right hand side of the frame, At this point, the clip would be rotated 90 degree clockwise. Over the a next couple of seconds, I'd like it to 'crash' down into the frame, rotating around the lower, right corner so that it ends up filling the frame and the correct way up :-). I thought it would be fairly easy to do this with a few adjustments around the anchor points but I seem to be having no luck as whenever I move the anchor point, the entire clip seems to move rather than just adjusting the point at which I'd like it to rotate.
    What am I missing??
    Any help would be greatly appreciated.
    Many thanks,
    Sean

    :-) Ah, I've been rumbled!! To be honest, I come from a straight video editing background and am just starting to get to grips with AE. I have just cracked open the Classroom-In-A-Book this week and (naively) thought that it might be something I could achieve simply by changing the anchor point from which to rotate the object around.  Seems like I was slightly off track - maybe I should have perservered with the book before I tried!
    Many thanks for the replies - I will certainly have a look at the blog post you mentioned and will see how I get on. From what I've seen so far, AE looks like it's going to be keep me occupied for many, many months to come. I'm looking forward to it!
    thanks again,
    Sean

  • Distributing objects around circle

    I am working on Mac OS 10.4.11 and Adobe CS3 ME.
    I know it's possible to evenly distribute objects in a line. But I would like to evenly distribute objects in a circle shape. Can that be done in Indesign or Illustrator?

    Yes, it can be done in either InDesign or Illustrator.
    I'm going to give you the steps in InDesign, but Illustrator is almost identical.
    First draw the shape that you want to distribute. Position it where you would want the top or 12 o'clock item.
    Now, switch to the Rotate tool. As you do, a rotation center point appears inside the bounding box of the original object.
    This center point needs to be moved to the center of the circle that you want to rotate the object around. (Or where the hands of the clock would originate from.)
    Hold the Option or Alt key and click where the roatation center point needs to be.
    A dialog box appears.
    Enter the angle of roation. This is usually an amount that is created by dividing 360. For instance, if you want 10 objects around the circle, you would enter the rotation amount of 36 degrees.
    If you wanted 12 objects, you would enter the rotation amount of 30 degrees. You figure out what you want.
    Use the Preview amount to see what it would look like. When you like what you have, click the Copy button (not the OK button).
    You will now have one new object in position. At this point you have "primed the pump" so to speak. InDesign now knows to make a copy at a certain rotation.
    Go to Object > Transform Again > Transform Again. The keyboard shortcut is Cmd-Opt-3 or Control-Alt-3.
    Each time you invoke the command, a new copy appears in position.
    This is the classic way to distribute objects in a circle.
    There are other ways to do it that would put the object around an actual circular object.
    But you might as well learn this one first.

  • How to limit rotation around an axis

    Hello!
    I am using Mouse Rotate to rotate an object around it's axis:
    MouseRotate mouseRotate = new MouseRotate();
    mouseRotate.setTransformGroup( sectionTransform );
    mouseRotate.setSchedulingBounds( new BoundingSphere() );
    mouseRotate.setFactor( 0, 0.3 );
    Currently it rotates 360 degrees, but I would like to be able to limit the rotation angle to say 180. Could you please help me out?
    Thanks!
    Anna.

    You might want to consider creating your own behaviour. It depends on your implementation, but if you have a Transform group above the object, you can get the transform and get the rotation values from that transform. It will take a bit of math, but here's a primer to get you started...
    http://www.martinb.com/maths/geometry/rotations/conversions/index.htm
    http://www.martinb.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm
    so if you calculate the angle around a particular axis from that transform and it is "greater" than the limit, then you can just set the transform's rotation angle to the limit by reconstructing a new transform and placing that transform in the transform group.
    Anyway, I dont know if that helps. It really depends on what you have as far as implementation thus far. My best suggestion is to try to create your own rotation behaviour.
    Cheers,
    Greg

  • How to use a Session object in a Javascript function

    I have an object that I have set in my session.
    On my jsp I want to pull it out of my session and use it as a parameter for a javascript function. But I am not sure how to do that... the function call is below... I want to assign a value to ifFormat (last variable in function) But I am not sure what to use inside javascript.
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:XXXXX});
    </script>

    Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
    If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
    <%
      String someValue = (String)session.getAttribute("theAttributeName");
    %>
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:<%=someVale%>});
    </script>

  • How to reference JavaScript functions stored in a script object on a different page?

    Hi,
    I have a form which has 2 pages. I have a bunch of JavaScript functions under script objects on page 1. How can I access these functions from page 2?
    I tried the following but none of it work:
    form1.page2.#variables[0].testScript.doThisNow();
    form1.page2.variables[0].testScript.doThisNow();
    form1.page2.variables.testScript.doThisNow();
    Please help.

    Hi,
    Simplest way would be to drag the script object to be under the root node (form1). On both pages would would then be able to reference the function by:
    testScript.doThisNow();
    If you leave the script object under page1, then from page2, the following should work:
    page1.testScript.doThisNow();
    Hope that helps,
    Niall

  • Using a request scope object in a javascript function

    Hello,
    is there a way to obtain a reference to a request scope attribute in a javascript function?
    or after using <jsp:useBean id="myBean" ...>, how do I pass the "myBean" object to a javascript fuction?
    Thanks for any help.
    E-

    ok, thanks...this is working for a string property of a bean... but I get an 'invalid character' error when I want to create an actual reference to the bean object itself.
    here is the jist of what I need to get working... myBean has a property 'listItems' that is a Vector of listBeans.
    function buildList() {
    var myBean = <%=request.getAttribute("mybean")%> ;
    // get referenence to the Vector property listItems
    var list = myBean.getListItems();
    // now I want to iterate the list and use the properties of the list beans
    for (x = 0 ; x < list.size() ; x++ ) {
    var listBean = list[x];
    var foo = listBean.getFoo();
    // need to use foo to populate a hierarchical list
    can I do this in JavaScript??? do I need to cast the classes to the variables?

  • How to always rotate objects around the same point, even using the right-click menu?

    I need some of my objects to always rotate around the same point. How can I select a point which will stay that way?
    Using the rotate tool resets after deselecting.
    Also, I'd like to rotate objects around a certain point even when using the right click > Transform > Rotate.
    Is it possible?

    Right, so this is where Illustrator falls short with respect you your need, but only in the sense that the reference point can't be made to stick. You can, however, use Smart Guides to make it so the point is easy to set at exactly the same location, (especially since your object has an anchor point there), manually before each rotation.

Maybe you are looking for

  • How can you save a draft SMS on X3-02 ?

    How can you save a draft SMS on X3-02 ?  Can't seem to find an option to do this  ...  Lost message typed half way  when I got out of the editor to check the calendar. Am I missing something or has Nokians obsoleted this function on the latest S40 pl

  • How are photos accessed from Apple TV via itunes

    I seem to be missing something. Having configured Apple TV (newest generation) and iTunes 10.0.5 on my iMac (10.8.4) for home sharing, (almost everything) works fine besides one thing: When it comes to photos, my iPhoto (9.4.3) libraries are accessed

  • Applications not updated

    My Ipod Touch is less than one week old, it worked fine for 2 days. Then no update on any application although the Wifi is ON. Wifi is on. Password has been accepted. Network screen provides IP Address Subnet Mask Router and DNS - Search Domain and C

  • Adobe Reader 11.0.6 for Maverick cannot open the pdfs it has just created.

    Why will Adobe Reader 11.0.6 for Maverick cannot open the pdfs it has just created.

  • Installing Wireless toolkit 1.04 On Linux.

    I try to install Wireless toolit 1.04 On My RedHat Linux 8.0, But it show the infor: Do you agree to the above license terms? [yes or no] y ./j2me_wireless_toolkit-1_0_4_01-bin-linuxi386.bin: line 270: uudecode: command not found Failed to extract Ja