Skip to content

Removing KHR_mesh_quantization #233

Answered by donmccurdy
donmccurdy asked this question in Q&A
Discussion options

You must be logged in to vote

Should be something like...

// remove_quantization.js
const { NodeIO } = require('@gltf-transform/core');
const { KHRONOS_EXTENSIONS } = require('@gltf-transform/extensions');

const io = new NodeIO().registerExtensions(KHRONOS_EXTENSIONS);
const document = io.read('input.glb');
const root = document.getRoot();
const tmpAttr = document.createAccessor('TMP');

// Replace int8/int16/uint8/uint16 attributes with float32.
for (const mesh of root.listMeshes()) {
	for (const prim of mesh.listPrimitives()) {
		for (const semantic of prim.listSemantics()) {

			const attr = prim.getAttribute(semantic);
			if (attr.getComponentSize() === 4) continue;
			if (semantic.startsWith('JOINTS_')) continue;

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by donmccurdy
Comment options

You must be logged in to vote
4 replies
@donmccurdy
Comment options

donmccurdy Apr 20, 2021
Maintainer Author

@carstenschwede
Comment options

@donmccurdy
Comment options

donmccurdy Apr 21, 2021
Maintainer Author

@carstenschwede
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants