RigidBody
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | position : Vector3f | Rigid Body Position |
Example
rb.position = new APJS.Vector3f(1, 2, 3);
Use Case
// Position
@customNode()
export class Use Case_Rigidbody_position extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const pos = rb.position;
this.info = `Position: (${pos.x}, ${pos.y}, ${pos.z})`;
rb.position = new APJS.Vector3f(1, 2, 3);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | rotation : Quaternion | Rigid body rotation angle (quaternion) |
Example
rb.rotation = new APJS.Quaternionf(0, 0, 0, 1); // Identity quaternion
Use Case
// Rotation (Quaternion)
@customNode()
export class Use Case_Rigidbody_rotation extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const rot = rb.rotation;
this.info = `Rotation: (${rot.x}, ${rot.y}, ${rot.z}, ${rot.w})`;
rb.rotation = new APJS.Quaternionf(0, 0, 0, 1); // Identity quaternion
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | eulerAngles : Vector3f | Euler angles of rigid body rotation |
Example
rb.eulerAngles = new APJS.Vector3f(0, 45, 0);
Use Case
// Euler Angles
@customNode()
export class Use Case_Rigidbody_eulerAngles extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const euler = rb.eulerAngles;
this.info = `EulerAngles: (${euler.x}, ${euler.y}, ${euler.z})`;
rb.eulerAngles = new APJS.Vector3f(0, 45, 0);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | velocity : Vector3f | Rigid body linear velocity |
Example
rb.velocity = new APJS.Vector3f(0, 5, 0);
Use Case
// Velocity
@customNode()
export class Use Case_Rigidbody_velocity extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const vel = rb.velocity;
this.info = `Velocity: (${vel.x}, ${vel.y}, ${vel.z})`;
rb.velocity = new APJS.Vector3f(0, 5, 0);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | angularVelocity : Vector3f | Angular Velocity |
Example
rb.angularVelocity = new APJS.Vector3f(0, 0, 10);
Use Case
// Angular Velocity
@customNode()
export class Use Case_Rigidbody_angularVelocity extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const angVel = rb.angularVelocity;
this.info = `AngularVelocity: (${angVel.x}, ${angVel.y}, ${angVel.z})`;
rb.angularVelocity = new APJS.Vector3f(0, 0, 10);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | force : Vector3f | External force value (external forces acting on the rigid body other than gravity) |
Example
rb.force = new APJS.Vector3f(0, 10, 0);
Use Case
@customNode()
export class Use Case_Rigidbody_force extends BasicScriptNode {
@input()
sceneObject: APJS.SceneObject;
@output()
info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const force = rb.force;
this.info = `Current force: (${force.x}, ${force.y}, ${force.z})`;
//set force, 10 means 10 unit upward
rb.force = new APJS.Vector3f(0, 10, 0);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | torque : Vector3f | External torque (the external force acting on a rigid body that causes it to rotate) |
Example
rb.torque = new APJS.Vector3f(0, 5, 0);
Use Case
@customNode()
export class Use Case_Rigidbody_torque extends BasicScriptNode {
@input()
sceneObject: APJS.SceneObject;
@output()
info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const torque = rb.torque;
this.info = `Current torque: (${torque.x}, ${torque.y}, ${torque.z})`;
rb.torque = new APJS.Vector3f(0, 5, 0);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | mass : number | Rigid Body Mass |
Example
rigidbody.mass = 10;
Use Case
@customNode()
export class Use Case_Rigidbody_mass extends BasicScriptNode{
@input()
sceneObject: APJS.SceneObject;
@output()
info: string;
execute() {
const rigidbody = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rigidbody)
return;
//get mass value
const mass = rigidbody.mass;
this.info = `RigidBody previous mass is ${mass}.`;
//set mass value
rigidbody.mass = 10;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | inertiaTensor : Vector3f | Moment of Inertia |
Example
rb.inertiaTensor = new APJS.Vector3f(1, 1, 1);
Use Case
// Inertia Tensor
@customNode()
export class Use Case_Rigidbody_inertiaTensor extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const tensor = rb.inertiaTensor;
this.info = `inertiaTensor: (${tensor.x}, ${tensor.y}, ${tensor.z})`;
rb.inertiaTensor = new APJS.Vector3f(1, 1, 1);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | damping : number | Damping value, linear motion damping |
Example
rb.damping = 0.2;
Use Case
@customNode()
export class Use Case_Rigidbody_damping extends BasicScriptNode {
@input()
sceneObject: APJS.SceneObject;
@output()
info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const damping = rb.damping;
this.info = `RigidBody damping was ${damping}.`;
rb.damping = 0.2;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | angularDamping : number | Damping value, rotational motion damping |
Example
rb.angularDamping = 0.05;
Use Case
@customNode()
export class Use Case_Rigidbody_angularDamping extends BasicScriptNode {
@input()
sceneObject: APJS.SceneObject;
@output()
info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const angularDamping = rb.angularDamping;
this.info = `Angular damping was ${angularDamping}.`;
rb.angularDamping = 0.05;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | static : boolean | Whether it is a static rigid body |
Example
rb.static = false;
Use Case
// Static
@customNode()
export class Use Case_Rigidbody_static extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const prev = rb.static;
this.info = `static was ${prev}`;
rb.static = !prev;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | freezeX : boolean | Whether the movement is locked in the x direction. |
Example
rb.freezeX = false;
Use Case
// Freeze X
@customNode()
export class Use Case_Rigidbody_freezeX extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const prev = rb.freezeX;
this.info = `freezeX was ${prev}`;
rb.freezeX = !prev;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | freezeY : boolean | Whether the movement is locked in the y direction. |
Example
rb.freezeY = false;
Use Case
// Freeze Y
@customNode()
export class Use Case_Rigidbody_freezeY extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const prev = rb.freezeY;
this.info = `freezeY was ${prev}`;
rb.freezeY = !prev;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | freezeZ : boolean | Whether the movement is locked in the z direction. |
Example
rb.freezeZ = false;
Use Case
// Freeze Z
@customNode()
export class Use Case_Rigidbody_freezeZ extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const prev = rb.freezeZ;
this.info = `freezeZ was ${prev}`;
rb.freezeZ = !prev;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | useGravity : boolean | Whether it is affected by gravity |
Example
rb.useGravity = false;
Use Case
// Use Gravity
@customNode()
export class Use Case_Rigidbody_useGravity extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
const prev = rb.useGravity;
this.info = `useGravity was ${prev}`;
rb.useGravity = !prev;
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Variables | addForce(force : Vector3f) : void | Add External Force |
Example
rb.addForce(new APJS.Vector3f(0, 100, 0));
Use Case
// addForce
@customNode()
export class Use Case_Rigidbody_addForce extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
rb.addForce(new APJS.Vector3f(0, 100, 0));
this.info = `Force (0,100,0) applied in world space.`;
// To apply in local space: rb.addForce(new APJS.Vector3f(0,100,0), true);
}
}
Class | Type | Name | Interface Description |
---|---|---|---|
RigidBody Dynamic Component | Functions | addTorque(torque : Vector3f) : void | Add Torque |
Example
rb.addTorque(new APJS.Vector3f(0, 0, 20));
Use Case
// addTorque
@customNode()
export class Use Case_Rigidbody_addTorque extends BasicScriptNode {
@input() sceneObject: APJS.SceneObject;
@output() info: string;
execute() {
const rb = this.sceneObject.getComponent('RigidBody') as APJS.RigidBody;
if (!rb) return;
rb.addTorque(new APJS.Vector3f(0, 0, 20));
this.info = `Torque (0,0,20) applied.`;
}
}