vue+css实现万圣节三维南瓜头可旋转效果代码

代码语言:html

所属分类:三维

代码描述:vue+css实现万圣节三维南瓜头可旋转效果代码

代码标签: vue css 万圣节 三维 南瓜头 可旋转

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Inconsolata&amp;display=swap'>
  
<style>
body {
  height: 100vh;
  margin: 0;
  background: linear-gradient(#1c0033, #0d0e11 50%);
  overflow: hidden;
  font-family: Inconsolata, monospace, sans-serif;
}
body * {
  box-sizing: border-box;
}
body #app {
  height: 100vh;
}
body details {
  margin: 1em 0 0 1em;
  color: white;
  z-index: 2;
  position: relative;
  cursor: pointer;
  position: absolute;
}
body #view {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 500px;
  border: 0;
  outline: 0;
}
body #view * {
  transform-style: preserve-3d;
}
body #view #scene #space {
  position: relative;
  display: grid;
  grid-template-areas: "overlap";
  transform-style: preserve-3d;
  justify-content: center;
  align-items: flex-end;
  transform: rotateX(-20deg) rotateY(20deg);
  font-size: calc(5vh + 1vw);
  transform-origin: center 90%;
  -pointer-events: none;
}
body #view #scene #space > * {
  grid-area: overlap;
}
body #view #scene #space .absolute {
  position: absolute;
}
body #view #scene #space .reference {
  transform-style: preserve-3d;
  display: grid;
  grid-template-areas: "overlap";
}
body #view #scene #space .reference > * {
  grid-area: overlap;
  transform-origin: top left;
  align-items: end;
}
body #view #scene #space .group {
  position: absolute;
  bottom: 0;
  transform-origin: bottom left;
  transform: translateX(calc(var(--posX))) translateY(calc(var(--posY) * -1)) translateZ(var(--posZ)) rotateX(var(--rotX)) rotateY(var(--rotY)) rotateZ(var(--rotZ));
}
body #view #scene #space .group > .reference {
  align-items: end;
}
body #view #scene #space .group.shaded > .reference .cuboid > .front, body #view #scene #space .group.shaded > .reference .cuboid > .back {
  filter: brightness(0.9);
}
body #view #scene #space .group.shaded > .reference .cuboid > .left, body #view #scene #space .group.shaded > .reference .cuboid > .right {
  filter: brightness(0.8);
}
body #view #scene #space .group.shaded > .reference .cuboid > .bottom {
  filter: brightness(0.7);
}
body #view #scene #space .cuboid,
body #view #scene #space .plane {
  position: absolute;
  bottom: 0;
  transform-origin: bottom left;
  width: var(--sizeX);
  height: var(--sizeY);
  transform: translateX(var(--posX)) translateY(calc(var(--posY) * -1)) translateZ(var(--posZ)) rotateX(var(--rotX)) rotateY(var(--rotY)) rotateZ(var(--rotZ));
  align-items: start;
}
body #view #scene #space .cuboid.test > *, body #view #scene #space .cuboid.plane.test,
body #view #scene #space .plane.test > *,
body #view #scene #space .plane.plane.test {
  border: solid 1px black;
  background: linear-gradient(#f005, #00f5);
  box-shadow: 0 0 0 1px #0005;
}
body #view #scene #space .cuboid.test > *.top, body #view #scene #space .cuboid.plane.test.top,
body #view #scene #space .plane.test > *.top,
body #view #scene #space .plane.plane.test.top {
  background: radial-gradient(circle, #fff 5%, #f0f5 20%);
}
body #view #scene #space .cuboid.test > *.bottom, body #view #scene #space .cuboid.plane.test.bottom,
body #view #scene #space .plane.test > *.bottom,
body #view #scene #space .plane.plane.test.bottom {
  background: radial-gradient(circle, #000 5%, #0f05 20%);
}
body #view #scene #space .cuboid.test > *.back, body #view #scene #space .cuboid.plane.test.back,
body #view #scene #space .plane.test > *.back,
body #view #scene #space .plane.plane.test.back {
  background: radial-gradient(circle, #f00 5%, #0000 20%), linear-gradient(#f005, #00f5);
}
body #view #scene #space .cuboid.plane.overflow, body #view #scene #space .cuboid.overflow > *,
body #view #scene #space .plane.plane.overflow,
body #view #scene #space .plane.overflow > * {
  box-shadow: 0 0 0 0.5px currentColor;
}
body #view #scene #space .cuboid._top > .top, body #view #scene #space .cuboid._bottom > .bottom, body #view #scene #space .cuboid._right > .right, body #view #scene #space .cuboid._left > .left, body #view #scene #space .cuboid._front > .front, body #view #scene #space .cuboid._back > .back,
body #view #scene #space .plane._top > .top,
body #view #scene #space .plane._bottom > .bottom,
body #view #scene #space .plane._right > .right,
body #view #scene #space .plane._left > .left,
body #view #scene #space .plane._front > .front,
body #view #scene #space .plane._back > .back {
  display: none;
}
body #view #scene #space .cuboid.plane.color, body #view #scene #space .cuboid.color > *,
body #view #scene #space .plane.plane.color,
body #view #scene #space .plane.color > * {
  background-color: currentColor;
}
body #view #scene #space .cuboid > *,
body #view #scene #space .plane > * {
  position: absolute;
}
body #view #scene #space .cuboid .top,
body #view #scene #space .plane .top {
  height: var(--sizeZ);
  width: var(--sizeX);
  transform: rotateX(90deg);
}
body #view #scene #space .cuboid .bottom,
body #view #scene #space .plane .bottom {
  height: var(--sizeZ);
  width: var(--sizeX);
  transform: translateY(var(--sizeY)) rotateX(90deg);
}
body #view #scene #space .cuboid .left,
body #view #scene #space .plane .left {
  height: var(--sizeY);
  width: var(--sizeZ);
  transform: rotateY(-90deg);
}
body #view #scene #space .cuboid .right,
body #view #scene #space .plane .right {
  height: var(--sizeY);
  width: var(--sizeZ);
  transform: translateX(var(--sizeX)) rotateY(-90deg);
}
body #view #scene #space .cuboid .front,
body #view #scene #space .plane .front {
  width: var(--sizeX);
  height: var(--sizeY);
  transform: translateZ(var(--sizeZ));
}
body #view #scene #space .cuboid .back,
body #view #scene #space .plane .back {
  width: var(--sizeX);
  height: var(--sizeY);
}
body #view #scene #space .cuboid.shaded.plane.front, body #view #scene #space .cuboid.shaded.plane.back, body #view #scene #space .cuboid.shaded > .front, body #view #scene #space .cuboid.shaded > .back,
body #view #scene #space .plane.shaded.plane.front,
body #view #scene #space .plane.shaded.plane.back,
body #view #scene #space .plane.shaded > .front,
body #view #scene #space .plane.shaded > .back {
  filter: brightness(0.9);
}
body #view #scene #space .cuboid.shaded.plane.left, body #view #scene #space .cuboid.shaded.plane.right, body #view #scene #space .cuboid.shaded > .left, body #view #scene #space .cuboid.shaded > .right,
body #view #scene #space .plane.shaded.plane.left,
body #view #scene #space .plane.shaded.plane.right,
body #view #scene #space .plane.shaded > .left,
body #view #scene #space .plane.shaded > .right {
  filter: brightness(0.8);
}
body #view #scene #space .cuboid.shaded.plane.top, body #view #scene #space .cuboid.shaded.plane.bottom, body #view #scene #space .cuboid.shaded > .top, body #view #scene #space .cuboid.shaded > .bottom,
body #view #scene #space .plane.shaded.plane.top,
body #view #scene #space .plane.shaded.plane.bottom,
body #view #scene #space .plane.shaded > .top,
body #view #scene #space .plane.shaded > .bottom {
  filter: brightness(0.7);
}
body #view #scene #space .frustum {
  position: absolute;
  bottom: 0;
  transform-origin: bottom left;
  width: var(--sizeX);
  height: var(--sizeY);
  transform: translateX(var(--posX)) translateY(calc(var(--posY) * -1)) translateZ(var(--posZ)) rotateX(var(--rotX)) rotateY(var(--rotY)) rotateZ(var(--rotZ));
  align-items: start;
}
body #view #scene #space .frustum.test > * {
  border: solid 1px black;
  background: linear-gradient(#f005, #00f5);
  box-shadow: 0 0 0 1px #0005;
}
body #view #scene #space .frustum.test > *.top {
  background: radial-gradient(circle, #fff 5%, #f0f5 20%);
}
body #view #scene #space .frustum.test > *.bottom {
  background: radial-gradient(circle, #000 5%, #0f05 20%);
}
body #view #scene #space .frustum.test > *.back {
  background: radial-gradient(circle, #f00 5%, #0000 20%), linear-gradient(#f005, #00f5);
}
body #view #scene #space .frustum.overflow > * {
  box-shadow: 0 0 0 0.5px currentColor;
}
body #view #scene #space .frustum.overflow > *.left {
  -webkit-clip-path: polygon(calc(var(--lrTopL) - 1px) calc(0% - 1px), calc(var(--lrTopR) + 1px) calc(0% - 1px), calc(var(--lrBotR) + 1px) calc(100% + 1px), calc(var(--lrBotL) - 1px) calc(100% + 1px));
          clip-path: polygon(calc(var(--lrTopL) - 1px) calc(0% - 1px), calc(var(--lrTopR) + 1px) calc(0% - 1px), calc(var(--lrBotR) + 1px) calc(100% + 1px), calc(var(--lrBotL) - 1px) calc(100% + 1px));
}
body #view #scene #space .frustum.overflow > *.right {
  -webkit-clip-path: polygon(calc(var(--lrTopL) - 1px) calc(0% - 1px), calc(var(--lrTopR) + 1px) calc(0% - 1px), calc(var(--lrBotR) + 1px) calc(100% + 1px), calc(var(--lrBotL) - 1px) calc(100% + 1px));
          clip-path: polygon(calc(var(--lrTopL) - 1px) calc(0% - 1px), calc(var(--lrTopR) + 1px) calc(0% - 1px), calc(var(--lrBotR) + 1px) calc(100% + 1px), calc(var(--lrBotL) - 1px) calc(100% + 1px));
}
body #view #scene #space .frustum.overflow > *.front {
  -webkit-clip-path: polygon(calc(var(--fbTopL) - 1px) calc(0% - 1px), calc(var(--fbTopR) + 1px) calc(0% - 1px), calc(var(--fbBotR) + 1px) calc(100% + 1px), calc(var(--fbBotL) - 1px) calc(100% + 1px));
          clip-path: polygon(calc(var(--fbTopL) - 1px) calc(0% - 1px), calc(var(--fbTopR) + 1px) calc(0% - 1px), calc(var(--fbBotR) + 1px) calc(100% + 1px), calc(var(--fbBotL) - 1px) calc(100% + 1px));
}
body #view #scene #space .frustum.overflow > *.back {
  -webkit-clip-path: polygon(calc(var(--fbTopL) - 1px) calc(0% - 1px), calc(var(--fbTopR) + 1px) calc(0% - 1px), calc(var(--fbBotR) + 1px) calc(100% + 1px), calc(var(--fbBotL) - 1px) calc(100% + 1px));
          clip-path: polygon(calc(var(--fbTopL) - 1px) calc(0% - 1px), calc(var(--fbTopR) + 1px) calc(0% - 1px), calc(var(--fbBotR) + 1px) calc(100% + 1px), calc(var(--fbBotL) - 1px) calc(100% + 1px));
}
body #view #scene #space .frustum._top > .top, body #view #scene #space .frustum._bottom > .bottom, body #view #scene #space .frustum._right > .right, body #view #scene #space .frustum._left > .left, body #view #scene #space .frustum._front > .front, body #view #scene #space .frustum._back > .back {
  display: none;
}
body #view #scene #space .frustum.color > * {
  background-color: currentColor;
}
body #view #scene #space .frustum > * {
  position: absolute;
}
body #view #scene #space .frustum .top {
  height: var(--topZ);
  width: var(--topX);
  transform: translateX(var(--offsetX)) translateZ(var(--offsetZ)) rotateX(90deg);
}
body #view #scene #space .frustum .bottom {
  height: var(--botZ);
  width: var(--botX);
  transform: translateY(var(--height)) rotateX(90deg);
}
body #view #scene #space .frustum .left {
  -webkit-clip-path: polygon(var(--lrTopL) 0%, var(--lrTopR) 0%, var(--lrBotR) 100%, var(--lrBotL) 100%);
          clip-path: polygon(var(--lrTopL) 0%, var(--lrTopR) 0%, var(--lrBotR) 100%, var(--lrBotL) 100%);
  height: var(--leftHeight);
  width: var(--lrSideWidth);
  transform: translateX(var(--offsetX)) translateZ(var(--lrPos)) rotateY(-90deg) rotateX(var(--lFaceAngle));
}
body #view #scene #space .frustum .right {
  -webkit-clip-path: polygon(var(--lrTopL) 0%, var(--lrTopR) 0%, var(--lrBotR) 100%, var(--lrBotL) 100%);
          clip-path: polygon(var(--lrTopL) 0%, var(--lrTopR) 0%, var(--lrBotR) 100%, var(--lrBotL) 100%);
  height: var(--rightHeight);
  width: var(--lrSideWidth);
  transform: translateX(calc(var(--botX) + var(--revOffsetX))) translateZ(var(--lrPos)) rotateY(-90deg) rotateX(var(--rFaceAngle));
}
body #view #scene #space .frustum .front {
  -webkit-clip-path: polygon(var(--fbTopL) 0%, var(--fbTopR) 0%, var(--fbBotR) 100%, var(--fbBotL) 100%);
          clip-path: polygon(var(--fbTopL) 0%, var(--fbTopR) 0%, var(--fbBotR) 100%, var(--fbBotL) 100%);
  height: var(--frontHeight);
  width: var(--fbSideWidth);
  transform: translateX(var(--fbPos)) translateZ(calc(var(--offsetZ) + var(--topZ))) rotateX(var(--fFaceAngle));
}
body #view #scene #space .frustum .back {
  -webkit-clip-path: polygon(var(--fbTopL) 0%, var(--fbTopR) 0%, var(--fbBotR) 100%, var(--fbBotL) 100%);
          clip-path: polygon(var(--fbTopL) 0%, var(--fbTopR) 0%, var(--fbBotR) 100%, var(--fbBotL) 100%);
  height: var(--backHeight);
  width: var(--fbSideWidth);
  transform: translateX(var(--fbPos)) translateZ(var(--offsetZ)) rotateX(var(--bFaceAngle));
}
body #view #scene #space .frustum.shaded > .front, body #view #scene #space .frustum.shaded > .back {
  filter: brightness(0.9);
}
body #view #scene #space .frustum.shaded > .left, body #view #scene #space .frustum.shaded > .right {
  filter: brightness(0.8);
}
body #view #scene #space .frustum.shaded > .top, body #view #scene #space .frustum.shaded > .bottom {
  filter: brightness(0.7);
}
body #view #scene #space .cylinder {
  position: absolute;
  bottom: 0;
  transform-origin: bottom left;
  transform: translateX(calc(var(--posX))) translateY(calc(var(--posY) * -1)) translateZ(calc(var(--posZ) + var(--radius))) rotateX(var(--rotX)) rotateY(var(--rotY)) rotateZ(var(--rotZ));
  height: var(--height);
  width: var(--diameter);
}
body #view #scene #space .cylinder.test > .cylinder-face {
  border: solid 1px black;
  background: linear-gradient(#f005, #00f5);
}
body #view #scene #space .cylinder.color > * {
  background-color: currentColor;
}
body #view #scene #space .cylinder > .cylinder-face {
  position: absolute;
  height: var(--height);
  width: var(--faceWidth);
  transform: translateX(calc(var(--radius) - var(--faceWidth) / 2)) rotateY(calc(var(--pos) * (360deg / var(--detailLevel)))) translateZ(var(--dist));
  transform-origin: center top;
}
body #view #scene #space .pyramid {
  position: absolute;
  bottom: 0;
  transform-origin: bottom left;
  transform: translateX(calc(var(--posX))) translateY(calc(var(--posY) * -1)) translateZ(calc(var(--posZ) + var(--radius))) rotateX(var(--rotX)) rotateY(var(--rotY)) rotateZ(var(--rotZ));
  height: var(--height);
  width: var(--diameter);
}
body #view #scene #space .pyramid.test > .pyramid-face {
  border: solid 1px black;
  background: linear-gradient(#f005, #00f5);
}
body #view #scene #space .pyramid > .pyramid-face {
  position: absolute;
  height: var(--faceHeight);
  width: var(--faceWidth);
  transform: translateX(calc(var(--radius) - var(--faceWidth) / 2)) rotateY(calc(var(--pos) * (360deg / var(--detailLevel)))) translateZ(var(--dist)) rotateX(var(--pyramidAngle));
  transform-origin: center bottom;
  -webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
          clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
body #view #scene #space .pyramid.shaded > *:first-child, body #view #scene #space .pyramid.shaded > *:nth-child(odd) {
  filter: brightness(0.8);
}
body #view #scene #space .pyramid.shaded > *:nth-child(even) {
  filter: brightness(0.9);
}
body #view #scene #space .pyramid.pyramid-shaded > * {
  filter: brightness(var(--shadeLevel));
}
body #view #scene #space .pyramid.color > * {
  background-color: currentColor;
}
body #view #scene #space .pyramid.overflow > * {
  -webkit-clip-path: polygon(calc(50% + .7px) 0, calc(50% - .7px) 0, -2px calc(100% + 1px), calc(100% + 1px) calc(100% + 1px));
          clip-path: polygon(calc(50% + .7px) 0, calc(50% - .7px) 0, -2px calc(100% + 1px), calc(100% + 1px) calc(100% + 1px));
  box-shadow: 0 0 0 1px currentColor;
}
body #view #scene #space .particle-positioner {
  transform: translateX(calc(var(--posX) - 50%)) translateY(calc(var(--posY) * -1 - 50%)) translateZ(var(--posZ));
}
body #view #scene #space .particle-positioner.test .particle {
  border: solid 1px black;
  background: linear-gradient(#f005, #00f5);
}
body #view #scene #space .particle-positioner .particle {
  width: var(--sizeX);
  height: var(--sizeY);
}

@-webkit-keyframes animateRotation {
  0% {
    transform: rotateX(var(--startRotX)) rotateY(var(--startRotY)) rotateZ(var(--startRotZ));
  }
  100% {
    transform: rotateX(var(--endRotX)) rotateY(var(--endRotY)) rotateZ(var(--endRotZ));
  }
}

@keyframes animateRotation {
  0% {
    transform: rotateX(var(--startRotX)) rotateY(var(--startRotY)) rotateZ(var(--startRotZ));
  }
  100% {
    transform: rotateX(var(--endRotX)) rotateY(var(--endRotY)) rotateZ(var(--endRotZ));
  }
}
@-webkit-keyframes animatePosition {
  0% {
    transform: translateX(var(--startPosX)) translateY(var(--startPosY)) translateZ(var(--startPosZ));
  }
  100% {
    transform: translateX(var(--endPosX)) translateY(var(--endPosY)) translateZ(var(--endPosZ));
  }
}
@keyframes animatePosition {
  0% {
    transform: translateX(var(--startPosX)) translateY(var(--startPosY)) translateZ(var(--startPosZ));
  }
  100% {
    transform: translateX(var(--endPosX)) translateY(var(--endPosY)) translateZ(var(--endPosZ));
  }
}
.pumpkin {
  color: #c84504;
}
.pumpkin > *:not(.top, .bottom), .pumpkin.plane {
  background-image: linear-gradient(90deg, #c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504);
}
.pumpkin > .top, .pumpkin > .bottom {
  background-image: conic-gradient(from 15deg, #c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504,#b43e04,#c84504);
}

.pumpkin_flesh {
  color: #ff9d00;
}

.pumpkin_flesh_carved {
  color: #ff9d00;
}
.pumpkin_flesh_carved > *.top, .pumpkin_flesh_carved > *.bottom {
  background: linear-gradient(#ff9d00 90%, #c84504);
}
.pumpkin_flesh_carved > *.left, .pumpkin_flesh_carved > *.right {
  background: linear-gradient(90deg, #ff9d00 90%, #c84504);
}
.pumpkin_flesh_carved.plane {
  background-image: linear-gradient(#ff9d00 90%, #c84504);
}

#innerShadow {
  background-image: radial-gradient(#0002, #0000 70%);
}

#outerFront {
  -webkit-mask: 0 0/0.5em 3em linear-gradient(red, red), 2.5em 0/0.5em 3em linear-gradient(red, red), 0 0/3em 0.5em linear-gradient(red, red), 0 1.25em/3em 0.5em linear-gradient(red, red), 0 2.5em/3em 0.5em linear-gradient(red, red), 1.25em 0.5em/0.5em 1em linear-gradient(red, red), 1.25em 0.5em/0.5em 1em linear-gradient(red, red), 0.9em 1.75em/0.4em 0.25em linear-gradient(red, red), 1.3em 2.25em/0.4em 0.25em linear-gradient(red, red), 1.7em 1.75em/0.4em 0.25em linear-gradient(red, red);
          mask: 0 0/0.5em 3em linear-gradient(red, red), 2.5em 0/0.5em 3em linear-gradient(red, red), 0 0/3em 0.5em linear-gradient(red, red), 0 1.25em/3em 0.5em linear-gradient(red, red), 0 2.5em/3em 0.5em linear-gradient(red, red), 1.25em 0.5em/0.5em 1em linear-gradient(red, red), 1.25em 0.5em/0.5em 1em linear-gradient(red, red), 0.9em 1.75em/0.4em 0.25em linear-gradient(red, red), 1.3em 2.25em/0.4em 0.25em linear-gradient(red, red), 1.7em 1.75em/0.4em 0.25em linear-gradient(red, red);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
}

.shine > * {
  background: linear-gradient(#fbcb3c20, #0000);
}

.stem {
  color: #264f0d;
}

#leaves > *[data-face="1"], #leaves > *[data-face="2"] {
  background-image: radial-gradient(ellipse at 50% 80%, #264f0d 66%, #0000 66%);
}
#leaves > *[data-face="3"] {
  background-image: radial-gradient(circle at 24% -24%, #264f0d 66%, #0000 66%);
}
#leaves > *[data-face="4"] {
  background-image: radial-gradient(circle at 76% -24%, #264f0d 66%, #0000 66%);
}

.rock {
  color: #444;
}

.grass {
  color: #2a300b;
}
.grass > * {
  color: #272f09;
  background: 0 0/10em 10em url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='300' height='300'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence  type='turbulence' baseFrequency='.005' numOctaves='10' stitchTiles='stitch'/%3E%3C.........完整代码请登录后点击上方下载按钮下载查看

网友评论0