Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/manual/en/introduction/How-to-use-WebGL2.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ <h2>Workflow</h2>

<p>
Since WebGL 2 is not supported by all devices that support WebGL 1, it's important to check the respective availability.
To do so, please include [link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js WebGL.js] into your project.
To do so, please include [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js WebGL.js] into your project.
</p>

<code>
&lt;script src="/path/to/WebGL.js"&gt;&lt;/script&gt;
import { WEBGL } from 'three/examples/jsm/WebGL.js';
</code>

<p>
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/en/introduction/WebGL-compatibility-check.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1>[name]</h1>
</p>

<p>
Add [link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js]
Add [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js]
to your javascript and run the following before attempting to render anything.
</p>

Expand Down
4 changes: 2 additions & 2 deletions docs/manual/zh/introduction/How-to-use-WebGL2.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ <h2>工作流程</h2>

<p>
由于WebGL 2并不被所有支持WebGL 1的设备所支持,因此检查各种设备上WebGL 2的可用性是非常重要的。
要对其可用性进行检查,请将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js WebGL.js]包含到你的项目中。
要对其可用性进行检查,请将[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js WebGL.js]包含到你的项目中。
</p>

<code>
&lt;script src="/path/to/WebGL.js"&gt;&lt;/script&gt;
import { WEBGL } from 'three/examples/jsm/WebGL.js';
</code>

<p>
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/zh/introduction/WebGL-compatibility-check.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>WebGL兼容性检查([name])</h1>
</p>

<p>
请将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js]引入到你的文件,并在尝试开始渲染之前先运行该文件。
请将[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js]引入到你的文件,并在尝试开始渲染之前先运行该文件。
</p>

<code>
Expand Down
2 changes: 1 addition & 1 deletion examples/js/WebGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author mr.doob / http://mrdoob.com/
*/

var WEBGL = {
THREE.WEBGL = {

isWebGLAvailable: function () {

Expand Down
9 changes: 9 additions & 0 deletions examples/jsm/WebGL.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export namespace WEBGL {

export function isWebGLAvailable(): boolean;
export function isWebGL2Available(): boolean;
export function getWebGLErrorMessage(): HTMLElement;
export function getWebGL2ErrorMessage(): HTMLElement;
export function getErrorMessage(version: number): HTMLElement;

}
98 changes: 98 additions & 0 deletions examples/jsm/WebGL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* @author alteredq / http://alteredqualia.com/
* @author mr.doob / http://mrdoob.com/
*/



var WEBGL = {

isWebGLAvailable: function () {

try {

var canvas = document.createElement( 'canvas' );
return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );

} catch ( e ) {

return false;

}

},

isWebGL2Available: function () {

try {

var canvas = document.createElement( 'canvas' );
return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );

} catch ( e ) {

return false;

}

},

getWebGLErrorMessage: function () {

return this.getErrorMessage( 1 );

},

getWebGL2ErrorMessage: function () {

return this.getErrorMessage( 2 );

},

getErrorMessage: function ( version ) {

var names = {
1: 'WebGL',
2: 'WebGL 2'
};

var contexts = {
1: window.WebGLRenderingContext,
2: window.WebGL2RenderingContext
};

var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';

var element = document.createElement( 'div' );
element.id = 'webglmessage';
element.style.fontFamily = 'monospace';
element.style.fontSize = '13px';
element.style.fontWeight = 'normal';
element.style.textAlign = 'center';
element.style.background = '#fff';
element.style.color = '#000';
element.style.padding = '1.5em';
element.style.width = '400px';
element.style.margin = '5em auto 0';

if ( contexts[ version ] ) {

message = message.replace( '$0', 'graphics card' );

} else {

message = message.replace( '$0', 'browser' );

}

message = message.replace( '$1', names[ version ] );

element.innerHTML = message;

return element;

}

};

export { WEBGL };
2 changes: 1 addition & 1 deletion examples/webgl2_materials_texture2darray.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
</div>

<script src="js/libs/jszip.min.js"></script>
<script src="js/WebGL.js"></script>

<script type="module">

import * as THREE from '../build/three.module.js';

import Stats from './jsm/libs/stats.module.js';
import { WEBGL } from './jsm/WebGL.js';

if ( WEBGL.isWebGL2Available() === false ) {

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl2_materials_texture3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
</div>
<div id="inset"></div>

<script src="js/WebGL.js"></script>

<script type="module">
import * as THREE from '../build/three.module.js';

import { GUI } from './jsm/libs/dat.gui.module.js';
import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { NRRDLoader } from './jsm/loaders/NRRDLoader.js';
import { VolumeRenderShader1 } from './jsm/shaders/VolumeShader.js';
import { WEBGL } from './jsm/WebGL.js';

if ( WEBGL.isWebGL2Available() === false ) {

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl2_multisampled_renderbuffers.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<div id="container">
</div>

<script src="js/WebGL.js"></script>

<script type="module">

import * as THREE from '../build/three.module.js';
Expand All @@ -43,6 +41,7 @@
import { RenderPass } from './jsm/postprocessing/RenderPass.js';
import { ShaderPass } from './jsm/postprocessing/ShaderPass.js';
import { CopyShader } from './jsm/shaders/CopyShader.js';
import { WEBGL } from './jsm/WebGL.js';

if ( WEBGL.isWebGL2Available() === false ) {

Expand Down
3 changes: 1 addition & 2 deletions examples/webgl2_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
<body>
<div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl2 sandbox</div>

<script src="js/WebGL.js"></script>

<script type="module">

import * as THREE from '../build/three.module.js';

import { OrbitControls } from './jsm/controls/OrbitControls.js';
import { WEBGL } from './jsm/WebGL.js';

if ( WEBGL.isWebGL2Available() === false ) {

Expand Down
2 changes: 2 additions & 0 deletions utils/modularize.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ var files = [
{ path: 'vr/deprecated/GearVRController.js', dependencies: [], ignoreList: [] },
{ path: 'vr/PaintViveController.js', dependencies: [ { name: 'ViveController', path: 'vr/ViveController.js' } ], ignoreList: [] },
{ path: 'vr/ViveController.js', dependencies: [], ignoreList: [] },

{ path: 'WebGL.js', dependencies: [], ignoreList: [] },
];

for ( var i = 0; i < files.length; i ++ ) {
Expand Down