Skip to content

Commit

Permalink
Start using MetroStation iModel (imodeljs#20)
Browse files Browse the repository at this point in the history
* Use MetroStation sample iModel

* linter
  • Loading branch information
Josh-Schifter committed Jun 12, 2020
1 parent daa0d01 commit 4043e4f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
16 changes: 9 additions & 7 deletions src/Components/IModelSelector/IModelSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import * as React from "react";
import "@bentley/icons-generic-webfont/dist/bentley-icons-generic-webfont.css";
import "../../common/samples-common.scss";

export enum SampleIModels {
RetailBuilding = "Retail Building Sample",
BayTown = "Bay Town Process Plant",
House = "House Sample",
}

// The Props and State for this sample component
interface IModelSelectorProps {
iModelNames: string[];
iModelName: string;
onIModelChange: (iModelName: string) => void;
}

export enum SampleIModels {
MetroStation = "Metrostation Sample",
RetailBuilding = "Retail Building Sample",
BayTown = "Bay Town Process Plant",
House = "House Sample",
}

export class IModelSelector extends React.Component<IModelSelectorProps, {}> {

public static defaultModelList = [SampleIModels.RetailBuilding, SampleIModels.BayTown, SampleIModels.House];
public static defaultIModelList = [SampleIModels.MetroStation, SampleIModels.RetailBuilding, SampleIModels.BayTown, SampleIModels.House];
public static defaultIModel = SampleIModels.MetroStation;

private _handleSelection = async (event: React.ChangeEvent<HTMLSelectElement>) => {
const index = Number.parseInt(event.target.selectedOptions[0].value, undefined);
Expand Down
6 changes: 3 additions & 3 deletions src/Components/SampleShowcase/SampleShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "./SampleShowcase.scss";
import "../../common/samples-common.scss";
import { sampleManifest, SampleSpecGroup } from "../../sampleManifest";
import { getViewportOnlySpec } from "../../frontend-samples/viewport-only-sample/sampleSpec";
import { IModelSelector, SampleIModels } from "../IModelSelector/IModelSelector";
import { IModelSelector } from "../IModelSelector/IModelSelector";
import SampleEditor, { InternalFile } from "../SampleEditor/SampleEditor";
import { ActivityBar, ActivityBarItem, SplitScreen } from "@bentley/monaco-editor";

Expand Down Expand Up @@ -41,7 +41,7 @@ export class SampleShowcase extends React.Component<{}, ShowcaseState> {
super(props, context);

this.state = {
iModelName: SampleIModels.RetailBuilding,
iModelName: IModelSelector.defaultIModel,
activeSampleGroup: this._samples[0].groupName,
showEditor: false,
};
Expand Down Expand Up @@ -69,7 +69,7 @@ export class SampleShowcase extends React.Component<{}, ShowcaseState> {

private getIModelList(sampleSpec: SampleSpec): string[] {
const customModelList = sampleSpec.customModelList;
return customModelList ? customModelList : IModelSelector.defaultModelList;
return customModelList ? customModelList : IModelSelector.defaultIModelList;
}

private async setupNewSample(name: string) {
Expand Down
11 changes: 10 additions & 1 deletion src/api/viewSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { DrawingViewState, IModelConnection, SpatialViewState, ViewState } from "@bentley/imodeljs-frontend";
import { DrawingViewState, IModelConnection, SpatialViewState, ViewState, ViewState3d } from "@bentley/imodeljs-frontend";
import { Id64, Id64String } from "@bentley/bentleyjs-core";

export class ViewSetup {
Expand Down Expand Up @@ -51,6 +51,15 @@ export class ViewSetup {
viewState.setOrigin(origin);
}

viewState.viewFlags.shadows = false;

if (viewState.is3d()) {
const viewState3d = viewState as ViewState3d;
const displayStyle = viewState3d.getDisplayStyle3d();

displayStyle.changeBackgroundMapProps({ useDepthBuffer: true });
}

return viewState;
}
}
14 changes: 4 additions & 10 deletions src/frontend-samples/shadow-study-sample/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import { ViewSetup } from "../../api/viewSetup";
export class ShadowStudyApp {

public static async setup(iModelName: string) {
const vp = IModelApp.viewManager.selectedView;

// Enable shadows for the current view
if (vp && vp.view.is3d()) {
const viewFlags = vp.viewFlags.clone();
viewFlags.shadows = true;
vp.viewFlags = viewFlags;
vp.synchWithView();
}

return <ShadowStudyUI iModelName={iModelName} />;
}

Expand Down Expand Up @@ -150,6 +140,10 @@ export class ShadowStudyUI extends React.Component<{ iModelName: string }, Shado
viewStyle.setSunTime(this.state.date.getTime());
viewState.displayStyle = viewStyle;
}

// We always want shadows
viewState.viewFlags.shadows = true;

return viewState;
}

Expand Down

0 comments on commit 4043e4f

Please sign in to comment.