three.js dev template - module
HTML
<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.155/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.155/examples/jsm/"
}
}
</script>
<div id="container">
</div>
CSS
body {
margin: 0;
padding: 0;
background: none;
}
JavaScript
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { FontLoader } from 'three/addons/loaders/FontLoader.js';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';
let camera, stats;
let composer, renderer, mixer, clock;
let orbit
let scene
let font
let typeface = 'https://unpkg.com/three@0.155/examples/fonts/gentilis_regular.typeface.json';
function bbox(target) {
return new THREE.Box3().setFromObject(target)
}
function reCenterText(mesh) {
const box = new THREE.Box3().setFromObject( mesh );
box.getCenter( mesh.position );
mesh.position.multiplyScalar( - 1 );
}
function degreesToRadians(degrees) {
return degrees * Math.PI/180
}
function randomValues(values) {
return values[Math.floor(Math.random() * values.length)]
}
function randomBetweenTwo(min, max) {
return Math.random() * (min - max) + max;
}
function createText(text, font) {
const geometry = new TextGeometry(text, {
font,
size: 20,
height: 5
});
const materials = [
new THREE.MeshStandardMaterial({ color: '#fff', flatShading: true, emissive: '#70f5ff', emissiveIntensity: 4 }),
new THREE.MeshPhongMaterial({ color: '#fff', flatShading: true, emissive: '#0e35d3', emissiveIntensity: 2 })
];
const mesh = new THREE.Mesh(geometry, materials);
const mesh2 = new THREE.Mesh(geometry, materials);
const group = new THREE.Group()
//Caixa do texto
const { x } = bbox(mesh).getSize(new THREE.Vector3(0,0,0))
const planeGeo = new THREE.BoxGeometry( x + 10, 30, 5 );
const planeMat1 = new THREE.MeshStandardMaterial( {color: '#0c3d59', side: THREE.DoubleSide, emissive: '#70f5ff',...