Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
Update multiple exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHubDragonFly authored Jan 10, 2025
1 parent a549381 commit c8e8154
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
24 changes: 13 additions & 11 deletions viewers/static/js/exporters/3MFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

// For id uniqueness let's hope there is not 1000000000+ objects in the model

let object_id = object.id + 1000000000 + mtl.id;
let object_id = object.id + 1000000000 + mtl.id + index;
let object_name = ( object.name || object.id ) + '_group_' + index;

let hex_uc = '#' + mtl.color.getHexString().toUpperCase();
Expand Down Expand Up @@ -505,10 +505,11 @@

let verticesString = ' <vertices>\n';

let start = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start : 0;
let end = ( index && geometry.groups[ index ] ) ? ( geometry.groups[ index ].start + geometry.groups[ index ].count ) : vertices.length;
let start = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start : 0;
let end = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start + geometry.groups[ index ].count : vertices.length;
if ( end === Infinity ) end = indices.length;

if ( index && geometry.groups[ index ] ) {
if ( index !== null && geometry.groups[ index ] !== undefined ) {

for ( let i = start; i < end; i ++ ) {

Expand Down Expand Up @@ -547,13 +548,14 @@
let trianglesString = ' <triangles>\n';

let start = 0;
let end = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].count : indices.length;
let end = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].count : indices.length;
if ( end === Infinity ) end = index !== null ? indices.length - geometry.groups[ index ].start : indices.length;

for ( let i = start; i < end; i += 3 ) {

let v1 = ( index && geometry.groups[ index ] ) ? i : indices[ i ];
let v2 = ( index && geometry.groups[ index ] ) ? i + 1 : indices[ i + 1 ];
let v3 = ( index && geometry.groups[ index ] ) ? i + 2 : indices[ i + 2 ];
let v1 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i : indices[ i ];
let v2 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i + 1 : indices[ i + 1 ];
let v3 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i + 2 : indices[ i + 2 ];

if ( map_pid ) {

Expand Down Expand Up @@ -584,10 +586,10 @@

let uvsString = ' <m:texture2dgroup id="' + id + '" texid="' + texid + '">\n';

let start = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start : 0;
let end = ( index && geometry.groups[ index ] ) ? ( geometry.groups[ index ].start + geometry.groups[ index ].count ) : uvs.length;
let start = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start : 0;
let end = ( index !== null && geometry.groups[ index ] !== undefined ) ? ( geometry.groups[ index ].start + geometry.groups[ index ].count ) : uvs.length;

if ( index && geometry.groups[ index ] ) {
if ( index !== null && geometry.groups[ index ] !== undefined ) {

for ( let i = start; i < end; i ++ ) {

Expand Down
18 changes: 9 additions & 9 deletions viewers/static/js/exporters/AMFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@

let verticesString = ' <vertices>\n';

let start = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start : 0;
let end = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start + geometry.groups[ index ].count : vertices.length;
let start = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start : 0;
let end = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start + geometry.groups[ index ].count : vertices.length;
if ( end === Infinity ) end = indices.length;

if ( index && geometry.groups[ index ] ) {
if ( index !== null && geometry.groups[ index ] !== undefined ) {

for ( let i = start; i < end; i ++ ) {

Expand Down Expand Up @@ -192,15 +192,15 @@

let trianglesString = ' <volume materialid="' + material.id + '">\n';

let start = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start : 0;
let end = ( index && geometry.groups[ index ] ) ? geometry.groups[ index ].start + geometry.groups[ index ].count : indices.length;
let start = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start : 0;
let end = ( index !== null && geometry.groups[ index ] !== undefined ) ? geometry.groups[ index ].start + geometry.groups[ index ].count : indices.length;
if ( end === Infinity ) end = indices.length;

for ( let i = start; i < end; i += 3 ) {

let v1 = ( index && geometry.groups[ index ] ) ? i : indices[ i ];
let v2 = ( index && geometry.groups[ index ] ) ? i + 1 : indices[ i + 1 ];
let v3 = ( index && geometry.groups[ index ] ) ? i + 2 : indices[ i + 2 ];
let v1 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i : indices[ i ];
let v2 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i + 1 : indices[ i + 1 ];
let v3 = ( index !== null && geometry.groups[ index ] !== undefined ) ? i + 2 : indices[ i + 2 ];

trianglesString += ` <triangle><v1>${ v1 }</v1><v2>${ v2 }</v2><v3>${ v3 }</v3></triangle>\n`;

Expand Down

0 comments on commit c8e8154

Please sign in to comment.