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.

42 lines 1.61 kB
import { RichTypeAny, RichTypeVector3 } from "../../../flowGraphRichTypes.js"; import { RegisterClass } from "../../../../Misc/typeStore.js"; import { FlowGraphCachedOperationBlock } from "../flowGraphCachedOperationBlock.js"; import { Vector3 } from "../../../../Maths/math.vector.js"; /** * @experimental * A data block that reads the linear velocity of a physics body. */ export class FlowGraphGetLinearVelocityBlock extends FlowGraphCachedOperationBlock { /** * Constructs a new FlowGraphGetLinearVelocityBlock. * @param config - optional configuration for the block */ constructor(config) { super(RichTypeVector3, config); this.body = this.registerDataInput("body", RichTypeAny); } /** * @internal */ _doOperation(context) { const physicsBody = this.body.getValue(context); if (!physicsBody) { return undefined; } let result = context._getExecutionVariable(this, "_cachedVelocity", null); if (!result) { result = new Vector3(); context._setExecutionVariable(this, "_cachedVelocity", result); } physicsBody.getLinearVelocityToRef(result); return result; } /** * @returns class name of the block. */ getClassName() { return "FlowGraphGetLinearVelocityBlock" /* FlowGraphBlockNames.PhysicsGetLinearVelocity */; } } RegisterClass("FlowGraphGetLinearVelocityBlock" /* FlowGraphBlockNames.PhysicsGetLinearVelocity */, FlowGraphGetLinearVelocityBlock); //# sourceMappingURL=flowGraphGetLinearVelocityBlock.js.map