1
- import { Scene , PerspectiveCamera , WebGLRenderer , Color , SphereGeometry , TorusKnotGeometry , TextBufferGeometry } from ' three' ;
2
- import { OrbitControls } from ' three/examples/jsm/controls/OrbitControls' ;
3
- import { createSculptureWithGeometry , sculptToThreeJSMaterial } from ' shader-park-core' ;
4
- import { spCode } from ' ./src/spCode.js' ;
5
- import { initUIInteractions } from ' ./src/ui.js' ;
6
- import { createEditor } from ' ./src/editor.js' ;
7
- import { Pane } from ' tweakpane' ;
8
-
9
- // import { font } from ' ./src/helvetiker_regular1.typeface.json' ;
1
+ import { Scene , PerspectiveCamera , WebGLRenderer , Color , SphereGeometry , TorusKnotGeometry , TextBufferGeometry } from " three" ;
2
+ import { OrbitControls } from " three/examples/jsm/controls/OrbitControls" ;
3
+ import { createSculptureWithGeometry , sculptToThreeJSMaterial } from " shader-park-core" ;
4
+ import { spCode } from " ./src/spCode.js" ;
5
+ import { initUIInteractions } from " ./src/ui.js" ;
6
+ import { createEditor } from " ./src/editor.js" ;
7
+ import { Pane } from " tweakpane" ;
8
+
9
+ // import { font } from " ./src/helvetiker_regular1.typeface.json" ;
10
10
// const fonts = JSON.parse(font);
11
11
12
12
// query parameters
13
13
const urlSearchParams = new URLSearchParams ( window . location . search ) ;
14
14
const qParams = Object . fromEntries ( urlSearchParams . entries ( ) ) ;
15
15
16
16
// starter code and its UI init
17
- const startCode = ( ' code' in qParams ) ? decodeURI ( qParams [ ' code' ] ) : spCode ( ) ;
17
+ const startCode = ( " code" in qParams ) ? decodeURI ( qParams [ " code" ] ) : spCode ( ) ;
18
18
const state = { code : startCode } ;
19
19
initUIInteractions ( state ) ;
20
20
@@ -24,7 +24,7 @@ const sizes = {
24
24
height : window . innerHeight
25
25
}
26
26
27
- window . addEventListener ( ' resize' , ( ) =>
27
+ window . addEventListener ( " resize" , ( ) =>
28
28
{
29
29
sizes . width = window . innerWidth ;
30
30
sizes . height = window . innerHeight ;
@@ -64,14 +64,14 @@ const torusGeometry = new TorusKnotGeometry(2, .3, 100, 40);
64
64
torusGeometry . computeBoundingSphere ( ) ;
65
65
torusGeometry . center ( ) ;
66
66
67
- const geometry = ( ' torus' in qParams ) ? torusGeometry : sphereGeometry ;
67
+ const geometry = ( " torus" in qParams ) ? torusGeometry : sphereGeometry ;
68
68
69
69
// Shader Park Setup
70
70
const params = { } ;
71
71
72
72
params . time = 0 ;
73
- params . test = { 'x' :.2 , 'y' : .4 } ;
74
- params . scale = ( ' scale' in qParams ) ? qParams [ ' scale' ] : 1.0 ;
73
+ params . test = { "x" :.2 , "y" : .4 } ;
74
+ params . scale = ( " scale" in qParams ) ? qParams [ " scale" ] : 1.0 ;
75
75
76
76
const mesh = createSculptureWithGeometry ( geometry , state . code , ( ) => ( {
77
77
time : params . time ,
@@ -83,16 +83,16 @@ scene.add(mesh);
83
83
84
84
// const pane = new Pane();
85
85
// pane.addInput(
86
- // params, ' test' ,
86
+ // params, " test" ,
87
87
// {min: 0, max: 2 }
88
88
// );
89
89
90
- if ( ' text' in qParams ) {
90
+ if ( " text" in qParams ) {
91
91
const loader = new FontLoader ( ) ;
92
92
const mesh = state . mesh ;
93
93
94
- loader . load ( ' ./helvetiker_regular1.typeface.json' , function ( font ) {
95
- mesh . geometry = new TextBufferGeometry ( qParams [ ' text' ] , {
94
+ loader . load ( " ./helvetiker_regular1.typeface.json" , function ( font ) {
95
+ mesh . geometry = new TextBufferGeometry ( qParams [ " text" ] , {
96
96
font : font ,
97
97
size : 2 ,
98
98
height : .1 ,
@@ -108,7 +108,7 @@ if('text' in qParams) {
108
108
} ) ;
109
109
}
110
110
111
- const uniformsToExclude = { ' sculptureCenter' : 0 , ' msdf' : 0 , ' opacity' : 0 , ' time' : 0 , ' stepSize' : 0 , ' _scale' : 1 , ' resolution' : 0 } ;
111
+ const uniformsToExclude = { " sculptureCenter" : 0 , " msdf" : 0 , " opacity" : 0 , " time" : 0 , " stepSize" : 0 , " _scale" : 1 , " resolution" : 0 } ;
112
112
113
113
const onCodeChange = ( code ) => {
114
114
state . code = code ;
@@ -133,7 +133,7 @@ const onCodeChange = (code) => {
133
133
134
134
// Editor
135
135
const editor = createEditor ( state . code , onCodeChange ) ;
136
- const codeContainer = document . querySelector ( ' .code-container' ) ;
136
+ const codeContainer = document . querySelector ( " .code-container" ) ;
137
137
codeContainer . appendChild ( editor . dom ) ;
138
138
139
139
// Add parameters to window
0 commit comments