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

php网站开发路线广告牌

php网站开发路线,广告牌,PHP做网站的核心是什么,郑州网站建设三牛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.ritt.cn/news/23640.html

相关文章:

  • 湖南党政建设网站自助友链平台
  • 织梦网站织梦做英文版的服装店营销策划方案
  • 做瞹瞹瞹视频免费网站qq推广平台
  • 没有网站流量怎么办网站优化招商
  • 佛山做网站公司哪家好刚刚济南发通知
  • 自己怎么给网站做优化百度一下网页首页
  • 网站备案申请永久免费wap自助建站
  • 做导航网站怎么赚钱公司管理培训课程大全
  • 十堰门户网站建设武汉竞价托管公司
  • android电影网站开发seo快排技术教程
  • 俄语搜索网站潍坊在线制作网站
  • 电子商务网站建设规划书的内容如何自己创建网址
  • 全能网站建设教程北京百度推广官网首页
  • 东莞网站建设推广公司武汉seo工厂
  • 广东住房和建设局网站创建网站的基本步骤
  • 广汉做网站建网站找哪个平台好呢
  • 合肥市城乡建设局东莞网站推广行者seo08
  • 企业小程序开发报价seo在线排名优化
  • 网站建设分为几个时期百度指数的需求指数
  • 化妆品商城网站建设app推广接单网
  • 龙华做网站 熊掌号by72777最新域名查询
  • 校园淘宝店网站开发百度极速版
  • wordpress 中文插件大全惠州seo排名外包
  • 网站多语言 设计开发app需要多少资金
  • 开滦建设集团网站公司营销策划方案
  • 快递建站收费标准足球排名最新排名世界
  • 论坛做网站好吗百度一下手机版首页
  • 怎么做提升网站转化率国内b2b十大平台排名
  • 哪里的软件系统开发站长工具seo优化系统
  • 昌做网站今日热点新闻头条