Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._params = new ShadowMapParams(viewFrustum, sunDirection, settings);
else
this._params.update(viewFrustum, sunDirection, settings);
const iModel = view.iModel;
const worldToMapTransform = Transform.createRefs(Point3d.createZero(), Matrix3d.createRigidHeadsUp(this._params.direction.negate()).inverse()!);
const worldToMap = Matrix4d.createTransform(worldToMapTransform);
const mapToWorld = worldToMap.createInverse()!;
const backgroundOn = context.viewFlags.backgroundMap;
const shadowRange = Range3d.createTransformedArray(worldToMapTransform, this._params.viewFrustum.points);
// By fitting to the actual tiles we can reduce the shadowRange and make better use of the texture pixels.
if (!backgroundOn) {
const viewTileRange = Range3d.createNull();
this._scratchFrustumPlanes.init(this._params.viewFrustum);
view.forEachModelTreeRef((ref) => {
const tree = ref.treeOwner.load();
if (undefined !== tree)
tree.accumulateTransformedRange(viewTileRange, worldToMap, this._scratchFrustumPlanes);
});
if (!viewTileRange.isNull)
shadowRange.intersect(viewTileRange, shadowRange);
}
const projectRange = worldToMapTransform.multiplyRange(iModel.projectExtents, this._scratchRange);
shadowRange.low.x = Math.max(shadowRange.low.x, projectRange.low.x);
shadowRange.high.x = Math.min(shadowRange.high.x, projectRange.high.x);
shadowRange.low.y = Math.max(shadowRange.low.y, projectRange.low.y);
shadowRange.high.y = Math.min(shadowRange.high.y, projectRange.high.y);
public addPointString(pts: Point3d[], displayParams: DisplayParams, transform: Transform): boolean {
// Do this.getPrimitiveRange() manually, so there is no need to create a PointString3d object just to find the range
const range = Range3d.createNull();
range.extendArray(pts, undefined);
if (range.isNull)
return false;
this.calculateTransform(transform, range);
return this.addGeometry(Geometry.createFromPointString(pts, transform, range, displayParams));
}
public addLineString(pts: Point3d[], displayParams: DisplayParams, transform: Transform): boolean {
// Do this.getPrimitiveRange() manually, so there is no need to create a PointString3d object just to find the range
const range = Range3d.createNull();
range.extendArray(pts, undefined);
if (range.isNull)
return false;
this.calculateTransform(transform, range);
return this.addGeometry(Geometry.createFromLineString(pts, transform, range, displayParams));
}
function doFixRange(iModel: IModelDb) {
const totalRange = Range3d.createNull() as ElementAlignedBox3d;
iModel.withPreparedStatement("SELECT ECInstanceId,Category.Id,Origin,Yaw,Pitch,Roll,BBoxLow,BBoxHigh FROM bis.GeometricElement3d", (stmt: ECSqlStatement) => {
while (DbResult.BE_SQLITE_ROW === stmt.step()) {
const row = stmt.getRow();
if (undefined !== row.bBoxLow && undefined !== row.bBoxHigh && undefined !== row.origin) {
const box = Range3d.create(row.bBoxLow, row.bBoxHigh) as ElementAlignedBox3d;
const placement = new Placement3d(Point3d.fromJSON(row.origin), YawPitchRollAngles.createDegrees(row.yaw, row.pitch, row.roll), box);
const range = placement.calculateRange();
totalRange.extendRange(range);
}
}
});
if (totalRange.isNull)
return;
iModel.updateProjectExtents(totalRange);
const projectRange = worldToMapTransform.multiplyRange(iModel.projectExtents, this._scratchRange);
shadowRange.low.x = Math.max(shadowRange.low.x, projectRange.low.x);
shadowRange.high.x = Math.min(shadowRange.high.x, projectRange.high.x);
shadowRange.low.y = Math.max(shadowRange.low.y, projectRange.low.y);
shadowRange.high.y = Math.min(shadowRange.high.y, projectRange.high.y);
shadowRange.high.z = projectRange.high.z;
if (shadowRange.isNull) {
this.notifyGraphicsChanged();
return;
}
this._shadowFrustum.initFromRange(shadowRange);
mapToWorld.multiplyPoint3dArrayQuietNormalize(this._shadowFrustum.points);
const tileRange = Range3d.createNull();
this._scratchFrustumPlanes.init(this._shadowFrustum);
view.forEachModelTreeRef(((ref) => {
const tileTree = ref.treeOwner.tileTree;
if (undefined === tileTree)
return;
const drawArgs = SolarShadowMapDrawArgs.create(context, this, tileTree, this._scratchFrustumPlanes);
const tileToMapTransform = worldToMapTransform.multiplyTransformTransform(tileTree.location, this._scratchTransform);
const selectedTiles = tileTree.selectTiles(drawArgs);
for (const selectedTile of selectedTiles) {
tileRange.extendRange(tileToMapTransform.multiplyRange(selectedTile.range, this._scratchRange));
selectedTile.drawGraphics(drawArgs);
}
drawArgs.drawGraphics();
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) {
public appendGeometryRanges() {
this.geometryStream.push({ subRange: Range3d.createNull() });
}
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);
}
public computeRange(): Range3d {
const range: Range3d = Range3d.createNull();
const extendRange = (geom: Geometry) => range.extendRange(geom.tileRange);
this._list.forEach(extendRange);
return range;
}
public computeQuantizationParams(): QParams3d { return QParams3d.fromRange(this.computeRange()); }