Skip to content

Example integrating with three.js #607

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

You must be logged in to vote

Hi! If the only change you're making to the original glTF file is adding a mesh, I think I'd load the three.js scene with THREE.GLTFLoader and load a glTF Transform Document with WebIO in parallel. Once you've got a THREE.Mesh you can add it to the Document like this:

import { Primitive } from '@gltf-transform/core';

const position = document.createAccessor()
  .setArray(geometry.attributes.position.array)
  .setType('VEC3');
const normal = document.createAccessor()
  .setArray(geometry.attributes.normal.array)
  .setType('VEC3');
const texcoord = document.createAccessor()
  .setArray(geometry.attributes.uv.array)
  .setType('VEC2');

const prim = document.createPrimitive()
  .setAttribute(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@aiden-jeffrey
Comment options

Answer selected by aiden-jeffrey
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