three实现三维空灵模型几何体生成旋转效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维空灵模型几何体生成旋转效果代码
代码标签: three 三维 空灵 模型 几何体 生成 旋转
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
margin: 0;
overflow: hidden;
font-family: Avenir, Montserrat, Corbel, "URW Gothic", source-sans-pro,
sans-serif;
font-weight: 900;
}
canvas {
display: block;
}
#container {
position: fixed;
width: 100%;
height: 100%;
background: #0a192f;
}
#controls {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 20px;
align-items: center;
background: rgba(0, 0, 0, 0.3);
padding: 15px 25px;
border-radius: 8px;
backdrop-filter: blur(5px);
}
.button {
padding: 10px 20px;
font-family: inherit;
font-size: 14px;
color: white;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 4px;
cursor: pointer;
transition: all 0.3s ease;
}
.button:hover {
background: rgba(255, 255, 255, 0.2);
}
.button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.checkbox-wrapper {
display: flex;
align-items: center;
gap: 8px;
color: white;
font-size: 14px;
}
input[type="checkbox"] {
cursor: pointer;
width: 16px;
height: 16px;
}
#title {
color: white;
top: 10px;
position: absolute;
width: 100%;
text-align: center;
user-select: none;
pointer-events: none;
font-size: 48pt;
color: rgba(255, 165, 0, 0.4);
font-weight: 900;
letter-spacing: 2px;
color: transparent;
text-shadow: 0 0 10px black;
background: linear-gradient(
hsla(39, 100%, 80%, 0.8),
hsla(39, 100%, 80%, 0.8)
);
-webkit-background-clip: text;
background-clip: text;
}
// Add this to the style section
.button-group {
display: flex;
gap: 8px;
align-items: center;
}
.name {
position: absolute;
z-index: 10;
bottom: 10px;
right: 10px;
font-family: sans-serif;
color: white;
}
</style>
</head>
<body translate="no">
<div id="container"></div>
<div id="title">Ethereal Rotations</div>
<div id="subtitle">Each view creates a unique perspective</div>
<div id="controls">
<button id="generateButton" class="button">Generate New Shape</button>
<div class="button-group">
<div class="checkbox-wrapper">
<input type="checkbox" checked id="surfaceToggle">
<label for="surfaceToggle">Surface</label>
</div>
<div class="checkbox-wrapper">
<input type="checkbox"id="realSurfaceToggle" />
<label for="realSurfaceToggle">Real Surface</label>
</div>
</div>
<button id="downloadButton" class="button">Download View as SVG</button>
</div>
<script type="importmap">
{
"imports": {
"three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/164/three.module.js",
"three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/"
}
}
</script>
<script type="module">
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
import { SVGRenderer } from "three/addons/renderers/SVGRenderer.js";
let scene, camera, renderer, controls;
let pathLines = [];
let surfaces = [];
let isBuilding = false;
let buildIndex = 0;
let basePath = [];
let hue;
let generateButton, surfaceToggle, downloadButton;
// Add these variables to the top of the script
let lights = [];
let realSurfaceToggle;
let isRealSurface = false;
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000);
camera.position.set(5, 3, 5);
renderer = new THREE.WebGLRenderer({
antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x0a192f);
document.getElementById("container").appendChild(renderer.domElement);
controls = new OrbitControl.........完整代码请登录后点击上方下载按钮下载查看
网友评论0