FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
phaser/scripts/bundle-shaders.js at master · phaserjs/phaser · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
phaserjs
/
phaser
Public
Notifications
You must be signed in to change notification settings
Fork
7.2k
Star
40.2k
Code
Issues
108
Pull requests
23
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
phaser
/
scripts
/
bundle-shaders.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (75 loc) · 2.01 KB
Breadcrumbs
phaser
/
scripts
/
bundle-shaders.js
Copy path
File metadata and controls
102 lines (75 loc) · 2.01 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
let
fs
=
require
(
'fs-extra'
)
;
let
srcdir
=
'./src/renderer/webgl/shaders/src/'
;
let
destdir
=
'./src/renderer/webgl/shaders/'
;
let
files
=
fs
.
readdirSync
(
srcdir
)
;
let
index
=
`/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2026 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Renderer.WebGL.Shaders
*/
module.exports = {
`
;
files
.
forEach
(
function
(
file
,
c
)
{
let
shaderSource
=
fs
.
readFileSync
(
srcdir
+
file
,
'utf8'
)
;
let
type
=
file
.
substr
(
-
4
)
;
let
shaderFilename
=
file
.
substr
(
0
,
file
.
lastIndexOf
(
'.'
)
)
+
'-'
+
type
+
'.js'
;
let
outputSource
=
'module.exports = [\n'
;
let
lines
=
shaderSource
.
split
(
'\n'
)
;
for
(
var
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
let
line
=
lines
[
i
]
.
trimRight
(
)
;
if
(
line
==
''
||
line
.
trimStart
(
)
.
startsWith
(
'//'
)
)
{
continue
;
}
if
(
i
<
lines
.
length
-
1
)
{
outputSource
=
outputSource
.
concat
(
" '"
+
line
+
"',\n"
)
;
}
else
{
outputSource
=
outputSource
.
concat
(
" '"
+
line
+
"'\n"
)
;
}
}
outputSource
=
outputSource
.
concat
(
'].join(\'\\n\');\n'
)
;
fs
.
writeFile
(
destdir
+
shaderFilename
,
outputSource
,
function
(
error
)
{
if
(
error
)
{
throw
error
;
}
else
{
console
.
log
(
'Saved'
,
shaderFilename
)
;
}
}
)
;
let
inc
=
file
.
substr
(
0
,
file
.
lastIndexOf
(
'.'
)
)
;
if
(
file
.
substr
(
-
4
)
===
'frag'
)
{
inc
=
inc
.
concat
(
'Frag'
)
;
}
else
if
(
file
.
substr
(
-
4
)
===
'vert'
)
{
inc
=
inc
.
concat
(
'Vert'
)
;
}
index
=
index
.
concat
(
`
${
inc
}
: require('./
${
shaderFilename
}
')`
)
;
if
(
c
<
files
.
length
-
1
)
{
index
=
index
.
concat
(
',\n'
)
;
}
}
)
;
index
=
index
.
concat
(
`
};
`
)
;
fs
.
writeFile
(
destdir
+
'index.js'
,
index
,
function
(
error
)
{
if
(
error
)
{
throw
error
;
}
else
{
console
.
log
(
'Index Saved'
)
;
}
}
)
;
Back
|
FazBrowse Home
|
New Git URL