public initDefault() {
console.time('texture')
this.normalTexture = this.createTexture(32, 32, 255 * 0.5, 255 * 0.5, 255.0, 255.0, 'default-normalTexture');
this.maskTexture = this.createTexture(32, 32, 255, 255 * 0.5, 255.0, 255.0, 'default-maskTexture');
this.whiteTexture = this.createTexture(32, 32, 255, 255, 255, 255, 'default-whiteTexture');
this.blackTexture = this.createTexture(32, 32, 0, 0, 0, 255.0, 'default-blackTexture');
this.redTexture = this.createTexture(32, 32, 255, 0, 0, 255.0, 'default-redTexture');
this.blueTexture = this.createTexture(32, 32, 0, 0, 255, 255.0, 'default-blueTexture');
this.greenTexture = this.createTexture(32, 32, 0, 255, 0, 255, 'default-greenTexture');
this.yellowTexture = this.createTexture(32, 32, 0, 255, 255, 255.0, 'default-yellowTexture');
this.grayTexture = this.createTexture(32, 32, 128, 128, 128, 255.0, 'default-grayTexture');
let brdf = new BRDFLUTGenerate();
let brdf_texture = brdf.generateBRDFLUTTexture();
let BRDFLUT = brdf_texture.name = 'BRDFLUT';
this.addTexture(BRDFLUT, brdf_texture);
this.defaultSky = new HDRTextureCube();
this.defaultSky.createFromTexture(128, this.blackTexture);
Reference.getInstance().attached(this.defaultSky, this);
Reference.getInstance().attached(brdf_texture, this);
Reference.getInstance().attached(this.normalTexture, this);
Reference.getInstance().attached(this.maskTexture, this);
Reference.getInstance().attached(this.whiteTexture, this);
Reference.getInstance().attached(this.blackTexture, this);
Reference.getInstance().attached(this.redTexture, this);
Reference.getInstance().attached(this.blueTexture, this);
Reference.getInstance().attached(this.greenTexture, this);
Reference.getInstance().attached(this.yellowTexture, this);
Reference.getInstance().attached(this.grayTexture, this);
this.defaultGUITexture = new GUITexture(this.whiteTexture);
this.defaultGUISprite = new GUISprite(this.defaultGUITexture);
this.defaultGUISprite.trimSize.set(4, 4)
this.defaultMaterial = new LitMaterial();
console.timeEnd('texture')
}
测试的结果是 9毫秒
02eb7080-1b33-4b04-8a09-b49eb101dcb8-image.png