google-chrome - 三 js Texture Loader 无法加载纹理
问题描述
我正在尝试使用三个 js 加载图像(我想要与此项目相同的结果:https ://github.com/brunoimbrizi/interactive-particles )。但是当我运行项目时,代码不想加载图像并直接显示错误。这是我的代码:
init(src) {
const loader = new THREE.TextureLoader();
loader.load('images/sample-01.png',
(texture) => {
console.log('YOOOO');
this.texture = texture;
this.texture.minFilter = THREE.LinearFilter;
this.texture.magFilter = THREE.LinearFilter;
this.texture.format = THREE.RGBFormat;
this.width = texture.image.width;
this.height = texture.image.height;
this.initPoints(true);
this.initHitArea();
this.initTouch();
this.resize();
this.show();
},
function (err) {
console.log('LOADING');
},
// onError callback
function (err) {
console.error('An error happened.', err);
});
}
我确信图像路径是正确的,所以不幸的是我对这个问题有任何想法。这是错误:
我在 Vue js 上运行这个项目,使用 npm run dev 所以我在服务器上。
我希望有人能够帮助我,我正在为此工作3天......
谢谢 !
解决方案
尝试在没有任何外围方法调用的情况下分配加载的纹理。像这样简单的东西:
const loader = new THREE.TextureLoader();
const texMap = loader.load('images/sample-01.png');
new MeshBasicMaterial({map: texMap});
我很确定如果图像 URL 是正确的,并且上面的简单测试有效,那么问题来自这些额外的方法之一:
this.initPoints(true);
this.initHitArea();
this.initTouch();
this.resize();
this.show();
推荐阅读
- c# - 使用 SqlDatRecord 结果列表插入行 数据库中的外键错误
- gcc - 未定义对 `__isoc99_sscanf@GLIBC_2.7' 的引用
- java - 如何将主题的所有记录存储在单个文件中。?
- ssl - OCSP 查询没有颁发者证书的中间证书
- reporting-services - 是否可以限制 RunningValue 回顾一定数量的行?
- angular - Angular i18m xliffmerge 覆盖翻译
- php - 处理整数的 Explode 的替代方法 - 不能使用 str_split()
- javascript - JS:循环强制升序排序,如何保持定义的顺序?
- docker - 在 docker swarm 服务更新后替换对等容器
- android - 我的应用程序的内存使用量如此之高的可能原因是什么?