I stumbled upon a three.js 3D object featuring a unique touch - a 404 text with a floating orb replacing the zero. Upon importing its code, it rendered successfully, albeit against a black background. Despite my efforts to tweak values and apply background colors to the container, I couldn't achieve a transparent background. Even inspecting the elements yielded no results. My ultimate goal is to make the background of the 3D object transparent.
(I even attempted embedding it on a new website, but encountered the same issue.)
Below is the provided code:
HTML:
<div class="cont-404">
<p class="mega">4<span class="boom">0</span>4
<div class="bola"></div>
</p>
<p class="mini">That's an error.</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.min.js"></script>
CSS:
.cont-404{
float: right;
}
.mini {
font-size: 1em;
color: #fff;
line-height: 9em;
text-indent: 2.5em;
position: absolute;
left: 50%;
top: 50%;
}
.mega, .bola{
line-height: 1.65em;
font-weight: bold;
font-size: 11em;
color: #fff;
font-family: 'Roboto', saappeared
width: 300px;
height: 300px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -150px;
margin-top: -150px;}
.boom {color: #f5f5f5; }
JS:
var $container = $('.bola');
var renderer = new THREE.WebGLRenderer({ antialias: true });
var camera = new THREE.PerspectiveCamera(80, 1, 0.1, 10000);
var scene = new THREE.Scene();
scene.add(camera);
renderer.setSize(300, 300);
$container.append(renderer.domElement);
///////////////////////////////////////////////
// Camera
camera.position.z = 200;
// Material
var pinkMat = new THREE.MeshPhongMaterial({
color: new THREE.Color("#C3073F"),
emissive: new THREE.Color("rgb(0,0,0)"),
specular: new THREE.Color("#C3073F"),
shininess: 50,
shading: THREE.FlatShading,
transparent: 1,
opacity: 1
});
var L1 = new THREE.PointLight(0xffffff, 1);
L1.position.z = 100;
L1.position.y = 100;
L1.position.x = 100;
scene.add(L1);
var L2 = new THREE.PointLight(0xffffff, 0.8);
L2.position.z = 200;
L2.position.y = 400;
L2.position.x = -100;
scene.add(L2);
// IcoSphere -> THREE.IcosahedronGeometry(80, 1) 1-4
var Ico = new THREE.Mesh(new THREE.IcosahedronGeometry(75, 1), pinkMat);
Ico.rotation.z = 0.5;
scene.add(Ico);
function update() {
Ico.rotation.x += 2 / 100;
Ico.rotation.y += 2 / 100;
}
// Render
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
update();
}
render();