Here is my simple code to get the position of the box
box(y_pos) {
try {
const boxs = MeshBuilder.CreateBox(
"box",
{ size: 2, updatable: true },
this.scene
);
console.log("Box created, setting position...");
// Move the box upward 1/2 its height
boxs.position.y = y_pos;
console.log("Position set to y_pos: " + boxs.position.y); // This should now show the updated y position
// console.log("Position of box: " + boxs.position);
console.log("Box : " + boxs);
} catch (error) {
console.error("An error occurred: ", error);
}
}
On running this code there is no error is coming. The box creates perfectly. But in my console i am not getting the console.log data console.log("Position set to y_pos: " + await boxs.position.y); . I am not even getting "Position set to y_pos: " part. But I was getting this console log data perfectly fine console.log("Box : " + boxs);
Are you able to repro in a Playground ?
I gave it a try on my side and I have no issue :
BJS - [15:25:18]: Babylon.js v7.26.0 - WebGL2 - Parallel shader compilation
VM41:28 Box created, setting position...
VM41:30 Position set to y_pos: 2
VM41:31 Box : Name: box, isInstance: YES, # of submeshes: 1, n vertices: 24, parent: NONE
1 Like

But I am only getting this even after running your playground code.
1 Like
Weird. What about your warnings and errors ? 
I think my brave browser is causing the problem. On firefox it is working correctly
The Content Security Policy (CSP) prevents the evaluation of arbitrary strings as JavaScript to make it more difficult for an attacker to inject unathorized code on your site.
To solve this issue, avoid using eval(), new Function(), setTimeout([string], ...) and setInterval([string], ...) for evaluating strings.
If you absolutely must: you can enable string evaluation by adding unsafe-eval as an allowed source in a script-src directive.
â ď¸ Allowing string evaluation comes at the risk of inline script injection.
Thatâs weird, because to me we are not using any eval here⌠
What about this one ? (a bit cleaner logâŚ)
([Edit] fixed the scene arg)
Nope. Not getting the position log