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

Method initialize

demo/src/demos/ColorDepthDemo.js:86–143  ·  view source on GitHub ↗

* Creates the scene.

()

Source from the content-addressed store, hash-verified

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

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