按文档写 regl({...}),但通过 <script> 引入 CDN 版本后控制台报 regl is not defined。
看构建产物开头:
(function(Z,ka){ ... Z.createREGL = ka() })(this, function(){ ... })
UMD 挂到全局的是 window.createREGL。兼容写法:
const factory = window.createREGL || window.regl;
const renderer = factory({ canvas });
如果你用 bundler 的 import regl from 'regl',默认导出就是工厂函数,不受影响。