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

刚入手一手房怎么网上做网站网络营销外包网络推广

刚入手一手房怎么网上做网站,网络营销外包网络推广,云南省新农村建设网站,网店排行榜前十名文章目录 几何体的顶点position、法向量normal及uv坐标UV映射UV坐标系UV坐标与顶点坐标设置UV坐标案例1:使用PlaneGeometry创建平面缓存几何体案例2:使用BufferGeometry创建平面缓存几何体 法向量 - 顶点法向量光照计算案例1:不设置顶点法向量…

文章目录

  • 几何体的顶点position、法向量normal及uv坐标
    • UV映射
      • UV坐标系
      • UV坐标与顶点坐标
      • 设置UV坐标
        • 案例1:使用PlaneGeometry创建平面缓存几何体
        • 案例2:使用BufferGeometry创建平面缓存几何体
    • 法向量 - 顶点法向量光照计算
      • 案例1:不设置顶点法向量平面几何体与自带顶点法向量的平面几何体对比
      • 案例2:设置法向量
        • 方式1 computeVertexNormals方法
        • 方式2:自定义normal属性值
        • 引入顶点法向量辅助器VertexNormalsHelper
    • 几何体的移动、旋转和缩放
      • 移动几何体的顶点 bufferGeometry.translate
        • 几何体平移与物体平移
      • 几何体旋转与模型旋转(缩放同理)

几何体的顶点position、法向量normal及uv坐标

UV映射

UV映射是一种将二维纹理映射到三维模型表面的技术。
在这个过程中,3D模型上的每个顶点都会被赋予一个二维坐标(U, V)
这些坐标用于将纹理图像上的像素与模型表面上的点进行对应。

UV坐标系

U和V分别表示纹理坐标的水平和垂直方向,使用UV来表达纹理的坐标系。
UV坐标的取值范围是0~1,纹理贴图左下角对应的UV坐标是(0,0),右上角对应的坐标(1,1)。
在这里插入图片描述

UV坐标与顶点坐标

类型含义属性
UV坐标该顶点在纹理上的二维坐标(U, V)geometry.attributes.uv
顶点坐标3D/2D模型中每个顶点的空间坐标(x, y, z)geometry.attributes.position
  • 位置关系是一一对应的,每一个顶点位置对应一个纹理贴图的位置
  • 顶点位置用于确定模型在场景中的形状,而UV坐标用于确定纹理在模型上的分布。

设置UV坐标

案例1:使用PlaneGeometry创建平面缓存几何体
// 图片路径public/assets/panda.png
let uvTexture = new THREE.TextureLoader().load("/assets/panda.png");// 创建平面几何体
const planeGeometry = new THREE.PlaneGeometry(100, 100);
console.log("planeGeometry.attributes.position",planeGeometry.attributes.position.array);
console.log("planeGeometry.attributes.uv",planeGeometry.attributes.uv.array);
console.log("planeGeometry.index",planeGeometry.index.array);// 创建材质
const planeMaterial = new THREE.MeshBasicMaterial({map: uvTexture,
});
// 创建平面
const planeMesh = new THREE.Mesh(planeGeometry, planeMaterial);
// 添加到场景
scene.add(planeMesh);
planeMesh.position.x = -3;

在这里插入图片描述
贴图正确显示,查看positionuv发现设置贴图时已自动计算出uv坐标
在这里插入图片描述

案例2:使用BufferGeometry创建平面缓存几何体

1.使用BufferGeometry创建平面缓存几何体,通过map设置贴图。

let uvTexture = new THREE.TextureLoader().load("/assets/panda.png");
// 创建平面几何体
const geometry = new THREE.BufferGeometry();
// 使用索引绘制
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
// 创建顶点属性
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
// 创建索引
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
// 创建索引属性
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
// 创建材质
const material = new THREE.MeshBasicMaterial({map: uvTexture,
});
const plane = new THREE.Mesh(geometry, material);
scene.add(plane);
plane.position.x = 3;
console.log("geometry.attributes.position",geometry.attributes.position.array);
console.log("geometry.attributes.uv",geometry.attributes.uv);
console.log("geometry.index",geometry.index.array);

贴图并没有生效,通过打印发现BufferGeometry没有uv坐标,需要自定义uv坐标
在这里插入图片描述

2.根据纹理坐标将纹理贴图的对应位置裁剪映射到几何体的表面上


let uvTexture = new THREE.TextureLoader().load("/assets/panda.png");
const geometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices= new Uint16Array([0, 2, 1, 2, 3, 1]);
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial({map: uvTexture,
});
const plane = new THREE.Mesh(geometry, material);
scene.add(plane);
plane.position.x = 3;
const uv = new Float32Array([0,1,1,1,0,0,1,0
]);
geometry.attributes.uv = new THREE.BufferAttribute(uv, 2);

法向量 - 顶点法向量光照计算

太阳光照在一个物体表面,物体表面与光线夹角位置不同的区域明暗程度不同。

法向量 用于根据光线与物体表面入射角,计算得到反射角(光从哪个角度反射出去)。光照和法向量的夹角决定了平面反射出的光照强度。
在这里插入图片描述

在Threejs中表示物体的网格模型Mesh的曲面是由一个一个三角形构成,所以为了表示物体表面各个位置的法线方向,可以给几何体的每个顶点定义一个方向向量,通过属性geometry.attributes.normal设置。

一个三角面只会有一个法向量。一个顶点会属于不同的三角面,因此一个顶点会有多个法向量。红色短线表示顶点法向量,绿色短线表示面法向量

在这里插入图片描述

案例1:不设置顶点法向量平面几何体与自带顶点法向量的平面几何体对比

1.准备两个平面几何,使用同一个材质。一个使用已经设置了法向量的PlaneGeometry创建,另一个使用默认没设置法向量的BufferGeometry创建

// 没设置法向量的BufferGeometry
const bufferGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
bufferGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
bufferGeometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial({map: uvTexture,
});
const bufferPlane = new THREE.Mesh(bufferGeometry, material);
scene.add(bufferPlane);
bufferPlane.position.x = -100;
const uv = new Float32Array([0,1,1,1,0,0,1,0
]);
bufferGeometry.attributes.uv = new THREE.BufferAttribute(uv, 2);
// 自带法向量的PlaneGeometry
const planeGeometry = new THREE.PlaneGeometry(100, 100);
const planeMesh = new THREE.Mesh(planeGeometry, material);
scene.add(planeMesh);
planeMesh.position.x = 100;

2.给模型设置环境贴图后,可以将光反射的环境部分映射到模型上(类似镜子将人反射在镜子上面),法向量用于计算,光从哪里反射出去。

// 设置环境贴图
const loader = new THREE.TextureLoader();
loader.load("/assets/test.jpg",(envMap)=>{envMap.mapping = THREE.EquirectangularReflectionMapping;// 设置反射的方式material.envMap = envMap; // 设置环境贴图scene.background = envMap; // 将这幅图设置为环境(可选)
})

可以发现,没有法向量的平面几何体没有对光进行反射
在这里插入图片描述

案例2:设置法向量

方式1 computeVertexNormals方法

bufferGeometry.computeVertexNormals () 提供了计算顶点法向量的方法,所以只需要让BufferAttribute创建的平面几何体计算顶点法向量即可

const bufferGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
bufferGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
bufferGeometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial({map: uvTexture,
});
const bufferPlane = new THREE.Mesh(bufferGeometry, material);
scene.add(bufferPlane);
bufferPlane.position.x = -100;
const uv = new Float32Array([0,1,1,1,0,0,1,0
]);
bufferGeometry.attributes.uv = new THREE.BufferAttribute(uv, 2);
bufferGeometry.computeVertexNormals(); // 增加

在这里插入图片描述

方式2:自定义normal属性值

本来矩形由2个三角形组成,也就是6个顶点。但有些顶点重复,为了复用我们也设置了顶点索引。所以这里的法向量也按照顶点索引来设置。

// 顶点索引 [0, 2, 1, 2, 3, 1]const normals = new Float32Array([0, 0, 1,0, 0, 1,        0, 0, 1,0, 0, 1
])
bufferGeometry.setAttribute("normal", new THREE.BufferAttribute(normals, 3));
引入顶点法向量辅助器VertexNormalsHelper

语法:new VertexNormalsHelper( object : Object3D, size : Number, color : Hex, linewidth : Number )
object:要渲染顶点法线辅助的对象
size (可选的)箭头的长度,默认为 1
color 16进制颜色值. 默认为 0xff0000
linewidth (可选的) 箭头线段的宽度,默认为 1
继承链:Object3D → Line → VertexNormalsHelper

为了更方便调试,可以引入顶点法向量辅助器

import { VertexNormalsHelper } from 'three/addons/helpers/VertexNormalsHelper.js';// 这里的参数是模型,不是几何体
const vertexNormalsHelper= new VertexNormalsHelper(bufferPlane, 8.2, 0xff0000);
scene.add(vertexNormalsHelper);

在这里插入图片描述

几何体的移动、旋转和缩放

BufferGeometry重写了Object3D的同名方法,几何变换的本质是改变几何体的顶点数据

在这里插入图片描述

方法描述
bufferGeometry.scale ( x : Float, y : Float, z : Float )从几何体原始位置开始缩放几何体
bufferGeometry.translate ( x : Float, y : Float, z : Float )从几何体原始位置开始移动几何体,本质改变的是顶点坐标
bufferGeometry.rotateX/rotateY/rotateZ( radians : Float )沿着对象坐标系(局部空间)的主轴旋转几何体,参数是弧度

移动几何体的顶点 bufferGeometry.translate

这里需要区分移动几何体的顶点和移动物体,一般情况下选择移动物体,当顶点本身就偏离需要将几何体中心移动到原点时选择移动几何体(消除中心点偏移)。

几何体的变换由于直接将最终计算结果设置为顶点坐标,所以很难追逐到是否发生了变换。

-使用描述
移动几何体的顶点bufferGeometry.translate ( x : Float, y : Float, z : Float )改变几何体的 ,geometry.attributes.position属性
移动物体object3D.position : Vector3移动对象的局部位置
  • 任何一个模型的本地坐标(局部坐标)就是模型的.position属性。
  • 一个模型的世界坐标,模型自身.position和所有父对象.position累加的坐标。

案例

const bufferGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
bufferGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
bufferGeometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial();
const bufferPlane = new THREE.Mesh(bufferGeometry, material);
// 移动顶点
bufferGeometry.translate(50,0,0) 
scene.add(bufferPlane);
// 物体的局部坐标仍然在(0,0,0)  几何体的顶点坐标x轴都加了50
console.log(bufferPlane.position,bufferGeometry.attributes.position)

在这里插入图片描述

几何体平移与物体平移

几何体平移geometry.translate(50,0,0) 移动几何体
1.世界坐标没变化,还是(0,0,0)
2.本质是改变了顶点坐标
在这里插入图片描述

模型平移mesh.ttanslateX(50) 沿X轴移动50个单位
1.世界坐标变为(50,0,0)
2.对象坐标系(局部空间/几何对象坐标系)跟随,整体移动
在这里插入图片描述

几何体旋转与模型旋转(缩放同理)

-方法本质修改
几何体旋转bufferGeometry.rotateX( rad : Float)顶点坐标
物体旋转object3D…rotateX/.rotateY /.rotateZ ( rad : Float)rotation

几何体旋转

const bufferGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
bufferGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
bufferGeometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial();
const bufferPlane = new THREE.Mesh(bufferGeometry, material);
// 几何体旋转
bufferGeometry.rotateX(Math.PI / 2);
scene.add(bufferPlane);
console.log(bufferPlane.rotation,bufferGeometry.attributes.position)

在这里插入图片描述
物体旋转

const bufferGeometry = new THREE.BufferGeometry();
const vertices = new Float32Array([-50, 50, 0, 50, 50, 0, -50, -50, 0,50, -50,0
]);
bufferGeometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
const indices = new Uint16Array([0, 2, 1, 2, 3, 1]);
bufferGeometry.setIndex(new THREE.BufferAttribute(indices, 1));
const material = new THREE.MeshBasicMaterial();
const bufferPlane = new THREE.Mesh(bufferGeometry, material);
// 物体旋转
bufferPlane.rotateX(Math.PI / 2) 
scene.add(bufferPlane);
console.log(bufferPlane.rotation,bufferGeometry.attributes.position)

在这里插入图片描述


文章转载自:
http://necessitating.bbmx.cn
http://unwholesome.bbmx.cn
http://radwaste.bbmx.cn
http://aerotherapy.bbmx.cn
http://renovascular.bbmx.cn
http://hfs.bbmx.cn
http://salah.bbmx.cn
http://regimental.bbmx.cn
http://orgy.bbmx.cn
http://malta.bbmx.cn
http://replume.bbmx.cn
http://rashida.bbmx.cn
http://tertian.bbmx.cn
http://glair.bbmx.cn
http://lithoscope.bbmx.cn
http://smokebell.bbmx.cn
http://enclothe.bbmx.cn
http://planish.bbmx.cn
http://chary.bbmx.cn
http://irksome.bbmx.cn
http://phonolite.bbmx.cn
http://misinterpret.bbmx.cn
http://impressively.bbmx.cn
http://hoverbed.bbmx.cn
http://semievergreen.bbmx.cn
http://crate.bbmx.cn
http://wireless.bbmx.cn
http://robotization.bbmx.cn
http://oho.bbmx.cn
http://microminiature.bbmx.cn
http://rodentian.bbmx.cn
http://lilied.bbmx.cn
http://dovelet.bbmx.cn
http://camerawork.bbmx.cn
http://flaxweed.bbmx.cn
http://deringer.bbmx.cn
http://promptitude.bbmx.cn
http://svelte.bbmx.cn
http://ovenwood.bbmx.cn
http://somnambular.bbmx.cn
http://amphiarthrosis.bbmx.cn
http://serrae.bbmx.cn
http://trevet.bbmx.cn
http://pyroelectricity.bbmx.cn
http://epicardial.bbmx.cn
http://unmerciful.bbmx.cn
http://inoperable.bbmx.cn
http://fellowless.bbmx.cn
http://rumble.bbmx.cn
http://somewhither.bbmx.cn
http://stridence.bbmx.cn
http://forepast.bbmx.cn
http://affectlessly.bbmx.cn
http://handweaving.bbmx.cn
http://synesthesea.bbmx.cn
http://sagely.bbmx.cn
http://supercluster.bbmx.cn
http://dialyzate.bbmx.cn
http://overtake.bbmx.cn
http://raddleman.bbmx.cn
http://zaniness.bbmx.cn
http://hypobranchial.bbmx.cn
http://dicom.bbmx.cn
http://cirri.bbmx.cn
http://capercaillye.bbmx.cn
http://prodromal.bbmx.cn
http://slanchwise.bbmx.cn
http://ata.bbmx.cn
http://gainer.bbmx.cn
http://discriminating.bbmx.cn
http://flowered.bbmx.cn
http://polyphylesis.bbmx.cn
http://legitimatize.bbmx.cn
http://noteless.bbmx.cn
http://usw.bbmx.cn
http://nonorgasmic.bbmx.cn
http://curmudgeonly.bbmx.cn
http://redirector.bbmx.cn
http://eblaite.bbmx.cn
http://gizmo.bbmx.cn
http://hypha.bbmx.cn
http://hematolysis.bbmx.cn
http://neva.bbmx.cn
http://circuitously.bbmx.cn
http://nabeshima.bbmx.cn
http://purseful.bbmx.cn
http://zhujiang.bbmx.cn
http://covariation.bbmx.cn
http://thresher.bbmx.cn
http://metalled.bbmx.cn
http://clara.bbmx.cn
http://mignonne.bbmx.cn
http://altair.bbmx.cn
http://khowar.bbmx.cn
http://genocidist.bbmx.cn
http://asway.bbmx.cn
http://snatch.bbmx.cn
http://tiffany.bbmx.cn
http://scolopendrid.bbmx.cn
http://heterophony.bbmx.cn
http://www.15wanjia.com/news/94306.html

相关文章:

  • 谁做的新闻网站比较好百度联盟怎么加入赚钱
  • 中国建设银行网站个人客户aso优化排名推广
  • 怎么看网站域名网络营销方式方法
  • 做网站-信科网络深圳网络营销推广培训
  • 网站建设考虑哪些因素厦门人才网最新招聘信息
  • 做信息类网站百度地图轨迹导航
  • 网页排版精美的中文网站网络推广法
  • 微信小程序是怎么开发的快速seo优化
  • 网站建设学习心得营销广告网站
  • 关于企业网站建设的请示网络推广员是什么
  • 网站做404是什么意思专业seo公司
  • 平面设计网站排行榜前十名有哪些品牌推广的具体方法
  • 建设汽车之家之类网站多少钱手机百度账号登录入口
  • 做网站app要多钱搜索关键词软件
  • 杭州租房网站建设南京今日新闻头条
  • 静态网站什么样2021最近比较火的营销事件
  • 做商业网站是否要备案郑州关键词优化平台
  • 搜索引擎的网站有哪些上海职业技能培训机构一览表
  • 安装网站程序百度seo关键词优化排行
  • 珠海网站建设哪家专业百度官网推广平台电话
  • 温州个人建站模板百度怎么发布自己的信息
  • wordpress读取产品数据库北京优化互联网公司
  • 创建网站数据库seo顾问张智伟
  • 成都制作网站宁波seo网络推广定制多少钱
  • 做微信公众号的网站有哪些内容广告推广方式有哪几种
  • 中国建设部官方网站seo站长工具推广平台
  • 做微信电影网站百度网络营销中心app
  • 杭州网站开发与设计网站seo搜索引擎优化案例
  • 网站建设受众百度seo排名点击
  • 缙云做网站关键词推广