Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform 設定方法の変更 #108

Open
lriki opened this issue Dec 15, 2019 · 0 comments
Open

Transform 設定方法の変更 #108

lriki opened this issue Dec 15, 2019 · 0 comments
Labels
proposal 実装済みの機能を変更する場合に使用する。

Comments

@lriki
Copy link
Collaborator

lriki commented Dec 15, 2019

Proposal

// x 座標を直接設定する
sprite->setPositionX(1.0f);

// x 座標を平行移動する
sprite->translateX(1.0f);

// x 軸回転を直接設定する
sprite->setRotation(1.0f);

// x 軸回転を加算する
sprite->rotateX(1.0f);

// x 軸拡大率を直接設定する
sprite->setScale(1.0f);

// x 軸拡大率を加算する
sprite->scaleX(1.0f);

Motivation

現状、例えばX方向に移動するのに↓のように書く必要があるのがめんどい。

sprite->setPosition(Vector3(sprite->position().x + 1.0f, sprite->position().y, sprite->position().z));

公開変数を用いる方法について

WorldTransform の遅延構築について・・・
現在 WorldTransform は、setPosition時に dirty フラグを立てておき、WorldTransform が欲しいときに計算している。

Binding の Wrapper 側で変数を使う場合、この値をどこかで Native 側に渡さなければならない。

しかし上記の例の場合は WorldTransform が position や rotation に依存しているため、WorldTransform get 時に Wrapper 側にコールバックして値をもらう必要がある。
(onPreUpdate などで定期的に Wrapper から Native へ送り付けるのもアリだが、WorldTransform の場合はタイミング的に onPreUpdate などではカバーできない。setPosition() の直後に getWroldTransform() したりもできる)

そのため、公開変数を用意することはできない。

translateX

代替として、setPositionX() による直接設定や、translateX() による相対移動、rotateX() による相対回転などを実装する。

Research

Three.js

Object3D.position などは公開変数である。(getter, setter などは無い)

そのため、obj.position.x += 1.0 のように、要素単位で演算ができる。

Unity

ドキュメント上は「変数」となっているが、ReferenceCode を見るとプロパティとなっている。

@lriki lriki added the proposal 実装済みの機能を変更する場合に使用する。 label Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal 実装済みの機能を変更する場合に使用する。
Projects
None yet
Development

No branches or pull requests

1 participant