webcomponent实现太阳系行星运行轨迹交互效果代码
代码语言:html
所属分类:其他
代码描述:webcomponent实现太阳系行星运行轨迹交互效果代码
代码标签: webcomponent 太阳系 行星 运行 轨迹 交互
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet"> <style> @layer reset, token, pen; @layer pen { html { overflow: auto; scrollbar-width: none; } body { display: flex; flex-direction: column; font-family: Space Mono, monospace; } ow-system { --cycle: 1320s; --cycle: 120s; --unit: calc(var(--scale, 1) * 95vmin); --sun-glow: #ba702f; --orbit-border-width: 1px; position: relative; isolation: isolate; flex: 1; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr; justify-content: center; align-items: center; block-size: calc(1 * var(--unit)); inline-size: calc(1 * var(--unit)); aspect-ratio: 1; margin: auto; background: radial-gradient(circle at center, var(--sun-glow), transparent 35%) no-repeat center/var(--unit) var(--unit); transition: --scale 5ms linear; -webkit-animation: --sun-glow var(--cycle) linear infinite; animation: --sun-glow var(--cycle) linear infinite; } ow-system::before { position: absolute; inset: 0; z-index: -1; background: url(https://res.cloudinary.com/chriskirknielsen/image/upload/c_crop,ar_1:1/v1729476626/image_uw02rg.png) no-repeat 50% 51%/contain; transform: translateY(0.375%); opacity: 0.5; } #sun { --orbit-radius: 0.00000000000000001; --body-radius: 0.05; --orbital-speed: 0; --w-color: #f6ab48; -webkit-animation: --orbit calc(var(--cycle) * 0.1) linear infinite; animation: --orbit calc(var(--cycle) * 0.1) linear infinite; } #sun ow-wanderer { -webkit-animation: --supernova var(--cycle) linear infinite; animation: --supernova var(--cycle) linear infinite; } #sun-station { --orbit-radius: 0.06; --body-radius: 0.0075; --orbital-speed: 0.9; --w-color: gold; } #hourglass-twins { --orbit-radius: 0.105; --body-radius: 0.0000001; --orbital-speed: 0.091667; --w-color: orangered; --initial-delay: -8.5s; } #hourglass-twins > ow-wanderer { display: flex; justify-content: center; align-items: center; } #hourglass-twins > ow-wanderer:defined[image] { --gap: calc(0.0075 * var(--unit)); } #hourglass-twins > ow-wanderer:defined[image]::before { content: ""; position: absolute; inset: 50%; flex-shrink: 0; block-size: var(--gap); inline-size: var(--gap); margin: auto; background: inherit; scale: 2; } #twins { --orbit-radius: 0.0075; --body-radius: 0.0000001; --orbital-speed: 0; } #ash-twin, #ember-twin { --orbit-radius: 0.0075; --body-radius: 0.005; --orbital-speed: 0; } #ember-twin { --w-offset: 50%; } #timber-hearth { --orbit-radius: 0.18; --body-radius: 0.0075; --orbital-speed: 0.191667; --w-color: greenyellow; } #attlerock { --orbit-radius: 0.0125; --body-radius: 0.005; --orbital-speed: 0; --w-color: slategray; } #brittle-hollow { --orbit-radius: 0.245; --body-radius: 0.01; --orbital-speed: 0.3; --w-color: darkturquoise; } #hollows-lantern { --orbit-radius: 0.015; --body-radius: 0.005; --orbital-speed: 0; --w-color: darkorange; } #giants-deep { --orbit-radius: 0.3425; --body-radius: 0.0225; --orbital-speed: 0.5; --w-color: darkseagreen; } #orbital-probe-cannon { --orbit-radius: 0.025; --body-radius: 0.005; --orbital-speed: 0; --w-color: gold; --w-angle: 90deg; } #dark-bramble { --orbit-radius: 0.4175; --body-radius: 0.01625; --orbital-speed: 0.6667; --w-color: darkslateblue; } #interloper { --orbit-radius: 0.278; --body-radius: 0.0075; --orbit-ratio: 0.575; --orbital-speed: 0.441667; --tilt-axis: -8.9deg; --w-color: cyan; --orbit-dir: -1; transform-origin: 93.5% 47.6%; transform: translate(-41%, 0) rotate(var(--tilt-axis)); } #interloper ow-wanderer { --revolution-animation: none; offset-rotate: auto -90deg; } #interloper ow-wanderer, #interloper ow-name { -webkit-animation-timing-function: cubic-bezier(0.25, 0.6, 0.75, 0.4); animation-timing-function: cubic-bezier(0.25, 0.6, 0.75, 0.4); } #quantum-moon { --orbit-radius: 0.0275; --body-radius: 0.0075; --orbital-speed: 0.5; --w-color: slategray; --w-offset: 50%; } #white-hole-station { --orbit-radius: 0.5; --body-radius: 0.01625; --orbital-speed: 0.85; --w-color: gold; } ow-orbit { position: relative; z-index: -1; pointer-events: none; grid-area: 1/1/-1/-1; place-self: center; display: flex; block-size: calc(var(--orbit-radius) * 2 * var(--unit) * var(--orbit-ratio, 1)); inline-size: calc(var(--orbit-radius) * 2 * var(--unit)); border: var(--orbit-border-width) solid #8888; border-color: color-mix(in oklch, transparent, color-mix(in oklch, var(--fg), var(--w-color))); border-radius: 50%; } ow-wanderer { --revolution-animation: --orbit calc(var(--cycle) * var(--orbital-speed) * 0.5) linear infinite; position: absolute; z-index: 2; pointer-events: auto; inset-block-start: 0; inset-inline-start: 50%; display: block; block-size: calc(var(--body-radius) * 2 * var(--unit)); inline-size: calc(var(--body-radius) * 2 * var(--unit)); aspect-ratio: 1; border-radius: 50%; background: var(--w-color, deeppink); offset-anchor: 50% 50%; offset-rotate: auto calc(-90deg + var(--w-angle, 0deg)); offset-distance: var(--w-offset, 0%); -webkit-animation: var(--orbit-animation), var(--revolution-animation); animation: var(--orbit-animation), var(--revolution-animation); transform-origin: 50% 50%; } ow-wanderer:defined[image] { background: var(--w-image) no-repeat 50%/contain; } ow-wanderer, ow-name { --orbit-animation: --w-orbit calc(var(--cycle) * var(--orbital-speed)) linear var(--initial-delay, -17s) infinite; offset-path: ellipse(calc(var(--orbit-radius) * var(--unit)) calc(var(--orbit-radius) * var(--unit) * var(--orbit-ratio, 1)) at 50% 50%); } ow-name { position: absolute; z-index: 3; inset-block-end: 100%; inset-inline-start: 50%; pointer-events: auto; min-block-size: 1em; inline-size: calc(0.25 * var(--unit)); max-inline-size: 50vw; margin-block: auto; font-size: clamp(8px, 1vmin + 0.25rem, 24px); text-transform: uppercase; color: var(--fg); text-shadow: 0 1px 2px var(--bg); offset-anchor: -2em 100%; offset-rotate: calc(var(--tilt-axis, 0deg) * -1); -webkit-animation: var(--orbit-animation); animation: var(--orbit-animation); } ow-name[shy] { visibility: hidden; } ow-orbit[path=false], ow-wanderer > ow-orbit { border-color: transparent; } ow-system > ow-orbit:has(:hover), ow-system > ow-orbit:has(:hover) ow-orbit { border-color: cyan; } ow-wanderer > ow-orbit { position: absolute; inset: 50% 0 0 50%; place-self: unset; transform: translate(-50%, -50%); } ow-system.paused, ow-system.paused * { -webkit-animation-play-state: paused !important; animation-play-state: paused !important; } } @layer token { :root { --fg: #fcfefc; --bg: #050215; } } @property --w-color { syntax: "<color>"; inherits: true; initial-value: deeppink; } @property --sun-glow { syntax: "<color>"; inherits: true; initial-value: deeppink; } @property --scale { syntax: "<number>"; inherits: true; initial-value: 1; } @-webkit-keyframes --orbit { to { transform: rotate(-360deg); } } @keyframes --orbit { to { transfor.........完整代码请登录后点击上方下载按钮下载查看
网友评论0