Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
50bc249f
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,发现更多精彩内容 >>
提交
50bc249f
编写于
12月 17, 2017
作者:
T
Tentone
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GCode loader example
上级
c79d27fb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
103 addition
and
7 deletion
+103
-7
examples/js/loaders/GCodeLoader.js
examples/js/loaders/GCodeLoader.js
+7
-7
examples/webgl_loader_gcode.html
examples/webgl_loader_gcode.html
+96
-0
未找到文件。
examples/js/loaders/GCodeLoader.js
浏览文件 @
50bc249f
"
use strict
"
;
/**
* GCodeLoader is used to load gcode files usually used for 3D printing or CNC applications.
*
THREE.
GCodeLoader is used to load gcode files usually used for 3D printing or CNC applications.
*
* Gcode files are composed by commands used by machines to create objects.
*
* @class GCodeLoader
* @class
THREE.
GCodeLoader
* @param {Manager} manager Loading manager.
* @author tentone
*/
function
GCodeLoader
(
manager
)
THREE
.
GCodeLoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
}
GCodeLoader
.
prototype
.
load
=
function
(
url
,
onLoad
,
onProgress
,
onError
)
THREE
.
GCodeLoader
.
prototype
.
load
=
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
var
self
=
this
;
...
...
@@ -28,7 +28,7 @@ GCodeLoader.prototype.load = function(url, onLoad, onProgress, onError)
},
onProgress
,
onError
);
};
GCodeLoader
.
prototype
.
parse
=
function
(
data
)
THREE
.
GCodeLoader
.
prototype
.
parse
=
function
(
data
)
{
var
currentState
=
{
x
:
0
,
y
:
0
,
z
:
0
,
e
:
0
,
f
:
0
,
extruding
:
false
};
var
currentLayer
=
undefined
;
...
...
@@ -149,7 +149,7 @@ GCodeLoader.prototype.parse = function(data)
//G2/G3 - Arc Movement (G2 clock wise and G3 counter clock wise)
else
if
(
cmd
===
"
G2
"
||
cmd
===
"
G3
"
)
{
console
.
warn
(
"
GCodeLoader: Arc command not supported
"
);
console
.
warn
(
"
THREE.
GCodeLoader: Arc command not supported
"
);
}
//G90: Set to Absolute Positioning
else
if
(
cmd
===
"
G90
"
)
...
...
@@ -173,7 +173,7 @@ GCodeLoader.prototype.parse = function(data)
}
else
{
console
.
warn
(
"
GCodeLoader: Command not supported:
"
+
cmd
);
console
.
warn
(
"
THREE.
GCodeLoader: Command not supported:
"
+
cmd
);
}
}
...
...
examples/webgl_loader_gcode.html
0 → 100644
浏览文件 @
50bc249f
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - loaders - GCode loader
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
font-family
:
Monospace
;
background-color
:
#000
;
color
:
#fff
;
margin
:
0px
;
overflow
:
hidden
;
}
#info
{
color
:
#fff
;
position
:
absolute
;
top
:
10px
;
width
:
100%
;
text-align
:
center
;
z-index
:
100
;
display
:
block
;
}
#info
a
,
.button
{
color
:
#f00
;
font-weight
:
bold
;
text-decoration
:
underline
;
cursor
:
pointer
}
</style>
</head>
<body>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
three.js
</a>
- GCode loader
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/controls/OrbitControls.js"
></script>
<script
src=
"js/loaders/GCodeLoader.js"
></script>
<script>
var
container
,
controls
;
var
camera
,
scene
,
renderer
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
0.1
,
10000
);
camera
.
position
.
set
(
0
,
0
,
50
);
controls
=
new
THREE
.
OrbitControls
(
camera
);
scene
=
new
THREE
.
Scene
();
var
loader
=
new
THREE
.
GCodeLoader
(
);
loader
.
load
(
'
models/gcode/benchy.gcode
'
,
function
(
object
)
{
object
.
position
.
set
(
-
100
,
-
20
,
100
);
object
.
rotation
.
set
(
-
Math
.
PI
/
2
,
0
,
0
);
scene
.
add
(
object
);
});
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
window
.
addEventListener
(
'
resize
'
,
resize
,
false
);
}
function
resize
()
{
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
function
animate
()
{
controls
.
update
();
renderer
.
render
(
scene
,
camera
);
requestAnimationFrame
(
animate
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录