Skip to content

Commit e5579de

Browse files
committed
Initial commit!
0 parents  commit e5579de

7 files changed

+304
-0
lines changed

.eslintrc.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "eslint:recommended",
7+
"parserOptions": {
8+
"sourceType": "module"
9+
},
10+
"rules": {
11+
"indent": [
12+
"error",
13+
2
14+
],
15+
"linebreak-style": [
16+
"error",
17+
"unix"
18+
],
19+
"quotes": [
20+
"error",
21+
"single"
22+
],
23+
"semi": [
24+
"error",
25+
"always"
26+
]
27+
},
28+
"globals": {
29+
"NIN": true,
30+
"THREE": true,
31+
"GU": true,
32+
"BEAT": true,
33+
"BEAN": true,
34+
"BEAN_FOR_FRAME": true,
35+
"FRAME_FOR_BEAN": true,
36+
"Loader": true,
37+
"SHADERS": true,
38+
"demo": true,
39+
"clamp": true,
40+
"lerp": true,
41+
"easeOut": true,
42+
"easeIn": true,
43+
"smoothstep": true,
44+
"elasticOut": true
45+
}
46+
}

index.html

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset=utf8>
5+
NIN_WILL_REPLACE_THIS_TAG_WITH_AUTOGENERATED_COMMENT_TAGS
6+
<style>
7+
* {
8+
font-family: sans-serif;
9+
display: none;
10+
color: transparent;
11+
}
12+
13+
.visible, .visible * {
14+
display: block;
15+
}
16+
17+
html, body {
18+
width: 100%;
19+
height: 100%;
20+
display: block;
21+
overflow: hidden;
22+
padding: 0;
23+
margin: 0;
24+
border: 0;
25+
outline: 0;
26+
background: -webkit-linear-gradient(top, #FFFFFF, #CCDDFF);
27+
background: -moz-linear-gradient(top, #FFFFFF, #CCDDFF);
28+
background-size: cover;
29+
}
30+
31+
h1, h2 {
32+
text-align: center;
33+
color: black;
34+
}
35+
36+
canvas {
37+
position: fixed;
38+
display: block;
39+
background: #000;
40+
}
41+
42+
.hide {
43+
display: none;
44+
}
45+
46+
.loading-text {
47+
position: fixed;
48+
left: 45%;
49+
top: 52%;
50+
width: 10%;
51+
color: black;
52+
text-align: center;
53+
font-size: 14px;
54+
}
55+
56+
.progress-bar-inner {
57+
width: 0;
58+
height: 100%;
59+
background: #2c7f61;
60+
}
61+
62+
.progress-bar-container {
63+
position: fixed;
64+
left: 45%;
65+
top: 54.5%;
66+
bottom: 43.5%;
67+
width: 10%;
68+
border: 1px solid #2c7f61;
69+
}
70+
71+
#start-button {
72+
position: fixed;
73+
left: 45%;
74+
top: 54.5%;
75+
width: 10%;
76+
color: black;
77+
text-decoration: none;
78+
text-align: center;
79+
border: 1px solid black;
80+
padding: 5px;
81+
margin-top: -10px;
82+
}
83+
#pouet-link {
84+
position: fixed;
85+
bottom: 10px;
86+
text-align: center;
87+
color: gray;
88+
left: 0;
89+
right: 0;
90+
font-size: 14px;
91+
}
92+
</style>
93+
NIN_WILL_REPLACE_THIS_TAG_WITH_AUTOGENERATED_META_TAGS
94+
</head>
95+
96+
<body>
97+
<div id=wrapper class=visible>
98+
<div class=loading-text>Loading...</div>
99+
<div class=progress-bar-container>
100+
<div class=progress-bar-inner>
101+
</div>
102+
</div>
103+
<a id=start-button class=hide href=javascript:; onclick=STARTDEMO();>
104+
START
105+
</a>
106+
<a href="http://www.pouet.net/groups.php?which=11702" target="_blank" id="pouet-link">Read more about this demo on Pouet</a>
107+
</div>
108+
<script>
109+
var loadingText = document.querySelector('.loading-text');
110+
var progressBarInner = document.querySelector('.progress-bar-inner');
111+
var progressBarContainer = document.querySelector('.progress-bar-container');
112+
var wrapper = document.querySelector('#wrapper');
113+
var startButton = document.querySelector('#start-button');
114+
ONPROGRESS = function(progress) {
115+
progressBarInner.style.width = ((+progress * 100 | 0) / 100) + '%';
116+
};
117+
118+
ONCOMPLETE = function() {
119+
progressBarInner.style.width = '100%';
120+
loadingText.classList.add('hide');
121+
progressBarContainer.classList.add('hide');
122+
startButton.classList.remove('hide');
123+
};
124+
125+
function requestFullScreen() {
126+
var doc = window.document;
127+
var docEl = doc.documentElement;
128+
129+
var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
130+
131+
if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
132+
requestFullScreen.call(docEl);
133+
}
134+
}
135+
136+
STARTDEMO = function() {
137+
requestFullScreen();
138+
139+
startButton.innerHTML = 'Starting..!';
140+
setTimeout(function() {
141+
wrapper.classList.remove('visible');
142+
wrapper.style.background = '#fff';
143+
document.body.style.background = '#000';
144+
demo.start();
145+
}, 100);
146+
};
147+
</script>
148+
149+
NIN_WILL_REPLACE_THIS_TAG_WITH_YOUR_ANALYTICS_ID

nin.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "My project",
3+
"authors": [
4+
"Your demoscene handle"
5+
],
6+
"description": "This is my project",
7+
"previewImage": "https://raw.githubusercontent.com/ninjadev/nin/master/nin/frontend/app/images/nin-dark.png",
8+
"aspectRatio": "16:9",
9+
"music": {
10+
"path": "res/music.mp3",
11+
"bpm": 125,
12+
"subdivision": 4,
13+
"BEANOffset": 0
14+
},
15+
"googleAnalyticsID": "Your GA ID",
16+
"labels": [
17+
{
18+
"name": "Start",
19+
"BEAN": 0
20+
}
21+
]
22+
}

res/graph.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"id": "root",
4+
"type": "NIN.RootNode",
5+
"connected": {
6+
"screen": "sceneSwitcherNode.render"
7+
}
8+
},
9+
{
10+
"id": "sceneSwitcherNode",
11+
"type": "SceneSwitcherNode",
12+
"connected": {
13+
"A": "SpinningCube.render"
14+
}
15+
},
16+
{
17+
"id": "SpinningCube",
18+
"type": "spinningCube"
19+
}
20+
]

res/music.mp3

3.35 MB
Binary file not shown.

src/SceneSwitcherNode.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(function(global) {
2+
class SceneSwitcherNode extends NIN.Node {
3+
constructor(id) {
4+
super(id, {
5+
inputs: {
6+
A: new NIN.TextureInput(),
7+
B: new NIN.TextureInput(),
8+
},
9+
outputs: {
10+
render: new NIN.TextureOutput(),
11+
}
12+
});
13+
}
14+
15+
beforeUpdate() {
16+
this.inputs.A.enabled = false;
17+
this.inputs.B.enabled = false;
18+
19+
let selectedScene;
20+
if (BEAN < 48 * 4) {
21+
selectedScene = this.inputs.A;
22+
} else {
23+
selectedScene = this.inputs.B;
24+
}
25+
26+
selectedScene.enabled = true;
27+
this.selectedScene = selectedScene;
28+
}
29+
30+
render() {
31+
this.outputs.render.setValue(this.selectedScene.getValue());
32+
}
33+
}
34+
35+
global.SceneSwitcherNode = SceneSwitcherNode;
36+
})(this);

src/spinningCube.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(function(global) {
2+
class spinningCube extends NIN.THREENode {
3+
constructor(id, options) {
4+
super(id, {
5+
camera: options.camera,
6+
outputs: {
7+
render: new NIN.TextureOutput()
8+
}
9+
});
10+
11+
this.cube = new THREE.Mesh(new THREE.BoxGeometry(50, 50, 50),
12+
new THREE.MeshStandardMaterial());
13+
this.scene.add(this.cube);
14+
15+
var light = new THREE.PointLight(0xffffff, 1, 100);
16+
light.position.set(50, 50, 50);
17+
this.scene.add(light);
18+
19+
this.camera.position.z = 100;
20+
}
21+
22+
update(frame) {
23+
super.update(frame);
24+
25+
this.cube.rotation.x = Math.sin(frame / 50);
26+
this.cube.rotation.y = Math.cos(frame / 50);
27+
}
28+
}
29+
30+
global.spinningCube = spinningCube;
31+
})(this);

0 commit comments

Comments
 (0)