案例展示
创建焊接场景
<template>
<div id="TO" :style="{ width: width + '%', height: height + 'px' }"></div>
</template>
<script setup>
import { onMounted } from 'vue';
import animateData1 from "./utils/weld/animateData1.js";
import animateData2 from "./utils/weld/animateData2.js";
const props = defineProps({
width: {
type: Number,
default: 100,
},
height: {
type: Number,
default: 400,
},
});
onMounted(() => {
let sceneDom = document.getElementById("TO")
let TO = new ThingOrigin("easyBuild", sceneDom, {
helper: {
axes: {
active: false,
},
grid: {
active: false,
},
},
lights: [
{
name: "light1",
type: "AmbientLight",
color: "#fff",
intensity: 1,
visible: true,
position: {
x: 150,
y: 150,
z: 150,
},
},
],
})
// 模型数据
let weldInfo = {
id: 1,
modelType: "gltf",
modelName: "weld",
base: {
modelUrl: `${import.meta.env.BASE_URL}models/weld.gltf`, // 模型地址
},
scale: {
x: 12,
y: 12,
z: 12,
},
}
let carInfo = {
id: 2,
modelType: "gltf",
modelName: "car",
base: {
modelUrl: `${import.meta.env.BASE_URL}models/car.gltf`,
},
scale: {
x: 12,
y: 12,
z: 12,
},
}
TO.model.initFileModel(carInfo).then((model) => {
TO.scene.add(model.scene)
})
TO.model.initFileModel(weldInfo).then((model) => {
TO.scene.add(model.scene);
//6轴机器人运动起来
moveRobot();
})
function moveRobot() {
let weld = TO.scene.getObjectByProperty("name", "weld")
TO.machine.twinModel(
weld,
animateData1.axis,
animateData1.robot1,
animateData1.robot2,
2000
)
setTimeout(() => {
TO.machine.twinModel(
weld,
animateData2.axis,
animateData2.robot1,
animateData2.robot2,
2000
)
}, 2200)
}
});
</script>
<style scoped>
#TO {
width: 100%;
height: 400px;
position: relative;
}
</style>