Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
113e2f06
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
113e2f06
编写于
7月 09, 2015
作者:
T
tschw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: GLSL diagnostics in source code editor.
上级
04de696b
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
297 addition
and
32 deletion
+297
-32
editor/index.html
editor/index.html
+1
-0
editor/js/Script.js
editor/js/Script.js
+95
-32
editor/js/libs/glslprep.min.js
editor/js/libs/glslprep.min.js
+201
-0
未找到文件。
editor/index.html
浏览文件 @
113e2f06
...
...
@@ -44,6 +44,7 @@
<script
src=
"js/libs/codemirror/mode/javascript.js"
></script>
<script
src=
"js/libs/esprima.js"
></script>
<script
src=
"js/libs/jsonlint.js"
></script>
<script
src=
"js/libs/glslprep.min.js"
></script>
<script
src=
"js/libs/codemirror/mode/glsl.js"
></script>
...
...
editor/js/Script.js
浏览文件 @
113e2f06
...
...
@@ -42,6 +42,16 @@ var Script = function ( editor ) {
}
);
header
.
add
(
close
);
var
renderer
;
signals
.
rendererChanged
.
add
(
function
(
newRenderer
)
{
renderer
=
newRenderer
;
}
);
var
delay
;
var
currentMode
;
var
currentScript
;
...
...
@@ -75,26 +85,12 @@ var Script = function ( editor ) {
return
;
}
switch
(
currentScript
)
{
case
'
vertexShader
'
:
currentObject
.
vertexShader
=
value
;
break
;
case
'
fragmentShader
'
:
currentObject
.
fragmentShader
=
value
;
break
;
case
'
programInfo
'
:
if
(
currentScript
!==
'
programInfo
'
)
return
;
var
json
=
JSON
.
parse
(
value
);
currentObject
.
defines
=
json
.
defines
;
currentObject
.
uniforms
=
json
.
uniforms
;
currentObject
.
attributes
=
json
.
attributes
;
}
var
json
=
JSON
.
parse
(
value
);
currentObject
.
defines
=
json
.
defines
;
currentObject
.
uniforms
=
json
.
uniforms
;
currentObject
.
attributes
=
json
.
attributes
;
currentObject
.
needsUpdate
=
true
;
signals
.
materialChanged
.
dispatch
(
currentObject
);
...
...
@@ -118,7 +114,8 @@ var Script = function ( editor ) {
var
validate
=
function
(
string
)
{
var
errors
;
var
valid
;
var
errors
=
[];
return
codemirror
.
operation
(
function
()
{
...
...
@@ -147,10 +144,12 @@ var Script = function ( editor ) {
}
catch
(
error
)
{
errors
=
[
errors
.
push
(
{
lineNumber
:
error
.
lineNumber
-
1
,
message
:
error
.
message
{
lineNumber
:
error
.
lineNumber
,
message
:
error
.
message
}
];
}
);
}
...
...
@@ -171,10 +170,12 @@ var Script = function ( editor ) {
message
=
message
.
split
(
'
\n
'
)[
3
];
errors
.
push
({
lineNumber
:
info
.
loc
.
first_line
,
errors
.
push
(
{
lineNumber
:
info
.
loc
.
first_line
-
1
,
message
:
message
});
}
);
};
...
...
@@ -192,13 +193,75 @@ var Script = function ( editor ) {
case
'
glsl
'
:
// TODO validate GLSL (compiling shader?)
try
{
var
shaderType
=
currentScript
===
'
vertexShader
'
?
glslprep
.
Shader
.
VERTEX
:
glslprep
.
Shader
.
FRAGMENT
;
default
:
glslprep
.
parseGlsl
(
string
,
shaderType
);
errors
=
[];
}
catch
(
error
)
{
}
if
(
error
instanceof
glslprep
.
SyntaxError
)
{
errors
.
push
(
{
lineNumber
:
error
.
line
,
message
:
"
Syntax Error:
"
+
error
.
message
}
);
}
else
{
console
.
error
(
error
.
stack
||
error
);
}
}
if
(
errors
.
length
!==
0
)
break
;
if
(
renderer
instanceof
THREE
.
WebGLRenderer
===
false
)
break
;
currentObject
[
currentScript
]
=
string
;
currentObject
.
needsUpdate
=
true
;
signals
.
materialChanged
.
dispatch
(
currentObject
);
var
programs
=
renderer
.
info
.
programs
;
valid
=
true
;
var
parseMessage
=
/^
(?:
ERROR|WARNING
)
:
\d
+:
(\d
+
)
:
(
.*
)
/g
;
for
(
var
i
=
0
,
n
=
programs
.
length
;
i
!==
n
;
++
i
)
{
var
diagnostics
=
programs
[
i
].
diagnostics
;
if
(
diagnostics
===
undefined
||
diagnostics
.
material
!==
currentObject
)
continue
;
if
(
!
diagnostics
.
runnable
)
valid
=
false
;
var
shaderInfo
=
diagnostics
[
currentScript
];
var
lineOffset
=
shaderInfo
.
prefix
.
split
(
/
\r\n
|
\r
|
\n
/
).
length
;
while
(
true
)
{
var
parseResult
=
parseMessage
.
exec
(
shaderInfo
.
log
);
if
(
parseResult
===
null
)
break
;
errors
.
push
(
{
lineNumber
:
parseResult
[
1
]
-
lineOffset
,
message
:
parseResult
[
2
]
}
);
}
// messages
break
;
}
// programs
}
// mode switch
for
(
var
i
=
0
;
i
<
errors
.
length
;
i
++
)
{
...
...
@@ -208,7 +271,7 @@ var Script = function ( editor ) {
message
.
className
=
'
esprima-error
'
;
message
.
textContent
=
error
.
message
;
var
lineNumber
=
error
.
lineNumber
-
1
;
var
lineNumber
=
Math
.
max
(
error
.
lineNumber
,
0
)
;
errorLines
.
push
(
lineNumber
);
codemirror
.
addLineClass
(
lineNumber
,
'
background
'
,
'
errorLine
'
);
...
...
@@ -219,7 +282,7 @@ var Script = function ( editor ) {
}
return
errorLine
s
.
length
===
0
;
return
valid
!==
undefined
?
valid
:
error
s
.
length
===
0
;
});
...
...
editor/js/libs/glslprep.min.js
0 → 100644
浏览文件 @
113e2f06
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录