Hello everyone,
i just started to learn Threejs, i imported a 3D model (.obj) and its materials (.mtl) from blender to threejs, now, how can i rescale the object via three js?!
Thanks
Hi!
Read this topic: Best way of resizing an obj that's appearing too large by default?
Thanks,
i just tried it and it works fine except that’s what i need it after all, my bad,
what i like to change is the dimensions (x,y,z) not the scale.!
i tried object.width but it didn’t work!
Could you clarify what you want to achieve? Explanatory pics and/or live code example would be great to have.
ok, my aim is to put a ring on fingers, so in one hand i implemented a python script to detect position of fingers also the widths of fingers, in the other hand, what i want in three js, is to get the width of finger from python script and give it the ring also the coordinates.
but first i’m just trying to understand threejs, so i get the model from blender, i uploaded it to threejs, now i’m stuck in changing the width of the ring.
You can find the images below.
Also the width should be in pixels! if it’s possible!
Thanks
<!DOCTYPE html>
<style type="text/css">
body {
margin: 0px;
}
</style>
const scene = new THREE.Scene();
const light = new THREE.DirectionalLight('#ffffff' , 0.9);
light.position.set(0,5,0);
scene.add(light);
const camera = new THREE.PerspectiveCamera( 75,window.innerWidth/window.innerHeight,0.1,1000);
camera.position.set(0,5,0);
camera.lookAt(new THREE.Vector3(0,0,0));
//camera.position.z=5;
const renderer = new THREE.WebGLRenderer( );
renderer.setSize(window.innerWidth,window.innerHeight);
document.body.appendChild(renderer.domElement);
const objLoader = new THREE.OBJLoader();
objLoader.setPath('/blender-files/')
const mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath('/blender-files/')
new Promise((resolve) =>{
mtlLoader.load('tstRing.mtl',(materials) =>{
resolve(materials);
})
})
.then((materials) => {
materials.preload();
objLoader.setMaterials(materials);
objLoader.load('tstRing.obj',(object) => {
scene.add(object);
})
})
function render(){
requestAnimationFrame(render);
renderer.setClearColor( 0xb8b894 );
renderer.render(scene,camera);
}
render();
</script>
Image1: https://ibb.co/0MwW50w
Image2: https://ibb.co/0BTcCXd