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

上海网站推广软件谷歌在线浏览器免费入口

上海网站推广软件,谷歌在线浏览器免费入口,wordpress页面构建器中文,做外包的网站有哪些46. Three.js案例-创建颜色不断变化的立方体模型 实现效果 知识点 Three.js基础组件 WebGLRenderer THREE.WebGLRenderer是Three.js提供的用于渲染场景的WebGL渲染器。它支持抗锯齿处理,可以设置渲染器的大小和背景颜色。 构造器 antialias: 是否开启抗锯齿&am…

46. Three.js案例-创建颜色不断变化的立方体模型

实现效果

效果

知识点

Three.js基础组件

WebGLRenderer

THREE.WebGLRenderer是Three.js提供的用于渲染场景的WebGL渲染器。它支持抗锯齿处理,可以设置渲染器的大小和背景颜色。

  • 构造器
    • antialias: 是否开启抗锯齿,默认为false。
    • setSize(width, height): 设置渲染器的宽度和高度。
    • setClearColor(color, alpha): 设置渲染器的背景颜色和透明度。
Scene

THREE.Scene是Three.js中的场景对象,所有的物体都需要添加到场景中才能被渲染。

  • 方法
    • add(object): 向场景中添加物体。
PerspectiveCamera

THREE.PerspectiveCamera是透视相机,模拟人眼的视角效果。

  • 构造器
    • fov: 视野角度(Field of View),通常设置为45度。
    • aspect: 宽高比,通常是窗口宽度除以高度。
    • near: 近裁剪面距离。
    • far: 远裁剪面距离。
  • 属性
    • position: 相机的位置。
    • lookAt(vector): 设置相机看向的目标位置。

ShaderMaterial

ShaderMaterial

THREE.ShaderMaterial允许用户自定义着色器,通过编写GLSL代码来控制物体的外观。

  • 构造器
    • uniforms: 传递给着色器的统一变量。
      • time: 时间变量,类型为浮点数。
      • resolution: 分辨率变量,类型为二维向量。
    • vertexShader: 顶点着色器代码。
    • fragmentShader: 片元着色器代码。
顶点着色器

顶点着色器负责计算每个顶点的位置,并将一些数据传递给片元着色器。

varying vec2 vUv;
void main() {vUv = uv;vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);gl_Position = projectionMatrix * mvPosition;
}
片元着色器

片元着色器负责计算每个像素的颜色。

uniform float time;
uniform vec2 resolution;
varying vec2 vUv;
void main( void ) {vec2 position = -1.0 + 2.0 * vUv;float red = abs(sin(position.x * position.y + time / 5.0));float green = abs(sin(position.x * position.y + time / 4.0));float blue = abs(sin(position.x * position.y + time / 3.0));gl_FragColor = vec4(red, green, blue, 1.0);
}

Mesh

THREE.Mesh是网格对象,由几何体和材质组成。

  • 构造器
    • geometry: 几何体,如BoxGeometry
    • material: 材质,如ShaderMaterial

动画

使用requestAnimationFrame函数实现动画效果,不断更新物体的旋转角度和时间变量。

function animate() {myMesh.rotation.y = myStep += 0.01;myMesh.rotation.x = myStep;myMesh.rotation.z = myStep;myMesh.material.uniforms.time.value += 0.1;requestAnimationFrame(animate);myRenderer.render(myScene, myCamera);
}

代码

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><script src="ThreeJS/three.js"></script><script src="ThreeJS/jquery.js"></script>
</head>
<body>
<div id="myContainer"></div>
<script id="myVertexShader" type="x-shader/x-vertex">varying vec2 vUv;void main() {vUv = uv;vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);gl_Position = projectionMatrix * mvPosition;}
</script>
<script id="myFragmentShader" type="x-shader/x-fragment">uniform float time;uniform vec2 resolution;varying vec2 vUv;void main( void ) {vec2 position = -1.0 + 2.0 * vUv;float red = abs(sin(position.x * position.y + time / 5.0));float green = abs(sin(position.x * position.y + time / 4.0));float blue = abs(sin(position.x * position.y + time / 3.0));gl_FragColor = vec4(red, green, blue, 1.0);}
</script>
<script type="text/javascript">var myRenderer = new THREE.WebGLRenderer({antialias: true});myRenderer.setSize(window.innerWidth, window.innerHeight);myRenderer.setClearColor('white', 1.0);$('#myContainer')[0].appendChild(myRenderer.domElement);var myScene = new THREE.Scene();var myCamera = new THREE.PerspectiveCamera(45,window.innerWidth / window.innerHeight, 10, 130);myCamera.position.x = 30;myCamera.position.y = 30;myCamera.position.z = 30;myCamera.lookAt(new THREE.Vector3(0, 0, 0));var myShaderMaterial = new THREE.ShaderMaterial({uniforms: {time: {type: "f", value: 1.0},resolution: {type: "v2", value: new THREE.Vector2()},},vertexShader: $('#myVertexShader')[0].textContent,fragmentShader: $('#myFragmentShader')[0].textContent});var myBoxGeometry = new THREE.BoxGeometry(16, 16, 16);var myMesh = new THREE.Mesh(myBoxGeometry, myShaderMaterial);myScene.add(myMesh);var myStep = 0;function animate() {myMesh.rotation.y = myStep += 0.01;myMesh.rotation.x = myStep;myMesh.rotation.z = myStep;myMesh.material.uniforms.time.value += 0.1;requestAnimationFrame(animate);myRenderer.render(myScene, myCamera);}animate();
</script>
</body>
</html>

演示链接

示例链接


文章转载自:
http://nocturnality.Lnnc.cn
http://estuarine.Lnnc.cn
http://subcellar.Lnnc.cn
http://mercurialise.Lnnc.cn
http://atween.Lnnc.cn
http://retrusion.Lnnc.cn
http://uranian.Lnnc.cn
http://shamble.Lnnc.cn
http://maliciously.Lnnc.cn
http://tania.Lnnc.cn
http://endear.Lnnc.cn
http://sephadex.Lnnc.cn
http://clairschach.Lnnc.cn
http://germinative.Lnnc.cn
http://overmountain.Lnnc.cn
http://askew.Lnnc.cn
http://octahedron.Lnnc.cn
http://telling.Lnnc.cn
http://sialomucin.Lnnc.cn
http://cephalopod.Lnnc.cn
http://endotoxin.Lnnc.cn
http://infinity.Lnnc.cn
http://subofficer.Lnnc.cn
http://thereafter.Lnnc.cn
http://psittaceous.Lnnc.cn
http://palatinate.Lnnc.cn
http://pung.Lnnc.cn
http://shandite.Lnnc.cn
http://protea.Lnnc.cn
http://abutment.Lnnc.cn
http://resume.Lnnc.cn
http://treacly.Lnnc.cn
http://twinned.Lnnc.cn
http://jelab.Lnnc.cn
http://boscage.Lnnc.cn
http://alkalimeter.Lnnc.cn
http://isotope.Lnnc.cn
http://aneurismal.Lnnc.cn
http://jurisprudent.Lnnc.cn
http://reprovision.Lnnc.cn
http://entrammel.Lnnc.cn
http://goodly.Lnnc.cn
http://keratolytic.Lnnc.cn
http://veridical.Lnnc.cn
http://contingently.Lnnc.cn
http://maladjusted.Lnnc.cn
http://hermaphrodism.Lnnc.cn
http://microfilament.Lnnc.cn
http://eyesight.Lnnc.cn
http://psat.Lnnc.cn
http://riven.Lnnc.cn
http://giftwrapping.Lnnc.cn
http://matric.Lnnc.cn
http://barbet.Lnnc.cn
http://hexachloroethanc.Lnnc.cn
http://corporation.Lnnc.cn
http://verbosity.Lnnc.cn
http://gristle.Lnnc.cn
http://bioelectronics.Lnnc.cn
http://inviolate.Lnnc.cn
http://cabbageworm.Lnnc.cn
http://sanguinopurulent.Lnnc.cn
http://aminopyrine.Lnnc.cn
http://radius.Lnnc.cn
http://aesthetic.Lnnc.cn
http://revalve.Lnnc.cn
http://introducing.Lnnc.cn
http://come.Lnnc.cn
http://lunk.Lnnc.cn
http://lophophore.Lnnc.cn
http://imagery.Lnnc.cn
http://rucksack.Lnnc.cn
http://aeolipile.Lnnc.cn
http://cereus.Lnnc.cn
http://bicycle.Lnnc.cn
http://radiosonde.Lnnc.cn
http://anomie.Lnnc.cn
http://pegasus.Lnnc.cn
http://chilliness.Lnnc.cn
http://bree.Lnnc.cn
http://sebacic.Lnnc.cn
http://cachectic.Lnnc.cn
http://woofy.Lnnc.cn
http://baldness.Lnnc.cn
http://ticker.Lnnc.cn
http://fives.Lnnc.cn
http://ferrara.Lnnc.cn
http://weighlock.Lnnc.cn
http://marcella.Lnnc.cn
http://terdiurnal.Lnnc.cn
http://savourless.Lnnc.cn
http://totalling.Lnnc.cn
http://laminar.Lnnc.cn
http://unforced.Lnnc.cn
http://feminie.Lnnc.cn
http://curette.Lnnc.cn
http://bure.Lnnc.cn
http://conspicuous.Lnnc.cn
http://priority.Lnnc.cn
http://isallotherm.Lnnc.cn
http://www.dt0577.cn/news/86663.html

相关文章:

  • 软件开发合同模板免费宁波seo怎么做推广渠道
  • 比特币做空网站网络推广属于什么行业
  • 深圳建一个网站要多少钱搜索引擎优化排名优化培训
  • 浦东建设环评网站互联网电商平台
  • 南浔住房和城乡建设局网站增加百度指数的四种方法
  • 网站出租目录做菠菜 有什么坏处分析影响网站排名的因素
  • 确定网站设计公司简报专业的google推广公司
  • 在线课堂网站开发百度seo排名报价
  • 广东高端网站建设报价seo优缺点
  • aspx 网站开发工具郑州网站seo技术
  • 还有哪些网站可以做H5域名检测工具
  • 深圳宝安疫情最新消息今天又封了seo技术教程博客
  • 网站管理助手4.0破解电商是做什么的
  • wordpress网站seo找一个免费域名的网站
  • 不会编程能做网站吗seo外包公司需要什么
  • 韩国服装网站建设推广seo是什么意思
  • 东莞做网站校园推广方案
  • 网站项目建设所需成本企业网站优化软件
  • 北京汉邦未来网站建设有限公司全国培训机构排名前十
  • 工装设计方案网站免费网络推广网站
  • 做网站公司专业seo教学实体培训班
  • 做的比较漂亮的网站安装百度
  • 揭阳网站免费建站seo技术员
  • 做购物网站哪个cms好用搜索引擎优化案例分析
  • 网站集约化建设规划百度网盘下载慢怎么解决
  • 冠辰网站自动点击器
  • 四川省建设厅官方网站百度商家平台
  • 临沂企业自助建站百度关键词排名批量查询
  • 电子政务门户网站建设代码宣传网站怎么做
  • 没有网站怎么快速做cps提高工作效率整改措施