Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scilla-core
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-core
Commits
0a4af8af
Commit
0a4af8af
authored
Jun 20, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nothing
parent
4127b833
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
6 deletions
+37
-6
Entity.ts
src/core/Entity.ts
+1
-1
ScillaEngine.ts
src/core/ScillaEngine.ts
+13
-4
interpreter.ts
src/core/interpreter.ts
+1
-1
utils.ts
src/core/utils.ts
+22
-0
No files found.
src/core/Entity.ts
View file @
0a4af8af
...
...
@@ -6,7 +6,7 @@ import HashObject from "./HashObject";
import
{
Component
}
from
"./Component"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
{
ScillaEngine
}
from
"./ScillaEngine"
;
import
{
bubbling
,
traverse
}
from
"./
entity-
utils"
;
import
{
bubbling
,
traverse
}
from
"./utils"
;
/**
* 实体类
...
...
src/core/ScillaEngine.ts
View file @
0a4af8af
...
...
@@ -10,7 +10,7 @@ import InteractContext from "./context/InteractContext";
import
RenderContext
,
{
ScaleMode
}
from
"./context/RenderContext"
;
import
'./requestAnimationFrame'
;
import
{
AssetsManager
}
from
"../assets-manager"
;
import
{
traverse
,
traversePostorder
}
from
"./
entity-
utils"
;
import
{
traverse
,
traversePostorder
}
from
"./utils"
;
import
DataCenter
from
"../support/DataCenter"
;
/**
...
...
@@ -68,8 +68,8 @@ export class ScillaEngine {
injectProp
(
this
.
customConfig
,
_customConfig
);
injectProp
(
this
.
dataCenterConfig
,
_dataCenterConfig
);
if
(
this
.
dataCenterConfig
.
dataCenterRoot
)
{
for
(
let
item
of
this
.
dataCenterConfig
.
dataCenterRoot
)
{
if
(
this
.
dataCenterConfig
.
dataCenterRoot
)
{
for
(
let
item
of
this
.
dataCenterConfig
.
dataCenterRoot
)
{
this
.
_dataCenter
.
register
(
item
);
}
}
...
...
@@ -191,7 +191,7 @@ export class ScillaEngine {
return
this
.
_assetsManager
;
}
get
canvasElement
():
HTMLCanvasElement
{
get
canvasElement
():
HTMLCanvasElement
{
return
this
.
_canvasElement
;
}
...
...
@@ -313,6 +313,15 @@ export class ScillaEngine {
})
}
/**
* 射线测试获取实体
*/
getEntitiesByRayTest
(
x
,
y
)
{
traversePostorder
(
this
.
_root
,
function
(
child
)
{
return
child
.
onInteract
(
2
,
event
);
})
}
/**
* 页面坐标转画布坐标
* @param pageX
...
...
src/core/interpreter.ts
View file @
0a4af8af
...
...
@@ -8,7 +8,7 @@ import {Entity} from "../core/Entity";
import
{
ScillaEvent
}
from
"../core/ScillaEvent"
;
import
{
EngineConfig
}
from
"../engine-config"
;
import
engine
from
"./ScillaEngine"
;
import
{
traverse
}
from
"./
entity-
utils"
;
import
{
traverse
}
from
"./utils"
;
const
defMap
=
{};
let
entityMap
=
{};
...
...
src/core/
entity-
utils.ts
→
src/core/utils.ts
View file @
0a4af8af
...
...
@@ -5,6 +5,7 @@
*/
import
{
Entity
}
from
"./Entity"
;
import
{
Component
}
from
"./Component"
;
/**
* 节点遍历(先序遍历)
...
...
@@ -89,3 +90,24 @@ export function bubbling(target: Entity, hitParent: (parent: Entity, ...params)
}
}
}
export
function
hitTest
(
entity
:
Entity
){
const
transform
=
entity
.
components
[
0
];
const
matrix
=
transform
.
getMatrix
(
true
,
true
,
true
);
matrix
.
transformPoint
(
e
.
x
,
e
.
y
,
this
.
localPos
);
let
result
=
false
;
const
renderers
=
entity
.
getComponents
(
Renderer
);
for
(
let
renderer
of
renderers
)
{
if
(
renderer
.
hitTest
(
this
.
localPos
.
x
,
this
.
localPos
.
y
))
{
if
(
!
renderer
[
'isUsedToMask'
])
{
result
=
true
;
break
}
}
else
if
(
renderer
[
'isUsedToMask'
])
{
return
false
}
}
return
result
;
}
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