From a2fc6295335c558e1ae40d77429959cd42fbc008 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alex.rose@rcsb.org> Date: Fri, 22 Mar 2019 18:13:28 -0700 Subject: [PATCH] cleanup --- src/mol-io/common/ascii.ts | 90 ------------------- .../state/transforms/representation.ts | 1 - src/tests/browser/index.html | 73 +++++++-------- src/tests/browser/render-shape.ts | 4 +- 4 files changed, 36 insertions(+), 132 deletions(-) delete mode 100644 src/mol-io/common/ascii.ts diff --git a/src/mol-io/common/ascii.ts b/src/mol-io/common/ascii.ts deleted file mode 100644 index 4a9b2edfa..000000000 --- a/src/mol-io/common/ascii.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2017 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * Adapted from https://github.com/rcsb/mmtf-javascript - * @author Alexander Rose <alexander.rose@weirdbyte.de> - * @author David Sehnal <david.sehnal@gmail.com> - */ -// NOT IN USE ELSEWEHERE !!!!! -export function asciiWrite(data: Uint8Array, offset: number, str: string) { - for (let i = 0, l = str.length; i < l; i++) { - let codePoint = str.charCodeAt(i); - - // One byte of UTF-8 - if (codePoint < 0x80) { - data[offset++] = codePoint >>> 0 & 0x7f | 0x00; - continue; - } - - // Two bytes of UTF-8 - if (codePoint < 0x800) { - data[offset++] = codePoint >>> 6 & 0x1f | 0xc0; - data[offset++] = codePoint >>> 0 & 0x3f | 0x80; - continue; - } - - // Three bytes of UTF-8. - if (codePoint < 0x10000) { - data[offset++] = codePoint >>> 12 & 0x0f | 0xe0; - data[offset++] = codePoint >>> 6 & 0x3f | 0x80; - data[offset++] = codePoint >>> 0 & 0x3f | 0x80; - continue; - } - - // Four bytes of UTF-8 - if (codePoint < 0x110000) { - data[offset++] = codePoint >>> 18 & 0x07 | 0xf0; - data[offset++] = codePoint >>> 12 & 0x3f | 0x80; - data[offset++] = codePoint >>> 6 & 0x3f | 0x80; - data[offset++] = codePoint >>> 0 & 0x3f | 0x80; - continue; - } - throw new Error('bad codepoint ' + codePoint); - } -} - -const __chars = function () { - let data: string[] = []; - for (let i = 0; i < 1024; i++) data[i] = String.fromCharCode(i); - return data; -}(); - -function throwError(err: string) { - throw new Error(err); -} - -export function asciiRead(data: number, offset: number, length: number) { - let chars = __chars; - let str: string | undefined = void 0; - - let byte = data; - // One byte character - if ((byte & 0x80) !== 0x00) throwError('Invalid byte ' + byte.toString(16)); - str = chars[byte]; - return str; -} - -export function asciiByteCount(str: string) { - let count = 0; - for (let i = 0, l = str.length; i < l; i++) { - let codePoint = str.charCodeAt(i); - if (codePoint < 0x80) { - count += 1; - continue; - } - if (codePoint < 0x800) { - count += 2; - continue; - } - if (codePoint < 0x10000) { - count += 3; - continue; - } - if (codePoint < 0x110000) { - count += 4; - continue; - } - throwError('bad codepoint ' + codePoint); - } - return count; -} \ No newline at end of file diff --git a/src/mol-plugin/state/transforms/representation.ts b/src/mol-plugin/state/transforms/representation.ts index 4309e45f4..2b71e273f 100644 --- a/src/mol-plugin/state/transforms/representation.ts +++ b/src/mol-plugin/state/transforms/representation.ts @@ -194,7 +194,6 @@ const StructureRepresentation3D = PluginStateTransform.BuiltIn({ } }); - type StructureLabels3D = typeof StructureLabels3D const StructureLabels3D = PluginStateTransform.BuiltIn({ name: 'structure-labels-3d', diff --git a/src/tests/browser/index.html b/src/tests/browser/index.html index 856790048..62d647dc8 100644 --- a/src/tests/browser/index.html +++ b/src/tests/browser/index.html @@ -1,42 +1,37 @@ <!DOCTYPE html> <html lang="en"> -<head> - <meta charset="utf-8" /> - <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> - <title>Mol* Browser Test</title> - <style> - * { - margin: 0; - padding: 0; - box-sizing: border-box; - } - html, body { - width: 100%; - height: 100%; - overflow: hidden; - } - </style> -</head> -<body> -<div id="app"></div> -<script type="text/javascript"> - function urlQueryParameter (id) { - if (typeof window === 'undefined') return undefined - const a = new RegExp(`${id}=([^&#=]*)`) - const m = a.exec(window.location.search) - return m ? decodeURIComponent(m[1]) : undefined - } - const name = urlQueryParameter('name') - if (name) { - const script = document.createElement('script') - script.src = name + '.js' - document.body.appendChild(script) - } -</script> -<script type="text/javascript" > - const script = document.createElement('script'); - script.src = "render-shape.js"; - document.body.appendChild(script); -</script> -</body> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <title>Mol* Browser Test</title> + <style> + * { + margin: 0; + padding: 0; + box-sizing: border-box; + } + html, body { + width: 100%; + height: 100%; + overflow: hidden; + } + </style> + </head> + <body> + <div id="app"></div> + <script type="text/javascript"> + function urlQueryParameter (id) { + if (typeof window === 'undefined') return undefined + const a = new RegExp(`${id}=([^&#=]*)`) + const m = a.exec(window.location.search) + return m ? decodeURIComponent(m[1]) : undefined + } + const name = urlQueryParameter('name') + if (name) { + const script = document.createElement('script') + script.src = name + '.js' + document.body.appendChild(script) + } + </script> + </body> </html> \ No newline at end of file diff --git a/src/tests/browser/render-shape.ts b/src/tests/browser/render-shape.ts index 6fd4ace69..adc6c9eae 100644 --- a/src/tests/browser/render-shape.ts +++ b/src/tests/browser/render-shape.ts @@ -68,7 +68,7 @@ async function getSphereMesh(ctx: RuntimeContext, centers: number[], mesh?: Mesh const builderState = MeshBuilder.createState(centers.length * 128, centers.length * 128 / 2, mesh) const t = Mat4.identity() const v = Vec3.zero() - const sphere = Sphere(4) + const sphere = Sphere(3) builderState.currentGroup = 0 for (let i = 0, il = centers.length / 3; i < il; ++i) { // for production, calls to update should be guarded by `if (ctx.shouldUpdate)` @@ -121,4 +121,4 @@ export async function init() { await repr.createOrUpdate({}, myData).run() }, 1000) } -export default init(); \ No newline at end of file +init() \ No newline at end of file -- GitLab