The issue: The Three.js 3D cube I designed with a wireframe or outline mode looks fine on desktop and tablet devices, but when viewed on mobile, the wireframe becomes too thin to be practical. I need to maintain the same wireframe thickness for mobile as it appears on desktop and tablet.
Examples: Below are screenshots illustrating the problem:
- Desktop (simulated iPhone 6 size in Chrome browser) -
https://i.sstatic.net/8N5Nn.png
- Mobile (actual iPhone 6 size in iOS Chrome browser) -
https://i.sstatic.net/dWMLt.png
Current code snippet:
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// Make the site responsive
window.addEventListener('resize', function(){
var width = window.innerWidth;
var height = window.innerHeight;
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
});
var geometry = new THREE.BoxGeometry( 1.5, 1.5, 1.5 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00, wireframe: true } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
camera.position.z = 5;
function render() {
requestAnimationFrame( render );
cube.rotation.x += 0.025;
cube.rotation.y += 0.025;
renderer.render( scene, camera );
}
render();
html,body {
margin: 0;
overflow: hidden;
}
canvas {
width: 100%;
height: 100%;
background-color: black;
}
h1 {
font-family: 'Maven Pro', sans-serif;
font-size: 3em;
}
p {
font-family: 'Lato', sans-serif;
font-size: 1em;
}
#textthing {
position: absolute;
margin-bottom: 60px;
color: #00FF00;
/**height: 90%;**/
width:100%;
text-align: center;
bottom: 0;
}
<link href='https://fonts.googleapis.com/css?family=Maven+Pro' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Lato:400,300' rel='stylesheet' type='text/css'>
<div id="textthing">
<h1>weeflix LLC</h1>
<!--<h2>Coming soon.</h2>-->
<p>Jake Schnieder || Thomas Bisnitsz</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r77/three.min.js"></script>