How to use the @bentley/geometry-core.Matrix3d.createIdentity function in @bentley/geometry-core

To help you get started, we’ve selected a few @bentley/geometry-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / ui / framework / src / ui-framework / navigationaids / CubeNavigationAid.tsx View on Github external
startRotMatrix: Matrix3d;
  endRotMatrix: Matrix3d;
  animation: number;
  hoverMap: { [key: string]: CubeHover };
  face: Face;
}

/** Cube Navigation Aid Component
 * @alpha
 */
export class CubeNavigationAid extends React.Component {
  private _start: Vector2d = Vector2d.createZero();
  public readonly state: Readonly = {
    dragging: false,
    startRotMatrix: Matrix3d.createIdentity(),
    endRotMatrix: Matrix3d.createIdentity(),
    animation: 1,
    hoverMap: {},
    face: Face.Top,
  };

  private _lastTime: number | undefined;
  private _animationFrame: any;
  private _mounted: boolean = false;

  /** @internal */
  public componentDidMount() {
    this._mounted = true;
    ViewportComponentEvents.onViewRotationChangeEvent.addListener(this._handleViewRotationChangeEvent);

    // set initial rotation
    const activeContentControl = this.props.contentControlOverride !== undefined ? this.props.contentControlOverride : /* istanbul ignore next */ ContentViewManager.getActiveContentControl();
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / contentviews / CubeContent.tsx View on Github external
}

  /** Get the NavigationAidControl associated with this ContentControl */
  public get navigationAidControl(): string {
    return "CubeNavigationAid";
  }
}

interface CubeContentState {
  rotMatrix: Matrix3d;
}

class CubeContent extends React.Component<{}, CubeContentState> {

  public readonly state: CubeContentState = {
    rotMatrix: Matrix3d.createIdentity(),
  };

  public render(): React.ReactNode {
    return (
      <div>
        
      </div>
    );
  }

  public componentDidMount() {
    ViewportComponentEvents.onCubeRotationChangeEvent.addListener(this._handleCubeRotationChangeEvent);
  }
github imodeljs / imodeljs / ui / components / src / ui-components / viewport / ViewportComponentEvents.ts View on Github external
this._removeListener = IModelApp.viewManager.onSelectedViewportChanged.addListener(ViewportComponentEvents.handleSelectedViewportChanged);
  }

  /** @internal - for unit testing */
  public static terminate() {
    if (this._removeListener) {
      this._removeListener();
      this._removeListener = undefined;
    }
  }

  public static face = Face.None;
  public static readonly origin = Point3d.createZero();
  public static readonly extents = Vector3d.createZero();
  public static readonly rotationMatrix = Matrix3d.createIdentity();
  public static readonly onDrawingViewportChangeEvent = new DrawingViewportChangeEvent();
  public static readonly onCubeRotationChangeEvent = new CubeRotationChangeEvent();
  public static readonly onStandardRotationChangeEvent = new StandardRotationChangeEvent();
  public static readonly onViewRotationChangeEvent = new ViewRotationChangeEvent();
  public static readonly onViewClassFullNameChangedEvent = new ViewClassFullNameChangedEvent();
  public static readonly onViewIdChangedEvent = new ViewIdChangedEvent();

  private static handleSelectedViewportChanged(args: SelectedViewportChangedArgs): void {
    if (args.current)
      ViewportComponentEvents.setViewMatrix(args.current);
  }

  public static setCubeMatrix(rotMatrix: Matrix3d, face = Face.None, complete: boolean = false): void {
    this.rotationMatrix.setFrom(rotMatrix);
    this.face = face;
    this.onCubeRotationChangeEvent.emit({ rotMatrix, complete, face });
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
case RotationMode.View: {
        baseRMatrix = vp ? vp.rotation : Matrix3d.createIdentity();
        break;
      }

      case RotationMode.Context: {
        const axes = new ThreeAxes();
        axes.setFrom(this.baseAxes);
        this.accountForAuxRotationPlane(axes, this.flags.auxRotationPlane);
        baseRMatrix = axes.toMatrix3d();
        break;
      }

      default: {
        baseRMatrix = Matrix3d.createIdentity();
        break;
      }
    }
    return baseRMatrix;
  }
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
case 2: vecP.y = -1.0; break;
        }
        this.accountForACSContextLock(vecP);
        break;

      case RotationMode.Side:
        switch (whichVec) {
          case 0: vecP.y = 1.0; break;
          case 1: vecP.z = 1.0; break;
          case 2: vecP.x = 1.0; break;
        }
        this.accountForACSContextLock(vecP);
        break;

      case RotationMode.ACS:
        rMatrix = vp ? vp.getAuxCoordRotation() : Matrix3d.createIdentity();
        myAxes = ThreeAxes.createFromMatrix3d(rMatrix);
        this.accountForAuxRotationPlane(myAxes, this.flags.auxRotationPlane);
        switch (whichVec) {
          case 0: vecP.setFrom(myAxes.x); break;
          case 1: vecP.setFrom(myAxes.y); break;
          case 2: vecP.setFrom(myAxes.z); break;
        }
        break;

      case RotationMode.View:
        rMatrix = vp ? vp.rotation : Matrix3d.createIdentity();
        rMatrix.getRow(whichVec, vecP);
        break;

      case RotationMode.Context:
        myAxes = this.baseAxes.clone();
github imodeljs / imodeljs / ui / framework / src / ui-framework / navigationaids / DrawingNavigationAid.tsx View on Github external
constructor(props: DrawingNavigationAidProps) {
    super(props);
    const mode = props.initialMapMode || MapMode.Closed;
    const mapExtents = mode === MapMode.Closed ? this._getClosedMapSize() : this._getOpenedMapSize();
    const startMapExtents = mapExtents;

    this.state = {
      startOrigin: Point3d.createZero(),
      origin: Point3d.createZero(),
      extents: Vector3d.create(1, 1, 1),
      startRotation: Matrix3d.createIdentity(),
      rotation: Matrix3d.createIdentity(),

      startMapOrigin: Point3d.createZero(),
      mapOrigin: Point3d.createZero(),
      startMapExtents,
      mapExtents,

      mouseStart: Point2d.createZero(),
      panningDirection: Vector3d.createZero(),
      startDrawingZoom: 1.0,
      drawingZoom: 1.0,

      mode,
      animation: 1.0,

      viewId: props.initialView !== undefined ? props.initialView.id : "",
      view: props.initialView,
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
this.accountForACSContextLock(vecP);
        break;

      case RotationMode.ACS:
        rMatrix = vp ? vp.getAuxCoordRotation() : Matrix3d.createIdentity();
        myAxes = ThreeAxes.createFromMatrix3d(rMatrix);
        this.accountForAuxRotationPlane(myAxes, this.flags.auxRotationPlane);
        switch (whichVec) {
          case 0: vecP.setFrom(myAxes.x); break;
          case 1: vecP.setFrom(myAxes.y); break;
          case 2: vecP.setFrom(myAxes.z); break;
        }
        break;

      case RotationMode.View:
        rMatrix = vp ? vp.rotation : Matrix3d.createIdentity();
        rMatrix.getRow(whichVec, vecP);
        break;

      case RotationMode.Context:
        myAxes = this.baseAxes.clone();
        this.accountForAuxRotationPlane(myAxes, this.flags.auxRotationPlane);
        switch (whichVec) {
          case 0: vecP.setFrom(myAxes.x); break;
          case 1: vecP.setFrom(myAxes.y); break;
          case 2: vecP.setFrom(myAxes.z); break;
        }
        break;
    }
    return vecP;
  }
github imodeljs / imodeljs / core / frontend / src / tools / MeasureTool.ts View on Github external
protected getReferenceAxes(vp?: Viewport): Matrix3d {
    const refAxes = Matrix3d.createIdentity();
    if (undefined !== vp && vp.isContextRotationRequired)
      vp.getAuxCoordRotation(refAxes);
    return refAxes;
  }
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
case RotationMode.Side: {
        baseRMatrix = AccuDraw.getStandardRotation(StandardViewId.Right, vp, useAcs)!;
        break;
      }

      case RotationMode.ACS: {
        baseRMatrix = vp ? vp.getAuxCoordRotation() : Matrix3d.createIdentity();
        const axes = ThreeAxes.createFromMatrix3d(baseRMatrix);
        this.accountForAuxRotationPlane(axes, this.flags.auxRotationPlane);
        axes.toMatrix3d(baseRMatrix);
        break;
      }

      case RotationMode.View: {
        baseRMatrix = vp ? vp.rotation : Matrix3d.createIdentity();
        break;
      }

      case RotationMode.Context: {
        const axes = new ThreeAxes();
        axes.setFrom(this.baseAxes);
        this.accountForAuxRotationPlane(axes, this.flags.auxRotationPlane);
        baseRMatrix = axes.toMatrix3d();
        break;
      }

      default: {
        baseRMatrix = Matrix3d.createIdentity();
        break;
      }
    }
github imodeljs / imodeljs / core / frontend / src / tile / I3dmTileIO.ts View on Github external
private readInstances(): InstancedGraphicParams | undefined {
      const count = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);
      if (count &lt;= 0)
        return undefined;

      const json = this._featureJson;
      const binary = this._featureBinary;

      const batchIds = json.BATCH_ID ? new Int32Array(binary.buffer, binary.byteOffset + json.BATCH_ID.byteOffset, count) : undefined;
      const positions = json.POSITION ? new Float32Array(binary.buffer, binary.byteOffset + json.POSITION.byteOffset, count * 3) : undefined;
      const upNormals = json.NORMAL_UP ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_UP.byteOffset, count * 3) : undefined;
      const rightNormals = json.NORMAL_RIGHT ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_RIGHT.byteOffset, count * 3) : undefined;
      const scales = json.SCALE ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE.byteOffset, count) : undefined;
      const nonUniformScales = json.SCALE_NON_UNIFORM ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE_NON_UNIFORM.byteOffset, count * 3) : undefined;

      const matrix = Matrix3d.createIdentity();
      const position = Point3d.createZero();
      const upNormal = Vector3d.create(0, 0, 1);
      const rightNormal = Vector3d.create(1, 0, 0);
      const scale = Vector3d.create(1, 1, 1);

      const transformCenter = this._range.center;
      const transforms = new Float32Array(12 * count);
      for (let i = 0; i &lt; count; i++) {
        const index = i * 3;
        if (positions)
          position.set(positions[index] - transformCenter.x, positions[index + 1] - transformCenter.y, positions[index + 2] - transformCenter.z);

        if (upNormals || rightNormals) {
          if (upNormals)
            upNormal.set(upNormals[index], upNormals[index + 1], upNormals[index + 2]);