Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 13, 2025

Dragging materials and models from the file tree to the scene composer was failing with a ClassCastException and "no flavors matching" issues because AssetDataNode did not implement the AssetNameHolder interface and the drop target listener couldn't determine asset types from generic flavors.

The error occurred in SceneViewerDropTargetListener.drop() at line 72:

transferableObj = (AssetNameHolder) dtde.getTransferable().getTransferData(flavor);

When dragging from the file tree, the system creates an AssetDataNode, but the drop target listener expects all draggable assets to implement AssetNameHolder. Additionally, the listener only handled specific flavors (SpatialDataFlavor and MaterialDataFlavor) but file tree drag operations use generic flavors.

Changes:

  • Made AssetDataNode implement the AssetNameHolder interface
  • Added getAssetName() method that retrieves the asset name from the underlying AssetData lookup
  • Added setAssetName() method (no-op implementation as asset names are derived from asset keys)
  • Enhanced SceneViewerDropTargetListener to handle generic flavors by determining asset type from file extension
  • Added helper methods to extract file extensions and determine asset types (.j3o for models, .j3m for materials)
  • Added fallback logic to call appropriate methods (addModel or applyMaterial) based on file extension when specific flavors aren't available

The implementation follows the same pattern as AssetPreviewWidget and ensures consistent behavior across all drag and drop sources, whether from the asset browser or file tree.

Fixes #668.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits September 13, 2025 19:20
Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
…t AssetNameHolder

Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
Copilot AI changed the title [WIP] Drag and drop a material onto a geometry in scene composer doesn't work Fix drag and drop ClassCastException by implementing AssetNameHolder in AssetDataNode Sep 13, 2025
Copilot AI requested a review from neph1 September 13, 2025 19:26
Copy link
Contributor

@neph1 neph1 left a comment

Choose a reason for hiding this comment

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

@copilot this fixes the exception, but there is still a problem no flavors matching

        if (flavor instanceof SpatialDataFlavor) {
            rootPanel.addModel(assetKey, new Vector2f(dropXLoc, dropYLoc));
        } else if (flavor instanceof MaterialDataFlavor) {
            rootPanel.applyMaterial(assetKey, new Vector2f(dropXLoc, dropYLoc));
        }

Can you find a way to extract what type of asset it is from the available data?

…xtension

Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 14, 2025

@copilot this fixes the exception, but there is still a problem no flavors matching

...

I've fixed the "no flavors matching" issue by enhancing the SceneViewerDropTargetListener to determine the asset type from the file extension when specific flavors aren't available. The system now extracts the asset name from the AssetNameHolder and determines whether to call addModel() or applyMaterial() based on the file extension (.j3o for models, .j3m for materials). This approach works with any drag source that provides an AssetNameHolder, including the file tree.

Fixed in commit b1f7d79.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.apache.org

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Fix drag and drop ClassCastException by implementing AssetNameHolder in AssetDataNode Fix drag and drop issues from file tree to scene composer by implementing AssetNameHolder and flavor detection Sep 14, 2025
Copilot AI requested a review from neph1 September 14, 2025 05:37
@neph1 neph1 requested a review from Copilot September 14, 2025 18:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes drag and drop functionality from the file tree to the scene composer by resolving ClassCastException and "no flavors matching" issues. The fix enables dragging materials and models from the Projects tab to work consistently with the existing asset browser drag and drop behavior.

  • Implements AssetNameHolder interface in AssetDataNode to support asset name retrieval
  • Enhances SceneViewerDropTargetListener to handle generic flavors and determine asset types from file extensions
  • Removes unused setAssetName() method from AssetNameHolder interface

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
SceneViewerDropTargetListener.java Enhanced drop handling logic to support file tree drag operations and added file extension-based asset type detection
AssetNameHolder.java Simplified interface by removing unused setAssetName method and updated copyright
AssetDataNode.java Implemented AssetNameHolder interface with getAssetName method to enable drag and drop compatibility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…ner.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@neph1 neph1 marked this pull request as ready for review September 14, 2025 18:45
@neph1
Copy link
Contributor

neph1 commented Sep 18, 2025

I think this is done. Unless someone objects, I'll merge this within a couple of days.

@neph1 neph1 merged commit d7894fc into master Sep 20, 2025
3 checks passed
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.

Drag and drop a material onto a geometry in scene composer doesn't work

2 participants