在 2d 画布绘制能力在 threejs 章节中,initGameoverCanvas 报错,在上一章节中 GamePage.init 绘制三角形木有问题。和视频不一样的调整了 GameController.init 方法中 initGamePage 和 initGameOverPage 的执行位置,不然 GameOverPage 会报 scene 为 undefined 。
但是后来报 ImageBitmap is not defined 不知道如何解。
Google 之后有网友解法为修改three.js 源码或者全局添加 ImageBitmap 方法。如下:
import * as THREE from './../libs/three.js';
import Game from './game/game.js';
window.THREE = THREE
GameGlobal.ImageBitmap = function() {} // <- HERE
class Main {
static init () {
Game.init();
}
}
export default Main
然后添加了就好使了,矩形框出现了,不知道大家有木有遇到这个问题。
查了一下资料没有很明白为何这样,求解释 ?
1.5k 16
1.1k 11
1.1k 11
4.9k 10
2.3k 9