What I am trying to do is, Over the car I want change body color to some image. If try solid colors it works, but for textures it’s not redering correctly
What I tried so far,
* Some base code for SCENE is not included
initCar();
function initCar() {
var dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath( '/js/draco/gltf/' );
var loader = new THREE.GLTFLoader()
loader.setDRACOLoader( dracoLoader );
loader.load(
// resource URL
'./../models/ferrari/ferrari.glb',
// called when the resource is loaded
function ( gltf ) {
let model = gltf.scene.children[0];
// CHANGE MATERIAL
let part = model.getObjectByName( 'body' )
// THIS WORKS
// part.material = new THREE.MeshStandardMaterial( {
// color: 0xff4400, metalness: 1.0, roughness: 0.2, name: 'orange'
// } )
// THIS DOESN"T
var textureLoader = new THREE.TextureLoader();
textureLoader.crossOrigin = true;
textureLoader.load('/images/2.jpeg', function(texture) {
console.log("TEXTURE LOADED", texture)
texture.anisotropy = 16
var material = new THREE.MeshPhongMaterial( { map: texture, opacity:1, transparent: true} );
part.material = material
});
model.scale.set(20.5,20.5,20.5)
scene.add( model );
renderer.render( scene, camera );
},
undefined,
function ( error ) {
console.error( error );
}
);
}
Regardless of how you create the UVs, designing a UV layout for a texture that wasn’t meant for this car is going to be very hard… I would suggest finding a car model that already has UVs and a texture, then modify/recolor the texture to your liking.
Sorry for the typo,
What I meant was, for this Question I posted, Conclusion is problem is with the model, once I add UV texture I can change texture for a model.
I wanna do the very same thing that you were trying. Applying an image onto a 3D object or change its color by user selection. Did you make it work, by any chance? Did anybody work it out?