@@ -89,6 +89,11 @@ export const createRenderer = (options = {}) => {
8989 ) ;
9090 } ;
9191
92+ /**
93+ * The render function
94+ * @param {function } draw - The function for drawing
95+ * @param {HTMLCanvasElement } targetCanvas - The canvas element that should received the rendered pixels.
96+ */
9297 const render = ( draw , targetCanvas ) => {
9398 // Clear internal canvas
9499 regl . clear ( CLEAR_OPTIONS ) ;
@@ -116,6 +121,11 @@ export const createRenderer = (options = {}) => {
116121
117122 const drawFns = new Set ( ) ;
118123
124+ /**
125+ * Register an draw function that is going to be invoked on every animation
126+ * frame.
127+ * @param {function } draw - The callback function
128+ */
119129 const onFrame = ( draw ) => {
120130 drawFns . add ( draw ) ;
121131 return ( ) => {
@@ -146,6 +156,9 @@ export const createRenderer = (options = {}) => {
146156 resize ( ) ;
147157 }
148158
159+ /**
160+ * Destroy the renderer to free resources and cancel animation frames
161+ */
149162 const destroy = ( ) => {
150163 frame . cancel ( ) ;
151164 canvas = undefined ;
@@ -155,18 +168,38 @@ export const createRenderer = (options = {}) => {
155168 } ;
156169
157170 return {
171+ /**
172+ * Get the associated canvas element
173+ * @return {HTMLCanvasElement } The associated canvas element
174+ */
158175 get canvas ( ) {
159176 return canvas ;
160177 } ,
178+ /**
179+ * Get the associated Regl instance
180+ * @return {import('regl').Regl } The associated Regl instance
181+ */
161182 get regl ( ) {
162183 return regl ;
163184 } ,
185+ /**
186+ * Get the gamma value
187+ * @return {number } The gamma value
188+ */
164189 get gamma ( ) {
165190 return gamma ;
166191 } ,
192+ /**
193+ * Set gamma to a new value
194+ * @param {number } newGamma - The new gamma value
195+ */
167196 set gamma ( newGamma ) {
168197 gamma = + newGamma ;
169198 } ,
199+ /**
200+ * Get whether the browser supports all necessary WebGL features
201+ * @return {boolean } If `true` the browser supports all necessary WebGL features
202+ */
170203 get isSupported ( ) {
171204 return isSupportingAllGlExtensions ;
172205 } ,
0 commit comments