Skip to content

GLTFExporter: Add support for KHR_mesh_quantization. #20474

@xx0618

Description

@xx0618

In the past, my model was compressed with draco, and it was displayed on the web page normally, and it was also normal to export the file with GLTFExporter. However, due to the draco compressed model, the decompression speed is relatively slow, and the display is no problem if it is changed to GLTFPACK compression. But when I want to export the page, I am prompted that the bufferAttribute component type is not supported.

var loader = new THREE.GLTFLoader();
loader.setMeshoptDecoder(MeshoptDecoder);
loader.load(model_path, function(gltf) {
theModel = gltf.scene;
theModel.position.y = -1.2;
modelg.add(theModel);
});
var urlsave = ‘http://192.168.101.113:8080/customProduct/saveCustomProduct’;
var qhxhr = new XMLHttpRequest();
qhxhr.open(‘POST’, urlsave, true);
var blobfile = null;
var fdata = new FormData();

var btnsave = document.getElementById(‘savejm’);
btnsave.addEventListener(‘click’, saves);
function saves() {
var exporter3D = new THREE.GLTFExporter();
exporter3D.parse(modelg, function(glbfile) {
if (glbfile instanceof ArrayBuffer) {
saveArrayBuffer(glbfile, ‘customize1.glb’);
} else {
var scenejson = JSON.stringify(glbfile, null, 2);
saveString(scenejson, ‘customize.glb’);
};
}, binary = true, onlyVisible = true );
};
function saveString(text, filename) {

  save(new Blob([text], {
  	type: 'text/plain'
  }), filename);
};
function saveArrayBuffer(buffer, filename) {
save(new Blob([buffer], {
type: ‘application/octet-stream’
}), filename);
};
function save(blob, filename) {
fdata.append(‘file’, blob, ‘customize.glb’);
qhxhr.upload.addEventListener(“progress”, function(result) {
if (result.lengthComputable) {
var percent = (result.loaded / result.total * 100).toFixed(2);
console.log(percent);
}
}, false);
qhxhr.send(fdata);
console.log(“ff”);
};

Hope to support bufferAttribute component type in GLTFExporter.

微信截图_20201008112427

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions