I have several models (geometries) And they are all of different size and format
var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var materials = new THREE.MeshBasicMaterial({ color: "red"}) ; var cube = new THREE.Mesh(geometry, materials); scene.add(cube); var topy = 'models/JSON/111.json'; var loader = new THREE.ObjectLoader(); loader.load( topy, function ( obj ) { scene.add( obj ); }); var loader = new THREE.TextureLoader(); var normal = loader.load( 'models/3ds/portalgun/textures/normal.jpg' ); var loader = new THREE.TDSLoader( ); loader.setResourcePath( 'models/3ds/portalgun/textures/' ); loader.load( 'models/3ds/portalgun/portalgun.3ds', function ( object ) { object.traverse( function ( child ) { if ( child instanceof THREE.Mesh ) { child.material.normalMap = normal; } } ); scene.add( object ); } ); var loader = new THREE.ThreeMFLoader(); loader.load( 'models/3MF/Mi-24.3mf', function ( object ) { scene.add( object ); } ); I need all models to be the same size and in the same place.
as I have a floor on which in the center models should be displayed
var floor_gam = new THREE.PlaneBufferGeometry( 2000, 2000 ) ; var floor_rotat = - Math.PI / 2; var mat_standart = new THREE.MeshStandardMaterial( { color: 0x808080, roughness: 0, metalness: 0 } ) ; var object_floor_standart = new THREE.Mesh( floor_gam, mat_standart ); object_floor_standart.rotation.x = floor_rotat ; object_floor_standart.receiveShadow = true; scene.add( object_floor_standart ); Who does not know how to do this? I tried
var center = obj.geometry.boundingSphere.center; controls.target.set( center.x, center.y, center.z ); But this does not work with all models and simply fits the camera to the model, but vice versa.
width: 300px; height: 300px; object-fit: contain;width: 300px; height: 300px; object-fit: contain;only for three.js - zeni1agent 1:19 pm