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

GLTFExporter是一个用于将3D场景导出为glTF格式的JavaScript库。

demo案例
在这里插入图片描述

GLTFExporter是一个用于将3D场景导出为glTF格式的JavaScript库。下面我将逐个讲解其入参、出参、属性、方法以及API使用方式。

入参(Input Parameters):

GLTFExporter的主要入参是要导出的场景对象和一些导出选项。具体来说:

  1. scene(场景对象): 这是要导出的3D场景对象,通常是使用Three.js等库构建的场景。
  2. options(导出选项): 这是一个可选的对象,其中包含一些配置项,用于控制导出的行为。例如,您可以指定是否将纹理嵌入到输出文件中、是否包含额外的信息等。

出参(Output):

GLTFExporter的出参是导出的glTF文件。根据您的配置,它可能是一个二进制文件(.glb)或包含多个文件的文件夹(.gltf)。

属性(Properties):

GLTFExporter对象可能具有一些属性,用于配置导出的行为。这些属性通常是一些默认设置,如缩放系数等。

方法(Methods):

GLTFExporter包含了执行导出的方法。

  1. parse(scene, options, onCompleted, onError): 这个方法执行实际的导出过程。它接受场景对象、导出选项以及两个回调函数作为参数。第一个回调函数(onCompleted)在导出成功完成时调用,并接收导出的结果作为参数。第二个回调函数(onError)在导出过程中出现错误时调用。

API方式使用(API Usage):

使用GLTFExporter的基本流程通常如下:

  1. 创建GLTFExporter对象。
  2. 定义导出选项(可选)。
  3. 使用parse方法将场景导出为glTF格式。
  4. 处理导出的结果,如保存到文件或进一步处理。

示例代码:

// 导入GLTFExporter库
import { GLTFExporter } from 'three/examples/jsm/exporters/GLTFExporter.js';// 创建GLTFExporter对象
const exporter = new GLTFExporter();// 定义导出选项(可选)
const options = {binary: true, // 是否以二进制格式输出(默认为false,输出为.gltf文件)includeCustomExtensions: true, // 是否包含自定义扩展信息trs: true, // 是否将几何体的位置、旋转和缩放信息导出animations: [], // 要导出的动画(如果有的话)embedImages: false // 是否将图片嵌入到gltf文件中
};// 使用parse方法导出场景为glTF格式
exporter.parse(scene, options, function (result) {// 处理导出的结果if (result instanceof ArrayBuffer) {// 以二进制格式输出saveArrayBuffer(result, 'scene.glb');} else {// 以JSON格式输出const output = JSON.stringify(result, null, 2);saveString(output, 'scene.gltf');}
}, function (error) {// 处理导出过程中出现的错误console.error('Export error:', error);
});// 保存导出的文件
function saveArrayBuffer(buffer, filename) {// 实现保存二进制文件的逻辑
}function saveString(text, filename) {// 实现保存JSON文件的逻辑
}

所有源码


```html
<!DOCTYPE html>
<html lang="en">
<head><!-- 页面标题 --><title>three.js webgl - exporter - gltf</title><meta charset="utf-8"><!-- 响应式布局 --><meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"><!-- 引入 CSS 文件 --><link type="text/css" rel="stylesheet" href="main.css">
</head>
<body><!-- 信息提示 --><div id="info"><a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - exporter - gltf</div><!-- 导入映射 --><script type="importmap">{"imports": {"three": "../build/three.module.js","three/addons/": "./jsm/"}}</script><!-- 主要 JavaScript 代码 --><script type="module">// 导入所需的模块import * as THREE from 'three';  // 导入 three.js 库import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';  // 导入 GLTFExporter 模块import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';  // 导入 GLTFLoader 模块import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';  // 导入 KTX2Loader 模块import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';  // 导入 MeshoptDecoder 模块import { GUI } from 'three/addons/libs/lil-gui.module.min.js';  // 导入 GUI 模块// 导出 GLTF 文件的函数function exportGLTF( input ) {const gltfExporter = new GLTFExporter();const options = {trs: params.trs,onlyVisible: params.onlyVisible,binary: params.binary,maxTextureSize: params.maxTextureSize};gltfExporter.parse(input,function ( result ) {if ( result instanceof ArrayBuffer ) {saveArrayBuffer( result, 'scene.glb' );} else {const output = JSON.stringify( result, null, 2 );console.log( output );saveString( output, 'scene.gltf' );}},function ( error ) {console.log( 'An error happened during parsing', error );},options);}// 创建保存链接的函数const link = document.createElement( 'a' );link.style.display = 'none';document.body.appendChild( link ); // Firefox 的兼容性解决方案,见 #6594// 保存文件的函数function save( blob, filename ) {link.href = URL.createObjectURL( blob );link.download = filename;link.click();// URL.revokeObjectURL( url ); breaks Firefox...}// 保存字符串到文件的函数function saveString( text, filename ) {save( new Blob( [ text ], { type: 'text/plain' } ), filename );}// 保存 ArrayBuffer 到文件的函数function saveArrayBuffer( buffer, filename ) {save( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );}// 全局变量定义let container;  // 容器let camera, object, object2, material, geometry, scene1, scene2, renderer;  // 相机、物体、材质、几何体、场景、渲染器等let gridHelper, sphere, model, coffeemat;  // 网格帮助器、球体、模型、材质等// 参数定义const params = {trs: false,onlyVisible: true,binary: false,maxTextureSize: 4096,exportScene1: exportScene1,exportScenes: exportScenes,exportSphere: exportSphere,exportModel: exportModel,exportObjects: exportObjects,exportSceneObject: exportSceneObject,exportCompressedObject: exportCompressedObject,};// 初始化函数init();animate();// 初始化函数function init() {container = document.createElement( 'div' );document.body.appendChild( container );// 纹理数据const data = new Uint8ClampedArray( 100 * 100 * 4 );for ( let y = 0; y < 100; y ++ ) {for ( let x = 0; x < 100; x ++ ) {const stride = 4 * ( 100 * y + x );data[ stride ] = Math.round( 255 * y / 99 );data[ stride + 1 ] = Math.round( 255 - 255 * y / 99 );data[ stride + 2 ] = 0;data[ stride + 3 ] = 255;}}// 渐变纹理const gradientTexture = new THREE.DataTexture( data, 100, 100, THREE.RGBAFormat );gradientTexture.minFilter = THREE.LinearFilter;gradientTexture.magFilter = THREE.LinearFilter;gradientTexture.needsUpdate = true;// 第一个场景scene1 = new THREE.Scene();scene1.name = 'Scene1';// 透视相机camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );camera.position.set( 600, 400, 0 );camera.name = 'PerspectiveCamera';scene1.add( camera );// 环境光const ambientLight = new THREE.AmbientLight( 0xcccccc );ambientLight.name = 'AmbientLight';scene1.add( ambientLight );// 平行光const dirLight = new THREE.DirectionalLight( 0xffffff, 3 );dirLight.target.position.set( 0, 0, - 1 );dirLight.add( dirLight.target );dirLight.lookAt( - 1, - 1, 0 );dirLight.name = 'DirectionalLight';scene1.add( dirLight );// 网格辅助器gridHelper = new THREE.GridHelper( 2000, 20, 0xc1c1c1, 0x8d8d8d );gridHelper.position.y = - 50;gridHelper.name = 'Grid';scene1.add( gridHelper );// 坐标轴辅助器const axes = new THREE.AxesHelper( 500 );axes.name = 'AxesHelper';scene1.add( axes );// 基本材质的简单几何体// 二十面体const mapGrid = new THREE.TextureLoader().load( 'textures/uv_grid_opengl.jpg' );mapGrid.wrapS = mapGrid.wrapT = THREE.RepeatWrapping;mapGrid.colorSpace = THREE.SRGBColorSpace;material = new THREE.MeshBasicMaterial( {color: 0xffffff,map: mapGrid} );object = new THREE.Mesh( new THREE.IcosahedronGeometry( 75, 0 ), material );object.position.set( - 200, 0, 200 );object.name = 'Icosahedron';scene1.add( object );// 八面体material = new THREE.MeshBasicMaterial( {color: 0x0000ff,wireframe: true} );object = new THREE.Mesh( new THREE.OctahedronGeometry( 75, 1 ), material );object.position.set( 0, 0, 200 );object.name = 'Octahedron';scene1.add( object );// 四面体material = new THREE.MeshBasicMaterial( {color: 0xff0000,transparent: true,opacity: 0.5} );object = new THREE.Mesh( new THREE.TetrahedronGeometry( 75, 0 ), material );object.position.set( 200, 0, 200 );object.name = 'Tetrahedron';scene1.add( object );// 缓冲几何体原语// 球体material = new THREE.MeshStandardMaterial( {color: 0xffff00,metalness: 0.5,roughness: 1.0,flatShading: true,} );material.map = gradientTexture;material.bumpMap = mapGrid;sphere = new THREE.Mesh( new THREE.SphereGeometry( 70, 10, 10 ), material );sphere.position.set( 0, 0, 0 );sphere.name = 'Sphere';scene1.add( sphere );// 圆柱体material = new THREE.MeshStandardMaterial( {color: 0xff00ff,flatShading: true} );object = new THREE.Mesh( new THREE.CylinderGeometry( 10, 80, 100 ), material );object.position.set( 200, 0, 0 );object.name = 'Cylinder';scene1.add( object );// 环面纹理material = new THREE.MeshStandardMaterial( {color: 0xff0000,roughness: 1} );object = new THREE.Mesh( new THREE.TorusKnotGeometry( 50, 15, 40, 10 ), material );object.position.set( - 200, 0, 0 );object.name = 'Cylinder';scene1.add( object );// 组合体const mapWood = new THREE.TextureLoader().load( 'textures/hardwood2_diffuse.jpg' );material = new THREE.MeshStandardMaterial( { map: mapWood, side: THREE.DoubleSide } );object = new THREE.Mesh( new THREE.BoxGeometry( 40, 100, 100 ), material );object.position.set( - 200, 0, 400 );object.name = 'Cube';scene1.add( object );object2 = new THREE.Mesh( new THREE.BoxGeometry( 40, 40, 40, 2, 2, 2 ), material );object2.position.set( 0, 0, 50 );object2.rotation.set( 0, 45, 0 );object2.name = 'SubCube';object.add( object2 );// 群组const group1 = new THREE.Group();group1.name = 'Group';scene1.add( group1 );const group2 = new THREE.Group();group2.name = 'subGroup';group2.position.set( 0, 50, 0 );group1.add( group2 );object2 = new THREE.Mesh( new THREE.BoxGeometry( 30, 30, 30 ), material );object2.name = 'Cube in group';object2.position.set( 0, 0, 400 );group2.add( object2 );// 线条geometry = new THREE.BufferGeometry();let numPoints = 100;let positions = new Float32Array( numPoints * 3 );for ( let i = 0; i < numPoints; i ++ ) {positions[ i * 3 ] = i;positions[ i * 3 + 1 ] = Math.sin( i / 2 ) * 20;positions[ i * 3 + 2 ] = 0;}geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );object = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );object.position.set( - 50, 0, - 200 );scene1.add( object );// 线环geometry = new THREE.BufferGeometry();numPoints = 5;const radius = 70;positions = new Float32Array( numPoints * 3 );for ( let i = 0; i < numPoints; i ++ ) {const s = i * Math.PI * 2 / numPoints;positions[ i * 3 ] = radius * Math.sin( s );positions[ i * 3 + 1 ] = radius * Math.cos( s );positions[ i * 3 + 2 ] = 0;}geometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );object = new THREE.LineLoop( geometry, new THREE.LineBasicMaterial( { color: 0xffff00 } ) );object.position.set( 0, 0, - 200 );scene1.add( object );// 点numPoints = 100;const pointsArray = new Float32Array( numPoints * 3 );for ( let i = 0; i < numPoints; i ++ ) {pointsArray[ 3 * i ] = - 50 + Math.random() * 100;pointsArray[ 3 * i + 1 ] = Math.random() * 100;pointsArray[ 3 * i + 2 ] = - 50 + Math.random() * 100;}const pointsGeo = new THREE.BufferGeometry();pointsGeo.setAttribute( 'position', new THREE.BufferAttribute( pointsArray, 3 ) );const pointsMaterial = new THREE.PointsMaterial( { color: 0xffff00, size: 5 } );const pointCloud = new THREE.Points( pointsGeo, pointsMaterial );pointCloud.name = 'Points';pointCloud.position.set( - 200, 0, - 200 );scene1.add( pointCloud );// 正交相机const cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 0.1, 10 );scene1.add( cameraOrtho );cameraOrtho.name = 'OrthographicCamera';material = new THREE.MeshLambertMaterial( {color: 0xffff00,side: THREE.DoubleSide} );object = new THREE.Mesh( new THREE.CircleGeometry( 50, 20, 0, Math.PI * 2 ), material );object.position.set( 200, 0, - 400 );scene1.add( object );object = new THREE.Mesh( new THREE.RingGeometry( 10, 50, 20, 5, 0, Math.PI * 2 ), material );object.position.set( 0, 0, - 400 );scene1.add( object );object = new THREE.Mesh( new THREE.CylinderGeometry( 25, 75, 100, 40, 5 ), material );object.position.set( - 200, 0, - 400 );scene1.add( object );//const points = [];for ( let i = 0; i < 50; i ++ ) {points.push( new THREE.Vector2( Math.sin( i * 0.2 ) * Math.sin( i * 0.1 ) * 15 + 50, ( i - 5 ) * 2 ) );}object = new THREE.Mesh( new THREE.LatheGeometry( points, 20 ), material );object.position.set( 200, 0, 400 );scene1.add( object );// 用于测试 `onlyVisible` 选项的隐藏的大红色盒子material = new THREE.MeshBasicMaterial( {color: 0xff0000} );object = new THREE.Mesh( new THREE.BoxGeometry( 200, 200, 200 ), material );object.position.set( 0, 0, 0 );object.name = 'CubeHidden';object.visible = false;scene1.add( object );// 需要 KHR_mesh_quantization 的模型const loader = new GLTFLoader();loader.load( 'models/gltf/ShaderBall.glb', function ( gltf ) {model = gltf.scene;model.scale.setScalar( 50 );model.position.set( 200, - 40, - 200 );scene1.add( model );} );// 需要 KHR_mesh_quantization 的模型material = new THREE.MeshBasicMaterial( {color: 0xffffff,} );object = new THREE.InstancedMesh( new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ), material, 50 );const matrix = new THREE.Matrix4();const color = new THREE.Color();for ( let i = 0; i < 50; i ++ ) {matrix.setPosition( Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 );object.setMatrixAt( i, matrix );object.setColorAt( i, color.setHSL( i / 50, 1, 0.5 ) );}object.position.set( 400, 0, 200 );scene1.add( object );// 第二个 THREE.Scenescene2 = new THREE.Scene();object = new THREE.Mesh( new THREE.BoxGeometry( 100, 100, 100 ), material );object.position.set( 0, 0, 0 );object.name = 'Cube2ndScene';scene2.name = 'Scene2';scene2.add( object );renderer = new THREE.WebGLRenderer( { antialias: true } );renderer.setPixelRatio( window.devicePixelRatio );renderer.setSize( window.innerWidth, window.innerHeight );renderer.toneMapping = THREE.ACESFilmicToneMapping;renderer.toneMappingExposure = 1;container.appendChild( renderer.domElement );window.addEventListener( 'resize', onWindowResize );// 导出压缩的纹理和网格(KTX2 / Draco / Meshopt)const ktx2Loader = new KTX2Loader().setTranscoderPath( 'jsm/libs/basis/' ).detectSupport( renderer );const gltfLoader = new GLTFLoader().setPath( 'models/gltf/' );gltfLoader.setKTX2Loader( ktx2Loader );gltfLoader.setMeshoptDecoder( MeshoptDecoder );gltfLoader.load( 'coffeemat.glb', function ( gltf ) {gltf.scene.position.x = 400;gltf.scene.position.z = - 200;scene1.add( gltf.scene );coffeemat = gltf.scene;} );const gui = new GUI();let h = gui.addFolder( 'Settings' );h.add( params, 'trs' ).name( 'Use TRS' );h.add( params, 'onlyVisible' ).name( 'Only Visible Objects' );h.add( params, 'binary' ).name( 'Binary (GLB)' );h.add( params, 'maxTextureSize', 2, 8192 ).name( 'Max Texture Size' ).step( 1 );h = gui.addFolder( 'Export' );h.add( params, 'exportScene1' ).name( 'Export Scene 1' );h.add( params, 'exportScenes' ).name( 'Export Scene 1 and 2' );h.add( params, 'exportSphere' ).name( 'Export Sphere' );h.add( params, 'exportModel' ).name( 'Export Model' );h.add( params, 'exportObjects' ).name( 'Export Sphere With Grid' );h.add( params, 'exportSceneObject' ).name( 'Export Scene 1 and Object' );h.add( params, 'exportCompressedObject' ).name( 'Export Coffeemat (from compressed data)' );gui.open();}function exportScene1() {exportGLTF( scene1 );}function exportScenes() {exportGLTF( [ scene1, scene2 ] );}function exportSphere() {exportGLTF( sphere );}function exportModel() {exportGLTF( model );}function exportObjects() {exportGLTF( [ sphere, gridHelper ] );}function exportSceneObject() {exportGLTF( [ scene1, gridHelper ] );}function exportCompressedObject() {exportGLTF( [ coffeemat ] );}function onWindowResize() {camera.aspect = window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();renderer.setSize( window.innerWidth, window.innerHeight );}function animate() {requestAnimationFrame( animate );render();}function render() {const timer = Date.now() * 0.0001;camera.position.x = Math.cos( timer ) * 800;camera.position.z = Math.sin( timer ) * 800;camera.lookAt( scene1.position );renderer.render( scene1, camera );}</script></body>
</html>

本内容来源于小豆包,想要更多内容请跳转小豆包 》

相关文章:

GLTFExporter是一个用于将3D场景导出为glTF格式的JavaScript库。

demo案例 GLTFExporter是一个用于将3D场景导出为glTF格式的JavaScript库。下面我将逐个讲解其入参、出参、属性、方法以及API使用方式。 入参&#xff08;Input Parameters&#xff09;: GLTFExporter的主要入参是要导出的场景对象和一些导出选项。具体来说&#xff1a; s…...

消息队列经典应用场景

笔者心中,消息队列,缓存,分库分表是高并发解决方案三剑客。 在职业生涯中,笔者曾经使用过 ActiveMQ 、RabbitMQ 、Kafka 、RocketMQ 这些知名的消息队列 。 这篇文章,笔者结合自己的真实经历,和大家分享消息队列的七种经典应用场景。 1 异步&解耦 笔者曾经负责某电…...

阿里云Salesforce CRM功能差异列表 - Winter‘24

阉割版的阿里云Salesforce由于技术和监管等因素与国际版的Salesforce差距很大&#xff01; 一、Winter‘ 24版差异概况&#xff1a; 1.1. 主要版本&#xff1a; 阿里云上的 Salesforce 提供两个版本&#xff0c;用于生产用途的 CN 版本&#xff08;CN Edition&#xff09;和用…...

WIN10系统下误删除了用户重启无法登录

WIN10系统下误删除了用户重启无法登录 不小心在控制面板的用户组里面删除了当前的用户&#xff0c;在电脑重启后无论怎么输入密码都提示不正确不能登录。 在选择登录的界面同时点击 shift 和重启按钮&#xff1b;在进入的界面选择“疑难问题”&#xff1b;选择进入安全模式&…...

国内ip怎么来回切换:操作指南与注意事项

在数字化时代&#xff0c;互联网已经成为我们日常生活、学习和工作中不可或缺的一部分。然而&#xff0c;随着网络应用的不断深化&#xff0c;用户对于网络环境的稳定性和安全性要求也越来越高。其中&#xff0c;IP地址作为网络中的关键标识&#xff0c;其切换与管理显得尤为重…...

day72Html

常用标签&#xff1a; 分类&#xff1a; 块级标签&#xff1a;独立成行 行级标签&#xff1a;不独立成行&#xff0c;同一行可放多个行级标 注意网页显示时&#xff0c;忽略空白字符,(回车符&#xff0c;空格&#xff0c;tab制表符&#xff09; 一&#xff09;块级标签&#xf…...

C语言内存函数(超详解)

乐观学习&#xff0c;乐观生活&#xff0c;才能不断前进啊&#xff01;&#xff01;&#xff01; 我的主页&#xff1a;optimistic_chen 我的专栏&#xff1a;c语言 点击主页&#xff1a;optimistic_chen和专栏&#xff1a;c语言&#xff0c; 创作不易&#xff0c;大佬们点赞鼓…...

2024年天津体育学院退役大学生士兵专升本专业考试报名安排

天津体育学院2024年退役大学生士兵免试专升本招生专业考试报名安排 一、报名安排 1.报名对象&#xff1a;免于参加天津市文化考试的退役大学生士兵&#xff08;已参加天津市统一报名且资格审核通过&#xff09; 2.报名时间&#xff1a;2024年4月4日9&#xff1a;00-4月5日17…...

linux bypy 定时备份到百度网盘

安装 # 先卸载安装的python-pip sudo yum remove python-pip# 下载get-pip.py文件 wget https://bootstrap.pypa.io/pip/2.7/get-pip.py sudo python get-pip.py直接访问这个地址下载文件,再导入linux更快! https://bootstrap.pypa.io/pip/2.7/get-pip.py 连接 复制上面的连…...

星光/宝骏/缤果/长安 车机CarPlay手机操作破解教程V2.0版本(无需笔记本、无需笔记本、无需笔记本)

之前写了个1.0版本&#xff0c;由于太局限&#xff0c;需要用到笔记本才能操作&#xff0c;很多车友反馈不方便。特此出个手机版教程&#xff0c;简单easy&#xff0c;妈妈再也不用担心我搞不定啦 一、准备工作 先卸载车机上的autokit 或者 智能互联 app&#xff0c;这步很关…...

Spring Web MVC的入门学习(一)

目录 一、什么是 Spring Web MVC 1、MVC 定义 二、学习Spring MVC 1、项目准备 2、建立连接 2.1 RequestMapping 注解的学习 2.2 RequestMapping 使用 3、请求 3.1 传递单个参数 3.2 传递多个参数 3.3 传递对象 3.4 后端参数重命名&#xff08;后端参数映射&#xf…...

如何使用Java语言发票查验接口实现发票真伪查验、票据ocr

随着时代潮流的发展&#xff0c;企业也在寻找更加便捷、高效的办公模式&#xff0c;尤其是针对财务工作人员而言&#xff0c;繁琐的发票录入、查验工作占据了财务人员的大部分时间。对此&#xff0c;翔云提供了发票识别接口、发票查验接口&#xff0c;那么企业应当如何将这些接…...

CAPL实现关闭TCP连接的几种方式以及它们的区别

在讲正文前,我们有必要复习下关闭TCP连接的过程:四次挥手。 假设A和B建立TCP连接并进行数据传输,当A的数据发送完后,需要主动发起断开连接的请求: A发送FIN报文,发起断开连接的请求B收到FIN报文后,首先回复ACK确认报文B把自己的数据发送完,发送FIN报文,发起断开连接的…...

Git--08--Git分支合并操作

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 Git分支合并操作案例流程客户端&#xff1a;GitExtensions操作步骤&#xff1a;A操作步骤&#xff1a;B操作步骤&#xff1a;C操作步骤&#xff1a;D操作步骤&#…...

深度学习训练中的种子设置

文章目录 深度学习训练中的种子设置1. 为什么需要设置随机种子2. 随机种子的设置及使用 深度学习训练中的种子设置 1. 为什么需要设置随机种子 在神经网络训练过程中&#xff0c;经常会通过随机的方式对一些数据进行初始化&#xff1a; 1、随机权重&#xff0c;网络有些部分…...

LLM:函数调用(Function Calling)

1 函数调用 虽然大模型能解决很多问题&#xff0c;但大模型并不能知晓一切。比如&#xff0c;大模型不知道最新消息(GPT-3.5 的知识截至 2021年9月&#xff0c;GPT-4 是 2023 年12月)。另外&#xff0c;大模型没有“真逻辑”。它表现出的逻辑、推理&#xff0c;是训练文本的统计…...

ssm 房屋销售管理系统开发mysql数据库web结构java编程计算机网页源码eclipse项目

一、源码特点 ssm 房屋销售管理系统是一套完善的信息系统&#xff0c;结合springMVC框架完成本系统&#xff0c;对理解JSP java编程开发语言有帮助系统采用SSM框架&#xff08;MVC模式开发&#xff09;&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模…...

MySQL使用ALTER命令创建与修改索引

索引&#xff08;index&#xff09;分类 单列索引&#xff0c;即一个索引只包含单个列&#xff0c;一个表可以有多个单列索引。组合索引&#xff0c;即一个索引包含多个列。 创建索引时&#xff0c;需要确保该索引是应用在 SQL查询语句的条件(一般作为 WHERE 子句的条件)。 实…...

54 npm run serve 和 npm run build 输出的关联和差异

前言 通常来说 我们开发的时候一般会用到的命令是 “npm run serve”, “npm run build” 前者会编译当前项目, 然后将编译之后的结果以 node 的形式启动一个服务, 暴露相关业务资源, 因此 我们可以通过 该服务访问到当前项目 后者是编译当前项目, 然后做一下最小化代码的优…...

iOS —— 初识KVO

iOS —— 初始KVO KVO的基础1. KVO概念2. KVO使用步骤注册KVO监听实现KVO监听销毁KVO监听 3. KVO基本用法4. KVO传值禁止KVO的方法 注意事项&#xff1a; KVO的基础 1. KVO概念 KVO是一种开发模式&#xff0c;它的全称是Key-Value Observing (观察者模式) 是苹果Fundation框架…...

【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型

摘要 拍照搜题系统采用“三层管道&#xff08;多模态 OCR → 语义检索 → 答案渲染&#xff09;、两级检索&#xff08;倒排 BM25 向量 HNSW&#xff09;并以大语言模型兜底”的整体框架&#xff1a; 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后&#xff0c;分别用…...

SciencePlots——绘制论文中的图片

文章目录 安装一、风格二、1 资源 安装 # 安装最新版 pip install githttps://github.com/garrettj403/SciencePlots.git# 安装稳定版 pip install SciencePlots一、风格 简单好用的深度学习论文绘图专用工具包–Science Plot 二、 1 资源 论文绘图神器来了&#xff1a;一行…...

【第二十一章 SDIO接口(SDIO)】

第二十一章 SDIO接口 目录 第二十一章 SDIO接口(SDIO) 1 SDIO 主要功能 2 SDIO 总线拓扑 3 SDIO 功能描述 3.1 SDIO 适配器 3.2 SDIOAHB 接口 4 卡功能描述 4.1 卡识别模式 4.2 卡复位 4.3 操作电压范围确认 4.4 卡识别过程 4.5 写数据块 4.6 读数据块 4.7 数据流…...

ServerTrust 并非唯一

NSURLAuthenticationMethodServerTrust 只是 authenticationMethod 的冰山一角 要理解 NSURLAuthenticationMethodServerTrust, 首先要明白它只是 authenticationMethod 的选项之一, 并非唯一 1 先厘清概念 点说明authenticationMethodURLAuthenticationChallenge.protectionS…...

大模型多显卡多服务器并行计算方法与实践指南

一、分布式训练概述 大规模语言模型的训练通常需要分布式计算技术,以解决单机资源不足的问题。分布式训练主要分为两种模式: 数据并行:将数据分片到不同设备,每个设备拥有完整的模型副本 模型并行:将模型分割到不同设备,每个设备处理部分模型计算 现代大模型训练通常结合…...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台

🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

Unity | AmplifyShaderEditor插件基础(第七集:平面波动shader)

目录 一、&#x1f44b;&#x1f3fb;前言 二、&#x1f608;sinx波动的基本原理 三、&#x1f608;波动起来 1.sinx节点介绍 2.vertexPosition 3.集成Vector3 a.节点Append b.连起来 4.波动起来 a.波动的原理 b.时间节点 c.sinx的处理 四、&#x1f30a;波动优化…...

《C++ 模板》

目录 函数模板 类模板 非类型模板参数 模板特化 函数模板特化 类模板的特化 模板&#xff0c;就像一个模具&#xff0c;里面可以将不同类型的材料做成一个形状&#xff0c;其分为函数模板和类模板。 函数模板 函数模板可以简化函数重载的代码。格式&#xff1a;templa…...

基于PHP的连锁酒店管理系统

有需要请加文章底部Q哦 可远程调试 基于PHP的连锁酒店管理系统 一 介绍 连锁酒店管理系统基于原生PHP开发&#xff0c;数据库mysql&#xff0c;前端bootstrap。系统角色分为用户和管理员。 技术栈 phpmysqlbootstrapphpstudyvscode 二 功能 用户 1 注册/登录/注销 2 个人中…...

tomcat入门

1 tomcat 是什么 apache开发的web服务器可以为java web程序提供运行环境tomcat是一款高效&#xff0c;稳定&#xff0c;易于使用的web服务器tomcathttp服务器Servlet服务器 2 tomcat 目录介绍 -bin #存放tomcat的脚本 -conf #存放tomcat的配置文件 ---catalina.policy #to…...