@@ -21,12 +21,7 @@ const scene = new THREE.Scene();
2121
2222// camera
2323
24- const camera = new THREE . PerspectiveCamera (
25- 25 ,
26- 1 ,
27- 0.1 ,
28- 100 ,
29- ) ;
24+ const camera = new THREE . PerspectiveCamera ( 25 , 1 , 0.1 , 100 ) ;
3025camera . position . set ( 3 , 5 , 8 ) ;
3126
3227// ambient light
@@ -100,46 +95,32 @@ for (let i = 0; i < attractorsPositions.node.array.length; i++) {
10095 arrowHelper . scale . setScalar ( 0.325 ) ;
10196 reference . add ( arrowHelper ) ;
10297
103- const ring = new THREE . Mesh (
104- helpersRingGeometry ,
105- helpersMaterial ,
106- ) ;
98+ const ring = new THREE . Mesh ( helpersRingGeometry , helpersMaterial ) ;
10799 ring . rotation . x = - Math . PI * 0.5 ;
108100 arrowHelper . add ( ring ) ;
109101
110- const arrow = new THREE . Mesh (
111- helpersArrowGeometry ,
112- helpersMaterial ,
113- ) ;
102+ const arrow = new THREE . Mesh ( helpersArrowGeometry , helpersMaterial ) ;
114103 arrow . position . x = 1 ;
115104 arrow . position . z = 0.2 ;
116105 arrow . rotation . x = Math . PI * 0.5 ;
117106 arrowHelper . add ( arrow ) ;
118107
119- const attractorControls = new TransformControls (
120- camera ,
121- renderer . domElement ,
122- ) ;
108+ const attractorControls = new TransformControls ( camera , renderer . domElement ) ;
123109
124110 attractorControls . mode = 'translate' ;
125111 attractorControls . size = 0.5 ;
126112 attractorControls . attach ( reference ) ;
127113 attractorControls . enabled = true ;
128114 scene . add ( attractorControls . getHelper ( ) ) ;
129115
130- attractorControls . addEventListener (
131- 'dragging-changed' ,
132- ( event ) => {
133- orbitControls . enabled = ! event . value ;
134- } ,
135- ) ;
116+ attractorControls . addEventListener ( 'dragging-changed' , ( event ) => {
117+ orbitControls . enabled = ! event . value ;
118+ } ) ;
136119
137120 attractorControls . addEventListener ( 'change' , ( ) => {
138121 position . copy ( reference . position ) ;
139122 orientation . copy (
140- new THREE . Vector3 ( 0 , 1 , 0 ) . applyQuaternion (
141- reference . quaternion ,
142- ) ,
123+ new THREE . Vector3 ( 0 , 1 , 0 ) . applyQuaternion ( reference . quaternion ) ,
143124 ) ;
144125 } ) ;
145126
@@ -195,7 +176,7 @@ const initCompute = t3.toTSL(() => {
195176 const instanceIndex = t3 . instanceIndex . $ ;
196177 randf . seed ( instanceIndex / count + comptimeRandom ( ) ) ;
197178
198- const basePosition = d . vec3f ( randf . sample ( ) , randf . sample ( ) , randf . sample ( ) )
179+ const basePosition = randf . inUnitCube ( )
199180 . sub ( 0.5 )
200181 . mul ( d . vec3f ( 5 , 0.2 , 5 ) ) ;
201182 positionBuffer . $ [ instanceIndex ] = d . vec3f ( basePosition ) ;
0 commit comments