Skip to content

Commit

Permalink
Merge pull request #69 from ZackaryH8/vector-constructor
Browse files Browse the repository at this point in the history
shared: Add constructor overload to Vector class
Former-commit-id: 3bbe4a6
  • Loading branch information
LeonMrBonnie authored Oct 17, 2021
2 parents 8e1172e + 260bb2e commit 9cb2966
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions shared/bindings/Vector2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,11 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK(x->IsNumber(), "x must be a number");
V8_CHECK(y->IsNumber(), "y must be a number");
}
else if(val->IsNumber())
{
x = val;
y = val;
}
else
{
V8Helpers::Throw(isolate, "Argument must be an array of 2 numbers or IVector2");
Expand Down
6 changes: 6 additions & 0 deletions shared/bindings/Vector3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ static void Constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_CHECK(y->IsNumber(), "y must be a number");
V8_CHECK(z->IsNumber(), "z must be a number");
}
else if(val->IsNumber())
{
x = val;
y = val;
z = val;
}
else
{
V8Helpers::Throw(isolate, "Argument must be an array of 3 numbers or IVector3");
Expand Down

0 comments on commit 9cb2966

Please sign in to comment.