MCPcopy Create free account
hub / github.com/pmndrs/postprocessing / initialize

Method initialize

demo/src/demos/PixelationDemo.js:81–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79 }
80
81 initialize() {
82
83 const scene = this.scene;
84 const assets = this.assets;
85 const composer = this.composer;
86 const renderer = composer.getRenderer();
87 const domElement = renderer.domElement;
88
89 // Camera
90
91 const aspect = window.innerWidth / window.innerHeight;
92 const vFoV = calculateVerticalFoV(90, Math.max(aspect, 16 / 9));
93 const camera = new PerspectiveCamera(vFoV, aspect, 0.3, 2000);
94 this.camera = camera;
95
96 // Controls
97
98 const { position, quaternion } = camera;
99 const controls = new SpatialControls(position, quaternion, domElement);
100 const settings = controls.settings;
101 settings.rotation.sensitivity = 2.2;
102 settings.rotation.damping = 0.05;
103 settings.translation.sensitivity = 3.0;
104 settings.translation.damping = 0.1;
105 controls.position.set(-9, 0.5, 0);
106 controls.lookAt(0, 3, -3.5);
107 this.controls = controls;
108
109 // Sky
110
111 scene.background = new Color(0xeeeeee);
112
113 // Lights
114
115 scene.add(...Sponza.createLights());
116
117 // Objects
118
119 scene.add(assets.get(Sponza.tag));
120
121 // Passes
122
123 const smaaEffect = new SMAAEffect(
124 assets.get("smaa-search"),
125 assets.get("smaa-area"),
126 SMAAPreset.HIGH,
127 EdgeDetectionMode.DEPTH
128 );
129
130 smaaEffect.edgeDetectionMaterial.setEdgeDetectionThreshold(0.01);
131
132 const pixelationEffect = new PixelationEffect(5);
133
134 const effectPass = new EffectPass(camera, pixelationEffect);
135 const smaaPass = new EffectPass(camera, smaaEffect);
136
137 this.effect = pixelationEffect;
138

Callers

nothing calls this directly

Calls 6

calculateVerticalFoVFunction · 0.85
getRendererMethod · 0.80
setMethod · 0.80
addMethod · 0.80
addPassMethod · 0.80

Tested by

no test coverage detected