Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
44b89989
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,发现更多精彩内容 >>
提交
44b89989
编写于
2月 09, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
APP: Added event.delta.
上级
87312c64
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
11 deletion
+15
-11
editor/examples/arkanoid.app.json
editor/examples/arkanoid.app.json
+5
-4
editor/examples/pong.app.json
editor/examples/pong.app.json
+4
-4
editor/js/Sidebar.Script.js
editor/js/Sidebar.Script.js
+1
-1
editor/js/libs/app.js
editor/js/libs/app.js
+5
-2
未找到文件。
editor/examples/arkanoid.app.json
100644 → 100755
浏览文件 @
44b89989
...
...
@@ -6,7 +6,7 @@
"generator"
:
"ObjectExporter"
},
"object"
:
{
"uuid"
:
"
A32F9E56-4DDC-442E-8A0D-F23B9E93EEA9
"
,
"uuid"
:
"
8EFB9C06-6312-4975-B04A-C9E4549BE348
"
,
"type"
:
"PerspectiveCamera"
,
"name"
:
"Camera"
,
"fov"
:
50
,
...
...
@@ -107,7 +107,7 @@
"name"
:
"Ground"
,
"geometry"
:
"8F05A1F2-3877-478B-8DFC-F572AC61AB3A"
,
"material"
:
"2F69AF3A-DDF5-4BBA-87B5-80159F90DDBF"
,
"matrix"
:
[
1
,
0
,
0
,
0
,
0
,
0.0007962
886593304574
,
-0.9999997019767761
,
0
,
0
,
0.9999997019767761
,
0.0007962886593304574
,
0
,
0
,
0
,
0
,
1
]
"matrix"
:
[
1
,
0
,
0
,
0
,
0
,
0.0007962
50649727881
,
-0.9999997019767761
,
0
,
0
,
0.9999997019767761
,
0.000796250649727881
,
0
,
0
,
0
,
0
,
1
]
},
{
"uuid"
:
"6EE2E764-43E0-48E0-85F2-E0C8823C20DC"
,
...
...
@@ -148,6 +148,7 @@
"color"
:
16777215
,
"intensity"
:
1
,
"distance"
:
0
,
"decay"
:
1
,
"matrix"
:
[
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
-116.54356384277344
,
69.48957061767578
,
-206.8248291015625
,
1
]
}]
}
...
...
@@ -161,7 +162,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.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
}"
"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(
event.delta /
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
editor/examples/pong.app.json
100644 → 100755
浏览文件 @
44b89989
...
...
@@ -6,7 +6,7 @@
"generator"
:
"ObjectExporter"
},
"object"
:
{
"uuid"
:
"
E5C76691-3D55-4E26-862E-24BADC21F4D7
"
,
"uuid"
:
"
8EFB9C06-6312-4975-B04A-C9E4549BE348
"
,
"type"
:
"PerspectiveCamera"
,
"name"
:
"Camera"
,
"fov"
:
50
,
...
...
@@ -88,7 +88,7 @@
"name"
:
"Ground"
,
"geometry"
:
"77B20ED1-2871-4B14-A652-8F823B2A817E"
,
"material"
:
"7EDF7C08-6325-418A-BBAB-89341C694730"
,
"matrix"
:
[
1
,
0
,
0
,
0
,
0
,
0.000796
1748051457107
,
-0.9999997019767761
,
0
,
0
,
0.9999997019767761
,
0.0007961748051457107
,
0
,
0
,
-10
,
0
,
1
]
"matrix"
:
[
1
,
0
,
0
,
0
,
0
,
0.000796
0614748299122
,
-0.9999997019767761
,
0
,
0
,
0.9999997019767761
,
0.0007960614748299122
,
0
,
0
,
-10
,
0
,
1
]
},
{
"uuid"
:
"CE13E58A-4E8B-4F72-9E2E-7DE57C58F989"
,
...
...
@@ -128,7 +128,7 @@
"31517222-A9A7-4EAF-B5F6-60751C0BABA3"
:
[
{
"name"
:
"Game logic"
,
"source"
:
"var ball = this.getObjectByName( 'Ball' );
\n\n
var position = ball.position;
\n\n
var velocity = new THREE.Vector3();
\n\n
var direction = new THREE.Vector3();
\n
direction.x = Math.random() - 0.5;
\n
direction.z = Math.random() - 0.5;
\n
direction.normalize();
\n\n
var pad1 = this.getObjectByName( 'Pad 1' );
\n
var pad2 = this.getObjectByName( 'Pad 2' );
\n\n
var raycaster = new THREE.Raycaster();
\n
var objects = [ pad1, pad2 ];
\n\n
//
\n\n
function mousemove( event ) {
\n\n\t
pad1.position.z = ( event.clientX / player.width ) * 300 - 150;
\n\t
pad2.position.z = - pad1.position.z;
\n\n
}
\n\n
function update( event ) {
\n\n\t
if ( position.x < -300 || position.x > 300 ) {
\n\t\t\n\t\t
direction.x = - direction.x;
\n\t\t\n\t
}
\n\n\t
if ( position.z < -200 || position.z > 200 ) {
\n\t\t\n\t\t
direction.z = - direction.z;
\n\t\t\n\t
}
\n\t\n\t
raycaster.set( position, direction );
\n\t\n\t
var intersections = raycaster.intersectObjects( objects );
\n\t\n\t
if ( intersections.length > 0 ) {
\n\n\t\t
var intersection = intersections[ 0 ];
\n\t\t\n\t\t
if ( intersection.distance < 10 ) {
\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\t
position.add( velocity.copy( direction ).multiplyScalar(
8
) );
\n\n
}"
"source"
:
"var ball = this.getObjectByName( 'Ball' );
\n\n
var position = ball.position;
\n\n
var velocity = new THREE.Vector3();
\n\n
var direction = new THREE.Vector3();
\n
direction.x = Math.random() - 0.5;
\n
direction.z = Math.random() - 0.5;
\n
direction.normalize();
\n\n
var pad1 = this.getObjectByName( 'Pad 1' );
\n
var pad2 = this.getObjectByName( 'Pad 2' );
\n\n
var raycaster = new THREE.Raycaster();
\n
var objects = [ pad1, pad2 ];
\n\n
//
\n\n
function mousemove( event ) {
\n\n\t
pad1.position.z = ( event.clientX / player.width ) * 300 - 150;
\n\t
pad2.position.z = - pad1.position.z;
\n\n
}
\n\n
function update( event ) {
\n\n\t
if ( position.x < -300 || position.x > 300 ) {
\n\t\t\n\t\t
direction.x = - direction.x;
\n\t\t\n\t
}
\n\n\t
if ( position.z < -200 || position.z > 200 ) {
\n\t\t\n\t\t
direction.z = - direction.z;
\n\t\t\n\t
}
\n\t\n\t
raycaster.set( position, direction );
\n\t\n\t
var intersections = raycaster.intersectObjects( objects );
\n\t\n\t
if ( intersections.length > 0 ) {
\n\n\t\t
var intersection = intersections[ 0 ];
\n\t\t\n\t\t
if ( intersection.distance < 10 ) {
\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\t
position.add( velocity.copy( direction ).multiplyScalar(
event.delta / 2
) );
\n\n
}"
}]
}
}
}
\ No newline at end of file
editor/js/Sidebar.Script.js
浏览文件 @
44b89989
...
...
@@ -84,7 +84,7 @@ Sidebar.Script = function ( editor ) {
}
);
scriptsContainer
.
add
(
remove
);
scriptsContainer
.
add
(
new
UI
.
Break
()
);
}
)(
object
,
scripts
[
i
]
)
...
...
editor/js/libs/app.js
浏览文件 @
44b89989
...
...
@@ -102,16 +102,18 @@ var APP = {
};
var
request
;
var
prevTime
,
request
;
var
animate
=
function
(
time
)
{
request
=
requestAnimationFrame
(
animate
);
dispatch
(
events
.
update
,
{
time
:
time
}
);
dispatch
(
events
.
update
,
{
time
:
time
,
delta
:
time
-
prevTime
}
);
renderer
.
render
(
scene
,
camera
);
prevTime
=
time
;
};
this
.
play
=
function
()
{
...
...
@@ -126,6 +128,7 @@ var APP = {
document
.
addEventListener
(
'
touchmove
'
,
onDocumentTouchMove
);
request
=
requestAnimationFrame
(
animate
);
prevTime
=
performance
.
now
();
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录