-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web viewer formatting improvements and fixes #1635
Merged
jstone-lucasfilm
merged 7 commits into
AcademySoftwareFoundation:main
from
kwokcb:webviewer_formatting
Jan 6, 2024
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6a58931
- Fix parenting of enum
kwokcb 25811a9
Finish coloring items / folders.
kwokcb d1a3e5b
Fix string to set `disabled` as `readonly` does not exist in API.
kwokcb 5e18cc4
Remove changes for uiadvanced.
kwokcb 98a19b8
Refine to still close ui-advanced so default shading mode inputs for …
kwokcb 3563756
Omit closing of advanced folders
jstone-lucasfilm 118e962
Merge branch 'main' into webviewer_formatting
jstone-lucasfilm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,16 +637,18 @@ export class Material | |
// Only create the shader once even if assigned more than once. | ||
var startGenTime = performance.now(); | ||
let shaderMap = new Map(); | ||
let closeUI = false; | ||
for (let matassign of this._materials) | ||
{ | ||
let materialName = matassign.getMaterial().getName(); | ||
let shader = shaderMap[materialName]; | ||
if (!shader) | ||
{ | ||
shader = viewer.getMaterial().generateMaterial(matassign.getMaterial(), viewer, searchPath); | ||
shader = viewer.getMaterial().generateMaterial(matassign.getMaterial(), viewer, searchPath, closeUI); | ||
shaderMap[materialName] = shader; | ||
} | ||
matassign.setShader(shader); | ||
closeUI = true; | ||
} | ||
console.log("- Generate (", this._materials.length, ") shader(s) time: ", performance.now() - startGenTime, " ms.", ); | ||
|
||
|
@@ -694,7 +696,7 @@ export class Material | |
// | ||
// Generate a new material for a given element | ||
// | ||
generateMaterial(elem, viewer, searchPath) | ||
generateMaterial(elem, viewer, searchPath, closeUI) | ||
{ | ||
var startGenerateMat = performance.now(); | ||
|
||
|
@@ -767,7 +769,7 @@ export class Material | |
|
||
// Update property editor | ||
const gui = viewer.getEditor().getGUI(); | ||
this.updateEditor(elem, shader, newMaterial, gui, viewer); | ||
this.updateEditor(elem, shader, newMaterial, gui, viewer, closeUI); | ||
|
||
if (logDetailedTime) | ||
console.log("- Per material generate time: ", performance.now() - startGenerateMat, "ms"); | ||
|
@@ -779,7 +781,7 @@ export class Material | |
// Update property editor for a given MaterialX element, it's shader, and | ||
// Three material | ||
// | ||
updateEditor(elem, shader, material, gui) | ||
updateEditor(elem, shader, material, gui, viewer, closeUI) | ||
{ | ||
const DEFAULT_MIN = 0; | ||
const DEFAULT_MAX = 100; | ||
|
@@ -788,6 +790,10 @@ export class Material | |
|
||
const elemPath = elem.getNamePath(); | ||
var matUI = gui.addFolder(elemPath + ' Properties'); | ||
if (closeUI) | ||
{ | ||
matUI.close(); | ||
} | ||
const uniformBlocks = Object.values(shader.getStage('pixel').getUniformBlocks()); | ||
var uniformToUpdate; | ||
const ignoreList = ['u_envRadianceMips', 'u_envRadianceSamples', 'u_alphaThreshold']; | ||
|
@@ -852,8 +858,18 @@ export class Material | |
if (uifolderName && uifolderName.length) { | ||
let newFolderName = currentNodePath + '/' + uifolderName; | ||
currentFolder = folderList[newFolderName]; | ||
if (!currentFolder) { | ||
currentFolder = matUI.addFolder(uifolderName); | ||
if (!currentFolder) | ||
{ | ||
if (nodeDefInput.hasAttribute('uiadvanced')) | ||
{ | ||
currentFolder = matUI.addFolder(uifolderName + " (Advanced)"); | ||
currentFolder.close(); | ||
} | ||
else | ||
{ | ||
currentFolder = matUI.addFolder(uifolderName); | ||
} | ||
currentFolder.domElement.classList.add('peditorfolder'); | ||
folderList[newFolderName] = currentFolder; | ||
} | ||
} | ||
|
@@ -929,7 +945,8 @@ export class Material | |
{ | ||
step = (maxValue - minValue) / 1000.0; | ||
} | ||
currentFolder.add(material.uniforms[name], 'value', minValue, maxValue, step).name(path); | ||
const w = currentFolder.add(material.uniforms[name], 'value', minValue, maxValue, step).name(path); | ||
w.domElement.classList.add('peditoritem'); | ||
} | ||
break; | ||
|
||
|
@@ -991,7 +1008,8 @@ export class Material | |
} | ||
if (enumList.length == 0) | ||
{ | ||
currentFolder.add(material.uniforms[name], 'value', minValue, maxValue, step).name(path); | ||
let w = currentFolder.add(material.uniforms[name], 'value', minValue, maxValue, step).name(path); | ||
w.domElement.classList.add('peditoritem'); | ||
} | ||
else | ||
{ | ||
|
@@ -1017,8 +1035,9 @@ export class Material | |
} | ||
} | ||
const defaultOption = enumList[value]; // Set the default selected option | ||
const dropdownController = gui.add(enumeration, defaultOption, enumeration).name(path); | ||
const dropdownController = currentFolder.add(enumeration, defaultOption, enumeration).name(path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was adding to the wrong parent. Should add to the current folder. |
||
dropdownController.onChange(handleDropdownChange); | ||
dropdownController.domElement.classList.add('peditoritem'); | ||
} | ||
} | ||
break; | ||
|
@@ -1027,7 +1046,8 @@ export class Material | |
uniformToUpdate = material.uniforms[name]; | ||
if (uniformToUpdate && value != null) | ||
{ | ||
currentFolder.add(material.uniforms[name], 'value').name(path); | ||
let w = currentFolder.add(material.uniforms[name], 'value').name(path); | ||
w.domElement.classList.add('peditoritem'); | ||
} | ||
break; | ||
|
||
|
@@ -1069,6 +1089,7 @@ export class Material | |
Object.keys(material.uniforms[name].value).forEach((key) => { | ||
let w = vecFolder.add(material.uniforms[name].value, | ||
key, minValue[key], maxValue[key], step[key]).name(keyString[key]); | ||
w.domElement.classList.add('peditoritem'); | ||
}) | ||
} | ||
break; | ||
|
@@ -1085,11 +1106,12 @@ export class Material | |
const color3 = new THREE.Color(dummy.color); | ||
color3.fromArray(material.uniforms[name].value); | ||
dummy.color = color3.getHex(); | ||
currentFolder.addColor(dummy, 'color').name(path) | ||
let w = currentFolder.addColor(dummy, 'color').name(path) | ||
.onChange(function (value) { | ||
const color3 = new THREE.Color(value); | ||
material.uniforms[name].value.set(color3.toArray()); | ||
}); | ||
w.domElement.classList.add('peditoritem'); | ||
} | ||
break; | ||
|
||
|
@@ -1106,7 +1128,8 @@ export class Material | |
if (uniformToUpdate && value != null) { | ||
item = currentFolder.add(material.uniforms[name], 'value'); | ||
item.name(path); | ||
item.readonly(true); | ||
item.disable(true); | ||
item.domElement.classList.add('peditoritem'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API readonly does not exist anymore. |
||
} | ||
break; | ||
default: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can easily be changed to modify the preferred colors.