UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

48 lines 1.91 kB
import { FlowGraphBlock } from "../../../flowGraphBlock.js"; import { RichTypeAny, RichTypeNumber, RichTypeVector3 } from "../../../flowGraphRichTypes.js"; import { RegisterClass } from "../../../../Misc/typeStore.js"; /** * @experimental * A data block that reads the mass properties of a physics body. * Outputs the mass, center of mass (local space), and principal inertia. */ export class FlowGraphGetPhysicsMassPropertiesBlock extends FlowGraphBlock { /** * Constructs a new FlowGraphGetPhysicsMassPropertiesBlock. * @param config - optional configuration for the block */ constructor(config) { super(config); this.body = this.registerDataInput("body", RichTypeAny); this.mass = this.registerDataOutput("mass", RichTypeNumber); this.centerOfMass = this.registerDataOutput("centerOfMass", RichTypeVector3); this.inertia = this.registerDataOutput("inertia", RichTypeVector3); } /** * @internal */ _updateOutputs(context) { const physicsBody = this.body.getValue(context); if (!physicsBody) { return; } const props = physicsBody.getMassProperties(); if (props.mass !== undefined) { this.mass.setValue(props.mass, context); } if (props.centerOfMass) { this.centerOfMass.setValue(props.centerOfMass, context); } if (props.inertia) { this.inertia.setValue(props.inertia, context); } } /** * @returns class name of the block. */ getClassName() { return "FlowGraphGetPhysicsMassPropertiesBlock" /* FlowGraphBlockNames.PhysicsGetMassProperties */; } } RegisterClass("FlowGraphGetPhysicsMassPropertiesBlock" /* FlowGraphBlockNames.PhysicsGetMassProperties */, FlowGraphGetPhysicsMassPropertiesBlock); //# sourceMappingURL=flowGraphGetPhysicsMassPropertiesBlock.js.map