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.

70 lines 2.2 kB
/** This file must only contain pure code and pure imports */ import { NodeGeometryBlock } from "../../nodeGeometryBlock.js"; import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js"; import { Matrix, Vector3 } from "../../../../Maths/math.vector.pure.js"; import { RegisterClass } from "../../../../Misc/typeStore.js"; /** * Block used to get a align matrix */ export class AlignBlock extends NodeGeometryBlock { /** * Create a new AlignBlock * @param name defines the block name */ constructor(name) { super(name); this.registerInput("source", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Up()); this.registerInput("target", NodeGeometryBlockConnectionPointTypes.Vector3, true, Vector3.Left()); this.registerOutput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix); } /** * Gets the current class name * @returns the class name */ getClassName() { return "AlignBlock"; } /** * Gets the source input component */ get source() { return this._inputs[0]; } /** * Gets the target input component */ get target() { return this._inputs[1]; } /** * Gets the matrix output component */ get matrix() { return this._outputs[0]; } _buildBlock(state) { super._buildBlock(state); this.matrix._storedFunction = (state) => { const source = this.source.getConnectedValue(state).clone(); const target = this.target.getConnectedValue(state).clone(); const result = new Matrix(); source.normalize(); target.normalize(); Matrix.RotationAlignToRef(source, target, result, true); return result; }; } } let _Registered = false; /** * Register side effects for alignBlock. * Safe to call multiple times; only the first call has an effect. */ export function RegisterAlignBlock() { if (_Registered) { return; } _Registered = true; RegisterClass("BABYLON.AlignBlock", AlignBlock); } //# sourceMappingURL=alignBlock.pure.js.map