Browse Source

添加输送线

master
liupeng 7 months ago
parent
commit
18b34ae649
  1. 41
      src/designer/model3DView/Model3DView.vue

41
src/designer/model3DView/Model3DView.vue

@ -84,7 +84,7 @@ import { TransformControls } from 'three/examples/jsm/controls/TransformControls
import Split from '@/components/split/split.vue'
import SplitArea from '@/components/split/split-area.vue'
import { renderIcon } from '@/utils/webutils.js'
import textureUrl from '@/assets/images/conveyor/shapes/Belt1.png'
import textureUrl from '@/assets/images/conveyor/shapes/RibSideSkirtThumbnail.jpg'
// DOM refs
const canvasContainer = ref(null)
@ -167,18 +167,21 @@ watch(() => restate.mode, (newVal) => {
function addConveyor(){
// 1. 10 0.8
const length = 10; // X
const width = 0.8; // Y
const geometry = new THREE.PlaneGeometry(length, width);
const length = 20; // (X)
const width = 0.8; // (Y)
const height = 0.2; // / (Z)
const geometry = new THREE.BoxGeometry(length, width, height);
// 2.
const textureLoader = new THREE.TextureLoader();
debugger
textureLoader.load(textureUrl, (texture)=>{
debugger
// 3.
texture.wrapS = THREE.RepeatWrapping; // X
texture.wrapT = THREE.RepeatWrapping; // Y
texture.center.set(0.5,0.5)
texture.rotation = Math.PI / 2
texture.repeat.set(1, 1); //
// 4. 线Y
@ -188,7 +191,8 @@ function addConveyor(){
texture.repeat.set(1, 20); // Y
// 5.
const material = new THREE.MeshBasicMaterial({ map: texture });
const material = new THREE.MeshBasicMaterial(
{ map: texture,color: 0x9f9f9f});
// 6.
const conveyorBelt = new THREE.Mesh(geometry, material);
@ -196,7 +200,30 @@ function addConveyor(){
// 7. XPlaneGeometryX/Y
conveyorBelt.rotation.x = -Math.PI / 2; // X/Z
//
conveyorBelt.position.y = height / 2; //
scene.add(conveyorBelt)
//
let offsetSpeed = 0.01; //
function animate() {
requestAnimationFrame(animate);
// 沿Y
if (texture) {
let currentOffset = texture.offset.y;
currentOffset += offsetSpeed;
// 1
if (currentOffset >= 1) {
currentOffset -= 1;
}
texture.offset.set(texture.offset.x,currentOffset);
}
renderer.render(scene, camera);
}
animate();
});

Loading…
Cancel
Save