Skip to content

Commit

Permalink
index.js: fix ArrayBuffer for handle_special_geometry
Browse files Browse the repository at this point in the history
index.js: change return signature of merge_geometries

+ adapt handle_special_geometry
+ fix handling of multiple materials per group in handle_special_geometry
+ fix line 35
+ simplify handle_special_geometry
  • Loading branch information
ManifoldFR committed May 22, 2024
1 parent 0b0e82a commit 5bfcf87
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/main.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/main.min.js.THIRD_PARTY_LICENSES.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
"license": "MIT",
"licenseText": "The MIT License\n\nCopyright © 2010-2024 three.js authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
},
{
"name": "three",
"version": "0.160.1",
"author": "mrdoob",
"repository": "https://github.com/mrdoob/three.js",
"source": "https://registry.npmjs.org/three/-/three-0.160.1.tgz",
"license": "MIT",
"licenseText": "The MIT License\n\nCopyright © 2010-2023 three.js authors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
},
{
"name": "wtd-core",
"version": "3.0.0",
Expand Down
13 changes: 12 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,19 @@ function merge_geometries(object, preserve_materials = false) {
}
} else if (geometries.length > 1) {
result = mergeGeometries(geometries, true);
const ngeom = result.groups.length;
let mts = [];
if (preserve_materials) {
result.material = materials;
for (let i = 0; i < ngeom; i++) {
const group = result.groups[i];
let m = materials[i];
if (Array.isArray(m)) {
mts.push(m[m.length - 1]);
} else {
mts.push(m);
}
}
result.material = mts;
}
} else {
result = new THREE.BufferGeometry();
Expand Down

0 comments on commit 5bfcf87

Please sign in to comment.