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

怎样在建设部网站查资质证书文化产品电商网站建设规划

怎样在建设部网站查资质证书,文化产品电商网站建设规划,怎么做微信小程序商城,网站app免费制作👨‍⚕️ 主页: gis分享者 👨‍⚕️ 感谢各位大佬 点赞👍 收藏⭐ 留言📝 加关注✅! 👨‍⚕️ 收录于专栏:threejs gis工程师 文章目录 一、🍀前言1.1 ☘️Texture 贴图 二、&#x1…

👨‍⚕️ 主页: gis分享者
👨‍⚕️ 感谢各位大佬 点赞👍 收藏⭐ 留言📝 加关注✅!
👨‍⚕️ 收录于专栏:threejs gis工程师


文章目录

  • 一、🍀前言
    • 1.1 ☘️Texture 贴图
  • 二、🍀使用canvas更新纹理
    • 1. ☘️实现思路
    • 2. ☘️代码样例


一、🍀前言

本文详细介绍如何基于threejs在三维场景中使用canvas更新纹理,亲测可用。希望能帮助到您。一起学习,加油!加油!

1.1 ☘️Texture 贴图

创建一个纹理贴图,将其应用到一个表面,或者作为反射/折射贴图。
构造函数:
Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding )
常用属性:
在这里插入图片描述
方法:
在这里插入图片描述

二、🍀使用canvas更新纹理

1. ☘️实现思路

  • 1、初始化renderer渲染器
  • 2、初始化Scene三维场景scene,创建THREE.CubeTextureLoader立方体纹理加载器cubeTextureLoader,加载cubeTextureLoader的六个方位的图片获取纹理对象cubeTexture,scene背景background设置为cubeTexture。
  • 3、创建id为‘surface’的canvas页面元素火焰然后动画,并执行。具体实现参考下面代码样例。
  • 4、初始化camera相机,定义相机位置 camera.position.set
  • 5、初始化THREE.AmbientLight环境光源,scene场景加入环境光源,初始化THREE.DirectionalLight平行光源,设置平行光源位置,设置平行光源投影,scene添加平行光源。
  • 6、加载几何模型:创建THREE.AxesHelper坐标辅助工具helper,scene场景中加入helper。创建THREE.BoxGeometry立方体几何体geometry,创建THREE.MeshBasicMaterial基础材质material,material设置map贴图(为步骤3canvas元素)、水平和垂直贴图包裹,传入geometry和material创建THREE.Mesh网格对象,scene中加入创建的网格对象。
  • 7、加入controls控制,加入stats监控器,监控帧数信息。

2. ☘️代码样例

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>learn60(使用CANVAS更新纹理)</title><script src="lib/threejs/127/three.js-master/build/three.js"></script><script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script><script src="lib/threejs/127/three.js-master/examples/js/controls/OrbitControls.js"></script><script src="lib/threejs/127/three.js-master/examples/js/libs/stats.min.js"></script><script src="lib/threejs/127/three.js-master/examples/js/libs/dat.gui.min.js"></script><script src="lib/js/Detector.js"></script>
</head>
<style type="text/css">html, body {margin: 0;height: 100%;}canvas {display: block;}#surface {position: fixed;left: 0;bottom: 0;}
</style>
<body onload="draw()">
<canvas id="surface"></canvas>
</body>
<script>var renderer, camera, scene, gui, light, stats, controls//引入一个canvas动画function initCanvas() {$(document).ready(function () {// Set canvas drawing surfacevar space = document.getElementById("surface")var surface = space.getContext("2d")surface.scale(1, 1)// Set Particlesvar particles = []var particle_count = 150for (var i = 0; i < particle_count; i++) {particles.push(new particle())}var time = 0// Set wrapper and canvas items sizevar canvasWidth = 480var canvasHeight = 480$(".wrapper").css({width: canvasWidth, height: canvasHeight})$("#surface").css({width: canvasWidth, height: canvasHeight})// shim layer with setTimeout fallback from Paul Irishwindow.requestAnimFrame = (function () {return window.requestAnimationFrame ||window.webkitRequestAnimationFrame ||window.mozRequestAnimationFrame ||function (callback) {window.setTimeout(callback, 6000 / 60)}})()function particle() {this.speed = {x: -1 + Math.random() * 2, y: -5 + Math.random() * 5}canvasWidth = (document.getElementById("surface").width)canvasHeight = (document.getElementById("surface").height)this.location = {x: canvasWidth / 2, y: (canvasHeight / 2) + 35}this.radius = .5 + Math.random() * 1this.life = 10 + Math.random() * 10this.death = this.lifethis.r = 255this.g = Math.round(Math.random() * 155)this.b = 0}function ParticleAnimation() {surface.globalCompositeOperation = "source-over"surface.fillStyle = "black"surface.fillRect(0, 0, canvasWidth, canvasHeight)surface.globalCompositeOperation = "lighter"for (var i = 0; i < particles.length; i++) {var p = particles[i]surface.beginPath()p.opacity = Math.round(p.death / p.life * 100) / 100var gradient = surface.createRadialGradient(p.location.x, p.location.y, 0, p.location.x, p.location.y, p.radius)gradient.addColorStop(0, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")")gradient.addColorStop(0.5, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")")gradient.addColorStop(1, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", 0)")surface.fillStyle = gradientsurface.arc(p.location.x, p.location.y, p.radius, Math.PI * 2, false)surface.fill()p.death--p.radius++p.location.x += (p.speed.x)p.location.y += (p.speed.y)//regenerate particlesif (p.death < 0 || p.radius < 0) {//a brand new particle replacing the dead oneparticles[i] = new particle()}}requestAnimFrame(ParticleAnimation)}ParticleAnimation()})}var initRender = () => {renderer = new THREE.WebGLRenderer({antialias: true})renderer.setClearColor(0xeeeeee)renderer.setSize(window.innerWidth, window.innerHeight)renderer.shadowMap.enabled = truerenderer.setPixelRatio(window.devicePixelRatio)document.body.appendChild(renderer.domElement)}var initCamera = () => {camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000)camera.position.set(0, 0, 15)}var initScene = () => {var cubeTextureLoader = new THREE.CubeTextureLoader()cubeTextureLoader.setPath('data/texture/skybox/space/')var cubeTexture = cubeTextureLoader.load(['right.jpg', 'left.jpg','top.jpg', 'bottom.jpg','front.jpg', 'back.jpg'])scene = new THREE.Scene()scene.background = cubeTexture}var initLight = () => {scene.add(new THREE.AmbientLight(0x444444))light = new THREE.DirectionalLight(0xffffff)light.position.set(0, 20, 20)light.castShadow = truescene.add(light)}var initModel = () => {var helper = new THREE.AxesHelper(50)scene.add(helper)var geometry = new THREE.BoxBufferGeometry(5, 5, 5)var canvas = $('#surface')[0]var texture = new THREE.Texture(canvas)material = new THREE.MeshBasicMaterial({map: texture})scene.add(new THREE.Mesh(geometry, material))}var initStats = () => {stats = new Stats()document.body.appendChild(stats.dom)}var initControls = () => {controls = new THREE.OrbitControls(camera, renderer.domElement)controls.enableDamping = true}var render = () => {material.map.needsUpdate = truerenderer.render(scene, camera)}var onWindowResize = () => {camera.aspect = window.innerWidth / window.innerHeightcamera.updateProjectionMatrix()renderer.setSize(window.innerWidth, window.innerHeight)}var animate = () => {render()stats.update()controls.update()requestAnimationFrame(animate)}var draw = () => {if(!Detector.webgl)Detector.addGetWebGLMessage()initCanvas()initRender()initScene()initCamera()initLight()initModel()initStats()initControls()animate()window.onresize = onWindowResize}
</script>
</html>

效果如下:
在这里插入图片描述

http://www.yayakq.cn/news/887826/

相关文章:

  • 面向网站开发的相关知识网站设计 北京店
  • 视频网站公共关系怎么做西安网页设计教育培训机构
  • 版式设计图片网站加alt属性对优化有影响吗
  • 安阳网站建设哪家好商洛网站建设求职简历
  • 青岛专业网站建设定制网站将要准备建设的内容有哪些
  • 怎么建立自己的个人网站做孝道的网站的目的
  • 旅行网站开发意义设计精美的网站
  • 网站建设公司968一站式服务图片
  • 买外链网站不懂的做网站
  • 做财经比较好的网站有哪些网站关键词快照优化
  • 网站集约建设后网站域名规范那个网站可以做域名跳转的
  • 网站赢利广州做网站推广的公司
  • 科技股龙头冀州网站优化
  • 查看网站是什么空间网站优化公司哪家服务好
  • 百度上网站怎么做福建建设人才网站
  • 如何做产品销售网站购物网站设计思路
  • 如何查询网站开发语言网站开发 工作职责
  • 要学做游戏上什么网站学好请人做网站我要提供什么需求
  • 做网站 聊城商务局网站溪江农贸市场建设
  • 网站模板手机整站seoseo优化
  • 住建部城乡建设网站汽车网站 源码
  • dede网站入侵教程做营销型网站多少钱
  • 怎么查一个网站是否备案做网站打开图片慢
  • 建设工程竞标网站手机百度app
  • 网站软文推广范文福田祥菱
  • 福建省建设执业资格注册管理中心网站公司商业网站怎么做
  • 电商网站前端源码深圳十大外贸公司排名
  • 辽阳建设网站找哪家手机网址怎么输入
  • 杭州网站建设怎么样电脑上怎么创建wordpress
  • 手机个别网页打不开天津关键词优化网站