Addition of Div on the image texture and it must move when we move the sphere

function onMouseClick(event) {

	// Calculate normalized device coordinates (NDC) from mouse coordinates
	const mouse = new THREE.Vector2();
	mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
	mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;

	// Create a ray from the camera through the mouse's NDC
	const raycaster = new THREE.Raycaster();
	raycaster.setFromCamera(mouse, camera);

	// Intersect the ray with the sphere
	const intersects = raycaster.intersectObject(mesh);

	const inputDiv = document.createElement('div'); = 'absolute'; = '1'; = intersects[0].uv.x + "px"; = intersects[0].uv.y + "px";
	// Create an input text box element and add it to the div
	const inputBox = document.createElement('input'); = 'absolute' = '200px'; = '60px'; = '1.5px solid black'; = '5px';
	inputBox.type = 'text'; = "block";

	// Append the div to the document body

	// Add an event listener to handle input text changes
	inputBox.addEventListener('input', function () {
		const xValue = parseFloat(inputBox.value); // Parse the X coordinate from the input
		// You can use xValue for your desired purpose

	// Remove the div when you're done with it (e.g., when you click outside of it)
	document.addEventListener('dblclick', function (e) {
		if (!inputDiv.contains( {
 window.addEventListener('dblclick', onMouseClick);

This is my code

how can we do it

It’s quite unclear exactly what you’re asking, it would be best if you provided some reference images of what you’re trying to achieve along with a nicely formatted question, it’s quite difficult to deduct what result you’re expecting from the code you have provided as it only partially seems to relate to the title…

if you need to preserve the input functionality of the inputBox, the common option would be to use the CSS3DRenderer class, this wouldn’t have the option of being used as an addition to an image texture as it is HTML and not a texture… if you do not need to preserve the input functionality and just need to serve an image texture you could use a library such as html2canvas which you could then apply as a CanvasTexture onto your object…

1 Like