P2. JS's move constraint (Prismaticconstraint) memo

Source: Internet
Author: User

Prismaticconstraint, called piston restraint, is better understood, because the object it constrains can only move in a single direction. First segment Key code:
1 var New P2. Prismaticconstraint (Holderbody, Circlebody, {2     Localanchora: [1, -0.5],3     Localanchorb: [0, 0],4     Localaxisa: [0, 1],5     false 6 }); 7 p1.setlimits (0, 0 ); 8 World.addconstraint (p1);

The blue dots inside the rectangle represent the center of the rectangle, which is added manually. First of all, the concept, Localanchora and Localanchorb coordinates are relative to object A and object B respectively. The object A here is the first parameter holderbody that the method passes in, and the object B is the circlebody. According to the Localanchora and Localanchorb, the piston-bound connection point is the lower right corner of the rectangle and the center point of the Circle, which is what it looks like. Localaxisa This coordinate is defined in object A, and the anchor point of object B can be moved along this axis (original: an axis, defined in body a frame, that body B ' s anchor points may slide along). It can be understood that when this coordinate is [1,0] or [ -1,0], B moves along the horizontal direction, and when this coordinate is [0,1] or [0,-1], B moves in a vertical direction. Disablerotationallock, the use of this property is that when set to True, object B will be able to rotate freely along the anchor point. Setting this to false is convenient for pinning the constraint. The Setlimits (xx,xx) method allows you to set the free action range of the constraint. This is written setlimits (0, 0) is convenient to bind to the fixed. This method can be used to view the constrained action axes set by the Localaxisa. Practice more experiments anyway. The source code for the practice here: https://gist.github.com/yxzblue/3a66babfb93b889f0833#file-prismaticconstraint-html p2.js v0.6.0 's zip package, link : Http://pan.baidu.com/s/1mgsW7xA Password: Bj85p2.js's github Address: https://github.com/schteppe/p2.js Reference:/http Www.cnblogs.com/Just-go/archive/2012/03/19/2405778.html

P2. JS's move constraint (Prismaticconstraint) memo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.