123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817 |
- <template>
- <div class="wcontainer">
- <img class="logo" :src="require(`@/assets/images/logo.png`)" alt="" />
- <Loading :barWidth="loadprogress" v-if="!hadLoaded" />
- <transition appear name="dm">
- <vmenu @clickItem="handleItem" />
- </transition>
- <transition appear name="dm">
- <vintroduce v-if="currentItem == 'info'" />
- </transition>
- <div class="infobg">
- <img :src="require('@/assets/images/info_bg.png')" alt="">
- <p>特展馆·二楼<br />镇院之宝展厅</p>
- </div>
- <div class="right-title">
- <img :src="require('@/assets/images/title.png')" alt="">
- </div>
- <div id="player">
- <div class='widgets-doll-labels'> </div>
- <canvas></canvas>
- </div>
- </div>
- </template>
- <script>
- import vmenu from "@/components/menu";
- import Loading from "@/components/loading";
- import vintroduce from "@/components/introduce";
- const transitionTime = 2000
- let labelClick = (e) => {
- if (e.centerCamePosi) {
- console.log(e);
- let { x, y, z } = e.centerCamePosi
- window.transitions.start(
- window.lerp.vector(window.viewer.camera.position,
- new window.THREE.Vector3(x, y, z)),
- transitionTime,
- () => {
- e.elem[0].style.display == 'block' && e.elem.addClass('detailShow')
- e.elem.siblings().removeClass('detailShow')
- e.elem.siblings().css({
- "opacity": 0,
- "pointer-events": "none"
- })
- console.log(e.elem.siblings());
- let wlmesh = window.viewer.model.getObjectByName("WL48_ping")
- wlmesh.material.emissiveMap = e.emissiveTexture;
- wlmesh.material.dispose();
- window.showWenli = true
- // window.viewer.labels.forEach(item => {
- // if (centerLabel.title == item.title) {
- // this.centerLabel = centerLabel
- // }
- // else {
- // item.elem.removeClass('detailShow')
- // }
- // })
- },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly2');
- }
- }
- let infoLabels = [{ "title": "宝珠钮", "posInModel": [-4.6302, 20.0953, 2.9731] },
- { "title": "瓶身", "posInModel": [-11.7969, -1.7939, 3.9055] },
- { "title": "瓶盖", "posInModel": [-6.0636, 16.2615, 3.4633] }]
- let picLabels = [
- {
- "title": "竹子",
- "entitle": "Diagonal squares pattern",
- "infodesc": "清代郑燮咏竹:咬定青山不放松,立根原在破岩中;千磨万击还坚劲,任尔东西南北风。",
- "imgsrc": "zhu",
- "labeltype": "canShow",
- "posInModel": [
- -9.9383,
- 1.517,
- 8.4702
- ],
- "centerCamePosi": {
- x: -0.4650665393060424,
- y: 0.0106499843061736,
- z: 0.43269467554899155,
- },
- clickFun: labelClick
- },
- {
- "title": "牡丹",
- "entitle": "Diagonal squares pattern",
- "infodesc": "唐朝·刘禹锡《赏牡丹》:庭前芍药妖无格,池上芙蕖净少情。唯有牡丹真国色,花开时节动京城。",
- "imgsrc": "mudan",
- "labeltype": "canShow",
- "posi": "right",
- "posInModel": [
- -10.5926,
- -6.1392,
- 1.8685
- ],
- "centerCamePosi": {
- x: -0.5357516927819861,
- y: -0.3176574374999963,
- z: 0.1252552053945424
- },
- clickFun: labelClick
- },
- {
- "title": "梅",
- "entitle": "Diagonal squares pattern",
- "labeltype": "canShow",
- "infodesc": "元代王冕咏梅:不要人夸好颜色,只留清气满乾坤。",
- "imgsrc": "mei",
- "posi": "right",
- "posInModel": [
- 12.4014,
- 5.4827,
- 2.9209
- ],
- "centerCamePosi": {
- x: 0.5882886392634421,
- y: 0.2267149762544653,
- z: 0.07836955309150107
- },
- clickFun: labelClick
- },
- {
- "title": "松",
- "entitle": "Diagonal squares pattern",
- "labeltype": "canShow",
- "infodesc": "唐代白居易咏松:岁暮满山雪,松色郁青苍。彼如君子心,秉操贯冰霜。",
- "imgsrc": "song",
- "posInModel": [
- -5.2427,
- 1.903,
- -12.1582
- ],
- "centerCamePosi": {
- x: -0.2604583387784285,
- y: 0.00816509249833358,
- z: -0.5794133027654209
- },
- clickFun: labelClick
- }
- ]
- export default {
- components: { vmenu, Loading, vintroduce },
- data() {
- return {
- scene: null,
- camera: null,
- renderer: null,
- controls: null,
- rafId: null,
- container: null,
- containerW: 0,
- containerH: 0,
- loadprogress: 0,
- hadLoaded: false,
- modelLoaded: null,
- timer: null,
- obj: null,
- labelRenderer: null,
- label: null,
- meshGroup: null,
- currentItem: 'info',
- centerLabel: null,
- fgtimer: null
- };
- },
- methods: {
- handleItem(data) {
- this.currentItem = data.id
- switch (data.id) {
- case "info":
- this.info()
- break;
- case "pic":
- this.pic()
- break;
- default:
- break;
- }
- },
- // 重置相机位置
- resetCameraView() {
- window.transitions.start(
- window.lerp.vector(window.viewer.camera.rotation,
- new window.THREE.Vector3(-6.123233995736765e-17, 0, 0)),
- transitionTime,
- () => { },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- },
- info() {
- this.resetCameraView()
- window.viewer.removeAllLabels()
- window.viewer.model.getObjectByName("wl48_biaochi").visible = true
- //模型位置
- window.transitions.start(
- window.lerp.vector(window.viewer.model.position,
- new window.THREE.Vector3(0, 0, 0)),
- transitionTime,
- () => { },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- //模型旋转角度
- window.transitions.start(
- window.lerp.vector(window.viewer.model.rotation,
- new window.THREE.Vector3(0, 0, 0)),
- transitionTime,
- () => {
- window.viewer.loadLabelsFromData(infoLabels)
- window.viewer.control.maxPolarAngle = Math.PI;
- window.viewer.control.minPolarAngle = 0;
- },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- //相机位置
- window.transitions.start(
- window.lerp.vector(window.viewer.camera.position,
- new window.THREE.Vector3(0, 0, 0.78)),
- transitionTime,
- () => { },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- },
- pic() {
- this.resetCameraView()
- window.viewer.removeAllLabels()
- window.viewer.model.getObjectByName("wl48_biaochi").visible = false
- //相机位置
- window.transitions.start(
- window.lerp.vector(window.viewer.camera.position,
- new window.THREE.Vector3(0, 3.8901816405972494e-17, 0.6353148749999993)),
- transitionTime,
- () => { },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- //模型位置
- window.transitions.start(
- window.lerp.vector(window.viewer.model.position,
- new window.THREE.Vector3(0, 0, 0)),
- transitionTime,
- () => { },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- //模型旋转角度
- window.transitions.start(
- window.lerp.vector(window.viewer.model.rotation,
- new window.THREE.Vector3(0, 0, 0)),
- transitionTime,
- () => {
- window.viewer.control.maxPolarAngle = Math.PI / 1.5;
- window.viewer.control.minPolarAngle = Math.PI / 6;
- window.viewer.loadLabelsFromData(picLabels)
- // window.showWenli = true
- },
- 0/* Delay */,
- window.easing.easeInOutQuad,
- 'cameraFly');
- },
- // 窗口改变
- onresize() {
- },
- },
- watch: {
- centerLabel(newVal) {
- if (newVal) {
- newVal.elem[0].style.display == 'block' && newVal.elem.addClass('detailShow')
- let wlmesh = window.viewer.model.getObjectByName("WL48_ping")
- wlmesh.material.emissiveMap = this.centerLabel.emissiveTexture;
- wlmesh.material.dispose();
- }
- },
- currentItem(newVal) {
- if (newVal != 'pix') {
- window.showWenli = false
- }
- }
- },
- mounted() {
- this.timer = setInterval(() => {
- if (!this.hadLoaded) {
- if (this.loadprogress < 80) {
- this.loadprogress += 0.8;
- } else {
- if (this.modelLoaded) {
- if (this.loadprogress <= 100) {
- this.loadprogress += 2;
- } else {
- this.hadLoaded = true;
- clearInterval(this.timer);
- this.timer = null;
- }
- }
- }
- }
- }, 10);
- window.viewer = new window.Viewer(0, window.$("#player")[0])
- window.viewer.addEventListener("hadLoaded", () => {
- this.modelLoaded = true
- window.viewer.loadLabelsFromData(infoLabels)
- window.viewer.control.maxPolarAngle = Math.PI;
- window.viewer.control.minPolarAngle = 0;
- })
- window.viewer.addEventListener("delayUpdate", (e) => {
- // setTimeout(() => {
- // if (this.currentItem == 'pic') {
- // let centerLabel = window.viewer.getCLabel()
- // if (centerLabel) {
- // window.viewer.labels.forEach(item => {
- // if (centerLabel.title == item.title) {
- // this.centerLabel = centerLabel
- // }
- // else {
- // item.elem.removeClass('detailShow')
- // }
- // })
- // }
- // }
- // });
- })
- },
- beforeDestroy() {
- },
- };
- </script>
- <style lang="less" scoped>
- .wcontainer {
- width: 100%;
- height: 100%;
- position: relative;
- background-repeat: no-repeat;
- color: #ac5b5b;
- .logo {
- position: absolute;
- top: 50px;
- left: 66px;
- width: 100px;
- z-index: 9999;
- }
- .infobg {
- position: absolute;
- bottom: 0;
- right: 0;
- width: 250px;
- height: auto;
- >p {
- position: absolute;
- top: 70%;
- left: 50%;
- transform: translate(-50%, -50%);
- color: rgba(255, 255, 255, 0.8);
- font-family: SimSun;
- line-height: 1.5;
- }
- }
- .right-title {
- position: absolute;
- right: 90px;
- top: 14%;
- width: 150px;
- height: auto;
- >img {
- width: 100%;
- }
- }
- #player {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- }
- }
- .dm-enter {
- opacity: 0;
- }
- .dm-leave-to {
- opacity: 0;
- }
- .dm-enter-active,
- .dm-leave-active {
- transition: all 2.8s ease;
- }
- </style>
- <style lang="less">
- *,
- :after,
- :before {
- box-sizing: border-box;
- }
- .widgets-doll-labels {
- overflow: hidden;
- position: absolute;
- pointer-events: none;
- top: 0;
- left: 0;
- bottom: 0;
- right: 0;
- .room-label {
- position: absolute;
- width: 0;
- height: 0;
- transform: translateZ(0);
- animation: room-label 0.3s ease 0.1s;
- animation-fill-mode: both;
- cursor: pointer;
- &:after {
- content: "";
- display: block;
- position: absolute;
- height: 1px;
- width: 88px;
- // background-image: url("img/labelline.svg");
- background-color: #A99979;
- background-size: contain;
- background-repeat: no-repeat;
- bottom: 0;
- right: 0;
- }
- a {
- display: block;
- position: absolute;
- line-height: 2;
- top: 50%;
- right: 88px;
- transform: translateY(-50%);
- text-align: center;
- white-space: nowrap;
- padding: 6px 14px;
- pointer-events: auto;
- background-repeat: no-repeat;
- background-size: 100% 100%;
- background-image: url('~@/assets/images/tab.svg');
- color: #fff;
- box-sizing: border-box;
- >p {
- margin: 0;
- width: 100%;
- height: 100%;
- }
- span {
- white-space: nowrap;
- user-select: none;
- }
- }
- }
- .right {
- a {
- left: 88px;
- right: unset;
- }
- &:after {
- content: "";
- display: block;
- position: absolute;
- bottom: 0;
- right: unset;
- left: 0;
- }
- }
- .canShow {
- &:after {
- content: "";
- display: block;
- position: absolute;
- height: 38px;
- width: 38px;
- background-image: url('~@/assets/images/point.svg');
- background-color: transparent;
- background-size: cover;
- background-repeat: no-repeat;
- bottom: 0;
- right: 0;
- top: 0;
- left: 0;
- }
- &::before {
- content: '';
- width: 100px;
- height: 2px;
- display: inline-block;
- background-color: #A99979;
- position: absolute;
- transform: rotate(45deg);
- top: -30px;
- right: -20px;
- }
- &:hover {
- color: #fff;
- &:after {
- background-image: url('~@/assets/images/point_active.svg');
- content: '';
- }
- &::before {
- content: '';
- background-color: #fff !important;
- }
- a {
- >p,
- span {
- color: #fff;
- }
- .sline {
- background-color: #fff;
- }
- }
- }
- a {
- display: block;
- position: absolute;
- line-height: 2;
- transition: .1s opacity ease;
- top: -103px;
- right: 51px;
- transform: translateY(0);
- text-align: center;
- white-space: nowrap;
- padding: 6px 14px;
- pointer-events: auto;
- background-repeat: no-repeat;
- background-size: 100% 100%;
- background-image: none;
- color: #fff;
- box-sizing: border-box;
- &::after {
- content: '';
- }
- &::before {
- content: '';
- }
- >p {
- margin: 0;
- width: 100%;
- height: 100%;
- text-align: left;
- }
- span {
- white-space: nowrap;
- padding-right: 30px;
- user-select: none;
- color: #A99979;
- font-size: 16px;
- text-align: left;
- }
- .sline {
- width: 100%;
- height: 2px;
- background-color: #A99979;
- }
- .enspan {
- font-size: 12px;
- }
- }
- &.right {
- a {
- left: 88px;
- right: unset;
- }
- &::before {
- content: '';
- width: 100px;
- height: 2px;
- display: inline-block;
- background-color: #A99979;
- position: absolute;
- transform: rotate(-45deg);
- top: -30px;
- left: 18px;
- right: unset;
- }
- a {
- >p {
- text-align: right;
- padding-right: 0;
- padding-left: 30px;
- }
- span {
- text-align: right;
- padding-right: 0;
- padding-left: 30px;
- }
- }
- }
- &.detailShow {
- z-index: 1088 !important;
- &:after {
- content: "";
- background-image: url('~@/assets/images/point_active.svg');
- }
- &::before {
- content: "";
- background-color: #fff;
- }
- a {
- opacity: 0;
- }
- .picdetail {
- opacity: 1;
- pointer-events: auto;
- &::before {
- content: '';
- background-color: #fff !important;
- }
- }
- &.right {
- .picdetail {
- top: -254px;
- left: 163px;
- right: unset;
- &::before {
- content: '';
- display: inline-block;
- width: 60px;
- height: 2px;
- background-color: #A99979;
- position: absolute;
- left: -60px;
- right: unset;
- }
- }
- }
- }
- }
- }
- .picdetail {
- position: absolute;
- z-index: 999;
- opacity: 0;
- top: -254px;
- right: 163px;
- width: 300px;
- background-image: url('~@/assets/images/pop.png');
- background-repeat: no-repeat;
- background-size: 100% 100%;
- color: #fff;
- padding: 30px 36px;
- min-height: 378px;
- transition: .1s opacity ease;
- &::before {
- content: '';
- display: inline-block;
- width: 98px;
- height: 2px;
- background-color: #A99979;
- position: absolute;
- right: -98px;
- top: 189px;
- }
- .header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .pinfo {
- width: 100%;
- margin-top: 20px;
- >img {
- width: 100%;
- }
- >p {
- text-align: justify;
- font-size: 14px;
- color: rgba(255, 255, 255, 0.8);
- margin-top: 10px;
- line-height: 1.5;
- }
- }
- }
- @-webkit-keyframes room-label {
- 0% {
- opacity: 0;
- margin-top: 8.75px;
- }
- to {
- opacity: 1;
- margin-top: 0;
- }
- }
- @keyframes room-label {
- 0% {
- opacity: 0;
- margin-top: 8.75px;
- }
- to {
- opacity: 1;
- margin-top: 0;
- }
- }
- </style>
|