Skip to content

Commit aa76460

Browse files
committed
Add feature toggle for environment settings.
1 parent 0ec5e8d commit aa76460

8 files changed

+42
-26
lines changed

.vscode/tasks.json

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
"script": "build_engine_dev",
1616
"group": "build",
1717
"label": "npm: build_engine_dev"
18+
},
19+
{
20+
"type": "npm",
21+
"script": "lint",
22+
"group": "build",
23+
"label": "npm: lint"
1824
}
1925
]
2026
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"scripts": {
2222
"start": "http-server",
2323
"test": "mocha test",
24-
"lint": "eslint source",
24+
"lint": "eslint source --fix",
2525
"docs": "jsdoc -c tools/jsdoc.json",
2626
"generate_icon_font": "node tools/run_python.js tools/generate_icon_font.py",
2727
"update_engine_exports": "node tools/run_python.js tools/update_engine_exports.py",

sandbox/embed_selfhost_externallibs.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
<div class="online_3d_viewer"
3434
style="width: 360px; height: 240px;"
3535
model="../../test/testfiles/gltf/Box/glTF-Binary/Box.glb"
36-
environmentsettings="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
36+
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
3737
</div>
3838
<div class="online_3d_viewer"
3939
style="width: 360px; height: 240px;"
4040
model="../../test/testfiles/gltf/Box/glTF-Draco/Box.gltf,../../test/testfiles/gltf/Box/glTF-Draco/Box.bin"
41-
environmentsettings="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
41+
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
4242
</div>
4343
<div class="online_3d_viewer"
4444
style="width: 360px; height: 240px;"
@@ -47,7 +47,7 @@
4747
<div class="online_3d_viewer"
4848
style="width: 360px; height: 240px;"
4949
model="../../test/testfiles/gltf/DamagedHelmet/glTF-Binary/DamagedHelmet.glb"
50-
environmentsettings="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
50+
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
5151
</div>
5252
<div class="online_3d_viewer"
5353
style="width: 360px; height: 240px;"

sandbox/embed_selfhost_multiple_2.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
<div class="online_3d_viewer"
3131
style="width: 360px; height: 240px;"
3232
model="../../test/testfiles/gltf/BoxVertexColors/glTF-Binary/BoxVertexColors.glb"
33-
defaultcolor="200,0,0"
3433
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
3534
</div>
3635
<div class="online_3d_viewer"
3736
style="width: 360px; height: 240px;"
3837
model="../../test/testfiles/gltf/BoxVertexColors/glTF-Binary/BoxVertexColors.glb"
39-
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg">
38+
environmentmap="../website/assets/envmaps/fishermans_bastion/posx.jpg,../website/assets/envmaps/fishermans_bastion/negx.jpg,../website/assets/envmaps/fishermans_bastion/posy.jpg,../website/assets/envmaps/fishermans_bastion/negy.jpg,../website/assets/envmaps/fishermans_bastion/posz.jpg,../website/assets/envmaps/fishermans_bastion/negz.jpg"
39+
environmentmapbg="true">
4040
</div>
4141
</body>
4242

source/engine/viewer/embeddedviewer.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,18 @@ export function Init3DViewerElements (onReady)
162162
}
163163

164164
let environmentSettings = null;
165-
let environmentSettingsParams = element.getAttribute ('environmentsettings');
166-
if (environmentSettingsParams) {
167-
let environmentSettingsParts = environmentSettingsParams.split (',');
168-
if (environmentSettingsParts.length === 6) {
169-
// TODO: background is env map
165+
let environmentMapParams = element.getAttribute ('environmentmap');
166+
if (environmentMapParams) {
167+
let environmentMapParts = environmentMapParams.split (',');
168+
if (environmentMapParts.length === 6) {
169+
let backgroundIsEnvMap = false;
170+
let backgroundIsEnvMapParam = element.getAttribute ('environmentmapbg');
171+
if (backgroundIsEnvMapParam && backgroundIsEnvMapParam === 'true') {
172+
backgroundIsEnvMap = true;
173+
}
170174
environmentSettings = {
171-
environmentMap : environmentSettingsParts,
172-
backgroundIsEnvMap : false
175+
environmentMap : environmentMapParts,
176+
backgroundIsEnvMap : backgroundIsEnvMap
173177
};
174178
}
175179
}

source/website/featureset.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const FeatureSet =
22
{
33
ShowGrid : false,
4-
MeasureTool : false
4+
MeasureTool : false,
5+
EnvironmentMap : false
56
};

source/website/sharingdialog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function ShowSharingDialog (fileList, settings, camera)
9595
HandleEvent ('model_shared', 'embedding_code');
9696
return GetEmbeddingCode (modelFiles, useCurrentSettings, settings, camera);
9797
});
98-
AddCheckboxLine (optionsSection, 'Use current settings instead of defaults', 'embed_current_settings', (checked) => {
98+
AddCheckboxLine (optionsSection, 'Use customized settings', 'embed_current_settings', (checked) => {
9999
useCurrentSettings = checked;
100100
embeddingCodeInput.value = GetEmbeddingCode (modelFiles, useCurrentSettings, settings, camera);
101101
});

source/website/sidebarsettingspanel.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Color, ColorToHexString } from '../engine/model/color.js';
22
import { AddDiv, AddDomElement, AddRangeSlider, AddToggle, AddCheckbox, ShowDomElement, SetDomElementOuterHeight } from '../engine/viewer/domutils.js';
33
import { CalculatePopupPositionToElementTopLeft } from './dialogs.js';
4+
import { FeatureSet } from './featureset.js';
45
import { PopupDialog } from './modal.js';
56
import { Settings, Theme } from './settings.js';
67
import { SidebarPanel } from './sidebarpanel.js';
@@ -154,17 +155,19 @@ class SettingsModelDisplaySection extends SettingsSection
154155

155156
Init (settings, callbacks)
156157
{
157-
this.environmentMapButton = AddDiv (this.contentDiv, 'ov_panel_button');
158-
AddSvgIconElement (this.environmentMapButton, 'arrow_left', 'ov_panel_button_left_icon');
159-
AddDiv (this.environmentMapButton, 'ov_panel_button_text', 'Environment Map');
160-
this.environmentMapButton.addEventListener ('click', () => {
161-
this.environmentMapPopup = new EnvironmentMapPopup ();
162-
this.environmentMapPopup.ShowPopup (this.environmentMapButton, settings, {
163-
onEnvironmentMapChange : () => {
164-
callbacks.onEnvironmentMapChange ();
165-
}
158+
if (FeatureSet.EnvironmentMap) {
159+
this.environmentMapButton = AddDiv (this.contentDiv, 'ov_panel_button');
160+
AddSvgIconElement (this.environmentMapButton, 'arrow_left', 'ov_panel_button_left_icon');
161+
AddDiv (this.environmentMapButton, 'ov_panel_button_text', 'Environment Map');
162+
this.environmentMapButton.addEventListener ('click', () => {
163+
this.environmentMapPopup = new EnvironmentMapPopup ();
164+
this.environmentMapPopup.ShowPopup (this.environmentMapButton, settings, {
165+
onEnvironmentMapChange : () => {
166+
callbacks.onEnvironmentMapChange ();
167+
}
168+
});
166169
});
167-
});
170+
}
168171

169172
let backgroundColorDiv = AddDiv (this.contentDiv, 'ov_sidebar_parameter');
170173
let backgroundColorInput = AddDiv (backgroundColorDiv, 'ov_color_picker');
@@ -216,7 +219,9 @@ class SettingsModelDisplaySection extends SettingsSection
216219

217220
UpdateVisibility (isPhysicallyBased)
218221
{
219-
ShowDomElement (this.environmentMapButton, isPhysicallyBased);
222+
if (this.environmentMapButton !== null) {
223+
ShowDomElement (this.environmentMapButton, isPhysicallyBased);
224+
}
220225
}
221226

222227
Update (settings)

0 commit comments

Comments
 (0)