当前位置:网站首页>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
边栏推荐
- Anti vulnerability · benefit from uncertainty --- management?
- July 28, 2022 Gu Yujia's study notes
- HDU multi School Game 2 1011 DOS card
- How close can QA be to business code QA conducts testability transformation on business code
- web-uploader不能多文件上传
- Shardingsphere's level table practice (III)
- C traps and defects Chapter 3 semantic "traps" 3.6 Boundary Calculation and asymmetric boundary
- xxxxx
- MYSQL入门与进阶(十四)
- Redis之sentinel哨兵集群怎么部署
猜你喜欢

Flask creation process day05-06 creation project

Self study notes on Apache file management -- mapping folders and configuring Apache virtual machines based on single IP and multi domain names

暴力递归到动态规划 01 (机器人移动)

Configure vscade to realize ROS writing
![[freeswitch development practice] unimrcp compilation and installation](/img/ef/b82326152326293bf98e89da28b887.png)
[freeswitch development practice] unimrcp compilation and installation

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

Photo scale correction tool: DxO viewpoint 3 direct mount version

Redis之sentinel哨兵集群怎么部署

带你来浅聊一下,单商户功能模块汇总

Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
随机推荐
简历竟然敢写精通并发编程,那你说说AQS为什么要用双向链表?
Tencent cloud logs in with PEM
Mathematical modeling -- analytic hierarchy process model
Summary of basic knowledge points of C language
HDU多校第二场 1011 DOS Card
Plato Farm在Elephant Swap上铸造的ePLATO是什么?为何具备高溢价?
Self study notes on Apache file management -- mapping folders and configuring Apache virtual machines based on single IP and multi domain names
Typescript learning (I)
Division and description of military technical documents
Summarize the knowledge points of the ten JVM modules. If you don't believe it, you still don't understand it
Military product development process - transition phase
后缀自动机(sam)板子 from jly
带你来浅聊一下,单商户功能模块汇总
美联储再加息,75基点 鲍威尔“放鸽”,美股狂欢
C traps and defects Chapter 3 semantic "traps" 3.8 operators &, |, and!
Alibaba Sentinel - workflow and principle analysis
Regular expression bypasses WAF
Learn more than 4000 words, understand the problem of this pointing in JS, and handwrite to realize call, apply and bind
MYSQL入门与进阶(十二)
Makefile details