Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
cff06616
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
cff06616
编写于
1月 16, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: Minor tweaks to Arkanoid example.
上级
8b31578a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
editor/examples/arkanoid.app.json
editor/examples/arkanoid.app.json
+1
-1
未找到文件。
editor/examples/arkanoid.app.json
浏览文件 @
cff06616
...
...
@@ -165,7 +165,7 @@
"31517222-A9A7-4EAF-B5F6-60751C0BABA3"
:
[
{
"name"
:
"Game Logic"
,
"source"
:
"var ball = this.getObjectByName( 'Ball' );
\n\n
var direction = new THREE.Vector3();
\n
direction.x = Math.random() - 0.5;
\n
direction.z = - 0.5;
\n
direction.normalize();
\n\n
var speed = new THREE.Vector3();
\n\n
//
\n\n
var group = new THREE.Group();
\n
this.add( group );
\n\n
var paddle = this.getObjectByName( 'Paddle' );
\n
group.add( paddle );
\n\n
var brick = this.getObjectByName( 'Brick' );
\n\n
for ( var j = 0; j < 8; j ++
) {
\n\n\t
var material = new THREE.MeshPhongMaterial( { color: Math.random() * 0xffffff } );
\n\n\t
for ( var i = 0; i < 12; i ++ ) {
\n\t\t\n\t\t
var object = brick.clone();
\n\t\t
object.position.x = i * 22 - 120;
\n\t\t
object.position.z = j * 14 - 120;
\n\t\t
object.material = material
;
\n\t\t
group.add( object );
\n\t\t\n\t
}
\n\t\n
}
\n\n
brick.visible = false;
\n\n
//
\n\n
var raycaster = new THREE.Raycaster();
\n\n
function update( event ) {
\n\t\n\t
if ( ball.position.x < - 150 || ball.position.x > 150 ) direction.x = - direction.x;
\n\t
if ( ball.position.z < - 200 || ball.position.z > 200 ) direction.z = - direction.z;
\n\n\t
ball.position.add( speed.copy( direction ).multiplyScalar( 4 ) );
\n\t\n\t
raycaster.set( ball.position, direction );
\n\t\n\t
var intersections = raycaster.intersectObjects( group.children );
\n\t\n\t
if ( intersections.length > 0 ) {
\n\t\n\t\t
var intersection = intersections[ 0 ];
\n\t\t\n\t\t
if ( intersection.distance < 5 ) {
\n\t\t\t\n\t\t\t
if ( intersection.object !== paddle ) {
\n\n\t\t\t\t
group.remove( intersection.object );
\n\t\t\t\t\n\t\t\t
}
\n\t\t\t\n\t\t\t
direction.reflect( intersection.face.normal );
\n\t\t\t\n\t\t
}
\n\t\t\n\t
}
\n\n
}"
"source"
:
"var ball = this.getObjectByName( 'Ball' );
\n\n
var direction = new THREE.Vector3();
\n
direction.x = Math.random() - 0.5;
\n
direction.z = - 0.5;
\n
direction.normalize();
\n\n
var speed = new THREE.Vector3();
\n\n
//
\n\n
var group = new THREE.Group();
\n
this.add( group );
\n\n
var paddle = this.getObjectByName( 'Paddle' );
\n
group.add( paddle );
\n\n
var brick = this.getObjectByName( 'Brick' );
\n\n
for ( var j = 0; j < 8; j ++
) {
\n\n\t
var material = new THREE.MeshPhongMaterial( { color: Math.random() * 0xffffff } );
\n\n\t
for ( var i = 0; i < 12; i ++ ) {
\n\t\t\n\t\t
var object = brick.clone();
\n\t\t
object.material = material;
\n\t\t
object.position.x = i * 22 - 120;
\n\t\t
object.position.z = j * 14 - 120
;
\n\t\t
group.add( object );
\n\t\t\n\t
}
\n\t\n
}
\n\n
brick.visible = false;
\n\n
//
\n\n
var raycaster = new THREE.Raycaster();
\n\n
function update( event ) {
\n\t\n\t
if ( ball.position.x < - 150 || ball.position.x > 150 ) direction.x = - direction.x;
\n\t
if ( ball.position.z < - 200 || ball.position.z > 200 ) direction.z = - direction.z;
\n\n\t
ball.position.add( speed.copy( direction ).multiplyScalar( 4 ) );
\n\t\n\t
raycaster.set( ball.position, direction );
\n\t\n\t
var intersections = raycaster.intersectObjects( group.children );
\n\t\n\t
if ( intersections.length > 0 ) {
\n\t\n\t\t
var intersection = intersections[ 0 ];
\n\t\t\n\t\t
if ( intersection.distance < 5 ) {
\n\t\t\t\n\t\t\t
if ( intersection.object !== paddle ) {
\n\n\t\t\t\t
group.remove( intersection.object );
\n\t\t\t\t\n\t\t\t
}
\n\t\t\t\n\t\t\t
direction.reflect( intersection.face.normal );
\n\t\t\t\n\t\t
}
\n\t\t\n\t
}
\n\n
}"
}]
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录