planePanel.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { TmpVectors, Vector3 } from "babylonjs/Maths/math.vector";
  2. import { Container3D } from "./container3D";
  3. import { Control3D } from "./control3D";
  4. import { VolumeBasedPanel } from "./volumeBasedPanel";
  5. /**
  6. * Class used to create a container panel deployed on the surface of a plane
  7. */
  8. export class PlanePanel extends VolumeBasedPanel {
  9. protected _mapGridNode(control: Control3D, nodePosition: Vector3) {
  10. let mesh = control.mesh;
  11. if (!mesh) {
  12. return;
  13. }
  14. control.position = nodePosition.clone();
  15. let target = TmpVectors.Vector3[0];
  16. target.copyFrom(nodePosition);
  17. switch (this.orientation) {
  18. case Container3D.FACEORIGIN_ORIENTATION:
  19. case Container3D.FACEFORWARD_ORIENTATION:
  20. target.addInPlace(new Vector3(0, 0, 1));
  21. mesh.lookAt(target);
  22. break;
  23. case Container3D.FACEFORWARDREVERSED_ORIENTATION:
  24. case Container3D.FACEORIGINREVERSED_ORIENTATION:
  25. target.addInPlace(new Vector3(0, 0, -1));
  26. mesh.lookAt(target);
  27. break;
  28. }
  29. }
  30. }