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

网站建设学多久哈尔滨建设工程信息网站

网站建设学多久,哈尔滨建设工程信息网站,免费图纸网站,wordpress 改系统1. 准备工作 将下列文件在three.js的包中找到#xff0c;注意的是我这里使用的是模块化版本的#xff0c;这里不知道模块化的#xff0c;可以先去看一下es6的模块化。 控制器#xff1a; OrbitControls.js 加载器#xff1a;GLTFLoader.js 材质#xff1a; RoomEnvironm… 1.  准备工作 将下列文件在three.js的包中找到注意的是我这里使用的是模块化版本的这里不知道模块化的可以先去看一下es6的模块化。 控制器 OrbitControls.js 加载器GLTFLoader.js 材质 RoomEnvironment.js three.js加载压缩模型 DRACOLoader 模型文件 我这里用的是glb 2.  演示开始 1. 在body中新建一个div用来承载three.js创建canvas标签 2. 把准备好的文件引入注意script标签加上typemodule 代码 bodydiv idWebGL-output/div /bodyscript typemoduleimport * as THREE from ./js/three.module.jsimport { OrbitControls } from ./js/OrbitControls.jsimport { GLTFLoader } from ./js/GLTFLoader.jsimport { RoomEnvironment } from ./js/RoomEnvironment.jsimport { DRACOLoader } from ./js/DRACOLoader.js /script 到这里算是准备工作正式完成 注意引用文件中有些事件依赖于three.module.js这个文件夹的需要去源码当中把路径修改这里举一个例子 3.初始化场景相机渲染器控制器灯光 function init() {clock new THREE.Clock()// 场景相机scene new THREE.Scene()// 添加场景背景const loader11 new THREE.TextureLoader();const bgTexture loader11.load(./model/111.png);scene.background bgTexture;// scene.background new THREE.Color(0xbbbbbb)// 透视相机camera new THREE.PerspectiveCamera(50,window.innerWidth / window.innerHeight,1,2000)camera.position.set(-230, 100, 300)scene.add(camera);// 渲染器renderer new THREE.WebGLRenderer()renderer.setSize(window.innerWidth, window.innerHeight)document.body.appendChild(renderer.domElement)// 地表格// const grid new THREE.GridHelper(500, 100, 0xffffff, 0xffffff)// grid.material.opacity 0.5// grid.material.depthWrite false// grid.material.transparent true// scene.add(grid)// 材质// const environment new RoomEnvironment()// const pmremGenerator new THREE.PMREMGenerator(renderer)// scene.environment pmremGenerator.fromScene(environment).texture// 灯光-环境光scene.add(new THREE.AmbientLight(0x444444))// 灯光-平行光const light new THREE.DirectionalLight(0xffffff)light.position.set(0, 20, 20)light.castShadow truelight.shadow.camera.top 100light.shadow.camera.bottom -100light.shadow.camera.left -100light.shadow.camera.right 100//告诉平行光需要开启阴影投射light.castShadow truescene.add(light)// 鼠标控制器control new OrbitControls(camera, renderer.domElement)// 坐标轴// const axesHelper new THREE.AxesHelper(114)// scene.add(axesHelper)loader()animate()} 4. 加载带动画的glb文件 // glb模型加载function loader() {const loader new GLTFLoader().setPath(./model/).setDRACOLoader(new DRACOLoader().setDecoderPath(js/gltf/))loader.load(bbb.glb, function (gltf) {gltf.scene.scale.set(80, 80, 80)// 动画播放器mixer new THREE.AnimationMixer(gltf.scene)mixer.clipAction(gltf.animations[0]).play()scene.add(gltf.scene)})} 5.animate和render函数 function animate() {requestAnimationFrame(animate)if (mixer) mixer.update(clock.getDelta())control.update() // required if damping enabledrender()}function render() {renderer.render(scene, camera)}6.函数调用 init() animate() 所有代码 !DOCTYPE html html langenheadmeta charsetUTF-8 /meta http-equivX-UA-Compatible contentIEedge /meta nameviewport contentwidthdevice-width, initial-scale1.0 /titleglb文件渲染/title /headbodydiv idWebGL-output/div /bodyscript typemoduleimport * as THREE from ./js/three.module.jsimport { OrbitControls } from ./js/OrbitControls.jsimport { GLTFLoader } from ./js/GLTFLoader.jsimport { RoomEnvironment } from ./js/RoomEnvironment.jsimport { DRACOLoader } from ./js/DRACOLoader.jslet scene, camera, renderer, control, clock, mixerfunction init() {clock new THREE.Clock()// 场景相机scene new THREE.Scene()// 添加场景背景const loader11 new THREE.TextureLoader();const bgTexture loader11.load(./model/111.png);scene.background bgTexture;// scene.background new THREE.Color(0xbbbbbb)// 透视相机camera new THREE.PerspectiveCamera(50,window.innerWidth / window.innerHeight,1,2000)camera.position.set(-230, 100, 300)scene.add(camera);// 渲染器renderer new THREE.WebGLRenderer()renderer.setSize(window.innerWidth, window.innerHeight)document.body.appendChild(renderer.domElement)// 地表格// const grid new THREE.GridHelper(500, 100, 0xffffff, 0xffffff)// grid.material.opacity 0.5// grid.material.depthWrite false// grid.material.transparent true// scene.add(grid)// 材质// const environment new RoomEnvironment()// const pmremGenerator new THREE.PMREMGenerator(renderer)// scene.environment pmremGenerator.fromScene(environment).texture// 灯光-环境光scene.add(new THREE.AmbientLight(0x444444))// 灯光-平行光const light new THREE.DirectionalLight(0xffffff)light.position.set(0, 20, 20)light.castShadow truelight.shadow.camera.top 100light.shadow.camera.bottom -100light.shadow.camera.left -100light.shadow.camera.right 100//告诉平行光需要开启阴影投射light.castShadow truescene.add(light)// 鼠标控制器control new OrbitControls(camera, renderer.domElement)// 坐标轴// const axesHelper new THREE.AxesHelper(114)// scene.add(axesHelper)loader()animate()}// glb模型加载function loader() {const loader new GLTFLoader().setPath(./model/).setDRACOLoader(new DRACOLoader().setDecoderPath(js/gltf/))loader.load(bbb.glb, function (gltf) {gltf.scene.scale.set(80, 80, 80)// 动画播放器mixer new THREE.AnimationMixer(gltf.scene)mixer.clipAction(gltf.animations[0]).play()scene.add(gltf.scene)})}function animate() {requestAnimationFrame(animate)if (mixer) mixer.update(clock.getDelta())control.update() // required if damping enabledrender()}function render() {renderer.render(scene, camera)}init()animate() /script /html 右击运行 结果
http://www.zqtcl.cn/news/641691/

相关文章:

  • 上海工程造价咨询公司余姚网站seo运营
  • 小加工厂做网站wordpress免费主题破解版
  • 网站打开风险怎么解决企业建设网站网站建设公司
  • 随州网站建设公司wordpress怎样上传主题
  • 做外链等于网站更新么台州椒江网站建设
  • 自己搭建一个博客网站网络营销是什么大类
  • 10元网站备案php企业网站开发实训报告
  • 建筑网站设计大全wordpress模板死循环
  • 网站优化排名软件泌阳网站建设
  • 网站反向绑定域名企业网站的建立网络虚拟社区时对于企业
  • 重庆大渡口网站建设解决方案梓潼 网站建设 有限公司
  • 高端平面网站东营住房和城乡建设厅网站
  • 品牌网站建设e小蝌蚪易时代网站
  • 做搜狗手机网站点击软网站建设有哪些种类
  • 想自学做网站太原要做网站的公司
  • 站内seo优化淘宝网站推广策划方案
  • 福建建设执业注册中心网站网址格式怎么写
  • 网站开发外包公司坑襄垣城乡建设管理局的网站
  • 网络公司怎么做网站常州新北区网站建设
  • 扬州专业外贸网站建设推广做详情页上什么网站找素材
  • 北京做网站设计招聘深圳市住房和建设局官网平台
  • 冻品网站建设网站头图设计
  • 手机网站分辨率做多大h5微网站建设多少钱
  • 网站制作软件下载公司怎么注册邮箱帐号
  • 做婚纱网站的图片园林设计
  • 濮阳公司建站淮北城市住建网
  • 建设银行网站打不开 显示停止工作专门做地图的网站
  • 有没有人一起做网站app网站建设方案
  • 洛阳网站建设兼职企业网站建设文案
  • 动漫制作贵州seo策略