THREE.Sprite无法在我的Android设备上运行

时间:2017-02-23 21:14:56

标签: javascript three.js

我试图在我的Android手机上使用THREE.Sprite渲染图像,但图像没有显示出来。使用Mac上的Chrome浏览器的远程调试器,我收到以下错误:

Uncaught TypeError: Cannot read property 'vertexAttribDivisorANGLE' of null
    at THREE.WebGLState.enableAttribute (three.min.js:728)
    at THREE.SpritePlugin.render (three.min.js:752)
    at THREE.WebGLRenderer.render (three.min.js:663)
    at animate (app.js:1241)
enableAttribute @   three.min.js:728
render  @   three.min.js:752
render  @   three.min.js:663
animate @   app.js:1241
requestAnimationFrame (async)

设备信息:

  • Chrome应用程序版本:56.0.2924.87
  • 操作系统:Android 4.1.2:GT-l8190L Build / JZO54K

我正在使用的代码片段:

const createSprite = (spriteMap, scaleUnit = 1) => {
  const material = new THREE.SpriteMaterial({ map: spriteMap });
  const sprite = new THREE.Sprite(material);
  const width = material.map.image.width * scaleUnit;
  const height = material.map.image.height * scaleUnit;
  sprite.scale.set(width, height, 1);
  return sprite;
};

// To load my textures:
const loadComponents = (components, callback) => {
  const loadFabricImages = (images, loaded, objs) => {
    if (images.length) {
      fabric.Image.fromURL(images.shift(), (img) => {
        loaded.push(img);
        objs[img._element.getAttribute('src').split('/').pop().split('.').shift()] = img;
        loadFabricImages(images, loaded, objs);
      });
    } else {
      callback(loaded, objs);
    }
  };

  loadFabricImages(components, [], {});
};

loadComponents(['img1.png', 'img2.png'], (textures) => {
    const sprite = createSprite(textures[0], 0.55);
});

它在其他设备和浏览器上运行良好。

这个问题有解决办法吗?提前谢谢。

0 个答案:

没有答案