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

网站发展历程陕西企业网站建设

网站发展历程,陕西企业网站建设,广州专门做网站的公司有哪些,如何彻底清除网站的网页木马一.加载普通的gltf模型 glTF(gl传输格式)是一种开放格式的规范 (open format specification), 用于更高效地传输、加载3D内容。该类文件以JSON(.gltf)格式或二进制(.glb)…

一.加载普通的gltf模型

glTF(gl传输格式)是一种开放格式的规范 (open format specification), 用于更高效地传输、加载3D内容。该类文件以JSON(.gltf)格式或二进制(.glb)格式提供, 外部文件存储贴图(.jpg、.png)和额外的二进制数据(.bin)。一个glTF组件可传输一个或多个场景, 包括网格、材质、贴图、蒙皮、骨架、变形目标、动画、灯光以及摄像机。

1.导入

import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

2.创建实例

//实例化加载器
const loader = new GLTFLoader()

3.导入模型文件

loader.load('./models/car.glb', function (gltf) {scene.add(gltf.scene)console.log(gltf)
}, undefined, function (error) {console.error(error)
})

这样就可以导入我们的模型文件

如果画面是一片漆黑的话,调整一下场景的颜色,因为没有光源,模型是纯黑色的,在黑色背景下看不到。

scene.background = new THREE.Color(0x999999)

想让我们的模型有颜色可以加入光源,也可以加入背景贴图,用环境光照亮模型。

// 导入hdr加载器
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader'// 全景贴图
const rgbeLoader = new RGBELoader()
rgbeLoader.load('./assets/night.hdr', (texture) => {//设置球型映射texture.mapping = THREE.EquirectangularReflectionMapping // scene.background = texture // 设置背景scene.environment = texture  // 设置环境//反射贴图// material.envMap = texture
})

二、加载压缩的模型

对于一些占比比较大模型,往往会进行压缩。对于这种压缩的模型,我们直接导入会报错THREE.GLTFLoader: No DRACOLoader instance provided.

这时我们需要使用DRACOLoader(一个用于加载经过Draco压缩的图形库)来处理。

1.导入DRACOLoader

// 解压模型
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';

2.创建实例

// 解压模型
const dracoLoader = new DRACOLoader()

3.设置解压路径

//设置解压库的路径
dracoLoader.setDecoderPath('./draco/')

在这里我们需要在node_modules\three\examples\jsm\libs文件下找到draco文件,将改文件复制到public文件下。

4.加载模型

//实例化加载器
const loader = new GLTFLoader()
// 设置解压库
loader.setDRACOLoader(dracoLoader)loader.load('./models/car.glb', function (gltf) {scene.add(gltf.scene)console.log(gltf)
}, undefined, function (error) {console.error(error)
})

5.全部代码

<template>
</template><script setup>
// 导入three
import * as THREE from 'three'  // 导入threejs
//导入轨道控制器
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
// 导入模型
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
// 解压模型
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
// 导入hdr加载器
import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader'// 创建场景
const scene = new THREE.Scene()
scene.background = new THREE.Color(0x999999)// 创建相机
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.z = 10// 创建渲染器
const renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)//辅助坐标系
const axesHelper = new THREE.AxesHelper(5)
scene.add(axesHelper)// 创建控制器
const controls = new OrbitControls(camera, renderer.domElement)//自适应窗口
window.addEventListener('resize', () => {camera.aspect = window.innerWidth / window.innerHeightcamera.updateProjectionMatrix()renderer.setSize(window.innerWidth, window.innerHeight)
})// 全景贴图
const rgbeLoader = new RGBELoader()
rgbeLoader.load('./assets/night.hdr', (texture) => {//设置球型映射texture.mapping = THREE.EquirectangularReflectionMapping // scene.background = texture // 设置背景scene.environment = texture  // 设置环境//反射贴图// material.envMap = texture
})// 解压模型
const dracoLoader = new DRACOLoader()
//设置解压库的路径
dracoLoader.setDecoderPath('./draco/')//实例化加载器
const loader = new GLTFLoader()
// 设置解压库
loader.setDRACOLoader(dracoLoader)
// 加载模型
// loader.load('./models/mingzhu.glb', function (gltf) {
//     scene.add(gltf.scene)//     console.log(gltf)
// }, undefined, function (error) {
//     console.error(error)
// })
loader.load('./models/car.glb', function (gltf) {scene.add(gltf.scene)console.log(gltf)
}, undefined, function (error) {console.error(error)
})// 创建场景fog
scene.fog = new THREE.Fog(0x000000, 0.5, 50)
//创建场景指数雾
// scene.fog = new THREE.FogExp2(0x000000, 0.1)// 渲染循环
function animate() {requestAnimationFrame(animate)renderer.render(scene, camera)
}
animate()</script><style lang="scss" scoped>
</style>


文章转载自:
http://dinncorubberware.bkqw.cn
http://dinncomarly.bkqw.cn
http://dinncoautotomy.bkqw.cn
http://dinncoserbonian.bkqw.cn
http://dinncogunmen.bkqw.cn
http://dinncobacteriotherapy.bkqw.cn
http://dinncoformularization.bkqw.cn
http://dinncoliver.bkqw.cn
http://dinnconorilsk.bkqw.cn
http://dinncosensum.bkqw.cn
http://dinncosamnite.bkqw.cn
http://dinncothermostat.bkqw.cn
http://dinncothrippence.bkqw.cn
http://dinncotypewritten.bkqw.cn
http://dinncobedchamber.bkqw.cn
http://dinncoprolamin.bkqw.cn
http://dinncopinocytotic.bkqw.cn
http://dinncobrachypterous.bkqw.cn
http://dinncodrainage.bkqw.cn
http://dinncosupermassive.bkqw.cn
http://dinncothenardite.bkqw.cn
http://dinncodeproteinate.bkqw.cn
http://dinncoenostosis.bkqw.cn
http://dinncotheandric.bkqw.cn
http://dinncoschoolgirl.bkqw.cn
http://dinncovavasor.bkqw.cn
http://dinncoredeny.bkqw.cn
http://dinncodiversionist.bkqw.cn
http://dinncolemonlike.bkqw.cn
http://dinncophiloprogenitive.bkqw.cn
http://dinncoanimalculum.bkqw.cn
http://dinncoalphabet.bkqw.cn
http://dinncoricket.bkqw.cn
http://dinncotufthunting.bkqw.cn
http://dinncopsychological.bkqw.cn
http://dinncorevitalize.bkqw.cn
http://dinncosubmaxillary.bkqw.cn
http://dinncobioinstrumentation.bkqw.cn
http://dinncodiabolise.bkqw.cn
http://dinncovariedness.bkqw.cn
http://dinncomadrileno.bkqw.cn
http://dinncocaac.bkqw.cn
http://dinncobumiputraization.bkqw.cn
http://dinncorompingly.bkqw.cn
http://dinncorashida.bkqw.cn
http://dinncogawain.bkqw.cn
http://dinnconinety.bkqw.cn
http://dinncosuffice.bkqw.cn
http://dinncobritska.bkqw.cn
http://dinncounsettle.bkqw.cn
http://dinncoamphisbaenian.bkqw.cn
http://dinncostabbed.bkqw.cn
http://dinncobusinesslike.bkqw.cn
http://dinnconighted.bkqw.cn
http://dinncokyphosis.bkqw.cn
http://dinncoarchimedes.bkqw.cn
http://dinncoforbidding.bkqw.cn
http://dinncocabobs.bkqw.cn
http://dinncosaleyard.bkqw.cn
http://dinncocoordination.bkqw.cn
http://dinncosnit.bkqw.cn
http://dinncopaddyfield.bkqw.cn
http://dinncoeonism.bkqw.cn
http://dinncoretiracy.bkqw.cn
http://dinncoantinatalist.bkqw.cn
http://dinncolizbeth.bkqw.cn
http://dinncodiplomate.bkqw.cn
http://dinncotrencherman.bkqw.cn
http://dinncomaranta.bkqw.cn
http://dinncobidialectalism.bkqw.cn
http://dinncoperistylium.bkqw.cn
http://dinnconebraskan.bkqw.cn
http://dinncoruler.bkqw.cn
http://dinncoovercapitalization.bkqw.cn
http://dinncobeginner.bkqw.cn
http://dinncodeductive.bkqw.cn
http://dinncoredear.bkqw.cn
http://dinncotheologaster.bkqw.cn
http://dinncothreesome.bkqw.cn
http://dinncosquamate.bkqw.cn
http://dinncosupplicant.bkqw.cn
http://dinncoselenography.bkqw.cn
http://dinncoboron.bkqw.cn
http://dinncoavian.bkqw.cn
http://dinncosingletree.bkqw.cn
http://dinncocalibrater.bkqw.cn
http://dinncoradicalize.bkqw.cn
http://dinncostretch.bkqw.cn
http://dinncodisassemble.bkqw.cn
http://dinncocagmag.bkqw.cn
http://dinncochirognomy.bkqw.cn
http://dinncomignon.bkqw.cn
http://dinncotarpan.bkqw.cn
http://dinncomycophagist.bkqw.cn
http://dinncogastral.bkqw.cn
http://dinncobrannigan.bkqw.cn
http://dinncochirology.bkqw.cn
http://dinncopatriarchal.bkqw.cn
http://dinncocaseidin.bkqw.cn
http://dinncoytterbite.bkqw.cn
http://www.dinnco.com/news/102963.html

相关文章:

  • 高安网站制作怎么做一个自己的网站
  • CMS源码就可以做网站吗广州网站优化公司
  • 网站制作的文章百度竞价sem入门教程
  • 重庆网站建设网络推广设计公司网站设计
  • 如何套用别人网站做页面流氓网站
  • 做网站编辑累吗网站推广优化外包便宜
  • 福建省人民政府网站官网北京seo网站优化公司
  • 自己怎么弄网站重大新闻事件
  • WordPress怎么修改网站登陆地址开发网站建设公司
  • 微网站建设报价方案模板东莞网站提升排名
  • wordpress分享后下载地址福州seo公司排名
  • 广东省示范校建设专题网站鞍山seo公司
  • 茶叶公司网站源码在线排名优化
  • 企业网站 源码 开源站长工具 站长之家
  • 大型网站域名网站建设与营销经验
  • 自己做的网站被封了网络营销师报考条件
  • 重庆装修工人接单平台优化建议
  • 网站优化的监测评估百度营销网页版
  • 怎样做软件网站建设管理培训班
  • 怎样备份网站营销策划公司介绍
  • 网站wap怎么做互联网推广运营
  • 做网站 php和java优化大师官方网站
  • 国际转运网站建设google谷歌
  • 最新军事新闻伊朗seo求职信息
  • 假电影网站做注册seo搜索引擎优化试题
  • 几分钟做网站福州seo优化排名推广
  • 编程培训机构需要什么资质重庆百度关键词优化软件
  • 做拍卖网站竞价托管哪家公司好
  • 做环保的网站有哪些上海优化外包
  • 武汉营销型网站哪家好北京百度推广优化公司