Will do the exact same, but I don’t know, how to apply subdivision changes on my mesh in object. Three example fits not and is to much complicated, I guess. This is, what I have for now:
var manager = new THREE.LoadingManager();
new GLTFLoader(manager)
.load('cube.glb', function(gltf) {
gltf.scene.traverse( function ( child ) {
if ( child.isMesh ) {
glTFGeometry = child.geometry;
}
} );
scene.add(gltf.scene);
Now, before and after adding gltf to scene, I would like to change subdivisions on this object (e.g. Cube).
var subdivisions = 2;
var modifier = new SubdivisionModifier(subdivisions);
modifier.modify(glTFGeometry);
Think, this does what I need. But how can I apply this to gltf mesh? I cannot see any changes in scene.
SubdivisionModifier.modify() returns a new geometry object. Meaning it does not affect the existing one. Try it like so:
var manager = new THREE.LoadingManager();
new GLTFLoader(manager)
.load('cube.glb', function(gltf) {
var subdivisions = 2;
var modifier = new SubdivisionModifier(subdivisions);
gltf.scene.traverse( function ( child ) {
if ( child.isMesh ) {
child.geometry = modifier.modify( child.geometry );
}
} );
scene.add(gltf.scene);