2016-02-11 22:38:15 +00:00
|
|
|
import THREE from 'three';
|
|
|
|
import Scene from './Scene';
|
|
|
|
|
|
|
|
// This can only be accessed from Engine.renderer if you want to reference the
|
|
|
|
// same scene in multiple places
|
|
|
|
|
2016-03-11 18:10:36 +00:00
|
|
|
export default function(container, antialias) {
|
2016-02-11 22:38:15 +00:00
|
|
|
var renderer = new THREE.WebGLRenderer({
|
2016-03-11 18:10:36 +00:00
|
|
|
antialias: antialias
|
2016-10-07 10:46:52 +00:00
|
|
|
|
|
|
|
// Enabling this removes a lot of z-index intersecting but it also removes
|
|
|
|
// shadows due to a bug in three.js
|
|
|
|
//
|
|
|
|
// See: https://github.com/mrdoob/three.js/issues/7815
|
|
|
|
// logarithmicDepthBuffer: true
|
2016-02-11 22:38:15 +00:00
|
|
|
});
|
|
|
|
|
2016-02-23 23:11:49 +00:00
|
|
|
// TODO: Re-enable when this works with the skybox
|
|
|
|
// renderer.setClearColor(Scene.fog.color, 1);
|
2016-02-11 22:38:15 +00:00
|
|
|
|
2016-02-24 20:42:32 +00:00
|
|
|
renderer.setClearColor(0xffffff, 1);
|
2016-03-22 10:55:31 +00:00
|
|
|
|
|
|
|
// TODO: Re-enable this when perf issues can be solved
|
|
|
|
//
|
|
|
|
// Rendering double the resolution of the screen can be really slow
|
|
|
|
// var pixelRatio = window.devicePixelRatio;
|
|
|
|
var pixelRatio = 1;
|
|
|
|
|
|
|
|
renderer.setPixelRatio(pixelRatio);
|
2016-02-24 20:42:32 +00:00
|
|
|
|
2016-02-11 22:38:15 +00:00
|
|
|
// Gamma settings make things look nicer
|
|
|
|
renderer.gammaInput = true;
|
|
|
|
renderer.gammaOutput = true;
|
|
|
|
|
2016-02-25 22:32:06 +00:00
|
|
|
renderer.shadowMap.enabled = true;
|
2016-03-13 13:47:45 +00:00
|
|
|
|
|
|
|
// TODO: Work out which of the shadowmap types is best
|
|
|
|
// https://github.com/mrdoob/three.js/blob/r56/src/Three.js#L107
|
|
|
|
// renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
|
|
|
|
|
|
// TODO: Check that leaving this as default (CullFrontFace) is right
|
|
|
|
// renderer.shadowMap.cullFace = THREE.CullFaceBack;
|
2016-02-25 22:32:06 +00:00
|
|
|
|
2016-02-11 22:38:15 +00:00
|
|
|
container.appendChild(renderer.domElement);
|
|
|
|
|
|
|
|
var updateSize = function() {
|
|
|
|
renderer.setSize(container.clientWidth, container.clientHeight);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener('resize', updateSize, false);
|
|
|
|
updateSize();
|
|
|
|
|
|
|
|
return renderer;
|
|
|
|
};
|