Skip to content

Commit

Permalink
Added ImportMaps availability script (#23148)
Browse files Browse the repository at this point in the history
* Added ImportMaps availability script.

* Puppeteer: Added missing webgpu examples exception list.
  • Loading branch information
mrdoob authored Jan 4, 2022
1 parent 687e14f commit fe276f2
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 1 deletion.
32 changes: 32 additions & 0 deletions examples/jsm/capabilities/ImportMaps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class ImportMaps {

static isAvailable() {

return ( 'supports' in HTMLScriptElement && HTMLScriptElement.supports( 'importmap' ) );

}

static getErrorMessage() {

const message = 'Your browser does not support <a href="https://wicg.github.io/import-maps/" style="color:blue">Import Maps</a>';

const element = document.createElement( 'div' );
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';

element.innerHTML = message;

return element;

}

}

export default ImportMaps;
13 changes: 13 additions & 0 deletions examples/webgpu_compute.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_instance_uniform.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_lights_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_lights_selective.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_nodes_playground.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_rtt.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_skinning.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
13 changes: 13 additions & 0 deletions examples/webgpu_skinning_points.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
}
}
</script>

<script type="module">

import ImportMaps from './jsm/capabilities/ImportMaps.js';

if ( ImportMaps.isAvailable() === false ) {

document.body.appendChild( ImportMaps.getErrorMessage() );

}

</script>

<script type="module">

import * as THREE from 'three';
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ const exceptionList = [
'webgpu_lights_custom',
'webgpu_lights_selective',
'webgpu_materials',
'webgpu_nodes_playground',
'webgpu_rtt',
'webgpu_sandbox'
'webgpu_sandbox',
'webgpu_skinning_points',
'webgpu_skinning'
].concat( ( process.platform === 'win32' ) ? [

'webgl_effects_ascii' // windows fonts not supported
Expand Down

0 comments on commit fe276f2

Please sign in to comment.