Skip to content

Commit

Permalink
Merge pull request #226 from Smithsonian/dev-ar
Browse files Browse the repository at this point in the history
Dev ar
  • Loading branch information
gjcope authored Sep 1, 2023
2 parents ba0ae54 + 2a11eca commit fa15046
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 64 deletions.
216 changes: 157 additions & 59 deletions source/client/components/CVARManager.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion source/client/components/CVScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ export default class CVScene extends CVNode
const box = this.outs.boundingBox.value;
box.makeEmpty();

this.models.forEach(model => box.expandByObject(model.object3D));
this.models.forEach(model => {
if(model.object3D.visible){
box.expandByObject(model.object3D)
}
});
box.getSize(_vec3);

this.outs.boundingBox.set();
Expand Down
15 changes: 15 additions & 0 deletions source/client/components/CVViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import CVModel2, { IModelLoadEvent } from "./CVModel2";
import CVAnnotationView, { IAnnotationClickEvent, ITagUpdateEvent } from "./CVAnnotationView";
import CVAnalytics from "./CVAnalytics";
import CVLanguageManager from "./CVLanguageManager";
import CVARManager from "./CVARManager";

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -50,6 +51,8 @@ export default class CVViewer extends Component
exposure: types.Number("Renderer.Exposure", 1),
gamma: types.Number("Renderer.Gamma", 2),
quality: types.Enum("Models.Quality", EDerivativeQuality, EDerivativeQuality.High),
isWallMountAR: types.Boolean("AR.IsWallMount", false),
arScale: types.Number("AR.Scale", 1.0)
};

protected static readonly outs = {
Expand All @@ -69,6 +72,8 @@ export default class CVViewer extends Component
this.ins.toneMapping,
this.ins.exposure,
this.ins.gamma,
this.ins.isWallMountAR,
this.ins.arScale,
];
}

Expand All @@ -88,6 +93,9 @@ export default class CVViewer extends Component
protected get renderer() {
return this.getMainComponent(CRenderer);
}
protected get ar() {
return this.getMainComponent(CVARManager);
}

get rootElement() {
return this._rootElement;
Expand All @@ -102,6 +110,9 @@ export default class CVViewer extends Component
this.graph.components.on(CVModel2, this.onModelComponent, this);
this.graph.components.on(CVAnnotationView, this.onAnnotationsComponent, this);
this.graph.components.on(CVLanguageManager, this.onLanguageComponent, this);

this.ar.ins.wallMount.linkFrom(this.ins.isWallMountAR);
this.ar.ins.arScale.linkFrom(this.ins.arScale);
}

dispose()
Expand Down Expand Up @@ -184,6 +195,8 @@ export default class CVViewer extends Component
exposure: data.exposure !== undefined ? data.exposure : ins.exposure.schema.preset,
toneMapping: data.toneMapping || false,
gamma: data.gamma !== undefined ? data.gamma : ins.gamma.schema.preset,
isWallMountAR: data.isWallMountAR || false,
arScale: data.arScale || 1.0,
annotationsVisible: !!data.annotationsVisible,
activeTags: data.activeTags || "",
sortedTags: data.sortedTags || "",
Expand All @@ -200,6 +213,8 @@ export default class CVViewer extends Component
exposure: ins.exposure.value,
toneMapping: ins.toneMapping.value,
gamma: ins.gamma.value,
isWallMountAR: ins.isWallMountAR.value,
arScale: ins.arScale.value
};

if (ins.annotationsVisible.value) {
Expand Down
2 changes: 2 additions & 0 deletions source/client/schema/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface IViewer
exposure: number;
toneMapping: boolean;
gamma: number;
isWallMountAR: boolean;
arScale: number;
annotationsVisible?: boolean;
activeTags?: string;
sortedTags?: string;
Expand Down
9 changes: 8 additions & 1 deletion source/client/ui/explorer/ARMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import CVDocument from "../../components/CVDocument";
import CVARManager from "../../components/CVARManager";

import DocumentView, { customElement, html } from "./DocumentView";
import CVAnnotationView from "client/components/CVAnnotationView";
import CVScene from "client/components/CVScene";

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -37,6 +39,9 @@ export default class ARMenu extends DocumentView
protected get arManager() {
return this.system.getMainComponent(CVARManager);
}
protected get sceneNode() {
return this.system.getComponent(CVScene);
}

protected firstConnected()
{
Expand Down Expand Up @@ -65,8 +70,10 @@ export default class ARMenu extends DocumentView
const outs = arManager.outs;

const setup = document.setup;
const scene = this.sceneNode;

const annotationsButtonVisible = true;
const views = scene.getGraphComponents(CVAnnotationView);
const annotationsButtonVisible = views.some(view => {return view.hasAnnotations;});
const annotationsActive = setup.viewer.ins.annotationsVisible.value;

const narrationButtonVisible = setup.audio.outs.narrationEnabled.value;
Expand Down
3 changes: 2 additions & 1 deletion source/client/ui/explorer/ARPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ export default class ARPrompt extends DocumentView
{
const arManager = this.arManager;
const outs = arManager.outs;
const location = arManager.ins.wallMount.value === true ? "a wall" : "the floor";

return !outs.isPlaced.value && outs.isPresenting.value ? html`<div class="sv-ar-prompt">
<div class="sv-content">
<div><ff-icon class="ff-off ff-icon sv-ar-icon" name="device-move"}></ff-icon></div>
Move the device to place your Smithsonian object!<br><br>**BETA**
Point your device at ${location} and move it around to place your Smithsonian object!<br><br>**BETA**
</div>
</div>` : null;
}
Expand Down
7 changes: 5 additions & 2 deletions source/client/ui/explorer/MainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ export default class MainMenu extends DocumentView

// TODO - push to ARManager?
const models = scene.getGraphComponents(CVModel2);
const ARderivatives = models[0] ? models[0].derivatives.getByQuality(EDerivativeQuality.AR) : [];
const arButtonVisible = this.arManager.outs.available.value && ARderivatives.length > 0 && models.length >= 1;
let hasARderivatives = false;
models.forEach(model => {
hasARderivatives = model.derivatives.getByQuality(EDerivativeQuality.AR).length > 0 ? true : hasARderivatives;
});
const arButtonVisible = this.arManager.outs.available.value && hasARderivatives && models.length >= 1;


return html`
Expand Down
16 changes: 16 additions & 0 deletions source/client/ui/explorer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ $pad: $canvas-border-width + $main-menu-button-size + 8px;
transform: translate(-50%, -100%);
}

.sv-scale-annotation {
opacity: 0;
transition: opacity 0.3s ease-in;
position: absolute;
color: black;
background-color: white;
font-weight: bold;
border-radius: 20px;
padding-left: 4px;
padding-right: 4px;

&.sv-show {
opacity: 1;
}
}

.sv-standard-annotation, .sv-extended-annotation {
max-width: 20%;
min-width: min-content;
Expand Down

0 comments on commit fa15046

Please sign in to comment.