Skip to content

Commit 5372c00

Browse files
committed
Editor: Added Arkanoid and fixed pixelRatio breakage.
1 parent 5b728b6 commit 5372c00

File tree

6 files changed

+183
-6
lines changed

6 files changed

+183
-6
lines changed

editor/examples/arkanoid.app.json

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"camera": {
3+
"metadata": {
4+
"version": 4.3,
5+
"type": "Object",
6+
"generator": "ObjectExporter"
7+
},
8+
"object": {
9+
"uuid": "A32F9E56-4DDC-442E-8A0D-F23B9E93EEA9",
10+
"type": "PerspectiveCamera",
11+
"name": "Camera",
12+
"fov": 50,
13+
"aspect": 1.536388140161725,
14+
"near": 0.1,
15+
"far": 100000,
16+
"matrix": [0.9392361044883728,-1.2050817232989175e-8,-0.34327182173728943,0,-0.15080472826957703,0.8983326554298401,-0.41262128949165344,0,0.30837228894233704,0.4393158257007599,0.8437464833259583,0,142.32125854492188,202.75485229492188,389.40936279296875,1]
17+
}
18+
},
19+
"scene": {
20+
"metadata": {
21+
"version": 4.3,
22+
"type": "Object",
23+
"generator": "ObjectExporter"
24+
},
25+
"geometries": [
26+
{
27+
"uuid": "8F05A1F2-3877-478B-8DFC-F572AC61AB3A",
28+
"type": "PlaneGeometry",
29+
"width": 300,
30+
"height": 400,
31+
"widthSegments": 1,
32+
"heightSegments": 1
33+
},
34+
{
35+
"uuid": "7149652B-DBD7-4CB7-A600-27A9AC005C95",
36+
"type": "BoxGeometry",
37+
"width": 20,
38+
"height": 10,
39+
"depth": 10,
40+
"widthSegments": 1,
41+
"heightSegments": 1,
42+
"depthSegments": 1
43+
},
44+
{
45+
"uuid": "CABCC711-1331-4D4C-9FF6-409299F10C68",
46+
"type": "SphereGeometry",
47+
"radius": 5,
48+
"widthSegments": 32,
49+
"heightSegments": 16,
50+
"phiStart": 0,
51+
"phiLength": 6.28,
52+
"thetaStart": 0,
53+
"thetaLength": 3.14
54+
},
55+
{
56+
"uuid": "A1D8B049-74DD-4B08-B5BC-8DCEC9AF0222",
57+
"type": "BoxGeometry",
58+
"width": 40,
59+
"height": 10,
60+
"depth": 10,
61+
"widthSegments": 1,
62+
"heightSegments": 1,
63+
"depthSegments": 1
64+
}],
65+
"materials": [
66+
{
67+
"uuid": "2F69AF3A-DDF5-4BBA-87B5-80159F90DDBF",
68+
"type": "MeshPhongMaterial",
69+
"color": 86015,
70+
"ambient": 16777215,
71+
"emissive": 0,
72+
"specular": 1118481,
73+
"shininess": 30
74+
},
75+
{
76+
"uuid": "CFBEAD4C-6695-4A99-887B-8161E2947225",
77+
"type": "MeshPhongMaterial",
78+
"color": 16777215,
79+
"ambient": 16777215,
80+
"emissive": 0,
81+
"specular": 1118481,
82+
"shininess": 30
83+
},
84+
{
85+
"uuid": "043B208C-1F83-42C6-802C-E0E35621C27C",
86+
"type": "MeshPhongMaterial",
87+
"color": 16777215,
88+
"ambient": 16777215,
89+
"emissive": 0,
90+
"specular": 1118481,
91+
"shininess": 30
92+
},
93+
{
94+
"uuid": "40EC9BDA-91C0-4671-937A-2BCB6DA7EEBB",
95+
"type": "MeshPhongMaterial",
96+
"color": 13486790,
97+
"ambient": 16777215,
98+
"emissive": 0,
99+
"specular": 1118481,
100+
"shininess": 30
101+
}],
102+
"object": {
103+
"uuid": "31517222-A9A7-4EAF-B5F6-60751C0BABA3",
104+
"type": "Scene",
105+
"name": "Scene",
106+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
107+
"children": [
108+
{
109+
"uuid": "EBBB1E63-6318-4752-AE2E-440A4E0B3EF3",
110+
"type": "Mesh",
111+
"name": "Ground",
112+
"geometry": "8F05A1F2-3877-478B-8DFC-F572AC61AB3A",
113+
"material": "2F69AF3A-DDF5-4BBA-87B5-80159F90DDBF",
114+
"matrix": [1,0,0,0,0,0.0007962886593304574,-0.9999997019767761,0,0,0.9999997019767761,0.0007962886593304574,0,0,0,0,1]
115+
},
116+
{
117+
"uuid": "6EE2E764-43E0-48E0-85F2-E0C8823C20DC",
118+
"type": "DirectionalLight",
119+
"name": "DirectionalLight 1",
120+
"color": 16777215,
121+
"intensity": 1,
122+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,100,200,150,1]
123+
},
124+
{
125+
"uuid": "38219749-1E67-45F2-AB15-E64BA0940CAD",
126+
"type": "Mesh",
127+
"name": "Brick",
128+
"geometry": "7149652B-DBD7-4CB7-A600-27A9AC005C95",
129+
"material": "CFBEAD4C-6695-4A99-887B-8161E2947225",
130+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,5,0,1]
131+
},
132+
{
133+
"uuid": "18FFA67C-F893-4E7A-8A76-8D996DEBE0C6",
134+
"type": "Mesh",
135+
"name": "Ball",
136+
"geometry": "CABCC711-1331-4D4C-9FF6-409299F10C68",
137+
"material": "043B208C-1F83-42C6-802C-E0E35621C27C",
138+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,5,35.54999923706055,1]
139+
},
140+
{
141+
"uuid": "6D660D49-39B8-40C3-95F6-E4E007AA8D79",
142+
"type": "Mesh",
143+
"name": "Paddle",
144+
"geometry": "A1D8B049-74DD-4B08-B5BC-8DCEC9AF0222",
145+
"material": "40EC9BDA-91C0-4671-937A-2BCB6DA7EEBB",
146+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,5,159.54217529296875,1]
147+
},
148+
{
149+
"uuid": "B0BEAF69-8B5D-4D87-ADCA-FDE83A02762D",
150+
"type": "PointLight",
151+
"name": "PointLight 2",
152+
"color": 16777215,
153+
"intensity": 1,
154+
"distance": 0,
155+
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,-116.54356384277344,69.48957061767578,-206.8248291015625,1]
156+
}]
157+
}
158+
},
159+
"scripts": {
160+
"6D660D49-39B8-40C3-95F6-E4E007AA8D79": [
161+
{
162+
"name": "User",
163+
"source": "function mousemove( event ) {\n\n\tthis.position.x = ( event.clientX / player.width ) * 300 - 150;\n\n}\n\n// function update( event ) {}"
164+
}],
165+
"31517222-A9A7-4EAF-B5F6-60751C0BABA3": [
166+
{
167+
"name": "Game Logic",
168+
"source": "var ball = this.getObjectByName( 'Ball' );\n\nvar direction = new THREE.Vector3();\ndirection.x = Math.random() - 0.5;\ndirection.z = - 0.5;\ndirection.normalize();\n\nvar speed = new THREE.Vector3();\n\n//\n\nvar group = new THREE.Group();\nthis.add( group );\n\nvar paddle = this.getObjectByName( 'Paddle' );\ngroup.add( paddle );\n\nvar brick = this.getObjectByName( 'Brick' );\n\nfor ( var j = 0; j < 8; j ++ ) {\n\n\tvar material = new THREE.MeshPhongMaterial( { color: Math.random() * 0xffffff } );\n\n\tfor ( var i = 0; i < 12; i ++ ) {\n\t\t\n\t\tvar object = brick.clone();\n\t\tobject.position.x = i * 22 - 120;\n\t\tobject.position.z = j * 14 - 120;\n\t\tobject.material = material;\n\t\tgroup.add( object );\n\t\t\n\t}\n\t\n}\n\nbrick.visible = false;\n\n//\n\nvar raycaster = new THREE.Raycaster();\n\nfunction update( event ) {\n\t\n\tif ( ball.position.x < - 150 || ball.position.x > 150 ) direction.x = - direction.x;\n\tif ( ball.position.z < - 200 || ball.position.z > 200 ) direction.z = - direction.z;\n\n\tball.position.add( speed.copy( direction ).multiplyScalar( 4 ) );\n\t\n\traycaster.set( ball.position, direction );\n\t\n\tvar intersections = raycaster.intersectObjects( group.children );\n\t\n\tif ( intersections.length > 0 ) {\n\t\n\t\tvar intersection = intersections[ 0 ];\n\t\t\n\t\tif ( intersection.distance < 5 ) {\n\t\t\t\n\t\t\tif ( intersection.object !== paddle ) {\n\n\t\t\t\tgroup.remove( intersection.object );\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t\tdirection.reflect( intersection.face.normal );\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n}"
169+
}]
170+
}
171+
}

editor/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
signals.sceneGraphChanged.add( saveState );
201201
signals.scriptChanged.add( saveState );
202202

203+
/*
203204
var showDialog = function ( content ) {
204205
205206
dialog.clear();
@@ -210,6 +211,7 @@
210211
};
211212
212213
signals.showDialog.add( showDialog );
214+
*/
213215

214216
} );
215217

@@ -253,15 +255,19 @@
253255

254256
//
255257

258+
var file = null;
256259
var hash = window.location.hash;
257260

258-
if ( hash.substr( 1, 4 ) === 'app=' ) {
261+
if ( hash.substr( 1, 4 ) === 'app=' ) file = hash.substr( 5 );
262+
if ( hash.substr( 1, 6 ) === 'scene=' ) file = hash.substr( 7 );
263+
264+
if ( file !== null ) {
259265

260266
if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) {
261267

262268
var loader = new THREE.XHRLoader();
263269
loader.crossOrigin = '';
264-
loader.load( hash.substr( 5 ), function ( text ) {
270+
loader.load( file, function ( text ) {
265271

266272
var json = JSON.parse( text );
267273

editor/js/Editor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var Editor = function () {
2222
playAnimation: new SIGNALS.Signal(),
2323
stopAnimation: new SIGNALS.Signal(),
2424

25-
showDialog: new SIGNALS.Signal(),
25+
// showDialog: new SIGNALS.Signal(),
2626

2727
// notifications
2828

editor/js/Menubar.Examples.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Menubar.Examples = function ( editor ) {
1919
// Examples
2020

2121
var items = [
22+
{ title: 'Arkanoid', file: 'arkanoid.app.json' },
2223
{ title: 'Camera', file: 'camera.app.json' },
2324
{ title: 'Particles', file: 'particles.app.json' },
2425
{ title: 'Pong', file: 'pong.app.json' }

editor/js/Menubar.File.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ Menubar.File = function ( editor ) {
272272
*/
273273

274274

275-
276275
//
277276

278277
var exportString = function ( output ) {

editor/js/Viewport.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ var Viewport = function ( editor ) {
276276
container.dom.removeChild( renderer.domElement );
277277

278278
renderer = createRenderer( type, antialias );
279-
renderer.setClearColor( clearColor );
280-
renderer.setPixelRatio( window.devicePixelRatio );
281279
renderer.setSize( container.dom.offsetWidth, container.dom.offsetHeight );
282280

283281
container.dom.appendChild( renderer.domElement );
@@ -527,6 +525,8 @@ var Viewport = function ( editor ) {
527525
}
528526

529527
var renderer = new THREE[ type ]( { antialias: antialias } );
528+
renderer.setClearColor( clearColor );
529+
renderer.setPixelRatio( window.devicePixelRatio );
530530
renderer.autoClear = false;
531531
renderer.autoUpdateScene = false;
532532

0 commit comments

Comments
 (0)