Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public addMarker(context: DecorateContext) {
super.addMarker(context);
const builder = context.createGraphicBuilder(GraphicType.WorldDecoration);
const ellipse = Arc3d.createScaledXYColumns(this.worldLocation, context.viewport.rotation.transpose(), .2, .2, IncidentMarker._sweep360);
// draw the circle the color of the marker, but with some transparency.
const color = this._color.clone();
builder.setSymbology(ColorDef.white, color, 1);
color.setTransparency(200);
builder.addArc(ellipse, false, false);
builder.setBlankingFill(color);
builder.addArc(ellipse, true, true);
context.addDecorationFromBuilder(builder);
}
}
// High water mark decoding based on decompressIndices_ in webgl-loader's loader.js.
// https://code.google.com/p/webgl-loader/source/browse/trunk/samples/loader.js?r=99#55
// Copyright 2012 Google Inc., Apache 2.0 license.
let highest = 0;
const length = indices.length;
for (let i = 0; i < length; ++i) {
const code = indices[i];
indices[i] = highest - code;
if (code === 0) {
++highest;
}
}
const corners = (tile as any).corners;
const patch = new BilinearPatch(corners[0], corners[1], corners[2], corners[3]);
const materialParams = new RenderMaterial.Params();
const color = ColorDef.white.clone();
materialParams.diffuseColor = materialParams.specularColor = color;
materialParams.diffuse = 0.8;
materialParams.specular = 0.0;
const material = system.createMaterial(materialParams, this._iModel);
const displayParams = new DisplayParams(DisplayParams.Type.Mesh, color, color, 0.0, LinePixels.Solid, FillFlags.None, material);
CesiumWorldTerrainTileLoader._scratchRange.setNull();
CesiumWorldTerrainTileLoader._scratchRange.extendArray(corners);
CesiumWorldTerrainTileLoader._scratchRange.low.z = minHeight - skirtHeight;
CesiumWorldTerrainTileLoader._scratchRange.high.z = maxHeight;
CesiumWorldTerrainTileLoader._scratchQParams.setFromRange(CesiumWorldTerrainTileLoader._scratchRange);
const rangeCenter = CesiumWorldTerrainTileLoader._scratchRange.fractionToPoint(.5, .5, .5);
CesiumWorldTerrainTileLoader._scratchRange.low.minus(rangeCenter, CesiumWorldTerrainTileLoader._scratchLocalRange.low);
CesiumWorldTerrainTileLoader._scratchRange.high.minus(rangeCenter, CesiumWorldTerrainTileLoader._scratchLocalRange.high);
const mesh = Mesh.create({ displayParams, type: Mesh.PrimitiveType.Mesh, range: CesiumWorldTerrainTileLoader._scratchLocalRange, isPlanar: false, is2d: false });
public onDynamicFrame(ev: BeButtonEvent, context: DynamicsContext): void {
if (this.points.length < 1)
return;
const tmpPoints = this.points.slice();
tmpPoints.push(ev.point.clone());
const builder = context.createSceneGraphicBuilder();
builder.setSymbology(ColorDef.white, ColorDef.white, 1);
builder.addLineString(tmpPoints);
context.addGraphic(builder.finish());
this.updateDynamicDistanceMarker(tmpPoints);
}
private addCategoryToExistingDb(categoryName: string) {
const categoryId = SpatialCategory.insert(this.iModelDb, IModel.dictionaryId, categoryName, { color: ColorDef.white });
this.iModelDb.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, ((view: ViewDefinition) => {
const categorySelector = this.iModelDb.elements.getElement(view.categorySelectorId);
categorySelector.categories.push(categoryId);
this.iModelDb.elements.updateElement(categorySelector);
return true;
}));
return categoryId;
}
/** Iterate through and accumulate the GeoJSON FeatureCollection range. */
context.addDecorationFromBuilder(builderDynVis);
const builderDynHid = context.createGraphicBuilder(GraphicType.WorldOverlay);
const colorDynHid = colorDynVis.clone(); colorDynHid.setAlpha(100);
builderDynHid.setSymbology(colorDynHid, ColorDef.black, 1);
builderDynHid.addLineString(tmpPoints);
context.addDecorationFromBuilder(builderDynHid);
this.displayDynamicDistance(context, tmpPoints);
}
if (this._acceptedSegments.length > 0) {
const builderAccVis = context.createGraphicBuilder(GraphicType.WorldDecoration);
const builderAccHid = context.createGraphicBuilder(GraphicType.WorldOverlay);
const colorAccVis = ColorDef.white.adjustForContrast(context.viewport.view.backgroundColor);
const colorAccHid = colorAccVis.clone(); colorAccHid.setAlpha(100);
builderAccVis.setSymbology(colorAccVis, ColorDef.black, 3);
builderAccHid.setSymbology(colorAccHid, ColorDef.black, 1);
for (const seg of this._acceptedSegments) {
builderAccVis.addLineString([seg.start, seg.end]);
builderAccHid.addLineString([seg.start, seg.end]);
seg.marker.addDecoration(context);
if (seg.marker.isSelected)
this.displayDelta(context, seg);
}
context.addDecorationFromBuilder(builderAccVis);
context.addDecorationFromBuilder(builderAccHid);
}
public addMarker(context: DecorateContext) {
super.addMarker(context);
const builder = context.createGraphicBuilder(GraphicType.WorldDecoration);
const ellipse = Arc3d.createScaledXYColumns(this.worldLocation, context.viewport.rotation.transpose(), .2, .2, IncidentMarker._sweep360);
builder.setSymbology(ColorDef.white, this._color, 1);
builder.addArc(ellipse, false, false);
builder.setBlankingFill(this._color);
builder.addArc(ellipse, true, true);
context.addDecorationFromBuilder(builder);
}
}
const rgb = FloatRgb.fromColorDef(params.diffuseColor);
this.rgba[0] = rgb.red;
this.rgba[1] = rgb.green;
this.rgba[2] = rgb.blue;
} else {
this.rgba[0] = this.rgba[1] = this.rgba[2] = -1;
}
const alpha = undefined !== params.alpha ? params.alpha : -1;
this.rgba[3] = alpha;
const scale = (value: number) => Math.floor(value * 255 + 0.5);
this.setInteger(scale(params.diffuse), scale(params.specular), 0);
const textureWeight = undefined !== this.textureMapping ? this.textureMapping.params.weight : 1.0;
const specularRgb = undefined !== params.specularColor ? params.specularColor : ColorDef.white;
const specularColors = specularRgb.colors;
this.setInteger(scale(textureWeight), specularColors.r, 1);
this.setInteger(specularColors.g, specularColors.b, 2);
this.fragUniforms[3] = params.specularExponent;
}