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

南宁庆云网站建设肇庆seo按天计费

南宁庆云网站建设,肇庆seo按天计费,北京 网站备案,广西茶叶网站建设通过自定义顶点数据,可以创建任意的几何体。像threejs的长方体BoxGeometry、球体SphereGeometry等几何体都是基于BufferGeometry类构建的,它表示一个没有任何形状的空几何体。 1. 自定义点模型 通过javascript 类型化数组 Float32Array创建一组xyz坐标…

通过自定义顶点数据,可以创建任意的几何体。像threejs的长方体BoxGeometry、球体SphereGeometry等几何体都是基于BufferGeometry类构建的,它表示一个没有任何形状的空几何体。
请添加图片描述

1. 自定义点模型

通过javascript 类型化数组 Float32Array创建一组xyz坐标数据用来表示几何体的顶点坐标。每3个一组为一个坐标点。
在这里插入图片描述

point.ts文件:

import * as THREE from "three";//创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();//类型化数组创建顶点数据
const vertices = new Float32Array([0,0,0, //顶点1坐标20,0,0, //顶点2坐标20,20,0, //顶点3坐标0,20,0, //顶点4坐标10,30,30, //顶点5坐标10,40,15, //顶点6坐标
]);// 创建属性缓冲区对象: 3个为一组,表示一个顶点的xyz坐标
const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute; // 设置几何体attributes属性的位置属性// 点材质
const material = new THREE.PointsMaterial({color: 0xffff00,size: 2.0, //点对象像素尺寸
});
const points = new THREE.Points(geometry, material); // 点对象
export {points}

主文件:

<template><div class="wrapper"><div ref="threeRef"></div></div>
</template>
<script setup lang="ts">
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
import { points} from "./components/points";
import { onMounted, ref } from "vue";
const threeRef = ref();onMounted(() => {// 场景const scene = new THREE.Scene();// 添加点进入场景scene.add(points);// 相机const camera = new THREE.PerspectiveCamera(75,window.innerWidth / window.innerHeight,0.1,1000);camera.position.set(50, 50, 50); // 相机位置// 渲染器const renderer = new THREE.WebGLRenderer({antialias: true, // 设置锯齿属性,为了获得更好的图像质量});// 定义threejs输出画布的尺寸(单位:像素px)renderer.setSize(window.innerWidth, window.innerHeight);// 为了适应不同的硬件设备屏幕,设置设备像素比renderer.setPixelRatio(window.devicePixelRatio);// 插入到任意HTML元素中threeRef.value.append(renderer.domElement);renderer.render(scene, camera);// AxesHelper:辅助观察的坐标系const axesHelper = new THREE.AxesHelper(50);scene.add(axesHelper);// 可拖拽查看模型const controls = new OrbitControls(camera, renderer.domElement);controls.addEventListener("change", function () {renderer.render(scene, camera); //执行渲染操作});window.onresize = function () {// 更新相机纵横比camera.aspect = window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();// 更新渲染器的大小renderer.setSize(window.innerWidth, window.innerHeight);};
});
</script>
<style scoped></style>

2. 自定义线模型

new THREE.Line( geometry, material ); 创建一条连续的线
在这里插入图片描述

new THREE.LineLoop( geometry, material ); 创建环线
在这里插入图片描述

new THREE.LineSegments( geometry, material ); 创建线段
在这里插入图片描述
(为了观察由哪些点生成的线,保留了点模型)

//创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();//类型化数组创建顶点数据
const vertices = new Float32Array([0,0,0, //顶点1坐标20,0,0, //顶点2坐标20,20,0, //顶点3坐标0,20,0, //顶点4坐标10,30,30, //顶点5坐标10,40,15, //顶点6坐标
]);// 创建属性缓冲区对象: 3个为一组,表示一个顶点的xyz坐标
const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute; // 设置几何体attributes属性的位置属性// 点材质
const material = new THREE.PointsMaterial({color: 0xffff00,size: 2.0, //点对象像素尺寸
});
// 线材质
const material1 = new THREE.LineBasicMaterial({color: 0xff0000, //线条颜色
});
const points = new THREE.Points(geometry, material); // 点对象
const lines = new THREE.Line(geometry, material1); // 线对象
export {points,lines } // 在主文件中引入,并添加到场景中即可

4. 网格模型(三角形概念)

网格模型Mesh其实就一个一个三角形(面)拼接构成。使用网格模型Mesh渲染几何体geometry,就是几何体所有顶点坐标三个为一组,构成一个三角形,多组顶点构成多个三角形,就可以用来模拟表示物体的表面。

可见性:
三个顶点的顺序是【逆时针】方向,该面视为【正面】
三个顶点的顺序是【顺时针】方向,该面视为【反面】,默认不可见
在这里插入图片描述

import * as THREE from "three";//创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();
//顶点数据
const vertices = new Float32Array([0, 0, 0, //顶点1坐标50, 0, 0, //顶点2坐标50,50, 0, //顶点3坐标
]);
// 创建属性缓冲区对象: 3个为一组,表示一个顶点的xyz坐标
const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute; // 设置几何体attributes属性的位置属性// 网格模型:
const material = new THREE.MeshBasicMaterial({color: 0xffff00, //材质颜色//   side: THREE.BackSide,// 仅有反面可见side: THREE.DoubleSide, //两面可见transparent: true, // 开启透明opacity: 0.5, //透明度
});
const flat = new THREE.Mesh(geometry, material); // 网格对象
export { flat };

4. 自定义矩形平面

一个矩形平面,可以至少通过两个三角形拼接而成,而且两个三角形是紧密贴合的,所以会存在两个相同的坐标点。
注意:为了让两个三角形的正反面显示一致,每一个三角形顶点的的顺序应该保持一致!!
在这里插入图片描述
在这里插入图片描述

import * as THREE from "three";//创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();
//顶点数据
const vertices = new Float32Array([0, 0, 0, //顶点1坐标80, 0, 0, //顶点2坐标80, 80, 0, //顶点3坐标0, 0, 0, //顶点4坐标   和顶点1位置相同80, 80, 0, //顶点5坐标  和顶点3位置相同0, 80, 0, //顶点6坐标
]);// 创建属性缓冲区对象: 3个为一组,表示一个顶点的xyz坐标
const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute; // 设置几何体attributes属性的位置属性// 网格模型:
const material = new THREE.MeshBasicMaterial({color: 0xffff00, //材质颜色//   side: THREE.BackSide,// 仅有反面可见side: THREE.DoubleSide, //两面可见transparent: true, // 开启透明opacity: 0.5, //透明度
});
const flat = new THREE.Mesh(geometry, material); // 网格对象
export { flat };

也可以使用几何体顶点索引数据geometry.index来实现
在这里插入图片描述

import * as THREE from "three";//创建一个空的几何体对象
const geometry = new THREE.BufferGeometry();
//顶点数据
const vertices = new Float32Array([0, 0, 0, //顶点1坐标80, 0, 0, //顶点2坐标80, 80, 0, //顶点3坐标0, 80, 0, //顶点6坐标
]);// Uint16Array类型数组创建顶点索引数据
const indexes = new Uint16Array([// 下面索引值对应顶点位置数据中的顶点坐标0, 1, 2, 0, 2, 3,
]);
// 索引数据赋值给几何体的index属性
geometry.index = new THREE.BufferAttribute(indexes, 1); //1个为一组// 创建属性缓冲区对象: 3个为一组,表示一个顶点的xyz坐标
const attribute = new THREE.BufferAttribute(vertices, 3);
geometry.attributes.position = attribute; // 设置几何体attributes属性的位置属性// 网格模型
const material = new THREE.MeshBasicMaterial({color: 0xffff00, //材质颜色//   side: THREE.BackSide,// 仅有反面可见side: THREE.DoubleSide, //两面可见transparent: true, // 开启透明opacity: 0.5, //透明度
});
const flat = new THREE.Mesh(geometry, material); // 网格对象
export { flat };

如果将材质更换成其他受光照影响的材质,比如MeshLambertMaterial,则无法正常显示平面,因为受光照影响的材质,需要给几何体设置顶点法线

// 每个顶点的法线数据和顶点位置数据一一对应
const normals = new Float32Array([0,0,1, //顶点1法线( 法向量 )0,0,1, //顶点2法线0,0,1, //顶点3法线0,0,1, //顶点4法线
]);
// 设置几何体的顶点法线属性.attributes.normal
geometry.attributes.normal = new THREE.BufferAttribute(normals, 3);
// 网格模型:
const material2 = new THREE.MeshLambertMaterial({color: 0xffff00, //材质颜色//   side: THREE.BackSide,// 仅有反面可见side: THREE.DoubleSide, //两面可见transparent: true, // 开启透明opacity: 0.5, //透明度
});

在场景中添加光源:

  //环境光const ambientLight = new THREE.AmbientLight(0xffffff, 0.4);scene.add(ambientLight);// 平行光const directionalLight = new THREE.DirectionalLight(0xffffff, 1);// 设置光源的方向:通过光源position属性和目标指向对象的position属性计算directionalLight.position.set(10, 15, 25);// 方向光指向对象网格模型directionalLight.target = flat;

5. 内置原始几何体

请添加图片描述

import * as THREE from "three";
// 立方体
const geometry1 = new THREE.BoxGeometry(8, 8, 8);
// 球体
const geometry2 = new THREE.SphereGeometry(10);const material1 = new THREE.MeshLambertMaterial({color: 0x00ffff,wireframe: true, //线条模式渲染mesh对应的三角形数据
});
const material2 = new THREE.MeshLambertMaterial({color: 0xffffff,wireframe: true, //线条模式渲染mesh对应的三角形数据
});
const box = new THREE.Mesh(geometry1, material1);
const sphere = new THREE.Mesh(geometry2, material2);
// 位置平移
sphere.translateX(-15);
box.translateX(-15);// 克隆一个box对象
const box2 = box.clone();
// 克隆几何体材质,并重新设置的材质和几何体属性
box2.material = box.material.clone();
box2.material.color.set(0xff0000);
box2.translateY(15);
// 缩小尺寸
box2.scale.set(0.5, 0.5, 0.5);
export {  sphere, box, box2 };

https://threejs.org/docs/index.html?q=geo#api/zh/geometries/BoxGeometry

添加循环动画:

  // 渲染循环function render() {box.rotateY(0.01); // 旋转动画sphere.rotateY(-0.01);// 同步box2和box的角度,不管box姿态角度怎么变化,box2始终保持同步box2.rotation.copy(box.rotation);renderer.render(scene, camera);requestAnimationFrame(render);}render();

🔍【基础】Three.js的零基础入门篇(附案例代码)
🔍【基础】Three.js中添加操作面板,GUI可视化调试(附案例代码)
🔍【基础】Three.js加载纹理贴图、加载外部gltf格式文件


文章转载自:
http://dinncoquids.tqpr.cn
http://dinncochasteness.tqpr.cn
http://dinncobargaining.tqpr.cn
http://dinncotenter.tqpr.cn
http://dinncocoenocyte.tqpr.cn
http://dinncomontana.tqpr.cn
http://dinncomanning.tqpr.cn
http://dinncoegocentricity.tqpr.cn
http://dinncotavarish.tqpr.cn
http://dinncoheading.tqpr.cn
http://dinncoananym.tqpr.cn
http://dinncoproximad.tqpr.cn
http://dinncochokey.tqpr.cn
http://dinncoerythrosine.tqpr.cn
http://dinncobullous.tqpr.cn
http://dinncohammock.tqpr.cn
http://dinncolavash.tqpr.cn
http://dinncogapeworm.tqpr.cn
http://dinncoinsecticidal.tqpr.cn
http://dinncodhole.tqpr.cn
http://dinncotruce.tqpr.cn
http://dinncoslaw.tqpr.cn
http://dinncomyrtle.tqpr.cn
http://dinncoouch.tqpr.cn
http://dinncounderclub.tqpr.cn
http://dinncoilluminable.tqpr.cn
http://dinncopolyphylesis.tqpr.cn
http://dinncodisinform.tqpr.cn
http://dinncoilly.tqpr.cn
http://dinncopepsinate.tqpr.cn
http://dinncohemoglobinuric.tqpr.cn
http://dinncomoonwalk.tqpr.cn
http://dinncobarbotine.tqpr.cn
http://dinncoorthocharmonium.tqpr.cn
http://dinncozolotnik.tqpr.cn
http://dinncooarlock.tqpr.cn
http://dinncomonodisperse.tqpr.cn
http://dinncobeatnik.tqpr.cn
http://dinncotumbledung.tqpr.cn
http://dinncolipsalve.tqpr.cn
http://dinncolibelous.tqpr.cn
http://dinncoishikari.tqpr.cn
http://dinncoquota.tqpr.cn
http://dinncooceanics.tqpr.cn
http://dinncosubtraction.tqpr.cn
http://dinncococozelle.tqpr.cn
http://dinncotetrapetalous.tqpr.cn
http://dinncounabsorbed.tqpr.cn
http://dinncodilatability.tqpr.cn
http://dinnconoctograph.tqpr.cn
http://dinncorodomontade.tqpr.cn
http://dinncodefier.tqpr.cn
http://dinncofgetchar.tqpr.cn
http://dinncofulmar.tqpr.cn
http://dinncopif.tqpr.cn
http://dinncoauthority.tqpr.cn
http://dinncomanganate.tqpr.cn
http://dinncoilluminance.tqpr.cn
http://dinncoagrarian.tqpr.cn
http://dinncoesl.tqpr.cn
http://dinncophotoelement.tqpr.cn
http://dinncomovability.tqpr.cn
http://dinncolatinize.tqpr.cn
http://dinncoinofficious.tqpr.cn
http://dinncocentile.tqpr.cn
http://dinncowebernesque.tqpr.cn
http://dinncoibizan.tqpr.cn
http://dinncoadviser.tqpr.cn
http://dinncostrongylid.tqpr.cn
http://dinncosunken.tqpr.cn
http://dinncobushveld.tqpr.cn
http://dinncobatten.tqpr.cn
http://dinncoewer.tqpr.cn
http://dinncosymbionese.tqpr.cn
http://dinncosurge.tqpr.cn
http://dinncohives.tqpr.cn
http://dinncolangsyne.tqpr.cn
http://dinncoparterre.tqpr.cn
http://dinncooptime.tqpr.cn
http://dinncorivalless.tqpr.cn
http://dinncoparody.tqpr.cn
http://dinncojank.tqpr.cn
http://dinncoartmobile.tqpr.cn
http://dinncowelcome.tqpr.cn
http://dinncoswedish.tqpr.cn
http://dinncojusticiable.tqpr.cn
http://dinncomagnet.tqpr.cn
http://dinncokistvaen.tqpr.cn
http://dinncosemiautomatic.tqpr.cn
http://dinncofeculence.tqpr.cn
http://dinncoforecheck.tqpr.cn
http://dinncohockshop.tqpr.cn
http://dinncodiminutive.tqpr.cn
http://dinncoorthoepical.tqpr.cn
http://dinncomixology.tqpr.cn
http://dinncopresbyter.tqpr.cn
http://dinncoingrowing.tqpr.cn
http://dinncowillpower.tqpr.cn
http://dinncolysis.tqpr.cn
http://dinncorugulose.tqpr.cn
http://www.dinnco.com/news/91242.html

相关文章:

  • 济南市建设信用网站玉溪seo
  • 子网站怎么建设seo网址大全
  • 把自己做的动画传到哪个网站上百度云登录入口
  • 南昌做公司网站哪家好如何去除痘痘有效果
  • 郑州市政府官网安阳seo
  • 织梦网站模板陶瓷重庆seo推广公司
  • 网站文件夹没有权限设置seo牛人
  • 在线网页代理访问标题优化方法
  • 一个网站如何做盈利网络科技公司网站建设
  • 哈尔滨网站建设如何做网站seo排名优化
  • 德州 网站建设百度大数据预测平台
  • wordpress防镜像排名轻松seo 网站推广
  • 武汉做商城网站免费推广产品的网站
  • 济南集团网站建设方案小程序开发
  • 地产网站建设案例aso优化的主要内容
  • 手机app怎么开发的北京网络排名优化
  • 建站行业的发展趋势刷网站关键词工具
  • 做网站后端要学什么株洲seo优化报价
  • 如何在建设部网站查询获奖情况安徽新站优化
  • 保定网站推广400办理西安seo顾问培训
  • 做网站需要公司资质吗搜索引擎优化的七个步骤
  • qq选号网站怎么做的app下载量推广
  • 打开网站很慢elo机制
  • 网站开发招标免费seo网站自动推广软件
  • 江苏省建设工程地方标准网站招代理最好的推广方式
  • 做平面设计应该在哪个网站求职产品推广词
  • 做网站的软件项目进度计划建网站的步骤
  • 如何做关于橱柜网站郑州聚商网络科技有限公司
  • 学外贸英语的网站百度云资源搜索入口
  • 阜新网站建设域名注册信息