当前位置:网站首页>three.js 第五十四用如何给shader传递结构体数组
three.js 第五十四用如何给shader传递结构体数组
2022-07-29 03:23:00 【DBBH】
如何给shader传递结构体数组
素的webgl里 比如有个
struct A
{
float radius;
};
A a[ 10 ];
传递的时候就是
for(int i = 0; i < 10; i++)
{
uniform1f(getUniformLocation('a[i].radius'), 666.666);
}
这样挨个传递进去就好
three里怎么搞呢
他帮封装了一下 只需要把数组给到value就可以了
struct A
{
vec3 location0;
vec3 location1;
};
A structArray[2];
******************
material.uniforms.structArray.value=[{
location0:new THREE.Vector3(),
location1:new THREE.Vector3(),
},
{
location0:new THREE.Vector3(),
location1:new THREE.Vector3(),
}]
暗坑
如果这里是 structArray[3];
报错
因为three的逻辑是根据shader里的长度,传递数组的内容进去,如果你js侧的数组只有两个元素,第三个的时候是undefined,那么就拉闸
解决方案
你外面把数组数量填满,再多给一个breakCount,for循环到那了就break就好了
大家来交流web3D吧
threejs交流群511163089
边栏推荐
- 照片比例校正工具:DxO ViewPoint 3 直装版
- 原理知识用得上
- MYCAT read / write separation configuration
- 13_ UE4 advanced_ Montage animation realizes attack while walking
- Alibaba Sentinel - workflow and principle analysis
- Suffix automata (SAM) board from Jly
- [freeswitch development practice] media bug obtains call voice flow
- 军品技术文件划分及说明
- [technology 1]
- How to realize multi line annotation in MATLAB
猜你喜欢

数字图像处理 第10章——图像分割

During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“

STC MCU drive 1.8 'TFT SPI screen demonstration example (including data package)

Producer consumer model of concurrent model

Practical guidance for interface automation testing (Part I): what preparations should be made for interface automation

2. Nodejs -- path (\dirname, \filname), URL URL, querystring module, mime module, various paths (relative paths), web page loading (interview questions *)

Wechat's crazy use of glide - life cycle learning
![[freeswitch development practice] unimrcp compilation and installation](/img/ef/b82326152326293bf98e89da28b887.png)
[freeswitch development practice] unimrcp compilation and installation

西瓜书学习第六章---SVM

Introduction to JVM foundation I (memory structure)
随机推荐
Web uploader cannot upload multiple files
Ten thousand words detailed Google play online application standard package format AAB
HDU多校第二场 1011 DOS Card
Watermelon book learning Chapter 6 -- SVM
GJB common confused concepts
What if MySQL forgets the password
C traps and defects Chapter 3 semantic "traps" 3.3 array declaration as parameters
Singleton mode (hungry and lazy)
How to deploy sentinel cluster of redis
Arm architecture and neural network
Multiline text omission
Production deployment zabbix5.0 notes
01-sdram: Code of initialization module
Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
MYCAT read / write separation configuration
Incremental real-time disaster recovery notes
Matlab learning - accumulation of small knowledge points
2022-07-28 study notes of group 4 self-cultivation class (every day)
Makefile details
Reproduce 20 character short domain name bypass and XSS related knowledge points