Hi there ! I’m sure I’m missing something, but I can’t get anything to render (not even basic render pass) through EffectComposer…
Here is my code :
<!DOCTYPE html>
<html>
<head>
<title>fml</title>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/three.min.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/js/controls/OrbitControls.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/js/loaders/OBJLoader.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/js/loaders/MTLLoader.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/jsm/postprocessing/EffectComposer.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/jsm/postprocessing/RenderPass.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/jsm/postprocessing/ShaderPass.js"></script>
<script src="https://r105.threejsfundamentals.org/threejs/resources/threejs/r105/jsm/postprocessing/SavePass.js"></script>
<script>
//Scene
scene = new THREE.Scene();
//Camera
camera = new THREE.PerspectiveCamera( 55, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 30, 30, 100 );
//Light
directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
scene.add( directionalLight );
//Loader
mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath( "OBJ/" );
mtlLoader.load("Helmet32.mtl",function ( materials ){
materials.preload();
objLoader = new THREE.OBJLoader();
objLoader.setMaterials( materials );
objLoader.setPath("OBJ/");
objLoader.load("Helmet33.obj",function ( object ){
object.scale.set(0.1, 0.1, 0.1);
scene.add(object);
})
});
//Skybox (disabled)
geometry = new THREE.BoxGeometry( 10000, 10000, 10000 );
cubeMaterials = [
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/pz.png'), side: THREE.DoubleSide,color : 0x111455 } ),
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/nx.png'), side: THREE.DoubleSide,color : 0x111455 } ),
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/ny.png'), side: THREE.DoubleSide,color : 0x111455 } ),
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/py.png'), side: THREE.DoubleSide,color : 0x111455 } ),
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/nz.png'), side: THREE.DoubleSide,color : 0x111455 } ),
new THREE.MeshBasicMaterial({map: new THREE.TextureLoader( ).load('textures/skbx/px.png'), side: THREE.DoubleSide,color : 0x111455 } ),
]
cubeMaterial = new THREE.MeshFaceMaterial( cubeMaterials );
cube = new THREE.Mesh( geometry, cubeMaterial );
//scene.add( cube );
scene.background = new THREE.Color( 0xffffff );
cube.position.set (0, 000, 0);
//Renderer
renderer = new THREE.WebGLRenderer({
antialias : true
});
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
//Controls
controls = new THREE.OrbitControls( camera );
THREE.OrbitControls = function ( camera ){
}
controls.enablePan = false;
controls.enableZoom = false;
controls.maxPolarAngle = 1.6;
controls.minPolarAngle = 0.2;
//Movement (rotate on scroll)
ySpeed = 0.1;
document.addEventListener("scroll", onDocumentKeyDown, false);
function onDocumentKeyDown(event) {
logo.rotation.y += ySpeed;
};
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
composer = new THREE.EffectComposer(renderer);
renderPass = new THREE.RenderPass(scene, camera);
composer.addPass(renderPass);
renderPass.renderToScreen = true;
//Render loop
render = function () {
//renderer.render( scene, camera );
requestAnimationFrame(render);
composer.render();
};
render();
</script>
</body>
</html>