VUE使用轮播图画3D模型图

使用vue的组件和three.js画出3d模型图

直接上代码,有问题评论区联系吧,经常在线。qq:2277655147

<template>
  <div class="card text-center m-b-20">
    <div class="card-body text-muted" >
      <h4 class="mt-0 header-title" style="font-weight: bold;font-size: 20px; height: 40px;">{
   {
   equipmentTitle}}</h4>
      <div class="paramPanel" v-show="sensorModel.sphereModel">
        <el-row>
          <label>{
   {
   sensorModel.sensorName}}{
   {
   sensorModel.sensorValue}}</label>
        </el-row>
      </div>
      <el-carousel
              trigger="click"
              :autoplay="false"
              :height="modelHeight"
              arrow="always"
              @change="equipmentChange"
      >
        <el-carousel-item v-for="(item,index) in equipmentData" :key="index"  >
          <div ref="panel3d"  :style="'height: '+modelHeight"></div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
  <!--<div ref="panel3d"  style="height: 31vh;"></div>-->
</template>
<script>
    import * as THREE from 'three'
    import {
    OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
    import {
    STLLoader } from 'three/examples/jsm/loaders/STLLoader'
    import * as TWEEN from '../../../Tween.js';
    export default {
   
        // props:['pointsInfo','sensorModel','equipmentTitle','parentActiveName','parentMethod','styleHeight'],
        /*
         *equipmentData:3d模型所需要的标题和监测点数据
         * equipmentChangeParent:设备变化之后的方法
         * sensorChangeParent:传感器变化之后的方法
         * styleHeight:3d模型的高度
         * initHighLight:是否初始化高亮
         */
        props:['equipmentData','equipmentChangeParent','sensorChangeParent','styleHeight','initHighLight'],
        data() {
   
            let temp_height=this.styleHeight;
            if(!this.styleHeight){
   
                temp_height='35vh';
            }
            return{
   
                //3d图
                scene: null,
                camera: null,
                raycaster: null,
                renderer: null,
                controls: null,
                material: null,
                mesh: null,
                INTERSECTED: null,
                INTERSECTEDForcus: null,
                pointsInfo: [],
                points: null,
                pointShells: null,
                width: 0,
                height: 0,
                //固定模型
                modelInfo:{
   
                    path:'/big.STL',
                    position:{
   
                        x:108,
                        y:0,
                        z:-137,
                    },
                    rotation:'-90',
                    scale:'0.052',
                },
                //模型的高度
                modelHeight:temp_height,
                //轮播图第一个
                sensorModel:{
   
                    sphereModel:false,
                    sensorName:'',
                    sensorValue:'',
                },
                //变压器标题
                equipmentTitle:'',
                //所有监测点
                parentActiveName:'',
                //展示的第几个
                index:0,
                //所有的模型
                indexs:[]
            }
        },
        watch:{
   
            'equipmentTitle'(value){
   
                if(value==this.parentActiveName){
   
                    if(this.points){
   
                        if(!this.INTERSECTED){
   
                            this.sensorModel.sphereModel=false;
                            return false;
                        }
                        for(let i = 0; i < this.points.children.length; i++){
   
                            if(this.points.children[i] == this.INTERSECTED){
   
                                this.sensorModel.sphereModel=true;
                                this.sensorModel.sensorName=this.pointsInfo[i].sensorName;
                                this.sensorModel.sensorValue=this.pointsInfo[i].sensorValue;
                            }
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值