Skip to content

Add initial glTF export plugin scaffold#4485

Open
PrateekSingh070 wants to merge 1 commit into
mapeditor:masterfrom
PrateekSingh070:gltf-plugin-scaffold
Open

Add initial glTF export plugin scaffold#4485
PrateekSingh070 wants to merge 1 commit into
mapeditor:masterfrom
PrateekSingh070:gltf-plugin-scaffold

Conversation

@PrateekSingh070
Copy link
Copy Markdown

@PrateekSingh070 PrateekSingh070 commented Mar 31, 2026

Scaffold only — not ready for review as an exporter. This PR adds the plumbing a glTF / .glb map format plugin would need (plugin.json, qbs, the Tiled::WritableMapFormat-derived class, name filter, output-file enumeration) and nothing else.

Scope after cleanup:

  • src/plugins/gltf/ — seven new files
  • src/plugins/plugins.qbs — one line registering the plugin

The plugin is disabled by default (condition: false in gltf.qbs, and "defaultEnable": false in plugin.json), so this has no effect on default builds. The exporter's write() currently returns false with a "glTF export is not implemented yet (GSoC 2026 work in progress)" error, which is the honest state rather than a half-working writer.

I'm keeping this open mainly as evidence attached to the GSoC 2026 proposal for #2741. If the proposal is accepted, I'll reopen the actual exporter work as reviewable chunks (vertex/index buffers, embedded textures, .glb container, validator integration) rather than as one large PR. Happy to close this if maintainers would rather not carry an inert scaffold branch.

Earlier iterations of this branch touched unrelated files (a CI workflow, NEWS.md, a doc reference page, and two unrelated Tiled widgets). All of that has been dropped; the branch has been rebased onto current master and squashed to one commit containing only the scaffold files.

@PrateekSingh070 PrateekSingh070 marked this pull request as ready for review March 31, 2026 18:46
Copilot AI review requested due to automatic review settings March 31, 2026 18:46
@PrateekSingh070
Copy link
Copy Markdown
Author

Small follow-up pushed on this draft PR: I split the write path into a dedicated GltfExporter helper so the plugin entry point stays minimal and future cgltf-based export logic can be added behind that interface.

Copy link
Copy Markdown

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 adds a new glTF export plugin scaffold under src/plugins/gltf/ and wires it into the plugin build so it shows up as an export format, currently returning a clear “not implemented yet” error.

Changes:

  • Registered a new gltf plugin reference in the plugins Qbs project.
  • Added a new src/plugins/gltf/ plugin module (Qbs file, plugin metadata, export macro header).
  • Implemented a minimal WritableMapFormat stub that always fails with a user-facing not-implemented error.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/plugins/plugins.qbs Registers the new gltf plugin in the plugins project.
src/plugins/gltf/plugin.json Sets default enablement for the plugin.
src/plugins/gltf/gltfplugin.h Declares the WritableMapFormat-based plugin class and Qt plugin metadata.
src/plugins/gltf/gltfplugin.cpp Implements a stub exporter returning a not-implemented error.
src/plugins/gltf/gltf.qbs Adds the Qbs build target for the glTF plugin module.
src/plugins/gltf/gltf_global.h Adds export/import macro definitions for the plugin library.

Comment thread src/plugins/plugins.qbs
Comment on lines 10 to +11
"gmx",
"gltf",
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The plugin list in this file appears to be kept in alphabetical order (e.g., defold/defoldcollection/droidcraft, tbin/tengine/tscn). With the new entry, "gltf" should come before "gmx" to preserve that ordering.

Suggested change
"gmx",
"gltf",
"gltf",
"gmx",

Copilot uses AI. Check for mistakes.
Comment thread src/plugins/gltf/plugin.json Outdated
@@ -0,0 +1 @@
{ "defaultEnable": true }
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

defaultEnable is set to true, but the plugin currently always fails exports with a not-implemented error. Consider setting this to false until the exporter is functional, to avoid exposing a non-working export option to users by default.

Suggested change
{ "defaultEnable": true }
{ "defaultEnable": false }

Copilot uses AI. Check for mistakes.
@PrateekSingh070
Copy link
Copy Markdown
Author

Another small follow-up pushed: the plugin now implements outputFiles() and centralizes .gltf/.glb container detection in GltfExporter, so expected output planning is in place before actual writer logic lands.

@PrateekSingh070
Copy link
Copy Markdown
Author

Pushed another incremental step: .gltf export now writes a minimal placeholder output (JSON + empty .bin) through SaveFile, while .glb still returns a clear not-implemented message. This keeps the PR small but makes the write path concrete.

@PrateekSingh070
Copy link
Copy Markdown
Author

Pushed another incremental update: placeholder .gltf output now includes Tiled map metadata in root extras (orientation, map/tile dimensions, infinite flag, plus stagger/hex fields where relevant).

@PrateekSingh070
Copy link
Copy Markdown
Author

Small follow-up pushed: placeholder output now includes a named root node and scene entry (derived from output file base name), so the generated glTF has a minimal but inspectable node hierarchy in viewers.

@PrateekSingh070
Copy link
Copy Markdown
Author

Follow-up pushed: root extras now includes an export block with placeholder metadata (container, placeholder, exportedAtUtc) so generated files are self-describing while the exporter is still in early stages.

@PrateekSingh070
Copy link
Copy Markdown
Author

PrateekSingh070 commented Mar 31, 2026

Another incremental update pushed: placeholder output now includes explicit empty glTF resource tables (bufferViews, accessors, materials, meshes) and marks extras.export.hasGeometry = false, making the file structure ready for the next geometry-wiring steps.

@PrateekSingh070
Copy link
Copy Markdown
Author

PrateekSingh070 commented Mar 31, 2026

Milestone update: placeholder export now emits a concrete fixed quad mesh (positions/uvs/indices) with real .bin data and connected bufferViews/accessors/materials/meshes in the generated .gltf. This is still fixed geometry, before map traversal logic.

@PrateekSingh070
Copy link
Copy Markdown
Author

Incremental follow-up pushed: the placeholder quad is now sized from map->tileWidth() / map->tileHeight() (with fallback handling), so generated geometry reflects map dimensions even before tile-layer traversal is added.

@PrateekSingh070
Copy link
Copy Markdown
Author

Hi @bjorn,

Quick status update on the glTF exporter draft work:

  • I’ve been intentionally building this in small reviewable steps (plugin scaffold -> exporter helper -> placeholder glTF/bin output -> basic mesh wiring).
  • Current output is still placeholder-level by design, but now includes map metadata and a minimal map-aware quad path to validate structure incrementally.
  • I’m avoiding big jumps so each step can be reviewed/refined before moving to full tile-layer traversal.

If you’d like, I can pause at this stage and split the next work into whichever order you prefer (for example: first non-empty tile placement vs. full orthogonal layer traversal).

Thanks.

@PrateekSingh070
Copy link
Copy Markdown
Author

Follow-up pushed: placeholder quad node translation is now derived from map content by locating the first non-empty cell in visible tile layers and translating the mesh node to that tile position (still a single-quad placeholder, before full traversal).

@PrateekSingh070
Copy link
Copy Markdown
Author

Milestone update: exporter now emits one quad per non-empty cell for the first visible non-empty tile layer (orthogonal-only scope for now). This replaces the single-quad placeholder while keeping UV/material behavior intentionally simple for incremental review.

@PrateekSingh070
Copy link
Copy Markdown
Author

PrateekSingh070 commented Mar 31, 2026

Milestone update: UVs are now derived per tile from tileset atlas parameters (tileId, columns, margin, spacing, image size) for the first visible non-empty orthogonal tile layer. This keeps one-layer scope, but moves output from generic UVs toward recognizable tile mapping.

@PrateekSingh070
Copy link
Copy Markdown
Author

Addressed one review concern: src/plugins/gltf/plugin.json now sets defaultEnable to alse so the exporter is not exposed by default while implementation is still in progress.

Adds the plumbing for a glTF / .glb map exporter plugin: plugin.json,
qbs build file, and the Tiled::WritableMapFormat-derived GltfPlugin
class wired up to a GltfExporter that currently returns an honest
"not implemented yet" error.

The plugin is disabled in gltf.qbs (`condition: false`) so default
builds are unaffected. The exporter implementation itself is the
subject of a GSoC 2026 proposal (mapeditor#2741); this PR is the scaffold only,
kept separate so the plumbing and the exporter can be reviewed in
isolation.
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.

2 participants