当前位置:网站首页>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
边栏推荐
- 基于单片机烟雾温湿度甲醛监测设计
- [open the door to the new world] see how the old bird of testing plays API testing between applause
- 反脆弱·从不确定性中获益---管理?
- Score addition and subtraction of force deduction and brushing questions (one question per day 7/27)
- MySQL流程控制之while、repeat、loop循环实例分析
- 1.4 nn. Module neural network (II)
- Kubernetes-1.24.x feature
- 13_ UE4 advanced_ Montage animation realizes attack while walking
- ShardingSphere之水平分表实战(三)
- Singleton and invariant modes of concurrent mode
猜你喜欢

4000 多字学懂弄通 js 中 this 指向问题,顺便手写实现 call、apply 和 bind

【C】数组

Example analysis of while, repeat and loop loops in MySQL process control

3D advanced renderer: artlandis studio 2021.2 Chinese version

接口自动化测试实践指导(上):接口自动化需要做哪些准备工作

Whole process record of yolov3 target detection

How dare you write a resume that is proficient in concurrent programming? Why do you use a two-way linked list in AQS?

ROS-Errror:Did you forget to specify generate_ messages(DEPENDENCIES ...)?

Does domestic ERP have a chance to beat sap?

Unity game special effects
随机推荐
How close can QA be to business code Direct exposure of defects through codediff
MYSQL入门与进阶(十二)
Server operation management system
1.4 nn. Module neural network (II)
MYCAT read / write separation configuration
Matlab learning -- structured programs and user-defined functions
2022-07-28 顾宇佳 学习笔记
Tonight at 7:30 | is the AI world in the eyes of Lianjie, Jiangmen, Baidu and country garden venture capital continue to be advanced or return to the essence of business
Multiline text omission
Mathematical modeling -- analytic hierarchy process model
Digital image processing Chapter 10 - image segmentation
mycat读写分离配置
C traps and defects Chapter 3 semantic "traps" 3.2 pointers to non arrays
Alibaba Sentinel - workflow and principle analysis
力扣刷题之分数加减运算(每日一题7/27)
3D advanced renderer: artlandis studio 2021.2 Chinese version
Leetcode 1331 array sequence number conversion [map] the leetcode path of heroding
C traps and defects Chapter 2 syntax "traps" 2.6 problems caused by "hanging" else
Tencent cloud logs in with PEM
Shell script summary