diff --git a/.version b/.version index 5d3ba08..7b11d3b 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -v10.2.1 +v10.3.0 diff --git a/package.json b/package.json index 56eb686..4a11405 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ohzi-core", - "version": "10.2.1", + "version": "10.3.0", "description": "OHZI Core Library", "source": "src/index.js", "module": "build/index.module.js", diff --git a/src/Graphics.js b/src/Graphics.js index 7735a7b..1a340e3 100644 --- a/src/Graphics.js +++ b/src/Graphics.js @@ -22,7 +22,7 @@ import { WebGLRenderer } from 'three'; class Graphics { - init(canvas, context_attributes) + init(canvas, core_attributes, context_attributes, threejs_attributes) { this._renderer = undefined; this.blitter = undefined; @@ -36,23 +36,34 @@ class Graphics this.canvas_context = undefined; this.context_attributes = undefined; + this.core_attributes = { + force_webgl2: true, + xr_enabled: false + }; + this.context_attributes = { alpha: true, + antialias: false, depth: true, desynchronized: false, - stencil: false, - antialias: false, + failIfMajorPerformanceCaveat: false, + powerPreference: 'high-performance', premultipliedAlpha: true, preserveDrawingBuffer: true, - powerPreference: 'high-performance', - logarithmicDepthBuffer: false, - force_webgl2: true, - xr_enabled: false + stencil: false + }; + + this.threejs_attributes = { + logarithmicDepthBuffer: false }; + Object.assign(this.core_attributes, core_attributes); Object.assign(this.context_attributes, context_attributes); - if (this.context_attributes.force_webgl2) + Object.assign(this.threejs_attributes, this.context_attributes); + Object.assign(this.threejs_attributes, threejs_attributes); + + if (this.core_attributes.force_webgl2) { this.canvas_context = canvas.getContext('webgl2', this.context_attributes) || canvas.getContext('webgl', this.context_attributes) || @@ -68,12 +79,12 @@ class Graphics // console.log(`Using WebGL ${this.is_webgl2 ? 2 : 1}`); - this._renderer = new WebGLRenderer({ - canvas: canvas, - context: this.canvas_context - }); + this.threejs_attributes.canvas = canvas; + this.threejs_attributes.context = this.canvas_context; + + this._renderer = new WebGLRenderer(this.threejs_attributes); - if (this.context_attributes.xr_enabled) + if (this.core_attributes.xr_enabled) { this._renderer.xr.enabled = true; } diff --git a/src/Initializer.js b/src/Initializer.js index 0cf2c5d..23b4561 100644 --- a/src/Initializer.js +++ b/src/Initializer.js @@ -21,7 +21,7 @@ class Initializer { } - init(canvas, context_attributes, input) + init(input) { CameraManager.init(); CameraUtilities.init(input); @@ -39,7 +39,6 @@ class Initializer Time.init(); UI.init(input); - Graphics.init(canvas, context_attributes); Debug.init(); } diff --git a/types/Initializer.d.ts b/types/Initializer.d.ts index 2089d74..ce2da5e 100644 --- a/types/Initializer.d.ts +++ b/types/Initializer.d.ts @@ -1,6 +1,6 @@ export { initializer as Initializer }; declare const initializer: Initializer; declare class Initializer { - init(canvas: any, context_attributes: any, input: any): void; + init(input: any): void; dispose(render_loop: any): void; }