Skip to content
Discussion options

You must be logged in to vote

To remove KHR_texture_transform and apply its transforms to each mesh primitive:

import { Material } from '@gltf-transform/core';
import { Transform } from '@gltf-transform/extensions';
import { prune } from '@gltf-transform/functions';
import { vec3, mat3 } from 'gl-matrix';

const matrixMap = new Map();

// Compute UV transform matrix for each material's base color texture.
for (const material of document.getRoot().listMaterials()) {
	const info = material.getBaseColorTextureInfo();
	const transform = info.getExtension('KHR_texture_transform');
	if (!transform) continue;
	
	const matrix = mat3.create();
	mat3.translate(matrix, matrix, transform.getOffset());
	mat3.rotate(matrix, matrix, -…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by donmccurdy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants