11import {
22 AmbientLight ,
33 AnimationMixer ,
4- BoxBufferGeometry ,
5- CircleBufferGeometry ,
4+ CircleGeometry ,
65 Color ,
76 CubeTextureLoader ,
8- ConeBufferGeometry ,
7+ ConeGeometry ,
98 DirectionalLight ,
109 DoubleSide ,
1110 Mesh ,
1211 MeshPhongMaterial ,
13- OctahedronBufferGeometry ,
12+ OctahedronGeometry ,
1413 PerspectiveCamera ,
1514 Raycaster ,
16- SphereBufferGeometry ,
17- sRGBEncoding ,
15+ SphereGeometry ,
1816 TextureLoader ,
19- Vector2
17+ Vector2 ,
18+ SRGBColorSpace
2019} from "three" ;
2120
2221import { ControlMode , SpatialControls } from "spatial-controls" ;
@@ -85,7 +84,7 @@ export class OutlineDemo extends PostProcessingDemo {
8584 /**
8685 * An effect.
8786 *
88- * @type {Effect }
87+ * @type {OutlineEffect }
8988 * @private
9089 */
9190
@@ -200,14 +199,14 @@ export class OutlineDemo extends PostProcessingDemo {
200199
201200 cubeTextureLoader . load ( urls , ( t ) => {
202201
203- t . encoding = sRGBEncoding ;
202+ t . colorSpace = SRGBColorSpace ;
204203 assets . set ( "sky" , t ) ;
205204
206205 } ) ;
207206
208207 textureLoader . load ( "textures/pattern.png" , ( t ) => {
209208
210- t . encoding = sRGBEncoding ;
209+ t . colorSpace = SRGBColorSpace ;
211210 assets . set ( "pattern-color" , t ) ;
212211
213212 } ) ;
@@ -270,9 +269,9 @@ export class OutlineDemo extends PostProcessingDemo {
270269
271270 // Lights
272271
273- const ambientLight = new AmbientLight ( 0x212121 ) ;
274- const mainLight = new DirectionalLight ( 0xff7e66 , 1.0 ) ;
275- const backLight = new DirectionalLight ( 0xff7e66 , 0.1 ) ;
272+ const ambientLight = new AmbientLight ( 0x656565 ) ;
273+ const mainLight = new DirectionalLight ( 0xffbbaa , 1.0 ) ;
274+ const backLight = new DirectionalLight ( 0xffbbaa , 0.1 ) ;
276275
277276 mainLight . position . set ( 14.4 , 2 , 20 ) ;
278277 backLight . position . copy ( mainLight . position ) . negate ( ) ;
@@ -285,7 +284,7 @@ export class OutlineDemo extends PostProcessingDemo {
285284 const meshes = [ ] ;
286285
287286 let mesh = new Mesh (
288- new SphereBufferGeometry ( 1 , 32 , 32 ) ,
287+ new SphereGeometry ( 1 , 32 , 32 ) ,
289288 new MeshPhongMaterial ( {
290289 color : 0xffff00
291290 } )
@@ -296,7 +295,7 @@ export class OutlineDemo extends PostProcessingDemo {
296295 selection . push ( mesh ) ;
297296
298297 mesh = new Mesh (
299- new OctahedronBufferGeometry ( ) ,
298+ new OctahedronGeometry ( ) ,
300299 new MeshPhongMaterial ( {
301300 color : 0xff00ff
302301 } )
@@ -307,7 +306,7 @@ export class OutlineDemo extends PostProcessingDemo {
307306 selection . push ( mesh ) ;
308307
309308 mesh = new Mesh (
310- new CircleBufferGeometry ( 0.75 , 32 ) ,
309+ new CircleGeometry ( 0.75 , 32 ) ,
311310 new MeshPhongMaterial ( {
312311 side : DoubleSide ,
313312 color : 0xff0000
@@ -320,7 +319,7 @@ export class OutlineDemo extends PostProcessingDemo {
320319 selection . push ( mesh ) ;
321320
322321 mesh = new Mesh (
323- new ConeBufferGeometry ( 1 , 1 , 32 ) ,
322+ new ConeGeometry ( 1 , 1 , 32 ) ,
324323 new MeshPhongMaterial ( {
325324 color : 0x00ff00
326325 } )
@@ -331,7 +330,7 @@ export class OutlineDemo extends PostProcessingDemo {
331330 selection . push ( mesh ) ;
332331
333332 mesh = new Mesh (
334- new BoxBufferGeometry ( 1 , 1 , 1 ) ,
333+ new BoxGeometry ( 1 , 1 , 1 ) ,
335334 new MeshPhongMaterial ( {
336335 color : 0x00ffff
337336 } )
@@ -428,39 +427,38 @@ export class OutlineDemo extends PostProcessingDemo {
428427 "pulse speed" : effect . pulseSpeed ,
429428 "edge strength" : uniforms . get ( "edgeStrength" ) . value ,
430429 "visible edge" : color . copyLinearToSRGB (
431- uniforms . get ( "visibleEdgeColor" ) . value ) . getHex ( ) ,
432- "hidden edge" : color . copyLinearToSRGB (
433- uniforms . get ( "hiddenEdgeColor" ) . value ) . getHex ( ) ,
430+ "edge strength" : effect . edgeStrength ,
431+ "visible edge" : color . copyLinearToSRGB ( effect . visibleEdgeColor ) . getHex ( ) ,
432+ "hidden edge" : color . copyLinearToSRGB ( effect . hiddenEdgeColor ) . getHex ( ) ,
434433 "x-ray" : true ,
435434 "opacity" : blendMode . opacity . value ,
436435 "blend mode" : blendMode . blendFunction
437436 } ;
438437
439- menu . add ( params , "resolution" , [ 240 , 360 , 480 , 720 , 1080 ] )
440- . onChange ( ( value ) => {
438+ menu . add ( params , "resolution" , [ 240 , 360 , 480 , 720 , 1080 ] ) . onChange ( ( value ) => {
441439
442- effect . resolution . height = Number ( value ) ;
440+ effect . resolution . height = Number ( value ) ;
443441
444- } ) ;
442+ } ) ;
445443
446444 menu . add ( params , "blurriness" ,
447445 KernelSize . VERY_SMALL , KernelSize . HUGE + 1 , 1 ) . onChange ( ( value ) => {
448446
449- effect . blur = ( value > 0 ) ;
450- effect . blurPass . kernelSize = value - 1 ;
447+ effect . blurPass . enabled = ( value > 0 ) ;
448+ effect . blurPass . blurMaterial . kernelSize = value - 1 ;
451449
452450 } ) ;
453451
454452 menu . add ( params , "use pattern" ) . onChange ( ( value ) => {
455453
456454 if ( value ) {
457455
458- effect . setPatternTexture ( assets . get ( "pattern-color" ) ) ;
456+ effect . patternTexture = assets . get ( "pattern-color" ) ;
459457 uniforms . get ( "patternScale" ) . value = params [ "pattern scale" ] ;
460458
461459 } else {
462460
463- effect . setPatternTexture ( null ) ;
461+ effect . patternTexture = null ;
464462
465463 }
466464
@@ -486,15 +484,13 @@ export class OutlineDemo extends PostProcessingDemo {
486484
487485 menu . addColor ( params , "visible edge" ) . onChange ( ( value ) => {
488486
489- uniforms . get ( "visibleEdgeColor" ) . value . setHex ( value )
490- . convertSRGBToLinear ( ) ;
487+ effect . visibleEdgeColor . setHex ( value ) . convertSRGBToLinear ( ) ;
491488
492489 } ) ;
493490
494491 menu . addColor ( params , "hidden edge" ) . onChange ( ( value ) => {
495492
496- uniforms . get ( "hiddenEdgeColor" ) . value . setHex ( value )
497- . convertSRGBToLinear ( ) ;
493+ effect . hiddenEdgeColor . setHex ( value ) . convertSRGBToLinear ( ) ;
498494
499495 } ) ;
500496
0 commit comments