Lathed Dome with rounded edges and flat floor
Based on a fork of this Jsfiddle by Paul West, [email protected]: https://jsfiddle.net/prisoner849/Lsn3pq90/
by Chrisssie
HTML
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/[email protected]/build/three.module.js",
"three/addons/": "https://unpkg.com/[email protected]/examples/jsm/"
}
}
</script>
CSS
body{
overflow: hidden;
margin: 0;
}
JavaScript
import * as THREE from "three";
import {
OrbitControls
} from "three/addons/controls/OrbitControls.js";
import {toCreasedNormals} from "three/addons/utils/BufferGeometryUtils.js";
import { VertexNormalsHelper } from 'three/addons/helpers/VertexNormalsHelper.js';
let texture;
const points = [];
const PI_180 = Math.PI / 180.0;
const textureLoader = new THREE.TextureLoader();
texture = textureLoader.load(
'https://vielzutun.ch/wordpress/Danni_animation/Three.js/textures/pano.jpg',)
texture.colorSpace = THREE.SRGBColorSpace
texture.mapping = THREE.EquirectangularReflectionMapping;
let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 1, 100);
camera.position.set(0, 0, 20);
let renderer = new THREE.WebGLRenderer({
antialias: true
});
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
window.addEventListener("resize", event => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
})
let controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
let light = new THREE.DirectionalLight(0xffffff, Math.PI);
light.position.set(1, 0.25, 1);
scene.add(light, new THREE.AmbientLight(0xffffff, Math.PI * 0.5));
// ***************** PleasureDome ****************
var smallRadius = 1;
var largeRadius = 5;
var r = largeRadius - smallRadius;
var steps =16 ;
points.length = 0;
points.push( new THREE.Vector2( 0.0, 0.0 ) ); // floor center
points.push( new THREE.Vector2( -r, 0.0 ) ); // floor transition point to smallRadius
addArcToPath( -r, smallRadius, smallRadius, 270, 180, steps); // 90° arc with smallRadius
//points.push( new THREE.Vector2( -largeRadius, smallRadius) );
addArcToPath( 0, smallRadius, largeRadius, 180, 90, steps); // 90° arc to zenith
let c = new THREE.MeshBasicMaterial( {
envMap: texture,
combine:...