Skip to content

Send non-uniform scale and quaternions natively on gem API 0.5.0 - #36

Merged
nickschuetz merged 2 commits into
mainfrom
feat/native-scale-quaternion
Oct 9, 2026
Merged

nickschuetz merged 2 commits into
mainfrom
feat/native-scale-quaternion

Conversation

@nickschuetz

Copy link
Copy Markdown
Owner

What

The AiCompanion gem's API 0.5.0 (gem 0.6.0) adds two things to its native set_transform:

  • scale as [x, y, z]: the gem applies a non-uniform scale with the engine's Non-uniform Scale component, the same call the Transform component's "Add non-uniform scale" button uses, in one undo step.
  • rotation_quaternion.

The editor Python API cannot add that component (tried live: editor.AddNonUniformScaleComponent returns None and adds nothing), so a native path is the only way to get real non-uniform scale.

Changes

  • set_transform asks the gem for its API version when a rotation or a non-uniform scale is given. The version is cached on the connection and forgotten when it closes, so position-only and uniform-scale calls cost no extra round trip.
  • On API 0.5.0+ it sends the quaternion and the scale natively:
    • no Euler conversion, and no editor-Python detour for rotations at a gimbal pole;
    • non-uniform scale works, in secure mode too.
  • Older gems keep the previous behavior: Euler degrees, editor Python at a gimbal pole, and a non-uniform scale refused with non_uniform_scale_unsupported.
  • get_transform reports the effective scale (the Transform's uniform scale times the component) with uniform_scale and non_uniform_scale beside it. Its editor-Python GetScale answers (0, 0, 0), not None, without the component (seen live), so a zero vector reads as no component.

Tests

  • Unit: the API 0.5.0 request shape (quaternion and array scale; a uniform scale still sent as a number), a native refusal, the version cache (asked once, forgotten on close; no gem means no version), and get_transform's zero-vector and component cases. Existing tests now run as an API 0.4.0 gem.

  • Live, the 0.6.0 release gate: AiCompanion gem release/0.6.0 at 54798a4 (gem 0.6.0, API 0.5.0), full suite 56 of 56, run twice:

    • [50, 50, 1] lands natively, and get_transform reports scale [50, 50, 1], uniform 1, component [50, 50, 1];
    • a later uniform [2, 2, 2] resets the component;
    • [0.001, 1, 1] is refused (validation_failed);
    • a gimbal-pole quaternion goes through natively and keeps scale 3.

    On older gems the same live tests assert the refusal instead.

Docs

The tool reference, the architecture doc, CLAUDE.md and the CHANGELOG describe both paths.

The AiCompanion gem's API 0.5.0 (shipping in 0.6.0) takes set_transform's
scale as [x, y, z], applying a non-uniform scale through the engine's
Non-uniform Scale component, and takes a rotation as rotation_quaternion.
set_transform now asks the gem for its API version when a rotation or a
non-uniform scale is given (cached on the connection, forgotten when it
closes) and on 0.5.0+ sends both natively: no Euler conversion, no editor
Python detour for rotations at a gimbal pole, and non-uniform scale works,
in secure mode too. Older gems keep the previous behavior: Euler degrees,
editor Python at a gimbal pole, and a non-uniform scale refused.

get_transform reports the effective scale (the Transform's uniform scale
times the Non-uniform Scale component) with uniform_scale and
non_uniform_scale beside it. GetScale answers (0, 0, 0) rather than None on
an entity without the component (seen live), so a zero vector reads as no
component.
@nickschuetz
nickschuetz merged commit d441c28 into main Oct 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant