Object dissapears when using transform controls

transform-controls

#1

Hi, I have a problem. I am creating some kind of editor and when I move my object by an input field the object gets translated properly. But when I use it to set the value under 1 and use the transform controls afterwards the object simply disapears.

Here I have a video example:
GIF

I save the object in a global value and everytime i change the input I directly move the object:

langitude.addEventListener(“input”, function(){
global.MainObject[‘position’].x = langitude.value;
})

And when I move the object with the transform tools I do this:

if(langitude != null){
            langitude.value = parseFloat(position.x).toFixed(3);
        }

I hope I have supplied some insight into what I am doing and if someone can help that would be really helpfull. If I need to supply more information for you to help me please say so and I will happily do so.

Thank you in advance!


#2

It seems that your provided link does not work. It leads to a 404 site of imgur. Besides, is it possible for you to reproduce the problem in a small live example? I’m afraid your provided code is not enough in order to analyze the problem. You can use the following fiddle as a basis. It already uses TransformControls.

https://jsfiddle.net/f2Lommf5/15122/


#3

Hi, I will try and fix the url first and try and recreate it in js fiddle. Give me a moment.


#4

https://jsfiddle.net/f2Lommf5/15129/

The gif has been fiex also the JSFiddle seems to do the same thing.
If you want to re create the issue: In the input field add an object smaller than 1. Try and move the cube. It disapears.


#5

Here is the fixed code: https://jsfiddle.net/f2Lommf5/15137/

The problem was that you have passed input.value directly the mesh.position.x. input.value is a string whereas Vector3.x expects a float. parseFloat() solves this issue.

mesh.position.x = parseFloat( input.value );

#6

Hmm, it indeed seems to fix it in the fiddle but doesn’t in my editor. To me it looks like it is something with the transform controlls where the controlls expect the object to be somewhere but it not there anymore? because I can see the object teleport back sometimes aswell. Do you know if I can set the position via trnasform controlls?


#7

AFAIK, no. I’ve not seen an API for this. I think TransformControls should be still working if its current object (mesh) is manually transformed like in the fiddle.


#8

I am going to look more into this myself. When I hardcode a string with a previously not working value it now works so I think the parsing has send me in the right direction. Thank you!