Skip to content

Commit

Permalink
Editor: Added Manifest and ServiceWorker.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Mar 13, 2019
1 parent 09e1fde commit a5bf724
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 5 deletions.
Binary file added editor/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/images/icon.xcf
Binary file not shown.
25 changes: 20 additions & 5 deletions editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<!-- Origin Trial Token, feature = WebXR Device API (For Chrome M69+), origin = https://threejs.org, expires = 2019-03-06 -->
<meta http-equiv="origin-trial" data-feature="WebXR Device API (For Chrome M69+)" data-expires="2019-03-06" content="AvDjbxYpoTgOL1PS0JEra7KFCehfTlKnXpU/ORSwNdCQ35cX70cTUkXOnQ26A5XJi3eXHSKpBPchdt5lbcxDuAIAAABTeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkRldmljZU02OSIsImV4cGlyeSI6MTU1MTgzMDM5OX0=">
<link rel="manifest" href="manifest.json">
</head>
<body ontouchstart="">
<link href="css/main.css" rel="stylesheet" />
<link id="theme" href="css/light.css" rel="stylesheet" />
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" id="theme" href="css/light.css">

<script src="../build/three.js"></script>
<script src="../examples/js/libs/system.min.js"></script>
Expand Down Expand Up @@ -86,6 +87,9 @@
<script src="js/libs/ui.js"></script>
<script src="js/libs/ui.three.js"></script>

<script src="js/libs/html2canvas.js"></script>
<script src="js/libs/three.html.js"></script>

<script src="js/libs/app.js"></script>
<script src="js/Player.js"></script>
<script src="js/Script.js"></script>
Expand Down Expand Up @@ -162,9 +166,6 @@
<script src="js/commands/SetMaterialMapCommand.js"></script>
<script src="js/commands/SetSceneCommand.js"></script>

<script src="js/libs/html2canvas.js"></script>
<script src="js/libs/three.html.js"></script>

<script>

window.URL = window.URL || window.webkitURL;
Expand Down Expand Up @@ -329,6 +330,20 @@

}

// ServiceWorker

if ( 'serviceWorker' in navigator ) {

try {

navigator.serviceWorker.register( 'sw.js' );

} catch ( error ) {

}

}

/*
window.addEventListener( 'message', function ( event ) {
Expand Down
13 changes: 13 additions & 0 deletions editor/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"short_name": "Editor",
"name": "Three.js Editor",
"icons": [
{
"src": "./images/icon.png",
"type": "image/png",
"sizes": "144x144"
}
],
"start_url": ".",
"display": "standalone"
}
197 changes: 197 additions & 0 deletions editor/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
// r102

const staticAssets = [
'./',

'../build/three.js',
'../examples/js/libs/system.min.js',

'../examples/js/controls/EditorControls.js',
'../examples/js/controls/TransformControls.js',

'../examples/js/libs/jszip.min.js',
'../examples/js/libs/inflate.min.js',

'../examples/js/loaders/AMFLoader.js',
'../examples/js/loaders/AWDLoader.js',
'../examples/js/loaders/BabylonLoader.js',
'../examples/js/loaders/ColladaLoader.js',
'../examples/js/loaders/DRACOLoader.js',
'../examples/js/loaders/FBXLoader.js',
'../examples/js/loaders/GLTFLoader.js',
'../examples/js/loaders/deprecated/LegacyGLTFLoader.js',
'../examples/js/loaders/KMZLoader.js',
'../examples/js/loaders/MD2Loader.js',
'../examples/js/loaders/OBJLoader.js',
'../examples/js/loaders/MTLLoader.js',
'../examples/js/loaders/PlayCanvasLoader.js',
'../examples/js/loaders/PLYLoader.js',
'../examples/js/loaders/STLLoader.js',
'../examples/js/loaders/SVGLoader.js',
'../examples/js/loaders/TGALoader.js',
'../examples/js/loaders/TDSLoader.js',
'../examples/js/loaders/VRMLLoader.js',
'../examples/js/loaders/VTKLoader.js',
'../examples/js/loaders/ctm/lzma.js',
'../examples/js/loaders/ctm/ctm.js',
'../examples/js/loaders/ctm/CTMLoader.js',

'../examples/js/exporters/ColladaExporter.js',
'../examples/js/exporters/GLTFExporter.js',
'../examples/js/exporters/OBJExporter.js',
'../examples/js/exporters/STLExporter.js',

'../examples/js/renderers/Projector.js',
'../examples/js/renderers/RaytracingRenderer.js',
'../examples/js/renderers/SoftwareRenderer.js',
'../examples/js/renderers/SVGRenderer.js',

'./js/libs/codemirror/codemirror.css',
'./js/libs/codemirror/theme/monokai.css',

'./js/libs/codemirror/codemirror.js',
'./js/libs/codemirror/mode/javascript.js',
'./js/libs/codemirror/mode/glsl.js',

'./js/libs/esprima.js',
'./js/libs/jsonlint.js',
'./js/libs/glslprep.min.js',

'./js/libs/codemirror/addon/dialog.css',
'./js/libs/codemirror/addon/show-hint.css',
'./js/libs/codemirror/addon/tern.css',

'./js/libs/codemirror/addon/dialog.js',
'./js/libs/codemirror/addon/show-hint.js',
'./js/libs/codemirror/addon/tern.js',
'./js/libs/acorn/acorn.js',
'./js/libs/acorn/acorn_loose.js',
'./js/libs/acorn/walk.js',
'./js/libs/ternjs/polyfill.js',
'./js/libs/ternjs/signal.js',
'./js/libs/ternjs/tern.js',
'./js/libs/ternjs/def.js',
'./js/libs/ternjs/comment.js',
'./js/libs/ternjs/infer.js',
'./js/libs/ternjs/doc_comment.js',
'./js/libs/tern-threejs/threejs.js',

'./js/libs/signals.min.js',
'./js/libs/ui.js',
'./js/libs/ui.three.js',

'./js/libs/html2canvas.js',
'./js/libs/three.html.js',

'./js/libs/app.js',
'./js/Player.js',
'./js/Script.js',

'../examples/js/vr/WebVR.js',

//

'./css/main.css',
'./css/dark.css',
'./css/light.css',

'./js/Storage.js',

'./js/Editor.js',
'./js/Config.js',
'./js/History.js',
'./js/Loader.js',
'./js/Menubar.js',
'./js/Menubar.File.js',
'./js/Menubar.Edit.js',
'./js/Menubar.Add.js',
'./js/Menubar.Play.js',
// './js/Menubar.View.js',
'./js/Menubar.Examples.js',
'./js/Menubar.Help.js',
'./js/Menubar.Status.js',
'./js/Sidebar.js',
'./js/Sidebar.Scene.js',
'./js/Sidebar.Project.js',
'./js/Sidebar.Settings.js',
'./js/Sidebar.Settings.Shortcuts.js',
'./js/Sidebar.Settings.Viewport.js',
'./js/Sidebar.Properties.js',
'./js/Sidebar.Object.js',
'./js/Sidebar.Geometry.js',
'./js/Sidebar.Geometry.Geometry.js',
'./js/Sidebar.Geometry.BufferGeometry.js',
'./js/Sidebar.Geometry.Modifiers.js',
'./js/Sidebar.Geometry.BoxGeometry.js',
'./js/Sidebar.Geometry.CircleGeometry.js',
'./js/Sidebar.Geometry.CylinderGeometry.js',
'./js/Sidebar.Geometry.IcosahedronGeometry.js',
'./js/Sidebar.Geometry.PlaneGeometry.js',
'./js/Sidebar.Geometry.SphereGeometry.js',
'./js/Sidebar.Geometry.TorusGeometry.js',
'./js/Sidebar.Geometry.TorusKnotGeometry.js',
'./js/Sidebar.Geometry.TubeGeometry.js',
'../examples/js/geometries/TeapotBufferGeometry.js',
'./js/Sidebar.Geometry.TeapotBufferGeometry.js',
'./js/Sidebar.Geometry.LatheGeometry.js',
'./js/Sidebar.Material.js',
'./js/Sidebar.Animation.js',
'./js/Sidebar.Script.js',
'./js/Sidebar.History.js',
'./js/Strings.js',
'./js/Toolbar.js',
'./js/Viewport.js',
'./js/Viewport.Info.js',

'./js/Command.js',
'./js/commands/AddObjectCommand.js',
'./js/commands/RemoveObjectCommand.js',
'./js/commands/MoveObjectCommand.js',
'./js/commands/SetPositionCommand.js',
'./js/commands/SetRotationCommand.js',
'./js/commands/SetScaleCommand.js',
'./js/commands/SetValueCommand.js',
'./js/commands/SetUuidCommand.js',
'./js/commands/SetColorCommand.js',
'./js/commands/SetGeometryCommand.js',
'./js/commands/SetGeometryValueCommand.js',
'./js/commands/MultiCmdsCommand.js',
'./js/commands/AddScriptCommand.js',
'./js/commands/RemoveScriptCommand.js',
'./js/commands/SetScriptValueCommand.js',
'./js/commands/SetMaterialCommand.js',
'./js/commands/SetMaterialValueCommand.js',
'./js/commands/SetMaterialColorCommand.js',
'./js/commands/SetMaterialMapCommand.js',
'./js/commands/SetSceneCommand.js',

//

'./examples/arkanoid.app.json',
'./examples/camera.app.json',
'./examples/particles.app.json',
'./examples/pong.app.json',
'./examples/shaders.app.json'

];

self.addEventListener( 'install', async function ( event ) {

const cache = await caches.open( 'threejs-editor' );
cache.addAll( staticAssets );

} );

self.addEventListener( 'fetch', async function ( event ) {

const request = event.request;
event.respondWith( cacheFirst( request ) );

} );

async function cacheFirst( request ) {

const cachedResponse = await caches.match( request );
return cachedResponse || fetch( request );

}

0 comments on commit a5bf724

Please sign in to comment.