Skip to content

Commit

Permalink
Merge pull request #178 from Smithsonian/dev-bugfix
Browse files Browse the repository at this point in the history
Dev bugfix
  • Loading branch information
gjcope authored Dec 16, 2022
2 parents 135dd40 + c59e4fe commit 833cc1e
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 8 deletions.
4 changes: 3 additions & 1 deletion source/client/annotations/CircleSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import UniversalCamera from "@ff/three/UniversalCamera";
import AnnotationFactory from "./AnnotationFactory";
import CVAssetReader from "client/components/CVAssetReader";

import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';

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

const _vec3a = new Vector3();
Expand Down Expand Up @@ -331,7 +333,7 @@ class CircleAnnotation extends AnnotationElement
const annotationData = annotation.data;

return html`<div class="sv-title">${annotation.title}</div>
<div class="sv-content"><p>${annotation.lead}</p></div>
<div class="sv-content"><p>${unsafeHTML(annotation.lead)}</p></div>
${annotationData.articleId ? html`<ff-button inline text="Read more..." icon="document" @click=${this.onClickArticle}></ff-button>` : null}`;
}

Expand Down
3 changes: 2 additions & 1 deletion source/client/annotations/ExtendedSprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import math from "@ff/core/math";
import FFColor from "@ff/core/Color";

import { customElement, PropertyValues, html, render } from "@ff/ui/CustomElement";
import {unsafeHTML} from 'lit-html/directives/unsafe-html.js';
import "@ff/ui/Button";

import AnnotationSprite, { Annotation, AnnotationElement } from "./AnnotationSprite";
Expand Down Expand Up @@ -161,7 +162,7 @@ class ExtendedAnnotation extends AnnotationElement
this.titleElement.innerText = this.sprite.annotation.title;

// update content
const contentTemplate = html`<p>${this.sprite.annotation.lead}</p>
const contentTemplate = html`<p>${unsafeHTML(this.sprite.annotation.lead)}</p>
${annotation.articleId ? html`<ff-button inline text="Read more..." icon="document" @click=${this.onClickArticle}></ff-button>` : null}`;

render(contentTemplate, this.contentElement);
Expand Down
13 changes: 13 additions & 0 deletions source/client/components/CVModel2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ export default class CVModel2 extends CObject3D
this.ins.visible,
this.ins.quality,
this.ins.overlayMap,
this.ins.override,
this.ins.opacity
];
}

Expand Down Expand Up @@ -394,6 +396,10 @@ export default class CVModel2 extends CObject3D
});
}

if (data.overlayMap) {
ins.overlayMap.setValue(data.overlayMap);
}

if (data.annotations) {
this.getComponent(CVAnnotationView).fromData(data.annotations);
}
Expand Down Expand Up @@ -451,6 +457,10 @@ export default class CVModel2 extends CObject3D
};
}

if (ins.overlayMap.value !== 0) {
data.overlayMap = ins.overlayMap.value;
}

data.boundingBox = {
min: this._localBoundingBox.min.toArray() as LocalVector3,
max: this._localBoundingBox.max.toArray() as LocalVector3
Expand Down Expand Up @@ -679,6 +689,9 @@ export default class CVModel2 extends CObject3D
const overlayOptions = ["None"];
overlayOptions.push(...derivative.findAssets(EAssetType.Image).filter(image => image.data.mapType === EMapType.Zone).map(image => image.data.uri));
this.ins.overlayMap.setOptions(overlayOptions);
if(this.ins.overlayMap.value !== 0) {
this.ins.overlayMap.set();
}

this.emit<IModelLoadEvent>({ type: "model-load", quality: derivative.data.quality });
//this.getGraphComponent(CVSetup).navigation.ins.zoomExtents.set();
Expand Down
21 changes: 19 additions & 2 deletions source/client/components/CVOrbitNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default class CVOrbitNavigation extends CObject3D
projection: types.Enum("Camera.Projection", EProjection, EProjection.Perspective),
lightsFollowCamera: types.Boolean("Navigation.LightsFollowCam", true),
autoRotation: types.Boolean("Navigation.AutoRotation", false),
autoRotationSpeed: types.Number("Navigation.AutoRotationSpeed", 10),
zoomExtents: types.Event("Settings.ZoomExtents"),
autoZoom: types.Boolean("Settings.AutoZoom", true),
orbit: types.Vector3("Current.Orbit", [ -25, -25, 0 ]),
Expand All @@ -91,6 +92,7 @@ export default class CVOrbitNavigation extends CObject3D
private _hasChanged = false;
private _hasZoomed = false;
private _isAutoZooming = false;
private _autoRotationStartTime = null;

constructor(node: Node, id: string)
{
Expand All @@ -105,6 +107,7 @@ export default class CVOrbitNavigation extends CObject3D
this.ins.offset,
this.ins.autoZoom,
this.ins.autoRotation,
this.ins.autoRotationSpeed,
this.ins.lightsFollowCamera,
this.ins.minOrbit,
this.ins.minOffset,
Expand Down Expand Up @@ -226,6 +229,11 @@ export default class CVOrbitNavigation extends CObject3D
this._isAutoZooming = false;
}

// auto rotate
if (ins.autoRotation.changed) {
this._autoRotationStartTime = ins.autoRotation.value ? performance.now() : null;
}

return true;
}

Expand All @@ -242,7 +250,14 @@ export default class CVOrbitNavigation extends CObject3D
controller.camera = cameraComponent.camera;

const transform = cameraComponent.transform;
const forceUpdate = this.changed;
const forceUpdate = this.changed || ins.autoRotation.value;

if (ins.autoRotation.value && this._autoRotationStartTime) {
const now = performance.now();
const delta = now - this._autoRotationStartTime;
controller.orbit.y = (controller.orbit.y + ins.autoRotationSpeed.value * delta * 0.001) % 360.0;
this._autoRotationStartTime = now;
}

if (controller.updateCamera(transform.object3D, forceUpdate)) {
controller.orbit.toArray(ins.orbit.value);
Expand Down Expand Up @@ -401,7 +416,9 @@ export default class CVOrbitNavigation extends CObject3D
}
}
this._controller.setViewportSize(viewport.width, viewport.height);
this._controller.onKeypress(event);
if(this._controller.onKeypress(event)) {
event.originalEvent.preventDefault();
}
event.stopPropagation = true;
}

Expand Down
3 changes: 3 additions & 0 deletions source/client/schema/json/model.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@
"renderOrder": {
"type": "number"
},
"overlayMap": {
"type": "number"
},
"shadowSide": {
"type": "string",
"enum": [
Expand Down
1 change: 1 addition & 0 deletions source/client/schema/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface IModel

visible?: boolean;
renderOrder?: number;
overlayMap?: number;
shadowSide?: TSideType;
translation?: Vector3;
rotation?: Vector4;
Expand Down
12 changes: 10 additions & 2 deletions source/client/ui/explorer/TourNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export default class TourNavigator extends DocumentView
{
super.firstConnected();

this.classList.add("sv-bottom-bar-container", "sv-tour-navigator", "sv-transition");
setTimeout(() => this.classList.remove("sv-transition"), 1);
this.classList.add("sv-bottom-bar-container", "sv-tour-navigator"/*, "sv-transition"*/); // Chrome bug causing issues with transition
//setTimeout(() => this.classList.remove("sv-transition"), 1);
//this.addEventListener("transitionend", this.focusActive, { once: true });

this.needsFocus = true;
}

Expand Down Expand Up @@ -123,6 +125,12 @@ export default class TourNavigator extends DocumentView
this.tours.ins.next.set();
}

/*protected focusActive()
{
const container = this.getElementsByClassName("sv-section-trail").item(2) as HTMLElement;
container.focus();
}*/

protected onActiveDocument(previous: CVDocument, next: CVDocument)
{
if (previous) {
Expand Down
5 changes: 5 additions & 0 deletions source/client/ui/explorer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ $pad: $canvas-border-width + $main-menu-button-size + 8px;
box-sizing: border-box;
position: absolute;
z-index: 1;

a:link, a:visited, a:hover, a:active {
color: $color-primary;
}

@include noselect;
}

Expand Down
11 changes: 10 additions & 1 deletion source/client/ui/story/AnnotationsTaskView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import CVAnnotationsTask, { EAnnotationsTaskMode } from "../../components/CVAnno
import { TaskView } from "../../components/CVTask";
import { ELanguageStringType, ELanguageType, TLanguageType, DEFAULT_LANGUAGE } from "client/schema/common";

import sanitizeHtml from 'sanitize-html';

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

@customElement("sv-annotations-task-view")
Expand Down Expand Up @@ -120,7 +122,14 @@ export default class AnnotationsTaskView extends TaskView<CVAnnotationsTask>
const text = event.detail.text;

if (target.name === "lead") {
annotations.ins.lead.setValue(text);
annotations.ins.lead.setValue(sanitizeHtml(text,
{
allowedTags: [ 'b', 'i', 'em', 'strong', 'a' ],
allowedAttributes: {
'a': [ 'href' ]
}
}
));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion source/client/ui/story/CollectionPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export default class CollectionPanel extends DocumentView
const text = event.detail.text;

if (target.name === "title") {
activeDoc.ins.title.setValue(sanitizeHtml(text));
activeDoc.ins.title.setValue(sanitizeHtml(text,
{
allowedTags: [ 'i' ]
}
));
}
}
}
Expand Down

0 comments on commit 833cc1e

Please sign in to comment.