How to use the @bentley/geometry-core.Point3d.createZero 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 / core / frontend / src / AccuDraw.ts View on Github external
context.addDecorationFromBuilder(builder);

    // Create a new graphics with the compass transform and scale so that compass size is 1.0...
    builder = context.createGraphicBuilder(GraphicType.WorldOverlay, this.getDisplayTransform(vp));

    const hasFocus = this.hasInputFocus;
    const bgColor = vp.view.backgroundColor;
    const frameColor = (hasFocus ? this._frameColor : this._frameColorNoFocus).adjustForContrast(bgColor, 155);
    const fillColor = (hasFocus ? this._fillColor : this._fillColorNoFocus).adjustForContrast(bgColor, 75);
    const xColor = (hasFocus ? this._xColor : this._frameColorNoFocus).adjustForContrast(bgColor, 155);
    const yColor = (hasFocus ? this._yColor : this._frameColorNoFocus).adjustForContrast(bgColor, 155);
    const shadowColor = frameColor;

    // Display compass frame...
    builder.setSymbology(shadowColor, fillColor, 1);
    const center = Point3d.createZero();

    if (this.flags.animateRotation || 0.0 === this._percentChanged) {
      if (CompassMode.Polar === this.compassMode) {
        const ellipse = Arc3d.createXYEllipse(center, 1, 1);
        builder.addArc(ellipse, true, true);
        builder.addArc(ellipse, false, false);
      } else {
        const pts: Point3d[] = [
          new Point3d(-1.0, 1.0, 0.0),
          new Point3d(1.0, 1.0, 0.0),
          new Point3d(1.0, -1.0, 0.0),
          new Point3d(-1.0, -1.0, 0.0)];
        pts[4] = pts[0].clone();
        builder.addShape(pts);
        builder.addLineString(pts);
      }
github imodeljs / imodeljs / core / frontend / src / ViewContext.ts View on Github external
const xyzEye = eyeDir.scale(aa);
      eyeDir.setFrom(gridOrigin.vectorTo(xyzEye));
    }
    const normResult = eyeDir.normalize(eyeDir);
    if (!normResult)
      return;
    const zVec = rMatrix.rowZ();
    const eyeDot = eyeDir.dotProduct(zVec);
    if (!vp.isCameraOn && Math.abs(eyeDot) < 0.005)
      return;

    const plane = Plane3dByOriginAndUnitNormal.create(gridOrigin, zVec);
    if (undefined === plane)
      return;

    const loopPt = Point3d.createZero();
    const shapePoints = this.getClippedGridPlanePoints(vp, plane, loopPt);
    if (undefined === shapePoints)
      return;

    const meterPerPixel = vp.getPixelSizeAtPoint(loopPt);
    const refScale = (0 === gridsPerRef) ? 1.0 : gridsPerRef;
    const refSpacing = Vector2d.create(spacing.x, spacing.y).scale(refScale);
    const drawRefLines = !((refSpacing.x / meterPerPixel) < gridConstants.minSeparation || (refSpacing.y / meterPerPixel) < gridConstants.minSeparation);

    const viewZ = vp.rotation.getRow(2);
    const gridOffset = Point3d.create(viewZ.x * meterPerPixel, viewZ.y * meterPerPixel, viewZ.z * meterPerPixel); // Avoid z fighting with coincident geometry
    const builder = this.createGraphicBuilder(GraphicType.WorldDecoration, Transform.createTranslation(gridOffset));
    const color = vp.getContrastToBackgroundColor();
    const planeColor = eyeDot < 0.0 ? ColorDef.red.clone() : color.clone(); planeColor.setTransparency(gridConstants.planeTransparency);

    builder.setBlankingFill(planeColor);
github imodeljs / imodeljs / example-code / app / src / backend / RobotElement.ts View on Github external
public static generateGeometry(radius: number = 0.1): GeometryStreamProps {
    const builder = new GeometryStreamBuilder();  // I know what graphics represent a robot.
    const circle = Arc3d.createXY(Point3d.createZero(), radius);
    builder.appendGeometry(circle);
    return builder.geometryStream;
  }
github imodeljs / imodeljs / core / frontend / src / IModelConnection.ts View on Github external
this._noGcsDefined = true;

    if (this._noGcsDefined)
      throw new IModelError(IModelStatus.NoGeoLocation, "iModel is not GeoLocated");

    const geoConverter = this.geoServices.getConverter()!;
    const geoCoord = Point3d.create(Angle.radiansToDegrees(cartographic.longitude), Angle.radiansToDegrees(cartographic.latitude), cartographic.height); // x is longitude in degrees, y is latitude in degrees, z is height in meters...
    const coordResponse = await geoConverter.getIModelCoordinatesFromGeoCoordinates([geoCoord]);

    if (this._noGcsDefined = (1 !== coordResponse.iModelCoords.length || GeoCoordStatus.NoGCSDefined === coordResponse.iModelCoords[0].s))
      throw new IModelError(IModelStatus.NoGeoLocation, "iModel is not GeoLocated");

    if (GeoCoordStatus.Success !== coordResponse.iModelCoords[0].s)
      throw new IModelError(IModelStatus.BadRequest, "Error converting cartographic to spatial");

    result = result ? result : Point3d.createZero();
    result.setFromJSON(coordResponse.iModelCoords[0].p);
    return result;
  }
github imodeljs / imodeljs / test-apps / agent-test-app / src / changeSetUtility / ChangesetGenerator.ts View on Github external
private static _createBox(size: Point3d): GeometryStreamProps {
        const geometryStreamBuilder = new GeometryStreamBuilder();
        geometryStreamBuilder.appendGeometry(Box.createDgnBox(
            Point3d.createZero(), Vector3d.unitX(), Vector3d.unitY(), new Point3d(0, 0, size.z),
            size.x, size.y, size.x, size.y, true,
        )!);
        return geometryStreamBuilder.geometryStream;
    }
}
github imodeljs / imodeljs / core / common / src / geometry / AreaPattern.ts View on Github external
public applyTransform(transform: Transform): boolean {
      if (transform.isIdentity)
        return true;
      const origin = this.origin ? this.origin : Point3d.createZero();
      const rMatrix = this.rotation ? this.rotation.toMatrix3d() : Matrix3d.createIdentity();
      if (this.symbolId !== undefined) {
        this.space1 = Params.transformPatternSpace(transform, this.space1 ? this.space1 : 0.0, rMatrix, this.angle1);
        this.space2 = Params.transformPatternSpace(transform, this.space2 ? this.space2 : 0.0, rMatrix, this.angle2);
        const scale = Params.getTransformPatternScale(transform);
        this.scale = this.scale ? this.scale * scale : scale;
      } else if (this.defLines) {
        const scale = Params.getTransformPatternScale(transform);
        if (!Geometry.isSameCoordinate(scale, 1.0)) {
          this.scale = this.scale ? this.scale * scale : scale;
          for (const line of this.defLines) {
            if (line.through) {
              line.through.x *= scale;
              line.through.y *= scale;
            }
            if (line.offset) {
github imodeljs / imodeljs / core / frontend / src / ViewContext.ts View on Github external
const xDir = Vector3d.createStartEnd(dirPoints[0], dirPoints[1]); xDir.normalizeInPlace();
      const yDir = Vector3d.createStartEnd(dirPoints[0], dirPoints[2]); yDir.normalizeInPlace();
      const dotX = xDir.dotProduct(viewZ);
      const dotY = yDir.dotProduct(viewZ);
      const unambiguousX = Math.abs(dotX) > 0.25;
      const unambiguousY = Math.abs(dotY) > 0.25;
      const reverseX = dotX > 0.0;
      const reverseY = dotY > 0.0;
      const refStepX = reverseY ? -refSpacing.x : refSpacing.x;
      const refStepY = reverseX ? -refSpacing.y : refSpacing.y;
      const fadeRefSteps = 8;
      const fadeRefTransparencyStep = (255 - gridConstants.refTransparency) / (fadeRefSteps + 2);

      let lastDist = 0.0;
      const lastPt = Point3d.createZero();
      const planeX = Plane3dByOriginAndUnitNormal.create(lastPt, Vector3d.unitX())!;
      const planeY = Plane3dByOriginAndUnitNormal.create(lastPt, Vector3d.unitY())!;
      const thisPt = Point3d.create();
      const thisPt0 = Point3d.create();
      const thisPt1 = Point3d.create();
      const thisRay = Ray3d.createZero();

      const refColor = color.clone(); refColor.setTransparency(gridConstants.refTransparency);
      const linePat = eyeDot < 0.0 ? LinePixels.Code2 : LinePixels.Solid;

      const drawRefX = (nRefRepetitionsX < gridConstants.maxRefLines || (vp.isCameraOn && unambiguousX));
      const drawRefY = (nRefRepetitionsY < gridConstants.maxRefLines || (vp.isCameraOn && unambiguousY));
      const drawGridLines = drawRefX && drawRefY && (gridsPerRef > 1 && !((spacing.x / meterPerPixel) < gridConstants.minSeparation || (spacing.y / meterPerPixel) < gridConstants.minSeparation));

      if (drawRefX) {
        builder.setSymbology(refColor, planeColor, 1, linePat);
github imodeljs / imodeljs / core / frontend / src / tile / I3dmTileIO.ts View on Github external
const count = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);
      if (count <= 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 < 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]);

          if (rightNormals)
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,

      isMoving: false,
      isPanning: false,