Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
renderingEngine
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
王剑峰
renderingEngine
Commits
03035a71
Commit
03035a71
authored
Dec 26, 2019
by
rockyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交一下
parent
f70709ec
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1088 additions
and
503 deletions
+1088
-503
engine.js
debug/engine.js
+696
-347
engine.js.map
debug/engine.js.map
+1
-1
renderingengine.iml
renderingengine.iml
+3
-1
Container.ts
src/2d/display/Container.ts
+61
-1
Sprite.ts
src/2d/display/Sprite.ts
+26
-25
TextField.ts
src/2d/text/TextField.ts
+100
-25
index.ts
src/2d/utils/index.ts
+1
-1
index.ts
src/index.ts
+2
-0
Process.ts
src/zeroing/behavior-runtime/Process.ts
+1
-2
scripts.ts
src/zeroing/decorators/scripts.ts
+1
-1
GameStage.ts
src/zeroing/game-warpper/GameStage.ts
+8
-9
LoadingView.ts
src/zeroing/game-warpper/LoadingView.ts
+38
-0
assets-manager.ts
src/zeroing/game-warpper/assets-manager.ts
+23
-8
data-center.ts
src/zeroing/game-warpper/data-center.ts
+12
-3
TextInput.ts
src/zeroing/game-warpper/nodes/TextInput.ts
+47
-39
sound.ts
src/zeroing/game-warpper/sound.ts
+34
-10
index.ts
src/zeroing/index.ts
+3
-2
launcher.ts
src/zeroing/launcher.ts
+24
-7
node-utils.ts
src/zeroing/node-utils.ts
+0
-18
utils.ts
src/zeroing/utils/utils.ts
+7
-3
No files found.
debug/engine.js
View file @
03035a71
...
@@ -1798,13 +1798,16 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -1798,13 +1798,16 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
return
arr
.
join
(
'&'
);
return
arr
.
join
(
'&'
);
}
}
function
requireForCJS
(
id
)
{
return
window
[
id
];
}
function
importCJSCode
(
code
,
node
)
{
function
importCJSCode
(
code
,
node
)
{
if
(
node
)
{
if
(
node
)
{
var
create
=
new
Function
(
'module'
,
code
);
var
create
=
new
Function
(
'module'
,
'require'
,
code
);
var
module
=
{
var
module
=
{
exports
:
{},
exports
:
{},
};
};
create
(
module
);
create
(
module
,
requireForCJS
);
return
module
.
exports
;
return
module
.
exports
;
}
}
else
{
else
{
...
@@ -1912,7 +1915,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -1912,7 +1915,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
function
instantiateScript
(
node
,
ScriptConfig
)
{
function
instantiateScript
(
node
,
ScriptConfig
)
{
var
scriptName
=
ScriptConfig
.
script
,
props
=
ScriptConfig
.
props
,
disabled
=
ScriptConfig
.
disabled
;
var
scriptName
=
ScriptConfig
.
script
,
props
=
ScriptConfig
.
props
,
disabled
=
ScriptConfig
.
disabled
;
var
script
=
node
.
scripts
Proxy
.
add
(
scriptName
,
props
,
disabled
);
var
script
=
node
.
scripts
.
add
(
scriptName
,
props
,
disabled
);
}
}
function
injectProperties
(
target
,
source
)
{
function
injectProperties
(
target
,
source
)
{
for
(
var
key
in
source
)
{
for
(
var
key
in
source
)
{
...
@@ -2114,7 +2117,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2114,7 +2117,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
scriptDefs
=
{};
var
scriptDefs
=
{};
function
applyScript
(
ctor
)
{
function
applyScript
(
ctor
)
{
ctor
.
prototype
.
applyScripts
=
function
()
{
ctor
.
prototype
.
applyScripts
=
function
()
{
var
scriptsProxy
=
this
.
scripts
Proxy
=
new
ScriptsProxy
(
this
);
var
scriptsProxy
=
this
.
scripts
=
new
ScriptsProxy
(
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
scriptsProxy
.
onRemovedFromStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
REMOVED_FROM_STAGE
,
scriptsProxy
.
onRemovedFromStage
,
scriptsProxy
);
...
@@ -2252,21 +2255,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2252,21 +2255,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
ScriptsProxy
;
return
ScriptsProxy
;
}());
}());
function
findNodeByUUID
(
node
,
uuid
)
{
if
(
node
.
uuid
===
uuid
)
{
return
node
;
}
if
(
node
.
children
&&
node
.
children
.
length
>
0
)
{
for
(
var
_i
=
0
,
_a
=
node
.
children
;
_i
<
_a
.
length
;
_i
++
)
{
var
child
=
_a
[
_i
];
var
target
=
findNodeByUUID
(
child
,
uuid
);
if
(
target
)
{
return
target
;
}
}
}
}
var
DataCenter
=
(
function
(
_super
)
{
var
DataCenter
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
DataCenter
,
_super
);
tslib_1
.
__extends
(
DataCenter
,
_super
);
function
DataCenter
()
{
function
DataCenter
()
{
...
@@ -2276,7 +2264,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2276,7 +2264,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
_this
;
return
_this
;
}
}
DataCenter
.
prototype
.
registerGroup
=
function
(
name
,
origin
)
{
DataCenter
.
prototype
.
registerGroup
=
function
(
name
,
origin
)
{
return
this
.
store
[
name
]
=
origin
||
{}
;
return
this
.
store
[
name
]
=
origin
===
undefined
?
{}
:
origin
;
};
};
DataCenter
.
prototype
.
unregisterGroup
=
function
(
name
)
{
DataCenter
.
prototype
.
unregisterGroup
=
function
(
name
)
{
delete
this
.
store
[
name
];
delete
this
.
store
[
name
];
...
@@ -2285,7 +2273,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2285,7 +2273,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
this
.
store
[
name
];
return
this
.
store
[
name
];
};
};
DataCenter
.
prototype
.
getDataByPath
=
function
(
path
,
groupName
,
throwException
)
{
DataCenter
.
prototype
.
getDataByPath
=
function
(
path
,
groupName
,
throwException
)
{
var
scope
=
groupName
===
undefined
?
this
.
store
:
this
.
getGroup
(
groupName
)
||
this
.
store
;
var
scope
;
if
(
groupName
===
undefined
)
{
scope
=
this
.
store
;
}
else
{
var
group
=
this
.
getGroup
(
groupName
);
scope
=
group
===
undefined
?
this
.
store
:
group
;
}
return
getDataByPath
(
scope
,
path
,
throwException
);
return
getDataByPath
(
scope
,
path
,
throwException
);
};
};
DataCenter
.
prototype
.
getDataByName
=
function
(
name
,
throwException
)
{
DataCenter
.
prototype
.
getDataByName
=
function
(
name
,
throwException
)
{
...
@@ -2332,6 +2327,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2332,6 +2327,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
};
DataCenter
.
prototype
.
mutate
=
function
(
groupName
,
data
,
path
,
dispatch
)
{
DataCenter
.
prototype
.
mutate
=
function
(
groupName
,
data
,
path
,
dispatch
)
{
if
(
dispatch
===
void
0
)
{
dispatch
=
true
;
}
if
(
dispatch
===
void
0
)
{
dispatch
=
true
;
}
if
(
!
groupName
)
{
return
;
}
var
group
=
this
.
getGroup
(
groupName
);
var
group
=
this
.
getGroup
(
groupName
);
if
(
!
group
)
{
if
(
!
group
)
{
group
=
this
.
registerGroup
(
groupName
);
group
=
this
.
registerGroup
(
groupName
);
...
@@ -2660,7 +2658,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -2660,7 +2658,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
else
if
(
value
&&
value
.
indexOf
&&
value
.
indexOf
(
nodeScheme
)
===
0
)
{
else
if
(
value
&&
value
.
indexOf
&&
value
.
indexOf
(
nodeScheme
)
===
0
)
{
var
uuid
=
value
.
replace
(
nodeScheme
,
''
);
var
uuid
=
value
.
replace
(
nodeScheme
,
''
);
if
(
uuid
)
{
if
(
uuid
)
{
props
[
key
]
=
findNodeByUUID
(
this
.
_vm
.
globalContext
.
gameStage
,
uuid
);
props
[
key
]
=
this
.
_vm
.
globalContext
.
gameStage
.
findChildByUUID
(
uuid
);
}
}
}
}
else
if
(
originProps
[
key
]
!==
undefined
)
{
else
if
(
originProps
[
key
]
!==
undefined
)
{
...
@@ -3011,6 +3009,44 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -3011,6 +3009,44 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
return
this
.
children
[
index
];
return
this
.
children
[
index
];
};
};
Container
.
prototype
.
getChildByPath
=
function
(
path
,
method
)
{
if
(
!
path
)
{
return
null
;
}
var
p
=
this
;
while
(
path
.
length
>
0
)
{
var
segment
=
path
.
shift
();
p
=
p
[
method
](
segment
);
if
(
!
p
)
{
break
;
}
}
return
p
;
};
Container
.
prototype
.
getChildByNamePath
=
function
(
path
)
{
var
pathArr
=
path
.
split
(
'/'
);
return
this
.
getChildByPath
(
pathArr
,
'getChildByName'
);
};
Container
.
prototype
.
getChildByIndexPath
=
function
(
path
)
{
var
pathArr
=
path
.
split
(
'/'
).
map
(
function
(
seg
)
{
return
parseInt
(
seg
);
});
return
this
.
getChildByPath
(
pathArr
,
'getChildAt'
);
};
Container
.
prototype
.
findChildByUUID
=
function
(
uuid
)
{
if
(
this
[
'uuid'
]
===
uuid
)
{
return
this
;
}
if
(
this
.
children
&&
this
.
children
.
length
>
0
)
{
for
(
var
_i
=
0
,
_a
=
this
.
children
;
_i
<
_a
.
length
;
_i
++
)
{
var
child
=
_a
[
_i
];
if
(
child
.
findChildByUUID
)
{
var
target
=
child
.
findChildByUUID
(
uuid
);
if
(
target
)
{
return
target
;
}
}
}
}
};
Container
.
prototype
.
getChildByName
=
function
(
name
,
isOnlyOne
,
isRecursive
)
{
Container
.
prototype
.
getChildByName
=
function
(
name
,
isOnlyOne
,
isRecursive
)
{
if
(
isOnlyOne
===
void
0
)
{
isOnlyOne
=
true
;
}
if
(
isOnlyOne
===
void
0
)
{
isOnlyOne
=
true
;
}
if
(
isRecursive
===
void
0
)
{
isRecursive
=
false
;
}
if
(
isRecursive
===
void
0
)
{
isRecursive
=
false
;
}
...
@@ -4221,199 +4257,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -4221,199 +4257,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
_dRender
.
htmlElement
.
toDataURL
(
"image/"
+
typeInfo
.
type
,
typeInfo
.
quality
);
return
_dRender
.
htmlElement
.
toDataURL
(
"image/"
+
typeInfo
.
type
,
typeInfo
.
quality
);
}
}
var
nextUid
=
0
;
function
uid
()
{
return
++
nextUid
;
}
var
backupCanvas
=
document
.
createElement
(
"canvas"
);
function
getGradientColor
(
points
,
colors
)
{
var
colorObj
;
var
ctx
=
backupCanvas
.
getContext
(
"2d"
);
if
(
points
.
length
==
4
)
{
colorObj
=
ctx
.
createLinearGradient
(
points
[
0
],
points
[
1
],
points
[
2
],
points
[
3
]);
}
else
{
colorObj
=
ctx
.
createRadialGradient
(
points
[
0
],
points
[
1
],
0
,
points
[
2
],
points
[
3
],
points
[
4
]);
}
for
(
var
i
=
0
,
l
=
colors
.
length
;
i
<
l
;
i
++
)
{
colorObj
.
addColorStop
(
colors
[
i
][
0
],
getRGBA
(
colors
[
i
][
1
],
colors
[
i
][
2
]));
}
return
colorObj
;
}
function
getCanvasBitmapStyle
(
image
)
{
var
ctx
=
backupCanvas
.
getContext
(
"2d"
);
return
ctx
.
createPattern
(
image
,
"repeat"
);
}
function
hex2rgb
(
hex
,
out
)
{
out
=
out
||
[];
out
[
0
]
=
((
hex
>>
16
)
&
0xFF
)
/
255
;
out
[
1
]
=
((
hex
>>
8
)
&
0xFF
)
/
255
;
out
[
2
]
=
(
hex
&
0xFF
)
/
255
;
return
out
;
}
function
hex2string
(
hex
)
{
hex
=
hex
.
toString
(
16
);
hex
=
'000000'
.
substr
(
0
,
6
-
hex
.
length
)
+
hex
;
return
"#"
+
hex
;
}
function
string2hex
(
string
)
{
if
(
string
.
indexOf
(
"#"
)
==
0
)
{
string
=
string
.
replace
(
"#"
,
"0x"
);
}
return
parseInt
(
string
);
}
function
getRGBA
(
color
,
alpha
)
{
if
(
color
.
indexOf
(
"0x"
)
==
0
)
{
color
=
color
.
replace
(
"0x"
,
"#"
);
}
if
(
color
.
length
<
7
)
{
color
=
"#000000"
;
}
if
(
alpha
!=
1
)
{
var
r
=
parseInt
(
"0x"
+
color
.
substr
(
1
,
2
));
var
g
=
parseInt
(
"0x"
+
color
.
substr
(
3
,
2
));
var
b
=
parseInt
(
"0x"
+
color
.
substr
(
5
,
2
));
color
=
"rgba("
+
r
+
","
+
g
+
","
+
b
+
","
+
alpha
+
")"
;
}
return
color
;
}
function
inputFeildIosEnable
()
{
var
u
=
navigator
.
userAgent
,
app
=
navigator
.
appVersion
;
var
isIOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
if
(
isIOS
)
{
setTimeout
(
function
()
{
window
[
"$"
](
"input"
).
blur
(
function
()
{
if
(
isIOS
)
{
blurAdjust
();
}
});
},
50
);
}
function
blurAdjust
()
{
setTimeout
(
function
()
{
if
(
document
.
activeElement
.
tagName
==
'INPUT'
||
document
.
activeElement
.
tagName
==
'TEXTAREA'
)
{
return
;
}
var
result
=
'pc'
;
if
(
/
(
iPhone|iPad|iPod|iOS
)
/i
.
test
(
navigator
.
userAgent
))
{
result
=
'ios'
;
}
else
if
(
/
(
Android
)
/i
.
test
(
navigator
.
userAgent
))
{
result
=
'android'
;
}
if
(
result
=
'ios'
)
{
document
.
activeElement
[
"scrollIntoViewIfNeeded"
](
true
);
}
},
100
);
}
}
function
decomposeDataUri
(
dataUri
)
{
var
dataUriMatch
=
DATA_URI
.
exec
(
dataUri
);
if
(
dataUriMatch
)
{
return
{
mediaType
:
dataUriMatch
[
1
]
?
dataUriMatch
[
1
].
toLowerCase
()
:
undefined
,
subType
:
dataUriMatch
[
2
]
?
dataUriMatch
[
2
].
toLowerCase
()
:
undefined
,
charset
:
dataUriMatch
[
3
]
?
dataUriMatch
[
3
].
toLowerCase
()
:
undefined
,
encoding
:
dataUriMatch
[
4
]
?
dataUriMatch
[
4
].
toLowerCase
()
:
undefined
,
data
:
dataUriMatch
[
5
],
};
}
return
undefined
;
}
function
getUrlFileExtension
(
url
)
{
var
extension
=
URL_FILE_EXTENSION
.
exec
(
url
);
if
(
extension
)
{
return
extension
[
1
].
toLowerCase
();
}
return
undefined
;
}
function
sign
(
n
)
{
if
(
n
===
0
)
return
0
;
return
n
<
0
?
-
1
:
1
;
}
function
premultiplyTint
(
tint
,
alpha
)
{
if
(
alpha
===
1.0
)
{
return
(
alpha
*
255
<<
24
)
+
tint
;
}
if
(
alpha
===
0.0
)
{
return
0
;
}
var
R
=
((
tint
>>
16
)
&
0xFF
);
var
G
=
((
tint
>>
8
)
&
0xFF
);
var
B
=
(
tint
&
0xFF
);
R
=
((
R
*
alpha
)
+
0.5
)
|
0
;
G
=
((
G
*
alpha
)
+
0.5
)
|
0
;
B
=
((
B
*
alpha
)
+
0.5
)
|
0
;
return
(
alpha
*
255
<<
24
)
+
(
R
<<
16
)
+
(
G
<<
8
)
+
B
;
}
var
TextureCache
=
Object
.
create
(
null
);
var
BaseTextureCache
=
Object
.
create
(
null
);
var
GlobalPro
=
{
stageRenderType
:
exports
.
RENDERER_TYPE
.
WEBGL
,
dpi
:
1
,
padding
:
2
,
startTime
:
0
};
function
isWebGLSupported
()
{
var
contextOptions
=
{
stencil
:
true
,
failIfMajorPerformanceCaveat
:
true
};
try
{
if
(
!
window
[
"WebGLRenderingContext"
])
{
return
false
;
}
var
canvas
=
document
.
createElement
(
'canvas'
);
var
gl
=
canvas
.
getContext
(
'webgl'
,
contextOptions
)
||
canvas
.
getContext
(
'experimental-webgl'
,
contextOptions
);
var
success
=
!!
(
gl
&&
gl
[
"getContextAttributes"
]().
stencil
);
if
(
gl
)
{
var
loseContext
=
gl
[
"getExtension"
](
'WEBGL_lose_context'
);
if
(
loseContext
)
{
loseContext
.
loseContext
();
}
}
gl
=
null
;
return
success
;
}
catch
(
e
)
{
return
false
;
}
}
function
removeItems
(
arr
,
startIdx
,
removeCount
)
{
var
i
,
length
=
arr
.
length
;
if
(
startIdx
>=
length
||
removeCount
===
0
)
{
return
;
}
removeCount
=
(
startIdx
+
removeCount
>
length
?
length
-
startIdx
:
removeCount
);
var
len
=
length
-
removeCount
;
for
(
i
=
startIdx
;
i
<
len
;
++
i
)
{
arr
[
i
]
=
arr
[
i
+
removeCount
];
}
arr
.
length
=
len
;
}
function
mapWebGLBlendModesToPixi
(
gl
,
array
)
{
if
(
array
===
void
0
)
{
array
=
[];
}
array
[
exports
.
BLEND_MODES
.
NORMAL
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
ADD
]
=
[
gl
.
ONE
,
gl
.
DST_ALPHA
];
array
[
exports
.
BLEND_MODES
.
MULTIPLY
]
=
[
gl
.
DST_COLOR
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SCREEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_COLOR
];
array
[
exports
.
BLEND_MODES
.
OVERLAY
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
DARKEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
LIGHTEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR_DODGE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR_BURN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
HARD_LIGHT
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SOFT_LIGHT
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
DIFFERENCE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
EXCLUSION
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
HUE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SATURATION
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
LUMINOSITY
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
NORMAL_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
ONE_MINUS_SRC_ALPHA
,
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
ADD_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
DST_ALPHA
,
gl
.
ONE
,
gl
.
DST_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SCREEN_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
ONE_MINUS_SRC_COLOR
,
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_COLOR
];
return
array
;
}
var
BaseTexture
=
(
function
(
_super
)
{
var
BaseTexture
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
BaseTexture
,
_super
);
tslib_1
.
__extends
(
BaseTexture
,
_super
);
function
BaseTexture
(
source
,
scaleMode
)
{
function
BaseTexture
(
source
,
scaleMode
)
{
...
@@ -4901,44 +4744,376 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -4901,44 +4744,376 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
textureFromCache
;
return
textureFromCache
;
}
}
}
}
else
if
(
texture
&&
texture
.
textureCacheIds
)
{
else
if
(
texture
&&
texture
.
textureCacheIds
)
{
for
(
var
i
=
0
;
i
<
texture
.
textureCacheIds
.
length
;
++
i
)
{
for
(
var
i
=
0
;
i
<
texture
.
textureCacheIds
.
length
;
++
i
)
{
if
(
TextureCache
[
texture
.
textureCacheIds
[
i
]]
===
texture
)
{
if
(
TextureCache
[
texture
.
textureCacheIds
[
i
]]
===
texture
)
{
delete
TextureCache
[
texture
.
textureCacheIds
[
i
]];
delete
TextureCache
[
texture
.
textureCacheIds
[
i
]];
}
}
}
texture
.
textureCacheIds
.
length
=
0
;
return
texture
;
}
return
null
;
};
return
Texture
;
}(
EventDispatcher
));
function
createWhiteTexture
()
{
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
16
;
canvas
.
height
=
16
;
var
context
=
canvas
.
getContext
(
'2d'
);
context
.
fillStyle
=
'white'
;
context
.
fillRect
(
0
,
0
,
16
,
16
);
return
new
Texture
(
new
BaseTexture
(
canvas
));
}
function
removeAllHandlers
(
tex
)
{
tex
.
destroy
=
function
_emptyDestroy
()
{
};
tex
.
addEventListener
=
function
_emptyOn
()
{
};
tex
.
once
=
function
_emptyOnce
()
{
};
tex
.
dispatchEvent
=
function
_emptyEmit
()
{
};
}
Texture
.
EMPTY
=
new
Texture
(
new
BaseTexture
());
removeAllHandlers
(
Texture
.
EMPTY
);
removeAllHandlers
(
Texture
.
EMPTY
.
baseTexture
);
Texture
.
WHITE
=
createWhiteTexture
();
removeAllHandlers
(
Texture
.
WHITE
);
removeAllHandlers
(
Texture
.
WHITE
.
baseTexture
);
var
padding
=
2
;
function
DrawAllToCanvas
(
images
,
callback
)
{
var
textures
=
{};
var
imagesAll
=
[];
var
countAll
=
Object
.
getOwnPropertyNames
(
images
).
length
;
preLoad
(
images
,
function
(
img
)
{
imagesAll
.
push
(
img
);
if
(
imagesAll
.
length
==
countAll
)
{
imagesAll
.
sort
(
compare
(
'width'
,
'height'
));
while
(
imagesAll
.
length
)
{
putInCanvas
(
imagesAll
,
textures
);
}
callback
(
textures
);
}
});
}
function
preLoad
(
images
,
callback
)
{
var
_loop_1
=
function
()
{
bitmap
=
images
[
key
];
if
(
typeof
(
bitmap
)
==
'string'
)
{
var
imgTag_1
=
new
Image
();
if
(
bitmap
.
indexOf
(
"iVBO"
)
===
0
||
bitmap
.
indexOf
(
"/9j/2w"
)
===
0
)
{
imgTag_1
.
src
=
'data:image/png;base64,'
+
bitmap
;
}
else
{
imgTag_1
.
src
=
bitmap
;
}
imgTag_1
[
"imageKey"
]
=
key
;
imgTag_1
.
onload
=
function
()
{
callback
(
imgTag_1
);
};
}
else
if
(
bitmap
instanceof
HTMLImageElement
)
{
bitmap
[
"imageKey"
]
=
key
;
if
(
bitmap
.
complete
&&
bitmap
.
width
&&
bitmap
.
height
)
{
callback
(
bitmap
);
}
else
{
bitmap
.
onload
=
function
()
{
callback
(
bitmap
);
};
}
}
else
if
(
bitmap
instanceof
HTMLCanvasElement
)
{
callback
(
bitmap
);
}
};
var
bitmap
;
for
(
var
key
in
images
)
{
_loop_1
();
}
}
function
compare
(
name1
,
name2
)
{
return
function
(
a
,
b
)
{
var
fir1
=
a
[
name1
];
var
sec1
=
b
[
name1
];
if
(
fir1
===
sec1
)
{
var
fir2
=
a
[
name2
];
var
sec2
=
b
[
name2
];
if
(
fir2
===
sec2
)
{
return
0
;
}
else
{
return
fir2
>
sec2
?
1
:
-
1
;
}
}
else
{
return
fir1
>
sec1
?
1
:
-
1
;
}
};
}
function
putInCanvas
(
imagesAll
,
textures
)
{
var
freeRects
=
[];
var
imageInfos
=
[];
var
canvas
=
document
.
createElement
(
'canvas'
);
canvas
.
width
=
4096
;
canvas
.
height
=
4096
;
freeRects
.
push
(
new
Rectangle
(
0
,
0
,
4096
,
4096
));
var
canvasWidth
=
0
,
canvasHeight
=
0
;
var
match
=
false
;
for
(
var
i
=
imagesAll
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
img
=
imagesAll
[
i
];
match
=
false
;
for
(
var
j
=
freeRects
.
length
-
1
;
j
>=
0
;
j
--
)
{
var
freeRect
=
freeRects
[
j
];
if
(
freeRect
.
width
>=
img
.
width
+
padding
*
2
&&
freeRect
.
height
>=
img
.
height
+
padding
*
2
)
{
match
=
true
;
var
imageIn
=
new
imageInfo
(
img
,
freeRect
.
x
+
padding
,
freeRect
.
y
+
padding
);
imageInfos
.
push
(
imageIn
);
imagesAll
.
splice
(
i
,
1
);
freeRects
.
splice
(
j
,
1
);
var
restW
=
freeRect
.
width
-
img
.
width
-
padding
;
if
(
restW
>
0
)
{
var
rightRect
=
new
Rectangle
(
freeRect
.
x
+
img
.
width
+
padding
,
freeRect
.
y
,
restW
,
img
.
height
+
padding
);
freeRect
.
y
==
0
?
freeRects
.
unshift
(
rightRect
)
:
freeRects
.
push
(
rightRect
);
}
var
restH
=
freeRect
.
height
-
img
.
height
-
padding
;
if
(
restH
>
0
)
{
var
downRect
=
new
Rectangle
(
freeRect
.
x
,
freeRect
.
y
+
img
.
height
+
padding
,
freeRect
.
width
,
restH
);
freeRect
.
x
==
0
?
freeRects
.
unshift
(
downRect
)
:
freeRects
.
push
(
downRect
);
}
if
(
imageIn
.
image
.
width
+
imageIn
.
x
>
canvasWidth
)
{
canvasWidth
=
imageIn
.
image
.
width
+
imageIn
.
x
;
}
if
(
imageIn
.
image
.
height
+
imageIn
.
y
>
canvasHeight
)
{
canvasHeight
=
imageIn
.
image
.
height
+
imageIn
.
y
;
}
break
;
}
}
if
(
!
match
)
break
;
}
canvas
.
width
=
nextPow2
(
canvasWidth
+
padding
);
canvas
.
height
=
nextPow2
(
canvasHeight
+
padding
);
var
ctx
=
canvas
.
getContext
(
"2d"
);
for
(
var
m
=
0
;
m
<
imageInfos
.
length
;
m
++
)
{
var
imageInfo_1
=
imageInfos
[
m
];
var
image
=
imageInfo_1
.
image
;
ctx
.
drawImage
(
imageInfo_1
.
image
,
0
,
0
,
image
.
width
,
image
.
height
,
imageInfo_1
.
x
,
imageInfo_1
.
y
,
image
.
width
,
image
.
height
);
}
var
baseTexture
=
new
BaseTexture
(
canvas
);
for
(
var
n
=
0
;
n
<
imageInfos
.
length
;
n
++
)
{
var
imageInfo_2
=
imageInfos
[
n
];
var
image
=
imageInfo_2
.
image
;
textures
[
image
.
imageKey
]
=
new
Texture
(
baseTexture
,
new
Rectangle
(
imageInfo_2
.
x
,
imageInfo_2
.
y
,
image
.
width
,
image
.
height
),
new
Rectangle
(
0
,
0
,
image
.
width
,
image
.
height
),
null
);
}
}
var
imageInfo
=
(
function
()
{
function
imageInfo
(
image
,
x
,
y
)
{
if
(
x
===
void
0
)
{
x
=
0
;
}
if
(
y
===
void
0
)
{
y
=
0
;
}
this
.
image
=
image
;
this
.
x
=
x
;
this
.
y
=
y
;
}
return
imageInfo
;
}());
var
nextUid
=
0
;
function
uid
()
{
return
++
nextUid
;
}
var
backupCanvas
=
document
.
createElement
(
"canvas"
);
function
getGradientColor
(
points
,
colors
)
{
var
colorObj
;
var
ctx
=
backupCanvas
.
getContext
(
"2d"
);
if
(
points
.
length
==
4
)
{
colorObj
=
ctx
.
createLinearGradient
(
points
[
0
],
points
[
1
],
points
[
2
],
points
[
3
]);
}
else
{
colorObj
=
ctx
.
createRadialGradient
(
points
[
0
],
points
[
1
],
0
,
points
[
2
],
points
[
3
],
points
[
4
]);
}
for
(
var
i
=
0
,
l
=
colors
.
length
;
i
<
l
;
i
++
)
{
colorObj
.
addColorStop
(
colors
[
i
][
0
],
getRGBA
(
colors
[
i
][
1
],
colors
[
i
][
2
]));
}
return
colorObj
;
}
function
getCanvasBitmapStyle
(
image
)
{
var
ctx
=
backupCanvas
.
getContext
(
"2d"
);
return
ctx
.
createPattern
(
image
,
"repeat"
);
}
function
hex2rgb
(
hex
,
out
)
{
out
=
out
||
[];
out
[
0
]
=
((
hex
>>
16
)
&
0xFF
)
/
255
;
out
[
1
]
=
((
hex
>>
8
)
&
0xFF
)
/
255
;
out
[
2
]
=
(
hex
&
0xFF
)
/
255
;
return
out
;
}
function
hex2string
(
hex
)
{
hex
=
hex
.
toString
(
16
);
hex
=
'000000'
.
substr
(
0
,
6
-
hex
.
length
)
+
hex
;
return
"#"
+
hex
;
}
function
string2hex
(
string
)
{
if
(
string
.
indexOf
(
"#"
)
==
0
)
{
string
=
string
.
replace
(
"#"
,
"0x"
);
}
return
parseInt
(
string
);
}
function
getRGBA
(
color
,
alpha
)
{
if
(
color
.
indexOf
(
"0x"
)
==
0
)
{
color
=
color
.
replace
(
"0x"
,
"#"
);
}
if
(
color
.
length
<
7
)
{
color
=
"#000000"
;
}
if
(
alpha
!=
1
)
{
var
r
=
parseInt
(
"0x"
+
color
.
substr
(
1
,
2
));
var
g
=
parseInt
(
"0x"
+
color
.
substr
(
3
,
2
));
var
b
=
parseInt
(
"0x"
+
color
.
substr
(
5
,
2
));
color
=
"rgba("
+
r
+
","
+
g
+
","
+
b
+
","
+
alpha
+
")"
;
}
return
color
;
}
function
inputFeildIosEnable
()
{
var
u
=
navigator
.
userAgent
,
app
=
navigator
.
appVersion
;
var
isIOS
=
!!
u
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
);
if
(
isIOS
)
{
setTimeout
(
function
()
{
window
[
"$"
](
"input"
).
blur
(
function
()
{
if
(
isIOS
)
{
blurAdjust
();
}
});
},
50
);
}
function
blurAdjust
()
{
setTimeout
(
function
()
{
if
(
document
.
activeElement
.
tagName
==
'INPUT'
||
document
.
activeElement
.
tagName
==
'TEXTAREA'
)
{
return
;
}
var
result
=
'pc'
;
if
(
/
(
iPhone|iPad|iPod|iOS
)
/i
.
test
(
navigator
.
userAgent
))
{
result
=
'ios'
;
}
else
if
(
/
(
Android
)
/i
.
test
(
navigator
.
userAgent
))
{
result
=
'android'
;
}
if
(
result
=
'ios'
)
{
document
.
activeElement
[
"scrollIntoViewIfNeeded"
](
true
);
}
},
100
);
}
}
function
decomposeDataUri
(
dataUri
)
{
var
dataUriMatch
=
DATA_URI
.
exec
(
dataUri
);
if
(
dataUriMatch
)
{
return
{
mediaType
:
dataUriMatch
[
1
]
?
dataUriMatch
[
1
].
toLowerCase
()
:
undefined
,
subType
:
dataUriMatch
[
2
]
?
dataUriMatch
[
2
].
toLowerCase
()
:
undefined
,
charset
:
dataUriMatch
[
3
]
?
dataUriMatch
[
3
].
toLowerCase
()
:
undefined
,
encoding
:
dataUriMatch
[
4
]
?
dataUriMatch
[
4
].
toLowerCase
()
:
undefined
,
data
:
dataUriMatch
[
5
],
};
}
return
undefined
;
}
function
getUrlFileExtension
(
url
)
{
var
extension
=
URL_FILE_EXTENSION
.
exec
(
url
);
if
(
extension
)
{
return
extension
[
1
].
toLowerCase
();
}
return
undefined
;
}
function
sign
(
n
)
{
if
(
n
===
0
)
return
0
;
return
n
<
0
?
-
1
:
1
;
}
function
premultiplyTint
(
tint
,
alpha
)
{
if
(
alpha
===
1.0
)
{
return
(
alpha
*
255
<<
24
)
+
tint
;
}
if
(
alpha
===
0.0
)
{
return
0
;
}
var
R
=
((
tint
>>
16
)
&
0xFF
);
var
G
=
((
tint
>>
8
)
&
0xFF
);
var
B
=
(
tint
&
0xFF
);
R
=
((
R
*
alpha
)
+
0.5
)
|
0
;
G
=
((
G
*
alpha
)
+
0.5
)
|
0
;
B
=
((
B
*
alpha
)
+
0.5
)
|
0
;
return
(
alpha
*
255
<<
24
)
+
(
R
<<
16
)
+
(
G
<<
8
)
+
B
;
}
var
TextureCache
=
Object
.
create
(
null
);
var
BaseTextureCache
=
Object
.
create
(
null
);
var
GlobalPro
=
{
stageRenderType
:
exports
.
RENDERER_TYPE
.
WEBGL
,
dpi
:
1
,
padding
:
2
,
startTime
:
0
};
function
isWebGLSupported
()
{
var
contextOptions
=
{
stencil
:
true
,
failIfMajorPerformanceCaveat
:
true
};
try
{
if
(
!
window
[
"WebGLRenderingContext"
])
{
return
false
;
}
var
canvas
=
document
.
createElement
(
'canvas'
);
var
gl
=
canvas
.
getContext
(
'webgl'
,
contextOptions
)
||
canvas
.
getContext
(
'experimental-webgl'
,
contextOptions
);
var
success
=
!!
(
gl
&&
gl
[
"getContextAttributes"
]().
stencil
);
if
(
gl
)
{
var
loseContext
=
gl
[
"getExtension"
](
'WEBGL_lose_context'
);
if
(
loseContext
)
{
loseContext
.
loseContext
();
}
}
texture
.
textureCacheIds
.
length
=
0
;
return
texture
;
}
}
return
null
;
gl
=
null
;
};
return
success
;
return
Texture
;
}
}(
EventDispatcher
));
catch
(
e
)
{
function
createWhiteTexture
()
{
return
false
;
var
canvas
=
document
.
createElement
(
'canvas'
);
}
canvas
.
width
=
16
;
canvas
.
height
=
16
;
var
context
=
canvas
.
getContext
(
'2d'
);
context
.
fillStyle
=
'white'
;
context
.
fillRect
(
0
,
0
,
16
,
16
);
return
new
Texture
(
new
BaseTexture
(
canvas
));
}
}
function
removeAllHandlers
(
tex
)
{
function
removeItems
(
arr
,
startIdx
,
removeCount
)
{
tex
.
destroy
=
function
_emptyDestroy
()
{
var
i
,
length
=
arr
.
length
;
};
if
(
startIdx
>=
length
||
removeCount
===
0
)
{
tex
.
addEventListener
=
function
_emptyOn
()
{
return
;
};
}
tex
.
once
=
function
_emptyOnce
()
{
removeCount
=
(
startIdx
+
removeCount
>
length
?
length
-
startIdx
:
removeCount
);
};
var
len
=
length
-
removeCount
;
tex
.
dispatchEvent
=
function
_emptyEmit
()
{
for
(
i
=
startIdx
;
i
<
len
;
++
i
)
{
};
arr
[
i
]
=
arr
[
i
+
removeCount
];
}
arr
.
length
=
len
;
}
function
mapWebGLBlendModesToPixi
(
gl
,
array
)
{
if
(
array
===
void
0
)
{
array
=
[];
}
array
[
exports
.
BLEND_MODES
.
NORMAL
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
ADD
]
=
[
gl
.
ONE
,
gl
.
DST_ALPHA
];
array
[
exports
.
BLEND_MODES
.
MULTIPLY
]
=
[
gl
.
DST_COLOR
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SCREEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_COLOR
];
array
[
exports
.
BLEND_MODES
.
OVERLAY
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
DARKEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
LIGHTEN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR_DODGE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR_BURN
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
HARD_LIGHT
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SOFT_LIGHT
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
DIFFERENCE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
EXCLUSION
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
HUE
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SATURATION
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
COLOR
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
LUMINOSITY
]
=
[
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
NORMAL_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
ONE_MINUS_SRC_ALPHA
,
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_ALPHA
];
array
[
exports
.
BLEND_MODES
.
ADD_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
DST_ALPHA
,
gl
.
ONE
,
gl
.
DST_ALPHA
];
array
[
exports
.
BLEND_MODES
.
SCREEN_NPM
]
=
[
gl
.
SRC_ALPHA
,
gl
.
ONE_MINUS_SRC_COLOR
,
gl
.
ONE
,
gl
.
ONE_MINUS_SRC_COLOR
];
return
array
;
}
}
Texture
.
EMPTY
=
new
Texture
(
new
BaseTexture
());
removeAllHandlers
(
Texture
.
EMPTY
);
removeAllHandlers
(
Texture
.
EMPTY
.
baseTexture
);
Texture
.
WHITE
=
createWhiteTexture
();
removeAllHandlers
(
Texture
.
WHITE
);
removeAllHandlers
(
Texture
.
WHITE
.
baseTexture
);
var
indices
=
new
Uint16Array
([
0
,
1
,
2
,
0
,
2
,
3
]);
var
indices
=
new
Uint16Array
([
0
,
1
,
2
,
0
,
2
,
3
]);
var
Sprite
=
(
function
(
_super
)
{
var
Sprite
=
(
function
(
_super
)
{
...
@@ -4950,6 +5125,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -4950,6 +5125,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this
.
_texture
=
null
;
_this
.
_texture
=
null
;
_this
.
_width
=
0
;
_this
.
_width
=
0
;
_this
.
_height
=
0
;
_this
.
_height
=
0
;
_this
.
_tint
=
null
;
_this
.
_tintRGB
=
null
;
_this
.
tint
=
0xFFFFFF
;
_this
.
_cachedTint
=
0xFFFFFF
;
_this
.
uvs
=
null
;
_this
.
uvs
=
null
;
_this
.
_onTextureUpdate
=
_this
.
_onTextureUpdate
.
bind
(
_this
);
_this
.
_onTextureUpdate
=
_this
.
_onTextureUpdate
.
bind
(
_this
);
_this
.
texture
=
texture
||
Texture
.
EMPTY
;
_this
.
texture
=
texture
||
Texture
.
EMPTY
;
...
@@ -4967,6 +5146,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -4967,6 +5146,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Sprite
.
prototype
.
_onTextureUpdate
=
function
()
{
Sprite
.
prototype
.
_onTextureUpdate
=
function
()
{
this
.
_textureID
=
-
1
;
this
.
_textureID
=
-
1
;
this
.
_textureTrimmedID
=
-
1
;
this
.
_textureTrimmedID
=
-
1
;
this
.
_cachedTint
=
0xFFFFFF
;
if
(
this
.
_texture
.
valid
)
if
(
this
.
_texture
.
valid
)
this
.
uvs
=
this
.
_texture
.
_uvs
.
uvsFloat32
;
this
.
uvs
=
this
.
_texture
.
_uvs
.
uvsFloat32
;
if
(
this
.
_width
)
{
if
(
this
.
_width
)
{
...
@@ -5159,6 +5339,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -5159,6 +5339,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this
.
_texture
=
value
||
Texture
.
EMPTY
;
this
.
_texture
=
value
||
Texture
.
EMPTY
;
this
.
_textureID
=
-
1
;
this
.
_textureID
=
-
1
;
this
.
_textureTrimmedID
=
-
1
;
this
.
_textureTrimmedID
=
-
1
;
this
.
_cachedTint
=
0xFFFFFF
;
if
(
value
)
{
if
(
value
)
{
if
(
value
.
baseTexture
.
hasLoaded
)
{
if
(
value
.
baseTexture
.
hasLoaded
)
{
this
.
_onTextureUpdate
();
this
.
_onTextureUpdate
();
...
@@ -5171,6 +5352,19 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -5171,6 +5352,19 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
enumerable
:
true
,
enumerable
:
true
,
configurable
:
true
configurable
:
true
});
});
Object
.
defineProperty
(
Sprite
.
prototype
,
"tint"
,
{
get
:
function
()
{
return
this
.
_tint
;
},
set
:
function
(
value
)
{
if
(
value
===
this
.
_tint
)
return
;
this
.
_tint
=
value
;
this
.
_tintRGB
=
(
value
>>
16
)
+
(
value
&
0xff00
)
+
((
value
&
0xff
)
<<
16
);
},
enumerable
:
true
,
configurable
:
true
});
Sprite
.
from
=
function
(
source
)
{
Sprite
.
from
=
function
(
source
)
{
return
new
Sprite
(
Texture
.
from
(
source
));
return
new
Sprite
(
Texture
.
from
(
source
));
};
};
...
@@ -10548,7 +10742,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10548,7 +10742,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}(
EventDispatcher
));
}(
EventDispatcher
));
var
globalLoader
=
new
Loader
();
var
globalLoader
=
new
Loader
();
var
padding
=
10
;
var
padding
$1
=
10
;
var
TextField
=
(
function
(
_super
)
{
var
TextField
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
TextField
,
_super
);
tslib_1
.
__extends
(
TextField
,
_super
);
function
TextField
()
{
function
TextField
()
{
...
@@ -10559,6 +10753,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10559,6 +10753,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this
.
_lineSpacing
=
14
;
_this
.
_lineSpacing
=
14
;
_this
.
_lineType
=
exports
.
TEXT_lINETYPE
.
SINGLE
;
_this
.
_lineType
=
exports
.
TEXT_lINETYPE
.
SINGLE
;
_this
.
_text
=
""
;
_this
.
_text
=
""
;
_this
.
_pureText
=
''
;
_this
.
_font
=
"Arial"
;
_this
.
_font
=
"Arial"
;
_this
.
_size
=
12
;
_this
.
_size
=
12
;
_this
.
_fillColor
=
"#000"
;
_this
.
_fillColor
=
"#000"
;
...
@@ -10697,6 +10892,53 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10697,6 +10892,53 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this
.
dispatchEvent
(
Event
.
RESIZE
);
this
.
dispatchEvent
(
Event
.
RESIZE
);
}
}
};
};
Object
.
defineProperty
(
TextField
.
prototype
,
"textFlow"
,
{
get
:
function
()
{
return
this
.
_textFlow
;
},
set
:
function
(
value
)
{
this
.
_textFlow
=
value
;
this
.
dirty
=
true
;
var
text
=
''
;
for
(
var
_i
=
0
,
_a
=
this
.
_textFlow
;
_i
<
_a
.
length
;
_i
++
)
{
var
item
=
_a
[
_i
];
text
+=
item
.
text
;
}
this
.
_pureText
=
text
;
},
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
TextField
.
prototype
,
"isPureText"
,
{
get
:
function
()
{
return
!
this
.
_textFlow
||
this
.
_textFlow
.
length
==
0
;
},
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
TextField
.
prototype
,
"pureText"
,
{
get
:
function
()
{
return
this
.
isPureText
?
this
.
_text
:
this
.
_pureText
;
},
enumerable
:
true
,
configurable
:
true
});
TextField
.
prototype
.
getStyle
=
function
(
index
)
{
if
(
!
this
.
textFlow
)
{
return
null
;
}
var
targetItem
;
var
count
=
0
;
for
(
var
_i
=
0
,
_a
=
this
.
_textFlow
;
_i
<
_a
.
length
;
_i
++
)
{
var
item
=
_a
[
_i
];
count
+=
item
.
text
.
length
;
if
(
index
<
count
)
{
targetItem
=
item
;
break
;
}
}
return
targetItem
.
style
;
};
Object
.
defineProperty
(
TextField
.
prototype
,
"font"
,
{
Object
.
defineProperty
(
TextField
.
prototype
,
"font"
,
{
get
:
function
()
{
get
:
function
()
{
return
this
.
_font
;
return
this
.
_font
;
...
@@ -10841,7 +11083,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10841,7 +11083,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
};
TextField
.
prototype
.
updateText
=
function
()
{
TextField
.
prototype
.
updateText
=
function
()
{
var
s
=
this
;
var
s
=
this
;
if
(
!
s
.
_text
)
{
var
text
=
s
.
_pureText
;
if
(
!
text
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
s
.
canvas
.
height
=
0
;
s
.
_localBoundsSelf
.
clear
();
s
.
_localBoundsSelf
.
clear
();
...
@@ -10849,18 +11092,19 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10849,18 +11092,19 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this
.
updateTexture
();
this
.
updateTexture
();
return
;
return
;
}
}
var
measureCache
=
{};
if
(
!
s
.
dirty
)
if
(
!
s
.
dirty
)
return
;
return
;
s
.
dirty
=
false
;
s
.
dirty
=
false
;
s
.
_
text
+=
""
;
text
+=
""
;
var
can
=
s
.
canvas
;
var
can
=
s
.
canvas
;
var
ctx
=
s
.
context
;
var
ctx
=
s
.
context
;
var
hardLines
=
s
.
_
text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
var
hardLines
=
text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
var
realLines
=
[];
var
realLines
=
[];
s
.
realLines
=
realLines
;
s
.
realLines
=
realLines
;
s
.
_prepContext
(
ctx
);
s
.
_prepContext
(
ctx
);
var
textWidth
=
s
.
_width
;
var
textWidth
=
s
.
_width
;
if
(
s
.
_
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
exports
.
TEXT_lINETYPE
.
SINGLE
)
{
if
(
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
exports
.
TEXT_lINETYPE
.
SINGLE
)
{
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
var
str
=
hardLines
[
0
];
var
str
=
hardLines
[
0
];
var
lineW
=
s
.
_getMeasuredWidth
(
str
);
var
lineW
=
s
.
_getMeasuredWidth
(
str
);
...
@@ -10884,7 +11128,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10884,7 +11128,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
}
}
else
{
else
{
var
measureCache
=
{};
var
shouldMeasureTextWidth
=
!
textWidth
;
var
shouldMeasureTextWidth
=
!
textWidth
;
for
(
var
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
for
(
var
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
var
str
=
hardLines
[
i
];
var
str
=
hardLines
[
i
];
...
@@ -10893,10 +11136,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10893,10 +11136,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
lineWidth
=
0
;
var
lineWidth
=
0
;
for
(
var
_i
=
0
,
str_1
=
str
;
_i
<
str_1
.
length
;
_i
++
)
{
for
(
var
_i
=
0
,
str_1
=
str
;
_i
<
str_1
.
length
;
_i
++
)
{
var
char
=
str_1
[
_i
];
var
char
=
str_1
[
_i
];
var
charWidth
=
measureCache
[
char
];
var
charWidth
=
measureChar
(
char
);
if
(
charWidth
===
undefined
)
{
charWidth
=
measureCache
[
char
]
=
s
.
_getMeasuredWidth
(
char
);
}
lineWidth
+=
charWidth
;
lineWidth
+=
charWidth
;
}
}
if
(
shouldMeasureTextWidth
)
{
if
(
shouldMeasureTextWidth
)
{
...
@@ -10936,17 +11176,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10936,17 +11176,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
else
if
(
s
.
_textAlign
==
exports
.
TEXT_ALIGN
.
RIGHT
)
{
else
if
(
s
.
_textAlign
==
exports
.
TEXT_ALIGN
.
RIGHT
)
{
tx
=
maxW
;
tx
=
maxW
;
}
}
can
.
width
=
maxW
+
padding
*
2
;
can
.
width
=
maxW
+
padding
$1
*
2
;
can
.
height
=
maxH
+
padding
*
2
;
can
.
height
=
maxH
+
padding
$1
*
2
;
ctx
.
clearRect
(
0
,
0
,
can
.
width
,
can
.
width
);
ctx
.
clearRect
(
0
,
0
,
can
.
width
,
can
.
width
);
if
(
s
.
border
)
{
if
(
s
.
border
)
{
ctx
.
beginPath
();
ctx
.
beginPath
();
ctx
.
strokeStyle
=
"#000"
;
ctx
.
strokeStyle
=
"#000"
;
ctx
.
lineWidth
=
1
;
ctx
.
lineWidth
=
1
;
ctx
.
strokeRect
(
padding
+
0.5
,
padding
+
0.5
,
maxW
,
maxH
);
ctx
.
strokeRect
(
padding
$1
+
0.5
,
padding$1
+
0.5
,
maxW
,
maxH
);
ctx
.
closePath
();
ctx
.
closePath
();
}
}
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
tx
+
padding
,
padding
);
ctx
.
setTransform
(
1
,
0
,
0
,
1
,
tx
+
padding
$1
,
padding$1
);
s
.
_prepContext
(
ctx
);
s
.
_prepContext
(
ctx
);
var
lineH
=
s
.
_lineSpacing
+
s
.
size
;
var
lineH
=
s
.
_lineSpacing
+
s
.
size
;
var
upY
=
0
;
var
upY
=
0
;
...
@@ -10958,20 +11198,62 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -10958,20 +11198,62 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
upY
=
s
.
_height
-
trueHeight
;
upY
=
s
.
_height
-
trueHeight
;
}
}
}
}
var
index
=
0
;
for
(
var
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
if
(
s
.
stroke
)
{
var
line
=
realLines
[
i
];
ctx
.
strokeStyle
=
s
.
strokeColor
;
if
(
s
.
isPureText
)
{
ctx
.
lineWidth
=
s
.
stroke
*
2
;
var
y
=
upY
+
i
*
lineH
;
ctx
.
strokeText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
if
(
s
.
stroke
)
{
ctx
.
strokeStyle
=
s
.
strokeColor
;
ctx
.
lineWidth
=
s
.
stroke
*
2
;
ctx
.
strokeText
(
line
,
0
,
y
,
maxW
);
}
ctx
.
fillText
(
line
,
0
,
y
,
maxW
);
}
else
{
var
x
=
0
;
for
(
var
j
=
0
,
lj
=
line
.
length
;
j
<
lj
;
j
++
)
{
var
char
=
line
[
j
];
var
style
=
s
.
getStyle
(
index
);
if
(
style
)
{
if
(
style
.
hasOwnProperty
(
'color'
))
{
ctx
.
fillStyle
=
style
.
color
;
}
if
(
style
.
hasOwnProperty
(
'stroke'
))
{
ctx
.
lineWidth
=
style
.
stroke
*
2
;
}
if
(
style
.
hasOwnProperty
(
'strokeColor'
))
{
ctx
.
strokeStyle
=
style
.
strokeColor
;
}
}
else
{
ctx
.
fillStyle
=
s
.
fillColor
;
ctx
.
lineWidth
=
s
.
stroke
;
ctx
.
strokeStyle
=
s
.
strokeColor
;
}
var
y
=
upY
+
i
*
lineH
;
if
(
ctx
.
lineWidth
>
0
)
{
ctx
.
strokeText
(
char
,
x
,
y
);
}
ctx
.
fillText
(
char
,
x
,
y
);
x
+=
measureChar
(
char
);
index
++
;
}
}
}
ctx
.
fillText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
}
}
s
.
offsetX
=
-
padding
;
s
.
offsetX
=
-
padding
$1
;
s
.
offsetY
=
-
padding
;
s
.
offsetY
=
-
padding
$1
;
this
.
anchorTexture
=
{
x
:
(
padding
+
0.5
)
/
can
.
width
,
y
:
padding
/
can
.
height
};
this
.
anchorTexture
=
{
x
:
(
padding
$1
+
0.5
)
/
can
.
width
,
y
:
padding$1
/
can
.
height
};
s
.
_localBoundsSelf
.
width
=
maxW
;
s
.
_localBoundsSelf
.
width
=
maxW
;
s
.
_localBoundsSelf
.
height
=
maxH
;
s
.
_localBoundsSelf
.
height
=
maxH
;
s
.
updateTexture
();
s
.
updateTexture
();
function
measureChar
(
char
)
{
var
w
=
measureCache
[
char
];
if
(
w
===
undefined
)
{
w
=
measureCache
[
char
]
=
s
.
_getMeasuredWidth
(
char
);
}
return
w
;
}
};
};
TextField
.
prototype
.
updateTexture
=
function
()
{
TextField
.
prototype
.
updateTexture
=
function
()
{
var
canvas
=
this
.
canvas
;
var
canvas
=
this
.
canvas
;
...
@@ -12450,7 +12732,24 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -12450,7 +12732,24 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
arrayFind
(
assetsConfig
,
function
(
item
)
{
return
item
.
uuid
===
uuid
;
});
return
arrayFind
(
assetsConfig
,
function
(
item
)
{
return
item
.
uuid
===
uuid
;
});
}
}
function
getAssetByName
(
name
)
{
function
getAssetByName
(
name
)
{
return
arrayFind
(
assetsConfig
,
function
(
item
)
{
return
item
.
name
===
name
;
});
var
result
=
arrayFind
(
assetsConfig
,
function
(
item
)
{
return
item
.
name
===
name
;
});
if
(
result
)
{
return
result
;
}
else
{
for
(
var
_i
=
0
,
assetsConfig_1
=
assetsConfig
;
_i
<
assetsConfig_1
.
length
;
_i
++
)
{
var
assetConfig
=
assetsConfig_1
[
_i
];
var
res
=
engine
.
globalLoader
.
get
(
assetConfig
.
url
);
if
(
res
&&
res
.
frames
)
{
for
(
var
key
in
res
.
frames
)
{
var
frame
=
res
.
frames
[
key
];
if
(
frame
.
name
===
name
)
{
return
{
url
:
key
};
}
}
}
}
}
}
}
var
commonjsGlobal
=
typeof
globalThis
!==
'undefined'
?
globalThis
:
typeof
window
!==
'undefined'
?
window
:
typeof
global
!==
'undefined'
?
global
:
typeof
self
!==
'undefined'
?
self
:
{};
var
commonjsGlobal
=
typeof
globalThis
!==
'undefined'
?
globalThis
:
typeof
window
!==
'undefined'
?
window
:
typeof
global
!==
'undefined'
?
global
:
typeof
self
!==
'undefined'
?
self
:
{};
...
@@ -14845,8 +15144,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14845,8 +15144,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
tslib_1
.
__extends
(
TextInput
,
_super
);
tslib_1
.
__extends
(
TextInput
,
_super
);
function
TextInput
()
{
function
TextInput
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_placeholder
=
'
'
;
_this
.
placeholderColor
=
'#666666
'
;
_this
.
_placeholderColor
=
'#666666
'
;
_this
.
type
=
'text
'
;
_this
.
onBlur
=
function
(
e
)
{
_this
.
onBlur
=
function
(
e
)
{
_this
.
setBlur
();
_this
.
setBlur
();
};
};
...
@@ -14856,41 +15155,23 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14856,41 +15155,23 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_this
.
text
=
''
;
_this
.
text
=
''
;
return
_this
;
return
_this
;
}
}
Object
.
defineProperty
(
TextInput
.
prototype
,
"placeholder"
,
{
TextInput
.
prototype
.
onModify
=
function
(
value
,
key
)
{
get
:
function
()
{
switch
(
key
)
{
return
this
.
_placeholder
;
case
'placeholder'
:
},
if
(
this
.
_placeholderLabel
)
{
set
:
function
(
value
)
{
this
.
_placeholderLabel
.
text
=
value
;
this
.
_placeholder
=
value
;
}
this
.
_placeholderLabel
.
text
=
value
;
break
;
},
case
'placeholderColor'
:
enumerable
:
true
,
if
(
this
.
_placeholderLabel
)
{
configurable
:
true
this
.
_placeholderLabel
.
fillColor
=
value
;
});
}
Object
.
defineProperty
(
TextInput
.
prototype
,
"placeholderColor"
,
{
break
;
get
:
function
()
{
case
'maxLength'
:
return
this
.
_placeholderColor
;
},
set
:
function
(
value
)
{
this
.
_placeholderColor
=
value
;
this
.
_placeholderLabel
.
fillColor
=
value
;
},
enumerable
:
true
,
configurable
:
true
});
Object
.
defineProperty
(
TextInput
.
prototype
,
"maxLength"
,
{
get
:
function
()
{
return
this
.
_maxLength
;
},
set
:
function
(
value
)
{
if
(
this
.
_maxLength
!=
value
)
{
this
.
_maxLength
=
value
;
this
.
setMaxLength
();
this
.
setMaxLength
();
}
break
;
},
}
enumerable
:
true
,
};
configurable
:
true
});
TextInput
.
prototype
.
setup
=
function
()
{
TextInput
.
prototype
.
setup
=
function
()
{
var
fd
=
this
.
_floatDisplay
=
new
FloatDisplay
();
var
fd
=
this
.
_floatDisplay
=
new
FloatDisplay
();
var
input
=
this
.
_input
=
document
.
createElement
(
'input'
);
var
input
=
this
.
_input
=
document
.
createElement
(
'input'
);
...
@@ -14905,7 +15186,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14905,7 +15186,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
input
.
type
=
'text'
;
input
.
type
=
'text'
;
input
.
addEventListener
(
'blur'
,
this
.
onBlur
);
input
.
addEventListener
(
'blur'
,
this
.
onBlur
);
var
pl
=
this
.
_placeholderLabel
=
new
TextField
();
var
pl
=
this
.
_placeholderLabel
=
new
TextField
();
pl
.
fillColor
=
this
.
_
placeholderColor
;
pl
.
fillColor
=
this
.
placeholderColor
;
this
.
verticalAlign
=
pl
.
verticalAlign
=
exports
.
VERTICAL_ALIGN
.
MIDDLE
;
this
.
verticalAlign
=
pl
.
verticalAlign
=
exports
.
VERTICAL_ALIGN
.
MIDDLE
;
this
.
addChild
(
fd
);
this
.
addChild
(
fd
);
};
};
...
@@ -14919,7 +15200,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14919,7 +15200,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
};
TextInput
.
prototype
.
setMaxLength
=
function
()
{
TextInput
.
prototype
.
setMaxLength
=
function
()
{
var
value
=
this
.
_text
;
var
value
=
this
.
_text
;
var
maxLength
=
this
.
_
maxLength
;
var
maxLength
=
this
.
maxLength
;
if
(
maxLength
>
0
&&
value
&&
value
.
length
>
maxLength
)
{
if
(
maxLength
>
0
&&
value
&&
value
.
length
>
maxLength
)
{
this
.
text
=
value
.
substr
(
0
,
maxLength
);
this
.
text
=
value
.
substr
(
0
,
maxLength
);
}
}
...
@@ -14934,7 +15215,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14934,7 +15215,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
else
{
else
{
if
(
!
pl
.
parent
)
{
if
(
!
pl
.
parent
)
{
pl
.
text
=
this
.
_
placeholder
;
pl
.
text
=
this
.
placeholder
;
pl
.
size
=
this
.
size
;
pl
.
size
=
this
.
size
;
pl
.
font
=
this
.
font
;
pl
.
font
=
this
.
font
;
this
.
addChildAt
(
pl
,
0
);
this
.
addChildAt
(
pl
,
0
);
...
@@ -14963,12 +15244,22 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -14963,12 +15244,22 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
this
.
_floatDisplay
.
alpha
=
1
;
this
.
_floatDisplay
.
alpha
=
1
;
input
.
style
.
pointerEvents
=
'auto'
;
input
.
style
.
pointerEvents
=
'auto'
;
if
(
this
.
_maxLength
>
0
)
{
var
maxLength
=
this
.
maxLength
;
input
.
maxLength
=
this
.
_maxLength
;
if
(
maxLength
>
0
)
{
input
.
maxLength
=
maxLength
;
}
}
else
{
else
{
input
.
removeAttribute
(
'maxLength'
);
input
.
removeAttribute
(
'maxLength'
);
}
}
if
(
this
.
pattern
)
{
input
.
pattern
=
this
.
pattern
;
}
else
{
input
.
removeAttribute
(
'pattern'
);
}
if
(
this
.
type
)
{
input
.
type
=
this
.
type
;
}
input
.
focus
();
input
.
focus
();
this
.
dispatchEvent
(
Event
.
FOCUS
);
this
.
dispatchEvent
(
Event
.
FOCUS
);
};
};
...
@@ -15017,6 +15308,21 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15017,6 +15308,21 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
null
;
return
null
;
};
};
TextInput
.
_bp
=
new
Point
();
TextInput
.
_bp
=
new
Point
();
tslib_1
.
__decorate
([
dirtyFieldTrigger
],
TextInput
.
prototype
,
"placeholder"
,
void
0
);
tslib_1
.
__decorate
([
dirtyFieldTrigger
],
TextInput
.
prototype
,
"placeholderColor"
,
void
0
);
tslib_1
.
__decorate
([
dirtyFieldTrigger
],
TextInput
.
prototype
,
"maxLength"
,
void
0
);
tslib_1
.
__decorate
([
dirtyFieldTrigger
],
TextInput
.
prototype
,
"type"
,
void
0
);
tslib_1
.
__decorate
([
dirtyFieldTrigger
],
TextInput
.
prototype
,
"pattern"
,
void
0
);
return
TextInput
;
return
TextInput
;
}(
Label
));
}(
Label
));
...
@@ -15055,6 +15361,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15055,6 +15361,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
textinput
:
TextInput
,
textinput
:
TextInput
,
scrollView
:
ScrollView
,
scrollView
:
ScrollView
,
};
};
function
registerNodeType
(
name
,
def
)
{
nodeTypeMapping
[
name
]
=
def
;
}
function
instantiate
(
config
)
{
function
instantiate
(
config
)
{
return
instantiateView
(
config
);
return
instantiateView
(
config
);
}
}
...
@@ -15092,21 +15401,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15092,21 +15401,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
return
node
;
return
node
;
}
}
var
template
=
"
\n
<div style=
\"\n
position: absolute;
\n
left: 0;
\n
right: 0;
\n
top: 0;
\n
bottom: 0;
\n
display: flex;
\n
display: -webkit-flex;
\n
justify-content: center;
\n
-webkit-justify-content: center;
\n
align-items: center;
\n
-webkit-align-items: center;
\n\"
>
\n
<img src=
\"
//yun.duiba.com.cn/editor/zeroing/assets/loading.gif
\"\n
</div>
\n
"
;
var
container$1
=
document
.
createElement
(
'div'
);
container$1
.
innerHTML
=
template
;
var
wrapper
=
container$1
.
removeChild
(
container$1
.
children
[
0
]);
function
showLoadingView
()
{
if
(
!
wrapper
.
parentElement
)
{
document
.
body
.
appendChild
(
wrapper
);
}
}
function
hideLoadingView
()
{
if
(
wrapper
.
parentElement
)
{
document
.
body
.
removeChild
(
wrapper
);
}
}
var
Toast
=
(
function
(
_super
)
{
var
Toast
=
(
function
(
_super
)
{
tslib_1
.
__extends
(
Toast
,
_super
);
tslib_1
.
__extends
(
Toast
,
_super
);
function
Toast
(
gameStage
)
{
function
Toast
(
gameStage
)
{
...
@@ -15279,7 +15573,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15279,7 +15573,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
}
}
}
}
}
showLoadingView
();
return
[
4
,
loadAssets
(
assets
,
p
).
catch
(
function
(
e
)
{
return
[
4
,
loadAssets
(
assets
,
p
).
catch
(
function
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
);
})];
})];
...
@@ -15302,7 +15595,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15302,7 +15595,6 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
_a
++
;
_a
++
;
return
[
3
,
2
];
return
[
3
,
2
];
case
5
:
case
5
:
hideLoadingView
();
this
.
start
();
this
.
start
();
onStart
&&
onStart
();
onStart
&&
onStart
();
return
[
2
];
return
[
2
];
...
@@ -15311,6 +15603,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15311,6 +15603,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
});
});
};
};
GameStage
.
prototype
.
start
=
function
()
{
GameStage
.
prototype
.
start
=
function
()
{
var
_this
=
this
;
var
_a
=
this
.
_config
,
_b
=
_a
.
options
,
entrySceneView
=
_b
.
entrySceneView
,
env
=
_b
.
env
,
dataMapping
=
_a
.
dataMapping
,
processes
=
_a
.
processes
,
builtinProcesses
=
_a
.
builtinProcesses
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
var
_a
=
this
.
_config
,
_b
=
_a
.
options
,
entrySceneView
=
_b
.
entrySceneView
,
env
=
_b
.
env
,
dataMapping
=
_a
.
dataMapping
,
processes
=
_a
.
processes
,
builtinProcesses
=
_a
.
builtinProcesses
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
Stage
.
addUpdateObj
(
Tween
);
Stage
.
addUpdateObj
(
Tween
);
injectEnv
(
env
);
injectEnv
(
env
);
...
@@ -15318,10 +15611,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -15318,10 +15611,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
this
.
dataCenter
.
registerDataMapping
(
dataMapping
);
}
}
setProcessMetaLibs
(
processes
,
builtinProcesses
);
setProcessMetaLibs
(
processes
,
builtinProcesses
);
var
sceneEntry
=
this
.
instantiateView
(
entrySceneView
);
setTimeout
(
function
()
{
if
(
sceneEntry
)
{
var
sceneEntry
=
_this
.
instantiateView
(
entrySceneView
);
this
.
_sceneContainer
.
push
(
sceneEntry
);
if
(
sceneEntry
)
{
}
_this
.
_sceneContainer
.
push
(
sceneEntry
);
}
});
};
};
GameStage
.
prototype
.
instantiateView
=
function
(
name
,
cache
)
{
GameStage
.
prototype
.
instantiateView
=
function
(
name
,
cache
)
{
if
(
cache
===
void
0
)
{
cache
=
true
;
}
if
(
cache
===
void
0
)
{
cache
=
true
;
}
...
@@ -18549,43 +18844,87 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18549,43 +18844,87 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var
url
=
assetConfig
.
url
;
var
url
=
assetConfig
.
url
;
var
opts
=
{
var
opts
=
{
src
:
[
url
],
src
:
[
url
],
autoplay
:
tru
e
,
autoplay
:
fals
e
,
};
};
injectProperties
(
opts
,
options
);
injectProperties
(
opts
,
options
);
var
sound
=
new
howler_2
(
opts
);
var
key_1
=
name
||
uuid
;
if
(
name
!==
undefined
)
{
var
_a
=
opts
.
keep
,
keep
=
_a
===
void
0
?
false
:
_a
;
instances
[
name
]
=
sound
;
var
sound
=
void
0
;
if
(
keep
)
{
var
data
=
instances
[
key_1
];
if
(
data
)
{
sound
=
data
.
sound
;
}
}
if
(
!
sound
)
{
sound
=
new
howler_2
(
opts
);
}
instances
[
key_1
]
=
{
sound
:
sound
,
keep
:
keep
,
};
if
(
!
keep
)
{
sound
.
on
(
'end'
,
function
()
{
sound
.
on
(
'end'
,
function
()
{
de
lete
instances
[
name
]
;
de
stroySound
(
key_1
)
;
});
});
}
}
sound
.
play
();
return
sound
;
return
sound
;
}
}
}
}
function
stopSound
(
name
)
{
function
stopSound
(
name
)
{
var
sound
=
instances
[
name
]
;
var
_a
=
instances
[
name
],
sound
=
_a
.
sound
,
keep
=
_a
.
keep
;
if
(
sound
)
{
if
(
sound
)
{
sound
.
stop
();
sound
.
stop
();
delete
instances
[
name
];
if
(
!
keep
)
{
destroySound
(
name
);
}
}
}
}
}
function
destroySound
(
name
)
{
delete
instances
[
name
];
}
var
template
=
"
\n
<div style=
\"\n
position: absolute;
\n
left: 0;
\n
right: 0;
\n
top: 0;
\n
bottom: 0;
\n
display: flex;
\n
display: -webkit-flex;
\n
justify-content: center;
\n
-webkit-justify-content: center;
\n
align-items: center;
\n
-webkit-align-items: center;
\n\"
>
\n
<img src=
\"
//yun.duiba.com.cn/editor/zeroing/assets/loading.gif
\"\n
</div>
\n
"
;
var
container$1
=
document
.
createElement
(
'div'
);
container$1
.
innerHTML
=
template
;
var
wrapper
=
container$1
.
removeChild
(
container$1
.
children
[
0
]);
var
builtinLoadingView
=
{
onProgress
:
function
(
done
,
total
)
{
if
(
!
wrapper
.
parentElement
)
{
document
.
body
.
appendChild
(
wrapper
);
}
},
onComplete
:
function
()
{
if
(
wrapper
.
parentElement
)
{
document
.
body
.
removeChild
(
wrapper
);
}
},
};
function
launch
(
url
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
)
{
function
launch
(
url
,
loadingDelega
te
,
onStart
)
{
return
globalLoader
.
loadJson
(
url
)
return
globalLoader
.
loadJson
(
url
)
.
then
(
function
(
config
)
{
.
then
(
function
(
config
)
{
return
launchWithConfig
(
config
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
);
return
launchWithConfig
(
config
,
loadingDelega
te
,
onStart
);
});
});
}
}
function
launchWithLocalStorage
(
id
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
)
{
function
launchWithLocalStorage
(
id
,
loadingDelega
te
,
onStart
)
{
var
storeKey
=
'preview-project-'
+
id
;
var
storeKey
=
'preview-project-'
+
id
;
var
storeData
=
localStorage
.
getItem
(
storeKey
);
var
storeData
=
localStorage
.
getItem
(
storeKey
);
var
_a
=
JSON
.
parse
(
storeData
),
data
=
_a
.
data
,
processes
=
_a
.
processes
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
var
_a
=
JSON
.
parse
(
storeData
),
data
=
_a
.
data
,
processes
=
_a
.
processes
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
setProcessMetaLibs
(
processes
);
setProcessMetaLibs
(
processes
);
registerScripts
(
scripts
);
registerScripts
(
scripts
);
registerCustomModuleFromConfig
(
customs
);
registerCustomModuleFromConfig
(
customs
);
return
launchWithConfig
(
data
,
onAssetsProgress
,
onAssetsComplete
,
onStart
);
return
launchWithConfig
(
data
,
loadingDelegate
,
onStart
);
}
function
launchWithWindowVariable
(
name
,
loadingDelegate
,
onStart
)
{
var
_a
=
window
[
name
],
data
=
_a
.
data
,
processes
=
_a
.
processes
,
scripts
=
_a
.
scripts
,
customs
=
_a
.
customs
;
setProcessMetaLibs
(
processes
);
registerScripts
(
scripts
);
registerCustomModuleFromConfig
(
customs
);
return
launchWithConfig
(
data
,
loadingDelegate
,
onStart
);
}
}
function
launchWithConfig
(
config
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
)
{
function
launchWithConfig
(
config
,
loadingDelega
te
,
onStart
)
{
return
new
Promise
(
function
(
resolve
)
{
return
new
Promise
(
function
(
resolve
)
{
var
_a
=
config
.
options
,
containerId
=
_a
.
containerId
,
designWidth
=
_a
.
designWidth
,
designHeight
=
_a
.
designHeight
,
frameRate
=
_a
.
frameRate
,
scaleMode
=
_a
.
scaleMode
,
rendererType
=
_a
.
rendererType
;
var
_a
=
config
.
options
,
containerId
=
_a
.
containerId
,
designWidth
=
_a
.
designWidth
,
designHeight
=
_a
.
designHeight
,
frameRate
=
_a
.
frameRate
,
scaleMode
=
_a
.
scaleMode
,
rendererType
=
_a
.
rendererType
;
var
stage
=
window
[
'stage'
]
=
new
Stage
(
containerId
||
"game-container"
,
designWidth
||
750
,
designHeight
||
1334
,
frameRate
||
60
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
rendererType
||
exports
.
RENDERER_TYPE
.
WEBGL
);
var
stage
=
window
[
'stage'
]
=
new
Stage
(
containerId
||
"game-container"
,
designWidth
||
750
,
designHeight
||
1334
,
frameRate
||
60
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
rendererType
||
exports
.
RENDERER_TYPE
.
WEBGL
);
...
@@ -18596,7 +18935,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18596,7 +18935,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
gameStage
:
exports
.
gameStage
gameStage
:
exports
.
gameStage
});
});
stage
.
addChild
(
exports
.
gameStage
);
stage
.
addChild
(
exports
.
gameStage
);
exports
.
gameStage
.
launch
(
config
,
onAssetsProgress
,
onAssetsComplete
,
onStart
);
var
delegate
=
loadingDelegate
||
builtinLoadingView
;
exports
.
gameStage
.
launch
(
config
,
function
(
done
,
total
)
{
delegate
.
onProgress
&&
delegate
.
onProgress
(
done
,
total
);
},
function
()
{
delegate
.
onComplete
&&
delegate
.
onComplete
();
},
onStart
);
});
});
resolve
(
exports
.
gameStage
);
resolve
(
exports
.
gameStage
);
});
});
...
@@ -18618,6 +18962,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18618,6 +18962,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
DATA_URI
=
DATA_URI
;
exports
.
DATA_URI
=
DATA_URI
;
exports
.
DEG_TO_RAD
=
DEG_TO_RAD
;
exports
.
DEG_TO_RAD
=
DEG_TO_RAD
;
exports
.
DisplayObject
=
DisplayObject
;
exports
.
DisplayObject
=
DisplayObject
;
exports
.
DrawAllToCanvas
=
DrawAllToCanvas
;
exports
.
ESCAPE_REG_EXP
=
ESCAPE_REG_EXP
;
exports
.
ESCAPE_REG_EXP
=
ESCAPE_REG_EXP
;
exports
.
Ease
=
Ease
;
exports
.
Ease
=
Ease
;
exports
.
EditableText
=
EditableText
;
exports
.
EditableText
=
EditableText
;
...
@@ -18626,6 +18971,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18626,6 +18971,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
FloatDisplay
=
FloatDisplay
;
exports
.
FloatDisplay
=
FloatDisplay
;
exports
.
GDispatcher
=
GDispatcher
;
exports
.
GDispatcher
=
GDispatcher
;
exports
.
GameStage
=
GameStage
;
exports
.
GameStage
=
GameStage
;
exports
.
GlobalPro
=
GlobalPro
;
exports
.
Graphics
=
Graphics
;
exports
.
Graphics
=
Graphics
;
exports
.
HashObject
=
HashObject
;
exports
.
HashObject
=
HashObject
;
exports
.
Howl
=
howler_2
;
exports
.
Howl
=
howler_2
;
...
@@ -18665,6 +19011,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18665,6 +19011,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
createTextureSheet
=
createTextureSheet
;
exports
.
createTextureSheet
=
createTextureSheet
;
exports
.
deepDirtyFieldDetector
=
deepDirtyFieldDetector
;
exports
.
deepDirtyFieldDetector
=
deepDirtyFieldDetector
;
exports
.
deepDirtyFieldTrigger
=
deepDirtyFieldTrigger
;
exports
.
deepDirtyFieldTrigger
=
deepDirtyFieldTrigger
;
exports
.
destroySound
=
destroySound
;
exports
.
devicePixelRatio
=
devicePixelRatio
;
exports
.
devicePixelRatio
=
devicePixelRatio
;
exports
.
dirtyFieldDetector
=
dirtyFieldDetector
;
exports
.
dirtyFieldDetector
=
dirtyFieldDetector
;
exports
.
dirtyFieldTrigger
=
dirtyFieldTrigger
;
exports
.
dirtyFieldTrigger
=
dirtyFieldTrigger
;
...
@@ -18694,6 +19041,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18694,6 +19041,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
launch
=
launch
;
exports
.
launch
=
launch
;
exports
.
launchWithConfig
=
launchWithConfig
;
exports
.
launchWithConfig
=
launchWithConfig
;
exports
.
launchWithLocalStorage
=
launchWithLocalStorage
;
exports
.
launchWithLocalStorage
=
launchWithLocalStorage
;
exports
.
launchWithWindowVariable
=
launchWithWindowVariable
;
exports
.
linkedFlag
=
linkedFlag
;
exports
.
linkedFlag
=
linkedFlag
;
exports
.
loadAssets
=
loadAssets
;
exports
.
loadAssets
=
loadAssets
;
exports
.
md5
=
md5
;
exports
.
md5
=
md5
;
...
@@ -18707,6 +19055,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
...
@@ -18707,6 +19055,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports
.
registerCustomCodeModule
=
registerCustomCodeModule
;
exports
.
registerCustomCodeModule
=
registerCustomCodeModule
;
exports
.
registerCustomModule
=
registerCustomModule
;
exports
.
registerCustomModule
=
registerCustomModule
;
exports
.
registerCustomModuleFromConfig
=
registerCustomModuleFromConfig
;
exports
.
registerCustomModuleFromConfig
=
registerCustomModuleFromConfig
;
exports
.
registerNodeType
=
registerNodeType
;
exports
.
registerScriptDef
=
registerScriptDef
;
exports
.
registerScriptDef
=
registerScriptDef
;
exports
.
registerScripts
=
registerScripts
;
exports
.
registerScripts
=
registerScripts
;
exports
.
setGlobalContext
=
setGlobalContext
;
exports
.
setGlobalContext
=
setGlobalContext
;
...
...
debug/engine.js.map
View file @
03035a71
This source diff could not be displayed because it is too large. You can
view the blob
instead.
renderingengine.iml
View file @
03035a71
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
<module
type=
"WEB_MODULE"
version=
"4"
>
<module
type=
"WEB_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
/>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/dist"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</component>
...
...
src/2d/display/Container.ts
View file @
03035a71
...
@@ -184,7 +184,7 @@ export default class Container extends DisplayObject {
...
@@ -184,7 +184,7 @@ export default class Container extends DisplayObject {
* 是否含有child
* 是否含有child
* @param child
* @param child
*/
*/
contains
(
child
:
DisplayObject
):
boolean
{
contains
(
child
:
DisplayObject
):
boolean
{
return
!!
this
.
getChildIndex
(
child
);
return
!!
this
.
getChildIndex
(
child
);
}
}
...
@@ -209,6 +209,66 @@ export default class Container extends DisplayObject {
...
@@ -209,6 +209,66 @@ export default class Container extends DisplayObject {
return
this
.
children
[
index
];
return
this
.
children
[
index
];
}
}
/**
* 根据路径获取子节点
* @param path
* @param method
*/
getChildByPath
(
path
:
any
,
method
:
string
):
DisplayObject
{
if
(
!
path
)
{
return
null
;
}
let
p
=
this
;
while
(
path
.
length
>
0
)
{
let
segment
=
path
.
shift
();
p
=
p
[
method
](
segment
);
if
(
!
p
)
{
break
;
}
}
return
p
;
}
/**
* 根据名称路径获取子节点
* @param path
*/
getChildByNamePath
(
path
:
string
):
DisplayObject
{
const
pathArr
=
path
.
split
(
'/'
);
return
this
.
getChildByPath
(
pathArr
,
'getChildByName'
);
}
/**
* 根据索引路径获取子节点
* @param path
*/
getChildByIndexPath
(
path
:
string
):
DisplayObject
{
const
pathArr
=
path
.
split
(
'/'
).
map
(
seg
=>
parseInt
(
seg
));
return
this
.
getChildByPath
(
pathArr
,
'getChildAt'
);
}
/**
* 根据uuid搜索子节点
* @param uuid
*/
findChildByUUID
(
uuid
:
string
)
{
if
(
this
[
'uuid'
]
===
uuid
)
{
return
this
;
}
if
(
this
.
children
&&
this
.
children
.
length
>
0
)
{
for
(
let
child
of
this
.
children
)
{
if
(
child
.
findChildByUUID
){
let
target
=
child
.
findChildByUUID
(
uuid
);
if
(
target
)
{
return
target
;
}
}
}
}
}
/**
/**
* 通过名字获取子级
* 通过名字获取子级
* @param name
* @param name
...
...
src/2d/display/Sprite.ts
View file @
03035a71
import
{
ObservablePoint
,
Point
,
Rectangle
}
from
'../math'
;
import
{
ObservablePoint
,
Point
,
Rectangle
}
from
'../math'
;
import
{
sign
,
TextureCache
}
from
'../utils'
;
import
{
sign
,
TextureCache
}
from
'../utils'
;
// import { BLEND_MODES } from '../const';
// import { BLEND_MODES } from '../const';
import
Texture
from
'../texture/Texture'
;
import
Texture
from
'../texture/Texture'
;
import
{
Event
}
from
'../events/Event'
;
import
{
Event
}
from
'../events/Event'
;
import
Container
from
'./Container'
;
import
Container
from
'./Container'
;
import
{
DisplayObject
}
from
"./DisplayObject"
;
import
{
DisplayObject
}
from
"./DisplayObject"
;
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
CanvasRenderer
from
'../renderers/CanvasRenderer'
;
import
{
SCALE_MODES
}
from
'../const'
;
import
{
SCALE_MODES
}
from
'../const'
;
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
const
indices
=
new
Uint16Array
([
0
,
1
,
2
,
0
,
2
,
3
]);
const
indices
=
new
Uint16Array
([
0
,
1
,
2
,
0
,
2
,
3
]);
/**
/**
...
@@ -22,17 +22,17 @@ export default class Sprite extends Container {
...
@@ -22,17 +22,17 @@ export default class Sprite extends Container {
*
*
*/
*/
private
_anchorTexture
:
ObservablePoint
;
private
_anchorTexture
:
ObservablePoint
;
/**
/**
* 色值调色
* 色值调色
*/
*/
private
_tint
:
number
;
private
_tint
:
number
;
/**
/**
* RGB形式色值,webgl用
* RGB形式色值,webgl用
*/
*/
_tintRGB
:
number
;
_tintRGB
:
number
;
/**
/**
* 和_tint比较用,用于canvas调色缓存
* 和_tint比较用,用于canvas调色缓存
*/
*/
_cachedTint
:
number
;
_cachedTint
:
number
;
/**
/**
* 使用的贴图
* 使用的贴图
...
@@ -99,9 +99,9 @@ export default class Sprite extends Container {
...
@@ -99,9 +99,9 @@ export default class Sprite extends Container {
this
.
_height
=
0
;
this
.
_height
=
0
;
this
.
_tint
=
null
;
this
.
_tint
=
null
;
this
.
_tintRGB
=
null
;
this
.
_tintRGB
=
null
;
this
.
tint
=
0xFFFFFF
;
this
.
tint
=
0xFFFFFF
;
this
.
_cachedTint
=
0xFFFFFF
;
this
.
_cachedTint
=
0xFFFFFF
;
this
.
uvs
=
null
;
this
.
uvs
=
null
;
...
@@ -454,13 +454,14 @@ export default class Sprite extends Container {
...
@@ -454,13 +454,14 @@ export default class Sprite extends Container {
}
}
get
tint
()
{
get
tint
()
{
return
this
.
_tint
;
return
this
.
_tint
;
}
}
set
tint
(
value
)
{
if
(
value
===
this
.
_tint
)
return
;
set
tint
(
value
)
{
this
.
_tint
=
value
;
if
(
value
===
this
.
_tint
)
return
;
this
.
_tintRGB
=
(
value
>>
16
)
+
(
value
&
0xff00
)
+
((
value
&
0xff
)
<<
16
);
this
.
_tint
=
value
;
}
this
.
_tintRGB
=
(
value
>>
16
)
+
(
value
&
0xff00
)
+
((
value
&
0xff
)
<<
16
);
}
//一些静态类方法
//一些静态类方法
/**
/**
...
...
src/2d/text/TextField.ts
View file @
03035a71
...
@@ -18,7 +18,6 @@ const padding = 10;
...
@@ -18,7 +18,6 @@ const padding = 10;
* @public
* @public
*/
*/
export
class
TextField
extends
Sprite
{
export
class
TextField
extends
Sprite
{
canvas
:
HTMLCanvasElement
;
canvas
:
HTMLCanvasElement
;
context
:
CanvasRenderingContext2D
;
context
:
CanvasRenderingContext2D
;
/**
/**
...
@@ -231,6 +230,8 @@ export class TextField extends Sprite {
...
@@ -231,6 +230,8 @@ export class TextField extends Sprite {
private
_lineType
:
TEXT_lINETYPE
=
TEXT_lINETYPE
.
SINGLE
;
private
_lineType
:
TEXT_lINETYPE
=
TEXT_lINETYPE
.
SINGLE
;
protected
_text
:
string
=
""
;
/**
/**
* 文本内容
* 文本内容
* @property text
* @property text
...
@@ -244,7 +245,7 @@ export class TextField extends Sprite {
...
@@ -244,7 +245,7 @@ export class TextField extends Sprite {
}
}
public
get
text
():
string
{
public
get
text
():
string
{
return
this
.
_t
ext
;
return
this
.
pureT
ext
;
}
}
protected
_setText
(
value
)
{
protected
_setText
(
value
)
{
...
@@ -256,7 +257,49 @@ export class TextField extends Sprite {
...
@@ -256,7 +257,49 @@ export class TextField extends Sprite {
}
}
}
}
protected
_text
:
string
=
""
;
protected
_textFlow
:
any
;
protected
_pureText
=
''
;
get
textFlow
():
any
{
return
this
.
_textFlow
;
}
set
textFlow
(
value
:
any
)
{
this
.
_textFlow
=
value
;
this
.
dirty
=
true
;
let
text
=
''
;
for
(
let
item
of
this
.
_textFlow
)
{
text
+=
item
.
text
;
}
this
.
_pureText
=
text
;
}
get
isPureText
()
{
return
!
this
.
_textFlow
||
this
.
_textFlow
.
length
==
0
;
}
get
pureText
()
{
return
this
.
isPureText
?
this
.
_text
:
this
.
_pureText
;
}
protected
getStyle
(
index
)
{
if
(
!
this
.
textFlow
)
{
return
null
;
}
let
targetItem
;
let
count
=
0
;
for
(
let
item
of
this
.
_textFlow
)
{
count
+=
item
.
text
.
length
;
if
(
index
<
count
)
{
targetItem
=
item
;
break
;
}
}
return
targetItem
.
style
;
}
/**
/**
* 文本的css字体样式
* 文本的css字体样式
...
@@ -292,7 +335,6 @@ export class TextField extends Sprite {
...
@@ -292,7 +335,6 @@ export class TextField extends Sprite {
this
.
_size
=
value
;
this
.
_size
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
size
():
number
{
public
get
size
():
number
{
...
@@ -314,7 +356,6 @@ export class TextField extends Sprite {
...
@@ -314,7 +356,6 @@ export class TextField extends Sprite {
this
.
_fillColor
=
value
;
this
.
_fillColor
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
fillColor
():
any
{
public
get
fillColor
():
any
{
...
@@ -336,7 +377,6 @@ export class TextField extends Sprite {
...
@@ -336,7 +377,6 @@ export class TextField extends Sprite {
this
.
_strokeColor
=
value
;
this
.
_strokeColor
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
strokeColor
():
string
{
public
get
strokeColor
():
string
{
...
@@ -358,7 +398,6 @@ export class TextField extends Sprite {
...
@@ -358,7 +398,6 @@ export class TextField extends Sprite {
this
.
_stroke
=
value
;
this
.
_stroke
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
stroke
():
number
{
public
get
stroke
():
number
{
...
@@ -380,7 +419,6 @@ export class TextField extends Sprite {
...
@@ -380,7 +419,6 @@ export class TextField extends Sprite {
this
.
_italic
=
value
;
this
.
_italic
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
italic
():
boolean
{
public
get
italic
():
boolean
{
...
@@ -402,7 +440,6 @@ export class TextField extends Sprite {
...
@@ -402,7 +440,6 @@ export class TextField extends Sprite {
this
.
_bold
=
value
;
this
.
_bold
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
bold
():
boolean
{
public
get
bold
():
boolean
{
...
@@ -423,7 +460,6 @@ export class TextField extends Sprite {
...
@@ -423,7 +460,6 @@ export class TextField extends Sprite {
this
.
_border
=
value
;
this
.
_border
=
value
;
this
.
dirty
=
true
;
this
.
dirty
=
true
;
}
}
;
}
}
public
get
border
():
boolean
{
public
get
border
():
boolean
{
...
@@ -512,8 +548,9 @@ export class TextField extends Sprite {
...
@@ -512,8 +548,9 @@ export class TextField extends Sprite {
*/
*/
public
updateText
():
void
{
public
updateText
():
void
{
let
s
:
TextField
=
this
;
let
s
:
TextField
=
this
;
let
text
=
s
.
_pureText
;
//如果没有文本
//如果没有文本
if
(
!
s
.
_
text
)
{
if
(
!
text
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
s
.
canvas
.
height
=
0
;
s
.
_localBoundsSelf
.
clear
();
s
.
_localBoundsSelf
.
clear
();
...
@@ -521,12 +558,13 @@ export class TextField extends Sprite {
...
@@ -521,12 +558,13 @@ export class TextField extends Sprite {
this
.
updateTexture
();
this
.
updateTexture
();
return
return
}
}
let
measureCache
=
{};
if
(
!
s
.
dirty
)
return
;
if
(
!
s
.
dirty
)
return
;
s
.
dirty
=
false
;
s
.
dirty
=
false
;
s
.
_
text
+=
""
;
text
+=
""
;
let
can
=
s
.
canvas
;
let
can
=
s
.
canvas
;
let
ctx
=
s
.
context
;
let
ctx
=
s
.
context
;
let
hardLines
:
any
=
s
.
_
text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
let
hardLines
:
any
=
text
.
toString
().
split
(
/
(?:\r\n
|
\r
|
\n)
/
);
let
realLines
:
any
=
[];
let
realLines
:
any
=
[];
s
.
realLines
=
realLines
;
s
.
realLines
=
realLines
;
s
.
_prepContext
(
ctx
);
s
.
_prepContext
(
ctx
);
...
@@ -534,7 +572,7 @@ export class TextField extends Sprite {
...
@@ -534,7 +572,7 @@ export class TextField extends Sprite {
let
textWidth
=
s
.
_width
;
let
textWidth
=
s
.
_width
;
// let lineH = s._lineSpacing + s.size;
// let lineH = s._lineSpacing + s.size;
//单行文本时
//单行文本时
if
(
s
.
_
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
if
(
text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
let
str
=
hardLines
[
0
];
let
str
=
hardLines
[
0
];
let
lineW
=
s
.
_getMeasuredWidth
(
str
);
let
lineW
=
s
.
_getMeasuredWidth
(
str
);
...
@@ -559,17 +597,13 @@ export class TextField extends Sprite {
...
@@ -559,17 +597,13 @@ export class TextField extends Sprite {
}
}
}
else
{
}
else
{
//textWidth取每行最大值,如果没设置过textWidth
//textWidth取每行最大值,如果没设置过textWidth
let
measureCache
=
{};
const
shouldMeasureTextWidth
=
!
textWidth
;
const
shouldMeasureTextWidth
=
!
textWidth
;
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
for
(
let
i
=
0
,
l
=
hardLines
.
length
;
i
<
l
;
i
++
)
{
let
str
=
hardLines
[
i
];
let
str
=
hardLines
[
i
];
if
(
!
str
)
continue
;
if
(
!
str
)
continue
;
let
lineWidth
=
0
;
let
lineWidth
=
0
;
for
(
let
char
of
str
)
{
for
(
let
char
of
str
)
{
let
charWidth
=
measureCache
[
char
];
let
charWidth
=
measureChar
(
char
);
if
(
charWidth
===
undefined
)
{
charWidth
=
measureCache
[
char
]
=
s
.
_getMeasuredWidth
(
char
);
}
lineWidth
+=
charWidth
;
lineWidth
+=
charWidth
;
}
}
if
(
shouldMeasureTextWidth
)
{
if
(
shouldMeasureTextWidth
)
{
...
@@ -630,13 +664,46 @@ export class TextField extends Sprite {
...
@@ -630,13 +664,46 @@ export class TextField extends Sprite {
upY
=
s
.
_height
-
trueHeight
;
upY
=
s
.
_height
-
trueHeight
;
}
}
}
}
let
index
=
0
;
for
(
let
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
if
(
s
.
stroke
)
{
let
line
=
realLines
[
i
];
ctx
.
strokeStyle
=
s
.
strokeColor
;
if
(
s
.
isPureText
)
{
ctx
.
lineWidth
=
s
.
stroke
*
2
;
let
y
=
upY
+
i
*
lineH
;
ctx
.
strokeText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
if
(
s
.
stroke
)
{
ctx
.
strokeStyle
=
s
.
strokeColor
;
ctx
.
lineWidth
=
s
.
stroke
*
2
;
ctx
.
strokeText
(
line
,
0
,
y
,
maxW
);
}
ctx
.
fillText
(
line
,
0
,
y
,
maxW
);
}
else
{
let
x
=
0
;
for
(
let
j
=
0
,
lj
=
line
.
length
;
j
<
lj
;
j
++
)
{
const
char
=
line
[
j
];
let
style
=
s
.
getStyle
(
index
);
if
(
style
)
{
if
(
style
.
hasOwnProperty
(
'color'
))
{
ctx
.
fillStyle
=
style
.
color
;
}
if
(
style
.
hasOwnProperty
(
'stroke'
))
{
ctx
.
lineWidth
=
style
.
stroke
*
2
;
}
if
(
style
.
hasOwnProperty
(
'strokeColor'
))
{
ctx
.
strokeStyle
=
style
.
strokeColor
;
}
}
else
{
ctx
.
fillStyle
=
s
.
fillColor
;
ctx
.
lineWidth
=
s
.
stroke
;
ctx
.
strokeStyle
=
s
.
strokeColor
;
}
let
y
=
upY
+
i
*
lineH
;
if
(
ctx
.
lineWidth
>
0
)
{
ctx
.
strokeText
(
char
,
x
,
y
);
}
ctx
.
fillText
(
char
,
x
,
y
);
x
+=
measureChar
(
char
);
index
++
;
}
}
}
ctx
.
fillText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
}
}
//offset用_anchorTexture代替
//offset用_anchorTexture代替
s
.
offsetX
=
-
padding
;
s
.
offsetX
=
-
padding
;
...
@@ -651,7 +718,15 @@ export class TextField extends Sprite {
...
@@ -651,7 +718,15 @@ export class TextField extends Sprite {
s
.
_localBoundsSelf
.
width
=
maxW
;
s
.
_localBoundsSelf
.
width
=
maxW
;
s
.
_localBoundsSelf
.
height
=
maxH
;
s
.
_localBoundsSelf
.
height
=
maxH
;
//修改texture及baseTexture属性
//修改texture及baseTexture属性
s
.
updateTexture
()
s
.
updateTexture
();
function
measureChar
(
char
)
{
let
w
=
measureCache
[
char
];
if
(
w
===
undefined
)
{
w
=
measureCache
[
char
]
=
s
.
_getMeasuredWidth
(
char
);
}
return
w
;
}
}
}
/**
/**
...
...
src/2d/utils/index.ts
View file @
03035a71
...
@@ -8,7 +8,7 @@ import { BLEND_MODES, DATA_URI, RENDERER_TYPE, URL_FILE_EXTENSION } from "../con
...
@@ -8,7 +8,7 @@ import { BLEND_MODES, DATA_URI, RENDERER_TYPE, URL_FILE_EXTENSION } from "../con
export
*
from
'./twiddle'
;
export
*
from
'./twiddle'
;
export
{
default
as
toDisplayDataURL
}
from
"./toDisplayDataURL"
;
export
{
default
as
toDisplayDataURL
}
from
"./toDisplayDataURL"
;
export
{
default
as
determineCrossOrigin
}
from
'./determineCrossOrigin'
;
export
{
default
as
determineCrossOrigin
}
from
'./determineCrossOrigin'
;
export
*
from
'./DrawAllToCanvas'
let
nextUid
=
0
;
let
nextUid
=
0
;
...
...
src/index.ts
View file @
03035a71
...
@@ -24,6 +24,8 @@ export * from "./2d/ui";
...
@@ -24,6 +24,8 @@ export * from "./2d/ui";
export
*
from
'./2d/tween'
export
*
from
'./2d/tween'
export
*
from
'./2d/net'
export
*
from
'./2d/net'
export
{
GlobalPro
,
DrawAllToCanvas
}
from
'./2d/utils'
export
{
default
as
toDisplayDataURL
}
from
"./2d/utils/toDisplayDataURL"
;
export
{
default
as
toDisplayDataURL
}
from
"./2d/utils/toDisplayDataURL"
;
export
{
inputFeildIosEnable
}
from
"./2d/utils/index"
export
{
inputFeildIosEnable
}
from
"./2d/utils/index"
...
...
src/zeroing/behavior-runtime/Process.ts
View file @
03035a71
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
*/
*/
import
{
VM
}
from
"./VM"
;
import
{
VM
}
from
"./VM"
;
import
{
getDataByPath
,
linkedFlag
,
nodeScheme
,
objClone
}
from
"../utils"
;
import
{
getDataByPath
,
linkedFlag
,
nodeScheme
,
objClone
}
from
"../utils"
;
import
{
findNodeByUUID
}
from
"../node-utils"
;
import
{
dataCenter
}
from
"../game-warpper/data-center"
;
import
{
dataCenter
}
from
"../game-warpper/data-center"
;
import
{
env
}
from
"../game-warpper/enviroment"
;
import
{
env
}
from
"../game-warpper/enviroment"
;
import
{
getLogSwitch
,
Logs
}
from
"../log-switch"
;
import
{
getLogSwitch
,
Logs
}
from
"../log-switch"
;
...
@@ -231,7 +230,7 @@ export class Process {
...
@@ -231,7 +230,7 @@ export class Process {
}
else
if
(
value
&&
value
.
indexOf
&&
value
.
indexOf
(
nodeScheme
)
===
0
)
{
}
else
if
(
value
&&
value
.
indexOf
&&
value
.
indexOf
(
nodeScheme
)
===
0
)
{
let
uuid
=
value
.
replace
(
nodeScheme
,
''
);
let
uuid
=
value
.
replace
(
nodeScheme
,
''
);
if
(
uuid
)
{
if
(
uuid
)
{
props
[
key
]
=
findNodeByUUID
(
this
.
_vm
.
globalContext
.
gameStage
,
uuid
);
props
[
key
]
=
this
.
_vm
.
globalContext
.
gameStage
.
findChildByUUID
(
uuid
);
}
}
}
else
if
(
originProps
[
key
]
!==
undefined
)
{
}
else
if
(
originProps
[
key
]
!==
undefined
)
{
props
[
key
]
=
originProps
[
key
];
props
[
key
]
=
originProps
[
key
];
...
...
src/zeroing/decorators/scripts.ts
View file @
03035a71
...
@@ -15,7 +15,7 @@ const scriptDefs = {};
...
@@ -15,7 +15,7 @@ const scriptDefs = {};
*/
*/
export
function
applyScript
(
ctor
:
Function
)
{
export
function
applyScript
(
ctor
:
Function
)
{
ctor
.
prototype
.
applyScripts
=
function
()
{
ctor
.
prototype
.
applyScripts
=
function
()
{
let
scriptsProxy
=
this
.
scripts
Proxy
=
new
ScriptsProxy
(
this
);
let
scriptsProxy
=
this
.
scripts
=
new
ScriptsProxy
(
this
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
scriptsProxy
.
onEnterFrame
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
this
.
addEventListener
(
Event
.
ADDED_TO_STAGE
,
scriptsProxy
.
onAddedToStage
,
scriptsProxy
);
...
...
src/zeroing/game-warpper/GameStage.ts
View file @
03035a71
...
@@ -8,14 +8,13 @@ import {loadAssets} from "./assets-manager";
...
@@ -8,14 +8,13 @@ import {loadAssets} from "./assets-manager";
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
instantiate
}
from
"./view-interpreter"
;
import
{
dataCenter
,
DataCenter
}
from
"./data-center"
;
import
{
dataCenter
,
DataCenter
}
from
"./data-center"
;
import
{
setProcessMetaLibs
}
from
"../behavior-runtime"
;
import
{
setProcessMetaLibs
}
from
"../behavior-runtime"
;
import
{
registerScripts
}
from
".."
;
import
{
Tween
}
from
"../../2d/tween"
;
import
{
Tween
}
from
"../../2d/tween"
;
import
{
Rect
}
from
"./nodes"
;
import
{
Rect
}
from
"./nodes"
;
import
{
injectEnv
}
from
"./enviroment"
;
import
{
injectEnv
}
from
"./enviroment"
;
import
{
registerCustomModuleFromConfig
}
from
"./custom-module"
;
import
{
hideLoadingView
,
showLoadingView
}
from
"./loading-view"
;
import
{
Toast
}
from
"./Toast"
;
import
{
Toast
}
from
"./Toast"
;
import
{
arrayFind
}
from
"../utils"
;
import
{
arrayFind
}
from
"../utils"
;
import
{
registerScripts
}
from
".."
;
import
{
registerCustomModuleFromConfig
}
from
"./custom-module"
;
/**
/**
* 游戏舞台
* 游戏舞台
...
@@ -111,7 +110,6 @@ export class GameStage extends Container {
...
@@ -111,7 +110,6 @@ export class GameStage extends Container {
}
}
}
}
showLoadingView
();
await
loadAssets
(
assets
,
p
).
catch
(
e
=>
{
await
loadAssets
(
assets
,
p
).
catch
(
e
=>
{
console
.
log
(
e
);
console
.
log
(
e
);
});
});
...
@@ -124,7 +122,6 @@ export class GameStage extends Container {
...
@@ -124,7 +122,6 @@ export class GameStage extends Container {
}
}
}
}
}
}
hideLoadingView
();
this
.
start
();
this
.
start
();
...
@@ -157,10 +154,12 @@ export class GameStage extends Container {
...
@@ -157,10 +154,12 @@ export class GameStage extends Container {
}
}
setProcessMetaLibs
(
processes
,
builtinProcesses
);
setProcessMetaLibs
(
processes
,
builtinProcesses
);
let
sceneEntry
=
this
.
instantiateView
(
entrySceneView
);
setTimeout
(()
=>
{
if
(
sceneEntry
)
{
let
sceneEntry
=
this
.
instantiateView
(
entrySceneView
);
this
.
_sceneContainer
.
push
(
sceneEntry
);
if
(
sceneEntry
)
{
}
this
.
_sceneContainer
.
push
(
sceneEntry
);
}
})
}
}
/**
/**
...
...
src/zeroing/game-warpper/
loading-v
iew.ts
→
src/zeroing/game-warpper/
LoadingV
iew.ts
View file @
03035a71
...
@@ -2,16 +2,6 @@
...
@@ -2,16 +2,6 @@
* Created by rockyl on 2019-11-22.
* Created by rockyl on 2019-11-22.
*/
*/
/*const template = `
<div id="loadingWrapper" style="position: absolute; left: 0;top: 0;right: 0;bottom: 0;">
<div id="loadingTrack" style="width: 100px;height: 20px;border: 1px solid deepskyblue;">
<div id="loadingThumb">
</div>
</div>
</div>
`;*/
const
template
=
`
const
template
=
`
<div style="
<div style="
position: absolute;
position: absolute;
...
@@ -34,18 +24,15 @@ let container = document.createElement('div');
...
@@ -34,18 +24,15 @@ let container = document.createElement('div');
container
.
innerHTML
=
template
;
container
.
innerHTML
=
template
;
let
wrapper
=
container
.
removeChild
(
container
.
children
[
0
]);
let
wrapper
=
container
.
removeChild
(
container
.
children
[
0
]);
export
function
showLoadingView
()
{
export
default
{
if
(
!
wrapper
.
parentElement
)
{
onProgress
(
done
,
total
)
{
document
.
body
.
appendChild
(
wrapper
);
if
(
!
wrapper
.
parentElement
)
{
}
document
.
body
.
appendChild
(
wrapper
);
}
}
},
export
function
hideLoadingView
()
{
onComplete
()
{
if
(
wrapper
.
parentElement
)
{
if
(
wrapper
.
parentElement
)
{
document
.
body
.
removeChild
(
wrapper
);
document
.
body
.
removeChild
(
wrapper
);
}
}
}
},
export
function
setLoadingViewProgress
(
current
,
total
)
{
}
}
src/zeroing/game-warpper/assets-manager.ts
View file @
03035a71
...
@@ -32,18 +32,18 @@ export function loadAssets(config, onProgress?, onComplete?) {
...
@@ -32,18 +32,18 @@ export function loadAssets(config, onProgress?, onComplete?) {
config
.
map
(
assetConfig
=>
{
config
.
map
(
assetConfig
=>
{
assetsConfig
.
push
(
assetConfig
);
assetsConfig
.
push
(
assetConfig
);
const
loadFunc
=
loaderMapping
[
assetConfig
.
ext
];
const
loadFunc
=
loaderMapping
[
assetConfig
.
ext
];
if
(
loadFunc
)
{
if
(
loadFunc
)
{
let
method
=
globalLoader
[
'load'
+
loadFunc
];
let
method
=
globalLoader
[
'load'
+
loadFunc
];
return
method
.
call
(
globalLoader
,
assetConfig
.
url
,
assetConfig
.
uuid
).
then
(
return
method
.
call
(
globalLoader
,
assetConfig
.
url
,
assetConfig
.
uuid
).
then
(
(
data
)
=>
{
(
data
)
=>
{
loaded
++
;
loaded
++
;
onProgress
&&
onProgress
(
loaded
,
total
);
onProgress
&&
onProgress
(
loaded
,
total
);
},
},
(
error
)
=>
{
(
error
)
=>
{
failedList
.
push
(
assetConfig
.
url
);
failedList
.
push
(
assetConfig
.
url
);
}
}
);
);
}
else
{
}
else
{
loaded
++
;
loaded
++
;
onProgress
&&
onProgress
(
loaded
,
total
);
onProgress
&&
onProgress
(
loaded
,
total
);
return
Promise
.
resolve
();
return
Promise
.
resolve
();
...
@@ -64,14 +64,29 @@ export function loadAssets(config, onProgress?, onComplete?) {
...
@@ -64,14 +64,29 @@ export function loadAssets(config, onProgress?, onComplete?) {
* 根据uuid获取素材配置
* 根据uuid获取素材配置
* @param uuid
* @param uuid
*/
*/
export
function
getAssetByUUID
(
uuid
)
{
export
function
getAssetByUUID
(
uuid
)
:
any
{
return
arrayFind
(
assetsConfig
,
item
=>
item
.
uuid
===
uuid
);
return
arrayFind
(
assetsConfig
,
item
=>
item
.
uuid
===
uuid
);
}
}
/**
/**
* 根据name获取素材配置
* 根据name获取素材配置
* @param name
* @param name
*/
*/
export
function
getAssetByName
(
name
)
{
export
function
getAssetByName
(
name
):
any
{
return
arrayFind
(
assetsConfig
,
item
=>
item
.
name
===
name
);
let
result
=
arrayFind
(
assetsConfig
,
item
=>
item
.
name
===
name
);
if
(
result
)
{
return
result
;
}
else
{
for
(
let
assetConfig
of
assetsConfig
)
{
let
res
=
engine
.
globalLoader
.
get
(
assetConfig
.
url
);
if
(
res
&&
res
.
frames
)
{
for
(
let
key
in
res
.
frames
)
{
const
frame
=
res
.
frames
[
key
];
if
(
frame
.
name
===
name
)
{
return
{
url
:
key
};
}
}
}
}
}
}
}
src/zeroing/game-warpper/data-center.ts
View file @
03035a71
...
@@ -24,7 +24,7 @@ export class DataCenter extends EventDispatcher {
...
@@ -24,7 +24,7 @@ export class DataCenter extends EventDispatcher {
* @param origin
* @param origin
*/
*/
registerGroup
(
name
,
origin
?)
{
registerGroup
(
name
,
origin
?)
{
return
this
.
store
[
name
]
=
origin
||
{}
;
return
this
.
store
[
name
]
=
origin
===
undefined
?
{}
:
origin
;
}
}
/**
/**
...
@@ -50,7 +50,13 @@ export class DataCenter extends EventDispatcher {
...
@@ -50,7 +50,13 @@ export class DataCenter extends EventDispatcher {
* @param throwException
* @param throwException
*/
*/
getDataByPath
(
path
,
groupName
?,
throwException
?)
{
getDataByPath
(
path
,
groupName
?,
throwException
?)
{
let
scope
=
groupName
===
undefined
?
this
.
store
:
this
.
getGroup
(
groupName
)
||
this
.
store
;
let
scope
;
if
(
groupName
===
undefined
)
{
scope
=
this
.
store
;
}
else
{
let
group
=
this
.
getGroup
(
groupName
);
scope
=
group
===
undefined
?
this
.
store
:
group
;
}
return
getDataByPath
(
scope
,
path
,
throwException
);
return
getDataByPath
(
scope
,
path
,
throwException
);
}
}
...
@@ -101,7 +107,7 @@ export class DataCenter extends EventDispatcher {
...
@@ -101,7 +107,7 @@ export class DataCenter extends EventDispatcher {
* @param dispatch
* @param dispatch
*/
*/
increase
(
groupName
,
step
?,
path
?,
dispatch
=
true
)
{
increase
(
groupName
,
step
?,
path
?,
dispatch
=
true
)
{
if
(
step
<
0
||
step
>
0
)
{
if
(
step
<
0
||
step
>
0
)
{
let
data
:
any
=
this
.
getDataByPath
(
path
,
groupName
);
let
data
:
any
=
this
.
getDataByPath
(
path
,
groupName
);
if
(
data
===
undefined
)
{
if
(
data
===
undefined
)
{
data
=
0
;
data
=
0
;
...
@@ -122,6 +128,9 @@ export class DataCenter extends EventDispatcher {
...
@@ -122,6 +128,9 @@ export class DataCenter extends EventDispatcher {
* @param dispatch
* @param dispatch
*/
*/
mutate
(
groupName
,
data
?,
path
?,
dispatch
=
true
)
{
mutate
(
groupName
,
data
?,
path
?,
dispatch
=
true
)
{
if
(
!
groupName
)
{
return
;
}
let
group
=
this
.
getGroup
(
groupName
);
let
group
=
this
.
getGroup
(
groupName
);
if
(
!
group
)
{
if
(
!
group
)
{
...
...
src/zeroing/game-warpper/nodes/TextInput.ts
View file @
03035a71
...
@@ -7,15 +7,23 @@ import {Event} from "../../../2d/events/Event";
...
@@ -7,15 +7,23 @@ import {Event} from "../../../2d/events/Event";
import
{
FloatDisplay
}
from
"../../../2d/display/FloatDisplay"
;
import
{
FloatDisplay
}
from
"../../../2d/display/FloatDisplay"
;
import
{
TextField
}
from
"../../../2d/text"
;
import
{
TextField
}
from
"../../../2d/text"
;
import
{
Point
}
from
"../../../2d/math"
;
import
{
Point
}
from
"../../../2d/math"
;
import
{
dirtyFieldTrigger
}
from
"../../decorators"
;
import
{
VERTICAL_ALIGN
}
from
"../../.."
;
import
{
VERTICAL_ALIGN
}
from
"../../.."
;
export
class
TextInput
extends
Label
{
export
class
TextInput
extends
Label
{
private
_floatDisplay
:
FloatDisplay
;
private
_floatDisplay
:
FloatDisplay
;
private
_placeholderLabel
:
TextField
;
private
_placeholderLabel
:
TextField
;
private
_input
:
any
;
private
_input
:
any
;
private
_placeholder
:
string
=
''
;
@
dirtyFieldTrigger
private
_placeholderColor
:
any
=
'#666666'
;
placeholder
:
string
;
private
_maxLength
:
number
;
@
dirtyFieldTrigger
placeholderColor
:
any
=
'#666666'
;
@
dirtyFieldTrigger
maxLength
:
number
;
@
dirtyFieldTrigger
type
:
string
=
'text'
;
@
dirtyFieldTrigger
pattern
:
string
;
private
_oldFillColor
;
private
_oldFillColor
;
private
_oldStrokeColor
;
private
_oldStrokeColor
;
...
@@ -30,32 +38,21 @@ export class TextInput extends Label {
...
@@ -30,32 +38,21 @@ export class TextInput extends Label {
this
.
text
=
''
;
this
.
text
=
''
;
}
}
get
placeholder
():
string
{
onModify
(
value
,
key
)
{
return
this
.
_placeholder
;
switch
(
key
)
{
}
case
'placeholder'
:
if
(
this
.
_placeholderLabel
)
{
set
placeholder
(
value
:
string
)
{
this
.
_placeholderLabel
.
text
=
value
;
this
.
_placeholder
=
value
;
}
this
.
_placeholderLabel
.
text
=
value
;
break
;
}
case
'placeholderColor'
:
if
(
this
.
_placeholderLabel
)
{
get
placeholderColor
():
any
{
this
.
_placeholderLabel
.
fillColor
=
value
;
return
this
.
_placeholderColor
;
}
}
break
;
case
'maxLength'
:
set
placeholderColor
(
value
:
any
)
{
this
.
setMaxLength
();
this
.
_placeholderColor
=
value
;
break
;
this
.
_placeholderLabel
.
fillColor
=
value
;
}
get
maxLength
():
number
{
return
this
.
_maxLength
;
}
set
maxLength
(
value
:
number
)
{
if
(
this
.
_maxLength
!=
value
){
this
.
_maxLength
=
value
;
this
.
setMaxLength
();
}
}
}
}
...
@@ -76,7 +73,7 @@ export class TextInput extends Label {
...
@@ -76,7 +73,7 @@ export class TextInput extends Label {
input
.
addEventListener
(
'blur'
,
this
.
onBlur
);
input
.
addEventListener
(
'blur'
,
this
.
onBlur
);
let
pl
=
this
.
_placeholderLabel
=
new
TextField
();
let
pl
=
this
.
_placeholderLabel
=
new
TextField
();
pl
.
fillColor
=
this
.
_
placeholderColor
;
pl
.
fillColor
=
this
.
placeholderColor
;
this
.
verticalAlign
=
pl
.
verticalAlign
=
VERTICAL_ALIGN
.
MIDDLE
;
this
.
verticalAlign
=
pl
.
verticalAlign
=
VERTICAL_ALIGN
.
MIDDLE
;
...
@@ -95,7 +92,7 @@ export class TextInput extends Label {
...
@@ -95,7 +92,7 @@ export class TextInput extends Label {
private
setMaxLength
()
{
private
setMaxLength
()
{
let
value
=
this
.
_text
;
let
value
=
this
.
_text
;
let
maxLength
=
this
.
_
maxLength
;
let
maxLength
=
this
.
maxLength
;
if
(
maxLength
>
0
&&
value
&&
value
.
length
>
maxLength
)
{
if
(
maxLength
>
0
&&
value
&&
value
.
length
>
maxLength
)
{
this
.
text
=
value
.
substr
(
0
,
maxLength
);
this
.
text
=
value
.
substr
(
0
,
maxLength
);
}
}
...
@@ -103,14 +100,14 @@ export class TextInput extends Label {
...
@@ -103,14 +100,14 @@ export class TextInput extends Label {
private
showPlaceholderLabel
(
value
)
{
private
showPlaceholderLabel
(
value
)
{
let
pl
=
this
.
_placeholderLabel
;
let
pl
=
this
.
_placeholderLabel
;
if
(
value
)
{
if
(
value
)
{
let
pl
=
this
.
_placeholderLabel
;
let
pl
=
this
.
_placeholderLabel
;
if
(
pl
.
parent
)
{
if
(
pl
.
parent
)
{
pl
.
parent
.
removeChild
(
pl
);
pl
.
parent
.
removeChild
(
pl
);
}
}
}
else
{
}
else
{
if
(
!
pl
.
parent
)
{
if
(
!
pl
.
parent
)
{
pl
.
text
=
this
.
_
placeholder
;
pl
.
text
=
this
.
placeholder
;
pl
.
size
=
this
.
size
;
pl
.
size
=
this
.
size
;
pl
.
font
=
this
.
font
;
pl
.
font
=
this
.
font
;
this
.
addChildAt
(
pl
,
0
);
this
.
addChildAt
(
pl
,
0
);
...
@@ -147,12 +144,23 @@ export class TextInput extends Label {
...
@@ -147,12 +144,23 @@ export class TextInput extends Label {
this
.
_floatDisplay
.
alpha
=
1
;
this
.
_floatDisplay
.
alpha
=
1
;
input
.
style
.
pointerEvents
=
'auto'
;
input
.
style
.
pointerEvents
=
'auto'
;
if
(
this
.
_maxLength
>
0
){
const
maxLength
=
this
.
maxLength
;
input
.
maxLength
=
this
.
_maxLength
;
if
(
maxLength
>
0
)
{
}
else
{
input
.
maxLength
=
maxLength
;
}
else
{
input
.
removeAttribute
(
'maxLength'
)
input
.
removeAttribute
(
'maxLength'
)
}
}
if
(
this
.
pattern
)
{
input
.
pattern
=
this
.
pattern
;
}
else
{
input
.
removeAttribute
(
'pattern'
)
}
if
(
this
.
type
)
{
input
.
type
=
this
.
type
;
}
input
.
focus
();
input
.
focus
();
this
.
dispatchEvent
(
Event
.
FOCUS
);
this
.
dispatchEvent
(
Event
.
FOCUS
);
...
@@ -178,8 +186,8 @@ export class TextInput extends Label {
...
@@ -178,8 +186,8 @@ export class TextInput extends Label {
this
.
setBlur
();
this
.
setBlur
();
};
};
private
onClickStage
(
e
){
private
onClickStage
(
e
)
{
if
(
e
.
currentTarget
!==
this
)
{
if
(
e
.
currentTarget
!==
this
)
{
this
.
setBlur
();
this
.
setBlur
();
}
}
}
}
...
...
src/zeroing/game-warpper/sound.ts
View file @
03035a71
...
@@ -7,35 +7,59 @@ import {injectProperties} from "../utils";
...
@@ -7,35 +7,59 @@ import {injectProperties} from "../utils";
const
instances
=
{};
const
instances
=
{};
export
function
playSound
(
uuid
,
options
=
{},
name
?)
{
export
function
playSound
(
uuid
,
options
:
any
=
{},
name
?)
{
let
assetConfig
=
getAssetByUUID
(
uuid
);
let
assetConfig
=
getAssetByUUID
(
uuid
);
if
(
assetConfig
)
{
if
(
assetConfig
)
{
let
url
=
assetConfig
.
url
;
let
url
=
assetConfig
.
url
;
let
opts
:
any
=
{
let
opts
:
any
=
{
src
:
[
url
],
src
:
[
url
],
autoplay
:
tru
e
,
autoplay
:
fals
e
,
};
};
injectProperties
(
opts
,
options
);
injectProperties
(
opts
,
options
);
let
sound
=
new
Howl
(
opts
)
;
const
key
=
name
||
uuid
;
if
(
name
!==
undefined
)
{
const
{
keep
=
false
}
=
opts
;
instances
[
name
]
=
sound
;
let
sound
;
if
(
keep
)
{
const
data
=
instances
[
key
];
if
(
data
)
{
sound
=
data
.
sound
;
}
}
if
(
!
sound
)
{
sound
=
new
Howl
(
opts
);
}
instances
[
key
]
=
{
sound
,
keep
,
};
if
(
!
keep
)
{
sound
.
on
(
'end'
,
function
()
{
sound
.
on
(
'end'
,
function
()
{
de
lete
instances
[
name
]
;
de
stroySound
(
key
)
;
});
});
}
}
sound
.
play
();
return
sound
;
return
sound
;
}
}
}
}
export
function
stopSound
(
name
){
export
function
stopSound
(
name
)
{
let
sound
=
instances
[
name
];
let
{
sound
,
keep
}
=
instances
[
name
];
if
(
sound
)
{
if
(
sound
)
{
sound
.
stop
();
sound
.
stop
();
delete
instances
[
name
];
if
(
!
keep
)
{
destroySound
(
name
);
}
}
}
}
}
export
function
destroySound
(
name
)
{
delete
instances
[
name
];
}
src/zeroing/index.ts
View file @
03035a71
...
@@ -11,10 +11,11 @@ export * from './game-warpper'
...
@@ -11,10 +11,11 @@ export * from './game-warpper'
export
*
from
'./behavior-runtime'
export
*
from
'./behavior-runtime'
export
*
from
'./web'
export
*
from
'./web'
export
*
from
'./log-switch'
export
*
from
'./log-switch'
import
{
instantiate
}
from
'./game-warpper/view-interpreter'
import
{
instantiate
,
registerNodeType
}
from
'./game-warpper/view-interpreter'
export
{
Howl
,
Howler
}
from
'howler'
;
export
{
Howl
,
Howler
}
from
'howler'
;
export
{
export
{
instantiate
instantiate
,
registerNodeType
,
}
}
src/zeroing/launcher.ts
View file @
03035a71
...
@@ -8,17 +8,18 @@ import {GameStage} from "./game-warpper";
...
@@ -8,17 +8,18 @@ import {GameStage} from "./game-warpper";
import
{
setGlobalContext
}
from
"./behavior-runtime"
;
import
{
setGlobalContext
}
from
"./behavior-runtime"
;
import
{
globalLoader
}
from
"../2d/loader/Loader"
;
import
{
globalLoader
}
from
"../2d/loader/Loader"
;
import
{
Event
}
from
"../2d/events/Event"
;
import
{
Event
}
from
"../2d/events/Event"
;
import
builtinLoadingView
from
"./game-warpper/LoadingView"
;
export
let
gameStage
:
GameStage
;
export
let
gameStage
:
GameStage
;
export
function
launch
(
url
,
onAssetsProgress
,
onAssetsComplete
,
onStart
)
{
export
function
launch
(
url
,
loadingDelegate
?,
onStart
?
)
{
return
globalLoader
.
loadJson
(
url
)
return
globalLoader
.
loadJson
(
url
)
.
then
(
config
=>
{
.
then
(
config
=>
{
return
launchWithConfig
(
config
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
);
return
launchWithConfig
(
config
,
loadingDelega
te
,
onStart
);
});
});
}
}
export
function
launchWithLocalStorage
(
id
,
onAssetsProgress
,
onAssetsComplete
,
onStart
)
{
export
function
launchWithLocalStorage
(
id
,
loadingDelegate
?,
onStart
?
)
{
const
storeKey
=
'preview-project-'
+
id
;
const
storeKey
=
'preview-project-'
+
id
;
let
storeData
=
localStorage
.
getItem
(
storeKey
);
let
storeData
=
localStorage
.
getItem
(
storeKey
);
let
{
data
,
processes
,
scripts
,
customs
,}
=
JSON
.
parse
(
storeData
);
let
{
data
,
processes
,
scripts
,
customs
,}
=
JSON
.
parse
(
storeData
);
...
@@ -27,10 +28,20 @@ export function launchWithLocalStorage(id, onAssetsProgress, onAssetsComplete, o
...
@@ -27,10 +28,20 @@ export function launchWithLocalStorage(id, onAssetsProgress, onAssetsComplete, o
registerScripts
(
scripts
);
registerScripts
(
scripts
);
registerCustomModuleFromConfig
(
customs
);
registerCustomModuleFromConfig
(
customs
);
return
launchWithConfig
(
data
,
onAssetsProgress
,
onAssetsComple
te
,
onStart
);
return
launchWithConfig
(
data
,
loadingDelega
te
,
onStart
);
}
}
export
function
launchWithConfig
(
config
,
onAssetsProgress
,
onAssetsComplete
,
onStart
)
{
export
function
launchWithWindowVariable
(
name
,
loadingDelegate
?,
onStart
?)
{
let
{
data
,
processes
,
scripts
,
customs
,}
=
window
[
name
];
setProcessMetaLibs
(
processes
);
registerScripts
(
scripts
);
registerCustomModuleFromConfig
(
customs
);
return
launchWithConfig
(
data
,
loadingDelegate
,
onStart
);
}
export
function
launchWithConfig
(
config
,
loadingDelegate
?,
onStart
?)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
const
{
containerId
,
designWidth
,
designHeight
,
frameRate
,
scaleMode
,
rendererType
,}
=
config
.
options
;
const
{
containerId
,
designWidth
,
designHeight
,
frameRate
,
scaleMode
,
rendererType
,}
=
config
.
options
;
let
stage
=
window
[
'stage'
]
=
new
Stage
(
let
stage
=
window
[
'stage'
]
=
new
Stage
(
...
@@ -39,7 +50,7 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete, onS
...
@@ -39,7 +50,7 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete, onS
designHeight
||
1334
,
designHeight
||
1334
,
frameRate
||
60
,
frameRate
||
60
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
scaleMode
||
StageScaleMode
.
FIXED_WIDTH
,
rendererType
||
RENDERER_TYPE
.
WEBGL
rendererType
||
RENDERER_TYPE
.
WEBGL
,
);
);
Stage
.
flushAll
();
Stage
.
flushAll
();
...
@@ -50,7 +61,13 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete, onS
...
@@ -50,7 +61,13 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete, onS
});
});
stage
.
addChild
(
gameStage
);
stage
.
addChild
(
gameStage
);
gameStage
.
launch
(
config
,
onAssetsProgress
,
onAssetsComplete
,
onStart
);
let
delegate
=
loadingDelegate
||
builtinLoadingView
;
gameStage
.
launch
(
config
,
function
(
done
,
total
){
delegate
.
onProgress
&&
delegate
.
onProgress
(
done
,
total
)
},
function
(){
delegate
.
onComplete
&&
delegate
.
onComplete
();
},
onStart
);
});
});
resolve
(
gameStage
);
resolve
(
gameStage
);
...
...
src/zeroing/node-utils.ts
deleted
100644 → 0
View file @
f70709ec
/**
* Created by rockyl on 2019-11-13.
*/
export
function
findNodeByUUID
(
node
,
uuid
)
{
if
(
node
.
uuid
===
uuid
)
{
return
node
;
}
if
(
node
.
children
&&
node
.
children
.
length
>
0
){
for
(
let
child
of
node
.
children
)
{
let
target
=
findNodeByUUID
(
child
,
uuid
);
if
(
target
)
{
return
target
;
}
}
}
}
src/zeroing/utils/utils.ts
View file @
03035a71
...
@@ -134,6 +134,10 @@ export function obj2query(obj: any): string {
...
@@ -134,6 +134,10 @@ export function obj2query(obj: any): string {
return
arr
.
join
(
'&'
);
return
arr
.
join
(
'&'
);
}
}
function
requireForCJS
(
id
){
return
window
[
id
];
}
/**
/**
* 导入cjs包装的代码
* 导入cjs包装的代码
* @param code
* @param code
...
@@ -141,11 +145,11 @@ export function obj2query(obj: any): string {
...
@@ -141,11 +145,11 @@ export function obj2query(obj: any): string {
*/
*/
export
function
importCJSCode
(
code
,
node
?)
{
export
function
importCJSCode
(
code
,
node
?)
{
if
(
node
)
{
if
(
node
)
{
let
create
=
new
Function
(
'module'
,
code
);
let
create
=
new
Function
(
'module'
,
'require'
,
code
);
let
module
=
{
let
module
=
{
exports
:
{},
exports
:
{},
};
};
create
(
module
);
create
(
module
,
requireForCJS
);
return
module
.
exports
;
return
module
.
exports
;
}
else
{
}
else
{
let
create
=
new
Function
(
'exports'
,
code
);
let
create
=
new
Function
(
'exports'
,
code
);
...
@@ -253,7 +257,7 @@ export function strShort(str, limit, replace = '…'){
...
@@ -253,7 +257,7 @@ export function strShort(str, limit, replace = '…'){
export
function
instantiateScript
(
node
,
ScriptConfig
)
{
export
function
instantiateScript
(
node
,
ScriptConfig
)
{
const
{
script
:
scriptName
,
props
,
disabled
}
=
ScriptConfig
;
const
{
script
:
scriptName
,
props
,
disabled
}
=
ScriptConfig
;
const
script
=
node
.
scripts
Proxy
.
add
(
scriptName
,
props
,
disabled
);
const
script
=
node
.
scripts
.
add
(
scriptName
,
props
,
disabled
);
}
}
export
function
injectProperties
(
target
,
source
)
{
export
function
injectProperties
(
target
,
source
)
{
...
...
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