# TitanForge GLB Editor

## Compact viewport-first update

This build removes the oversized marketing hero from the default viewport and opens directly into the editor workspace. The header is reduced to a slim tool bar, profile buttons are condensed, and the Load / Preview / Inspector panels fit in the visible editor area on desktop. It also adds a browser import map so Three.js add-ons resolve correctly on Cloudflare Pages without a bundler.


A Cloudflare-ready static GLB inspection, editing, preference-tuning, and export tool styled after the TitanForge Marketplace trade dress from the uploaded website package.

## What is included

- `index.html` — static app shell
- `styles.css` — TitanForge Marketplace-style UI system
- `script.js` — browser-native GLB loader/editor/exporter using Three.js CDN modules
- `assets/icons/titanforge-mark.svg` — copied from the uploaded marketplace package for visual continuity
- `functions/api/glb-editor/audit.js` — optional Cloudflare Pages Function for D1 audit logging
- `functions/api/glb-editor/prefs.js` — optional Cloudflare Pages Function for shared preference presets
- `migrations/0001_glb_editor_manual_d1.sql` — optional D1 schema to paste manually in Cloudflare Dashboard
- `MANUAL_D1_SETUP.md` — manual D1 setup notes; no Wrangler or CLI required

## Core tool behavior

The editor runs in the browser. GLB files are read locally from the user's machine and are not uploaded by the static tool.

Current in-browser edits:

- Load binary `.glb` files by picker or drag-and-drop
- Inspect file size, object count, mesh count, vertices, triangles, materials, textures, draw calls, animations, bones, bounds, and hierarchy
- Dynamically re-score findings based on the selected target profile:
  - Web Game
  - Mobile Low
  - Desktop / VR
  - Marketplace Source
  - Preserve Source
- Normalize world scale to a target maximum dimension
- Align pivot/origin to base, center, or preserve original
- Rotate model by 90 degrees on X, Y, or Z
- Apply global material preferences for roughness, metalness, alpha test, and material side
- Clean object, geometry, material, and animation names
- Remove hidden meshes from export
- Remove empty importer/helper nodes
- Set cast/receive shadow flags
- Add an optional transparent bounding-box collision proxy
- Strip or preserve animations during export
- Export edited `.glb`
- Export a ZIP package with edited GLB, manifest JSON, audit report JSON, and export README

## Cloudflare Pages install

1. Unzip this package.
2. Upload the `titanforge-glb-editor` folder contents to Cloudflare Pages.
3. No build command is needed.
4. No output directory is needed if uploading through the dashboard as static assets.
5. The app should run from `/index.html` immediately.

## Optional D1

The app does not require D1 to function. D1 is only for optional audit logging and shared preference presets.

For manual D1 setup, read `MANUAL_D1_SETUP.md` and paste `migrations/0001_glb_editor_manual_d1.sql` into the Cloudflare Dashboard SQL console.

Required D1 binding name for the included Pages Functions:

```text
TF_GLB_EDITOR_DB
```

If no D1 binding exists, the static editor still works. The optional audit POST will simply be ignored by the browser.

## CDN dependency notes

This package intentionally avoids a local npm build and does not include Wrangler, Python, or CLI scripts. It uses browser CDN modules for:

- Three.js
- GLTFLoader
- DRACOLoader
- GLTFExporter
- JSZip

This keeps the package lightweight and Cloudflare-dashboard deployable.

## Known limits

This is a practical browser-side GLB editor, not a full DCC replacement. It can tune scene transforms, metadata, materials, names, hierarchy cleanup, and export packaging. Heavy operations like true polygon decimation, texture baking, retopology, UV unwrapping, mesh merging by atlas, and material texture compression should still be handled by Blender, WarForge/TitanForge tooling, or an offline asset pipeline before final upload.

## Compact profile rail hotfix

This package keeps the compact editor layout and moves the Web Game, Mobile Low, Desktop/VR, Marketplace, and Preserve icons inline to the left of each profile label so the rail no longer clips or hides the icons at the top of the viewport.
