├── sphinxcadquery
├── __init__.py
├── sphinxcadquerystatic
│ ├── main.css
│ ├── WebGL.js
│ ├── main.js
│ ├── STLLoader.js
│ ├── AMFLoader.js
│ ├── LegacyJSONLoader.js
│ ├── OrbitControls.js
│ └── jszip.min.js
└── sphinxcadquery.py
├── tests
├── test_sphinx_build.py
└── example
│ ├── index.rst
│ └── conf.py
├── .github
└── workflows
│ └── CI.yml
├── setup.py
├── LICENSE
└── README.rst
/sphinxcadquery/__init__.py:
--------------------------------------------------------------------------------
1 | __version__ = '1.3.3'
2 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/main.css:
--------------------------------------------------------------------------------
1 | /* Canvas */
2 | #sphinxcadquerycanvas {
3 | position: absolute;
4 | left: 0;
5 | top: 0;
6 | width: 100%;
7 | height: 100%;
8 | display: block;
9 | pointer-events: none;
10 | }
11 |
--------------------------------------------------------------------------------
/tests/test_sphinx_build.py:
--------------------------------------------------------------------------------
1 |
2 | import subprocess
3 |
4 |
5 | def test_building_example_docs():
6 | """Builds documentation that contains a few example use cases"""
7 |
8 | subprocess.check_output(['sphinx-build', '-b', 'html', './tests/example', './build/html/'])
9 |
--------------------------------------------------------------------------------
/.github/workflows/CI.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | pull_request:
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/checkout@v2
11 | - uses: s-weigand/setup-conda@v1
12 |
13 | - name: installation
14 | run: |
15 | conda install -c conda-forge -c cadquery cadquery=2
16 | pip install pytest
17 | pip install .
18 | - name: test package
19 | run: |
20 | pytest tests
21 |
--------------------------------------------------------------------------------
/tests/example/index.rst:
--------------------------------------------------------------------------------
1 |
2 | Example 1
3 | ^^^^^^^^^
4 |
5 | .. cadquery::
6 |
7 | result = cadquery.Workplane("XY").box(2, 2, 2)
8 |
9 |
10 | Example 2
11 | ^^^^^^^^^
12 |
13 | .. cadquery::
14 | :select: mypart
15 | :include-source: true
16 | :color: #ff00ff
17 | :width: 80%
18 | :height: 200px
19 | :gridsize: 20.
20 | :griddivisions: 20
21 |
22 | mypart = cadquery.Workplane("XY").box(2, 2, 2)
23 |
24 | Example 3
25 | ^^^^^^^^^
26 |
27 | .. cadquery::
28 | :gridsize: 0
29 |
30 | result = cadquery.Workplane("XY").box(2, 2, 2)
31 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | """
2 | Setup module.
3 | """
4 | from setuptools import setup
5 |
6 | from sphinxcadquery import __version__
7 |
8 |
9 | setup(
10 | name='sphinxcadquery',
11 | version=__version__,
12 | description=
13 | 'An extension to visualize CadQuery 3D parts in your Sphinx documentation',
14 | long_description="""TODO""",
15 | url='https://github.com/Peque/sphinxcadquery',
16 | author='Miguel Sánchez de León Peque',
17 | author_email='peque@neosit.es',
18 | license='BSD License',
19 | classifiers=[
20 | 'Development Status :: 4 - Beta',
21 | 'Intended Audience :: Developers',
22 | 'Topic :: Documentation',
23 | 'Topic :: Software Development',
24 | 'Topic :: Utilities',
25 | 'License :: OSI Approved :: BSD License',
26 | 'Operating System :: OS Independent',
27 | 'Programming Language :: Python :: 3',
28 | 'Framework :: Sphinx :: Extension',
29 | ],
30 | packages=['sphinxcadquery'],
31 | package_data={
32 | 'sphinxcadquery': [
33 | 'sphinxcadquerystatic/*',
34 | ],
35 | },
36 | install_requires=[
37 | 'sphinx',
38 | ],
39 | )
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) The SphinxCadQuery contributors.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | 1. Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 |
10 | 2. Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 |
14 | 3. Neither the name of SphinxCadQuery nor the names of its contributors may
15 | be used to endorse or promote products derived from this software without
16 | specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/README.rst:
--------------------------------------------------------------------------------
1 | sphinxcadquery
2 | ==============
3 |
4 | An extension to visualize CadQuery 3D files in your Sphinx documentation.
5 |
6 | .. code::
7 |
8 | pip install sphinxcadquery
9 |
10 | Of course, ``cadquery`` needs to be installed as well.
11 |
12 |
13 | Usage
14 | -----
15 |
16 | Enable the Sphinx extension in your ``conf.py`` file:
17 |
18 | .. code:: python
19 |
20 | extensions = [
21 | '...',
22 | 'sphinxcadquery.sphinxcadquery',
23 | ]
24 |
25 | Then you can use the ``.. cadquery::`` directive in your documentation:
26 |
27 | .. code:: rest
28 |
29 | .. cadquery::
30 |
31 | result = cadquery.Workplane("XY").box(2, 2, 2)
32 |
33 | You may provide a source code file instead:
34 |
35 | .. code:: rest
36 |
37 | .. cadquery:: ../3d/mydesign.py
38 |
39 |
40 | Options
41 | -------
42 |
43 | By default it will try to load a part named ``result`` or ``part`` in that
44 | source code. You may change that by providing an explicit name to select:
45 |
46 | .. code:: rest
47 |
48 | .. cadquery:: ../3d/mydesign.py
49 | :select: mypart
50 |
51 | You may want to play with the supported options for a customized look:
52 |
53 | .. code:: rest
54 |
55 | .. cadquery::
56 | :select: mypart
57 | :include-source: true
58 | :color: #ff00ff
59 | :width: 80%
60 | :height: 200px
61 | :gridsize: 20.
62 | :griddivisions: 20
63 |
64 | mypart = cadquery.Workplane("XY").box(2, 2, 2)
65 |
66 | Optionally the grid can also be removed by setting gridsize to 0:
67 |
68 | .. code:: rest
69 |
70 | .. cadquery::
71 | :gridsize: 0
72 |
73 | result = cadquery.Workplane("XY").box(2, 2, 2)
74 |
75 | Global options
76 | --------------
77 |
78 | You may as well configure some options globally, by setting the corresponding
79 | variable in your ``conf.py`` file:
80 |
81 | .. code:: python
82 |
83 | # Define a different default color
84 | sphinxcadquery_color = '#bb0000'
85 | # By default, always show the source code above the scene
86 | sphinxcadquery_include_source = True
87 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/WebGL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author alteredq / http://alteredqualia.com/
3 | * @author mr.doob / http://mrdoob.com/
4 | */
5 |
6 | var WEBGL = {
7 |
8 | isWebGLAvailable: function () {
9 |
10 | try {
11 |
12 | var canvas = document.createElement( 'canvas' );
13 | return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
14 |
15 | } catch ( e ) {
16 |
17 | return false;
18 |
19 | }
20 |
21 | },
22 |
23 | isWebGL2Available: function () {
24 |
25 | try {
26 |
27 | var canvas = document.createElement( 'canvas' );
28 | return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
29 |
30 | } catch ( e ) {
31 |
32 | return false;
33 |
34 | }
35 |
36 | },
37 |
38 | getWebGLErrorMessage: function () {
39 |
40 | return this.getErrorMessage( 1 );
41 |
42 | },
43 |
44 | getWebGL2ErrorMessage: function () {
45 |
46 | return this.getErrorMessage( 2 );
47 |
48 | },
49 |
50 | getErrorMessage: function ( version ) {
51 |
52 | var names = {
53 | 1: 'WebGL',
54 | 2: 'WebGL 2'
55 | };
56 |
57 | var contexts = {
58 | 1: window.WebGLRenderingContext,
59 | 2: window.WebGL2RenderingContext
60 | };
61 |
62 | var message = 'Your $0 does not seem to support $1';
63 |
64 | var element = document.createElement( 'div' );
65 | element.id = 'webglmessage';
66 | element.style.fontFamily = 'monospace';
67 | element.style.fontSize = '13px';
68 | element.style.fontWeight = 'normal';
69 | element.style.textAlign = 'center';
70 | element.style.background = '#fff';
71 | element.style.color = '#000';
72 | element.style.padding = '1.5em';
73 | element.style.width = '400px';
74 | element.style.margin = '5em auto 0';
75 |
76 | if ( contexts[ version ] ) {
77 |
78 | message = message.replace( '$0', 'graphics card' );
79 |
80 | } else {
81 |
82 | message = message.replace( '$0', 'browser' );
83 |
84 | }
85 |
86 | message = message.replace( '$1', names[ version ] );
87 |
88 | element.innerHTML = message;
89 |
90 | return element;
91 |
92 | }
93 |
94 | };
95 |
--------------------------------------------------------------------------------
/tests/example/conf.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #
3 | # Configuration file for the Sphinx documentation builder.
4 | #
5 | # This file does only contain a selection of the most common options. For a
6 | # full list see the documentation:
7 | # http://www.sphinx-doc.org/en/master/config
8 |
9 | # -- Path setup --------------------------------------------------------------
10 |
11 | # If extensions (or modules to document with autodoc) are in another directory,
12 | # add these directories to sys.path here. If the directory is relative to the
13 | # documentation root, use os.path.abspath to make it absolute, like shown here.
14 | #
15 | import os
16 | import sys
17 |
18 | sys.path.insert(0, os.path.abspath("../.."))
19 |
20 | # -- Project information -----------------------------------------------------
21 |
22 | project = "sphinxcadquery"
23 | copyright = ""
24 | author = "sphinx cadquery contributors"
25 |
26 | # Define a different default color
27 | sphinxcadquery_color = '#bb0000'
28 | # By default, always show the source code above the scene
29 | sphinxcadquery_include_source = True
30 |
31 | # The short X.Y version
32 | version = ""
33 | # The full version, including alpha/beta/rc tags
34 | release = "1.0"
35 |
36 |
37 | # -- General configuration ---------------------------------------------------
38 |
39 | # If your documentation needs a minimal Sphinx version, state it here.
40 | #
41 | # needs_sphinx = '3.5.4'
42 |
43 | # Add any Sphinx extension module names here, as strings. They can be
44 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
45 | # ones.
46 | extensions = [
47 | "sphinxcadquery.sphinxcadquery",
48 | ]
49 |
50 | # Configure `sphinxcadquery`
51 | sphinxcadquery_include_source = True
52 |
53 |
54 | # Add any paths that contain templates here, relative to this directory.
55 | templates_path = ["_templates"]
56 |
57 | # The suffix(es) of source filenames.
58 | # You can specify multiple suffix as a list of string:
59 | #
60 | # source_suffix = ['.rst', '.md']
61 | source_suffix = ".rst"
62 |
63 | # The master toctree document.
64 | master_doc = "index"
65 |
66 | # The language for content autogenerated by Sphinx. Refer to documentation
67 | # for a list of supported languages.
68 | #
69 | # This is also used if you do content translation via gettext catalogs.
70 | # Usually you set "language" from the command line for these cases.
71 | language = None
72 |
73 | # List of patterns, relative to source directory, that match files and
74 | # directories to ignore when looking for source files.
75 | # This pattern also affects html_static_path and html_extra_path.
76 | exclude_patterns = []
77 |
78 | # The name of the Pygments (syntax highlighting) style to use.
79 | pygments_style = None
80 |
81 |
82 | # shorten module names in readme
83 | add_module_names = False
84 |
85 | # -- Options for HTML output -------------------------------------------------
86 |
87 | # The theme to use for HTML and HTML Help pages. See the documentation for
88 | # a list of builtin themes.
89 | #
90 | html_theme = "default"
91 |
92 | # Theme options are theme-specific and customize the look and feel of a theme
93 | # further. For a list of options available for each theme, see the
94 | # documentation.
95 | #
96 | # html_theme_options = {}
97 |
98 | # Add any paths that contain custom static files (such as style sheets) here,
99 | # relative to this directory. They are copied after the builtin static files,
100 | # so a file named "default.css" will overwrite the builtin "default.css".
101 | html_static_path = ["_static"]
102 |
103 | # Custom sidebar templates, must be a dictionary that maps document names
104 | # to template names.
105 | #
106 | # The default sidebars (for documents that don't match any pattern) are
107 | # defined by theme itself. Builtin themes are using these templates by
108 | # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
109 | # 'searchbox.html']``.
110 | #
111 | # html_sidebars = {}
112 |
113 |
114 | # -- Options for HTMLHelp output ---------------------------------------------
115 |
116 | # Output file base name for HTML help builder.
117 | htmlhelp_basename = "sphinxcadquerydoc"
118 |
119 |
120 | # -- Options for LaTeX output ------------------------------------------------
121 |
122 | latex_elements = {
123 | # The paper size ('letterpaper' or 'a4paper').
124 | #
125 | # 'papersize': 'letterpaper',
126 | # The font size ('10pt', '11pt' or '12pt').
127 | #
128 | # 'pointsize': '10pt',
129 | # Additional stuff for the LaTeX preamble.
130 | #
131 | # 'preamble': '',
132 | # Latex figure (float) alignment
133 | #
134 | # 'figure_align': 'htbp',
135 | }
136 |
137 | # Grouping the document tree into LaTeX files. List of tuples
138 | # (source start file, target name, title,
139 | # author, documentclass [howto, manual, or own class]).
140 | latex_documents = [
141 | (master_doc,
142 | "sphinx_cadquery.tex",
143 | "sphinx cadquery Documentation",
144 | "sphinx cadquery contributors",
145 | "manual"),
146 | ]
147 |
148 |
149 | # -- Options for manual page output ------------------------------------------
150 |
151 | # One entry per manual page. List of tuples
152 | # (source start file, name, description, authors, manual section).
153 | man_pages = [(master_doc, "sphinx cadquery", "sphinx cadquery Documentation", [author], 1)]
154 |
155 |
156 | # -- Options for Texinfo output ----------------------------------------------
157 |
158 | # Grouping the document tree into Texinfo files. List of tuples
159 | # (source start file, target name, title, author,
160 | # dir menu entry, description, category)
161 | texinfo_documents = [
162 | (
163 | master_doc,
164 | "sphinx_cadquery",
165 | "sphinx cadquery Documentation",
166 | author,
167 | "sphinx cadquery",
168 | "One line description of project.",
169 | "Miscellaneous",
170 | ),
171 | ]
172 |
173 |
174 | # -- Options for Epub output -------------------------------------------------
175 |
176 | # Bibliographic Dublin Core info.
177 | epub_title = project
178 |
179 | # The unique identifier of the text. This can be a ISBN number
180 | # or the project homepage.
181 | #
182 | # epub_identifier = ''
183 |
184 | # A unique identification for the text.
185 | #
186 | # epub_uid = ''
187 |
188 | # A list of files that should not be packed into the epub file.
189 | epub_exclude_files = ["search.html"]
190 |
191 |
192 | # -- Extension configuration -------------------------------------------------
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquery.py:
--------------------------------------------------------------------------------
1 | import os
2 | from hashlib import sha256
3 | import importlib
4 | import json
5 | import logging
6 | import textwrap
7 | from uuid import uuid4
8 | from pathlib import Path
9 | from pkg_resources import resource_filename
10 | from tempfile import NamedTemporaryFile
11 |
12 | from docutils import nodes
13 | from docutils.parsers.rst import Directive
14 | from docutils.parsers.rst import directives
15 |
16 | from sphinx.transforms import SphinxTransform
17 | from sphinx.util.docutils import LoggingReporter
18 | from sphinx.util.fileutil import copy_asset
19 |
20 | import cadquery
21 |
22 | from . import __version__
23 |
24 |
25 | logger = logging.getLogger(__name__)
26 |
27 | common_part_names = ['result', 'part']
28 | common_source_header = [
29 | 'import cadquery',
30 | 'import cadquery as cq',
31 | ]
32 | raw_html_template = """
33 |
34 |
41 |
42 | """
43 |
44 |
45 | def directive_truefalse(argument):
46 | return directives.choice(argument, ('true', 'false'))
47 |
48 |
49 | def get_handler(fname):
50 | loader = importlib.machinery.SourceFileLoader('source', str(fname))
51 | return loader.load_module('source')
52 |
53 |
54 | def find_part(module, name):
55 | """
56 | Try to find the 3D part to visualize.
57 |
58 | If no part name is provided, it will try with a list of default/usual
59 | candidates.
60 | """
61 | source = module.__dict__
62 | if name:
63 | candidates = [name]
64 | else:
65 | candidates = common_part_names
66 | for candidate in candidates:
67 | if candidate in source.keys():
68 | return source[candidate]
69 | raise KeyError('Could not find `%s` to visualize!' % candidates[0])
70 |
71 |
72 | class CadQueryDirective(Directive):
73 | has_content = True
74 | required_arguments = 0
75 | optional_arguments = 1
76 | final_argument_whitespace = True
77 | option_spec = {
78 | 'select': directives.unchanged,
79 | 'include-source': bool,
80 | 'color': directives.unchanged,
81 | 'background': directives.unchanged,
82 | 'rotation': directive_truefalse,
83 | 'width': directives.unchanged,
84 | 'height': directives.unchanged,
85 | 'gridsize': float,
86 | 'griddivisions': int,
87 | }
88 |
89 | def run(self):
90 |
91 | doc_source_name = self.state.document.attributes['source']
92 |
93 | self.options.setdefault('include-source',
94 | setup.app.config.sphinxcadquery_include_source)
95 | self.options.setdefault('color', setup.app.config.sphinxcadquery_color)
96 |
97 | if len(self.arguments):
98 | fname = Path(setup.app.srcdir) / self.arguments[0]
99 | fname = fname.resolve()
100 | handle = get_handler(fname)
101 | else:
102 | with NamedTemporaryFile() as named:
103 | fname = named.name
104 | with open(fname, 'w') as tmp:
105 | tmp.write(
106 | '\n'.join(common_source_header + self.content.data))
107 | handle = get_handler(fname)
108 |
109 | select = self.options.get('select', None)
110 | part = find_part(handle, select)
111 | content = cadquery.exporters.toString(part, 'TJS')
112 | digest = sha256(content.encode('utf')).hexdigest()
113 |
114 | fpath = Path('_static') / 'sphinxcadquery'
115 | fname = Path(digest).with_suffix('.tjs')
116 | outputdir = Path(setup.app.builder.outdir) / fpath
117 | outputdir.mkdir(parents=True, exist_ok=True)
118 | outputfname = outputdir / fname
119 |
120 | with open(outputfname, 'w') as outputfile:
121 | outputfile.write(content)
122 |
123 | source_path = Path(doc_source_name)
124 | depth = \
125 | len(source_path.parent.relative_to(Path(setup.app.srcdir)).parents)
126 | relative_uri = Path('.')
127 | for _ in range(depth):
128 | relative_uri /= '../'
129 |
130 | raw_html = raw_html_template.format(
131 | parturi=relative_uri / fpath / fname,
132 | color=self.options['color'],
133 | width=self.options.get('width', '100%'),
134 | height=self.options.get('height', '400px'),
135 | gridsize=self.options.get('gridsize', 100.),
136 | griddivisions=self.options.get('griddivisions', 20),
137 | )
138 |
139 | lines = []
140 | if self.options['include-source']:
141 | data = textwrap.indent('\n'.join(self.content.data), ' ')
142 | lines = ['.. code-block:: python', '', *data.splitlines()]
143 | lines.extend(['', ''])
144 | lines.extend(['', ''])
145 | raw_html = textwrap.indent(raw_html, ' ')
146 | lines.extend(['.. raw:: html', '', *raw_html.splitlines()])
147 | lines.extend(['', ''])
148 | self.state_machine.insert_input(lines, source=doc_source_name)
149 | return []
150 |
151 |
152 | def copy_asset_files(app, exc):
153 | if exc is not None: # build failed
154 | return
155 | source = resource_filename(__name__, 'sphinxcadquerystatic')
156 | copy_asset(source, os.path.join(app.outdir, '_static/sphinxcadquerystatic'))
157 |
158 |
159 | def setup(app):
160 | setup.app = app
161 | app.connect('build-finished', copy_asset_files)
162 | app.add_js_file('sphinxcadquerystatic/three.js')
163 | app.add_js_file('sphinxcadquerystatic/AMFLoader.js')
164 | app.add_js_file('sphinxcadquerystatic/STLLoader.js')
165 | app.add_js_file('sphinxcadquerystatic/LegacyJSONLoader.js')
166 | app.add_js_file('sphinxcadquerystatic/jszip.min.js')
167 | app.add_js_file('sphinxcadquerystatic/OrbitControls.js')
168 | app.add_js_file('sphinxcadquerystatic/WebGL.js')
169 | app.add_js_file('sphinxcadquerystatic/main.js')
170 | app.add_css_file('sphinxcadquerystatic/main.css')
171 | app.add_directive('cadquery', CadQueryDirective)
172 | app.add_config_value('sphinxcadquery_color', '#99bbdd', 'env')
173 | app.add_config_value('sphinxcadquery_include_source', False, 'env')
174 | return {'version': __version__, 'parallel_read_safe': True}
175 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/main.js:
--------------------------------------------------------------------------------
1 | if ( WEBGL.isWebGLAvailable() === false ) {
2 |
3 | document.body.appendChild( WEBGL.getWebGLErrorMessage() );
4 |
5 | }
6 |
7 | var scenes = [], views, canvas, renderer;
8 | var render_queued_flag = false;
9 |
10 | window.addEventListener('load', init, false);
11 | window.addEventListener('scroll', queueRender, false);
12 | window.addEventListener('resize', queueRender, false);
13 |
14 | function queueRender() {
15 |
16 | if ( !render_queued_flag ) {
17 |
18 | render_queued_flag = true;
19 | requestAnimationFrame( render );
20 |
21 | }
22 |
23 | }
24 |
25 | function load_amf_into_scene( scene ) {
26 |
27 | return function ( amfobject ) {
28 |
29 | scene.add( amfobject );
30 | queueRender();
31 |
32 | }
33 |
34 | }
35 |
36 | function load_geometry_into_scene( scene ) {
37 |
38 | return function ( geometry ) {
39 |
40 | var material = new THREE.MeshPhongMaterial( {
41 |
42 | color: scene.userData.view.color,
43 | specular: 0x111111,
44 | shininess: 20,
45 |
46 | } );
47 | geometry.computeVertexNormals();
48 | var mesh = new THREE.Mesh( geometry, material );
49 | scene.add( mesh );
50 |
51 | var edges = new THREE.EdgesGeometry( geometry, 15 );
52 | var line = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0x666666 } ) );
53 | scene.add( line );
54 |
55 | camera = scene.userData.camera;
56 | geometry.computeBoundingSphere();
57 | var distance = geometry.boundingSphere.radius / Math.atan( (camera.fov / 2) * (Math.PI / 180) );
58 | var factor = distance / Math.sqrt(2);
59 | camera.position.set( -factor / 3, -factor, factor );
60 | camera.lookAt( geometry.boundingSphere.center );
61 | scene.userData.controls.target = geometry.boundingSphere.center;
62 | scene.userData.distance_factor = factor;
63 |
64 | queueRender();
65 |
66 | }
67 |
68 | }
69 |
70 | function TranslucentGrid( size, divisions, color1, color2, opacity ) {
71 |
72 | size = size || 10;
73 | divisions = divisions || 10;
74 | color1 = new THREE.Color( color1 !== undefined ? color1 : 0x444444 );
75 | color2 = new THREE.Color( color2 !== undefined ? color2 : 0x888888 );
76 |
77 | var center = divisions / 2;
78 | var step = size / divisions;
79 | var halfSize = size / 2;
80 |
81 | var vertices = [], colors = [];
82 |
83 | for ( var i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) {
84 |
85 | vertices.push( - halfSize, 0, k, halfSize, 0, k );
86 | vertices.push( k, 0, - halfSize, k, 0, halfSize );
87 |
88 | var color = i === center ? color1 : color2;
89 |
90 | color.toArray( colors, j ); j += 3;
91 | color.toArray( colors, j ); j += 3;
92 | color.toArray( colors, j ); j += 3;
93 | color.toArray( colors, j ); j += 3;
94 |
95 | }
96 |
97 | var geometry = new THREE.BufferGeometry();
98 | geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
99 | geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) );
100 |
101 | var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors, opacity: opacity } );
102 |
103 | THREE.LineSegments.call( this, geometry, material );
104 |
105 | }
106 |
107 | TranslucentGrid.prototype = Object.create( THREE.LineSegments.prototype );
108 | TranslucentGrid.prototype.constructor = TranslucentGrid;
109 |
110 | function init() {
111 |
112 | var canvasElement = document.createElement('canvas');
113 | canvasElement.id = 'sphinxcadquerycanvas';
114 | document.body.appendChild(canvasElement);
115 |
116 | canvas = document.getElementById( 'sphinxcadquerycanvas' );
117 |
118 | renderer = new THREE.WebGLRenderer( {
119 | canvas: canvas,
120 | antialias: true,
121 | alpha: true,
122 | premultipliedAlpha: false,
123 | } );
124 | renderer.setPixelRatio( window.devicePixelRatio );
125 |
126 | views = document.querySelectorAll( '.sphinxcadqueryview' );
127 |
128 | for ( var n = 0; n < views.length; n ++ ) {
129 |
130 | var scene = new THREE.Scene();
131 | scene.background = new THREE.Color( 0xffffff );
132 |
133 | scene.userData.view = views[ n ];
134 |
135 | scene.add( new THREE.AmbientLight( 0x888888 ) );
136 |
137 | hemiLight = new THREE.HemisphereLight( 0x888888, 0x222222, 0.3 );
138 | hemiLight.position.set( 50, 50, 100 );
139 | scene.add( hemiLight );
140 |
141 | var gsize = parseFloat(scene.userData.view.gridsize);
142 | var gdivs = parseInt(scene.userData.view.griddivisions);
143 | if ( gsize > 0 ) {
144 | var grid = new TranslucentGrid( gsize, gdivs, 0x888888, 0xdddddd, 0.6, );
145 |
146 | grid.rotateOnAxis( new THREE.Vector3( 1, 0, 0 ), 90 * ( Math.PI / 180 ) );
147 | grid.material.transparent = true;
148 | scene.add( grid );
149 | }
150 |
151 | var camera = new THREE.PerspectiveCamera( 30, 1, 1, 10000 );
152 | camera.up.set( 0, 0, 1 );
153 | camera.position.set( 0, - 9, 6 );
154 | camera.add( new THREE.PointLight( 0xffffff, 0.5 ) );
155 | scene.add( camera );
156 | scene.userData.camera = camera;
157 |
158 | var controls = new THREE.OrbitControls( camera, views[ n ] );
159 | controls.addEventListener( 'change', queueRender );
160 | scene.userData.controls = controls;
161 |
162 | var loader = new THREE.LegacyJSONLoader();
163 | loader.load( scene.userData.view.fname, load_geometry_into_scene( scene ) );
164 |
165 | scenes.push( scene );
166 |
167 | }
168 |
169 | queueRender();
170 |
171 | }
172 |
173 | function updateSize() {
174 |
175 | var width = canvas.clientWidth;
176 | var height = canvas.clientHeight;
177 |
178 | if ( canvas.width !== width || canvas.height !== height ) {
179 |
180 | renderer.setSize( width, height, false );
181 |
182 | }
183 |
184 | }
185 |
186 | function render() {
187 |
188 | render_queued_flag = false;
189 |
190 | if ( canvas == undefined ) {
191 |
192 | queueRender();
193 | return;
194 |
195 | }
196 |
197 | updateSize();
198 |
199 | renderer.setScissorTest( true );
200 |
201 | const transform = `translateY(${window.scrollY}px)`;
202 | renderer.domElement.style.transform = transform;
203 |
204 | scenes.forEach( function ( scene ) {
205 |
206 | var rect = scene.userData.view.getBoundingClientRect();
207 |
208 | // set the viewport
209 | var width = rect.right - rect.left;
210 | var height = rect.bottom - rect.top;
211 | var left = rect.left;
212 | var bottom = renderer.domElement.clientHeight - rect.bottom;
213 |
214 | renderer.setViewport( left, bottom, width, height );
215 | renderer.setScissor( left, bottom, width, height );
216 |
217 | var camera = scene.userData.camera
218 | camera.aspect = width / height;
219 | camera.updateProjectionMatrix();
220 |
221 | renderer.render( scene, scene.userData.camera );
222 |
223 | } );
224 |
225 | }
226 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/STLLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author aleeper / http://adamleeper.com/
3 | * @author mrdoob / http://mrdoob.com/
4 | * @author gero3 / https://github.com/gero3
5 | * @author Mugen87 / https://github.com/Mugen87
6 | *
7 | * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
8 | *
9 | * Supports both binary and ASCII encoded files, with automatic detection of type.
10 | *
11 | * The loader returns a non-indexed buffer geometry.
12 | *
13 | * Limitations:
14 | * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
15 | * There is perhaps some question as to how valid it is to always assume little-endian-ness.
16 | * ASCII decoding assumes file is UTF-8.
17 | *
18 | * Usage:
19 | * var loader = new THREE.STLLoader();
20 | * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
21 | * scene.add( new THREE.Mesh( geometry ) );
22 | * });
23 | *
24 | * For binary STLs geometry might contain colors for vertices. To use it:
25 | * // use the same code to load STL as above
26 | * if (geometry.hasColors) {
27 | * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors });
28 | * } else { .... }
29 | * var mesh = new THREE.Mesh( geometry, material );
30 | */
31 |
32 |
33 | THREE.STLLoader = function ( manager ) {
34 |
35 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
36 |
37 | };
38 |
39 | THREE.STLLoader.prototype = {
40 |
41 | constructor: THREE.STLLoader,
42 |
43 | load: function ( url, onLoad, onProgress, onError ) {
44 |
45 | var scope = this;
46 |
47 | var loader = new THREE.FileLoader( scope.manager );
48 | loader.setPath( scope.path );
49 | loader.setResponseType( 'arraybuffer' );
50 | loader.load( url, function ( text ) {
51 |
52 | try {
53 |
54 | onLoad( scope.parse( text ) );
55 |
56 | } catch ( exception ) {
57 |
58 | if ( onError ) {
59 |
60 | onError( exception );
61 |
62 | }
63 |
64 | }
65 |
66 | }, onProgress, onError );
67 |
68 | },
69 |
70 | setPath: function ( value ) {
71 |
72 | this.path = value;
73 | return this;
74 |
75 | },
76 |
77 | parse: function ( data ) {
78 |
79 | function isBinary( data ) {
80 |
81 | var expect, face_size, n_faces, reader;
82 | reader = new DataView( data );
83 | face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
84 | n_faces = reader.getUint32( 80, true );
85 | expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
86 |
87 | if ( expect === reader.byteLength ) {
88 |
89 | return true;
90 |
91 | }
92 |
93 | // An ASCII STL data must begin with 'solid ' as the first six bytes.
94 | // However, ASCII STLs lacking the SPACE after the 'd' are known to be
95 | // plentiful. So, check the first 5 bytes for 'solid'.
96 |
97 | // Several encodings, such as UTF-8, precede the text with up to 5 bytes:
98 | // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
99 | // Search for "solid" to start anywhere after those prefixes.
100 |
101 | // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
102 |
103 | var solid = [ 115, 111, 108, 105, 100 ];
104 |
105 | for ( var off = 0; off < 5; off ++ ) {
106 |
107 | // If "solid" text is matched to the current offset, declare it to be an ASCII STL.
108 |
109 | if ( matchDataViewAt ( solid, reader, off ) ) return false;
110 |
111 | }
112 |
113 | // Couldn't find "solid" text at the beginning; it is binary STL.
114 |
115 | return true;
116 |
117 | }
118 |
119 | function matchDataViewAt( query, reader, offset ) {
120 |
121 | // Check if each byte in query matches the corresponding byte from the current offset
122 |
123 | for ( var i = 0, il = query.length; i < il; i ++ ) {
124 |
125 | if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
126 |
127 | }
128 |
129 | return true;
130 |
131 | }
132 |
133 | function parseBinary( data ) {
134 |
135 | var reader = new DataView( data );
136 | var faces = reader.getUint32( 80, true );
137 |
138 | var r, g, b, hasColors = false, colors;
139 | var defaultR, defaultG, defaultB, alpha;
140 |
141 | // process STL header
142 | // check for default color in header ("COLOR=rgba" sequence).
143 |
144 | for ( var index = 0; index < 80 - 10; index ++ ) {
145 |
146 | if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
147 | ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
148 | ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
149 |
150 | hasColors = true;
151 | colors = [];
152 |
153 | defaultR = reader.getUint8( index + 6 ) / 255;
154 | defaultG = reader.getUint8( index + 7 ) / 255;
155 | defaultB = reader.getUint8( index + 8 ) / 255;
156 | alpha = reader.getUint8( index + 9 ) / 255;
157 |
158 | }
159 |
160 | }
161 |
162 | var dataOffset = 84;
163 | var faceLength = 12 * 4 + 2;
164 |
165 | var geometry = new THREE.BufferGeometry();
166 |
167 | var vertices = [];
168 | var normals = [];
169 |
170 | for ( var face = 0; face < faces; face ++ ) {
171 |
172 | var start = dataOffset + face * faceLength;
173 | var normalX = reader.getFloat32( start, true );
174 | var normalY = reader.getFloat32( start + 4, true );
175 | var normalZ = reader.getFloat32( start + 8, true );
176 |
177 | if ( hasColors ) {
178 |
179 | var packedColor = reader.getUint16( start + 48, true );
180 |
181 | if ( ( packedColor & 0x8000 ) === 0 ) {
182 |
183 | // facet has its own unique color
184 |
185 | r = ( packedColor & 0x1F ) / 31;
186 | g = ( ( packedColor >> 5 ) & 0x1F ) / 31;
187 | b = ( ( packedColor >> 10 ) & 0x1F ) / 31;
188 |
189 | } else {
190 |
191 | r = defaultR;
192 | g = defaultG;
193 | b = defaultB;
194 |
195 | }
196 |
197 | }
198 |
199 | for ( var i = 1; i <= 3; i ++ ) {
200 |
201 | var vertexstart = start + i * 12;
202 |
203 | vertices.push( reader.getFloat32( vertexstart, true ) );
204 | vertices.push( reader.getFloat32( vertexstart + 4, true ) );
205 | vertices.push( reader.getFloat32( vertexstart + 8, true ) );
206 |
207 | normals.push( normalX, normalY, normalZ );
208 |
209 | if ( hasColors ) {
210 |
211 | colors.push( r, g, b );
212 |
213 | }
214 |
215 | }
216 |
217 | }
218 |
219 | geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) );
220 | geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) );
221 |
222 | if ( hasColors ) {
223 |
224 | geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( colors ), 3 ) );
225 | geometry.hasColors = true;
226 | geometry.alpha = alpha;
227 |
228 | }
229 |
230 | return geometry;
231 |
232 | }
233 |
234 | function parseASCII( data ) {
235 |
236 | var geometry = new THREE.BufferGeometry();
237 | var patternFace = /facet([\s\S]*?)endfacet/g;
238 | var faceCounter = 0;
239 |
240 | var patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
241 | var patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
242 | var patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
243 |
244 | var vertices = [];
245 | var normals = [];
246 |
247 | var normal = new THREE.Vector3();
248 |
249 | var result;
250 |
251 | while ( ( result = patternFace.exec( data ) ) !== null ) {
252 |
253 | var vertexCountPerFace = 0;
254 | var normalCountPerFace = 0;
255 |
256 | var text = result[ 0 ];
257 |
258 | while ( ( result = patternNormal.exec( text ) ) !== null ) {
259 |
260 | normal.x = parseFloat( result[ 1 ] );
261 | normal.y = parseFloat( result[ 2 ] );
262 | normal.z = parseFloat( result[ 3 ] );
263 | normalCountPerFace ++;
264 |
265 | }
266 |
267 | while ( ( result = patternVertex.exec( text ) ) !== null ) {
268 |
269 | vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
270 | normals.push( normal.x, normal.y, normal.z );
271 | vertexCountPerFace ++;
272 |
273 | }
274 |
275 | // every face have to own ONE valid normal
276 |
277 | if ( normalCountPerFace !== 1 ) {
278 |
279 | console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
280 |
281 | }
282 |
283 | // each face have to own THREE valid vertices
284 |
285 | if ( vertexCountPerFace !== 3 ) {
286 |
287 | console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
288 |
289 | }
290 |
291 | faceCounter ++;
292 |
293 | }
294 |
295 | geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
296 | geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
297 |
298 | return geometry;
299 |
300 | }
301 |
302 | function ensureString( buffer ) {
303 |
304 | if ( typeof buffer !== 'string' ) {
305 |
306 | return THREE.LoaderUtils.decodeText( new Uint8Array( buffer ) );
307 |
308 | }
309 |
310 | return buffer;
311 |
312 | }
313 |
314 | function ensureBinary( buffer ) {
315 |
316 | if ( typeof buffer === 'string' ) {
317 |
318 | var array_buffer = new Uint8Array( buffer.length );
319 | for ( var i = 0; i < buffer.length; i ++ ) {
320 |
321 | array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
322 |
323 | }
324 | return array_buffer.buffer || array_buffer;
325 |
326 | } else {
327 |
328 | return buffer;
329 |
330 | }
331 |
332 | }
333 |
334 | // start
335 |
336 | var binData = ensureBinary( data );
337 |
338 | return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
339 |
340 | }
341 |
342 | };
343 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/AMFLoader.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @author tamarintech / https://tamarintech.com
3 | *
4 | * Description: Early release of an AMF Loader following the pattern of the
5 | * example loaders in the three.js project.
6 | *
7 | * More information about the AMF format: http://amf.wikispaces.com
8 | *
9 | * Usage:
10 | * var loader = new AMFLoader();
11 | * loader.load('/path/to/project.amf', function(objecttree) {
12 | * scene.add(objecttree);
13 | * });
14 | *
15 | * Materials now supported, material colors supported
16 | * Zip support, requires jszip
17 | * No constellation support (yet)!
18 | *
19 | */
20 |
21 | THREE.AMFLoader = function ( manager ) {
22 |
23 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
24 |
25 | };
26 |
27 | THREE.AMFLoader.prototype = {
28 |
29 | constructor: THREE.AMFLoader,
30 |
31 | load: function ( url, onLoad, onProgress, onError ) {
32 |
33 | var scope = this;
34 |
35 | var loader = new THREE.FileLoader( scope.manager );
36 | loader.setPath( scope.path );
37 | loader.setResponseType( 'arraybuffer' );
38 | loader.load( url, function ( text ) {
39 |
40 | onLoad( scope.parse( text ) );
41 |
42 | }, onProgress, onError );
43 |
44 | },
45 |
46 | setPath: function ( value ) {
47 |
48 | this.path = value;
49 | return this;
50 |
51 | },
52 |
53 | parse: function ( data ) {
54 |
55 | function loadDocument( data ) {
56 |
57 | var view = new DataView( data );
58 | var magic = String.fromCharCode( view.getUint8( 0 ), view.getUint8( 1 ) );
59 |
60 | if ( magic === 'PK' ) {
61 |
62 | var zip = null;
63 | var file = null;
64 |
65 | console.log( 'THREE.AMFLoader: Loading Zip' );
66 |
67 | try {
68 |
69 | zip = new JSZip( data ); // eslint-disable-line no-undef
70 |
71 | } catch ( e ) {
72 |
73 | if ( e instanceof ReferenceError ) {
74 |
75 | console.log( 'THREE.AMFLoader: jszip missing and file is compressed.' );
76 | return null;
77 |
78 | }
79 |
80 | }
81 |
82 | for ( file in zip.files ) {
83 |
84 | if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
85 |
86 | break;
87 |
88 | }
89 |
90 | }
91 |
92 | console.log( 'THREE.AMFLoader: Trying to load file asset: ' + file );
93 | view = new DataView( zip.file( file ).asArrayBuffer() );
94 |
95 | }
96 |
97 | var fileText = THREE.LoaderUtils.decodeText( view );
98 | var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
99 |
100 | if ( xmlData.documentElement.nodeName.toLowerCase() !== 'amf' ) {
101 |
102 | console.log( 'THREE.AMFLoader: Error loading AMF - no AMF document found.' );
103 | return null;
104 |
105 | }
106 |
107 | return xmlData;
108 |
109 | }
110 |
111 | function loadDocumentScale( node ) {
112 |
113 | var scale = 1.0;
114 | var unit = 'millimeter';
115 |
116 | if ( node.documentElement.attributes.unit !== undefined ) {
117 |
118 | unit = node.documentElement.attributes.unit.value.toLowerCase();
119 |
120 | }
121 |
122 | var scaleUnits = {
123 | millimeter: 1.0,
124 | inch: 25.4,
125 | feet: 304.8,
126 | meter: 1000.0,
127 | micron: 0.001
128 | };
129 |
130 | if ( scaleUnits[ unit ] !== undefined ) {
131 |
132 | scale = scaleUnits[ unit ];
133 |
134 | }
135 |
136 | console.log( 'THREE.AMFLoader: Unit scale: ' + scale );
137 | return scale;
138 |
139 | }
140 |
141 | function loadMaterials( node ) {
142 |
143 | var matName = 'AMF Material';
144 | var matId = node.attributes.id.textContent;
145 | var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
146 |
147 | var loadedMaterial = null;
148 |
149 | for ( var i = 0; i < node.childNodes.length; i ++ ) {
150 |
151 | var matChildEl = node.childNodes[ i ];
152 |
153 | if ( matChildEl.nodeName === 'metadata' && matChildEl.attributes.type !== undefined ) {
154 |
155 | if ( matChildEl.attributes.type.value === 'name' ) {
156 |
157 | matName = matChildEl.textContent;
158 |
159 | }
160 |
161 | } else if ( matChildEl.nodeName === 'color' ) {
162 |
163 | color = loadColor( matChildEl );
164 |
165 | }
166 |
167 | }
168 |
169 | loadedMaterial = new THREE.MeshPhongMaterial( {
170 | flatShading: true,
171 | color: new THREE.Color( color.r, color.g, color.b ),
172 | name: matName
173 | } );
174 |
175 | if ( color.a !== 1.0 ) {
176 |
177 | loadedMaterial.transparent = true;
178 | loadedMaterial.opacity = color.a;
179 |
180 | }
181 |
182 | return { id: matId, material: loadedMaterial };
183 |
184 | }
185 |
186 | function loadColor( node ) {
187 |
188 | var color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
189 |
190 | for ( var i = 0; i < node.childNodes.length; i ++ ) {
191 |
192 | var matColor = node.childNodes[ i ];
193 |
194 | if ( matColor.nodeName === 'r' ) {
195 |
196 | color.r = matColor.textContent;
197 |
198 | } else if ( matColor.nodeName === 'g' ) {
199 |
200 | color.g = matColor.textContent;
201 |
202 | } else if ( matColor.nodeName === 'b' ) {
203 |
204 | color.b = matColor.textContent;
205 |
206 | } else if ( matColor.nodeName === 'a' ) {
207 |
208 | color.a = matColor.textContent;
209 |
210 | }
211 |
212 | }
213 |
214 | return color;
215 |
216 | }
217 |
218 | function loadMeshVolume( node ) {
219 |
220 | var volume = { name: '', triangles: [], materialid: null };
221 |
222 | var currVolumeNode = node.firstElementChild;
223 |
224 | if ( node.attributes.materialid !== undefined ) {
225 |
226 | volume.materialId = node.attributes.materialid.nodeValue;
227 |
228 | }
229 |
230 | while ( currVolumeNode ) {
231 |
232 | if ( currVolumeNode.nodeName === 'metadata' ) {
233 |
234 | if ( currVolumeNode.attributes.type !== undefined ) {
235 |
236 | if ( currVolumeNode.attributes.type.value === 'name' ) {
237 |
238 | volume.name = currVolumeNode.textContent;
239 |
240 | }
241 |
242 | }
243 |
244 | } else if ( currVolumeNode.nodeName === 'triangle' ) {
245 |
246 | var v1 = currVolumeNode.getElementsByTagName( 'v1' )[ 0 ].textContent;
247 | var v2 = currVolumeNode.getElementsByTagName( 'v2' )[ 0 ].textContent;
248 | var v3 = currVolumeNode.getElementsByTagName( 'v3' )[ 0 ].textContent;
249 |
250 | volume.triangles.push( v1, v2, v3 );
251 |
252 | }
253 |
254 | currVolumeNode = currVolumeNode.nextElementSibling;
255 |
256 | }
257 |
258 | return volume;
259 |
260 | }
261 |
262 | function loadMeshVertices( node ) {
263 |
264 | var vertArray = [];
265 | var normalArray = [];
266 | var currVerticesNode = node.firstElementChild;
267 |
268 | while ( currVerticesNode ) {
269 |
270 | if ( currVerticesNode.nodeName === 'vertex' ) {
271 |
272 | var vNode = currVerticesNode.firstElementChild;
273 |
274 | while ( vNode ) {
275 |
276 | if ( vNode.nodeName === 'coordinates' ) {
277 |
278 | var x = vNode.getElementsByTagName( 'x' )[ 0 ].textContent;
279 | var y = vNode.getElementsByTagName( 'y' )[ 0 ].textContent;
280 | var z = vNode.getElementsByTagName( 'z' )[ 0 ].textContent;
281 |
282 | vertArray.push( x, y, z );
283 |
284 | } else if ( vNode.nodeName === 'normal' ) {
285 |
286 | var nx = vNode.getElementsByTagName( 'nx' )[ 0 ].textContent;
287 | var ny = vNode.getElementsByTagName( 'ny' )[ 0 ].textContent;
288 | var nz = vNode.getElementsByTagName( 'nz' )[ 0 ].textContent;
289 |
290 | normalArray.push( nx, ny, nz );
291 |
292 | }
293 |
294 | vNode = vNode.nextElementSibling;
295 |
296 | }
297 |
298 | }
299 | currVerticesNode = currVerticesNode.nextElementSibling;
300 |
301 | }
302 |
303 | return { 'vertices': vertArray, 'normals': normalArray };
304 |
305 | }
306 |
307 | function loadObject( node ) {
308 |
309 | var objId = node.attributes.id.textContent;
310 | var loadedObject = { name: 'amfobject', meshes: [] };
311 | var currColor = null;
312 | var currObjNode = node.firstElementChild;
313 |
314 | while ( currObjNode ) {
315 |
316 | if ( currObjNode.nodeName === 'metadata' ) {
317 |
318 | if ( currObjNode.attributes.type !== undefined ) {
319 |
320 | if ( currObjNode.attributes.type.value === 'name' ) {
321 |
322 | loadedObject.name = currObjNode.textContent;
323 |
324 | }
325 |
326 | }
327 |
328 | } else if ( currObjNode.nodeName === 'color' ) {
329 |
330 | currColor = loadColor( currObjNode );
331 |
332 | } else if ( currObjNode.nodeName === 'mesh' ) {
333 |
334 | var currMeshNode = currObjNode.firstElementChild;
335 | var mesh = { vertices: [], normals: [], volumes: [], color: currColor };
336 |
337 | while ( currMeshNode ) {
338 |
339 | if ( currMeshNode.nodeName === 'vertices' ) {
340 |
341 | var loadedVertices = loadMeshVertices( currMeshNode );
342 |
343 | mesh.normals = mesh.normals.concat( loadedVertices.normals );
344 | mesh.vertices = mesh.vertices.concat( loadedVertices.vertices );
345 |
346 | } else if ( currMeshNode.nodeName === 'volume' ) {
347 |
348 | mesh.volumes.push( loadMeshVolume( currMeshNode ) );
349 |
350 | }
351 |
352 | currMeshNode = currMeshNode.nextElementSibling;
353 |
354 | }
355 |
356 | loadedObject.meshes.push( mesh );
357 |
358 | }
359 |
360 | currObjNode = currObjNode.nextElementSibling;
361 |
362 | }
363 |
364 | return { 'id': objId, 'obj': loadedObject };
365 |
366 | }
367 |
368 | var xmlData = loadDocument( data );
369 | var amfName = '';
370 | var amfAuthor = '';
371 | var amfScale = loadDocumentScale( xmlData );
372 | var amfMaterials = {};
373 | var amfObjects = {};
374 | var childNodes = xmlData.documentElement.childNodes;
375 |
376 | var i, j;
377 |
378 | for ( i = 0; i < childNodes.length; i ++ ) {
379 |
380 | var child = childNodes[ i ];
381 |
382 | if ( child.nodeName === 'metadata' ) {
383 |
384 | if ( child.attributes.type !== undefined ) {
385 |
386 | if ( child.attributes.type.value === 'name' ) {
387 |
388 | amfName = child.textContent;
389 |
390 | } else if ( child.attributes.type.value === 'author' ) {
391 |
392 | amfAuthor = child.textContent;
393 |
394 | }
395 |
396 | }
397 |
398 | } else if ( child.nodeName === 'material' ) {
399 |
400 | var loadedMaterial = loadMaterials( child );
401 |
402 | amfMaterials[ loadedMaterial.id ] = loadedMaterial.material;
403 |
404 | } else if ( child.nodeName === 'object' ) {
405 |
406 | var loadedObject = loadObject( child );
407 |
408 | amfObjects[ loadedObject.id ] = loadedObject.obj;
409 |
410 | }
411 |
412 | }
413 |
414 | var sceneObject = new THREE.Group();
415 | var defaultMaterial = new THREE.MeshPhongMaterial( { color: 0xaaaaff, flatShading: true } );
416 |
417 | sceneObject.name = amfName;
418 | sceneObject.userData.author = amfAuthor;
419 | sceneObject.userData.loader = 'AMF';
420 |
421 | for ( var id in amfObjects ) {
422 |
423 | var part = amfObjects[ id ];
424 | var meshes = part.meshes;
425 | var newObject = new THREE.Group();
426 | newObject.name = part.name || '';
427 |
428 | for ( i = 0; i < meshes.length; i ++ ) {
429 |
430 | var objDefaultMaterial = defaultMaterial;
431 | var mesh = meshes[ i ];
432 | var vertices = new THREE.Float32BufferAttribute( mesh.vertices, 3 );
433 | var normals = null;
434 |
435 | if ( mesh.normals.length ) {
436 |
437 | normals = new THREE.Float32BufferAttribute( mesh.normals, 3 );
438 |
439 | }
440 |
441 | if ( mesh.color ) {
442 |
443 | var color = mesh.color;
444 |
445 | objDefaultMaterial = defaultMaterial.clone();
446 | objDefaultMaterial.color = new THREE.Color( color.r, color.g, color.b );
447 |
448 | if ( color.a !== 1.0 ) {
449 |
450 | objDefaultMaterial.transparent = true;
451 | objDefaultMaterial.opacity = color.a;
452 |
453 | }
454 |
455 | }
456 |
457 | var volumes = mesh.volumes;
458 |
459 | for ( j = 0; j < volumes.length; j ++ ) {
460 |
461 | var volume = volumes[ j ];
462 | var newGeometry = new THREE.BufferGeometry();
463 | var material = objDefaultMaterial;
464 |
465 | newGeometry.setIndex( volume.triangles );
466 | newGeometry.addAttribute( 'position', vertices.clone() );
467 |
468 | if ( normals ) {
469 |
470 | newGeometry.addAttribute( 'normal', normals.clone() );
471 |
472 | }
473 |
474 | if ( amfMaterials[ volume.materialId ] !== undefined ) {
475 |
476 | material = amfMaterials[ volume.materialId ];
477 |
478 | }
479 |
480 | newGeometry.scale( amfScale, amfScale, amfScale );
481 | newObject.add( new THREE.Mesh( newGeometry, material.clone() ) );
482 |
483 | }
484 |
485 | }
486 |
487 | sceneObject.add( newObject );
488 |
489 | }
490 |
491 | return sceneObject;
492 |
493 | }
494 |
495 | };
496 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/LegacyJSONLoader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author mrdoob / http://mrdoob.com/
3 | * @author alteredq / http://alteredqualia.com/
4 | */
5 |
6 | THREE.LegacyJSONLoader = ( function () {
7 |
8 | function LegacyJSONLoader( manager ) {
9 |
10 | if ( typeof manager === 'boolean' ) {
11 |
12 | console.warn( 'THREE.JSONLoader: showStatus parameter has been removed from constructor.' );
13 | manager = undefined;
14 |
15 | }
16 |
17 | this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
18 |
19 | this.withCredentials = false;
20 |
21 | }
22 |
23 | Object.assign( LegacyJSONLoader.prototype, {
24 |
25 | crossOrigin: 'anonymous',
26 |
27 | load: function ( url, onLoad, onProgress, onError ) {
28 |
29 | var scope = this;
30 |
31 | var path = ( this.path === undefined ) ? THREE.LoaderUtils.extractUrlBase( url ) : this.path;
32 |
33 | var loader = new THREE.FileLoader( this.manager );
34 | loader.setPath( this.path );
35 | loader.setWithCredentials( this.withCredentials );
36 | loader.load( url, function ( text ) {
37 |
38 | var json = JSON.parse( text );
39 | var metadata = json.metadata;
40 |
41 | if ( metadata !== undefined ) {
42 |
43 | var type = metadata.type;
44 |
45 | if ( type !== undefined ) {
46 |
47 | if ( type.toLowerCase() === 'object' ) {
48 |
49 | console.error( 'THREE.JSONLoader: ' + url + ' should be loaded with THREE.ObjectLoader instead.' );
50 | return;
51 |
52 | }
53 |
54 | }
55 |
56 | }
57 |
58 | var object = scope.parse( json, path );
59 | onLoad( object.geometry, object.materials );
60 |
61 | }, onProgress, onError );
62 |
63 | },
64 |
65 | setPath: function ( value ) {
66 |
67 | this.path = value;
68 | return this;
69 |
70 | },
71 |
72 | setResourcePath: function ( value ) {
73 |
74 | this.resourcePath = value;
75 | return this;
76 |
77 | },
78 |
79 | setCrossOrigin: function ( value ) {
80 |
81 | this.crossOrigin = value;
82 | return this;
83 |
84 | },
85 |
86 | parse: ( function () {
87 |
88 | var _BlendingMode = {
89 | NoBlending: THREE.NoBlending,
90 | NormalBlending: THREE.NormalBlending,
91 | AdditiveBlending: THREE.AdditiveBlending,
92 | SubtractiveBlending: THREE.SubtractiveBlending,
93 | MultiplyBlending: THREE.MultiplyBlending,
94 | CustomBlending: THREE.CustomBlending
95 | };
96 |
97 | var _color = new THREE.Color();
98 | var _textureLoader = new THREE.TextureLoader();
99 | var _materialLoader = new THREE.MaterialLoader();
100 |
101 | function initMaterials( materials, texturePath, crossOrigin ) {
102 |
103 | var array = [];
104 |
105 | for ( var i = 0; i < materials.length; ++ i ) {
106 |
107 | array[ i ] = createMaterial( materials[ i ], texturePath, crossOrigin );
108 |
109 | }
110 |
111 | return array;
112 |
113 | }
114 |
115 | function createMaterial( m, texturePath, crossOrigin ) {
116 |
117 | // convert from old material format
118 |
119 | var textures = {};
120 |
121 | //
122 |
123 | var json = {
124 | uuid: THREE.Math.generateUUID(),
125 | type: 'MeshLambertMaterial'
126 | };
127 |
128 | for ( var name in m ) {
129 |
130 | var value = m[ name ];
131 |
132 | switch ( name ) {
133 |
134 | case 'DbgColor':
135 | case 'DbgIndex':
136 | case 'opticalDensity':
137 | case 'illumination':
138 | break;
139 | case 'DbgName':
140 | json.name = value;
141 | break;
142 | case 'blending':
143 | json.blending = _BlendingMode[ value ];
144 | break;
145 | case 'colorAmbient':
146 | case 'mapAmbient':
147 | console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' );
148 | break;
149 | case 'colorDiffuse':
150 | json.color = _color.fromArray( value ).getHex();
151 | break;
152 | case 'colorSpecular':
153 | json.specular = _color.fromArray( value ).getHex();
154 | break;
155 | case 'colorEmissive':
156 | json.emissive = _color.fromArray( value ).getHex();
157 | break;
158 | case 'specularCoef':
159 | json.shininess = value;
160 | break;
161 | case 'shading':
162 | if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial';
163 | if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';
164 | if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial';
165 | break;
166 | case 'mapDiffuse':
167 | json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin );
168 | break;
169 | case 'mapDiffuseRepeat':
170 | case 'mapDiffuseOffset':
171 | case 'mapDiffuseWrap':
172 | case 'mapDiffuseAnisotropy':
173 | break;
174 | case 'mapEmissive':
175 | json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin );
176 | break;
177 | case 'mapEmissiveRepeat':
178 | case 'mapEmissiveOffset':
179 | case 'mapEmissiveWrap':
180 | case 'mapEmissiveAnisotropy':
181 | break;
182 | case 'mapLight':
183 | json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin );
184 | break;
185 | case 'mapLightRepeat':
186 | case 'mapLightOffset':
187 | case 'mapLightWrap':
188 | case 'mapLightAnisotropy':
189 | break;
190 | case 'mapAO':
191 | json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin );
192 | break;
193 | case 'mapAORepeat':
194 | case 'mapAOOffset':
195 | case 'mapAOWrap':
196 | case 'mapAOAnisotropy':
197 | break;
198 | case 'mapBump':
199 | json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin );
200 | break;
201 | case 'mapBumpScale':
202 | json.bumpScale = value;
203 | break;
204 | case 'mapBumpRepeat':
205 | case 'mapBumpOffset':
206 | case 'mapBumpWrap':
207 | case 'mapBumpAnisotropy':
208 | break;
209 | case 'mapNormal':
210 | json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin );
211 | break;
212 | case 'mapNormalFactor':
213 | json.normalScale = value;
214 | break;
215 | case 'mapNormalRepeat':
216 | case 'mapNormalOffset':
217 | case 'mapNormalWrap':
218 | case 'mapNormalAnisotropy':
219 | break;
220 | case 'mapSpecular':
221 | json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin );
222 | break;
223 | case 'mapSpecularRepeat':
224 | case 'mapSpecularOffset':
225 | case 'mapSpecularWrap':
226 | case 'mapSpecularAnisotropy':
227 | break;
228 | case 'mapMetalness':
229 | json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin );
230 | break;
231 | case 'mapMetalnessRepeat':
232 | case 'mapMetalnessOffset':
233 | case 'mapMetalnessWrap':
234 | case 'mapMetalnessAnisotropy':
235 | break;
236 | case 'mapRoughness':
237 | json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin );
238 | break;
239 | case 'mapRoughnessRepeat':
240 | case 'mapRoughnessOffset':
241 | case 'mapRoughnessWrap':
242 | case 'mapRoughnessAnisotropy':
243 | break;
244 | case 'mapAlpha':
245 | json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin );
246 | break;
247 | case 'mapAlphaRepeat':
248 | case 'mapAlphaOffset':
249 | case 'mapAlphaWrap':
250 | case 'mapAlphaAnisotropy':
251 | break;
252 | case 'flipSided':
253 | json.side = THREE.BackSide;
254 | break;
255 | case 'doubleSided':
256 | json.side = THREE.DoubleSide;
257 | break;
258 | case 'transparency':
259 | console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' );
260 | json.opacity = value;
261 | break;
262 | case 'depthTest':
263 | case 'depthWrite':
264 | case 'colorWrite':
265 | case 'opacity':
266 | case 'reflectivity':
267 | case 'transparent':
268 | case 'visible':
269 | case 'wireframe':
270 | json[ name ] = value;
271 | break;
272 | case 'vertexColors':
273 | if ( value === true ) json.vertexColors = THREE.VertexColors;
274 | if ( value === 'face' ) json.vertexColors = THREE.FaceColors;
275 | break;
276 | default:
277 | console.error( 'THREE.Loader.createMaterial: Unsupported', name, value );
278 | break;
279 |
280 | }
281 |
282 | }
283 |
284 | if ( json.type === 'MeshBasicMaterial' ) delete json.emissive;
285 | if ( json.type !== 'MeshPhongMaterial' ) delete json.specular;
286 |
287 | if ( json.opacity < 1 ) json.transparent = true;
288 |
289 | _materialLoader.setTextures( textures );
290 |
291 | return _materialLoader.parse( json );
292 |
293 | }
294 |
295 | function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin ) {
296 |
297 | var fullPath = texturePath + path;
298 | var loader = THREE.Loader.Handlers.get( fullPath );
299 |
300 | var texture;
301 |
302 | if ( loader !== null ) {
303 |
304 | texture = loader.load( fullPath );
305 |
306 | } else {
307 |
308 | _textureLoader.setCrossOrigin( crossOrigin );
309 | texture = _textureLoader.load( fullPath );
310 |
311 | }
312 |
313 | if ( repeat !== undefined ) {
314 |
315 | texture.repeat.fromArray( repeat );
316 |
317 | if ( repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping;
318 | if ( repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping;
319 |
320 | }
321 |
322 | if ( offset !== undefined ) {
323 |
324 | texture.offset.fromArray( offset );
325 |
326 | }
327 |
328 | if ( wrap !== undefined ) {
329 |
330 | if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = THREE.RepeatWrapping;
331 | if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = THREE.MirroredRepeatWrapping;
332 |
333 | if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = THREE.RepeatWrapping;
334 | if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = THREE.MirroredRepeatWrapping;
335 |
336 | }
337 |
338 | if ( anisotropy !== undefined ) {
339 |
340 | texture.anisotropy = anisotropy;
341 |
342 | }
343 |
344 | var uuid = THREE.Math.generateUUID();
345 |
346 | textures[ uuid ] = texture;
347 |
348 | return uuid;
349 |
350 | }
351 |
352 | function parseModel( json, geometry ) {
353 |
354 | function isBitSet( value, position ) {
355 |
356 | return value & ( 1 << position );
357 |
358 | }
359 |
360 | var i, j, fi,
361 |
362 | offset, zLength,
363 |
364 | colorIndex, normalIndex, uvIndex, materialIndex,
365 |
366 | type,
367 | isQuad,
368 | hasMaterial,
369 | hasFaceVertexUv,
370 | hasFaceNormal, hasFaceVertexNormal,
371 | hasFaceColor, hasFaceVertexColor,
372 |
373 | vertex, face, faceA, faceB, hex, normal,
374 |
375 | uvLayer, uv, u, v,
376 |
377 | faces = json.faces,
378 | vertices = json.vertices,
379 | normals = json.normals,
380 | colors = json.colors,
381 |
382 | scale = json.scale,
383 |
384 | nUvLayers = 0;
385 |
386 |
387 | if ( json.uvs !== undefined ) {
388 |
389 | // disregard empty arrays
390 |
391 | for ( i = 0; i < json.uvs.length; i ++ ) {
392 |
393 | if ( json.uvs[ i ].length ) nUvLayers ++;
394 |
395 | }
396 |
397 | for ( i = 0; i < nUvLayers; i ++ ) {
398 |
399 | geometry.faceVertexUvs[ i ] = [];
400 |
401 | }
402 |
403 | }
404 |
405 | offset = 0;
406 | zLength = vertices.length;
407 |
408 | while ( offset < zLength ) {
409 |
410 | vertex = new THREE.Vector3();
411 |
412 | vertex.x = vertices[ offset ++ ] * scale;
413 | vertex.y = vertices[ offset ++ ] * scale;
414 | vertex.z = vertices[ offset ++ ] * scale;
415 |
416 | geometry.vertices.push( vertex );
417 |
418 | }
419 |
420 | offset = 0;
421 | zLength = faces.length;
422 |
423 | while ( offset < zLength ) {
424 |
425 | type = faces[ offset ++ ];
426 |
427 | isQuad = isBitSet( type, 0 );
428 | hasMaterial = isBitSet( type, 1 );
429 | hasFaceVertexUv = isBitSet( type, 3 );
430 | hasFaceNormal = isBitSet( type, 4 );
431 | hasFaceVertexNormal = isBitSet( type, 5 );
432 | hasFaceColor = isBitSet( type, 6 );
433 | hasFaceVertexColor = isBitSet( type, 7 );
434 |
435 | // console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
436 |
437 | if ( isQuad ) {
438 |
439 | faceA = new THREE.Face3();
440 | faceA.a = faces[ offset ];
441 | faceA.b = faces[ offset + 1 ];
442 | faceA.c = faces[ offset + 3 ];
443 |
444 | faceB = new THREE.Face3();
445 | faceB.a = faces[ offset + 1 ];
446 | faceB.b = faces[ offset + 2 ];
447 | faceB.c = faces[ offset + 3 ];
448 |
449 | offset += 4;
450 |
451 | if ( hasMaterial ) {
452 |
453 | materialIndex = faces[ offset ++ ];
454 | faceA.materialIndex = materialIndex;
455 | faceB.materialIndex = materialIndex;
456 |
457 | }
458 |
459 | // to get face <=> uv index correspondence
460 |
461 | fi = geometry.faces.length;
462 |
463 | if ( hasFaceVertexUv ) {
464 |
465 | for ( i = 0; i < nUvLayers; i ++ ) {
466 |
467 | uvLayer = json.uvs[ i ];
468 |
469 | geometry.faceVertexUvs[ i ][ fi ] = [];
470 | geometry.faceVertexUvs[ i ][ fi + 1 ] = [];
471 |
472 | for ( j = 0; j < 4; j ++ ) {
473 |
474 | uvIndex = faces[ offset ++ ];
475 |
476 | u = uvLayer[ uvIndex * 2 ];
477 | v = uvLayer[ uvIndex * 2 + 1 ];
478 |
479 | uv = new THREE.Vector2( u, v );
480 |
481 | if ( j !== 2 ) geometry.faceVertexUvs[ i ][ fi ].push( uv );
482 | if ( j !== 0 ) geometry.faceVertexUvs[ i ][ fi + 1 ].push( uv );
483 |
484 | }
485 |
486 | }
487 |
488 | }
489 |
490 | if ( hasFaceNormal ) {
491 |
492 | normalIndex = faces[ offset ++ ] * 3;
493 |
494 | faceA.normal.set(
495 | normals[ normalIndex ++ ],
496 | normals[ normalIndex ++ ],
497 | normals[ normalIndex ]
498 | );
499 |
500 | faceB.normal.copy( faceA.normal );
501 |
502 | }
503 |
504 | if ( hasFaceVertexNormal ) {
505 |
506 | for ( i = 0; i < 4; i ++ ) {
507 |
508 | normalIndex = faces[ offset ++ ] * 3;
509 |
510 | normal = new THREE.Vector3(
511 | normals[ normalIndex ++ ],
512 | normals[ normalIndex ++ ],
513 | normals[ normalIndex ]
514 | );
515 |
516 |
517 | if ( i !== 2 ) faceA.vertexNormals.push( normal );
518 | if ( i !== 0 ) faceB.vertexNormals.push( normal );
519 |
520 | }
521 |
522 | }
523 |
524 |
525 | if ( hasFaceColor ) {
526 |
527 | colorIndex = faces[ offset ++ ];
528 | hex = colors[ colorIndex ];
529 |
530 | faceA.color.setHex( hex );
531 | faceB.color.setHex( hex );
532 |
533 | }
534 |
535 |
536 | if ( hasFaceVertexColor ) {
537 |
538 | for ( i = 0; i < 4; i ++ ) {
539 |
540 | colorIndex = faces[ offset ++ ];
541 | hex = colors[ colorIndex ];
542 |
543 | if ( i !== 2 ) faceA.vertexColors.push( new THREE.Color( hex ) );
544 | if ( i !== 0 ) faceB.vertexColors.push( new THREE.Color( hex ) );
545 |
546 | }
547 |
548 | }
549 |
550 | geometry.faces.push( faceA );
551 | geometry.faces.push( faceB );
552 |
553 | } else {
554 |
555 | face = new THREE.Face3();
556 | face.a = faces[ offset ++ ];
557 | face.b = faces[ offset ++ ];
558 | face.c = faces[ offset ++ ];
559 |
560 | if ( hasMaterial ) {
561 |
562 | materialIndex = faces[ offset ++ ];
563 | face.materialIndex = materialIndex;
564 |
565 | }
566 |
567 | // to get face <=> uv index correspondence
568 |
569 | fi = geometry.faces.length;
570 |
571 | if ( hasFaceVertexUv ) {
572 |
573 | for ( i = 0; i < nUvLayers; i ++ ) {
574 |
575 | uvLayer = json.uvs[ i ];
576 |
577 | geometry.faceVertexUvs[ i ][ fi ] = [];
578 |
579 | for ( j = 0; j < 3; j ++ ) {
580 |
581 | uvIndex = faces[ offset ++ ];
582 |
583 | u = uvLayer[ uvIndex * 2 ];
584 | v = uvLayer[ uvIndex * 2 + 1 ];
585 |
586 | uv = new THREE.Vector2( u, v );
587 |
588 | geometry.faceVertexUvs[ i ][ fi ].push( uv );
589 |
590 | }
591 |
592 | }
593 |
594 | }
595 |
596 | if ( hasFaceNormal ) {
597 |
598 | normalIndex = faces[ offset ++ ] * 3;
599 |
600 | face.normal.set(
601 | normals[ normalIndex ++ ],
602 | normals[ normalIndex ++ ],
603 | normals[ normalIndex ]
604 | );
605 |
606 | }
607 |
608 | if ( hasFaceVertexNormal ) {
609 |
610 | for ( i = 0; i < 3; i ++ ) {
611 |
612 | normalIndex = faces[ offset ++ ] * 3;
613 |
614 | normal = new THREE.Vector3(
615 | normals[ normalIndex ++ ],
616 | normals[ normalIndex ++ ],
617 | normals[ normalIndex ]
618 | );
619 |
620 | face.vertexNormals.push( normal );
621 |
622 | }
623 |
624 | }
625 |
626 |
627 | if ( hasFaceColor ) {
628 |
629 | colorIndex = faces[ offset ++ ];
630 | face.color.setHex( colors[ colorIndex ] );
631 |
632 | }
633 |
634 |
635 | if ( hasFaceVertexColor ) {
636 |
637 | for ( i = 0; i < 3; i ++ ) {
638 |
639 | colorIndex = faces[ offset ++ ];
640 | face.vertexColors.push( new THREE.Color( colors[ colorIndex ] ) );
641 |
642 | }
643 |
644 | }
645 |
646 | geometry.faces.push( face );
647 |
648 | }
649 |
650 | }
651 |
652 | }
653 |
654 | function parseSkin( json, geometry ) {
655 |
656 | var influencesPerVertex = ( json.influencesPerVertex !== undefined ) ? json.influencesPerVertex : 2;
657 |
658 | if ( json.skinWeights ) {
659 |
660 | for ( var i = 0, l = json.skinWeights.length; i < l; i += influencesPerVertex ) {
661 |
662 | var x = json.skinWeights[ i ];
663 | var y = ( influencesPerVertex > 1 ) ? json.skinWeights[ i + 1 ] : 0;
664 | var z = ( influencesPerVertex > 2 ) ? json.skinWeights[ i + 2 ] : 0;
665 | var w = ( influencesPerVertex > 3 ) ? json.skinWeights[ i + 3 ] : 0;
666 |
667 | geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) );
668 |
669 | }
670 |
671 | }
672 |
673 | if ( json.skinIndices ) {
674 |
675 | for ( var i = 0, l = json.skinIndices.length; i < l; i += influencesPerVertex ) {
676 |
677 | var a = json.skinIndices[ i ];
678 | var b = ( influencesPerVertex > 1 ) ? json.skinIndices[ i + 1 ] : 0;
679 | var c = ( influencesPerVertex > 2 ) ? json.skinIndices[ i + 2 ] : 0;
680 | var d = ( influencesPerVertex > 3 ) ? json.skinIndices[ i + 3 ] : 0;
681 |
682 | geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) );
683 |
684 | }
685 |
686 | }
687 |
688 | geometry.bones = json.bones;
689 |
690 | if ( geometry.bones && geometry.bones.length > 0 && ( geometry.skinWeights.length !== geometry.skinIndices.length || geometry.skinIndices.length !== geometry.vertices.length ) ) {
691 |
692 | console.warn( 'When skinning, number of vertices (' + geometry.vertices.length + '), skinIndices (' +
693 | geometry.skinIndices.length + '), and skinWeights (' + geometry.skinWeights.length + ') should match.' );
694 |
695 | }
696 |
697 | }
698 |
699 | function parseMorphing( json, geometry ) {
700 |
701 | var scale = json.scale;
702 |
703 | if ( json.morphTargets !== undefined ) {
704 |
705 | for ( var i = 0, l = json.morphTargets.length; i < l; i ++ ) {
706 |
707 | geometry.morphTargets[ i ] = {};
708 | geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
709 | geometry.morphTargets[ i ].vertices = [];
710 |
711 | var dstVertices = geometry.morphTargets[ i ].vertices;
712 | var srcVertices = json.morphTargets[ i ].vertices;
713 |
714 | for ( var v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
715 |
716 | var vertex = new THREE.Vector3();
717 | vertex.x = srcVertices[ v ] * scale;
718 | vertex.y = srcVertices[ v + 1 ] * scale;
719 | vertex.z = srcVertices[ v + 2 ] * scale;
720 |
721 | dstVertices.push( vertex );
722 |
723 | }
724 |
725 | }
726 |
727 | }
728 |
729 | if ( json.morphColors !== undefined && json.morphColors.length > 0 ) {
730 |
731 | console.warn( 'THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.' );
732 |
733 | var faces = geometry.faces;
734 | var morphColors = json.morphColors[ 0 ].colors;
735 |
736 | for ( var i = 0, l = faces.length; i < l; i ++ ) {
737 |
738 | faces[ i ].color.fromArray( morphColors, i * 3 );
739 |
740 | }
741 |
742 | }
743 |
744 | }
745 |
746 | function parseAnimations( json, geometry ) {
747 |
748 | var outputAnimations = [];
749 |
750 | // parse old style Bone/Hierarchy animations
751 | var animations = [];
752 |
753 | if ( json.animation !== undefined ) {
754 |
755 | animations.push( json.animation );
756 |
757 | }
758 |
759 | if ( json.animations !== undefined ) {
760 |
761 | if ( json.animations.length ) {
762 |
763 | animations = animations.concat( json.animations );
764 |
765 | } else {
766 |
767 | animations.push( json.animations );
768 |
769 | }
770 |
771 | }
772 |
773 | for ( var i = 0; i < animations.length; i ++ ) {
774 |
775 | var clip = THREE.AnimationClip.parseAnimation( animations[ i ], geometry.bones );
776 | if ( clip ) outputAnimations.push( clip );
777 |
778 | }
779 |
780 | // parse implicit morph animations
781 | if ( geometry.morphTargets ) {
782 |
783 | // TODO: Figure out what an appropraite FPS is for morph target animations -- defaulting to 10, but really it is completely arbitrary.
784 | var morphAnimationClips = THREE.AnimationClip.CreateClipsFromMorphTargetSequences( geometry.morphTargets, 10 );
785 | outputAnimations = outputAnimations.concat( morphAnimationClips );
786 |
787 | }
788 |
789 | if ( outputAnimations.length > 0 ) geometry.animations = outputAnimations;
790 |
791 | }
792 |
793 | return function parse( json, path ) {
794 |
795 | if ( json.data !== undefined ) {
796 |
797 | // Geometry 4.0 spec
798 | json = json.data;
799 |
800 | }
801 |
802 | if ( json.scale !== undefined ) {
803 |
804 | json.scale = 1.0 / json.scale;
805 |
806 | } else {
807 |
808 | json.scale = 1.0;
809 |
810 | }
811 |
812 | var geometry = new THREE.Geometry();
813 |
814 | parseModel( json, geometry );
815 | parseSkin( json, geometry );
816 | parseMorphing( json, geometry );
817 | parseAnimations( json, geometry );
818 |
819 | geometry.computeFaceNormals();
820 | geometry.computeBoundingSphere();
821 |
822 | if ( json.materials === undefined || json.materials.length === 0 ) {
823 |
824 | return { geometry: geometry };
825 |
826 | } else {
827 |
828 | var materials = initMaterials( json.materials, this.resourcePath || path, this.crossOrigin );
829 |
830 | return { geometry: geometry, materials: materials };
831 |
832 | }
833 |
834 | };
835 |
836 | } )()
837 |
838 | } );
839 |
840 | return LegacyJSONLoader;
841 |
842 | } )();
843 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/OrbitControls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author qiao / https://github.com/qiao
3 | * @author mrdoob / http://mrdoob.com
4 | * @author alteredq / http://alteredqualia.com/
5 | * @author WestLangley / http://github.com/WestLangley
6 | * @author erich666 / http://erichaines.com
7 | */
8 |
9 | // This set of controls performs orbiting, dollying (zooming), and panning.
10 | // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
11 | //
12 | // Orbit - left mouse / touch: one-finger move
13 | // Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
14 | // Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move
15 |
16 | THREE.OrbitControls = function ( object, domElement ) {
17 |
18 | this.object = object;
19 |
20 | this.domElement = ( domElement !== undefined ) ? domElement : document;
21 |
22 | // Set to false to disable this control
23 | this.enabled = true;
24 |
25 | // "target" sets the location of focus, where the object orbits around
26 | this.target = new THREE.Vector3();
27 |
28 | // How far you can dolly in and out ( PerspectiveCamera only )
29 | this.minDistance = 0;
30 | this.maxDistance = Infinity;
31 |
32 | // How far you can zoom in and out ( OrthographicCamera only )
33 | this.minZoom = 0;
34 | this.maxZoom = Infinity;
35 |
36 | // How far you can orbit vertically, upper and lower limits.
37 | // Range is 0 to Math.PI radians.
38 | this.minPolarAngle = 0; // radians
39 | this.maxPolarAngle = Math.PI; // radians
40 |
41 | // How far you can orbit horizontally, upper and lower limits.
42 | // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
43 | this.minAzimuthAngle = - Infinity; // radians
44 | this.maxAzimuthAngle = Infinity; // radians
45 |
46 | // Set to true to enable damping (inertia)
47 | // If damping is enabled, you must call controls.update() in your animation loop
48 | this.enableDamping = false;
49 | this.dampingFactor = 0.25;
50 |
51 | // This option actually enables dollying in and out; left as "zoom" for backwards compatibility.
52 | // Set to false to disable zooming
53 | this.enableZoom = true;
54 | this.zoomSpeed = 1.0;
55 |
56 | // Set to false to disable rotating
57 | this.enableRotate = true;
58 | this.rotateSpeed = 1.0;
59 |
60 | // Set to false to disable panning
61 | this.enablePan = true;
62 | this.panSpeed = 1.0;
63 | this.screenSpacePanning = false; // if true, pan in screen-space
64 | this.keyPanSpeed = 7.0; // pixels moved per arrow key push
65 |
66 | // Set to true to automatically rotate around the target
67 | // If auto-rotate is enabled, you must call controls.update() in your animation loop
68 | this.autoRotate = false;
69 | this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
70 |
71 | // Set to false to disable use of the keys
72 | this.enableKeys = true;
73 |
74 | // The four arrow keys
75 | this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
76 |
77 | // Mouse buttons
78 | this.mouseButtons = { LEFT: THREE.MOUSE.LEFT, MIDDLE: THREE.MOUSE.MIDDLE, RIGHT: THREE.MOUSE.RIGHT };
79 |
80 | // for reset
81 | this.target0 = this.target.clone();
82 | this.position0 = this.object.position.clone();
83 | this.zoom0 = this.object.zoom;
84 |
85 | //
86 | // public methods
87 | //
88 |
89 | this.getPolarAngle = function () {
90 |
91 | return spherical.phi;
92 |
93 | };
94 |
95 | this.getAzimuthalAngle = function () {
96 |
97 | return spherical.theta;
98 |
99 | };
100 |
101 | this.saveState = function () {
102 |
103 | scope.target0.copy( scope.target );
104 | scope.position0.copy( scope.object.position );
105 | scope.zoom0 = scope.object.zoom;
106 |
107 | };
108 |
109 | this.reset = function () {
110 |
111 | scope.target.copy( scope.target0 );
112 | scope.object.position.copy( scope.position0 );
113 | scope.object.zoom = scope.zoom0;
114 |
115 | scope.object.updateProjectionMatrix();
116 | scope.dispatchEvent( changeEvent );
117 |
118 | scope.update();
119 |
120 | state = STATE.NONE;
121 |
122 | };
123 |
124 | // this method is exposed, but perhaps it would be better if we can make it private...
125 | this.update = function () {
126 |
127 | var offset = new THREE.Vector3();
128 |
129 | // so camera.up is the orbit axis
130 | var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
131 | var quatInverse = quat.clone().inverse();
132 |
133 | var lastPosition = new THREE.Vector3();
134 | var lastQuaternion = new THREE.Quaternion();
135 |
136 | return function update() {
137 |
138 | var position = scope.object.position;
139 |
140 | offset.copy( position ).sub( scope.target );
141 |
142 | // rotate offset to "y-axis-is-up" space
143 | offset.applyQuaternion( quat );
144 |
145 | // angle from z-axis around y-axis
146 | spherical.setFromVector3( offset );
147 |
148 | if ( scope.autoRotate && state === STATE.NONE ) {
149 |
150 | rotateLeft( getAutoRotationAngle() );
151 |
152 | }
153 |
154 | spherical.theta += sphericalDelta.theta;
155 | spherical.phi += sphericalDelta.phi;
156 |
157 | // restrict theta to be between desired limits
158 | spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );
159 |
160 | // restrict phi to be between desired limits
161 | spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
162 |
163 | spherical.makeSafe();
164 |
165 |
166 | spherical.radius *= scale;
167 |
168 | // restrict radius to be between desired limits
169 | spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
170 |
171 | // move target to panned location
172 | scope.target.add( panOffset );
173 |
174 | offset.setFromSpherical( spherical );
175 |
176 | // rotate offset back to "camera-up-vector-is-up" space
177 | offset.applyQuaternion( quatInverse );
178 |
179 | position.copy( scope.target ).add( offset );
180 |
181 | scope.object.lookAt( scope.target );
182 |
183 | if ( scope.enableDamping === true ) {
184 |
185 | sphericalDelta.theta *= ( 1 - scope.dampingFactor );
186 | sphericalDelta.phi *= ( 1 - scope.dampingFactor );
187 |
188 | panOffset.multiplyScalar( 1 - scope.dampingFactor );
189 |
190 | } else {
191 |
192 | sphericalDelta.set( 0, 0, 0 );
193 |
194 | panOffset.set( 0, 0, 0 );
195 |
196 | }
197 |
198 | scale = 1;
199 |
200 | // update condition is:
201 | // min(camera displacement, camera rotation in radians)^2 > EPS
202 | // using small-angle approximation cos(x/2) = 1 - x^2 / 8
203 |
204 | if ( zoomChanged ||
205 | lastPosition.distanceToSquared( scope.object.position ) > EPS ||
206 | 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {
207 |
208 | scope.dispatchEvent( changeEvent );
209 |
210 | lastPosition.copy( scope.object.position );
211 | lastQuaternion.copy( scope.object.quaternion );
212 | zoomChanged = false;
213 |
214 | return true;
215 |
216 | }
217 |
218 | return false;
219 |
220 | };
221 |
222 | }();
223 |
224 | this.dispose = function () {
225 |
226 | scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false );
227 | scope.domElement.removeEventListener( 'mousedown', onMouseDown, false );
228 | scope.domElement.removeEventListener( 'wheel', onMouseWheel, false );
229 |
230 | scope.domElement.removeEventListener( 'touchstart', onTouchStart, false );
231 | scope.domElement.removeEventListener( 'touchend', onTouchEnd, false );
232 | scope.domElement.removeEventListener( 'touchmove', onTouchMove, false );
233 |
234 | document.removeEventListener( 'mousemove', onMouseMove, false );
235 | document.removeEventListener( 'mouseup', onMouseUp, false );
236 |
237 | window.removeEventListener( 'keydown', onKeyDown, false );
238 |
239 | //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?
240 |
241 | };
242 |
243 | //
244 | // internals
245 | //
246 |
247 | var scope = this;
248 |
249 | var changeEvent = { type: 'change' };
250 | var startEvent = { type: 'start' };
251 | var endEvent = { type: 'end' };
252 |
253 | var STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY_PAN: 4 };
254 |
255 | var state = STATE.NONE;
256 |
257 | var EPS = 0.000001;
258 |
259 | // current position in spherical coordinates
260 | var spherical = new THREE.Spherical();
261 | var sphericalDelta = new THREE.Spherical();
262 |
263 | var scale = 1;
264 | var panOffset = new THREE.Vector3();
265 | var zoomChanged = false;
266 |
267 | var rotateStart = new THREE.Vector2();
268 | var rotateEnd = new THREE.Vector2();
269 | var rotateDelta = new THREE.Vector2();
270 |
271 | var panStart = new THREE.Vector2();
272 | var panEnd = new THREE.Vector2();
273 | var panDelta = new THREE.Vector2();
274 |
275 | var dollyStart = new THREE.Vector2();
276 | var dollyEnd = new THREE.Vector2();
277 | var dollyDelta = new THREE.Vector2();
278 |
279 | function getAutoRotationAngle() {
280 |
281 | return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
282 |
283 | }
284 |
285 | function getZoomScale() {
286 |
287 | return Math.pow( 0.95, scope.zoomSpeed );
288 |
289 | }
290 |
291 | function rotateLeft( angle ) {
292 |
293 | sphericalDelta.theta -= angle;
294 |
295 | }
296 |
297 | function rotateUp( angle ) {
298 |
299 | sphericalDelta.phi -= angle;
300 |
301 | }
302 |
303 | var panLeft = function () {
304 |
305 | var v = new THREE.Vector3();
306 |
307 | return function panLeft( distance, objectMatrix ) {
308 |
309 | v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix
310 | v.multiplyScalar( - distance );
311 |
312 | panOffset.add( v );
313 |
314 | };
315 |
316 | }();
317 |
318 | var panUp = function () {
319 |
320 | var v = new THREE.Vector3();
321 |
322 | return function panUp( distance, objectMatrix ) {
323 |
324 | if ( scope.screenSpacePanning === true ) {
325 |
326 | v.setFromMatrixColumn( objectMatrix, 1 );
327 |
328 | } else {
329 |
330 | v.setFromMatrixColumn( objectMatrix, 0 );
331 | v.crossVectors( scope.object.up, v );
332 |
333 | }
334 |
335 | v.multiplyScalar( distance );
336 |
337 | panOffset.add( v );
338 |
339 | };
340 |
341 | }();
342 |
343 | // deltaX and deltaY are in pixels; right and down are positive
344 | var pan = function () {
345 |
346 | var offset = new THREE.Vector3();
347 |
348 | return function pan( deltaX, deltaY ) {
349 |
350 | var element = scope.domElement === document ? document.body : scope.domElement;
351 |
352 | if ( scope.object.isPerspectiveCamera ) {
353 |
354 | // perspective
355 | var position = scope.object.position;
356 | offset.copy( position ).sub( scope.target );
357 | var targetDistance = offset.length();
358 |
359 | // half of the fov is center to top of screen
360 | targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
361 |
362 | // we use only clientHeight here so aspect ratio does not distort speed
363 | panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
364 | panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
365 |
366 | } else if ( scope.object.isOrthographicCamera ) {
367 |
368 | // orthographic
369 | panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
370 | panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
371 |
372 | } else {
373 |
374 | // camera neither orthographic nor perspective
375 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
376 | scope.enablePan = false;
377 |
378 | }
379 |
380 | };
381 |
382 | }();
383 |
384 | function dollyIn( dollyScale ) {
385 |
386 | if ( scope.object.isPerspectiveCamera ) {
387 |
388 | scale /= dollyScale;
389 |
390 | } else if ( scope.object.isOrthographicCamera ) {
391 |
392 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );
393 | scope.object.updateProjectionMatrix();
394 | zoomChanged = true;
395 |
396 | } else {
397 |
398 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
399 | scope.enableZoom = false;
400 |
401 | }
402 |
403 | }
404 |
405 | function dollyOut( dollyScale ) {
406 |
407 | if ( scope.object.isPerspectiveCamera ) {
408 |
409 | scale *= dollyScale;
410 |
411 | } else if ( scope.object.isOrthographicCamera ) {
412 |
413 | scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );
414 | scope.object.updateProjectionMatrix();
415 | zoomChanged = true;
416 |
417 | } else {
418 |
419 | console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
420 | scope.enableZoom = false;
421 |
422 | }
423 |
424 | }
425 |
426 | //
427 | // event callbacks - update the object state
428 | //
429 |
430 | function handleMouseDownRotate( event ) {
431 |
432 | //console.log( 'handleMouseDownRotate' );
433 |
434 | rotateStart.set( event.clientX, event.clientY );
435 |
436 | }
437 |
438 | function handleMouseDownDolly( event ) {
439 |
440 | //console.log( 'handleMouseDownDolly' );
441 |
442 | dollyStart.set( event.clientX, event.clientY );
443 |
444 | }
445 |
446 | function handleMouseDownPan( event ) {
447 |
448 | //console.log( 'handleMouseDownPan' );
449 |
450 | panStart.set( event.clientX, event.clientY );
451 |
452 | }
453 |
454 | function handleMouseMoveRotate( event ) {
455 |
456 | //console.log( 'handleMouseMoveRotate' );
457 |
458 | rotateEnd.set( event.clientX, event.clientY );
459 |
460 | rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
461 |
462 | var element = scope.domElement === document ? document.body : scope.domElement;
463 |
464 | rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
465 |
466 | rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
467 |
468 | rotateStart.copy( rotateEnd );
469 |
470 | scope.update();
471 |
472 | }
473 |
474 | function handleMouseMoveDolly( event ) {
475 |
476 | //console.log( 'handleMouseMoveDolly' );
477 |
478 | dollyEnd.set( event.clientX, event.clientY );
479 |
480 | dollyDelta.subVectors( dollyEnd, dollyStart );
481 |
482 | if ( dollyDelta.y > 0 ) {
483 |
484 | dollyIn( getZoomScale() );
485 |
486 | } else if ( dollyDelta.y < 0 ) {
487 |
488 | dollyOut( getZoomScale() );
489 |
490 | }
491 |
492 | dollyStart.copy( dollyEnd );
493 |
494 | scope.update();
495 |
496 | }
497 |
498 | function handleMouseMovePan( event ) {
499 |
500 | //console.log( 'handleMouseMovePan' );
501 |
502 | panEnd.set( event.clientX, event.clientY );
503 |
504 | panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
505 |
506 | pan( panDelta.x, panDelta.y );
507 |
508 | panStart.copy( panEnd );
509 |
510 | scope.update();
511 |
512 | }
513 |
514 | function handleMouseUp( event ) {
515 |
516 | // console.log( 'handleMouseUp' );
517 |
518 | }
519 |
520 | function handleMouseWheel( event ) {
521 |
522 | // console.log( 'handleMouseWheel' );
523 |
524 | if ( event.deltaY < 0 ) {
525 |
526 | dollyOut( getZoomScale() );
527 |
528 | } else if ( event.deltaY > 0 ) {
529 |
530 | dollyIn( getZoomScale() );
531 |
532 | }
533 |
534 | scope.update();
535 |
536 | }
537 |
538 | function handleKeyDown( event ) {
539 |
540 | // console.log( 'handleKeyDown' );
541 |
542 | var needsUpdate = false;
543 |
544 | switch ( event.keyCode ) {
545 |
546 | case scope.keys.UP:
547 | pan( 0, scope.keyPanSpeed );
548 | needsUpdate = true;
549 | break;
550 |
551 | case scope.keys.BOTTOM:
552 | pan( 0, - scope.keyPanSpeed );
553 | needsUpdate = true;
554 | break;
555 |
556 | case scope.keys.LEFT:
557 | pan( scope.keyPanSpeed, 0 );
558 | needsUpdate = true;
559 | break;
560 |
561 | case scope.keys.RIGHT:
562 | pan( - scope.keyPanSpeed, 0 );
563 | needsUpdate = true;
564 | break;
565 |
566 | }
567 |
568 | if ( needsUpdate ) {
569 |
570 | // prevent the browser from scrolling on cursor keys
571 | event.preventDefault();
572 |
573 | scope.update();
574 |
575 | }
576 |
577 |
578 | }
579 |
580 | function handleTouchStartRotate( event ) {
581 |
582 | //console.log( 'handleTouchStartRotate' );
583 |
584 | rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
585 |
586 | }
587 |
588 | function handleTouchStartDollyPan( event ) {
589 |
590 | //console.log( 'handleTouchStartDollyPan' );
591 |
592 | if ( scope.enableZoom ) {
593 |
594 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
595 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
596 |
597 | var distance = Math.sqrt( dx * dx + dy * dy );
598 |
599 | dollyStart.set( 0, distance );
600 |
601 | }
602 |
603 | if ( scope.enablePan ) {
604 |
605 | var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
606 | var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
607 |
608 | panStart.set( x, y );
609 |
610 | }
611 |
612 | }
613 |
614 | function handleTouchMoveRotate( event ) {
615 |
616 | //console.log( 'handleTouchMoveRotate' );
617 |
618 | rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
619 |
620 | rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );
621 |
622 | var element = scope.domElement === document ? document.body : scope.domElement;
623 |
624 | rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
625 |
626 | rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
627 |
628 | rotateStart.copy( rotateEnd );
629 |
630 | scope.update();
631 |
632 | }
633 |
634 | function handleTouchMoveDollyPan( event ) {
635 |
636 | //console.log( 'handleTouchMoveDollyPan' );
637 |
638 | if ( scope.enableZoom ) {
639 |
640 | var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
641 | var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
642 |
643 | var distance = Math.sqrt( dx * dx + dy * dy );
644 |
645 | dollyEnd.set( 0, distance );
646 |
647 | dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) );
648 |
649 | dollyIn( dollyDelta.y );
650 |
651 | dollyStart.copy( dollyEnd );
652 |
653 | }
654 |
655 | if ( scope.enablePan ) {
656 |
657 | var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );
658 | var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );
659 |
660 | panEnd.set( x, y );
661 |
662 | panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );
663 |
664 | pan( panDelta.x, panDelta.y );
665 |
666 | panStart.copy( panEnd );
667 |
668 | }
669 |
670 | scope.update();
671 |
672 | }
673 |
674 | function handleTouchEnd( event ) {
675 |
676 | //console.log( 'handleTouchEnd' );
677 |
678 | }
679 |
680 | //
681 | // event handlers - FSM: listen for events and reset state
682 | //
683 |
684 | function onMouseDown( event ) {
685 |
686 | if ( scope.enabled === false ) return;
687 |
688 | // Prevent the browser from scrolling.
689 |
690 | event.preventDefault();
691 |
692 | // Manually set the focus since calling preventDefault above
693 | // prevents the browser from setting it automatically.
694 |
695 | scope.domElement.focus ? scope.domElement.focus() : window.focus();
696 |
697 | switch ( event.button ) {
698 |
699 | case scope.mouseButtons.LEFT:
700 |
701 | if ( event.ctrlKey || event.metaKey || event.shiftKey ) {
702 |
703 | if ( scope.enablePan === false ) return;
704 |
705 | handleMouseDownPan( event );
706 |
707 | state = STATE.PAN;
708 |
709 | } else {
710 |
711 | if ( scope.enableRotate === false ) return;
712 |
713 | handleMouseDownRotate( event );
714 |
715 | state = STATE.ROTATE;
716 |
717 | }
718 |
719 | break;
720 |
721 | case scope.mouseButtons.MIDDLE:
722 |
723 | if ( scope.enableZoom === false ) return;
724 |
725 | handleMouseDownDolly( event );
726 |
727 | state = STATE.DOLLY;
728 |
729 | break;
730 |
731 | case scope.mouseButtons.RIGHT:
732 |
733 | if ( scope.enablePan === false ) return;
734 |
735 | handleMouseDownPan( event );
736 |
737 | state = STATE.PAN;
738 |
739 | break;
740 |
741 | }
742 |
743 | if ( state !== STATE.NONE ) {
744 |
745 | document.addEventListener( 'mousemove', onMouseMove, false );
746 | document.addEventListener( 'mouseup', onMouseUp, false );
747 |
748 | scope.dispatchEvent( startEvent );
749 |
750 | }
751 |
752 | }
753 |
754 | function onMouseMove( event ) {
755 |
756 | if ( scope.enabled === false ) return;
757 |
758 | event.preventDefault();
759 |
760 | switch ( state ) {
761 |
762 | case STATE.ROTATE:
763 |
764 | if ( scope.enableRotate === false ) return;
765 |
766 | handleMouseMoveRotate( event );
767 |
768 | break;
769 |
770 | case STATE.DOLLY:
771 |
772 | if ( scope.enableZoom === false ) return;
773 |
774 | handleMouseMoveDolly( event );
775 |
776 | break;
777 |
778 | case STATE.PAN:
779 |
780 | if ( scope.enablePan === false ) return;
781 |
782 | handleMouseMovePan( event );
783 |
784 | break;
785 |
786 | }
787 |
788 | }
789 |
790 | function onMouseUp( event ) {
791 |
792 | if ( scope.enabled === false ) return;
793 |
794 | handleMouseUp( event );
795 |
796 | document.removeEventListener( 'mousemove', onMouseMove, false );
797 | document.removeEventListener( 'mouseup', onMouseUp, false );
798 |
799 | scope.dispatchEvent( endEvent );
800 |
801 | state = STATE.NONE;
802 |
803 | }
804 |
805 | function onMouseWheel( event ) {
806 |
807 | if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;
808 |
809 | event.preventDefault();
810 | event.stopPropagation();
811 |
812 | scope.dispatchEvent( startEvent );
813 |
814 | handleMouseWheel( event );
815 |
816 | scope.dispatchEvent( endEvent );
817 |
818 | }
819 |
820 | function onKeyDown( event ) {
821 |
822 | if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;
823 |
824 | handleKeyDown( event );
825 |
826 | }
827 |
828 | function onTouchStart( event ) {
829 |
830 | if ( scope.enabled === false ) return;
831 |
832 | event.preventDefault();
833 |
834 | switch ( event.touches.length ) {
835 |
836 | case 1: // one-fingered touch: rotate
837 |
838 | if ( scope.enableRotate === false ) return;
839 |
840 | handleTouchStartRotate( event );
841 |
842 | state = STATE.TOUCH_ROTATE;
843 |
844 | break;
845 |
846 | case 2: // two-fingered touch: dolly-pan
847 |
848 | if ( scope.enableZoom === false && scope.enablePan === false ) return;
849 |
850 | handleTouchStartDollyPan( event );
851 |
852 | state = STATE.TOUCH_DOLLY_PAN;
853 |
854 | break;
855 |
856 | default:
857 |
858 | state = STATE.NONE;
859 |
860 | }
861 |
862 | if ( state !== STATE.NONE ) {
863 |
864 | scope.dispatchEvent( startEvent );
865 |
866 | }
867 |
868 | }
869 |
870 | function onTouchMove( event ) {
871 |
872 | if ( scope.enabled === false ) return;
873 |
874 | event.preventDefault();
875 | event.stopPropagation();
876 |
877 | switch ( event.touches.length ) {
878 |
879 | case 1: // one-fingered touch: rotate
880 |
881 | if ( scope.enableRotate === false ) return;
882 | if ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?
883 |
884 | handleTouchMoveRotate( event );
885 |
886 | break;
887 |
888 | case 2: // two-fingered touch: dolly-pan
889 |
890 | if ( scope.enableZoom === false && scope.enablePan === false ) return;
891 | if ( state !== STATE.TOUCH_DOLLY_PAN ) return; // is this needed?
892 |
893 | handleTouchMoveDollyPan( event );
894 |
895 | break;
896 |
897 | default:
898 |
899 | state = STATE.NONE;
900 |
901 | }
902 |
903 | }
904 |
905 | function onTouchEnd( event ) {
906 |
907 | if ( scope.enabled === false ) return;
908 |
909 | handleTouchEnd( event );
910 |
911 | scope.dispatchEvent( endEvent );
912 |
913 | state = STATE.NONE;
914 |
915 | }
916 |
917 | function onContextMenu( event ) {
918 |
919 | if ( scope.enabled === false ) return;
920 |
921 | event.preventDefault();
922 |
923 | }
924 |
925 | //
926 |
927 | scope.domElement.addEventListener( 'contextmenu', onContextMenu, false );
928 |
929 | scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
930 | scope.domElement.addEventListener( 'wheel', onMouseWheel, false );
931 |
932 | scope.domElement.addEventListener( 'touchstart', onTouchStart, false );
933 | scope.domElement.addEventListener( 'touchend', onTouchEnd, false );
934 | scope.domElement.addEventListener( 'touchmove', onTouchMove, false );
935 |
936 | window.addEventListener( 'keydown', onKeyDown, false );
937 |
938 | // force an update at start
939 |
940 | this.update();
941 |
942 | };
943 |
944 | THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
945 | THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
946 |
947 | Object.defineProperties( THREE.OrbitControls.prototype, {
948 |
949 | center: {
950 |
951 | get: function () {
952 |
953 | console.warn( 'THREE.OrbitControls: .center has been renamed to .target' );
954 | return this.target;
955 |
956 | }
957 |
958 | },
959 |
960 | // backward compatibility
961 |
962 | noZoom: {
963 |
964 | get: function () {
965 |
966 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
967 | return ! this.enableZoom;
968 |
969 | },
970 |
971 | set: function ( value ) {
972 |
973 | console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );
974 | this.enableZoom = ! value;
975 |
976 | }
977 |
978 | },
979 |
980 | noRotate: {
981 |
982 | get: function () {
983 |
984 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
985 | return ! this.enableRotate;
986 |
987 | },
988 |
989 | set: function ( value ) {
990 |
991 | console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );
992 | this.enableRotate = ! value;
993 |
994 | }
995 |
996 | },
997 |
998 | noPan: {
999 |
1000 | get: function () {
1001 |
1002 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
1003 | return ! this.enablePan;
1004 |
1005 | },
1006 |
1007 | set: function ( value ) {
1008 |
1009 | console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );
1010 | this.enablePan = ! value;
1011 |
1012 | }
1013 |
1014 | },
1015 |
1016 | noKeys: {
1017 |
1018 | get: function () {
1019 |
1020 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
1021 | return ! this.enableKeys;
1022 |
1023 | },
1024 |
1025 | set: function ( value ) {
1026 |
1027 | console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );
1028 | this.enableKeys = ! value;
1029 |
1030 | }
1031 |
1032 | },
1033 |
1034 | staticMoving: {
1035 |
1036 | get: function () {
1037 |
1038 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
1039 | return ! this.enableDamping;
1040 |
1041 | },
1042 |
1043 | set: function ( value ) {
1044 |
1045 | console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );
1046 | this.enableDamping = ! value;
1047 |
1048 | }
1049 |
1050 | },
1051 |
1052 | dynamicDampingFactor: {
1053 |
1054 | get: function () {
1055 |
1056 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
1057 | return this.dampingFactor;
1058 |
1059 | },
1060 |
1061 | set: function ( value ) {
1062 |
1063 | console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );
1064 | this.dampingFactor = value;
1065 |
1066 | }
1067 |
1068 | }
1069 |
1070 | } );
1071 |
--------------------------------------------------------------------------------
/sphinxcadquery/sphinxcadquerystatic/jszip.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 |
3 | JSZip - A Javascript class for generating and reading zip files
4 |
5 |
6 | (c) 2009-2014 Stuart Knightley
7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
8 |
9 | JSZip uses the library pako released under the MIT license :
10 | https://github.com/nodeca/pako/blob/master/LICENSE
11 | */
12 | !function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":8}],4:[function(a,b){"use strict";var c=a("./utils"),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var e="string"!==c.getTypeOf(a);"undefined"==typeof b&&(b=0);var f=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=e?a[i]:a.charCodeAt(i),g=255&(b^h),f=d[g],b=b>>>8^f;return-1^b}},{"./utils":21}],5:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":21}],6:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!1,c.date=null,c.compression=null,c.comment=null},{}],7:[function(a,b,c){"use strict";var d=a("./utils");c.string2binary=function(a){return d.string2binary(a)},c.string2Uint8Array=function(a){return d.transformTo("uint8array",a)},c.uint8Array2String=function(a){return d.transformTo("string",a)},c.string2Blob=function(a){var b=d.transformTo("arraybuffer",a);return d.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){return d.arrayBuffer2Blob(a)},c.transformTo=function(a,b){return d.transformTo(a,b)},c.getTypeOf=function(a){return d.getTypeOf(a)},c.checkSupport=function(a){return d.checkSupport(a)},c.MAX_VALUE_16BITS=d.MAX_VALUE_16BITS,c.MAX_VALUE_32BITS=d.MAX_VALUE_32BITS,c.pretty=function(a){return d.pretty(a)},c.findCompression=function(a){return d.findCompression(a)},c.isRegExp=function(a){return d.isRegExp(a)}},{"./utils":21}],8:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("pako");c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a){return e.deflateRaw(a)},c.uncompress=function(a){return e.inflateRaw(a)}},{pako:24}],9:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.comment=null,this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}var d=a("./base64");c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./deprecatedPublicUtils"),c.base64={encode:function(a){return d.encode(a)},decode:function(a){return d.decode(a)}},c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},t=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},x=function(a,b){return"/"!=a.slice(-1)&&(a+="/"),b="undefined"!=typeof b?b:!1,this.files[a]||v.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},y=function(a,b){var c,f=new j;return a._data instanceof j?(f.uncompressedSize=a._data.uncompressedSize,f.crc32=a._data.crc32,0===f.uncompressedSize||a.dir?(b=i.STORE,f.compressedContent="",f.crc32=0):a._data.compressionMethod===b.magic?f.compressedContent=a._data.getCompressedContent():(c=a._data.getContent(),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c)))):(c=p(a),(!c||0===c.length||a.dir)&&(b=i.STORE,c=""),f.uncompressedSize=c.length,f.crc32=e(c),f.compressedContent=b.compress(d.transformTo(b.compressInputType,c))),f.compressedSize=f.compressedContent.length,f.compressionMethod=b.magic,f},z=function(a,b,c,g){var h,i,j,k,m=(c.compressedContent,d.transformTo("string",l.utf8encode(b.name))),n=b.comment||"",o=d.transformTo("string",l.utf8encode(n)),p=m.length!==b.name.length,q=o.length!==n.length,r=b.options,t="",u="",v="";j=b._initialMetadata.dir!==b.dir?b.dir:r.dir,k=b._initialMetadata.date!==b.date?b.date:r.date,h=k.getHours(),h<<=6,h|=k.getMinutes(),h<<=5,h|=k.getSeconds()/2,i=k.getFullYear()-1980,i<<=4,i|=k.getMonth()+1,i<<=5,i|=k.getDate(),p&&(u=s(1,1)+s(e(m),4)+m,t+="up"+s(u.length,2)+u),q&&(v=s(1,1)+s(this.crc32(o),4)+o,t+="uc"+s(v.length,2)+v);var w="";w+="\n\x00",w+=p||q?"\x00\b":"\x00\x00",w+=c.compressionMethod,w+=s(h,2),w+=s(i,2),w+=s(c.crc32,4),w+=s(c.compressedSize,4),w+=s(c.uncompressedSize,4),w+=s(m.length,2),w+=s(t.length,2);var x=f.LOCAL_FILE_HEADER+w+m+t,y=f.CENTRAL_FILE_HEADER+"\x00"+w+s(o.length,2)+"\x00\x00\x00\x00"+(j===!0?"\x00\x00\x00":"\x00\x00\x00\x00")+s(g,4)+m+t+o;return{fileRecord:x,dirRecord:y,compressedObject:c}},A={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new r(d.name,d._data,t(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(d.isRegExp(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}return this.filter(function(b,c){return!c.dir&&b===a})[0]||null}return a=this.root+a,v.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d.isRegExp(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=x.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5}],19:[function(a,b){"use strict";var c=a("./utils"),d=function(a){this.data=new Uint8Array(a),this.index=0};d.prototype={append:function(a){0!==a.length&&(a=c.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}},b.exports=d},{"./utils":21}],20:[function(a,b,c){"use strict";for(var d=a("./utils"),e=a("./support"),f=a("./nodeBuffer"),g=new Array(256),h=0;256>h;h++)g[h]=h>=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;g[254]=g[254]=1;var i=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=e.uint8array?new Uint8Array(i):new Array(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},j=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+g[a[c]]>b?c:b},k=function(a){var b,c,e,f,h=a.length,i=new Array(2*h);for(c=0,b=0;h>b;)if(e=a[b++],128>e)i[c++]=e;else if(f=g[e],f>4)i[c++]=65533,b+=f-1;else{for(e&=2===f?31:3===f?15:7;f>1&&h>b;)e=e<<6|63&a[b++],f--;f>1?i[c++]=65533:65536>e?i[c++]=e:(e-=65536,i[c++]=55296|e>>10&1023,i[c++]=56320|1023&e)}return i.length!==c&&(i.subarray?i=i.subarray(0,c):i.length=c),d.applyFromCharCode(i)};c.utf8encode=function(a){return e.nodebuffer?f(a,"utf-8"):i(a)},c.utf8decode=function(a){if(e.nodebuffer)return d.transformTo("nodebuffer",a).toString("utf-8");a=d.transformTo(e.uint8array?"uint8array":"array",a);for(var b=[],c=0,f=a.length,g=65536;f>c;){var h=j(a,Math.min(c+g,f));b.push(e.uint8array?k(a.subarray(c,h)):k(a.slice(c,h))),c=h}return b.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support"),k=a("./object");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=k.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=g.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==n)throw new Error(j[c]);b.header&&g.deflateSetHeader(this.strm,b.header)
13 | };s.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?m:l,e.input="string"==typeof a?i.string2buf(a):a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new h.Buf8(f),e.next_out=0,e.avail_out=f),c=g.deflate(e,d),c!==o&&c!==n)return this.onEnd(c),this.ended=!0,!1;(0===e.avail_out||0===e.avail_in&&d===m)&&this.onData("string"===this.options.to?i.buf2binstring(h.shrinkBuf(e.output,e.next_out)):h.shrinkBuf(e.output,e.next_out))}while((e.avail_in>0||0===e.avail_out)&&c!==o);return d===m?(c=g.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===n):!0},s.prototype.onData=function(a){this.chunks.push(a)},s.prototype.onEnd=function(a){a===n&&(this.result="string"===this.options.to?this.chunks.join(""):h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=e,c.gzip=f},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(a,b,c){"use strict";function d(a,b){var c=new m(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,m=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,l.input="string"==typeof a?h.binstring2buf(a):a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(m),l.next_out=0,l.avail_out=m),c=f.inflate(l,i.Z_NO_FLUSH),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&d===i.Z_FINISH)&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=m-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out)))}while(l.avail_in>0&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):!0},m.prototype.onData=function(a){this.chunks.push(a)},m.prototype.onEnd=function(a){a===i.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=m,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],28:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":27}],29:[function(a,b){"use strict";function c(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=c},{}],30:[function(a,b){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(a,b){"use strict";function c(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function d(a,b,c,d){var f=e,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^f[255&(a^b[h])];return-1^a}var e=c();b.exports=d},{}],32:[function(a,b,c){"use strict";function d(a,b){return a.msg=G[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(C.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){D._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,C.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=E(a.adler,b,e,c):2===a.state.wrap&&(a.adler=F(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-jb?a.strstart-(a.w_size-jb):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ib,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ib-(m-f),f=m-ib,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-jb)){C.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=hb)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===H)return sb;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return sb;if(a.strstart-a.block_start>=a.w_size-jb&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?sb:sb}function o(a,b){for(var c,d;;){if(a.lookahead=hb&&(a.ins_h=(a.ins_h<=hb)if(d=D._tr_tally(a,a.strstart-a.match_start,a.match_length-hb),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=hb){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<=hb&&(a.ins_h=(a.ins_h<4096)&&(a.match_length=hb-1)),a.prev_length>=hb&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-hb,d=D._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-hb),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<=hb&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ib;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ib-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=hb?(c=D._tr_tally(a,1,a.match_length-hb),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===H)return sb;break}if(a.match_length=0,c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function s(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=B[a.level].max_lazy,a.good_match=B[a.level].good_length,a.nice_match=B[a.level].nice_length,a.max_chain_length=B[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=hb-1,a.match_available=0,a.ins_h=0}function t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*fb),this.dyn_dtree=new C.Buf16(2*(2*db+1)),this.bl_tree=new C.Buf16(2*(2*eb+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(gb+1),this.heap=new C.Buf16(2*cb+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*cb+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function u(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=X,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?lb:qb,a.adler=2===b.wrap?0:1,b.last_flush=H,D._tr_init(b),M):d(a,O)}function v(a){var b=u(a);return b===M&&s(a.state),b}function w(a,b){return a&&a.state?2!==a.state.wrap?O:(a.state.gzhead=b,M):O}function x(a,b,c,e,f,g){if(!a)return O;var h=1;if(b===R&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>Z||c!==Y||8>e||e>15||0>b||b>9||0>g||g>V)return d(a,O);8===e&&(e=9);var i=new t;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,v(a)}function y(a,b){return x(a,b,Y,$,_,W)}function z(a,b){var c,h,k,l;if(!a||!a.state||b>L||0>b)return a?d(a,O):O;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===rb&&b!==K)return d(a,0===a.avail_out?Q:O);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===lb)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=F(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=mb):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,wb),h.status=qb);else{var m=Y+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=T||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=kb),m+=31-m%31,h.status=qb,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===mb)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=nb)}else h.status=nb;if(h.status===nb)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=ob)}else h.status=ob;if(h.status===ob)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=pb)}else h.status=pb;if(h.status===pb&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=qb)):h.status=qb),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,M}else if(0===a.avail_in&&e(b)<=e(c)&&b!==K)return d(a,Q);if(h.status===rb&&0!==a.avail_in)return d(a,Q);if(0!==a.avail_in||0!==h.lookahead||b!==H&&h.status!==rb){var o=h.strategy===T?r(h,b):h.strategy===U?q(h,b):B[h.level].func(h,b);if((o===ub||o===vb)&&(h.status=rb),o===sb||o===ub)return 0===a.avail_out&&(h.last_flush=-1),M;if(o===tb&&(b===I?D._tr_align(h):b!==L&&(D._tr_stored_block(h,0,0,!1),b===J&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,M}return b!==K?M:h.wrap<=0?N:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?M:N)}function A(a){var b;return a&&a.state?(b=a.state.status,b!==lb&&b!==mb&&b!==nb&&b!==ob&&b!==pb&&b!==qb&&b!==rb?d(a,O):(a.state=null,b===qb?d(a,P):M)):O}var B,C=a("../utils/common"),D=a("./trees"),E=a("./adler32"),F=a("./crc32"),G=a("./messages"),H=0,I=1,J=3,K=4,L=5,M=0,N=1,O=-2,P=-3,Q=-5,R=-1,S=1,T=2,U=3,V=4,W=0,X=2,Y=8,Z=9,$=15,_=8,ab=29,bb=256,cb=bb+1+ab,db=30,eb=19,fb=2*cb+1,gb=15,hb=3,ib=258,jb=ib+hb+1,kb=32,lb=42,mb=69,nb=73,ob=91,pb=103,qb=113,rb=666,sb=1,tb=2,ub=3,vb=4,wb=3,xb=function(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e};B=[new xb(0,0,0,0,n),new xb(4,4,8,4,o),new xb(4,5,16,8,o),new xb(4,6,32,32,o),new xb(4,4,16,16,p),new xb(8,16,32,32,p),new xb(8,16,128,128,p),new xb(8,32,128,256,p),new xb(32,128,258,1024,p),new xb(32,258,258,4096,p)],c.deflateInit=y,c.deflateInit2=x,c.deflateReset=v,c.deflateResetKeep=u,c.deflateSetHeader=w,c.deflate=z,c.deflateEnd=A,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(a,b){"use strict";function c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=c},{}],34:[function(a,b){"use strict";var c=30,d=12;b.exports=function(a,b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;e=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=e.dmax,l=e.wsize,m=e.whave,n=e.wnext,o=e.window,p=e.hold,q=e.bits,r=e.lencode,s=e.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1);break}for(c.back=0;Ab=c.lencode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a;
14 | if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b<>V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b<>>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1<>=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1<=b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++jj){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)});
--------------------------------------------------------------------------------