Skip to content
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

Editor: Enhance SetValueCommand to support nested attributeName #28602

Conversation

ycw
Copy link
Contributor

@ycw ycw commented Jun 10, 2024

fix: #28601

This PR enhances SetValueCommand to support nested attributeName, s.t. editor will dispatch objectChanged on object(which is the selected object), not object.shadow(which can never be a selected object) ...

// do this
new SetValueCommand(editor, object, 'shadow.intensity',...) // dispatch objectChanged on `object`

// instead of this
new SetValueCommand(editor, object.shadow, 'intensity',...) // disptach objectChanged on `object.shadow`

... which in turn UI will get refresh:

signals.objectChanged.add( function ( object ) {
if ( object !== editor.selected ) return;
updateUI( object );
} );

Preview: https://raw.githack.com/ycw/three.js/editor-setvaluecommand-attributename-supports-nested-props/editor/index.html
Test file: File>Open project.json
Test:

  1. Select DirectionalLight in SCENE outliner
  2. Change shadow intensity from 1.0 to 0.2 in OBJECT tab
  3. Edit>Undo
  4. You should see shadow intensity field is 1.0
SetValueCommand.supports.nested.properties.mp4

@@ -1,5 +1,39 @@
import { Command } from '../Command.js';

function setValue( object, path, value ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates an unnecessary complexity in SetValueCommand. I've filed a different PR that solves the issue more consistent so light shadows are treated like geometries and materials, see #28608.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 10, 2024

Closing in favor of #28608.

@Mugen87 Mugen87 closed this Jun 10, 2024
@ycw ycw deleted the editor-setvaluecommand-attributename-supports-nested-props branch June 10, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor: Shadow properties in OBJECT tab do not refresh UI when UNDO/REDO
2 participants