Skip to content

Commit

Permalink
Merge pull request #12 from Smithsonian/dev-rendering
Browse files Browse the repository at this point in the history
Dev rendering
  • Loading branch information
gjcope committed Mar 9, 2020
2 parents b40a9f0 + 1f6181d commit 01feb71
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 7 deletions.
30 changes: 25 additions & 5 deletions source/client/components/CVModel2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ export default class CVModel2 extends CObject3D
localUnits: types.Enum("Model.LocalUnits", EUnitType, EUnitType.cm),
quality: types.Enum("Model.Quality", EDerivativeQuality, EDerivativeQuality.High),
tags: types.String("Model.Tags"),
renderOrder: types.Number("Model.RenderOrder", 0),
activeTags: types.String("Model.ActiveTags"),
autoLoad: types.Boolean("Model.AutoLoad", true),
position: types.Vector3("Model.Position"),
rotation: types.Vector3("Model.Rotation"),
center: types.Event("Model.Center"),
shader: types.Enum("Material.Shader", EShaderMode, EShaderMode.Default),
override: types.Boolean("Material.Override"),
override: types.Boolean("Material.Override", false),
color: types.ColorRGB("Material.BaseColor"),
opacity: types.Percent("Material.Opacity", 1.0),
hiddenOpacity: types.Percent("Material.HiddenOpacity", 0.0),
Expand All @@ -100,6 +101,7 @@ export default class CVModel2 extends CObject3D
this.ins.quality,
this.ins.localUnits,
this.ins.tags,
this.ins.renderOrder,
this.ins.shader,
this.ins.override,
this.ins.color,
Expand Down Expand Up @@ -223,6 +225,10 @@ export default class CVModel2 extends CObject3D
}
}

if(ins.renderOrder.changed) {
this.updateRenderOrder(this.object3D, ins.renderOrder.value);
}

if (ins.localUnits.changed || ins.globalUnits.changed) {
this.updateUnitScale();
}
Expand Down Expand Up @@ -292,7 +298,7 @@ export default class CVModel2 extends CObject3D
fromDocument(document: IDocument, node: INode): number
{
const { ins, outs } = this;

if (!isFinite(node.model)) {
throw new Error("model property missing in node");
}
Expand All @@ -304,6 +310,7 @@ export default class CVModel2 extends CObject3D

ins.visible.setValue(data.visible !== undefined ? data.visible : true);
ins.tags.setValue(data.tags || "");
ins.renderOrder.setValue(data.renderOrder !== undefined ? data.renderOrder : 0);

ins.position.reset();
ins.rotation.reset();
Expand Down Expand Up @@ -333,7 +340,7 @@ export default class CVModel2 extends CObject3D
this.derivatives.fromJSON(data.derivatives);
}
if (data.material) {
const material = data.material;
const material = data.material;
ins.copyValues({
override: true,
color: material.color || ins.color.schema.preset,
Expand Down Expand Up @@ -372,6 +379,9 @@ export default class CVModel2 extends CObject3D
if (ins.tags.value) {
data.tags = ins.tags.value;
}
if (ins.renderOrder.value !== 0) {
data.renderOrder = ins.renderOrder.value;
}

const position = ins.position.value;
if (position[0] !== 0 || position[1] !== 0 || position[2] !== 0) {
Expand Down Expand Up @@ -435,7 +445,7 @@ export default class CVModel2 extends CObject3D
material.color.fromArray(ins.color.value);
material.opacity = this._visible ? ins.opacity.value : ins.hiddenOpacity.value;
material.transparent = material.opacity < 1 || !!material.alphaMap;
material.depthWrite = material.opacity === 1;
//material.depthWrite = material.opacity === 1;
material.roughness = ins.roughness.value;
material.metalness = ins.metalness.value;
}
Expand Down Expand Up @@ -470,6 +480,12 @@ export default class CVModel2 extends CObject3D
this.outs.updated.set();
}

protected updateRenderOrder(model: THREE.Object3D, value: number)
{
model.renderOrder = value;
model.children.forEach(child => this.updateRenderOrder(child, value));
}

/**
* Automatically loads derivatives up to the given quality.
* First loads the lowest available quality (usually thumb), then
Expand Down Expand Up @@ -540,10 +556,14 @@ export default class CVModel2 extends CObject3D
// update loaded quality property
this.outs.quality.setValue(derivative.data.quality);

if (this.ins.override) {
if (this.ins.override.value) {
this.updateMaterial();
}

// make sure render order is correct
if(this.ins.renderOrder.value !== 0)
this.updateRenderOrder(this.object3D, this.ins.renderOrder.value);

// set asset manager flag for initial model load
if(!this.assetManager.initialLoad) {
this.assetManager.initialLoad = 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 @@ -211,6 +211,9 @@
"visible": {
"type": "boolean"
},
"renderOrder": {
"type": "number"
},
"derivatives": {
"type": "array",
"items": {
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 @@ -44,6 +44,7 @@ export interface IModel
derivatives: IDerivative[];

visible?: boolean;
renderOrder?: number;
translation?: Vector3;
rotation?: Vector4;
boundingBox?: IBoundingBox;
Expand Down
2 changes: 2 additions & 0 deletions source/client/shaders/UberPBRMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ export default class UberPBRMaterial extends THREE.MeshStandardMaterial
copyStandardMaterial(material: THREE.MeshStandardMaterial): this
{
this.color = material.color;
this.opacity = material.opacity;
this.transparent = material.opacity < 1 || !!material.alphaMap;

this.roughness = material.roughness;
this.roughnessMap = material.roughnessMap;
Expand Down
24 changes: 22 additions & 2 deletions source/client/ui/explorer/ContentView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,20 @@ export default class ContentView extends DocumentView
}
if (reader) {
readerVisible = ! tourMenuVisible && reader.ins.enabled.value;

readerPosition = reader.ins.position.value;

// do not use right reader position on mobile
if (readerPosition === EReaderPosition.Right && (navigator.platform.indexOf("iPhone")!=-1 || navigator.platform.indexOf("Android")!=-1)) {
readerPosition = EReaderPosition.Overlay;
}

/*if(document.documentElement.clientWidth < 1200) {
readerPosition = EReaderPosition.Overlay;
}
else {
readerPosition = EReaderPosition.Right;
}*/
}

const sceneView = this.sceneView;
Expand All @@ -112,9 +125,16 @@ export default class ContentView extends DocumentView
if (readerVisible) {
if (readerPosition === EReaderPosition.Right) {
return html`<div class="ff-fullsize sv-content-split">
${sceneView}
<div class="ff-splitter-section" style="flex-basis: 60%">
${sceneView}
</div>
<ff-splitter direction="horizontal"></ff-splitter>
<sv-reader-view .system=${system} class="sv-reader-split"></sv-reader-view></div>
<div class="ff-splitter-section" style="flex-basis: 40%; max-width: 500px;">
<div class="sv-reader-container">
<sv-reader-view .system=${system} @close=${this.onReaderClose} ></sv-reader-view>
</div>
</div>
</div>
<sv-spinner ?visible=${isLoading}></sv-spinner>`;
}
if (readerPosition === EReaderPosition.Overlay) {
Expand Down
20 changes: 20 additions & 0 deletions source/client/ui/explorer/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,32 @@ $pad: $canvas-border-width + $main-menu-button-size + 8px;
.sv-content-split {
display: flex;

.sv-reader-container {
@include fullsize;
margin-top: $pad;
}

.sv-scene-view {
flex: 1 1 60%;
}
.sv-reader-view {
pointer-events: auto;
flex: 1 1 40%;
padding: 0 20px;

.sv-left {
flex: 0 0 $pad;
}
.sv-article {
flex: 0 2 720px;
background-color: $color-paragraph-background;
padding-bottom: 35px; // room for tour navigator overlay
padding-right: 16px;
}
.sv-right {
flex: 0 3 16px;
background-color: $color-paragraph-background;
}
}
}

Expand Down

0 comments on commit 01feb71

Please sign in to comment.