Size model based on image target dimensions


#1

I am trying a very simple project where I need to replace a target image with a different image. The problem is I need the replacement image to be the same size as the target image. How do I get the target image dimensions so that my replacement image lies directly overtop the target image.

Thanks in advance!!!
Bill

Here is a sample of my code (some code left out for brevity):

const tracker = new ZapparThree.ImageTrackerLoader(manager).load(targetImage);
const trackerGroup = new ZapparThree.ImageAnchorGroup(camera, tracker);

// Add the tracker group to the ThreeJS scene
mainScene.add(trackerGroup);

var loader = new THREE.TextureLoader();
var imgSrc = ‘https://s3.amazonaws.com/duhaime/blog/tsne-webgl/assets/cat.jpg’;

var material = new THREE.MeshBasicMaterial({
map: loader.load(imgSrc),
side: THREE.DoubleSide,
opacity: 1
});
var geometry = new THREE.PlaneGeometry(5, 5*.75);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(0,0,0)
trackerGroup.add(mesh)