Customize gizmos issue

YL}2`FBF}QCE4VUVMT25KP7

gizmoPositionAxis code:

 /** @hidden */
    public static _CreateArrow(scene: BABYLON.Scene, material: BABYLON.StandardMaterial, thickness: number = 1): BABYLON.TransformNode {
        var arrow = new BABYLON.TransformNode("arrow", scene);
        var cylinder = BABYLON.CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (thickness - 1) / 4), tessellation: 96 }, scene);
        var line = BABYLON.CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, scene);
        line.material = material
        cylinder.parent = arrow;
        line.parent = arrow;

        // Position arrow pointing in its drag axis
        cylinder.material = material;
        cylinder.rotation.x = Math.PI / 2;
        cylinder.position.z += 0.3;

        line.position.z += 0.275 / 2;
        line.rotation.x = Math.PI / 2;
        return arrow;
    }

the arrow consists of two cylinders.The mouse when choosing arrow moving ,the ''pointerInfo.pickInfo.pickedMesh" is "cylinder "

I change the ‘line’ cylinders to the lineMesh, just like that:
C6BMMNBG9MDJRTMBK6}{J4
the code:

/** @hidden */
    public static _CreateArrow(scene: BABYLON.Scene, material: BABYLON.StandardMaterial, thickness: number = 1): BABYLON.TransformNode {
        var arrow = new BABYLON.TransformNode("arrow", scene);
        var cylinder = BABYLON.CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (thickness - 1) / 4), tessellation: 96 }, scene);
        // var line = BABYLON.CylinderBuilder.CreateCylinder("cylinder", { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, scene);

        // lineMesh
        let pointsArr = [];
        let point1 = new BABYLON.Vector3(0, 0, 0);
        let point2 = new BABYLON.Vector3(0, 0, 0.275);
        let centerPoint = new BABYLON.Vector3(0, 0, 0.275 / 2);
        pointsArr.push(new BABYLON.Vector3(point1.x - centerPoint.x, point1.y - centerPoint.y, point1.z - centerPoint.z));
        pointsArr.push(new BABYLON.Vector3(point2.x - centerPoint.x, point2.y - centerPoint.y, point2.z - centerPoint.z));

        let currentLine = BABYLON.MeshBuilder.CreateLines("line", { points: pointsArr }, scene);
        // currentLine.isPickable = false;
        currentLine.material = material;

        // line.material = material
        cylinder.parent = arrow;
        // line.parent = arrow;
        currentLine.parent = arrow;
        // Position arrow pointing in its drag axis
        cylinder.material = material;
        cylinder.rotation.x = Math.PI / 2;
        cylinder.position.z += 0.3;
        currentLine.position.z += 0.275 / 2;
        // currentLine.rotation.x = Math.PI / 2;
        // line.position.z += 0.275 / 2;
        // line.rotation.x = Math.PI / 2;
        return arrow;
    }

It is strange that the mouse when choosing arrow moving ,the ''pointerInfo.pickInfo.pickedMesh" is “currentLine”. Even if I set “currentLine.isPickable = false;”, the mouse when choosing arrow moving “pointerInfo.pickInfo.pickedMesh” is not "cylinder ".

I would like to know why and how to solve this problem, thank you!

Hello and welcome to the Babylon community! I’m sorry, but I don’t quite understand your issue fully :slight_smile: You changed your gizmo to have a line instead of a cylinder but you don’t want this line to be pickable…?
Also, is there a special reason you’re changing the gizmo directly on _CreateArrow instead of using setCustomMesh? Gizmos | Babylon.js Documentation

yeah ,I modified the source code of gizmos.like this,
image

i changed my gizmo to have a line instead of ‘cylinder2’。
As a result,cylinder1 cannot be pickable.
I tried many times, but I couldn’t find the reason.

I tried your code here and can still grab the cylinder1 and move it around. Its color doesn’t change to yellow however. Is this what you are talking about?

yeah, it can grab the ‘cylinder1’ and move it around. because ‘cylinder1’ and ‘currentLine’ have a same parent. you can print the “pointerInfo.pickInfo.pickedMesh”,it shows you grab the “currentLine”.
You can try to set “currentLine.isPickable = false;". As a result, I cannot grab
the ’cylinder1‘;
this is the record of my screen,you can download it to look:
https://veryar.oss-cn-hangzhou.aliyuncs.com/test/test.mp4“

At last , I delete the ‘currentLine’, I can grab the ‘cylinder1’ again.
So,I wondered if it had something to do with the line pickup mechanism, but I couldn’t find any documentation

:joy: Does anyone else have the same problem AS me?

Is there any specific reason you don’t want the line to be pickable? :slight_smile: Perhaps there is a different way of achieving what you want :slight_smile:

Hello @hbwow123 just checking in if you’re still having issues

i used other mesh to create a new Gizmos ,thanks everyone to help me!!!
image

1 Like