specklesystems / speckle-unity

AEC Interoperability for Unity through Speckle
https://speckle.systems/tag/unity/
Apache License 2.0
55 stars 20 forks source link

Speckle comments on wrong position/location #89

Closed LukasKlepper closed 1 year ago

LukasKlepper commented 1 year ago

Hi there,

we are currently trying to integrate the speckle comments on a stream within unity. For that we firstly wanted to just show the comments as basic game objects w/o any text or context.

I've had no problems getting the comments, but as I've looked at the location something wasn't correct. The comments from the graph ql api seem to return the (wrong?) locations.

Where I've expected it to be: grafik

Where it actually is: (the green dot represents it) grafik

I've used the data.location property from a CommentItem

Im sure that the coordinates are correct as I've checked against the graphql api explorer from speckle.xyz. grafik grafik

Code:

    public void LoadComments(string streamId, string streamName, GameObject go)
    {
        var comments = speckleLoader.Client.StreamGetComments(streamId).Result;
        foreach (var item in comments.items)
        {
            var comment = GameObject.Instantiate(commentPrefab, new Vector3((float)item.data.location.x, (float)item.data.location.y, (float)item.data.location.z), Quaternion.identity, go.transform);
            comment.name = $"Comment #{item.id}";
        }
    }

For our use case we would need the exact position like in the speckle viewer seen in the first picture.

I don't know if it fits in this correct repository as ait also seems to connect to Speckle.Core, please dont kill me!

LukasKlepper commented 1 year ago

Any news on this? @teocomi @JR-Morgan

JR-Morgan commented 1 year ago

Hi @LukasKlepper, Sorry for the delayed response,

This looks really exciting. 🙌

My suspicion is that the coordinate system that unity uses is slightly different from what we use in our comments (and objects) We have this function in the Unity Converter to correct for this. https://github.com/specklesystems/speckle-unity/blob/db2b8312780d7b79784f2c6dc6c0962c0b040f0f/Packages/systems.speckle.speckle-unity/Runtime/Converter/Unity/ConverterUnity.Geometry.cs#L33 Simply swapping the Y and the Z should get you the result you are looking for, although let me know if that's not the case, and I can do some more investigating

JR-Morgan commented 1 year ago

@LukasKlepper Were you able to resolve your issue?

I'm closing this issue for now, If you still need assistance, you can re-open this issue or reach out to us on speckle.community