Skip to content

Commit

Permalink
[WIP] add tween components (#175)
Browse files Browse the repository at this point in the history
* add tween components

* iterate tween

* update current_time to float

* update naming

* add optional current-time to tween

* added easing function types to enum

* added oneof for mode/rotation/scale

* wip tween helper for seuqences

* added 'face_direction' optional bool in Tween

* fixed missing semicolon =P

* add loop enum

* moved face_direction to Move inner-message

* update tween function with easing function

* add tween sequence to sdk-componenets

* remove comments

---------

Co-authored-by: Pravus <[email protected]>
  • Loading branch information
gonpombo8 and pravusjif authored Oct 10, 2023
1 parent a9a962a commit d038938
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 8 deletions.
16 changes: 8 additions & 8 deletions proto/decentraland/common/texture.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ enum TextureFilterMode {
}

message Texture {
string src = 1;
optional TextureWrapMode wrap_mode = 2; // default = TextureWrapMode.Clamp
optional TextureFilterMode filter_mode = 3; // default = FilterMode.Bilinear
string src = 1;
optional TextureWrapMode wrap_mode = 2; // default = TextureWrapMode.Clamp
optional TextureFilterMode filter_mode = 3; // default = FilterMode.Bilinear
}

message AvatarTexture {
Expand All @@ -32,9 +32,9 @@ message VideoTexture {
}

message TextureUnion {
oneof tex {
Texture texture = 1; // default = null
AvatarTexture avatar_texture = 2; // default = null
VideoTexture video_texture = 3; // default = null
}
oneof tex {
Texture texture = 1; // default = null
AvatarTexture avatar_texture = 2; // default = null
VideoTexture video_texture = 3; // default = null
}
}
74 changes: 74 additions & 0 deletions proto/decentraland/sdk/components/tween.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
syntax = "proto3";

package decentraland.sdk.components;

import "decentraland/common/vectors.proto";
import "decentraland/sdk/components/common/id.proto";

option (common.ecs_component_id) = 1102;

message PBTween {
float duration = 1; // in milliseconds
EasingFunction easing_function = 2;

oneof mode {
Move move = 3;
Rotate rotate = 4;
Scale scale = 5;
}

optional bool playing = 6; // default true (pause or running)
optional float current_time = 7; // between 0 and 1
}

message Move {
decentraland.common.Vector3 start = 1;
decentraland.common.Vector3 end = 2;
optional bool face_direction = 3;
}

message Rotate {
decentraland.common.Quaternion start = 1;
decentraland.common.Quaternion end = 2;
}

message Scale {
decentraland.common.Vector3 start = 1;
decentraland.common.Vector3 end = 2;
}

// Implementation guidelines for these easing functions can be found
// at https://github.com/ai/easings.net/blob/6fcd5f852a470bf1a7890e8178afa0f471d5f2ec/src/easings/easingsFunctions.ts
enum EasingFunction {
EF_LINEAR = 0; // default
EF_EASEINQUAD = 1;
EF_EASEOUTQUAD = 2;
EF_EASEQUAD = 3;
EF_EASEINSINE = 4;
EF_EASEOUTSINE = 5;
EF_EASESINE = 6;
EF_EASEINEXPO = 7;
EF_EASEOUTEXPO = 8;
EF_EASEEXPO = 9;
EF_EASEINELASTIC = 10;
EF_EASEOUTELASTIC = 11;
EF_EASEELASTIC = 12;
EF_EASEINBOUNCE = 13;
EF_EASEOUTBOUNCE = 14;
EF_EASEBOUNCE = 15;
EF_EASEINCUBIC = 16;
EF_EASEOUTCUBIC = 17;
EF_EASECUBIC = 18;
EF_EASEINQUART = 19;
EF_EASEOUTQUART = 20;
EF_EASEQUART = 21;
EF_EASEINQUINT = 22;
EF_EASEOUTQUINT = 23;
EF_EASEQUINT = 24;
EF_EASEINCIRC = 25;
EF_EASEOUTCIRC = 26;
EF_EASECIRC = 27;
EF_EASEINBACK = 28;
EF_EASEOUTBACK = 29;
EF_EASEBACK = 30;
}
18 changes: 18 additions & 0 deletions proto/decentraland/sdk/components/tween_sequence.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";

package decentraland.sdk.components;

import "decentraland/sdk/components/common/id.proto";
import "decentraland/sdk/components/tween.proto";

option (common.ecs_component_id) = 1104;

message PBTweenSequence {
repeated PBTween sequence = 1;
optional TweenLoop loop = 2;
}

enum TweenLoop {
TL_RESTART = 0;
TL_YOYO = 1;
}
18 changes: 18 additions & 0 deletions proto/decentraland/sdk/components/tween_state.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";

package decentraland.sdk.components;

import "decentraland/sdk/components/common/id.proto";

option (common.ecs_component_id) = 1103;

message PBTweenState {
TweenStateStatus state = 1;
float current_time = 2; // between 0 and 1
}

enum TweenStateStatus {
TS_ACTIVE = 0;
TS_COMPLETED = 1;
TS_PAUSED= 2;
}
3 changes: 3 additions & 0 deletions public/sdk-components.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import public "decentraland/sdk/components/pointer_lock.proto";
import public "decentraland/sdk/components/raycast_result.proto";
import public "decentraland/sdk/components/raycast.proto";
import public "decentraland/sdk/components/text_shape.proto";
import public "decentraland/sdk/components/tween.proto";
import public "decentraland/sdk/components/tween_state.proto";
import public "decentraland/sdk/components/tween_sequence.proto";
import public "decentraland/sdk/components/ui_background.proto";
import public "decentraland/sdk/components/ui_dropdown_result.proto";
import public "decentraland/sdk/components/ui_dropdown.proto";
Expand Down

0 comments on commit d038938

Please sign in to comment.