I have added a plane in the scene. Its position [x,y,z] and width, height is working perfectly fine.
Now I have added rotation to it, which is not working. What is wrong with my code ?
Here is the code for the same:
{ id: 0, url: "products/tshirt1.png", width: 1, height: 1, position: new BABYLON.Vector3(6.5999999999999925, 0, 2), rotation: { x: 0, y: 1.5, z: 0 }, name: "T-Shirt 1", price: "$10" },
mawa
2
Hi,
You should try provide a PG (if by any means possible). Still, quickly looking at this, did you just try?
rotation: new BABYLON.Vector3(0, Math.PI/2, 0)
If you define the position with new BABYLON.Vector3 I believe the rotation also should be new BABYLON.Vector3.
No, this line is giving error
{ id: 0, url: "products/tshirt1.png", width: 1, height: 1, position: new BABYLON.Vector3(6.5999999999999925, 0, 2), rotation: new BABYLON.Vector3{ x: 0, y: 1.5, z: 0 }, name: "T-Shirt 1", price: "$10" },
Can you please repro in a playground?
1 Like
Problem is solved by doing this:
I used adjustRotation
function to directly modify the rotation of the selected plane and ensure that the changes are reflected in the planeData
array.
function adjustRotation(axis, value) {
if (selectedPlane) {
const id = selectedPlane.name.replace("imagePlane", "");
const data = planeData.find(p => p.id == id);
switch(axis) {
case 'x':
selectedPlane.rotation.x += value;
data.rotation.x = selectedPlane.rotation.x;
break;
case 'y':
selectedPlane.rotation.y += value;
data.rotation.y = selectedPlane.rotation.y;
break;
case 'z':
selectedPlane.rotation.z += value;
data.rotation.z = selectedPlane.rotation.z;
break;
}
logSelectedPlaneData();
}
}
2 Likes