UNPKG

@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.

50 lines (47 loc) 2.68 kB
import { F as FlowGraphBlock } from './KHR_interactivity-Bmb38TjL.esm.js'; import { R as RichTypeAny, j as RichTypeVector3 } from './declarationMapper-rcGCdcDP.esm.js'; import { aS as TmpVectors, V as Vector3, R as RegisterClass } from './index-FzOfPXLV.esm.js'; import './objectModelMapping-CJnQ6at_.esm.js'; /** * This blocks transforms a vector from one coordinate system to another. */ class FlowGraphTransformCoordinatesSystemBlock extends FlowGraphBlock { /** * Creates a new FlowGraphCoordinateTransformBlock * @param config optional configuration for this block */ constructor(config) { super(config); this.sourceSystem = this.registerDataInput("sourceSystem", RichTypeAny); this.destinationSystem = this.registerDataInput("destinationSystem", RichTypeAny); this.inputCoordinates = this.registerDataInput("inputCoordinates", RichTypeVector3); this.outputCoordinates = this.registerDataOutput("outputCoordinates", RichTypeVector3); } _updateOutputs(_context) { const sourceSystemValue = this.sourceSystem.getValue(_context); const destinationSystemValue = this.destinationSystem.getValue(_context); const inputCoordinatesValue = this.inputCoordinates.getValue(_context); // takes coordinates from source space to world space const sourceWorld = sourceSystemValue.getWorldMatrix(); // takes coordinates from destination space to world space const destinationWorld = destinationSystemValue.getWorldMatrix(); const destinationWorldInverse = TmpVectors.Matrix[0].copyFrom(destinationWorld); // takes coordinates from world space to destination space destinationWorldInverse.invert(); const sourceToDestination = TmpVectors.Matrix[1]; // takes coordinates from source space to world space to destination space destinationWorldInverse.multiplyToRef(sourceWorld, sourceToDestination); const outputCoordinatesValue = this.outputCoordinates.getValue(_context); Vector3.TransformCoordinatesToRef(inputCoordinatesValue, sourceToDestination, outputCoordinatesValue); } /** * Gets the class name of this block * @returns the class name */ getClassName() { return "FlowGraphTransformCoordinatesSystemBlock" /* FlowGraphBlockNames.TransformCoordinatesSystem */; } } RegisterClass("FlowGraphTransformCoordinatesSystemBlock" /* FlowGraphBlockNames.TransformCoordinatesSystem */, FlowGraphTransformCoordinatesSystemBlock); export { FlowGraphTransformCoordinatesSystemBlock }; //# sourceMappingURL=flowGraphTransformCoordinatesSystemBlock-CPJvLgWf.esm.js.map