惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 热门话题
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Project Zero
Project Zero
V
Vulnerabilities – Threatpost
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
C
Cisco Blogs
A
Arctic Wolf
月光博客
月光博客
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
量子位
小众软件
小众软件
Latest news
Latest news
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
N
Netflix TechBlog - Medium
K
Kaspersky official blog
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
Y
Y Combinator Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Schneier on Security
D
Docker
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
GbyAI
GbyAI
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
H
Help Net Security
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tenable Blog
B
Blog
Know Your Adversary
Know Your Adversary
IT之家
IT之家

博客园 - 莫小龙

uniapp之plus.downloader.createDownload下载文件传参 谷歌之将网页保存为图片 elementui之table中相同数据的单元格合并 krpano之使用教程 threejs之灯光不跟随OrbitControls控制器旋转 threejs之将张纹理图片组成材质组 canvas之修改Base64图片中不透明部分的颜色 threejs之利用shape通过线绘制面和体 threejs之添加渐变背景 threejs之创建发光墙体 paperjs之fitBounds适应区域前后屏幕坐标和输入坐标的转换 arcmap之通过点数据获取等值线 uniapp之安卓APP打开百度地图、高德地图APP openlayer之添加带箭头的线 geoserver之图片图标样式 SHP转WKT文件工具 openlayers之geoserver的wms图层mysql数据源数据修改后更新问题 通过日照时数计算每天RAD(太阳辐射)值 Uniapp之安卓签名证书(.keystore)生成
threejs之将PlaneGeometry转换为BufferGeometry
莫小龙 · 2025-06-20 · via 博客园 - 莫小龙

threejs之将PlaneGeometry转换为BufferGeometry

用途:将PlaneGeometry转换为BufferGeometry后,对BufferGeometry的标记面数组操作,达成使用边界切割PlaneGeometry

            const material = new THREE.MeshBasicMaterial({
                color: 0x00ff00,
                side: THREE.DoubleSide,
                transparent: true,
                opacity: 0.5,
                wireframe: true
            });
            // 创建PlaneGeometry
            let widthLength = 4
            let heightLength = 5
            const geometry1 = new THREE.PlaneGeometry(
                30,
                30,
                widthLength,
                heightLength,
            );
            // const mesh1 = new THREE.Mesh(geometry1, material);
            // scene.add(mesh1);
            // 数据处理  生成BufferGeometry的点位标记面数组
            let arr = []
            for (let i = 0; i < heightLength; i++) {
                for (let j = 0; j < widthLength; j++) {
                    arr.push((i*(widthLength+1)+j))
                    arr.push((i*(widthLength+1)+j+1))
                    arr.push((i+1)*(widthLength+1)+j)

                    arr.push((i*(widthLength+1)+j+1))
                    arr.push((i+1)*(widthLength+1)+j)
                    arr.push((i+1)*(widthLength+1)+j+1)
                }
            }
            // 创建BufferGeometry
            const geometry = new THREE.BufferGeometry();
            // 将PlaneGeometry的点直接放入BufferGeometry
            // const vertices = new Float32Array([-1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0,2,2,2,2,2,0,2,0,0]);
            const vertices = new Float32Array(geometry1.attributes.position.array);
            const verticesBuffer = new THREE.BufferAttribute(vertices, 3);
            geometry.setAttribute('position', verticesBuffer);
            // 将点位标记面数组赋值
            // const indices = new Uint16Array([0, 1, 2, 0, 2, 3]);
            const indices = new Uint16Array(arr);
            geometry.setIndex(new THREE.BufferAttribute(indices, 1));
            const mesh = new THREE.Mesh(geometry, material);
            scene.add(mesh);

。。。 钻研不易,转载请注明出处