@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
72 lines (68 loc) • 2.73 kB
JavaScript
import { F as FlowGraphBlock } from './KHR_interactivity-CEwUaqxQ.esm.js';
import { R as RichTypeAny, d as RichTypeNumber, f as RichTypeVector3 } from './declarationMapper-CqO08-WM.esm.js';
import { u as RegisterClass } from './index-MZPybX0H.esm.js';
import './objectModelMapping-De5EKNEZ.esm.js';
import './spotLight.pure-CRdZC6Ci.esm.js';
/** This file must only contain pure code and pure imports */
/**
* @experimental
* A data block that reads the mass properties of a physics body.
* Outputs the mass, center of mass (local space), and principal inertia.
*/
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 */;
}
}
let _Registered = false;
/**
* Register side effects for flowGraphGetPhysicsMassPropertiesBlock.
* Safe to call multiple times; only the first call has an effect.
*/
function RegisterFlowGraphGetPhysicsMassPropertiesBlock() {
if (_Registered) {
return;
}
_Registered = true;
RegisterClass("FlowGraphGetPhysicsMassPropertiesBlock" /* FlowGraphBlockNames.PhysicsGetMassProperties */, FlowGraphGetPhysicsMassPropertiesBlock);
}
/**
* Re-exports pure implementation and applies runtime side effects.
* Import flowGraphGetPhysicsMassPropertiesBlock.pure for tree-shakeable, side-effect-free usage.
*/
RegisterFlowGraphGetPhysicsMassPropertiesBlock();
export { FlowGraphGetPhysicsMassPropertiesBlock, RegisterFlowGraphGetPhysicsMassPropertiesBlock };
//# sourceMappingURL=flowGraphGetPhysicsMassPropertiesBlock-DcIof42B.esm.js.map