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
16f854c7
Commit
16f854c7
authored
Jun 24, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复onUpdate时间戳是负数的问题
修复了Engine.stop()方法
parent
0a4af8af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
30 deletions
+39
-30
rollup.config.js
rollup.config.js
+5
-0
ScillaEngine.ts
src/core/ScillaEngine.ts
+34
-9
utils.ts
src/core/utils.ts
+0
-21
No files found.
rollup.config.js
View file @
16f854c7
...
...
@@ -20,6 +20,11 @@ export default {
file
:
`dist/index.es.js`
,
format
:
'es'
,
},
{
file
:
`dist/scilla.js`
,
format
:
'umd'
,
name
,
},
{
file
:
`dist/index.js`
,
format
:
'umd'
,
...
...
src/core/ScillaEngine.ts
View file @
16f854c7
...
...
@@ -12,6 +12,7 @@ import './requestAnimationFrame';
import
{
AssetsManager
}
from
"../assets-manager"
;
import
{
traverse
,
traversePostorder
}
from
"./utils"
;
import
DataCenter
from
"../support/DataCenter"
;
import
{
getDefByName
}
from
"./interpreter"
;
/**
* 引擎类
...
...
@@ -44,6 +45,7 @@ export class ScillaEngine {
private
tsStart
;
private
tsLast
;
private
lastFPS
=
0
;
private
tickId
;
private
_renderContext
:
RenderContext
;
private
_interactContext
:
InteractContext
;
...
...
@@ -109,7 +111,7 @@ export class ScillaEngine {
start
()
{
this
.
_root
.
enabled
=
true
;
this
.
tsStart
=
Date
.
now
()
;
this
.
tsStart
=
-
1
;
this
.
startTick
();
}
...
...
@@ -215,14 +217,14 @@ export class ScillaEngine {
this
.
_flush
=
0
;
}
requestAnimationFrame
(
this
.
flush
);
this
.
tickId
=
requestAnimationFrame
(
this
.
flush
);
}
/**
* 停止时钟
*/
private
stopTick
()
{
cancelAnimationFrame
(
this
.
tickId
);
}
/**
...
...
@@ -240,7 +242,7 @@ export class ScillaEngine {
}
}
requestAnimationFrame
(
this
.
flush
);
this
.
tickId
=
requestAnimationFrame
(
this
.
flush
);
}
/**
...
...
@@ -253,8 +255,11 @@ export class ScillaEngine {
}
private
onFrameTick
(
tsNow
)
{
if
(
this
.
tsStart
<
0
){
this
.
tsStart
=
tsNow
;
}
this
.
_renderContext
.
clear
();
const
tsNow2
=
Date
.
now
();
this
.
lastFPS
=
Math
.
floor
(
1000
/
(
tsNow
-
this
.
tsLast
));
this
.
tsLast
=
tsNow
;
const
ts
=
tsNow
-
this
.
tsStart
;
...
...
@@ -267,7 +272,6 @@ export class ScillaEngine {
},
-
1
,
true
,
function
(
current
)
{
current
.
afterUpdate
();
});
//const tsPass = Date.now() - tsNow;
for
(
let
i
=
0
,
li
=
this
.
nextTicks
.
length
;
i
<
li
;
i
++
)
{
const
item
=
this
.
nextTicks
[
i
];
...
...
@@ -315,11 +319,32 @@ export class ScillaEngine {
/**
* 射线测试获取实体
* 注:暂时只用在编辑器内
*/
getEntitiesByRayTest
(
x
,
y
)
{
getEntitiesByRayTest
(
x
,
y
,
ignoreMask
=
true
)
{
const
entities
=
[];
const
localPos
:
any
=
{};
let
rendererDef
=
getDefByName
(
'components/renderer/Renderer'
);
traversePostorder
(
this
.
_root
,
function
(
child
)
{
return
child
.
onInteract
(
2
,
event
);
})
const
transform
=
child
.
components
[
0
];
const
matrix
=
transform
[
'getMatrix'
](
true
,
true
,
true
);
matrix
.
transformPoint
(
x
,
y
,
localPos
);
const
renderers
=
child
.
getComponents
(
rendererDef
);
let
result
=
false
;
for
(
let
renderer
of
renderers
)
{
if
((
ignoreMask
||
!
renderer
[
'isUsedToMask'
])
&&
renderer
[
'hitTest'
](
localPos
.
x
,
localPos
.
y
))
{
result
=
true
;
break
}
}
if
(
result
)
{
entities
.
push
(
child
);
}
return
false
;
});
return
entities
;
}
/**
...
...
src/core/utils.ts
View file @
16f854c7
...
...
@@ -90,24 +90,3 @@ 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