Import a 3D Model and automatically assign and export animations
TypeScript
Simplify the model analysis
Scott Petrovicd345d5007db7
diff --git a/src/create.html b/src/create.htmlindex 85005f1..e291adc 100644--- a/src/create.html+++ b/src/create.html@@ -101,14 +101,6 @@<div id="load-skeleton-tools">- <button- class="link-button"- id="analyze-model-link"- >- Analyze Model data- </button>--<span><span style="max-width: 220px">Rotate Model to face front <br />@@ -131,6 +123,14 @@<span style="max-width: 220px"><span>Position model</span>++ <button+ class="link-button"+ id="analyze-model-link"+ >+ Analyze Import+ </button>+<div style="display: flex; flex-direction: column; gap: 0.5rem"><button class="secondary-button" id="reset-model-position-button">Reset positiondiff --git a/src/dialog.css b/src/dialog.cssindex f625d0c..dab3584 100644--- a/src/dialog.css+++ b/src/dialog.css@@ -53,7 +53,7 @@.modal-dialog-content * {color: var(--text-primary);- font-size: 1.1rem;+ font-size: 1.0rem;margin: 0.5rem;line-height: 125%;}@@ -264,7 +264,7 @@.model-analysis-dialog .model-analysis-table-scroll {display: block;- overflow-x: auto;+ overflow-x: visible;margin: 0;}@@ -282,14 +282,14 @@font-size: 0.95rem;line-height: 130%;text-align: left;- white-space: nowrap;+ white-space: normal;border-bottom: 1px solid var(--border-color);+ vertical-align: top;}.model-analysis-dialog .model-analysis-table thead th {- font-weight: 600;- opacity: 0.7;border-bottom: 1px solid var(--text-primary);+ font-weight: normal;}.model-analysis-dialog .model-analysis-table tbody th {@@ -297,20 +297,82 @@opacity: 0.7;}-.model-analysis-dialog .model-analysis-row-flagged td {- background: color-mix(in srgb, var(--button-primary-bg) 12%, transparent);+.model-analysis-dialog .model-analysis-object-list {+ margin: 0;+ padding: 0;+ list-style: none;+ display: grid;+ gap: 0.5rem;+}++.model-analysis-dialog .model-analysis-object-card {+ margin: 0;+ padding: 0.55rem 0.65rem;+ border: 1px solid var(--border-color);+ border-radius: 0.4rem;+ background: color-mix(in srgb, var(--bg-primary) 80%, transparent);+}++.model-analysis-dialog .model-analysis-object-card-flagged {+ padding: 2rem;+ background: color-mix(in srgb, var(--bg-primary) 30%, transparent);}.model-analysis-dialog .model-analysis-name {- display: block;+ display: inline-flex;margin: 0;+ font-size: 1.5rem;}.model-analysis-dialog .model-analysis-parent {- display: block;+ display: inline-flex;+ opacity: 0.7;+}++.model-analysis-dialog .model-analysis-object-properties-inline {margin: 0;- font-size: 0.85rem;- opacity: 0.6;+ padding: 0;+ display: flex;+ flex-wrap: wrap;+ gap: 0.2rem 0.6rem;+ list-style: none;+}++.model-analysis-dialog .model-analysis-object-property-inline {+ margin: 0;+ line-height: 1.35;+ word-break: break-word;+}++.model-analysis-dialog .model-analysis-object-property-inline::after {+ content: '•';+ margin-left: 0.6rem;+ opacity: 0.45;+}++.model-analysis-dialog .model-analysis-object-property-inline:last-child::after {+ content: '';+ margin: 0;+}++.model-analysis-dialog .model-analysis-object-property-label {+ margin: 0;+ opacity: 0.7;+}++.model-analysis-dialog .model-analysis-object-property-value {+ margin: 0;+ font-size: 0.92rem;+}++@media (max-width: 900px) {+ .model-analysis-dialog .model-analysis-object-properties-inline {+ gap: 0.15rem 0.45rem;+ }++ .model-analysis-dialog .model-analysis-object-property-inline::after {+ margin-left: 0.45rem;+ }}.model-analysis-dialog .model-analysis-chips {diff --git a/src/lib/processes/load-model/ModelAnalysisReport.ts b/src/lib/processes/load-model/ModelAnalysisReport.tsindex 96e6e62..7bdc311 100644--- a/src/lib/processes/load-model/ModelAnalysisReport.ts+++ b/src/lib/processes/load-model/ModelAnalysisReport.ts@@ -213,15 +213,18 @@ export class ModelAnalysisReport {private static describe_single_material (material: Material): string {const parts: string[] = [material.type]+ // texture file nameif (material.name !== '') {parts.push(`"${material.name}"`)}// a missing texture map is a common reason a model imports looking flat/grey+ // we already show info about the material type if it exists, so don't show anything if we have a mapconst has_map: boolean = (material as any).map !== undefined && (material as any).map !== nullparts.push(has_map ? 'textured' : 'no texture')- parts.push(this.describe_material_side(material.side))+ // single side, double sided, etc.+ parts.push(this.describe_material_side(material.side))return parts.join(' / ')}@@ -320,17 +323,17 @@ export class ModelAnalysisReport {? '<p>No model has been imported yet.</p>': this.build_html(analysis)- new ModalDialog('Model Analysis', content, { customClass: 'model-analysis-dialog' }).show()+ new ModalDialog('3D Model Import Analysis', content, { customClass: 'model-analysis-dialog' }).show()}public static build_html (analysis: ModelImportAnalysis): string {return `<div class="model-analysis">- <p class="model-analysis-source">Source: <strong>${this.escape_html(analysis.source_name)}</strong></p>+${this.build_warnings_html(analysis)}- ${this.build_summary_html(analysis)}+${this.build_mesh_table_html(analysis.imported)}- ${this.build_contents_html(analysis.imported)}+</div>`}@@ -423,68 +426,55 @@ export class ModelAnalysisReport {return ''}- const rows: string = snapshot.objects+ const cards: string = snapshot.objects.map((analyzed) => `- <tr${analyzed.warnings.length > 0 ? ' class="model-analysis-row-flagged"' : ''}>- <td>- <span class="model-analysis-name" style="padding-left: ${analyzed.depth * 0.75}rem">${this.escape_html(analyzed.name)}</span>- <span class="model-analysis-parent">${this.escape_html(this.describe_parentage(analyzed))}</span>- </td>- <td>${this.escape_html(analyzed.type)}</td>- <td>${this.escape_html(this.format_vector(analyzed.position))}</td>- <td>${this.escape_html(this.format_vector(analyzed.rotation_degrees))}</td>- <td>${this.escape_html(this.format_vector(analyzed.scale))}</td>- <td>${this.escape_html(this.format_vector(analyzed.world_scale))}</td>- <td>${this.escape_html(this.format_vector(analyzed.world_size, ' x '))}</td>- <td>${analyzed.vertex_count.toLocaleString()}</td>- <td>${analyzed.triangle_count.toLocaleString()}</td>- <td>${this.escape_html(analyzed.material_summary)}</td>- </tr>+ <li class="model-analysis-object-card${analyzed.warnings.length > 0 ? ' model-analysis-object-card-flagged' : ''}">+ <span class="model-analysis-name">${this.escape_html(analyzed.name)}</span>+ <span class="model-analysis-parent">Parent: ${this.escape_html(this.describe_parentage(analyzed))}</span>+ ${this.build_mesh_properties_html(analyzed)}+ </li>`).join('')return `- <h3>Meshes in the file (${snapshot.objects.length})</h3>- <p class="model-analysis-note">Transforms below are as authored in the file, and are baked into the vertices on import so the model keeps this orientation, placement, and scale. Rotation is in degrees. World scale includes any scale inherited from parent objects.</p>- <div class="model-analysis-table-scroll">- <table class="model-analysis-table">- <thead>- <tr>- <th scope="col">Name</th>- <th scope="col">Type</th>- <th scope="col">Position</th>- <th scope="col">Rotation</th>- <th scope="col">Scale</th>- <th scope="col">World scale</th>- <th scope="col">Size</th>- <th scope="col">Verts</th>- <th scope="col">Tris</th>- <th scope="col">Material</th>- </tr>- </thead>- <tbody>${rows}</tbody>- </table>- </div>+ <h3>${snapshot.objects.length} mesh(es) in the file</h3>+ <p class="model-analysis-note">Transforms come directly from loaded file. For them to work in Mesh2Motion, they are "baked" into the vertices on import. Rotation is in degrees. World scale includes any scale inherited from parent objects.</p>+ <ul class="model-analysis-object-list">${cards}</ul>`}- private static build_contents_html (snapshot: SceneSnapshot): string {- const type_names: string[] = Object.keys(snapshot.type_counts).sort()-- if (type_names.length === 0) {- return ''- }-- const chips: string = type_names- .map((type_name) => `<span class="model-analysis-chip">${this.escape_html(type_name)} x ${snapshot.type_counts[type_name]}</span>`)- .join('')+ private static build_mesh_properties_html (analyzed: AnalyzedObject): string {+ const properties: Array<[string, string]> = [+ ['Type', analyzed.type],+ ['Position', this.format_vector(analyzed.position)],+ ['Rotation', this.format_vector(analyzed.rotation_degrees)],+ ['Scale', this.format_vector(analyzed.scale)],+ ['World scale', this.format_vector(analyzed.world_scale)],+ ['Size', this.format_vector(analyzed.world_size, ' x ')],+ ['Vertices', analyzed.vertex_count.toLocaleString()],+ ['Triangles', analyzed.triangle_count.toLocaleString()],+ ['Material', analyzed.material_summary],+ ['UVs', analyzed.has_uvs ? 'yes' : 'no'],+ ['Normals', analyzed.has_normals ? 'yes' : 'no'],+ ['Skin weights', analyzed.has_skin_weights ? 'yes' : 'no']+ ]return `- <h3>Everything in the file</h3>- <div class="model-analysis-chips">${chips}</div>+ <ul class="model-analysis-object-properties-inline">+ ${properties+ .map(([label, value]) => `+ <li class="model-analysis-object-property-inline">+ <span class="model-analysis-object-property-label">${this.escape_html(label)}:</span>+ <span class="model-analysis-object-property-value">${this.escape_html(value)}</span>+ </li>+ `)+ .join('')}+ </ul>`}++/*** One line describing where a mesh sits and whether anything above it is* contributing a transform, which is what makes the world scale column differ