How can I get world coordinate from local coordinate?

Hello, sorry for my english skill.

I made own local coordinate system. It make only get XY from bounding box surface.
https://www.babylonjs-playground.com/#BYUN2F
(see line 24)

on the contrary, I can’t translate local XY to world position and normal vector (Pick info). I think it need raycast but when I move camera position, it broken.

https://www.babylonjs-playground.com/#BYUN2F#1
(see line 40)
I will make decal from local XY so I need world position and normal vector.

How can I get world position and normal vector?

I am sorry, I am not sure to understand exactly what you are trying to achieve.

Maybe the Framing Behavior of the camera would work here ??? Apply Camera Behaviors - Babylon.js Documentation

Hey deadcat, do you know about BJS createDecal() ? Use decals - Babylon.js Documentation
[playground demo]

Maybe that will make your decal-work… easier? Not sure.

Sorry, I need pick mesh, convert to local XY (It’s done)

but input local XY, convert to pick info

Sorry for my english again

yeap I work with decal already but my boss need picking point to local XY and if change local XY, need decal moving :frowning: with camera panning, zooming

1 Like

Is it not just a projection of the pickedPoint (world space) to the local system of the mesh. Basically multiplying the vector by the matrix ?

You could use Vector.TransformCoordinates for that then you could use your switch to isolate your desired xy.

About normal you can use pickingInfo.getNormal to find them at the collision point.

A possibly interesting demo: https://www.babylonjs-playground.com/#2C8LVE#24

Replace monkey model with red disk, or replace with little plane with red-circle texture on transparent background.

? shrug.

This is fun, having morning e-coffee with my friend and fellow forum helper… Sebavan… and my new friend deadcat. (Wingnut offers cinnamin buns) :slight_smile:

Yeah, pickResult/pickInfo objects have LOTS of useful properties on them. Handy.

I love cinnamon buns and there are not in France (a shame !!!) but having a coffee and cookies as well (probably a bit of topic but I think that not having cinnamon buns was worth sharing :wink: )

if I get picking info from localXY, I get normal and world position, but how :frowning: that is my question

For example,
mesh box size is 1000,
camera is arcrotatecamera and alpha=0, beta=0 (Top position)

when this condition, my local X matched box’s front-top edge, local Y matched box’s left-top edge.
(https://www.babylonjs-playground.com/#BYUN2F#2)

so, I have some local XY, { x: 300, y: 800 }, can I convert this to picking info?

camera can panning, zooming

Thank’s for interesting link Wingnut, you already my friend (and I really need coffee and cinnamon buns)

but I can’t get pick info :frowning: help me

The main thing is what do you want to achieve with those coordinates ? it might help finding the appropriate solution.

this is my project screen.

(camera only can move panning and zoomming)
when I click mesh’s surface, then create decal and fill local XY to below input fileld

that is done. already :smile: (that is Babylon.js Playground line 24)

but vice versa, fill input filed local XY, how can I get picking info for create decal?

I guess you want to project: World coordinates to screen XY

http://jsfiddle.net/gwenaelhagenmuller/fwd5Y/

the vector3 project functions converts from 3d space coordinates to screen ones

thank you for your answer.

that link is point to local XY. that is already done,
my question is local xy to pickinfo even local XY exceed screen space(when zoom in state)
sorry for my english and spending your time :frowning:

http://jsfiddle.net/gwenaelhagenmuller/fwd5Y/ explains how to use project to find screen coordinates between 0 and 1.

Then if you multiply by the screenSize, you can use pick again to do the same code than with the mouse.

Thank you for your answer, I check that code next day!