Skip to content

Commit b913223

Browse files
committed
include new font + new button look + logo
1 parent 2c7fd5a commit b913223

File tree

6 files changed

+74
-13
lines changed

6 files changed

+74
-13
lines changed

fonts/RegolaPro-Bold.woff2

46.8 KB
Binary file not shown.

fonts/RegolaPro-Book.woff2

44.4 KB
Binary file not shown.

index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
</head>
1111
<body>
1212
<div class="editor-action-buttons">
13-
<button class="show-hide-editor">></button>
14-
<button class="permalink">permalink</button>
13+
<button class="show-hide-editor editor-button">Hide Code</button>
14+
<button class="permalink editor-button">Permalink</button>
1515
</div>
1616
<div class="code-container"></div>
1717
<script src="./index.js" type="module"></script>
18+
<a href="https://www.shaderpark.com" target="_blank"><h1 class="logo">SHADER PARK</h1></a>
1819
</body>
1920
</html>

index.js

+25-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,27 @@ import { createSculptureWithGeometry, sculptToThreeJSMaterial } from 'shader-par
44
import { spCode } from './src/spCode.js';
55
import { initUIInteractions } from './src/ui.js';
66
import {createEditor} from './src/editor.js';
7+
import {Pane} from 'tweakpane';
78

9+
10+
11+
// import {font} from './src/helvetiker_regular1.typeface.json';
12+
13+
// let fonts = JSON.parse(font)
814
let state = {};
15+
16+
// const pane = new Pane();
17+
918
initUIInteractions(state);
1019

1120
let startCode = spCode();
1221

1322
let scene = new Scene();
14-
let params = { time: 0 };
23+
let params = { time: 0, test: {'x':.2, 'y': .4}};
24+
// pane.addInput(
25+
// params, 'test',
26+
// {min: 0, max: 2 }
27+
// );
1528

1629
let camera = new PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
1730
camera.position.z = 4;
@@ -46,11 +59,14 @@ let mesh = createSculptureWithGeometry(geometry, startCode, () => ( {
4659
time: params.time,
4760
_scale: scale
4861
} ));
62+
63+
4964
scene.add(mesh);
5065

5166
if( 'text' in qParams) {
5267
const loader = new FontLoader();
53-
loader.load( 'https://cdn.glitch.com/44b034f5-6c9a-414c-96b3-8280ecf82f27%2Fhelvetiker_regular.typeface.json?v=1615399030749', function ( font ) {
68+
69+
loader.load( './helvetiker_regular1.typeface.json', function ( font ) {
5470
mesh.geometry = new TextBufferGeometry( qParams['text'], {
5571
font: font,
5672
size: 2,
@@ -77,6 +93,8 @@ camera.position.z = 2;
7793

7894
window.controls = controls;
7995

96+
const uniformsToExclude = { 'sculptureCenter': 0, 'msdf': 0, 'opacity': 0, 'time': 0, 'stepSize': 0, '_scale' : 1, 'resolution': 0};;
97+
8098
let onCodeChange = (code) => {
8199
state.code = code;
82100
try {
@@ -86,7 +104,12 @@ let onCodeChange = (code) => {
86104
// scene.remove(mesh);
87105
// scene.add(newMesh);
88106
// mesh = newMesh;
107+
89108
mesh.material = sculptToThreeJSMaterial(code);
109+
let uniforms = mesh.material.uniformDescriptions;
110+
uniforms = uniforms.filter(uniform => !(uniform.name in uniformsToExclude))
111+
112+
console.log(uniforms);
90113
} catch (error) {
91114
console.error(error);
92115
}

src/ui.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@ const createPermaLink = (state) => {
2424

2525
const showHideButtonInteraction = () => {
2626
let codeContainer = document.querySelector('.code-container');
27+
let logo = document.querySelector('.logo');
28+
let permalink = document.querySelector('.permalink');
29+
let elements = [codeContainer, logo];
30+
2731
let showHideButton = document.querySelector('.show-hide-editor');
2832
toggleButton('.show-hide-editor', (active) => {
2933
if(active) {
30-
showHideButton.innerHTML= '>';
31-
codeContainer.style.display = 'block';
34+
showHideButton.innerHTML= 'Hide Code';
35+
elements.forEach(el => el.style.display = 'block');
3236
} else {
33-
showHideButton.innerHTML= '^';
34-
codeContainer.style.display = 'none';
37+
showHideButton.innerHTML= 'Show Code';
38+
elements.forEach(el => el.style.display = 'none');
3539
}
3640
});
3741
// showHideButton.addEventListener('click', (el) => {

style.css

+38-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
/* CSS files add styling rules to your content */
22

3+
@font-face {
4+
font-family: 'Regolapro';
5+
src: url('./fonts/RegolaPro-Book.woff2') format('opentype');
6+
font-weight: 700;
7+
font-style: normal;
8+
}
9+
310
body {
411
font-family: helvetica, arial, sans-serif;
512
margin: 2em;
@@ -14,7 +21,7 @@ body {
1421
.code-container {
1522
position: fixed;
1623
left: 0px;
17-
top: 20px;
24+
top: 30px;
1825
width: 50vw;
1926
height: 100vh;
2027
}
@@ -25,10 +32,6 @@ body {
2532
}
2633
}
2734

28-
h1 {
29-
font-style: italic;
30-
color: #373fff;
31-
}
3235

3336
canvas {
3437
width: 100%;
@@ -44,4 +47,34 @@ canvas {
4447
position: fixed;
4548
top: 0px;
4649
left: 0px;
50+
}
51+
52+
.logo {
53+
position: fixed;
54+
right: 15px;
55+
bottom: 10px;
56+
margin: 0px;
57+
padding: 0px;
58+
color: white;
59+
font-family: Regolapro;
60+
font-weight: 700;
61+
}
62+
63+
.editor-button {
64+
padding: 5px 15px 5px 15px;
65+
border-radius: 50px;
66+
/* border: 1px solid lightgrey; */
67+
/* box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.15); */
68+
margin-top: 2.5px;
69+
transition: all 300ms ease-in-out ;
70+
color: rgb(165, 165, 165);
71+
border-color: rgb(165, 165, 165);
72+
background-color: transparent;
73+
-webkit-transition: all 300ms ease-in-out;
74+
cursor: pointer;
75+
}
76+
.editor-button:hover {
77+
color: white;
78+
border-color: white;
79+
/* box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2); */
4780
}

0 commit comments

Comments
 (0)