JavaScript系列(48)-- 3D渲染引擎实现详解
JavaScript 3D渲染引擎实现详解 🎮
今天,让我们深入探讨JavaScript的3D渲染引擎实现。通过WebGL和现代JavaScript技术,我们可以构建一个功能完整的3D渲染系统。
3D渲染基础概念 🌟
💡 小知识:3D渲染引擎的核心是将三维场景转换为二维图像的过程。这涉及到场景图管理、几何变换、光照计算、材质渲染等多个方面。通过WebGL,我们可以直接访问GPU,实现高性能的3D渲染。
基本实现 📊
// 1. 渲染引擎核心
class Engine3D {constructor(canvas) {this.canvas = canvas;this.gl = canvas.getContext('webgl2');if (!this.gl) {throw new Error('WebGL2 not supported');}this.scene = new Scene();this.camera = new Camera();this.renderer = new Renderer(this.gl);this.initGL();}// 初始化WebGL上下文initGL() {this.gl.enable(this.gl.DEPTH_TEST);this.gl.enable(this.gl.CULL_FACE);this.gl.cullFace(this.gl.BACK);}// 设置视口大小setViewport(width, height) {this.canvas.width = width;this.canvas.height = height;this.gl.viewport(0, 0, width, height);this.camera.updateAspect(width / height);}// 渲染循环render() {this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);this.renderer.render(this.scene, this.camera);}
}// 2. 场景管理
class Scene {constructor() {this.objects = [];this.lights = [];}// 添加对象add(object) {if (object.isLight) {this.lights.push(object);} else {this.objects.push(object);}object.parent = this;}// 移除对象remove(object) {const array = object.isLight ? this.lights : this.objects;const index = array.indexOf(object);if (index !== -1) {array.splice(index, 1);object.parent = null;}}// 遍历场景traverse(callback) {this.objects.forEach(object => {callback(object);if (object.children) {object.traverse(callback);}});}
}// 3. 相机系统
class Camera {constructor() {this.position = new Vector3(0, 0, 5);this.target = new Vector3(0, 0, 0);this.up = new Vector3(0, 1, 0);this.fov = 45;this.aspect = 1;this.near = 0.1;this.far = 1000;this.updateProjectionMatrix();this.updateViewMatrix();}// 更新投影矩阵updateProjectionMatrix() {this.projectionMatrix = Matrix4.perspective(this.fov,this.aspect,this.near,this.far);}// 更新视图矩阵updateViewMatrix() {this.viewMatrix = Matrix4.lookAt(this.position,this.target,this.up);}// 更新相机位置lookAt(target) {this.target.copy(target);this.updateViewMatrix();}
}
高级功能实现 🚀
// 1. 几何体系统
class Geometry {constructor() {this.vertices = [];this.indices = [];this.normals = [];this.uvs = [];this.vertexBuffer = null;this.indexBuffer = null;this.normalBuffer = null;this.uvBuffer = null;}// 设置顶点数据setVertices(vertices) {this.vertices = vertices;this.updateVertexBuffer();}// 设置索引数据setIndices(indices) {this.indices = indices;this.updateIndexBuffer();}// 计算法线computeNormals() {this.normals = new Array(this.vertices.length);for (let i = 0; i < this.indices.length; i += 3) {const i1 = this.indices[i];const i2 = this.indices[i + 1];const i3 = this.indices[i + 2];const v1 = new Vector3().fromArray(this.vertices, i1 * 3);const v2 = new Vector3().fromArray(this.vertices, i2 * 3);const v3 = new Vector3().fromArray(this.vertices, i3 * 3);const normal = Vector3.cross(Vector3.subtract(v2, v1),Vector3.subtract(v3, v1)).normalize();this.normals[i1] = normal;this.normals[i2] = normal;this.normals[i3] = normal;}this.updateNormalBuffer();}
}// 2. 材质系统
class Material {constructor() {this.uniforms = {diffuseColor: new Vector3(1, 1, 1),specularColor: new Vector3(1, 1, 1),shininess: 32.0,opacity: 1.0};this.vertexShader = null;this.fragmentShader = null;this.program = null;}// 编译着色器compile(gl) {const vertexShader = this.compileShader(gl, gl.VERTEX_SHADER, this.vertexShader);const fragmentShader = this.compileShader(gl, gl.FRAGMENT_SHADER, this.fragmentShader);this.program = gl.createProgram();gl.attachShader(this.program, vertexShader);gl.attachShader(this.program, fragmentShader);gl.linkProgram(this.program);if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {throw new Error('Program linking failed: ' + gl.getProgramInfoLog(this.program));}}// 编译单个着色器compileShader(gl, type, source) {const shader = gl.createShader(type);gl.shaderSource(shader, source);gl.compileShader(shader);if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {throw new Error('Shader compilation failed: ' + gl.getShaderInfoLog(shader));}return shader;}
}// 3. 光照系统
class Light {constructor() {this.isLight = true;this.color = new Vector3(1, 1, 1);this.intensity = 1.0;}
}class DirectionalLight extends Light {constructor() {super();this.direction = new Vector3(0, -1, 0);}
}class PointLight extends Light {constructor() {super();this.position = new Vector3();this.distance = 0;this.decay = 1;}
}
实际应用场景 💼
// 1. 3D模型加载器
class ModelLoader {constructor(engine) {this.engine = engine;}// 加载OBJ格式模型async loadOBJ(url) {const response = await fetch(url);const text = await response.text();const vertices = [];const normals = [];const uvs = [];const indices = [];const lines = text.split('\n');for (const line of lines) {const parts = line.trim().split(/\s+/);switch (parts[0]) {case 'v': // 顶点vertices.push(parseFloat(parts[1]),parseFloat(parts[2]),parseFloat(parts[3]));break;case 'vn': // 法线normals.push(parseFloat(parts[1]),parseFloat(parts[2]),parseFloat(parts[3]));break;case 'vt': // 纹理坐标uvs.push(parseFloat(parts[1]),parseFloat(parts[2]));break;case 'f': // 面for (let i = 1; i <= 3; i++) {const vertexData = parts[i].split('/');indices.push(parseInt(vertexData[0]) - 1);}break;}}const geometry = new Geometry();geometry.setVertices(vertices);geometry.setIndices(indices);if (normals.length > 0) {geometry.normals = normals;} else {geometry.computeNormals();}if (uvs.length > 0) {geometry.uvs = uvs;}return geometry;}
}// 2. 动画系统
class AnimationSystem {constructor() {this.animations = new Map();this.currentTime = 0;}// 添加关键帧动画addKeyframeAnimation(name, keyframes) {this.animations.set(name, {keyframes,duration: keyframes[keyframes.length - 1].time});}// 更新动画update(deltaTime) {this.currentTime += deltaTime;for (const [name, animation] of this.animations) {const time = this.currentTime % animation.duration;// 查找当前关键帧let frame1, frame2;for (let i = 0; i < animation.keyframes.length - 1; i++) {if (time >= animation.keyframes[i].time && time < animation.keyframes[i + 1].time) {frame1 = animation.keyframes[i];frame2 = animation.keyframes[i + 1];break;}}if (frame1 && frame2) {const t = (time - frame1.time) / (frame2.time - frame1.time);this.interpolate(frame1, frame2, t);}}}// 插值计算interpolate(frame1, frame2, t) {// 实现关键帧插值return {position: Vector3.lerp(frame1.position, frame2.position, t),rotation: Quaternion.slerp(frame1.rotation, frame2.rotation, t),scale: Vector3.lerp(frame1.scale, frame2.scale, t)};}
}// 3. 物理系统
class PhysicsSystem {constructor() {this.objects = [];this.gravity = new Vector3(0, -9.81, 0);}// 添加物理对象addObject(object, mass = 1) {this.objects.push({object,mass,velocity: new Vector3(),acceleration: new Vector3()});}// 更新物理update(deltaTime) {for (const obj of this.objects) {// 应用重力obj.acceleration.add(this.gravity);// 更新速度obj.velocity.add(Vector3.multiply(obj.acceleration, deltaTime));// 更新位置obj.object.position.add(Vector3.multiply(obj.velocity, deltaTime));// 重置加速度obj.acceleration.set(0, 0, 0);}// 碰撞检测this.detectCollisions();}// 碰撞检测detectCollisions() {for (let i = 0; i < this.objects.length; i++) {for (let j = i + 1; j < this.objects.length; j++) {const obj1 = this.objects[i];const obj2 = this.objects[j];if (this.checkCollision(obj1, obj2)) {this.resolveCollision(obj1, obj2);}}}}
}
性能优化技巧 ⚡
// 1. 渲染优化
class RenderOptimizer {constructor(engine) {this.engine = engine;this.frustumCuller = new FrustumCuller();this.occlusionCuller = new OcclusionCuller();}// 视锥体剔除cullFrustum(scene, camera) {this.frustumCuller.updateFrustum(camera);return scene.objects.filter(object => this.frustumCuller.isVisible(object));}// 遮挡剔除cullOcclusion(objects) {return this.occlusionCuller.getVisibleObjects(objects);}// LOD管理updateLOD(objects, camera) {for (const object of objects) {if (object.lod) {const distance = Vector3.distance(object.position,camera.position);object.updateLOD(distance);}}}
}// 2. 内存管理
class ResourceManager {constructor() {this.geometries = new Map();this.textures = new Map();this.materials = new Map();}// 加载几何体async loadGeometry(url) {if (this.geometries.has(url)) {return this.geometries.get(url);}const loader = new ModelLoader();const geometry = await loader.loadOBJ(url);this.geometries.set(url, geometry);return geometry;}// 加载纹理async loadTexture(url) {if (this.textures.has(url)) {return this.textures.get(url);}return new Promise((resolve, reject) => {const image = new Image();image.onload = () => {const texture = new Texture(image);this.textures.set(url, texture);resolve(texture);};image.onerror = reject;image.src = url;});}// 释放资源unload(url) {if (this.geometries.has(url)) {const geometry = this.geometries.get(url);geometry.dispose();this.geometries.delete(url);}if (this.textures.has(url)) {const texture = this.textures.get(url);texture.dispose();this.textures.delete(url);}}
}// 3. 渲染批处理
class BatchRenderer {constructor(gl) {this.gl = gl;this.batches = new Map();}// 添加到批次addToBatch(object) {const key = this.getBatchKey(object);if (!this.batches.has(key)) {this.batches.set(key, {objects: [],vertices: [],indices: []});}const batch = this.batches.get(key);batch.objects.push(object);// 合并几何数据this.mergeGeometry(batch, object);}// 获取批次键getBatchKey(object) {return `${object.material.id}_${object.geometry.id}`;}// 合并几何数据mergeGeometry(batch, object) {const geometry = object.geometry;const baseVertex = batch.vertices.length / 3;// 添加顶点batch.vertices.push(...geometry.vertices);// 添加索引for (const index of geometry.indices) {batch.indices.push(index + baseVertex);}}// 渲染批次render() {for (const batch of this.batches.values()) {if (batch.objects.length === 0) continue;// 使用第一个对象的材质const material = batch.objects[0].material;material.use(this.gl);// 渲染合并后的几何体this.renderBatch(batch);}}
}
最佳实践建议 💡
- 性能优化策略
// 1. 渲染状态管理
class RenderStateManager {constructor(gl) {this.gl = gl;this.currentState = {program: null,texture: null,blending: false};}// 设置着色器程序useProgram(program) {if (this.currentState.program !== program) {this.gl.useProgram(program);this.currentState.program = program;}}// 设置纹理bindTexture(texture) {if (this.currentState.texture !== texture) {this.gl.bindTexture(this.gl.TEXTURE_2D, texture);this.currentState.texture = texture;}}// 设置混合setBlending(enable) {if (this.currentState.blending !== enable) {if (enable) {this.gl.enable(this.gl.BLEND);} else {this.gl.disable(this.gl.BLEND);}this.currentState.blending = enable;}}
}// 2. 着色器管理
class ShaderManager {constructor() {this.shaders = new Map();}// 注册着色器register(name, vertexSource, fragmentSource) {this.shaders.set(name, {vertex: vertexSource,fragment: fragmentSource});}// 获取着色器get(name) {return this.shaders.get(name);}// 编译着色器compile(gl, name) {const shader = this.get(name);if (!shader) return null;const program = new ShaderProgram(gl);program.compile(shader.vertex, shader.fragment);return program;}
}// 3. 调试工具
class DebugTools {constructor(engine) {this.engine = engine;this.stats = {drawCalls: 0,vertices: 0,triangles: 0};}// 开始性能分析beginProfile() {this.stats.drawCalls = 0;this.stats.vertices = 0;this.stats.triangles = 0;}// 记录绘制调用recordDrawCall(vertices, triangles) {this.stats.drawCalls++;this.stats.vertices += vertices;this.stats.triangles += triangles;}// 获取性能报告getStats() {return {...this.stats,fps: this.calculateFPS()};}// 显示调试信息showDebugInfo() {const stats = this.getStats();console.log(`FPS: ${stats.fps}Draw Calls: ${stats.drawCalls}Vertices: ${stats.vertices}Triangles: ${stats.triangles}`);}
}
结语 📝
JavaScript的3D渲染引擎实现是一个复杂但有趣的主题。通过本文,我们学习了:
- 3D渲染引擎的基本架构和实现
- 场景管理和相机系统
- 几何体、材质和光照系统
- 动画和物理系统
- 性能优化技巧和最佳实践
💡 学习建议:在实现3D渲染引擎时,要注意性能优化和内存管理。合理使用批处理、剔除和LOD等技术可以显著提升渲染性能。同时,要充分利用WebGL的特性,避免不必要的状态切换。
如果你觉得这篇文章有帮助,欢迎点赞收藏,也期待在评论区看到你的想法和建议!👇
终身学习,共同成长。
咱们下一期见
💻
相关文章:
JavaScript系列(48)-- 3D渲染引擎实现详解
JavaScript 3D渲染引擎实现详解 🎮 今天,让我们深入探讨JavaScript的3D渲染引擎实现。通过WebGL和现代JavaScript技术,我们可以构建一个功能完整的3D渲染系统。 3D渲染基础概念 🌟 💡 小知识:3D渲染引擎的…...
Golang并发机制及CSP并发模型
Golang 并发机制及 CSP 并发模型 Golang 是一门为并发而生的语言,其并发机制基于 CSP(Communicating Sequential Processes,通信顺序过程) 模型。CSP 是一种描述并发系统中交互模式的正式语言,强调通过通信来共享内存…...
使用 Docker + Nginx + Certbot 实现自动化管理 SSL 证书
使用 Docker Nginx Certbot 实现自动化管理 SSL 证书 在互联网安全环境日益重要的今天,为站点或应用部署 HTTPS 已经成为一种常态。然而,手动申请并续期证书既繁琐又容易出错。本文将以 Nginx Certbot 为示例,基于 Docker 容器来搭建一个…...
游戏策划的分类
P3游戏策划分类 1.程序2.美术3.策划 程序:一般分为客户端程序和服务器程序 客户端程序一般负责游戏的前端画面表现 服务器程序负责游戏的后端运算 美术:角色原画,角色模型动作,场景原画,场景模型,UI设计&a…...
Edge-TTS在广电系统中的语音合成技术的创新应用
Edge-TTS在广电系统中的语音合成技术的创新应用 作者:本人是一名县级融媒体中心的工程师,多年来一直坚持学习、提升自己。喜欢Python编程、人工智能、网络安全等多领域的技术。 摘要 随着人工智能技术的快速发展,文字转语音(Te…...
python学opencv|读取图像(四十七)使用cv2.bitwise_not()函数实现图像按位取反运算
【0】基础定义 按位与运算:两个等长度二进制数上下对齐,全1取1,其余取0。按位或运算:两个等长度二进制数上下对齐,有1取1,其余取0。 按位取反运算:一个二进制数,0变1,1变0。 【1】…...
一文讲解Java中Object类常用的方法
在Java中,经常提到一个词“万物皆对象”,其中的“万物”指的是Java中的所有类,而这些类都是Object类的子类; Object主要提供了11个方法,大致可以分为六类: 对象比较: public native int has…...
【算法篇·更新中】C++秒入门(附练习用题目)
一.二分 1.二分查找 我们来看这样一道题: 有一个保证有序的数组a,它的长度为n。现在我们需要知道这个序列是否含有x。 数据范围:保证n<1e9 我们看到这道题之后,第一时间想到的就是暴力枚举了,可是我们发现直接枚举…...
面向对象编程 vs 面向过程编程
面向对象编程 vs 面向过程编程:深入解析这两种编程范式的区别 在当今软件开发领域,编程范式的选择对于项目的可维护性和可扩展性至关重要。面向对象编程(OOP)和面向过程编程(POP)是两种根本的编程思想。本…...
【Rust自学】16.2. 使用消息传递来跨线程传递数据
喜欢的话别忘了点赞、收藏加关注哦(加关注即可阅读全文),对接下来的教程有兴趣的可以关注专栏。谢谢喵!(・ω・) 16.2.1. 消息传递 有一种很流行而且能保证安全并发的技术(或者叫机制ÿ…...
【四川乡镇界面】图层shp格式arcgis数据乡镇名称和编码2020年wgs84无偏移内容测评
本文将详细解析标题和描述中提到的IT知识点,主要涉及GIS(Geographic Information System,地理信息系统)技术,以及与之相关的文件格式和坐标系统。 我们要了解的是"shp"格式,这是一种广泛用于存储…...
人物传记之新月篇
相关故事链接(及时更新):Python的那些事第四篇:编程中的智慧之光控制结构-CSDN博客 Python的那些事第五篇:数据结构的艺术与应用-CSDN博客 目录 1. C语言程序:增强版加密与解密工具 2. Python程序&#x…...
TypeScript中的函数:类型安全与高级特性
🤍 前端开发工程师、技术日更博主、已过CET6 🍨 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 🕠 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 🍚 蓝桥云课签约作者、上架课程《Vue.js 和 E…...
DDD 和 TDD
领域驱动设计(DDD) DDD 是一种软件开发方法,强调通过与领域专家的密切合作来构建一个反映业务逻辑的模型。其核心思想是将业务逻辑和技术实现紧密结合,以便更好地解决复杂的业务问题。 DDD 的关键概念: 1. 领域模型 …...
【C语言分支与循环结构详解】
目录 ---------------------------------------begin--------------------------------------- 一、分支结构 1. if语句 2. switch语句 二、循环结构 1. for循环 2. while循环 3. do-while循环 三、嵌套结构 结语 -----------------------------------------end----…...
FaceFusion
文章目录 一、关于 FaceFusion预览 二、安装三、用法 一、关于 FaceFusion FaceFusion 是行业领先的人脸操作平台 github : https://github.com/facefusion/facefusion官方文档:https://docs.facefusion.io/Discord : https://discord.com/invite/facefusion-1141…...
图论——单源最短路的扩展应用
acwing1137.选择最佳路线 本题有两个解决思路 1.建立虚拟源点,连接虚拟源点和 w w w个可作为起点的点,边权为0,这样只需要从虚拟源点开始做一遍最短路算法便可。 2.反向建边,把所有的add(a,b,c)变成add(b,a,c),这样只…...
Linux shell脚本笔记-One
前言 本文主要汇总有关shell脚本常用的知识点,有时候使用忘记某些用法指令,特此汇总方便后续查阅。 一.shell脚本编写的头部定义: 定义的shell脚本头部有多种写法,具体根基实际系统结构处理,如下: #!/bin/sh ÿ…...
【C语言----函数详解】
目录 ----------------------------------------begin-------------------------------------- 引言 一、函数是什么 二、函数的定义和声明 1. 函数的定义 2. 函数的声明 三、函数的调用 四、函数参数传递 五、函数的返回值 六、递归函数 七、函数指针 八、总结 ---…...
QT交叉编译环境搭建(Cmake和qmake)
介绍一共有两种方法(基于qmake和cmake): 1.直接调用虚拟机中的交叉编译工具编译 2.在QT中新建编译套件kits camke和qmake的区别:CMake 和 qmake 都是自动化构建工具,用于简化构建过程,管理编译设置&…...
Zemax 中的屋脊棱镜建模
光学棱镜是一种透明的光学元件,其表面平坦且抛光,可以折射光线。最常见的棱镜类型是三棱镜,它有两个三角形底座和三个矩形或略呈梯形的表面。棱镜通常由玻璃或丙烯酸等材料制成。当光线以一定角度进入棱镜时,它会在穿过棱镜时发生…...
CUDA学习-内存访问
一 访存合并 1.1 说明 本部分内容主要参考: 搞懂 CUDA Shared Memory 上的 bank conflicts 和向量化指令(LDS.128 / float4)的访存特点 - 知乎 1.2 share memory结构 图1.1 share memory结构 放在 shared memory 中的数据是以 4 bytes(即 32 bits)作为 1 个 word,依…...
Nginx 开发总结
文章目录 1. Nginx 基础概念1-1、什么是 Nginx1-2、Nginx 的工作原理1-3、Nginx 的核心特点1-4、Nginx 的常见应用场景1-5、Nginx 与 Apache 的区别1-6、 Nginx 配置的基本结构1-7、Nginx 常见指令 2. Nginx 配置基础2-1、Nginx 配置文件结构2-2、全局配置 (Global Block)2-3、…...
目标跟踪之sort算法(3)
这里写目录标题 1 流程1 预处理2 跟踪 2 代码 参考:sort代码 https://github.com/abewley/sort 1 流程 1 预处理 1.1 获取离线检测数据。1.2 实例化跟踪器。2 跟踪 2.1 轨迹处理。根据上一帧的轨迹预测当前帧的轨迹,剔除到当前轨迹中为空的轨迹得到当前…...
C++/stack_queue
目录 1.stack 1.1stack的介绍 1.2stack的使用 练习题: 1.3stack的模拟实现 2.queue的介绍和使用 2.1queue的介绍 2.2queue的使用 2.3queue的模拟实现 3.priority_queue的介绍和使用 3.1priority_queue的介绍 3.2priority_queue的使用 欢迎 1.stack 1.1stack…...
小程序电商运营内容真实性增强策略及开源链动2+1模式AI智能名片S2B2C商城系统源码的应用探索
摘要:随着互联网技术的不断发展,小程序电商已成为现代商业的重要组成部分。然而,如何在竞争激烈的市场中增强小程序内容的真实性,提高用户信任度,成为电商运营者面临的一大挑战。本文首先探讨了通过图片、视频等方式增…...
「Unity3D」在Unity中使用C#控制显示Android的状态栏
Unity打包的Android默认都是全屏,如果想要在真机上显示状态栏,就需要额外设置,有两种方式: 第一种,使用Android的Java代码去控制,然后以插件的方式放到Unity中,被C#调用。第二种,使…...
基于51单片机和ESP8266(01S)、LCD1602、DS1302、独立按键的WiFi时钟
目录 系列文章目录前言一、效果展示二、原理分析三、各模块代码1、延时2、定时器03、串口通信4、DS13025、LCD16026、独立按键 四、主函数总结 系列文章目录 前言 之前做了一个WiFi定时器时钟,用八位数码管进行显示,但是定时器时钟的精度较低࿰…...
AI 浪潮席卷中国年,开启科技新春新纪元
在这博主提前祝大家蛇年快乐呀!!! 随着人工智能(AI)技术的飞速发展,其影响力已经渗透到社会生活的方方面面。在中国传统节日 —— 春节期间,AI 技术也展现出了巨大的潜力,为中国年带…...
STM32 LED呼吸灯
接线图: 这里将正极接到PA0引脚上,负极接到GND,这样就高电平点亮LED,低电平熄灭。 占空比越大,LED越亮,占空比越小,LED越暗 PWM初始化配置 输出比较函数介绍: 用这四个函数配置输…...
机器学习day4
自定义数据集 使用pytorch框架实现逻辑回归并保存模型,然后保存模型后再加载模型进行预测 import numpy as np import torch import torch.nn as nn import torch.optim as optimizer import matplotlib.pyplot as pltclass1_points np.array([[2.1, 1.8],[1.9, 2…...
《哈佛家训》
《哈佛家训》是一本以教育为主题的书籍,旨在通过一系列富有哲理的故事和案例,传递积极的人生观、价值观和教育理念。虽然它并非直接由哈佛大学官方出版,但其内容深受读者喜爱,尤其是在家庭教育和个人成长领域。 以下是《哈佛家训…...
为什么redis会开小差?Redis 频繁异常的深度剖析与解决方案
文章目录 导读为什么redis会开小差?1.连接数过多2.bigkey3.慢命令操作4.内存策略不合理5.外部数据双写一致性6.保护机制未开启7. 数据集中过期8. CPU饱和9. 持久化阻塞10. 网络问题结论 导读 提起分布式缓存,想必大多数同学脑海中都会浮出redis这个名字…...
window中80端口被占用问题
1,查看报错信息 可以看到在启动项目的时候,8081端口被占用了,导致项目无法启动。 2,查看被占用端口的pid #语法 netstat -aon|findstr :被占用端口#示例 netstat -aon|findstr :8080 3,杀死进程 #语法 taikkill /pid…...
< OS 有关 > 阿里云:轻量应用服务器 的使用 :轻量化 阿里云 vpm 主机
原因: < OS 有关 > 阿里云:轻量应用服务器 的使用 :从新开始 配置 SSH 主机名 DNS Tailscale 更新OS安装包 最主要是 清除阿里云客户端这个性能杀手-CSDN博客 防止 I/O 祸害系统 操作: 查看进程&#x…...
解决报错“The layer xxx has never been called and thus has no defined input shape”
解决报错“The layer xxx has never been called and thus has no defined input shape”(这里写自定义目录标题) 报错显示 最近在跑yolo的代码时遇到这样一个错误,显示“the layer {self.name} has never been called”.这个程序闲置了很久,每次一遇到…...
Microsoft Visual Studio 2022 主题修改(补充)
Microsoft Visual Studio 2022 透明背景修改这方面已经有很多佬介绍过了,今天闲来无事就补充几点细节。 具体的修改可以参考:Microsoft Visual Studio 2022 透明背景修改(快捷方法)_material studio怎么把背景弄成透明-CSDN博客文…...
PyCharm接入DeepSeek实现AI编程
目录 效果演示 创建API key 在PyCharm中下载CodeGPT插件 配置Continue DeepSeek 是一家专注于人工智能技术研发的公司,致力于开发高性能、低成本的 AI 模型。DeepSeek-V3 是 DeepSeek 公司推出的最新一代 AI 模型。其前身是 DeepSeek-V2.5,经过持续的…...
C++ 包装器与绑定器的应用之回调函数的实现
回调函数的实现 在消息队列和网络库的框架中,当接收到消息(报文)时,回调用户自定义的函数对象,把消息(报文)参数传给它,由它决定如何处理。 queue参考文章:C queue(STL queue&…...
一文读懂DeepSeek-R1论文
目录 论文总结 摘要 1. 引言 1.1. 贡献 1.2. 评估结果总结 2. 方法 2.1. 概述 2.2. DeepSeek-R1-Zero:在基础模型上进行强化学习 2.2.1. 强化学习算法 2.2.2. 奖励建模 2.2.3. 训练模板 2.2.4. DeepSeek-R1-Zero 的性能、自我进化过程和顿悟时刻 2.3. …...
文献阅读 250128-Tropical forests are approaching critical temperature thresholds
Tropical forests are approaching critical temperature thresholds 来自 <Tropical forests are approaching critical temperature thresholds | Nature> 热带森林正在接近临界温度阈值 ## Abstract: The critical temperature beyond which photosynthetic machinery…...
【python】python基于机器学习与数据分析的二手手机特性关联与分类预测(源码+数据集)【独一无二】
👉博__主👈:米码收割机 👉技__能👈:C/Python语言 👉专__注👈:专注主流机器人、人工智能等相关领域的开发、测试技术。 python基于机器学习与数据分析的二手手机特性关联与…...
构建可靠的时间序列预测模型:数据泄露检测、前瞻性偏差消除与因果关系验证
在时间序列分析领域中,存在多种可能影响分析结果有效性的技术挑战。其中,数据泄露、前瞻性偏差和因果关系违反是最为常见且具有显著影响的问题。 数据泄露:隐蔽的系统性错误 数据泄露是指在预测时理论上无法获取的信息,通过某种…...
Spring Boot - 数据库集成05 - 集成MongoDB
Spring Boot集成MongoDB 文章目录 Spring Boot集成MongoDB一:使用前的准备1:依赖导入 & 配置2:实体类创建 二:核心 - MongoRepository三:核心 - MongoTemplate1:集合操作2:文档操作(重点)3&…...
计算机网络之运输层
本文章目录结构出自于《王道计算机考研 计算机网络_哔哩哔哩_bilibili》 04 传输层 在网上看到其他人做了相关笔记,就不再多余写了,直接参考着学习吧。 王道考研 计算机网络笔记 第五章:传输层_王道计算机网络传输层_Baret-H的博客-CSDN博…...
DeepSeekMoE:迈向混合专家语言模型的终极专业化
一、结论写在前面 论文提出了MoE语言模型的DeepSeekMoE架构,目的是实现终极的专家专业化(expert specialization)。通过细粒度的专家分割和共享专家隔离,DeepSeekMoE相比主流的MoE架构实现了显著更高的专家专业化和性能。从较小的2B参数规模开始&#x…...
知识库管理驱动企业知识流动与工作协同创新模式
内容概要 知识库管理在现代企业中扮演着至关重要的角色,其价值不仅体现在知识的积累,还在于通过优质的信息流动促进协作与创新。有效的知识库能够将分散的信息整合为有序、易于访问的资源,为员工提供实时支持,进而提升整体工作效…...
二叉树-堆(补充)
二叉树-堆 1.二叉树的基本特性2.堆2.1.堆的基本概念2.2.堆的实现2.2.1.基本结构2.2.2.堆的初始化2.2.3.堆的销毁2.2.4.堆的插入2.2.5.取出堆顶的数据2.2.6.堆的删除2.2.7.堆的判空2.2.8.堆的数据个数2.2.9.交换2.2.10.打印堆数据2.2.11.堆的创建2.2.12.堆排序2.2.13.完整代码 3…...
Java面试题2025-并发编程基础(多线程、锁、阻塞队列)
并发编程 一、线程的基础概念 一、基础概念 1.1 进程与线程A 什么是进程? 进程是指运行中的程序。 比如我们使用钉钉,浏览器,需要启动这个程序,操作系统会给这个程序分配一定的资源(占用内存资源)。 …...
【方法论】ChatGPT与DeepSeek的联合应用,提升工作效率的新解决方案
标题:ChatGPT与DeepSeek的联合应用,提升工作效率的新解决方案 【表格】ChatGPT与DeepSeek联合应用流程 阶段工具主要任务优势备注初稿生成ChatGPT基于用户输入生成初步内容高效、快速生成内容,适应多种主题适合生成长篇文章、报告、分析等验…...