fix 3MF imports that lack model transforms
This commit is contained in:
parent
d20e51a0dc
commit
731b45ec04
2 changed files with 14 additions and 10 deletions
|
|
@ -834,7 +834,7 @@ function platformLoadFiles(files, group) {
|
|||
load.TMF.parseAsync(data).then(models => {
|
||||
api.hide.alert(msg);
|
||||
if (models.length > 1 && !group) {
|
||||
UC.confirm(`group ${models.length} objects?`).then(ok => {
|
||||
api.uc.confirm(`group ${models.length} objects?`).then(ok => {
|
||||
if (ok) {
|
||||
group = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,17 +115,21 @@ function loadModel(doc) {
|
|||
model = node.getAttribute("name") || undefined;
|
||||
query(node, ["components","+component"], (type, node) => {
|
||||
let objectid = node.getAttribute('objectid');
|
||||
let mat = node.getAttribute('transform').split(' ').map(v => parseFloat(v));
|
||||
mat = [
|
||||
...mat.slice(0,3), 0,
|
||||
...mat.slice(3,6), 0,
|
||||
...mat.slice(6,9), 0,
|
||||
...mat.slice(9,12), 1
|
||||
];
|
||||
let ref = byid[objectid];
|
||||
if (!ref) return;
|
||||
let m4 = new Matrix4().fromArray(mat);
|
||||
let pos = new BufferAttribute(ref.faces.toFloat32(), 3).applyMatrix4(m4);
|
||||
let pos = new BufferAttribute(ref.faces.toFloat32(), 3);
|
||||
let transform = node.getAttribute('transform');
|
||||
if (transform) {
|
||||
let mat = transform.split(' ').map(v => parseFloat(v));
|
||||
mat = [
|
||||
...mat.slice(0,3), 0,
|
||||
...mat.slice(3,6), 0,
|
||||
...mat.slice(6,9), 0,
|
||||
...mat.slice(9,12), 1
|
||||
];
|
||||
let m4 = new Matrix4().fromArray(mat);
|
||||
pos = pos.applyMatrix4(m4);
|
||||
}
|
||||
faces.appendAll(pos.array);
|
||||
});
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue