11import * as pc from 'playcanvas' ;
2- import { deviceType , rootPath } from 'examples/utils' ;
2+ import { deviceType , rootPath , fileImport } from 'examples/utils' ;
3+ const { CameraFrame } = await fileImport ( rootPath + '/static/assets/scripts/misc/camera-frame.mjs' ) ;
34
45const canvas = /** @type {HTMLCanvasElement } */ ( document . getElementById ( 'application-canvas' ) ) ;
56window . focus ( ) ;
@@ -10,10 +11,9 @@ const assets = {
1011 helipad : new pc . Asset (
1112 'helipad-env-atlas' ,
1213 'texture' ,
13- { url : rootPath + '/static/assets/cubemaps/helipad -env-atlas.png' } ,
14+ { url : rootPath + '/static/assets/cubemaps/table-mountain -env-atlas.png' } ,
1415 { type : pc . TEXTURETYPE_RGBP , mipmaps : false }
15- ) ,
16- bloom : new pc . Asset ( 'bloom' , 'script' , { url : rootPath + '/static/scripts/posteffects/posteffect-bloom.js' } )
16+ )
1717} ;
1818const gfxOptions = {
1919 deviceTypes : [ deviceType ] ,
@@ -74,15 +74,17 @@ assetListLoader.load(() => {
7474 } ) ;
7575 cameraEntity . translate ( 0 , 1 , 0 ) ;
7676
77- // add bloom postprocessing (this is ignored by the picker)
77+ // ------ Custom render passes set up ------
78+
7879 cameraEntity . addComponent ( 'script' ) ;
79- cameraEntity . script . create ( 'bloom' , {
80- attributes : {
81- bloomIntensity : 1 ,
82- bloomThreshold : 0.7 ,
83- blurAmount : 4
84- }
85- } ) ;
80+ const cameraFrame = cameraEntity . script . create ( CameraFrame ) ;
81+ cameraFrame . rendering . toneMapping = pc . TONEMAP_NEUTRAL ;
82+ cameraFrame . rendering . samples = 4 ;
83+ cameraFrame . bloom . enabled = true ;
84+ cameraFrame . bloom . intensity = 0.01 ;
85+
86+ // ------------------------------------------
87+
8688 app . root . addChild ( cameraEntity ) ;
8789
8890 const boxes = { } ;
@@ -121,7 +123,9 @@ assetListLoader.load(() => {
121123 const j = Math . floor ( pos . z + 0.5 ) ;
122124 const colorVec = new pc . Vec3 ( Math . random ( ) , Math . random ( ) , Math . random ( ) ) ;
123125 colorVec . mulScalar ( 1 / colorVec . length ( ) ) ;
124- boxes [ `${ i } ${ j } ` ] . render . material . emissive = new pc . Color ( colorVec . x , colorVec . y , colorVec . z ) ;
126+ const material = boxes [ `${ i } ${ j } ` ] . render . material ;
127+ material . emissive = new pc . Color ( colorVec . x , colorVec . y , colorVec . z ) ;
128+ material . emissiveIntensity = 50 ;
125129 highlightedBoxes . push ( boxes [ `${ i } ${ j } ` ] ) ;
126130 } ;
127131
@@ -174,8 +178,7 @@ assetListLoader.load(() => {
174178 // on update, iterate over any currently highlighted boxes and reduce their emissive property
175179 highlightedBoxes . forEach ( ( box ) => {
176180 const material = box . render . material ;
177- const emissive = material . emissive ;
178- emissive . lerp ( emissive , pc . Color . BLACK , 0.08 ) ;
181+ material . emissiveIntensity *= 0.95 ;
179182 material . update ( ) ;
180183 } ) ;
181184 // remove old highlighted boxes from the update loop
0 commit comments