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

网站维护模板免费网站空间怎么做网站

网站维护模板,免费网站空间怎么做网站,wordpress去除index.php,上海网站设计培训班由于工作原因#xff0c;近一年没怎么写代码#xff0c;有朋友问你做过3D模型展示吗#xff0c;之前都是做以vue为框架做定制业务#xff0c;这次抽时间试试3d模型展示。 软件功能 使用ThreeJS框架实现加载GLB模型#xff0c;并添加动画效果#xff0c;实现3d展示模型。… 由于工作原因近一年没怎么写代码有朋友问你做过3D模型展示吗之前都是做以vue为框架做定制业务这次抽时间试试3d模型展示。 软件功能 使用ThreeJS框架实现加载GLB模型并添加动画效果实现3d展示模型。使用GLTFLoader加载模型并使用OrbitControls实现鼠标拖拽旋转滚轮缩放点击模型显示信息等功能。参考代码 软件架构 工程化 使用webpack做工程化安装webpack webpack-cli webpack-dev-server html-webpack-plugin babel/core babel/preset-env babel-loader 编写webpack.config.js const path require(path); const HtmlWebpackPlugin require(html-webpack-plugin);module.exports {entry: ./src/app.js, // 入口文件路径output: {filename: bundle.js, // 输出文件名path: path.resolve(__dirname, dist), // 输出目录clean: true, // 自动清理输出目录},module: {rules: [{test: /\.js$/,exclude: /node_modules/,use: {loader: babel-loader,},},{test: /\.(glb|gltf)$/,type: asset/resource, // 确保可以加载GLB等资源文件},],},plugins: [new HtmlWebpackPlugin({template: ./src/index.html, // 模板文件路径filename: index.html, // 输出的 HTML 文件名}),],resolve: {extensions: [.js, .json], // 解析模块时尝试这些扩展名alias: {three: path.resolve(__dirname, node_modules/three), // 如果需要可以指定Three.js的位置},},devServer: {static: {directory: path.join(__dirname, assets), // 静态文件夹},open: true, // 启动时打开浏览器hot: true, // 热更新},mode: development, // 开发模式 };主程序代码 import * as THREE from three; import { GLTFLoader } from three/examples/jsm/loaders/GLTFLoader.js; import { OrbitControls } from three/examples/jsm/controls/OrbitControls.js;// 创建场景、相机、渲染器等... console.log(THREE version:, THREE.REVISION);// 创建场景 const scene new THREE.Scene(); const camera new THREE.PerspectiveCamera(75,window.innerWidth / window.innerHeight,0.1,1000 ); const renderer new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement);// 设置场景背景色 scene.background new THREE.Color(0xcccccc);// 添加环境灯光 const ambientLight new THREE.AmbientLight(0x404040, 0.2); scene.add(ambientLight);// 场景中增加四个点光源 const pointLight1 new THREE.PointLight(0xffffff, 0.3, 100); pointLight1.position.set(5, 5, 5); scene.add(pointLight1);const pointLight2 new THREE.PointLight(0xffffff, 0.3, 100); pointLight2.position.set(-5, -5, -5); scene.add(pointLight2);const pointLight3 new THREE.PointLight(0xffffff, 0.3, 100); pointLight3.position.set(-5, 5, 5); scene.add(pointLight3);const pointLight4 new THREE.PointLight(0xffffff, 0.3, 100); pointLight4.position.set(5, -5, -5); scene.add(pointLight4);// 场景中增加四个平行光 const light1 new THREE.DirectionalLight(0x001dff, 1); light1.position.set(5, 5, 5).normalize(); scene.add(light1); const light2 new THREE.DirectionalLight(0xffe8e8, 1); light2.position.set(5, -5, 5).normalize(); scene.add(light2); const light3 new THREE.DirectionalLight(0xfff8ef, 1); light3.position.set(-5, 5, 5).normalize(); scene.add(light3); const light4 new THREE.DirectionalLight(0xffffff, 1); light4.position.set(5, 5, -5).normalize(); scene.add(light4);// 添加坐标轴辅助器 // const axesHelper new THREE.AxesHelper(2) // scene.add(axesHelper)let model; // 用于存储加载的模型 // 加载GLB模型 const loader new GLTFLoader(); loader.load(test2.glb, // 确保路径正确function (gltf) {model gltf.scene; // 将加载的模型赋值给变量scene.add(gltf.scene);// 将模型的中心点设置为控制器中心点const box new THREE.Box3().setFromObject(model);if (box ! null) {const center new THREE.Vector3();box.getCenter(center);// 将 OrbitControls 的 target 设置为模型的中心controls.target.copy(center);}// 如果需要立即生效可以调用 update 方法controls.update();},undefined,function (error) {console.error(error);} );// 创建 OrbitControls 实例控制场景中的模型 const controls new OrbitControls(camera, renderer.domElement); controls.enableDamping true; controls.dampingFactor 0.25; controls.enableZoom true;controls.autoRotate true controls.autoRotateSpeed 3 controls.target new THREE.Vector3(0, 0, 0)// 调整相机位置以适应模型 camera.position.z 2;// let time 0; function animate() {requestAnimationFrame(animate);if (model) {// 更新时间变量// time 0.01;// 让模型旋转// model.rotation.x 0.01;// model.rotation.y 0.01;// 让模型上下浮动// model.position.y Math.sin(time) * 0.2;}renderer.render(scene, camera);controls.update() }animate();// 监听窗口大小变化 window.addEventListener(resize, () {camera.aspect window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();renderer.setSize(window.innerWidth, window.innerHeight); });
http://www.hkea.cn/news/14364281/

相关文章:

  • 笔记本做网站服务器跨境电商自己做网站卖衣服
  • 7天精通网站建设实录简介242烟台优化公司
  • 网站建设分为哪三部分企业erp生产管理系统
  • 贵阳网站开发人员工资如何做网站维护 找关键词
  • 谷歌网站收录提交入口建筑工程集团有限公司
  • 生产建设网站基坑开挖深度网线制作公开课
  • 荷兰网站后缀wordpress慢死了
  • uemo网站源码网站开发国内外研究状况
  • 惠州网站建设哪家好国外优秀设计公司网站
  • 网站内容更新慢原因自己做网站 发布视频
  • 开发外包网站网站建设制作设计seo优化湖北
  • 哪个网站做外链视频好网页设计师工作室
  • 模板网站seo模块建筑
  • 能在家做的兼职的网站本人有五金件外发加工
  • 江苏建站系统青岛网站备案
  • 网站开发中设置会员等级网站开发项目答辩主持词
  • 东莞市公司网站建设服务机构官网建设费用入什么科目
  • 天猫网站的建设建e网客厅效果图
  • 广州建设网站的公司简介wordpress登陆图标修改
  • 网站用花生壳nas做存储怎样用自己电脑做网站
  • 网站推广只能使用在线手段进行。网站建设0doit
  • 寻花问柳一家专注做男人喜爱的网站企业网站建设怎么做
  • 图片1600px做网站wordpress 函数手册
  • 百度网站入口网络营销工具分析
  • 大丰区城乡和住房建设局网站烟台seo
  • 昆明高端网站设计企业注册名字查询
  • 网站建设的基础是什么意思网站登录注册页面模板下载
  • lanyun网站开发wordpress老版编辑
  • 青岛网站关键词推广一个电商网站开发需要多久
  • 做网站卖装备wordpress wechat pay