mirror of
https://github.com/GoodStartLabs/AI_Diplomacy.git
synced 2026-04-22 16:49:15 +00:00
Center the SVG to the viewport of threejs
This commit is contained in:
parent
9dc6972b75
commit
00a5f5d179
2 changed files with 46 additions and 140 deletions
|
|
@ -576,6 +576,16 @@
|
|||
}
|
||||
// This rotates the SVG the "correct" way round, and scales it down
|
||||
group.scale.set(0.5, -0.5, 0.5)
|
||||
// After adding all meshes to the group, update its matrix:
|
||||
group.updateMatrixWorld(true);
|
||||
|
||||
// Compute the bounding box of the group:
|
||||
const box = new THREE.Box3().setFromObject(group);
|
||||
const center = new THREE.Vector3();
|
||||
box.getCenter(center);
|
||||
|
||||
// Offset the group's position by subtracting the center:
|
||||
group.position.sub(center);
|
||||
|
||||
scene.add(group);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue