Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-components
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
scilla-components
Commits
f1502810
Commit
f1502810
authored
Mar 21, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transform组价增加逆矩阵属性
parent
09b3eebd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
InteractComponent.ts
src/base/InteractComponent.ts
+2
-5
Transform.ts
src/base/Transform.ts
+27
-2
No files found.
src/base/InteractComponent.ts
View file @
f1502810
...
@@ -120,11 +120,8 @@ export default class InteractComponent extends ScillaComponent {
...
@@ -120,11 +120,8 @@ export default class InteractComponent extends ScillaComponent {
* @param e
* @param e
*/
*/
hitTest
(
e
)
{
hitTest
(
e
)
{
const
matrix
=
this
.
transform
.
getMatrix
();
const
matrix
=
this
.
transform
.
getMatrix
(
false
,
true
);
const
invertMatrix
=
this
.
invertMatrix
;
matrix
.
transformPoint
(
e
.
x
,
e
.
y
,
this
.
localPos
);
invertMatrix
.
copyFrom
(
matrix
);
invertMatrix
.
invert
();
invertMatrix
.
transformPoint
(
e
.
x
,
e
.
y
,
this
.
localPos
);
let
result
=
false
;
let
result
=
false
;
const
renderers
=
this
.
entity
.
getComponents
(
Renderer
);
const
renderers
=
this
.
entity
.
getComponents
(
Renderer
);
...
...
src/base/Transform.ts
View file @
f1502810
...
@@ -32,6 +32,11 @@ export default class Transform extends ScillaComponent {
...
@@ -32,6 +32,11 @@ export default class Transform extends ScillaComponent {
@
dirtyFieldTrigger
@
dirtyFieldTrigger
position
:
Vector2D
=
new
Vector2D
(
0
,
0
);
position
:
Vector2D
=
new
Vector2D
(
0
,
0
);
/**
* 全局坐标
*/
private
_globalPosition
:
Vector2D
=
new
Vector2D
(
0
,
0
);
/**
/**
* 节点透明度
* 节点透明度
*/
*/
...
@@ -73,6 +78,7 @@ export default class Transform extends ScillaComponent {
...
@@ -73,6 +78,7 @@ export default class Transform extends ScillaComponent {
protected
_localMatrix
:
Matrix
=
Matrix
.
create
();
protected
_localMatrix
:
Matrix
=
Matrix
.
create
();
protected
_globalMatrix
:
Matrix
=
Matrix
.
create
();
protected
_globalMatrix
:
Matrix
=
Matrix
.
create
();
protected
_globalInvertMatrix
:
Matrix
=
Matrix
.
create
();
protected
_globalPivotMatrix
:
Matrix
=
Matrix
.
create
();
protected
_globalPivotMatrix
:
Matrix
=
Matrix
.
create
();
protected
dirty
:
boolean
;
protected
dirty
:
boolean
;
...
@@ -110,6 +116,14 @@ export default class Transform extends ScillaComponent {
...
@@ -110,6 +116,14 @@ export default class Transform extends ScillaComponent {
}
}
}
}
/**
* 获取全局坐标
*/
get
globalPosition
(){
this
.
_globalPosition
.
setXY
(
this
.
_globalMatrix
.
tx
,
this
.
_globalMatrix
.
ty
);
return
this
.
_globalPosition
;
}
makeDirty
(
value
,
key
,
oldValue
?)
{
makeDirty
(
value
,
key
,
oldValue
?)
{
this
.
dirty
=
true
;
this
.
dirty
=
true
;
...
@@ -183,6 +197,8 @@ export default class Transform extends ScillaComponent {
...
@@ -183,6 +197,8 @@ export default class Transform extends ScillaComponent {
if
(
parentTransform
)
{
if
(
parentTransform
)
{
this
.
_renderAlpha
=
parentTransform
.
_renderAlpha
*
this
.
alpha
;
this
.
_renderAlpha
=
parentTransform
.
_renderAlpha
*
this
.
alpha
;
_globalMatrix
.
concat
(
parentTransform
.
getMatrix
(
true
));
_globalMatrix
.
concat
(
parentTransform
.
getMatrix
(
true
));
}
else
{
this
.
_renderAlpha
=
this
.
alpha
;
}
}
}
else
{
}
else
{
this
.
_renderAlpha
=
this
.
alpha
;
this
.
_renderAlpha
=
this
.
alpha
;
...
@@ -197,8 +213,17 @@ export default class Transform extends ScillaComponent {
...
@@ -197,8 +213,17 @@ export default class Transform extends ScillaComponent {
/**
/**
* 获取矩阵
* 获取矩阵
*/
*/
getMatrix
(
withPivot
=
false
):
Matrix
{
getMatrix
(
withPivot
:
boolean
=
false
,
invert
:
boolean
=
false
):
Matrix
{
return
withPivot
?
this
.
_globalPivotMatrix
:
this
.
_globalMatrix
;
let
matrix
=
withPivot
?
this
.
_globalPivotMatrix
:
this
.
_globalMatrix
;
if
(
invert
){
const
invertMatrix
=
this
.
_globalInvertMatrix
;
invertMatrix
.
copyFrom
(
matrix
);
invertMatrix
.
invert
();
return
invertMatrix
;
}
return
matrix
;
}
}
onUpdate
(
t
)
{
onUpdate
(
t
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment