1
+ // Camera Frame v 1.0
2
+
1
3
/* eslint-disable-next-line import/no-unresolved */
2
4
import { CameraFrame as EngineCameraFrame , Script , Color } from 'playcanvas' ;
3
5
@@ -32,7 +34,9 @@ const DebugType = {
32
34
SCENE : 'scene' ,
33
35
SSAO : 'ssao' ,
34
36
BLOOM : 'bloom' ,
35
- VIGNETTE : 'vignette'
37
+ VIGNETTE : 'vignette' ,
38
+ DOFCOC : 'dofcoc' ,
39
+ DOFBLUR : 'dofblur'
36
40
} ;
37
41
38
42
/** @interface */
@@ -258,6 +262,47 @@ class Taa {
258
262
jitter = 1 ;
259
263
}
260
264
265
+ /** @interface */
266
+ class Dof {
267
+ enabled = false ;
268
+
269
+ highQuality = true ;
270
+
271
+ nearBlur = false ;
272
+
273
+ /**
274
+ * @precision 2
275
+ * @step 1
276
+ */
277
+ focusDistance = 100 ;
278
+
279
+ /**
280
+ * @precision 2
281
+ * @step 1
282
+ */
283
+ focusRange = 10 ;
284
+
285
+ /**
286
+ * @precision 2
287
+ * @step 0.1
288
+ */
289
+ blurRadius = 3 ;
290
+
291
+ /**
292
+ * @range [1, 10]
293
+ * @precision 0
294
+ * @step 1
295
+ */
296
+ blurRings = 4 ;
297
+
298
+ /**
299
+ * @range [1, 10]
300
+ * @precision 0
301
+ * @step 1
302
+ */
303
+ blurRingPoints = 5 ;
304
+ }
305
+
261
306
class CameraFrame extends Script {
262
307
/**
263
308
* @attribute
@@ -301,6 +346,12 @@ class CameraFrame extends Script {
301
346
*/
302
347
fringing = new Fringing ( ) ;
303
348
349
+ /**
350
+ * @attribute
351
+ * @type {Dof }
352
+ */
353
+ dof = new Dof ( ) ;
354
+
304
355
engineCameraFrame = new EngineCameraFrame ( this . app , this . entity . camera ) ;
305
356
306
357
initialize ( ) {
@@ -321,7 +372,7 @@ class CameraFrame extends Script {
321
372
postUpdate ( dt ) {
322
373
323
374
const cf = this . engineCameraFrame ;
324
- const { rendering, bloom, grading, vignette, fringing, taa, ssao } = this ;
375
+ const { rendering, bloom, grading, vignette, fringing, taa, ssao, dof } = this ;
325
376
326
377
const dstRendering = cf . rendering ;
327
378
dstRendering . renderFormats . length = 0 ;
@@ -385,6 +436,19 @@ class CameraFrame extends Script {
385
436
const dstFringing = cf . fringing ;
386
437
dstFringing . intensity = fringing . enabled ? fringing . intensity : 0 ;
387
438
439
+ // dof
440
+ const dstDof = cf . dof ;
441
+ dstDof . enabled = dof . enabled ;
442
+ if ( dof . enabled ) {
443
+ dstDof . highQuality = dof . highQuality ;
444
+ dstDof . nearBlur = dof . nearBlur ;
445
+ dstDof . focusDistance = dof . focusDistance ;
446
+ dstDof . focusRange = dof . focusRange ;
447
+ dstDof . blurRadius = dof . blurRadius ;
448
+ dstDof . blurRings = dof . blurRings ;
449
+ dstDof . blurRingPoints = dof . blurRingPoints ;
450
+ }
451
+
388
452
// debugging
389
453
cf . debug = rendering . debug ;
390
454
0 commit comments