How to use the @bentley/imodeljs-common.QParams3d.fromRange function in @bentley/imodeljs-common

To help you get started, we’ve selected a few @bentley/imodeljs-common 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 / render / webgl / System.ts View on Github external
public createSheetTile(tile: RenderTexture, polyfaces: IndexedPolyface[], tileColor: ColorDef): GraphicList {
    const sheetTileGraphics: GraphicList = [];

    for (const polyface of polyfaces) {
      const rawParams = polyface.data.param;
      if (rawParams === undefined)
        return sheetTileGraphics;   // return empty

      const meshArgs = new MeshArgs();
      const pts = polyface.data.point.getPoint3dArray();

      meshArgs.points = new QPoint3dList(QParams3d.fromRange(Range3d.createArray(pts)));  // use these point params
      for (const point of pts)
        meshArgs.points.push(QPoint3d.create(point, meshArgs.points.params));

      const uvs: Point2d[] = rawParams.getPoint2dArray();

      const pointIndices: number[] = [];
      const uvIndices: number[] = [];
      const visitor = IndexedPolyfaceVisitor.create(polyface, 0);
      while (visitor.moveToNextFacet()) {
        for (let i = 0; i < 3; i++) {
          pointIndices.push(visitor.clientPointIndex(i));
          uvIndices.push(visitor.clientParamIndex(i));
        }
      }

      // make uv arrangement and indices match that of points
github imodeljs / imodeljs / core / frontend / src / render / primitives / mesh / MeshPrimitives.ts View on Github external
public reset(): void {
    this.flags.initDefaults();
    this.points = new QPoint3dList(QParams3d.fromRange(Range3d.createNull()));
    this.polylines = [];
    this.colors.reset();
    this.features.reset();
  }
  public init(mesh: Mesh) {
github imodeljs / imodeljs / core / frontend / src / render / primitives / mesh / MeshPrimitives.ts View on Github external
public constructor(points: QPoint3dList = new QPoint3dList(QParams3d.fromRange(Range3d.createNull())),
    polylines: PolylineData[] = [], pointParams?: QParams3d, is2d = false, isPlanar = false) {
    this.points = points;
    this.polylines = polylines;
    if (undefined === pointParams) {
      this.pointParams = QParams3d.fromRange(Range3d.createNull());
    } else {
      this.pointParams = pointParams;
    }
    this.flags = new PolylineFlags(is2d, isPlanar);
  }
github imodeljs / imodeljs / core / frontend / src / tile / IModelTileIO.ts View on Github external
const json = primitive.vertices;
      if (undefined === json)
        return undefined;

      const bytes = this.findBuffer(JsonUtils.asString(json.bufferView));
      if (undefined === bytes)
        return undefined;

      const uniformFeatureID = undefined !== json.featureID ? JsonUtils.asInt(json.featureID) : undefined;

      const rangeMin = JsonUtils.asArray(json.params.decodedMin);
      const rangeMax = JsonUtils.asArray(json.params.decodedMax);
      if (undefined === rangeMin || undefined === rangeMax)
        return undefined;

      const qparams = QParams3d.fromRange(Range3d.create(Point3d.create(rangeMin[0], rangeMin[1], rangeMin[2]), Point3d.create(rangeMax[0], rangeMax[1], rangeMax[2])));

      const uniformColor = undefined !== json.uniformColor ? ColorDef.fromJSON(json.uniformColor) : undefined;
      let uvParams: QParams2d | undefined;
      if (undefined !== primitive.surface && undefined !== primitive.surface.uvParams) {
        const uvMin = JsonUtils.asArray(primitive.surface.uvParams.decodedMin);
        const uvMax = JsonUtils.asArray(primitive.surface.uvParams.decodedMax);
        if (undefined === uvMin || undefined === uvMax)
          return undefined;

        const uvRange = new Range2d(uvMin[0], uvMin[1], uvMax[0], uvMax[1]);
        uvParams = QParams2d.fromRange(uvRange);
      }

      return new VertexTable({
        data: bytes,
        qparams,
github imodeljs / imodeljs / core / frontend / src / tile / BingElevation.ts View on Github external
import { ClientRequestContext } from "@bentley/bentleyjs-core";
import { QParams3d, QPoint3d, TextureMapping, RenderTexture, ColorDef, LinePixels, FillFlags } from "@bentley/imodeljs-common";
import { Mesh, MeshArgs } from "../render/primitives/mesh/MeshPrimitives";
import { DisplayParams } from "../render/primitives/DisplayParams";
import { Triangle } from "../render/primitives/Primitives";
import { VertexKey } from "../render/primitives/VertexKey";
import { MeshParams } from "../render/primitives/VertexTable";
import { request, Response, RequestOptions } from "@bentley/imodeljs-clients";
import { IModelConnection } from "../IModelConnection";
import { RenderSystem, RenderGraphic } from "../render/System";

/** @internal */
export class BingElevationProvider {
  private static _scratchRange = Range3d.createNull();
  private static _scratchVertex = Point3d.createZero();
  private static _scratchQParams = QParams3d.fromRange(BingElevationProvider._scratchRange);
  private static _scratchQPoint = QPoint3d.create(BingElevationProvider._scratchVertex, BingElevationProvider._scratchQParams);
  private static _scratchMeshArgs = new MeshArgs();
  private static _scratchUV = Point2d.createZero();
  private static _scratchPoint = Point3d.createZero();

  private _heightRangeRequestTemplate: string;
  private _seaLevelOffsetRequestTemplate: string;
  private _heightListRequestTemplate: string;
  protected _requestContext = new ClientRequestContext("");

  constructor() {
    const bingKey = "AtaeI3QDNG7Bpv1L53cSfDBgBKXIgLq3q-xmn_Y2UyzvF-68rdVxwAuje49syGZt";
    this._heightRangeRequestTemplate = "https://dev.virtualearth.net/REST/v1/Elevation/Bounds?bounds={boundingBox}&rows=16&cols=16&heights=ellipsoid&key={BingMapsAPIKey}".replace("{BingMapsAPIKey}", bingKey);
    this._seaLevelOffsetRequestTemplate = "https://dev.virtualearth.net/REST/v1/Elevation/SeaLevel?points={points}&key={BingMapsAPIKey}".replace("{BingMapsAPIKey}", bingKey);
    this._heightListRequestTemplate = "https://dev.virtualearth.net/REST/v1/Elevation/List?points={points}&heights={heights}&key={BingMapsAPIKey}".replace("{BingMapsAPIKey}", bingKey);
  }
github imodeljs / imodeljs / core / frontend / src / render / primitives / mesh / MeshPrimitives.ts View on Github external
  public constructor(points: QPoint3dList = new QPoint3dList(QParams3d.fromRange(Range3d.createNull())),
    polylines: PolylineData[] = [], pointParams?: QParams3d, is2d = false, isPlanar = false) {
    this.points = points;
    this.polylines = polylines;
    if (undefined === pointParams) {
      this.pointParams = QParams3d.fromRange(Range3d.createNull());
    } else {
      this.pointParams = pointParams;
    }
    this.flags = new PolylineFlags(is2d, isPlanar);
  }
github imodeljs / imodeljs / core / frontend / src / render / primitives / mesh / MeshPrimitives.ts View on Github external
private constructor(props: Mesh.Props) {
    const { displayParams, features, type, range, is2d, isPlanar } = props;
    this._data = Mesh.PrimitiveType.Mesh === type ? new TriangleList() : new MeshPolylineList();
    this.displayParams = displayParams;
    this.features = features;
    this.type = type;
    this.is2d = is2d;
    this.isPlanar = isPlanar;
    this.hasBakedLighting = (true === props.hasBakedLighting);
    this.isVolumeClassifier = (true === props.isVolumeClassifier);
    this.points = new QPoint3dList(QParams3d.fromRange(range));
  }