AnalyticalGraphicsInc / gltf-vscode

This is an extension for Visual Studio Code to add support for editing glTF files.
Apache License 2.0
460 stars 63 forks source link

Misleading navigation for KHR_draco_mesh_compression #89

Closed lexaknyazev closed 6 years ago

lexaknyazev commented 6 years ago

This check https://github.com/AnalyticalGraphicsInc/gltf-vscode/blob/e5ce897cff6d77c069e3202248a1fbffe2b4f334/server/src/server.ts#L432-L434 isn't precise enough so it leads to image

These indices are Draco's internal pointers.

emackey commented 6 years ago

Thanks @lexaknyazev.

@najadojo When time permits can you take a look?

najadojo commented 6 years ago

I haven't spent much time looking at the Draco extension yet but I assume I could create the same data view that I can with the core vertex buffers. I'll look into making such a modification.

emackey commented 6 years ago

So @lexaknyazev... Now that this fix is in master (not published yet)... When do we get Draco support in the validator? 😁

nodracovalidation

emackey commented 6 years ago

Version 2.1.7 is now published.

lexaknyazev commented 6 years ago

Go to Definition on indices or attributes within KHR_draco_mesh_compression yields

ERROR: Can no longer find document in editor: path

najadojo commented 6 years ago

This is working for me after updating to the released build... can you provide more explicit repro steps? I've found that VSCode sometimes closes the original document (when it shows the name in italics) and this messes up the processing we do to do the navigation.

lexaknyazev commented 6 years ago
  1. VSCode 1.21.1, plugin 2.1.7.
  2. Open folder (e.g. glTF-Sample-Models\2.0\).
  3. Click on a glTF file once (e.g. Avocado\glTF-Draco\Avocado.gltf).
  4. File opens in a new tab with the name in italics.
  5. JSON navigation works as expected.
  6. Ctrl-hover on indices or any attribute. Tool-tip shows some numbers.
  7. Ctrl-click on indices or any attribute. A new tab with error replaces the tab with the asset.
emackey commented 6 years ago

Yeah, the italics are significant because they indicate the document is being previewed (not sure if that's the correct term) and not permanently open. When you "Go to Definition", if the definition resides in an external document, it opens that new document in italics/preview mode, which displaces any prior document opened in italics/preview mode.

So VSCode ends up opening our preview URI in italics and closing the main JSON glTF if it was in italics.

I don't think we can effectively prevent this behavior, but, we could possibly replace the "can no longer find document" message with a file-load of the old document's path. This would allow the preview data to appear. The old glTF would still get closed, but that's editor behavior for documents in italics when you jump to an external definition.

lexaknyazev commented 6 years ago

Could external navigation event switch opened file from preview mode to regular?

emackey commented 6 years ago

As far as I know, the closing behavior is out of our control, and is intentional (for example when you use "Go to definition" multiple times in a row to jump from one file to the next, none of the intermediate files remain open). I'm curious if @najadojo knows more or has contacts that we should reach out to on this. But my thinking is we're kind of stuck with it.

The good news is, if a user makes any modifications to one of these name-in-italics documents, it immediately becomes a normal permanent document, so is not subject to auto-closing like this.

najadojo commented 6 years ago

I have a fix for this issue; if the document isn't an open editor then read in the file directly.

emackey commented 6 years ago

Version 2.1.8 is published.