|
From: Jung, Y. <yvo...@ig...> - 2013-11-05 15:40:00
|
Anfang der weitergeleiteten E-Mail: Von: Yvonne Jung <yvo...@ig...<mailto:yvo...@ig...>> Betreff: Re: [x3dom-users] 2D canvas coordinates to 3D world coordinates Datum: 5. November 2013 (KW 45) 16:36:39 MEZ An: Lukáš Herman <her...@ma...<mailto:her...@ma...>> Calling getViewingRay three times as in your example below is inefficient. Moreover, the viewing ray is only a line (with pos being the camera position). For intersection you have to call doIntersect(ray) on the _internal_ scene object, only then you get a valid hitObject. However, the internal doIntersect method is rather "ancient" and only works on bounding boxes, so you won't get a correct hit point. Therefore, you need to use the new shootRay method. Best, Yvonne Am 05.11.2013 um 16:04 schrieb Lukáš Herman: Unfortunately, I need to know the exact position (x, y, z coordinates) for 2D (x, y) points. I know that the function is not just inverse, but I think that the principle can be similar to displaying the coordinates after click in the scene. This information is in debug displayed as: “Ray hit at position -3.5408061500240406 0.021943795961279378 -7.930886792150201”. I made some experiments with getViewingRay function and I don't know if these values could be the solution. var x = x3dom_el.runtime.getViewingRay(400, 400).pos.x; var y = x3dom_el.runtime.getViewingRay(400, 400).pos.y; var z = x3dom_el.runtime.getViewingRay(400, 400).pos.z; var point = x3dom_el.runtime.getViewingRay(400, 400).hitPoint; //var object = x3dom_el.runtime.shootRay(400, 400); Lukas Herman her...@ma...<mailto:her...@ma...> "Jung, Yvonne" <yvo...@ig...<mailto:yvo...@ig...>> wrote on Thu, 31 Oct 2013 17:22:36 +0000: Hi, if you send a ray through a 2d canvas position, all 3d points along that ray are valid solutions, since due to the dimensionality reduction (from 3d to 2d coordinates), there is no inverse of this process. However, if you just want to know which 3d object position is at (x,y), you can try out the brand new runtime method shootRay(x,y). Hope that helps Yvonne Am 31.10.2013 um 16:28 schrieb Lukáš Herman: Hi, I need to calculate world coordinates (X, Y, Z) for different points localized in 2D coordinates (canvas or page coordinates). I do not work with mouse events. Coordinates would be found naturally only in case that at a given 2D point is some geometry (Shape element). It should be something like the inverse function of calcCanvasPos. Is it appropriate to modify function getViewingRay for this purpose? Or is there other (simple) solution? Any ideas would be much appreciated. Thanks Lukas Herman her...@ma...<mailto:her...@ma...> ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ X3dom-users mailing list X3d...@li...<mailto:X3d...@li...> https://lists.sourceforge.net/lists/listinfo/x3dom-users |