Web前端项目-交互式3D魔方【附源码】

交互式3D魔方

3D魔方游戏是一款基于网页技术的三维魔方游戏。它利用HTMLCSSJavaScript前端技术来实现3D效果,并在网页上呈现出逼真的魔方操作体验。

运行效果:
在这里插入图片描述
在这里插入图片描述

一:index.html

<!DOCTYPE html>
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"><link rel="stylesheet" type="text/css" href="styles/cube.css"><link rel="stylesheet" type="text/css" href="styles/doodle2.css"><link rel="stylesheet" type="text/css" href="styles/certificate2.css"><script charset="utf-8" src="scripts/tween.r12.js"></script><script charset="utf-8" src="scripts/three.js"></script><script charset="utf-8" src="scripts/cuber.min.js"></script></head><body><div id="bg"></div><div id="container"></div><div id="fail"><img src="media/static-cube.png"/><div id="upgradeText" class="bubble fadeTransition"><div class="upgradetext">To play, please use a supported hardware configuration and the latest version of one of these browsers:</div><br><a class="upgradetext" href="https://www.google.com/chrome/browser/" target="_blank">Chrome</a><br><a class="upgradetext" href="https://www.mozilla.org/firefox" target="_blank">Firefox</a><br><a class="upgradetext" href="https://www.apple.com/safari" target="_blank">Safari</a><br><span class="pointerleft SPRITE_carrot_down_2x"></span></div></div><div id="uipanel" class="fadeTransition" style="display:none"><div id="movecounter">0</div><div id="buttonpanel"><div id="sharebubble" class="fadeTransition" style="opacity:0"><input id="shareshortlink" type="text" value="google.com/doodles" readonly/><div id="sharegplus" class="bubbleicon SPRITE_google_plus_64_2x"></div><div id="sharefacebook" class="bubbleicon SPRITE_facebook_64_2x"></div><div id="sharetwitter" class="bubbleicon SPRITE_twitter_64_2x"></div><div id="shareemail" class="bubbleicon SPRITE_email_64_2x"></div></div><div id="uibuttons"><div id="sharebutton" class="bubbleicon SPRITE_share_64_2x"></div><div id="helpbutton" class="bubbleicon SPRITE_help_64_2x"></div><div id="searchbutton" class="bubbleicon SPRITE_search_64_2x"></div></div></div><div id="helpbubble" class="bubble" style="display:none"><span class="pointerup SPRITE_carrot_grey_up_2x"></span><div id="helpimage" class="one"></div><div id="helptext" class="helptext"></div><div id="helpnext" class="helptext"></div><span class="pointerdown SPRITE_carrot_down_2x"></span><br></div></div><script charset="utf-8" src="scripts/iecss3d.js"></script><script charset="utf-8" src="scripts/ierenderer.js"></script><script charset="utf-8" src="scripts/deviceMotion.js"></script><script charset="utf-8" src="scripts/locked.js"></script><script charset="utf-8" src="scripts/textBox.js"></script><script charset="utf-8" src="scripts/ResizeableTextBox.3.js"></script><script charset="utf-8" src="scripts/divBox.js"></script><script charset="utf-8" src="scripts/frames.js"></script><script charset="utf-8" src="scripts/certificate.js"></script><script charset="utf-8" src="scripts/main3.js"></script></body>
</html>

二:styles

(1)cube.css
.cube {width:  100%;height: 100%;
}
.faceLabel {display: none;position: absolute;font-size: 60px;text-align: center;text-shadow: 0 0 24px rgba( 0, 0, 0, 0.3 );color: #FFF;
}
.cube .cubelet {width:  1em;height: 1em;position: absolute;box-sizing: border-box;
}
.cube .face {position: absolute;width:  1em;height: 1em;background-color: #000;text-align: center;-webkit-backface-visibility: hidden;-moz-backface-visibility:hidden;-o-backface-visibility:hidden;backface-visibility:hidden;padding: 0.05em;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;-o-box-sizing: border-box;-ms-box-sizing: border-box;box-sizing: border-box;
}
.cube .face.faceIntroverted { background-color: #000; }
.cube .face.faceTransparent { background-color: transparent; }
.purty .face { opacity: 0.5; }
.purty .face.faceFront { background-color: #FFF; }
.purty .face.faceUp    { background-color: #E87000; }
.purty .face.faceRight { background-color: #3D81F6; }
.purty .face.faceDown  { background-color: #DC422F; }
.purty .face.faceLeft  { background-color: #009D54; }
.purty .face.faceBack  { background-color: #F5B400; }
.cube .face > .wireframe {display: none;position: absolute;width:  140px;height: 140px;background-color: rgba( 255, 255, 255, 0.05 );
}
.cube .sticker {width:  100%;height: 100%;background-color: #F0F;border-radius: 0.1em;text-align: center;
}
.cube .sticker.red   { background: #DC422F; }
.cube .sticker.white  { background: #F3F3F3; }
.cube .sticker.blue  { background: #3D81F6;  }
.cube .sticker.green  { background: #009D54; }
.cube .sticker.orange  { background: #E87000;  }
.cube .sticker.yellow  { background: #F5B400;  }
.cube .sticker.stickerLogo {background-size: 100% 100%;background-repeat: none;
}
.cube .face > .id {display: none;position: absolute;z-index: 1000;width:  90%;height: 90%;font-size:   1em;line-height: 0.9em;text-align: center;color: #000;
}
.cube .face > .id > .underline {border-bottom: 1px solid #000;
}
.cube .face.faceIntroverted > .id {color: #FEFEFE;
}
.cube .face.faceIntroverted > .id > .underline {border-bottom: 1px solid #FEFEFE;
}
.cube .face > .text {display: none;position: absolute;z-index: 2000;width:  100%;height: 100%;text-align: center;color: #FFF;font-size:   1em;line-height: 1em;
}
(2)certificate2.css
#certName, #certSolved{width: 1100px;color: #DC422F;padding: 20px;font-family: "Rubik One", Arial, sans-serif;font-size: 180px;text-align: center;line-height: .97em;text-transform: uppercase;
}
#certDate, #certMovesHeader, #certTimeHeader, #certName, #certSolved, #certTimeNumber, #certMovesNumber{-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;
}
#certDate{width: 1000px;color: #000;padding: 20px;font-family: "Rubik One", Arial, sans-serif;text-transform: uppercase;font-size: 110px;text-align:center;line-height: .8em;
}
#certMovesHeader, #certTimeHeader {width: 1000px;color: #000;padding: 20px;font-family: "Rubik One", Arial, sans-serif;text-transform: uppercase;font-size: 90px;text-align: center;line-height: .8em;
}
#certTimeNumber, #certMovesNumber{width: 1000px;color: #3D81F6;padding: 20px;font-family: "Rubik One", Arial, sans-serif;font-size: 180px;text-align: center;line-height: 1.0em;text-transform: uppercase;
}
#certLarryName, #certErnoName{width: 1000px;color: #FF6C00;padding: 20px;font-family: "Rubik One", Arial, sans-serif;font-size: 80px;text-align: center;line-height: 1.0em;
}
#larrySignature{width: 1000px;height: 300px;background-size: 700px 210px;background-repeat:no-repeat;background-position:center;
}
#ernoSignature{width: 1000px;height: 300px;background-size: 700px 210px;background-repeat:no-repeat;background-position:center;
}
#lineLeft, #lineRight{width: 1000px;height: 10px;background-color: #000;display: inline-block;background-repeat: no-repeat;background-position: 100px 100px;
}
.logoFace {width: 100%;height: 100%;display: block;z-index: 1000;background-size: 100% 100%;background-repeat: none;top: 0px;right: 1px;position: absolute;-webkit-transform: rotate(90deg);-moz-transform: rotate(90deg);-o-transform: rotate(90deg);-ms-transform: rotate(90deg);transform: rotate(90deg);
}
.faceDown .logoFace.ie{-webkit-transform: rotate(180deg);-moz-transform: rotate(180deg);-o-transform: rotate(180deg);-ms-transform: rotate(180deg);transform: rotate(180deg);
}
.cube .sticker.red { background: #DC422F; }
.cube .sticker.white { background: #FFFFFF; }
.cube .sticker.blue { background: #3D81F6; }
.cube .sticker.green { background: #009D54; }
.cube .sticker.orange { background: #FF6C00; }
.cube .sticker.yellow { background: #FDCC09; }
.textBox_IE{z-index: 10;top:0;
}
(3)doodle2.css
html {height: 100%;
}
body {background-color: #fff;display: inline;font-family: arial, sans-serif;font-size: 13px;height: 100%;line-height: 40px;margin: 0;vertical-align: baseline;-moz-user-select:-moz-none;-ms-user-select:none;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;
}
#fail {position: absolute;display: none;top: 50%;left: 50%;margin-left: -288px;margin-top: -117px;
}
@media not screen and (-webkit-transform-3d){#container {visibility: hidden;}#fail {display: block;}
}
#bg {background-color: #fff;font-family: arial, sans-serif;font-size: 13px;height: 100%;line-height: 40px;margin: 0;position: absolute;width: 100%;
}
.graydient {background: #000;background: -moz-radial-gradient(center,ellipse cover,#444 0%,#000000 90%);background: -webkit-gradient(radial,center center,0px,center center,100%,color-stop(0%,#444),color-stop(90%,#000000));background: -webkit-radial-gradient(center,ellipse cover,#444 0%,#000000 90%);background: -o-radial-gradient(center,ellipse cover,#444 0%,#000000 90%);background: -ms-radial-gradient(center,ellipse cover,#444 0%,#000000 90%);background: radial-gradient(ellipse at center,#444 0%,#000000 90%);filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444',endColorstr='#000000',GradientType=1 );
}
.grey {background: #555;
}
.white {background: #FFF;
}
#container {cursor: pointer;height: 100%;overflow: hidden;width: 100%;position:relative;
}
.text {font-size: 200;
}
.text.textDown  { color: #DC422F; }
.text.textBack  { color: #F5B400; }
.text.textRight { color: #3D81F6; }
.shadow {pointer-events: none;position: absolute;width: 120px;height: 120px;background: black;box-shadow: 0 0 100px 80px black;opacity: 0.06;-webkit-transition: opacity 1s;-moz-transition: opacity 1s;-ms-transition: opacity 1s;-o-transition: opacity 1s;transition: opacity 1s;
}
.bubble {background: #fff;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;border: 3px solid black;bottom: 4px;line-height: normal;padding: 16px;position: absolute;right: 0;
}
.mobile .bubble {background: #000;border: 2px solid #555;bottom: auto;position: absolute;right: 0;top: 44px;
}
.pointerdown {bottom: -15px;display: block;height: 15px;margin: 0 0 0 -5px;outline: none;position: absolute;right: 42px;
}
.mobile .pointerdown {display: none;
}
.pointerup {display: none;
}
.mobile .pointerup {top: -15px;display: block;outline: none;position: absolute;right: 68px;
}
.bubbleicon {cursor: pointer;display: inline-block;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;
}
.fadeTransition {-webkit-transition: opacity 250ms;-moz-transition: opacity 250ms;-ms-transition: opacity 250ms;-o-transition: opacity 250ms;transition: opacity 250ms;
}
#sharebubble {display: inline-block;vertical-align: bottom;
}
#uibuttons {display: inline-block;
}
#buttonpanel {line-height: normal;position: absolute;right: 0;
}
#shareshortlink {background: #ddd;border: none;color: #fff;font-weight: bold;margin: 0;outline: none;padding: 10px;vertical-align: top;width: 120px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;
}
#shareshortlink::-ms-clear {display: none;
}
#uipanel {bottom: 40px;height: 32px;margin: 0 auto;opacity: 0;position: relative;width: 572px;
}
.mobile #uipanel {bottom: auto;top: 4px;right: 4px;width: 100%;position: absolute;
}
#movecounter {bottom: -8px;color: #ddd;display: inline-block;font-family: "Rubik One";font-size: 14pt;left: 0;position: absolute;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;
}
.mobile #movecounter {bottom: auto;top: 0;color: #555;padding: 4px 20px;font-size: 16pt;font-weight: bold;
}
.upgradetext, .helptext {font-family: arial;font-size: 12pt;font-weight: bold;width: 120px;color: #999;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;
}
.helptext {font-family: arial;font-size: 12pt;font-weight: bold;width: 200px;color: #999;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;
}
#helpnext {padding-top: 10px;cursor: pointer;
}
#helpimage{width:160px;height: 123px;background-size:160px 123px;
}
#helpimage.one{width:140px;height: 100px;background-size:140px 100px;
}
#helpimage.two{width:140px;height: 100px;background-size:140px 100px;
}

注意:

由于博客字数限制,本篇文章所展示的代码并不全面,仅可供参考之用。关于本项目的完整代码及其素材已上传至资源,大家自行去下载就好

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/28427.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

绿色版DirectoryOpus功能强大且高度可定制的Windows文件管理器

Directory Opus&#xff08;通常简称为DOpus&#xff09;是一款功能强大且高度可定制的Windows文件管理器。它提供了许多超越Windows默认文件资源管理器&#xff08;Explorer&#xff09;的功能&#xff0c;使得文件和文件夹的管理变得更加高效和直观。以下是对Directory Opus的…

R进阶使用技巧

Introduction 分享一些R进阶使用的技巧&#xff0c;相当于是之前写的R语言学习的实践和总结了。 Online slide: https://asa-blog.netlify.app/R_tips_for_advanced_use_byAsa/R_tips.html 下载slide和相关的各种test文件: https://asa-blog.netlify.app/R_tips_for_advanced…

请解释Java中的volatile关键字的作用和内存可见性原理。什么是Java中的死锁?请解释其产生的原因和避免方法。

请解释Java中的volatile关键字的作用和内存可见性原理。 在Java中&#xff0c;volatile关键字是一个非常重要的修饰符&#xff0c;它主要用于确保多线程环境下变量的可见性和有序性。下面我将详细解释volatile的作用和内存可见性原理。 volatile的作用 可见性&#xff08;Vis…

第7章:系统架构设计基础知识-软件架构风格

由于历史原因&#xff0c;研究者和工程人员对Sofiware Architecture(简称SA)的翻译不尽相同&#xff0c;其软件的“体系结构”和“架构”具有相同的含义。 系统架构其实就是系统的结构&#xff0c;系统架构设计其实就是要给相关利益方说清楚通过什么样的结构来解决需求中功能和…

GTK tutorial 十三

Spin Buttons Spin Button用于让用户在一个范围内的数值中选择一个数字。它包含一个text entry box,并且在entry box旁边有用于上下翻的箭头按钮。entry box也能够直接被编辑。 下面举例说明其用法。 程序运行结果&#xff1a; /**spinbutton.c/ #include<stdio.h> #i…

Java并发自测题

文章目录 一、什么是线程和进程?线程与进程的关系,区别及优缺点&#xff1f;二、为什么要使用多线程呢?三、说说线程的生命周期和状态?四、什么是线程死锁?如何预防和避免线程死锁?五、synchronized 关键字六、并发编程的三个重要特性七、JMM &#xff08;Java Memory Mod…

上海计算机考研避雷,25考研慎报

上大计算机一直很热 408考研er重来没有让我失望过&#xff0c;现在上大的专业课是11408&#xff0c;按理说&#xff0c;这个专业课的难度是很高的&#xff0c;但是408er给卷出了新高度&#xff0c;大家可以去上大官网看看今年最新的数据&#xff0c;我也帮大家统计了24年最新的…

灾备建设中虚拟机细粒度恢复的含义及技术使用

灾备建设中为了考虑虚拟机恢复的效率与实际的用途&#xff0c;在恢复上出了普通的恢复虚拟机&#xff0c;也有其余的恢复功能&#xff0c;比如瞬时恢复&#xff0c;细粒度恢复等。这里谈的就是细粒度恢复。 首先细粒度恢复是什么&#xff0c;这个恢复可以恢复单个备份下来的文…

Git学习记录v1.0

1、常用操作 git clonegit configgit branchgitt checkoutgit statusgit addgit commitgit pushgit pullgit loggit tag 1.1 git clone 从git服务器拉取代码 git clone https://gitee.com/xxx/studyJava.git1.2 git config 配置开发者用户名和邮箱 git config user.name …

堆的基本概念

堆 堆是一个完全二叉树 完全二叉树的要求&#xff0c;除了最后一层&#xff0c;其他层的节点个数都是满的&#xff0c;最后一层的节点都靠左排列 堆中每一个节点的值都必须大于等于(或小于等于)其子树中每个节点的值 堆中每个节点的值都大于等于(或者小于等于)其左右子节点的值…

【React】Profiler作用是什么,怎么使用?

React的Profiler是一个内置的工具,主要用于帮助开发者检测和分析React应用中的性能瓶颈。以下是关于React Profiler的详细作用和使用方法: 作用: 性能分析:Profiler可以帮助你了解组件渲染所花费的时间,并提供有关哪些组件需要进行优化的信息。数据收集:它可以测量组件的…

RAG下的prompt编写探索

针对特定领域的回答,编写抽象的prompt需要在细节和灵活性之间找到平衡。我们需要一个既能涵盖普遍步骤又能适应不同问题的框架。以下是如何在这种情况下编写抽象prompt的方法,以及适用于各种技术领域的通用策略。 一、编写抽象Prompt的通用策略 定义用户问题和背景信息: 明…

Semantic Kernel 和 LangChain 如何选择?

选择 Semantic Kernel 还是 LangChain 取决于你特定的应用需求和技术偏好。以下是这两者的一些关键点和对比&#xff0c;可以帮助你做出决策&#xff1a; Semantic Kernel 1、优点&#xff1a; 集成性强&#xff1a;Semantic Kernel 是由微软开发的&#xff0c;专为与 Azure…

不同高速协议接口之间共享时钟

文章目录 前言1、万兆网给8B10B PHY共享2、8B10B PHY给万兆网共享3、综合实现4、总结4.1、上板验证4.1.1、第一路数据&#xff1a;万兆网4.1.2、第二路数据&#xff1a;8B10B PHY 前言 一个GT BANK有四个GT channel&#xff0c;他们之间是可以共享同一个QPLL输出参考时钟&…

【深度学习量化交易1】一个金融小白尝试量化交易的设想、畅享和遐想

关注我的朋友们可能知道&#xff0c;我经常在信号处理的领域出没&#xff0c;时不时会发一些信号处理、深度学习科普向的文章。 不过算法研究久了&#xff0c;总想做一些更有趣的事情。 比如用深度学习算法赚大钱。。毕竟有什么事情能比暴富更有意思呢。 一、神经网络与彩票…

【linux】Linux分析cpu问题

CPU使用率高怎么分析&#xff1a; 首先先看哪些线程占用资源高看每个线程在干啥&#xff08;类似windows系统的任务管理器&#xff09; 步骤&#xff1a; 定位应用进程 pid jps -l # 查看进程找到线程 tid top -Hp {pid}将 tid 转换成十六进制 printf "%x\n" {…

【loguru】【notifiers】配置ERROR级别邮件发送通知

完整代码 from loguru import logger from notifiers import get_notifier# 获取电子邮件通知器 notifier get_notifier("email")# 配置电子邮件通知参数 email_params {"username": "xxxxx163.com", # 发送邮件的用户名&#xff0c;我这里用…

数字孪生技术如何赋能智慧工厂

数字孪生技术为什么能在智慧工厂中发挥作用&#xff1f;随着工业4.0的推进和智能制造的普及&#xff0c;数字孪生技术成为智慧工厂的重要推动力。数字孪生是指在虚拟空间中创建一个与现实物理实体相对应的数字模型&#xff0c;通过实时数据交互和分析&#xff0c;实现对物理实体…

Kafka高频面试题整理

文章目录 1、什么是Kafka?2、kafka基本概念3、工作流程4、Kafka的数据模型与消息存储机制1)索引文件2)数据文件 5、ACKS 机制6、生产者重试机制:7、kafka是pull还是push8、kafka高性能高吞吐的原因1&#xff09;磁盘顺序读写&#xff1a;保证了消息的堆积2&#xff09;零拷贝机…

Android 安装过程四 MSG_INSTALL消息的处理 安装之前的验证

由Android 安装过程三文章知道&#xff0c;MSG_INSTALL消息的处理是调用的handleInstall()&#xff0c;看一下它的主要相关代码&#xff1a; private void handleInstall() {…………if (params.isStaged) {mStagingManager.commitSession(mStagedSession);// TODO(b/136257624…