当前位置: 首页 > news >正文

手机网站分享js代码网站后台用esayui做

手机网站分享js代码,网站后台用esayui做,怎样把已经有的网站做推广,网站介绍词three.js实现电子围栏效果&#xff08;纹理贴图&#xff09; 实现步骤 围栏的坐标坐标转换为几何体顶点&#xff0c;uv顶点坐标加载贴图&#xff0c;移动 图例 代码 <template><div class"app"><div ref"canvesRef" class"canvas-…

three.js实现电子围栏效果(纹理贴图)

实现步骤

  1. 围栏的坐标
  2. 坐标转换为几何体顶点,uv顶点坐标
  3. 加载贴图,移动

图例

在这里插入图片描述

代码

<template><div class="app"><div ref="canvesRef" class="canvas-wrap"></div></div>
</template><script setup>
import { ref, onMounted } from "vue";
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";const canvesRef = ref(null);
const canvasWidth = window.innerWidth;
const canvasHeight = window.innerHeight;
let scene;
let camera;
let renderer;
let axesHelper;
let cameraControls;init();
render();
function init() {// 场景scene = new THREE.Scene();// 模型addModel();// 相机camera = new THREE.PerspectiveCamera(75,canvasWidth / canvasHeight,0.1,3000);camera.position.set(300, 300, 300);// camera.lookAt(0, 0, 0);// 坐标辅助对象axesHelper = new THREE.AxesHelper(200);scene.add(axesHelper);// 渲染器//antialias - 是否执行抗锯齿。默认为false.renderer = new THREE.WebGLRenderer();renderer.setSize(canvasWidth, canvasHeight);// 相机轨道控制器cameraControls = new OrbitControls(camera, renderer.domElement);
}
function addModel() {// 坐标const points = [[0, 0, 0],[0, 0, 200],[200, 0, 200],[200, 0, 0],[0, 0, 0],];const height = 30; // 高度const color1 = "#ff00ff"; // 颜色// 围栏距离 累加const pointDistance = [];// 围栏总长度const distance = points.reduce((totalDistance, point, index) => {let segmentDistance = 0;if (index > 0) {let lastPoint = new THREE.Vector3(...points[index - 1]);let currPoint = new THREE.Vector3(...point);segmentDistance = lastPoint.distanceTo(currPoint);}totalDistance += segmentDistance;pointDistance.push(totalDistance);return totalDistance;}, 0);// console.log(distance, pointDistance);// 几何体const geometry = new THREE.BufferGeometry(); // 缓冲几何体const posArr = [];const uvArr = [];// 遍历坐标// posArr 几何体顶点points.forEach((point, index) => {if (index == 0) return;const lastPoint = points[index - 1];// 三角面1posArr.push(...lastPoint);uvArr.push(pointDistance[index - 1] / distance, 0);posArr.push(...point);uvArr.push(pointDistance[index] / distance, 0);posArr.push(lastPoint[0], lastPoint[1] + height, lastPoint[2]);uvArr.push(pointDistance[index - 1] / distance, 1);// 三角面2posArr.push(...point);uvArr.push(pointDistance[index] / distance, 0);posArr.push(point[0], point[1] + height, point[2]);uvArr.push(pointDistance[index] / distance, 1);posArr.push(lastPoint[0], lastPoint[1] + height, lastPoint[2]);uvArr.push(pointDistance[index - 1] / distance, 1);});console.log(posArr, uvArr);geometry.setAttribute("position",new THREE.BufferAttribute(new Float32Array(posArr), 3));geometry.setAttribute("uv",new THREE.BufferAttribute(new Float32Array(uvArr), 2));// 纹理const texture = new THREE.TextureLoader().load("../src/assets/img/icon.png");texture.wrapS = THREE.RepeatWrapping;texture.wrapT = THREE.RepeatWrapping;// 材质const material = new THREE.MeshBasicMaterial({// color: color1,map: texture,transparent: true,opacity: 1,depthWrite: false,side: THREE.DoubleSide,});// 创建围栏const mesh = new THREE.Mesh(geometry, material);scene.add(mesh);texture.repeat.set(10, 1); // 平铺textrue_offset(texture, "top", 5);
}
function textrue_offset(texture, direction = "right", speed = 0.5) {// 开始时间const start = Date.now();const h = () => {requestAnimationFrame(h);const now = Date.now();const offset = ((now - start) / 1000) * speed;switch (direction) {case "left":texture.offset = new THREE.Vector2(offset, 0); //纹理偏移break;case "right":texture.offset = new THREE.Vector2(-offset, 0);break;case "top":texture.offset = new THREE.Vector2(0, -offset);break;case "left":texture.offset = new THREE.Vector2(0, offset);break;}};h();
}
function render() {renderer.render(scene, camera);requestAnimationFrame(render);
}
onMounted(() => {canvesRef.value.appendChild(renderer.domElement);
});
</script><style lang="scss" scoped>
.app {position: relative;
}
</style>
http://www.yayakq.cn/news/483797/

相关文章:

  • 免费室内设计素材网站食品营销型网站建设
  • 企业站群系统三明市住房与建设局网站
  • 做汽车团购的网站德州口碑好的网站制作公司
  • 美颜秘籍网站建设南通市住房和城乡建设厅网站
  • 上海网站建设公司推荐排名哪个网站可以做ppt
  • 网站规划与开发专业深圳市手机网站建设怎么样
  • 昆山网站建设jofuns网站建设搭建是什么意思
  • 个人定制网站怎么做怎样做婚庆网站
  • 企业网站的特点怎样在网站上做超链接
  • 重庆的汽车网站建设乐陵网站服务在哪一条
  • 南海小程序网站开发网站建设专员工作
  • 哪个免费自助建站系统最好用百度浏览器官方网站
  • 服务器和网站的关系海南省建设注册执业资格中心网站
  • 拟定一个物流网站建设方案石家庄seo网站建设
  • wex5 后端实现全网站开发创业网站模板免费下载
  • 柳州网站建设公司哪家好个人网站备案查询
  • 网站图片分辨率北京确诊病例活动轨迹公布
  • 打造一个网站wordpress登陆菜单
  • 莆田有哪几家做网站设计网站建设的软硬件环境
  • 建设自己的网站步骤怎么做北京pk10的网站
  • wordpress广告链接地址丹东seo优化效果费用
  • 电子工程师网站wordpress theme 权限
  • php网站开发视频教学做网站赚谁的钱
  • 深圳网站建设小江南通做百度网站的公司
  • 装修合同电子版东莞优化公司首选3火星
  • 广州做网站哪家专业模型网站大全免费
  • 牛股大转盘网站建设wordpress不能后台
  • 网站源码修复快速网站开发
  • 网站建设和网页设计的区别长沙网站建设工作室
  • 惠州网站制作专业做章的网站