当前位置:网站首页>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
边栏推荐
- During the year, the first "three consecutive falls" of No. 95 gasoline returned to the "8 Yuan era"“
- 3D高级渲染器:Artlantis studio 2021.2中文版
- Unity 之游戏特效
- 美联储再加息,75基点 鲍威尔“放鸽”,美股狂欢
- Calculation of array serial number of force deduction questions (daily question 7/28)
- How to realize shortcut keys for interface scaling by vscade
- 「PHP基础知识」输出圆周率的近似值
- July 28, 2022 Gu Yujia's study notes
- How to realize multi line annotation in MATLAB
- 1.5 nn. Module neural network (III)
猜你喜欢
Alibaba Sentinel - 工作流程及原理解析
Pp-yoloe details
2022-07-28 顾宇佳 学习笔记
Introduction to JVM foundation I (memory structure)
"PHP Basics" output approximate value of PI
Rongyun IM & RTC capabilities on new sites
Makefile details
带你来浅聊一下,单商户功能模块汇总
04 | background login: login method based on account and password (Part 1)
Redis configuration cache expiration listening event trigger
随机推荐
Producer consumer model of concurrent model
Design of smoke temperature, humidity and formaldehyde monitoring based on single chip microcomputer
mycat读写分离配置
基于单片机烟雾温湿度甲醛监测设计
Example analysis of while, repeat and loop loops in MySQL process control
Configure vscade to realize ROS writing
Self study notes on Apache file management -- mapping folders and configuring Apache virtual machines based on single IP and multi domain names
2022-07-28 顾宇佳 学习笔记
How to deploy sentinel cluster of redis
GJB常见混淆概念
Minesweeping simple version
Military product development process - transition phase
Singleton mode (hungry and lazy)
AI platform, AI midrange architecture
2022-07-28 study notes of group 4 self-cultivation class (every day)
What if MySQL forgets the password
How to solve the time zone problem in MySQL timestamp
Kubernetes-1.24.x feature
Flask的创建的流程day05-06之创建项目
C语言基础知识点汇总