Three.js 添加obj模型,旋转,加速,减速功能
suerprisePlus
2024-06-04 0b8adfd8269ecbe4a5f720a491a7659335388f1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <div id="threeBox" class="appBox">
    <div class="menuButton">
      <button @click="setModelPlay(1)" v-show="!stratPlay">启动</button>
      <button @click="setModelPlay(2)" v-show="stratPlay">停止</button>
      <button @click="setModelPlay(3)">加速</button>
      <button @click="setModelPlay(4)">减速</button>
      <!-- <button @click="setModelPlay(5)">复位</button> -->
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { onMounted, ref } from "vue";
import mapThree from "./assets/js/mapThree.js";
const stratPlay = ref(false);
const setModelPlay = (item) => {
  switch (item) {
    case 1:
      stratPlay.value = true;
      mapThree.setModelStart();
 
      break;
    case 2:
      stratPlay.value = false;
      mapThree.setModelClosed();
      break;
    case 3:
      mapThree.setModeladdSpeed();
      break;
    case 4:
      mapThree.setModeldelSpeed();
      break;
      case 5:
      stratPlay.value = false;
      mapThree.setModelreFreash();
      break;
  }
};
onMounted(() => {
  mapThree.init();
});
</script>
 
<style lang="scss" scoped>
.appBox {
  width: 100%;
  height: 100%;
  position: absolute;
  .menuButton {
    position: absolute;
    z-index: 99999;
    top: 10px;
    left: 10px;
 
    background: rgba(0, 0, 0, 0.5);
    button {
      margin: 10px;
      height: 10px;
      font-size: 12px;
      line-height: 2px;
      padding: 10px;
    }
  }
}
</style>