Compare commits
102 Commits
feat-color
...
lgpl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6014fface6 | ||
|
|
2ef5e47c27 | ||
|
|
337618d6ef | ||
|
|
832e8cd4bd | ||
|
|
28869645cd | ||
|
|
da8eb6f76e | ||
|
|
0e3a359108 | ||
|
|
af89535a91 | ||
|
|
8d244596ba | ||
|
|
2a23e83c13 | ||
|
|
7b8272795d | ||
|
|
4d8b4bfb21 | ||
|
|
ebf8845e83 | ||
|
|
f863ac902c | ||
|
|
75123e6bc8 | ||
|
|
d5d7d2a650 | ||
|
|
d22c25ea8a | ||
|
|
acef664b45 | ||
|
|
9e8db0379b | ||
|
|
032bb57517 | ||
|
|
f0fc39d2c8 | ||
|
|
2df32cb643 | ||
|
|
904d449006 | ||
|
|
2594aff1b6 | ||
|
|
547c5422d4 | ||
|
|
9bcc93877b | ||
|
|
3f6f247735 | ||
|
|
c6c7ad44c9 | ||
|
|
cdc1733c4f | ||
|
|
6e40dbbfc1 | ||
|
|
e03b16119b | ||
|
|
e3162426be | ||
|
|
5a285dabed | ||
|
|
2d04730623 | ||
|
|
390c9096d7 | ||
|
|
0e9998a7fc | ||
|
|
22cfc972e2 | ||
|
|
a1386c2a13 | ||
|
|
7bdf0cc912 | ||
|
|
634d652c54 | ||
|
|
a10699c271 | ||
|
|
52b0b6fc4f | ||
|
|
9739b87439 | ||
|
|
9db098ce6a | ||
|
|
b35f79ad0a | ||
|
|
6cab5f9efd | ||
|
|
556388e260 | ||
|
|
e186713aa1 | ||
|
|
97995834bf | ||
|
|
11a87901e1 | ||
|
|
5948e6063b | ||
|
|
a91b2154a1 | ||
|
|
c6c17f0ba2 | ||
|
|
6879c22b02 | ||
|
|
48802d4494 | ||
|
|
5c6405bf8b | ||
|
|
e4689cf674 | ||
|
|
a4fad91abf | ||
|
|
0462a451b3 | ||
|
|
1dca5b1845 | ||
|
|
d73cc1c66d | ||
|
|
560696a6e1 | ||
|
|
258bc47d47 | ||
|
|
729f86066e | ||
|
|
86002f3e89 | ||
|
|
9ea92b3bff | ||
|
|
f9722a69ff | ||
|
|
c1dcb4b7e6 | ||
|
|
a1a8142b32 | ||
|
|
4294976105 | ||
|
|
12947ba9c9 | ||
|
|
dd7ae10e0d | ||
|
|
610d22fd23 | ||
|
|
9558bae25c | ||
|
|
dd00d0db27 | ||
|
|
1b10c59dca | ||
|
|
f9b23d286c | ||
|
|
809a53e694 | ||
|
|
d6583e47ef | ||
|
|
0c9c315f69 | ||
|
|
3454083449 | ||
|
|
311fa84919 | ||
|
|
3d445e4f6f | ||
|
|
950d0c693e | ||
|
|
895aa169b4 | ||
|
|
9201aff1ce | ||
|
|
9f70766c75 | ||
|
|
3726ca028c | ||
|
|
347e09ff70 | ||
|
|
e1f85bab97 | ||
|
|
5d6e113c19 | ||
|
|
2f9a1f297d | ||
|
|
0d2c0889a1 | ||
|
|
0cbd0c9f23 | ||
|
|
16a1e808a2 | ||
|
|
7b718eae96 | ||
|
|
221132ee1a | ||
|
|
f796a4c036 | ||
|
|
5d20bf3946 | ||
|
|
5d449b6185 | ||
|
|
89e3eb7e0a | ||
|
|
05f1ae2808 |
2
.github/workflows/npm-publish.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
npm install
|
||||
- name: "Build Aladin Lite"
|
||||
run: |
|
||||
npm run build
|
||||
npm run build:npm
|
||||
- name: "Publish Aladin Lite to npm"
|
||||
run: |
|
||||
npm publish
|
||||
|
||||
4
.github/workflows/test.yml
vendored
@@ -25,6 +25,10 @@ jobs:
|
||||
- name: "Install wasm-pack"
|
||||
run: |
|
||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -y
|
||||
- name: "Run cargo clippy"
|
||||
run: cd src/core && cargo clippy --all-targets --features=webgl2 -- -D warnings
|
||||
- name: Format check
|
||||
run: cd src/core && cargo fmt --all -- --check
|
||||
- name: "Install dependencies"
|
||||
run: |
|
||||
npm install
|
||||
|
||||
8
.gitignore
vendored
@@ -15,9 +15,11 @@ package-lock.json
|
||||
src/core/Cargo.lock
|
||||
src/core/target/
|
||||
|
||||
# this rust file is generated when compiling the code, so it is not
|
||||
# useful to put it on git
|
||||
src/core/src/shaders.rs
|
||||
# the tmp glsl files used when minifying the shaders into the wasm (build.rs)
|
||||
src/glsl/webgl2/**/*.min
|
||||
src/glsl/webgl2/**/*.tmp
|
||||
|
||||
package/
|
||||
|
||||
## python related
|
||||
# python environment
|
||||
|
||||
37
CHANGELOG.md
@@ -4,11 +4,42 @@
|
||||
|
||||
### What's Changed
|
||||
|
||||
* [perf] perform CPU computations with Vec3 and Matrix3 and not 4 dimensions matrices/vectors
|
||||
* [feat] lockNorthUp Aladin object new option locking the north pole up to the view center
|
||||
|
||||
## Released
|
||||
|
||||
### 3.8.0
|
||||
|
||||
* [fix] horizontal/vertical overlay lines appearing correctly <https://github.com/cds-astro/aladin-lite/issues/334>
|
||||
* [fix] layer opacity restored when switching from not visible to visible <https://github.com/cds-astro/aladin-lite/issues/332>
|
||||
* [feat] dark/light mode for the interface
|
||||
* [fix] polylines shapes size not consistent w.r.t to div size <https://github.com/cds-astro/aladin-lite/issues/331>
|
||||
* [feat] HiPS browser searching tree first version
|
||||
* [license] License change from GPLv3 to LGPLv3-or-later
|
||||
|
||||
### 3.7.0-beta
|
||||
|
||||
#### What's Changed
|
||||
|
||||
* [feat] flip longitude axis global method on Aladin by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/245>
|
||||
* [feat] add rotation event by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/283>
|
||||
* [docs] just fixing typo in image's doc by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/284>
|
||||
* [docs] change to an image with correct astrometry in example by [@ManonMarchand][ManonMarchand] in <https://github.com/cds-astro/aladin-lite/pull/290>
|
||||
* [docs] clarify use of precision in Coo by [@alexgoff][alexgoff] in <https://github.com/cds-astro/aladin-lite/pull/294>
|
||||
* [feat] allow setting HiPS CORS and credential options by [@pmatsson][pmatsson] in <https://github.com/cds-astro/aladin-lite/pull/281>
|
||||
* [feat] color picker and read pixel(s) API methods by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/280>
|
||||
* [fix] chandra hips display and akari by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/306>
|
||||
* [enhancement] update to the new version of fitsrs by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/310>
|
||||
* [fix] 26 channel color offset by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/320>
|
||||
* [fix] Circle intersectsBBox by [@emellega][emellega] in <https://github.com/cds-astro/aladin-lite/pull/309>
|
||||
* [feat] anti aliasing on lines plotted by the GPU by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/239>
|
||||
* [feat] source custom color and size from its data content by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/321>
|
||||
* [feat] catalog new select method by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/322>
|
||||
* [feat] HiPS 3D impl by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/314>
|
||||
* [feat] customize share URL function by [@tboch][tboch] in <https://github.com/cds-astro/aladin-lite/pull/327>
|
||||
* enhancement: use TAP entry point to query NED by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/257>
|
||||
* [perf] refac geometrical computations using Vec3/Mat3 instead of Vec4/Mat4 [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/276>
|
||||
* [fix] distortion at poles by [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/247>
|
||||
* [feat] new aladin option `lockNorthUp` to keep north pole up [@bmatthieu3][bmatthieu3] in <https://github.com/cds-astro/aladin-lite/pull/272>
|
||||
|
||||
### 3.6.3
|
||||
|
||||
#### What's Changed
|
||||
|
||||
304
COPYING.LESSER
Normal file
@@ -0,0 +1,304 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
964
LICENSE
@@ -1,674 +1,304 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
|
||||
4. Combined Works.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
17
README.md
@@ -1,4 +1,4 @@
|
||||
# [Aladin Lite](https://aladin.u-strasbg.fr/AladinLite)
|
||||
# [Aladin Lite](https://aladin.cds.unistra.fr/AladinLite)
|
||||
|
||||
**An astronomical HiPS visualizer in the browser** <img src="aladin-logo.png" alt="Aladin Lite logo" width="220">
|
||||
|
||||
@@ -8,14 +8,20 @@ See [A&A 578, A114 (2015)](https://arxiv.org/abs/1505.02291) and [IVOA HiPS Reco
|
||||
|
||||
Aladin Lite is built to be easily embeddable in any web page. It powers astronomical portals like [ESASky](https://sky.esa.int/), [ESO Science Archive portal](http://archive.eso.org/scienceportal/) and [ALMA Portal](https://almascience.eso.org/asax/).
|
||||
|
||||
More details on [Aladin Lite documentation page](http://aladin.u-strasbg.fr/AladinLite/doc/).
|
||||
More details on [Aladin Lite documentation page](http://aladin.cds.unistra.fr/AladinLite/doc/).
|
||||
A new [API technical documentation](https://cds-astro.github.io/aladin-lite/) is now available.
|
||||
|
||||
[](https://github.com/cds-astro/aladin-lite/actions/workflows/test.yml)
|
||||
[](https://cds-astro.github.io/aladin-lite)
|
||||
[](https://aladin.cds.unistra.fr/AladinLite/doc/release/)
|
||||
|
||||
Aladin Lite is available [at this link](https://aladin.u-strasbg.fr/AladinLite).
|
||||
Try Aladin Lite [here](https://aladin.cds.unistra.fr/AladinLite).
|
||||
|
||||
Aladin Lite is made possible thanks to pure Rust core libraries:
|
||||
* [cdshealpix](https://github.com/cds-astro/cds-healpix-rust) - for HEALPix projection and unprojection to/from sky coordinates
|
||||
* [mapproj](https://github.com/cds-astro/cds-mapproj-rust) - for computing (un)projections described by a WCS
|
||||
* [fitsrs](https://github.com/cds-astro/fitsrs) - for reading and parsing FITS images
|
||||
* [moc](https://github.com/cds-astro/cds-moc-rust) - for parsing, manipulating, and serializing multi-order HEALPix coverage maps
|
||||
|
||||
## Running & editable JS examples
|
||||
|
||||
@@ -102,14 +108,15 @@ Aladin Lite can be imported with:
|
||||
* [X] FITS images support
|
||||
* [X] WCS parsing, displaying an (JPEG/PNG) image in aladin lite view
|
||||
* [X] Display customized shapes (e.g. proper motions) from astronomical catalog data
|
||||
* [X] AVM tags parsing support
|
||||
* [X] AVM tags parsing support inside JPEG
|
||||
* [X] Easy sharing of current « view »
|
||||
* [ ] All VOTable serializations
|
||||
* [ ] FITS tables
|
||||
* [X] Creating HiPS instance from an URL
|
||||
* [X] Local HiPS loading
|
||||
* [X] Multiple mirrors handling for HiPS tile retrival
|
||||
* [ ] HiPS cube
|
||||
* [X] HiPS cube
|
||||
* [ ] HiPS3D
|
||||
|
||||
## Licence
|
||||
|
||||
|
||||
8
assets/icons/color-picker.svg
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<rect x="0" fill="none" width="20" height="20"/>
|
||||
|
||||
<g>
|
||||
|
After Width: | Height: | Size: 529 B |
4
assets/icons/folder.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 1H5L8 3H13V5H3.7457L2.03141 11H4.11144L5.2543 7H16L14 14H0V1Z" fill="#000000"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 322 B |
10
assets/icons/search-dark.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M15.7955 15.8111L21 21M18 10.5C18 14.6421 14.6421 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5Z"
|
||||
stroke="#ffffff"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 393 B |
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15.7955 15.8111L21 21M18 10.5C18 14.6421 14.6421 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5Z" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 455 B |
@@ -1,4 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M15.7955 15.8111L21 21M18 10.5C18 14.6421 14.6421 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M15.7955 15.8111L21 21M18 10.5C18 14.6421 14.6421 18 10.5 18C6.35786 18 3 14.6421 3 10.5C3 6.35786 6.35786 3 10.5 3C14.6421 3 18 6.35786 18 10.5Z"
|
||||
stroke="#000000"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 469 B After Width: | Height: | Size: 393 B |
@@ -1,6 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.1546 3.36026C12.4835 3.00999 11.5741 3.00459 10.8976 3.35396C8.30466 4.6931 5.95279 6.22853 3.89182 7.93154C3.57311 8.19489 3.34693 8.57758 3.35079 9.02802C3.35463 9.47662 3.58541 9.85419 3.90218 10.1132C5.94604 11.7844 8.29985 13.3212 10.8453 14.6497C11.5165 15 12.4258 15.0054 13.1023 14.656C15.6953 13.3169 18.0472 11.7815 20.1081 10.0785C20.4268 9.8151 20.653 9.43242 20.6492 8.98197C20.6453 8.53338 20.4145 8.1558 20.0978 7.89679C18.0539 6.22562 15.7001 4.6888 13.1546 3.36026ZM11.5859 4.68671C11.8256 4.56294 12.2193 4.56411 12.4606 4.69004C14.8899 5.95796 17.1283 7.41666 19.0675 8.99223C17.1167 10.5932 14.885 12.0471 12.414 13.3233C12.1744 13.4471 11.7807 13.4459 11.5394 13.32C9.11004 12.052 6.87163 10.5933 4.9324 9.01777C6.88321 7.41684 9.11496 5.96285 11.5859 4.68671Z" fill="#000000"/>
|
||||
<path d="M21.197 12.698C21.4164 13.0494 21.3094 13.512 20.958 13.7314L14.8508 17.5443C14.022 18.0617 12.9938 18.3009 11.9999 18.301C11.006 18.301 9.9777 18.0619 9.14884 17.5446L3.10851 13.7749C2.75711 13.5556 2.65003 13.093 2.86934 12.7416C3.08864 12.3902 3.55128 12.2831 3.90268 12.5024L9.94301 16.2721C10.4872 16.6117 11.2264 16.801 11.9998 16.801C12.7732 16.8009 13.5124 16.6116 14.0564 16.2719L20.1636 12.459C20.515 12.2397 20.9776 12.3467 21.197 12.698Z" fill="#000000"/>
|
||||
<path d="M21.197 16.4527C21.4164 16.804 21.3094 17.2667 20.9581 17.4861L15.6692 20.7889C14.6115 21.4494 13.2886 21.7602 11.9998 21.7602C10.7111 21.7603 9.38808 21.4497 8.3303 20.7894L3.10843 17.5296C2.75706 17.3102 2.65004 16.8476 2.86938 16.4962C3.08873 16.1448 3.55139 16.0378 3.90276 16.2572L9.12462 19.517C9.89764 19.9995 10.9316 20.2603 11.9998 20.2602C13.068 20.2602 14.1018 19.9993 14.8746 19.5167L20.1635 16.2138C20.5149 15.9944 20.9776 16.1013 21.197 16.4527Z" fill="#000000"/>
|
||||
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5">
|
||||
<path d="m1.75 11 6.25 3.25 6.25-3.25m-12.5-3 6.25 3.25 6.25-3.25m-6.25-6.25-6.25 3.25 6.25 3.25 6.25-3.25z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 437 B |
15
assets/icons/swap.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<title>swap-vertical-circle</title>
|
||||
<g id="Layer_2" data-name="Layer 2">
|
||||
<g id="invisible_box" data-name="invisible box">
|
||||
<rect width="48" height="48" fill="none"/>
|
||||
</g>
|
||||
<g id="icons_Q2" data-name="icons Q2">
|
||||
<path d="M19.4,36.4l5-4.9a2.1,2.1,0,0,0,.2-2.7,1.9,1.9,0,0,0-3-.2L20,30.2V15a2,2,0,0,0-4,0V30.2l-1.6-1.6a1.9,1.9,0,0,0-3,.2,2.1,2.1,0,0,0,.2,2.7l5,4.9A1.9,1.9,0,0,0,19.4,36.4Z"/>
|
||||
<path d="M32,33V17.8l1.6,1.6a1.9,1.9,0,0,0,3-.2,2.1,2.1,0,0,0-.2-2.7l-5-4.9a1.9,1.9,0,0,0-2.8,0l-5,4.9a2.1,2.1,0,0,0-.2,2.7,1.9,1.9,0,0,0,3,.2L28,17.8V33a2,2,0,0,0,4,0Z"/>
|
||||
<path d="M24,42A18,18,0,1,1,42,24,18.1,18.1,0,0,1,24,42m0,4A22,22,0,1,0,2,24,21.9,21.9,0,0,0,24,46Z"/>
|
||||
</g>
|
||||
</g>
|
||||
|
After Width: | Height: | Size: 948 B |
@@ -8,8 +8,8 @@
|
||||
"dateModified": "2023-01-31",
|
||||
"issueTracker": "https://github.com/cds-astro/aladin-lite/issues",
|
||||
"name": "Aladin Lite",
|
||||
"version": "3.6.5",
|
||||
"softwareVersion": "3.6.5",
|
||||
"version": "3.7.3-beta",
|
||||
"softwareVersion": "3.7.3-beta",
|
||||
"description": "An astronomical HiPS visualizer in the browser.",
|
||||
"identifier": "10.5281/zenodo.7638833",
|
||||
"applicationCategory": "Astronomy, Visualization",
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
aladin = A.aladin('#aladin-lite-div', {showSettingsControl: true, survey: "P/PanSTARRS/DR1/color-z-zg-g", showReticle: false, projection: "AIT", cooFrame: 'icrs', target: "stephan's quintet", fov: startFov, showGotoControl: false, showFrame: false, fullScreen: true, showLayersControl: true, showCooGridControl: false});
|
||||
|
||||
const chft = aladin.createImageSurvey('CFHT', "CFHT deep view of NGC7331 and Stephan's quintet u+g+r", "https://cds.unistra.fr/~derriere/PR_HiPS/2022_Duc/", null, null, {imgFormat: 'png'});
|
||||
const nircamJWST = aladin.createImageSurvey('Nircam', "Stephans Quintet NIRCam+MIRI", "http://alasky.cds.unistra.fr/JWST/CDS_P_JWST_Stephans-Quintet_NIRCam+MIRI/", null, null, {imgFormat: 'png', colormap: "viridis"});
|
||||
const nircamJWST = aladin.createImageSurvey('Nircam', "Stephans Quintet NIRCam+MIRI", "https://alasky.cds.unistra.fr/JWST/CDS_P_JWST_Stephans-Quintet_NIRCam-MIRI/", null, null, {imgFormat: 'png', colormap: "viridis"});
|
||||
|
||||
aladin.setOverlayImageLayer("CFHT", "CFHT");
|
||||
aladin.setOverlayImageLayer("Nircam", "Nircam");
|
||||
@@ -30,7 +30,7 @@
|
||||
fov *= 0.997;
|
||||
rotation += 0.07;
|
||||
|
||||
aladin.setViewCenter2NorthPoleAngle(rotation)
|
||||
aladin.setRotation(rotation)
|
||||
aladin.setFoV(fov);
|
||||
|
||||
if (fov < 3 && fov > 0.5) {
|
||||
|
||||
@@ -10,8 +10,6 @@ import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
let aladin = A.aladin('#aladin-lite-div', {projection: "TAN", survey: "P/HSC/DR2/deep/g", target: '02 21 36.529 -05 31 20.16', fov: 0.1});
|
||||
|
||||
aladin.reverseLongitude(true)
|
||||
|
||||
let hscGreenSurvey = aladin.getBaseImageLayer();
|
||||
hscGreenSurvey.setImageFormat("fits");
|
||||
hscGreenSurvey.setColormap("green", { stretch: "asinh" });
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<script type="module">
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
let aladin = A.aladin('#aladin-lite-div', {fov: 70,projection: "AIT"});
|
||||
let aladin = A.aladin('#aladin-lite-div', {target: "23 28 32.46 -00 10 38.9", fov: 4, projection: "AIT"});
|
||||
|
||||
let hsc = aladin.newImageSurvey("P/HSC/DR2/deep/g", {colormap:"Purples", imgFormat: "fits"});
|
||||
aladin.setBaseImageLayer(hsc);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import A from '../src/js/A.js';
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {survey: 'P/DSS2/red', target: 'M50', fov: 0.3});
|
||||
aladin = A.aladin('#aladin-lite-div', {survey: 'P/DSS2/red', target: '05 23 07.72 -69 46 09.1', fov: 0.3});
|
||||
|
||||
var customImg = new Image();
|
||||
customImg.onload = function() {
|
||||
|
||||
@@ -26,8 +26,17 @@
|
||||
limit: 1000,
|
||||
//orderBy: 'nb_ref',
|
||||
onClick: 'showTable',
|
||||
color: 'yellow',
|
||||
hoverColor: 'blue',
|
||||
onlyFootprints: false,
|
||||
color: (s) => {
|
||||
let coo = A.coo();
|
||||
coo.parse(s.data['RAJ2000'] + ' ' + s.data['DEJ2000'])
|
||||
|
||||
let a = (0.1 * Math.pow(10, +s.data.logD25)) / 60;
|
||||
let b = (1.0 / Math.pow(10, +s.data.logR25)) * a
|
||||
|
||||
return `rgb(${s.data["logR25"]*255.0}, ${s.data["logR25"]*255.0}, 255)`
|
||||
},
|
||||
hoverColor: 'red',
|
||||
shape: (s) => {
|
||||
let coo = A.coo();
|
||||
coo.parse(s.data['RAJ2000'] + ' ' + s.data['DEJ2000'])
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
fov: 10,
|
||||
showContextMenu: true,
|
||||
fullScreen: true,
|
||||
showSimbadPointerControl: true,
|
||||
showShareControl: true,
|
||||
showSettingsControl: true,
|
||||
showStackLayerControl: true,
|
||||
samp: true,
|
||||
@@ -31,15 +29,21 @@
|
||||
hoverColor: 'yellow',
|
||||
selectionColor: 'white',
|
||||
// Footprint associated to sources
|
||||
shape: (s) => {
|
||||
color: (s) => {
|
||||
// discard drawing a vector for big pm
|
||||
let totalPmSquared = s.data.pmra*s.data.pmra + s.data.pmdec*s.data.pmdec;
|
||||
if (totalPmSquared > 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
let color = rainbowColorMap((totalPmSquared - 2.5) / 2)
|
||||
|
||||
return rainbowColorMap((totalPmSquared - 2.5) / 2)
|
||||
},
|
||||
shape: (s) => {
|
||||
// discard drawing a vector for big pm
|
||||
let totalPmSquared = s.data.pmra*s.data.pmra + s.data.pmdec*s.data.pmdec;
|
||||
if (totalPmSquared > 6) {
|
||||
return;
|
||||
}
|
||||
// Compute the mean of pm over the catalog sources
|
||||
if (!pmraMean || !pmdecMean) {
|
||||
pmraMean = 0, pmdecMean = 0;
|
||||
@@ -62,13 +66,24 @@
|
||||
s.dec,
|
||||
s.ra + dra,
|
||||
s.dec + ddec,
|
||||
{color}
|
||||
)
|
||||
}
|
||||
},
|
||||
() => {
|
||||
aladin.addCatalog(pmCat);
|
||||
|
||||
pmCat.select((s) => {
|
||||
let totalPmSquared = s.data.pmra*s.data.pmra + s.data.pmdec*s.data.pmdec;
|
||||
if (totalPmSquared > 6) {
|
||||
return false;
|
||||
}
|
||||
return totalPmSquared < 3.0;
|
||||
});
|
||||
});
|
||||
aladin.addCatalog(pmCat);
|
||||
});
|
||||
|
||||
|
||||
|
||||
function rainbowColorMap(value) {
|
||||
// Ensure value is within range [0, 1]
|
||||
value = Math.max(0, Math.min(1, value));
|
||||
|
||||
@@ -37,7 +37,10 @@
|
||||
colorPicker.value = cat.color;
|
||||
colorPicker.addEventListener('input', function (e) {
|
||||
// Change the color of the catalog
|
||||
cat.updateShape({color: this.value});
|
||||
console.log(this.value)
|
||||
cat.updateShape({color: () => {
|
||||
return '#00ff00'
|
||||
}});
|
||||
})
|
||||
|
||||
// Define the box
|
||||
|
||||
22
examples/al-customize-share-url-fn.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, height=device-height, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
|
||||
</head>
|
||||
<body>
|
||||
<div id="aladin-lite-div" style="width: 500px; height: 500px"></div>
|
||||
|
||||
<script type="text/javascript" src="./../dist/aladin.umd.cjs" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
var aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {fullScreen: true, cooFrame: "ICRSd", showSimbadPointerControl: true, showShareControl: true, showShareControl: true, survey: 'https://alasky.cds.unistra.fr/DSS/DSSColor/', fov: 1.0, target: 'M 20', showContextMenu: true});
|
||||
|
||||
// customize share URL function
|
||||
aladin.customizeShareURLFunction(() => {return 'https://sky.esa.int/esasky/?target=' + aladin.getRaDec()[0] + '%20' + aladin.getRaDec()[1] + '&fov=' + aladin.getFoV()[0]})
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,12 +10,12 @@
|
||||
import A from '../src/js/A.js';
|
||||
var aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {projection: 'AIT', cooFrame: 'galactic', fov: 200, target: 'galactic center'});
|
||||
aladin = A.aladin('#aladin-lite-div', {projection: 'AIT', cooFrame: 'galactic', fov: 200, target: 'galactic center', showSettingsControl: true, showCooGridControl: true});
|
||||
let dss = aladin.createImageSurvey("DSS blue band", "Color DSS blue HiPS", "http://alasky.cds.unistra.fr/DSS/DSS2-blue-XJ-S/", "equatorial", 9, {imgFormat: 'fits'})
|
||||
|
||||
aladin.setBaseImageLayer(dss);
|
||||
|
||||
dss.setCuts(2, 10000);
|
||||
dss.setCuts(2, 100, 'jpeg');
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
import A from '../src/js/A.js';
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {cooFrame: "icrs", log: false, backgroundColor: 'red'});
|
||||
aladin = A.aladin('#aladin-lite-div', {cooFrame: "icrs", log: false, backgroundColor: 'rgba(0, 0, 0, 255)'});
|
||||
|
||||
aladin.displayFITS(
|
||||
//'https://fits.gsfc.nasa.gov/samples/FOCx38i0101t_c0f.fits', // url of the fits file
|
||||
'data/fits/panstarrs-g-m61.fits',
|
||||
//'https://almascience.eso.org/dataPortal/member.uid___A001_X88f_X297.calibrated_final_cont_Sgr_B1off.pbcor.fits',
|
||||
{
|
||||
name: 'm61',
|
||||
colormap: 'viridis'
|
||||
|
||||
@@ -39,7 +39,7 @@ Image Opacity: <br/> <input id="slider" type="range" value=1 min=0 max=1 step=0.
|
||||
//let fits = aladin.displayFITS('http://goldmine.mib.infn.it/data//B/fits/A04_VC1316_ooooog.fits', 'overlay');
|
||||
let jpg = aladin.displayJPG(
|
||||
// the JPG to transform to HiPS
|
||||
'https://noirlab.edu/public/media/archives/images/large/noirlab1912a.jpg',
|
||||
'https://owncloud.tuebingen.mpg.de/index.php/s/sdxfNgcEaaXoBp7/download/nightskycam3_2025_08_07_05_17_30_healpix1024_red.fits',
|
||||
// no options
|
||||
{
|
||||
transparency: 1.0,
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
console.log(proj)
|
||||
});
|
||||
|
||||
aladin.on('positionChanged', function(pos) {
|
||||
console.log(pos)
|
||||
});
|
||||
|
||||
aladin.on('layerChanged', function(imageLayer, layer, state){
|
||||
console.log(imageLayer, layer, state)
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
A.init.then(() => {
|
||||
// Start up Aladin Lite
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'M 1', fov: 0.2, showContextMenu: true, fullScreen: true});
|
||||
var overlay = A.graphicOverlay({color: '#ee2345', lineWidth: 3, lineDash: [2, 2]});
|
||||
var overlay = A.graphicOverlay({color: 'purple', lineWidth: 3, lineDash: [2, 2]});
|
||||
aladin.addOverlay(overlay);
|
||||
overlay.addFootprints([
|
||||
A.polygon([[83.64287, 22.01713], [83.59872, 22.01692], [83.59852, 21.97629], [83.64295, 21.97629]], {hoverColor: 'green'}),
|
||||
|
||||
62
examples/al-hips-3D.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div id="aladin-lite-div" style="width: 768px; height: 512px"></div>
|
||||
<script>let aladin; let hips;</script>
|
||||
<script type="module">
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin(
|
||||
'#aladin-lite-div',
|
||||
{
|
||||
showSimbadPointerControl: true,
|
||||
projection: 'AIT', // set a projection
|
||||
fov: 8.0, // initial field of view in degrees
|
||||
target: '10.6875598 +41.1402170', // initial target
|
||||
cooFrame: 'icrs', // set galactic frame
|
||||
reticleColor: '#ff89ff', // change reticle color
|
||||
showContextMenu: true,
|
||||
showFrame: true,
|
||||
showZoomControl:true,
|
||||
showSettingsControl:true,
|
||||
fullScreen: true,
|
||||
samp: true,
|
||||
}
|
||||
);
|
||||
|
||||
hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/HIPS3D/LGLBSHI-test-compression/", {
|
||||
successCallback: (hips) => {
|
||||
//hips.setFrequency({value: 6.374279333565797E-7, unit: "m"}) // GALFA
|
||||
}
|
||||
});
|
||||
// compressed https://alasky.cds.unistra.fr/test-compression-cubes/DHIGLS/
|
||||
//hips = aladin.newImageSurvey("http://alasky.cds.unistra.fr/DHIGLS");
|
||||
//hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/MUSE3D");
|
||||
// http://alasky.cds.unistra.fr/LGLBSHI
|
||||
aladin.setImageLayer(hips)
|
||||
|
||||
//hips.setFrequency({value: emMin + delta * i, unit: "m"})
|
||||
//hips.setFrequency({value: 6.374279333565797E-7, unit: "m"}) // MUSE
|
||||
//hips.setFrequency({value: 0.21101690259115785, unit: "m"}) // DGHILG
|
||||
|
||||
/*let id;
|
||||
aladin.on("zoomChanged", () => {
|
||||
if (id)
|
||||
clearTimeout(id);
|
||||
id = setTimeout(() => {
|
||||
console.log("wheel stopped, new cone search here")
|
||||
}, 500);
|
||||
})*/
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.aladin-cat-browser-box {
|
||||
width: 600px;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
@@ -30,9 +30,14 @@
|
||||
}
|
||||
);
|
||||
|
||||
hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/GALFAHI/GALFAHI-Narrow-DR2/");
|
||||
hips = aladin.newImageSurvey("https://alasky.cds.unistra.fr/GALFAHI/GALFAHI-Narrow-DR2");
|
||||
aladin.setImageLayer(hips)
|
||||
|
||||
setTimeout(() => {
|
||||
hips.setSliceNumber(100)
|
||||
|
||||
}, 1000)
|
||||
|
||||
/*let id;
|
||||
aladin.on("zoomChanged", () => {
|
||||
if (id)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {survey: "data/hips/CDS_P_DSS2_color", target: "05 40 59.12 -02 27 04.1", fov: 2, log: false});
|
||||
aladin = A.aladin('#aladin-lite-div', {survey: "./data/hips/CDS_P_DSS2_color", target: "05 40 59.12 -02 27 04.1", fov: 2, log: false});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
let aladin = A.aladin('#aladin-lite-div', {fov: 30, target: "280 +0", projection: "AIT", showShareControl:true, showSettingsControl: true, showContextMenu:true});
|
||||
|
||||
|
||||
aladin.setOverlayImageLayer(A.image(
|
||||
"https://www.virtualastronomy.org/files/avm_examples/spitzer/ssc2005-24a1.jpg",
|
||||
{
|
||||
|
||||
@@ -7,31 +7,55 @@
|
||||
<script type="module">
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
let aladin = A.aladin('#aladin-lite-div', {fov: 30, survey: "CDS/P/GALEXGR6/AIS/FUV", target: "280 +0", projection: "AIT", showShareControl:true, showSettingsControl: true, showContextMenu:true});
|
||||
let aladin = A.aladin('#aladin-lite-div', {fov: 30, target: "286.411023328 -37.3460065319", projection: "AIT", showShareControl:true, showSettingsControl: true, showContextMenu:true});
|
||||
|
||||
aladin.setOverlayImageLayer(A.image(
|
||||
"https://nova.astrometry.net/image/25038473?filename=M61.jpg",
|
||||
"data/img/m82.png",
|
||||
{
|
||||
name: "M61",
|
||||
name: "M82",
|
||||
wcs: {
|
||||
NAXIS: 0, // Minimal header
|
||||
CTYPE1: 'RA---TAN', // TAN (gnomic) projection
|
||||
CTYPE2: 'DEC--TAN', // TAN (gnomic) projection
|
||||
NAXIS: 2, // number of axes
|
||||
NAXIS1: 3000, // image width
|
||||
NAXIS2: 1918, // image height
|
||||
CTYPE3: "RGB", // Tell Aladin this is RGB
|
||||
WCSAXES: 2, // no comment
|
||||
CTYPE1: "RA---TAN", // TAN (gnomic) projection + SIP distortions
|
||||
CTYPE2: "DEC--TAN", // TAN (gnomic) projection + SIP distortions
|
||||
EQUINOX: 2000.0, // Equatorial coordinates definition (yr)
|
||||
LONPOLE: 180.0, // no comment
|
||||
LATPOLE: 0.0, // no comment
|
||||
CRVAL1: 185.445488837, // RA of reference point
|
||||
CRVAL2: 4.47896032431, // DEC of reference point
|
||||
CRPIX1: 588.995094299, // X reference pixel
|
||||
CRPIX2: 308.307905197, // Y reference pixel
|
||||
CUNIT1: 'deg', // X pixel scale units
|
||||
CUNIT2: 'deg', // Y pixel scale units
|
||||
CD1_1: -0.000223666022989, // Transformation matrix
|
||||
CD1_2: -0.000296578064584, // no comment
|
||||
CD2_1: -0.000296427555509, // no comment
|
||||
CD2_2: 0.000223774308964, // no comment
|
||||
NAXIS1: 1080, // Image width, in pixels.
|
||||
NAXIS2: 705 // Image height, in pixels.
|
||||
CRVAL1: 286.411023328, // RA of reference point
|
||||
CRVAL2: -37.3460065319, // DEC of reference point
|
||||
CRPIX1: 2264.1858724, // X reference pixel
|
||||
CRPIX2: 583.14634196, // Y reference pixel
|
||||
CUNIT1: "deg", // X pixel scale units
|
||||
CUNIT2: "deg", // Y pixel scale units
|
||||
CD1_1: -0.00284225200648, // Transformation matrix
|
||||
CD1_2: 0.00145908284254, // no comment
|
||||
CD2_1: -0.00145832184852, // no comment
|
||||
CD2_2: -0.0028440175499, // no comment
|
||||
A_ORDER: 2, // Polynomial order, axis 1
|
||||
A_0_0: 0, A_0_1: 0, A_0_2: 1.97760279295e-7,
|
||||
A_1_0: 0, A_1_1: 5.32298396638e-7,
|
||||
A_2_0: -2.16045473726e-6,
|
||||
B_ORDER: 2, // Polynomial order, axis 2
|
||||
B_0_0: 0, B_0_1: 0, B_0_2: 3.97377848239e-7,
|
||||
B_1_0: 0, B_1_1: -2.25823401545e-6,
|
||||
B_2_0: -1.47800507759e-7,
|
||||
AP_ORDER: 2, // Inv polynomial order, axis 1
|
||||
AP_0_0: 0.00617616810622,
|
||||
AP_0_1: -1.68315582233e-6,
|
||||
AP_0_2: -1.96504899588e-7,
|
||||
AP_1_0: -5.8320637913e-6,
|
||||
AP_1_1: -5.26081207663e-7,
|
||||
AP_2_0: 2.13760782681e-6,
|
||||
BP_ORDER: 2, // Inv polynomial order, axis 2
|
||||
BP_0_0: -0.000681183014773,
|
||||
BP_0_1: -2.15389849968e-7,
|
||||
BP_0_2: -3.94508397022e-7,
|
||||
BP_1_0: 4.51837961352e-6,
|
||||
BP_1_1: 2.24050293101e-6,
|
||||
BP_2_0: 1.49195269783e-7
|
||||
},
|
||||
successCallback: (ra, dec, fov, image) => {
|
||||
aladin.gotoRaDec(ra, dec);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
'#aladin-lite-div',
|
||||
{
|
||||
showSimbadPointerControl: true,
|
||||
survey: 'P/allWISE/color', // set initial image survey
|
||||
survey: 'https://skies.esac.esa.int/AKARI/color/', // set initial image survey
|
||||
projection: 'AIT', // set a projection
|
||||
fov: 360, // initial field of view in degrees
|
||||
target: 'orion', // initial target
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import A from '../src/js/A.js';
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {inertia: false, target: '00 00 00 +07 00 00', fov: 130, survey: 'P/Mellinger/color', showContextMenu: true, fullScreen: true});
|
||||
aladin = A.aladin('#aladin-lite-div', {inertia: true, target: '00 00 00 +07 00 00', fov: 130, survey: 'P/Mellinger/color', showContextMenu: true, fullScreen: true});
|
||||
var moc11 = A.MOCFromURL('http://skies.esac.esa.int/HST/NICMOS/Moc.fits', {color: '#84f', lineWidth: 3}, (moc) => {
|
||||
// moc is ready
|
||||
console.log(moc.contains(205.9019247, +2.4492764));
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<script type="module">
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {projection: 'MOL', fullScreen: true, fov: 360, survey: ['P/DM/vizMine', 'P/HST/GOODS/color', 'P/MATLAS/g'], target: '0 0', showProjectionControl: false, showSettingsControl: false, showLayersControl: true, showCooGrid: false, showFrame: false, showCooLocation: false});
|
||||
aladin = A.aladin('#aladin-lite-div', {projection: 'MOL', lockNorthUp: true, fullScreen: true, showSettingsControl: true, fov: 360, survey: ['P/DM/vizMine', 'P/HST/GOODS/color', 'P/MATLAS/g'], target: '0 0', showProjectionControl: false, showSettingsControl: true, showLayersControl: true, showCooGrid: true, showFrame: false, showCooLocation: false});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
});
|
||||
|
||||
aladin.addCatalog(A.catalogFromVizieR("B/assocdata/obscore", "0 +0", 20, {onClick: 'showTable', hoverColor: 'yellow', limit: 1000}))
|
||||
aladin.addCatalog(A.catalogFromSKAORucio("0 +0", 70, {onClick: 'showTable', hoverColor: 'yellow', limit: 1000}))
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -13,9 +13,15 @@
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'Gamma Cas', fov: 10, cooFrame: 'icrs'});
|
||||
|
||||
var overlay = A.graphicOverlay({lineWidth: 2});
|
||||
var overlay = A.graphicOverlay({color: 'green', lineWidth: 2});
|
||||
aladin.addOverlay(overlay);
|
||||
overlay.add(A.polyline([ [2.29452158, 59.14978110], [10.12683778, 56.53733116], [14.1772154, 60.7167403], [21.45396446, 60.23528403], [28.59885697, 63.67010079] ], {color: 'green'}));
|
||||
overlay.add(A.polyline([ [2.29452158, 59.14978110], [10.12683778, 56.53733116], [14.1772154, 60.7167403], [21.45396446, 60.23528403], [28.59885697, 63.67010079] ], {
|
||||
opacity: 0.7
|
||||
}));
|
||||
|
||||
aladin.on('rotationChanged', (rot) => {
|
||||
aladin.setRotation(rot)
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
123
examples/al-read-pixel.html
Normal file
@@ -0,0 +1,123 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="aladin-lite-div" style="width: 768px; height: 512px"></div>
|
||||
<canvas id="myChart" style="width:100%;max-width:600px"></canvas>
|
||||
|
||||
<script>let aladin;</script>
|
||||
<script type="module">
|
||||
function getPixelsOnLine(startX, startY, endX, endY){
|
||||
const pixelCols = [];
|
||||
|
||||
var x = Math.floor(startX);
|
||||
var y = Math.floor(startY);
|
||||
const xx = Math.floor(endX);
|
||||
const yy = Math.floor(endY);
|
||||
const dx = Math.abs(xx - x);
|
||||
const sx = x < xx ? 1 : -1;
|
||||
const dy = -Math.abs(yy - y);
|
||||
const sy = y < yy ? 1 : -1;
|
||||
var err = dx + dy;
|
||||
var e2;
|
||||
var end = false;
|
||||
while (!end) {
|
||||
pixelCols.push([x,y]);
|
||||
if ((x === xx && y === yy)) {
|
||||
end = true;
|
||||
} else {
|
||||
e2 = 2 * err;
|
||||
if (e2 >= dy) {
|
||||
err += dy;
|
||||
x += sx;
|
||||
}
|
||||
if (e2 <= dx) {
|
||||
err += dx;
|
||||
y += sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pixelCols;
|
||||
}
|
||||
|
||||
import A from '../src/js/A.js';
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin(
|
||||
'#aladin-lite-div',
|
||||
{
|
||||
showSimbadPointerControl: true,
|
||||
survey: 'P/allWISE/color', // set initial image survey
|
||||
projection: 'AIT', // set a projection
|
||||
fov: 360, // initial field of view in degrees
|
||||
target: 'orion', // initial target
|
||||
cooFrame: 'icrs', // set galactic frame
|
||||
reticleColor: '#ff89ff', // change reticle color
|
||||
reticleSize: 64, // change reticle size
|
||||
showContextMenu: true,
|
||||
showShareControl: true,
|
||||
showFrame: true,
|
||||
showZoomControl:true,
|
||||
showSettingsControl:true,
|
||||
showColorPickerControl: true,
|
||||
showCooGrid: true,
|
||||
fullScreen: true,
|
||||
samp: true,
|
||||
realFullscreen: true,
|
||||
}
|
||||
);
|
||||
|
||||
let base = aladin.getBaseImageLayer();
|
||||
|
||||
aladin.select('line', p => {
|
||||
let xValues = [];
|
||||
let rValues = [];
|
||||
let gValues = [];
|
||||
let bValues = [];
|
||||
|
||||
let i = 0;
|
||||
for(var [r, g, b] of base.probePixels({type: 'line', x1: p.a.x, y1: p.a.y, x2: p.b.x, y2: p.b.y})) {
|
||||
xValues.push(i)
|
||||
rValues.push(r)
|
||||
gValues.push(g)
|
||||
bValues.push(b)
|
||||
i++;
|
||||
}
|
||||
|
||||
new Chart("myChart", {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: xValues,
|
||||
datasets: [{
|
||||
fill: false,
|
||||
lineTension: 0,
|
||||
backgroundColor: "rgba(255,0,0,1.0)",
|
||||
data: rValues
|
||||
},
|
||||
{
|
||||
fill: false,
|
||||
lineTension: 0,
|
||||
backgroundColor: "rgba(0,255,0,1.0)",
|
||||
data: gValues
|
||||
},
|
||||
{
|
||||
fill: false,
|
||||
lineTension: 0,
|
||||
backgroundColor: "rgba(0,0,255,1.0)",
|
||||
data: bValues
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
legend: {display: false},
|
||||
scales: {
|
||||
yAxes: [{ticks: {min: 0, max:255}}],
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -33,10 +33,16 @@ var myFilterFunction = function(source) {
|
||||
return color>colorThreshold;
|
||||
}
|
||||
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'M 81', fov: 0.5, survey: 'CDS/P/SDSS9/color'});
|
||||
var cat = A.catalogFromSimbad('M 81', 0.25, {onClick: 'showTable', verbosity: 3, filter: myFilterFunction});
|
||||
aladin.addCatalog(cat);
|
||||
aladin = A.aladin('#aladin-lite-div', {target: 'M 81', fov: 0.5, survey: 'CDS/P/SDSS9/color'});
|
||||
var cat = A.catalogFromSimbad('M 81', 0.25, {
|
||||
shape: (s) => {
|
||||
return A.circle(s.ra, s.dec, 0.003, {lineWidth: 3});
|
||||
},
|
||||
onClick: 'showTable', verbosity: 3, filter: myFilterFunction
|
||||
});
|
||||
|
||||
aladin.addCatalog(cat);
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 54 KiB |
@@ -10,7 +10,7 @@
|
||||
<script type="text/javascript">
|
||||
var aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {fullScreen: true, cooFrame: "ICRSd", showSimbadPointerControl: true, showShareControl: true, showShareControl: true, survey: 'https://alasky.cds.unistra.fr/DSS/DSSColor/', fov: 180, showContextMenu: true});
|
||||
aladin = A.aladin('#aladin-lite-div', {fullScreen: true, cooFrame: "ICRSd", showSimbadPointerControl: true, showShareControl: true, showShareControl: true, fov: 180, showContextMenu: true});
|
||||
// manage URL parameters
|
||||
const searchParams = new URL(document.location).searchParams;
|
||||
if (searchParams.has('baseImageLayer')) {
|
||||
|
||||
21
package.json
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"homepage": "https://aladin.u-strasbg.fr/",
|
||||
"homepage": "https://aladin.cds.unistra.fr/",
|
||||
"name": "aladin-lite",
|
||||
"type": "module",
|
||||
"version": "3.7.0-beta",
|
||||
"version": "3.7.3-beta",
|
||||
"description": "An astronomical HiPS visualizer in the browser",
|
||||
"author": "Thomas Boch and Matthieu Baumann",
|
||||
"license": "GPL-3",
|
||||
@@ -30,13 +30,17 @@
|
||||
"HiPS"
|
||||
],
|
||||
"scripts": {
|
||||
"wasm": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2",
|
||||
"wasm:npm": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2",
|
||||
"wasm:prod": "wasm-pack build ./src/core --target web --release --out-name core -- --features \"webgl2 minify_shaders\" && wasm-opt -Oz --strip-debug --strip-producers --dce -o src/core/pkg/core_bg.wasm src/core/pkg/core_bg.wasm",
|
||||
"wasm:dev": "wasm-pack build ./src/core --target web --release --out-name core -- --features webgl2",
|
||||
"wasm:dbg": "wasm-pack build --dev ./src/core --target web --out-name core -- --features=webgl2,dbg",
|
||||
"predeploy": "npm run build && rm -rf aladin-lite*.tgz && npm pack",
|
||||
"predeploy": "npm run build:prod && rm -rf aladin-lite*.tgz && npm pack",
|
||||
"deploy": "python3 deploy/deploy.py",
|
||||
"build": "npm run wasm && vite build",
|
||||
"build:npm": "npm run wasm:npm && vite build",
|
||||
"build:prod": "npm run wasm:prod && vite build",
|
||||
"build:dev": "npm run wasm:dev && vite build",
|
||||
"build:dbg": "npm run wasm:dbg && vite build",
|
||||
"dev": "npm run build && vite",
|
||||
"dev": "npm run build:dev && vite",
|
||||
"dev:dbg": "npm run build:dbg && vite",
|
||||
"serve": "npm run dev",
|
||||
"serve:dbg": "npm run dev:dbg",
|
||||
@@ -45,14 +49,15 @@
|
||||
"test:playwright": "npx playwright test",
|
||||
"test:update-snapshots": "npx playwright test --update-snapshots",
|
||||
"doc": "jsdoc -c jsdoc.json src/js src/js/shapes src/js/libs/astro && cp aladin-logo.png docs/ && cp jsdoc-custom-style.css docs/ && cp jsdoc-make-responsive.js docs/",
|
||||
"doc:dev": "npm run doc && open docs/index.html"
|
||||
"doc:dev": "npm run doc && open docs/index.html",
|
||||
"analyze": "vite build --mode analyze"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.47.0",
|
||||
"docdash": "^2.0.2",
|
||||
"jsdoc": "^4.0.2",
|
||||
"rollup-plugin-visualizer": "^6.0.3",
|
||||
"vite": "^4.3.8",
|
||||
"vite-plugin-glsl": "^1.1.2",
|
||||
"vite-plugin-top-level-await": "^1.4.1",
|
||||
"vite-plugin-wasm": "^3.2.2",
|
||||
"vite-plugin-wasm-pack": "^0.1.12"
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "aladin-lite"
|
||||
description = "Aladin Lite v3 introduces a new graphical engine written in Rust with the use of WebGL"
|
||||
license = "BSD-3-Clause"
|
||||
repository = "https://github.com/cds-astro/aladin-lite"
|
||||
version = "3.7.0"
|
||||
version = "3.7.3-beta"
|
||||
authors = [ "baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr",]
|
||||
edition = "2018"
|
||||
|
||||
@@ -18,22 +18,20 @@ futures = "0.3.12"
|
||||
js-sys = "0.3.47"
|
||||
wasm-bindgen-futures = "0.4.20"
|
||||
cgmath = "*"
|
||||
url-lite = "0.1.0"
|
||||
serde_json = "1.0.104"
|
||||
serde-wasm-bindgen = "0.5"
|
||||
enum_dispatch = "0.3.8"
|
||||
wasm-bindgen = "=0.2.92"
|
||||
wasm-streams = "0.3.0"
|
||||
async-channel = "1.8.0"
|
||||
mapproj = "0.3.0"
|
||||
fitsrs = "0.2.11"
|
||||
wcs = "0.3.1"
|
||||
colorgrad = "0.6.2"
|
||||
fitsrs = "0.4.1"
|
||||
|
||||
[features]
|
||||
webgl1 = [ "al-core/webgl1", "al-api/webgl1", "web-sys/WebGlRenderingContext", "web-sys/AngleInstancedArrays", "web-sys/ExtSRgb", "web-sys/OesTextureFloat",]
|
||||
webgl2 = [ "al-core/webgl2", "al-api/webgl2", "web-sys/WebGl2RenderingContext", "web-sys/WebGlVertexArrayObject", "web-sys/ExtColorBufferFloat",]
|
||||
dbg = [ "dep:console_error_panic_hook",]
|
||||
minify_shaders = []
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.8"
|
||||
@@ -51,7 +49,8 @@ version = "0.7.3"
|
||||
|
||||
[dependencies.moclib]
|
||||
package = "moc"
|
||||
version = "0.17.0"
|
||||
git = "https://github.com/cds-astro/cds-moc-rust"
|
||||
branch = "main"
|
||||
|
||||
[dependencies.serde]
|
||||
version = "^1.0.183"
|
||||
@@ -65,7 +64,7 @@ path = "./al-api"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "0.3.56"
|
||||
features = [ "console", "CssStyleDeclaration", "Document", "Element", "HtmlCollection", "HtmlElement", "HtmlImageElement", "HtmlCanvasElement", "Blob", "ImageBitmap", "ImageData", "CanvasRenderingContext2d", "WebGlBuffer", "WebGlContextAttributes", "WebGlFramebuffer", "WebGlProgram", "WebGlShader", "WebGlUniformLocation", "WebGlTexture", "WebGlActiveInfo", "Headers", "Window", "Request", "RequestInit", "RequestMode", "RequestCredentials", "Response", "XmlHttpRequest", "XmlHttpRequestResponseType", "PerformanceTiming", "Performance", "Url", "ReadableStream", "File", "FileList",]
|
||||
features = [ "console", "CssStyleDeclaration", "Document", "Element", "HtmlCollection", "CustomEvent", "CustomEventInit", "HtmlElement", "HtmlImageElement", "HtmlCanvasElement", "Blob", "ImageBitmap", "ImageData", "CanvasRenderingContext2d", "WebGlBuffer", "WebGlContextAttributes", "WebGlFramebuffer", "WebGlProgram", "WebGlShader", "WebGlUniformLocation", "WebGlTexture", "WebGlActiveInfo", "Headers", "Window", "Request", "RequestInit", "RequestMode", "RequestCredentials", "Response", "XmlHttpRequest", "XmlHttpRequestResponseType", "PerformanceTiming", "Performance", "Url", "ReadableStream", "File", "FileList",]
|
||||
|
||||
[dev-dependencies.image-decoder]
|
||||
package = "image"
|
||||
@@ -84,7 +83,7 @@ overflow-checks = false
|
||||
lto = true
|
||||
panic = "abort"
|
||||
incremental = false
|
||||
codegen-units = 16
|
||||
codegen-units = 1
|
||||
rpath = false
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "al-api"
|
||||
version = "3.6.5"
|
||||
version = "3.7.0"
|
||||
authors = ["baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
@@ -32,5 +32,5 @@ use std::cmp::Eq;
|
||||
#[wasm_bindgen]
|
||||
pub enum Formatter {
|
||||
Sexagesimal,
|
||||
Decimal
|
||||
}
|
||||
Decimal,
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
pub type WebGlRenderingCtx = web_sys::WebGl2RenderingContext;
|
||||
#[cfg(feature = "webgl1")]
|
||||
pub type WebGlRenderingCtx = web_sys::WebGlRenderingContext;
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -94,7 +92,7 @@ impl fmt::Display for BlendFactor {
|
||||
BlendFactor::OneMinusSrcAlpha => "OneMinusSrcAlpha",
|
||||
BlendFactor::OneMinusConstantColor => "OneMinusConstantColor",
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
write!(f, "{str}")
|
||||
}
|
||||
}
|
||||
impl fmt::Display for BlendFunc {
|
||||
@@ -113,6 +111,6 @@ impl fmt::Display for BlendFunc {
|
||||
#[cfg(feature = "webgl2")]
|
||||
BlendFunc::Max => "Max",*/
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
write!(f, "{str}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HEALPixCellProjeted {
|
||||
pub ipix: u64,
|
||||
pub vx: [f64; 4],
|
||||
pub vy: [f64; 4],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ pub struct ColorRGBA {
|
||||
}
|
||||
|
||||
use std::ops::Mul;
|
||||
impl<'a> Mul<f32> for &'a ColorRGB {
|
||||
impl Mul<f32> for &ColorRGB {
|
||||
// The multiplication of rational numbers is a closed operation.
|
||||
type Output = ColorRGB;
|
||||
|
||||
|
||||
@@ -1,39 +1,30 @@
|
||||
use cgmath::Matrix3;
|
||||
|
||||
const GAL2ICRS: &'static Matrix3<f64> = &Matrix3::new(
|
||||
-0.44482972122205372312012370920248,
|
||||
0.74698218398450941835110635824212,
|
||||
0.49410943719710765017955928850141,
|
||||
|
||||
-0.19807633727507056817237662907031,
|
||||
0.45598381369115237931077906137440,
|
||||
-0.86766613755716255824577781583414,
|
||||
|
||||
-0.87343705195577915249273984034980,
|
||||
-0.48383507361641838378786914298189,
|
||||
-0.05487565771261968232908806948676,
|
||||
const GAL2ICRS: &Matrix3<f64> = &Matrix3::new(
|
||||
-0.444_829_721_222_053_7,
|
||||
0.746_982_183_984_509_4,
|
||||
0.494_109_437_197_107_65,
|
||||
-0.198_076_337_275_070_57,
|
||||
0.455_983_813_691_152_4,
|
||||
-0.867_666_137_557_162_6,
|
||||
-0.873_437_051_955_779_1,
|
||||
-0.483_835_073_616_418_37,
|
||||
-0.054_875_657_712_619_68,
|
||||
);
|
||||
|
||||
const ICRS2GAL: &'static Matrix3<f64> = &Matrix3::new(
|
||||
-0.44482972122205372312012370920248,
|
||||
-0.19807633727507056817237662907031,
|
||||
-0.87343705195577915249273984034980,
|
||||
|
||||
0.74698218398450941835110635824212,
|
||||
0.45598381369115237931077906137440,
|
||||
-0.48383507361641838378786914298189,
|
||||
|
||||
0.49410943719710765017955928850141,
|
||||
-0.86766613755716255824577781583414,
|
||||
-0.05487565771261968232908806948676,
|
||||
);
|
||||
|
||||
const ID: &'static Matrix3<f64> = &Matrix3::new(
|
||||
1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
const ICRS2GAL: &Matrix3<f64> = &Matrix3::new(
|
||||
-0.444_829_721_222_053_7,
|
||||
-0.198_076_337_275_070_57,
|
||||
-0.873_437_051_955_779_1,
|
||||
0.746_982_183_984_509_4,
|
||||
0.455_983_813_691_152_4,
|
||||
-0.483_835_073_616_418_37,
|
||||
0.494_109_437_197_107_65,
|
||||
-0.867_666_137_557_162_6,
|
||||
-0.054_875_657_712_619_68,
|
||||
);
|
||||
|
||||
const ID: &Matrix3<f64> = &Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
use serde::Deserialize;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -48,14 +48,26 @@ pub struct HiPSProperties {
|
||||
hips_initial_fov: Option<f64>,
|
||||
hips_initial_ra: Option<f64>,
|
||||
hips_initial_dec: Option<f64>,
|
||||
// HiPS cube
|
||||
hips_cube_depth: Option<u32>,
|
||||
|
||||
// HiPS 3D keywords
|
||||
hips_order_freq: Option<u8>,
|
||||
hips_tile_depth: Option<u8>,
|
||||
|
||||
/// Start of spectral coordinates (in meters)
|
||||
em_min: Option<f32>,
|
||||
/// End of spectral coordinates (in meters)
|
||||
em_max: Option<f32>,
|
||||
|
||||
// Parametrable by the user
|
||||
#[allow(unused)]
|
||||
min_cutout: Option<f32>,
|
||||
#[allow(unused)]
|
||||
max_cutout: Option<f32>,
|
||||
|
||||
dataproduct_type: Option<DataproductType>,
|
||||
|
||||
creator_did: String,
|
||||
|
||||
request_credentials: String,
|
||||
@@ -63,6 +75,20 @@ pub struct HiPSProperties {
|
||||
}
|
||||
|
||||
impl HiPSProperties {
|
||||
#[inline(always)]
|
||||
pub fn get_hips_order_freq(&self) -> Option<u8> {
|
||||
self.hips_order_freq
|
||||
}
|
||||
#[inline(always)]
|
||||
pub fn get_hips_tile_depth(&self) -> Option<u8> {
|
||||
self.hips_tile_depth
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_dataproduct_type(&self) -> Option<DataproductType> {
|
||||
self.dataproduct_type
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_url(&self) -> &str {
|
||||
&self.url
|
||||
@@ -137,6 +163,16 @@ impl HiPSProperties {
|
||||
pub fn get_request_mode(&self) -> &str {
|
||||
&self.request_mode
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_em_min(&self) -> Option<f32> {
|
||||
self.em_min
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_em_max(&self) -> Option<f32> {
|
||||
self.em_max
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
@@ -144,14 +180,27 @@ impl HiPSProperties {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ImageExt {
|
||||
Fits,
|
||||
#[serde(alias = "fits.fz")]
|
||||
FitsFz,
|
||||
Jpeg,
|
||||
Png,
|
||||
Webp,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[wasm_bindgen]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum DataproductType {
|
||||
#[serde(rename = "spectral-cube")]
|
||||
SpectralCube,
|
||||
Image,
|
||||
Cube,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ImageExt {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
ImageExt::FitsFz => write!(f, "fits.fz"),
|
||||
ImageExt::Fits => write!(f, "fits"),
|
||||
ImageExt::Png => write!(f, "png"),
|
||||
ImageExt::Jpeg => write!(f, "jpg"),
|
||||
@@ -163,9 +212,10 @@ impl std::fmt::Display for ImageExt {
|
||||
use serde::Serialize;
|
||||
use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Deserialize, Serialize, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TransferFunction {
|
||||
#[default]
|
||||
Linear,
|
||||
Sqrt,
|
||||
Log,
|
||||
@@ -189,12 +239,6 @@ impl TransferFunction {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for TransferFunction {
|
||||
fn default() -> Self {
|
||||
TransferFunction::Linear
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for TransferFunction {
|
||||
fn from(id: String) -> Self {
|
||||
TransferFunction::new(&id)
|
||||
|
||||
@@ -2,27 +2,29 @@
|
||||
It is used by al-ui and any javascript application calling
|
||||
the WASM core of aladin lite v3
|
||||
*/
|
||||
pub mod angle;
|
||||
pub mod blend;
|
||||
pub mod cell;
|
||||
pub mod color;
|
||||
pub mod colormap;
|
||||
pub mod coo_system;
|
||||
pub mod fov;
|
||||
pub mod grid;
|
||||
pub mod hips;
|
||||
pub mod image;
|
||||
pub mod moc;
|
||||
pub mod resources;
|
||||
pub mod cell;
|
||||
pub mod fov;
|
||||
pub mod image;
|
||||
pub mod angle;
|
||||
|
||||
pub trait Abort {
|
||||
type Item;
|
||||
fn unwrap_abort(self) -> Self::Item where Self: Sized;
|
||||
fn unwrap_abort(self) -> Self::Item
|
||||
where
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
impl<T> Abort for Option<T> {
|
||||
type Item = T;
|
||||
|
||||
|
||||
#[inline]
|
||||
fn unwrap_abort(self) -> Self::Item {
|
||||
use std::process;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
use super::color::{Color, ColorRGBA};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[wasm_bindgen]
|
||||
pub struct MOCOptions {
|
||||
@@ -19,6 +18,7 @@ use crate::{color::ColorRGB, Abort};
|
||||
use std::convert::TryInto;
|
||||
#[wasm_bindgen]
|
||||
impl MOCOptions {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new(
|
||||
uuid: String,
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
[package]
|
||||
name = "al-core"
|
||||
version = "3.6.5"
|
||||
version = "3.7.0"
|
||||
authors = ["baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
js-sys = "0.3.47"
|
||||
cgmath = "*"
|
||||
jpeg-decoder = "0.3.0"
|
||||
png = "0.17.6"
|
||||
fitsrs = "0.2.10"
|
||||
fitsrs = "0.4.1"
|
||||
al-api = { path = "../al-api" }
|
||||
serde = { version = "^1.0.59", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde-wasm-bindgen = "0.4"
|
||||
wasm-streams = "0.3.0"
|
||||
# wasm-streams = "0.3.0"
|
||||
futures = "0.3.25"
|
||||
colorgrad = "0.6.2"
|
||||
wasm-bindgen = "0.2.92"
|
||||
|
||||
@@ -2,13 +2,13 @@ use std::collections::HashMap;
|
||||
|
||||
use colorgrad::Color;
|
||||
|
||||
use crate::shader::SendUniformsWithParams;
|
||||
use crate::Texture2D;
|
||||
use crate::WebGlContext;
|
||||
use crate::image::format;
|
||||
use crate::shader::SendUniformsWithParams;
|
||||
|
||||
use wasm_bindgen::JsValue;
|
||||
use crate::texture::format::RGBA8U;
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
const WIDTH_CMAP_TEX: usize = 256;
|
||||
|
||||
@@ -20,7 +20,10 @@ pub struct Colormap {
|
||||
}
|
||||
impl Colormap {
|
||||
pub fn new(label: &str, grad: colorgrad::Gradient) -> Self {
|
||||
Self { label: label.to_string(), grad }
|
||||
Self {
|
||||
label: label.to_string(),
|
||||
grad,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &Label {
|
||||
@@ -29,18 +32,20 @@ impl Colormap {
|
||||
}
|
||||
|
||||
fn build_cmaps_texture(gl: &WebGlContext, cmaps: &[Colormap]) -> Result<Texture2D, JsValue> {
|
||||
let tex_bytes: Vec<u8> = cmaps.iter()
|
||||
.map(|cmap| {
|
||||
let tex_bytes: Vec<u8> = cmaps
|
||||
.iter()
|
||||
.flat_map(|cmap| {
|
||||
let mut values = [0_u8; 1024];
|
||||
for ix in 0..WIDTH_CMAP_TEX {
|
||||
let rgba = cmap.grad.at(ix as f64 / WIDTH_CMAP_TEX as f64).to_rgba8();
|
||||
let ptr = values[4*ix..].as_mut_ptr() as *mut [u8; 4];
|
||||
unsafe { *ptr = rgba; }
|
||||
let ptr = values[4 * ix..].as_mut_ptr() as *mut [u8; 4];
|
||||
unsafe {
|
||||
*ptr = rgba;
|
||||
}
|
||||
}
|
||||
|
||||
values
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
let tex_params = &[
|
||||
(
|
||||
@@ -63,12 +68,12 @@ fn build_cmaps_texture(gl: &WebGlContext, cmaps: &[Colormap]) -> Result<Texture2
|
||||
),
|
||||
];
|
||||
|
||||
Texture2D::create_from_raw_pixels::<format::RGBA8U>(
|
||||
Texture2D::create_from_raw_pixels::<RGBA8U>(
|
||||
gl,
|
||||
WIDTH_CMAP_TEX as i32,
|
||||
cmaps.len() as i32,
|
||||
tex_params,
|
||||
Some(&tex_bytes[..])
|
||||
Some(&tex_bytes[..]),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -87,20 +92,38 @@ use crate::Abort;
|
||||
impl Colormaps {
|
||||
pub fn new(gl: &WebGlContext) -> Result<Self, JsValue> {
|
||||
let labels: Vec<_> = [
|
||||
"blues", "cividis", "cubehelix", "eosb",
|
||||
"grayscale", "inferno", "magma", "native",
|
||||
"parula", "plasma", "rainbow", "rdbu",
|
||||
"rdylbu", "redtemperature", "sinebow", "spectral", "summer",
|
||||
"viridis", "ylgnbu", "ylorbr", "red", "green", "blue"
|
||||
"blues",
|
||||
"cividis",
|
||||
"cubehelix",
|
||||
"eosb",
|
||||
"grayscale",
|
||||
"inferno",
|
||||
"magma",
|
||||
"native",
|
||||
"parula",
|
||||
"plasma",
|
||||
"rainbow",
|
||||
"rdbu",
|
||||
"rdylbu",
|
||||
"redtemperature",
|
||||
"sinebow",
|
||||
"spectral",
|
||||
"summer",
|
||||
"viridis",
|
||||
"ylgnbu",
|
||||
"ylorbr",
|
||||
"red",
|
||||
"green",
|
||||
"blue",
|
||||
]
|
||||
.iter()
|
||||
.map(|cmap_name| cmap_name.to_string())
|
||||
.collect();
|
||||
|
||||
let indices = labels.iter().enumerate()
|
||||
.map(|(id, label)| {
|
||||
(label.clone(), id as i32)
|
||||
})
|
||||
let indices = labels
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(id, label)| (label.clone(), id as i32))
|
||||
.collect();
|
||||
|
||||
let cmaps = vec![
|
||||
@@ -111,14 +134,14 @@ impl Colormaps {
|
||||
Colormap::new("grayscale", {
|
||||
colorgrad::CustomGradient::new()
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("inferno", colorgrad::inferno()),
|
||||
Colormap::new("magma", colorgrad::magma()),
|
||||
Colormap::new("native", {
|
||||
colorgrad::CustomGradient::new()
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("parula", {
|
||||
colorgrad::CustomGradient::new()
|
||||
@@ -132,7 +155,7 @@ impl Colormaps {
|
||||
Color::from_rgba8(249, 250, 20, 255),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("plasma", colorgrad::plasma()),
|
||||
Colormap::new("rainbow", {
|
||||
@@ -150,7 +173,7 @@ impl Colormaps {
|
||||
Color::from_rgba8(255, 0, 0, 255),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("rdbu", colorgrad::rd_bu()),
|
||||
Colormap::new("rdylbu", colorgrad::rd_yl_bu()),
|
||||
@@ -163,7 +186,7 @@ impl Colormaps {
|
||||
Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("sinebow", colorgrad::sinebow()),
|
||||
Colormap::new("spectral", colorgrad::spectral()),
|
||||
@@ -178,7 +201,7 @@ impl Colormaps {
|
||||
Color::new(1.0, 0.0, 0.0, 1.0),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("green", {
|
||||
colorgrad::CustomGradient::new()
|
||||
@@ -187,7 +210,7 @@ impl Colormaps {
|
||||
Color::new(0.0, 1.0, 0.0, 1.0),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
Colormap::new("blue", {
|
||||
colorgrad::CustomGradient::new()
|
||||
@@ -196,14 +219,20 @@ impl Colormaps {
|
||||
Color::new(0.0, 0.0, 1.0, 1.0),
|
||||
])
|
||||
.build()
|
||||
.map_err(|err| JsValue::from_str(&format!("{:?}", err)))?
|
||||
.map_err(|err| JsValue::from_str(&format!("{err:?}")))?
|
||||
}),
|
||||
];
|
||||
|
||||
let cmaps_tex = build_cmaps_texture(gl, &cmaps[..])?;
|
||||
|
||||
let gl = gl.clone();
|
||||
Ok(Self { cmaps, cmaps_tex, labels, indices, gl })
|
||||
Ok(Self {
|
||||
cmaps,
|
||||
cmaps_tex,
|
||||
labels,
|
||||
indices,
|
||||
gl,
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -213,12 +242,14 @@ impl Colormaps {
|
||||
|
||||
#[inline]
|
||||
pub fn get(&self, label: &str) -> &Colormap {
|
||||
if let Some(id) = self.get_id(label).map(|id| *id) {
|
||||
if let Some(&id) = self.get_id(label) {
|
||||
&self.cmaps[id as usize]
|
||||
} else {
|
||||
crate::log::console_warn(&format!("{:?} is not a valid colormap, replaced with 'grayscale'.", label));
|
||||
let id_greys = self.get_id("grayscale").map(|id| *id).unwrap_abort();
|
||||
&self.cmaps[id_greys as usize]
|
||||
crate::log::console_warn(format!(
|
||||
"{label:?} is not a valid colormap, replaced with 'grayscale'.",
|
||||
));
|
||||
let id_greys = self.get_id("grayscale").unwrap_abort();
|
||||
&self.cmaps[*id_greys as usize]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,13 +259,13 @@ impl Colormaps {
|
||||
}
|
||||
|
||||
pub fn add_cmap(&mut self, label: Label, cmap: Colormap) -> Result<(), JsValue> {
|
||||
if let Some(id) = self.get_id(&label).map(|id| *id) {
|
||||
if let Some(&id) = self.get_id(&label) {
|
||||
let colormap = &mut self.cmaps[id as usize];
|
||||
*colormap = cmap;
|
||||
} else {
|
||||
let num_cmaps = self.labels.len();
|
||||
self.labels.push(label.clone());
|
||||
|
||||
|
||||
self.indices.insert(label, num_cmaps as i32);
|
||||
self.cmaps.push(cmap);
|
||||
}
|
||||
@@ -246,7 +277,7 @@ impl Colormaps {
|
||||
}
|
||||
}
|
||||
|
||||
use crate::shader::{ShaderBound, SendUniforms};
|
||||
use crate::shader::{SendUniforms, ShaderBound};
|
||||
impl SendUniforms for Colormaps {
|
||||
fn attach_uniforms<'a>(&self, shader: &'a ShaderBound<'a>) -> &'a ShaderBound<'a> {
|
||||
shader
|
||||
@@ -258,7 +289,11 @@ impl SendUniforms for Colormaps {
|
||||
}
|
||||
|
||||
impl SendUniformsWithParams<Colormaps> for Colormap {
|
||||
fn attach_uniforms_with_params<'a>(&self, shader: &'a ShaderBound<'a>, cmaps: &Colormaps) -> &'a ShaderBound<'a> {
|
||||
fn attach_uniforms_with_params<'a>(
|
||||
&self,
|
||||
shader: &'a ShaderBound<'a>,
|
||||
cmaps: &Colormaps,
|
||||
) -> &'a ShaderBound<'a> {
|
||||
let cmap_id = cmaps.get_id(&self.label).unwrap_abort();
|
||||
shader.attach_uniform("colormap_id", &(*cmap_id as f32));
|
||||
shader
|
||||
|
||||
@@ -6,11 +6,11 @@ pub struct Bitmap<F> {
|
||||
format: std::marker::PhantomData<F>,
|
||||
}
|
||||
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::image::Image;
|
||||
use crate::texture::format::TextureFormat;
|
||||
impl<F> Bitmap<F>
|
||||
where
|
||||
F: ImageFormat + Clone,
|
||||
F: TextureFormat + Clone,
|
||||
{
|
||||
pub fn new(image: web_sys::ImageBitmap) -> Self {
|
||||
Self {
|
||||
@@ -23,7 +23,7 @@ use crate::texture::Tex3D;
|
||||
use wasm_bindgen::JsValue;
|
||||
impl<F> Image for Bitmap<F>
|
||||
where
|
||||
F: ImageFormat + Clone,
|
||||
F: TextureFormat + Clone,
|
||||
{
|
||||
fn insert_into_3d_texture<T: Tex3D>(
|
||||
&self,
|
||||
@@ -34,4 +34,8 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
(self.image.width(), self.image.height(), 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ pub struct Canvas<F> {
|
||||
|
||||
impl<F> Canvas<F>
|
||||
where
|
||||
F: ImageFormat + Clone,
|
||||
F: TextureFormat + Clone,
|
||||
{
|
||||
pub fn new(canvas: web_sys::HtmlCanvasElement) -> Self {
|
||||
Self {
|
||||
@@ -17,14 +17,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::image::Image;
|
||||
use crate::texture::format::TextureFormat;
|
||||
use crate::texture::Tex3D;
|
||||
use cgmath::Vector3;
|
||||
use wasm_bindgen::JsValue;
|
||||
impl<F> Image for Canvas<F>
|
||||
where
|
||||
F: ImageFormat,
|
||||
F: TextureFormat,
|
||||
{
|
||||
fn insert_into_3d_texture<T: Tex3D>(
|
||||
&self,
|
||||
@@ -42,4 +42,8 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
(self.canvas.width(), self.canvas.height(), 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,123 +1,188 @@
|
||||
use cgmath::{Vector2, Vector3};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Fits<'a> {
|
||||
// Tile size
|
||||
size: Vector2<i32>,
|
||||
|
||||
pub data: Data<'a>,
|
||||
}
|
||||
|
||||
use crate::texture::format::TextureFormat;
|
||||
use crate::texture::format::R8U;
|
||||
use cgmath::Vector3;
|
||||
use fitsrs::hdu::data::bintable::data::BinaryTableData;
|
||||
use fitsrs::hdu::data::bintable::tile_compressed::pixels::Pixels;
|
||||
use fitsrs::hdu::header::extension::bintable::TileCompressedImage;
|
||||
use fitsrs::hdu::header::Bitpix;
|
||||
use fitsrs::WCS;
|
||||
use fitsrs::{Fits, HDU};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Debug;
|
||||
#[derive(Debug)]
|
||||
pub enum Data<'a> {
|
||||
U8(Cow<'a, [u8]>),
|
||||
I16(Cow<'a, [i16]>),
|
||||
I32(Cow<'a, [i32]>),
|
||||
F32(Cow<'a, [f32]>),
|
||||
}
|
||||
use fitsrs::{fits::Fits as FitsData, hdu::data::InMemData};
|
||||
use std::io::Cursor;
|
||||
use std::ops::Range;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
impl<'a> Fits<'a> {
|
||||
pub fn from_byte_slice(bytes_reader: &'a mut Cursor<&[u8]>) -> Result<Self, JsValue> {
|
||||
let FitsData { hdu } = FitsData::from_reader(bytes_reader)
|
||||
.map_err(|_| JsValue::from_str(&"Parsing fits error"))?;
|
||||
|
||||
let header = hdu.get_header();
|
||||
let xtension = header.get_xtension();
|
||||
let width = xtension
|
||||
.get_naxisn(1)
|
||||
.ok_or_else(|| JsValue::from_str("NAXIS1 not found in the fits"))?;
|
||||
|
||||
let height = xtension
|
||||
.get_naxisn(2)
|
||||
.ok_or_else(|| JsValue::from_str("NAXIS2 not found in the fits"))?;
|
||||
|
||||
let data = hdu.get_data();
|
||||
let data = match *data {
|
||||
InMemData::U8(slice) => Data::U8(Cow::Borrowed(slice)),
|
||||
InMemData::I16(slice) => Data::I16(Cow::Borrowed(slice)),
|
||||
InMemData::I32(slice) => Data::I32(Cow::Borrowed(slice)),
|
||||
InMemData::I64(slice) => {
|
||||
let data = slice.iter().map(|v| *v as i32).collect();
|
||||
Data::I32(Cow::Owned(data))
|
||||
}
|
||||
InMemData::F32(slice) => Data::F32(Cow::Borrowed(slice)),
|
||||
InMemData::F64(slice) => {
|
||||
let data = slice.iter().map(|v| *v as f32).collect();
|
||||
Data::F32(Cow::Owned(data))
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
// Tile size
|
||||
size: Vector2::new(*width as i32, *height as i32),
|
||||
|
||||
// Allocation info of the layout
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_size(&self) -> &Vector2<i32> {
|
||||
&self.size
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct FitsImage<'a> {
|
||||
// Margin values for HiPS3D cubic tiles
|
||||
pub trim1: u32,
|
||||
pub trim2: u32,
|
||||
pub trim3: u32,
|
||||
// Image/cube size
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub depth: u32,
|
||||
// Bitpix
|
||||
pub bitpix: Bitpix,
|
||||
// 1.0 by default
|
||||
pub bscale: f32,
|
||||
// 0.0 by default
|
||||
pub bzero: f32,
|
||||
// blank
|
||||
pub blank: Option<f32>,
|
||||
// optional wcs
|
||||
pub wcs: Option<WCS>,
|
||||
// bytes offset where the data bytes are located inside the fits
|
||||
pub data_byte_offset: Range<usize>,
|
||||
// raw bytes of the data image (in Big-Endian)
|
||||
pub raw_bytes: Cow<'a, [u8]>,
|
||||
}
|
||||
|
||||
/*impl Fits<'static> {
|
||||
pub async fn from_async_reader(reader: IntoAsyncRead<'static>) -> Result<Self, JsValue> {
|
||||
let fitsrs::fits::AsyncFits { hdu: AsyncHDU { data, header } } = fitsrs::fits::AsyncFits::from_reader(futures::io::BufReader::new(reader))
|
||||
.await
|
||||
.map_err(|err| {
|
||||
JsValue::from_str(&format!("Parsing fits error: {}", err))
|
||||
})?;
|
||||
impl<'a> FitsImage<'a> {
|
||||
/// Get all the hdu images from a fits file
|
||||
pub fn from_raw_bytes(bytes: &'a [u8]) -> Result<Vec<Self>, JsValue> {
|
||||
let mut fits = Fits::from_reader(Cursor::new(bytes));
|
||||
let mut images = vec![];
|
||||
|
||||
let width = header.get_axis_size(1)
|
||||
.ok_or_else(|| JsValue::from_str("NAXIS1 not found in the fits"))?;
|
||||
while let Some(Ok(hdu)) = fits.next() {
|
||||
match hdu {
|
||||
HDU::XImage(hdu) | HDU::Primary(hdu) => {
|
||||
// Prefer getting the dimension directly from NAXIS1/NAXIS2 instead of from the WCS
|
||||
// because it may not exist in all HDU images
|
||||
let naxis = hdu.get_header().get_xtension().get_naxis();
|
||||
if naxis.len() >= 2 {
|
||||
let width = naxis[0];
|
||||
let height = naxis[1];
|
||||
let depth = if naxis.len() >= 3 { naxis[2] } else { 1 };
|
||||
|
||||
let height = header.get_axis_size(2)
|
||||
.ok_or_else(|| JsValue::from_str("NAXIS2 not found in the fits"))?;
|
||||
let header = hdu.get_header();
|
||||
|
||||
let data = match data {
|
||||
fitsrs::hdu::data_async::DataOwned::U8(stream) => {
|
||||
let data = stream.collect().await;
|
||||
Data::U8(Cow::Owned(data))
|
||||
},
|
||||
fitsrs::hdu::data_async::DataOwned::I16(stream) => {
|
||||
let data = stream.collect().await;
|
||||
Data::I16(Cow::Owned(data))
|
||||
},
|
||||
fitsrs::hdu::data_async::DataOwned::I32(stream) => {
|
||||
let data = stream.collect().await;
|
||||
Data::I32(Cow::Owned(data))
|
||||
},
|
||||
fitsrs::hdu::data_async::DataOwned::I64(stream) => {
|
||||
let data = stream.map(|v| v as i32).collect().await;
|
||||
Data::I32(Cow::Owned(data))
|
||||
},
|
||||
fitsrs::hdu::data_async::DataOwned::F32(stream) => {
|
||||
let data = stream.collect().await;
|
||||
Data::F32(Cow::Owned(data))
|
||||
},
|
||||
fitsrs::hdu::data_async::DataOwned::F64(stream) => {
|
||||
let data = stream.map(|v| v as f32).collect().await;
|
||||
Data::F32(Cow::Owned(data))
|
||||
let bscale = header.get_parsed::<f32>("BSCALE").unwrap_or(1.0);
|
||||
let bzero = header.get_parsed::<f32>("BZERO").unwrap_or(0.0);
|
||||
let blank = header.get_parsed::<f32>("BLANK").ok();
|
||||
|
||||
let trim1 = header.get_parsed::<u32>("TRIM1").unwrap_or(0);
|
||||
let trim2 = header.get_parsed::<u32>("TRIM2").unwrap_or(0);
|
||||
let trim3 = header.get_parsed::<u32>("TRIM3").unwrap_or(0);
|
||||
|
||||
let bitpix = hdu.get_header().get_xtension().get_bitpix();
|
||||
|
||||
let off = hdu.get_data_unit_byte_offset() as usize;
|
||||
let len = hdu.get_data_unit_byte_size() as usize;
|
||||
|
||||
let data_byte_offset = off..(off + len);
|
||||
let raw_bytes = Cow::Borrowed(&bytes[data_byte_offset.clone()]);
|
||||
|
||||
let wcs = hdu.wcs().ok();
|
||||
|
||||
images.push(Self {
|
||||
trim1,
|
||||
trim2,
|
||||
trim3,
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
depth: depth as u32,
|
||||
bitpix,
|
||||
bscale,
|
||||
wcs,
|
||||
bzero,
|
||||
blank,
|
||||
data_byte_offset,
|
||||
raw_bytes,
|
||||
});
|
||||
}
|
||||
}
|
||||
HDU::XBinaryTable(hdu) => {
|
||||
let header = hdu.get_header();
|
||||
let bin_table = header.get_xtension();
|
||||
|
||||
if let Some(TileCompressedImage {
|
||||
z_bitpix: bitpix,
|
||||
z_naxisn: naxis,
|
||||
..
|
||||
}) = &bin_table.get_z_image()
|
||||
{
|
||||
if naxis.len() >= 2 {
|
||||
let width = naxis[0] as u32;
|
||||
let height = naxis[1] as u32;
|
||||
|
||||
let depth = if naxis.len() >= 3 { naxis[2] as u32 } else { 1 };
|
||||
|
||||
let bscale = header.get_parsed::<f32>("BSCALE").unwrap_or(1.0);
|
||||
let bzero = header.get_parsed::<f32>("BZERO").unwrap_or(0.0);
|
||||
let blank = header.get_parsed::<f32>("BLANK").ok();
|
||||
|
||||
let trim1 = header.get_parsed::<u32>("TRIM1").unwrap_or(0);
|
||||
let trim2 = header.get_parsed::<u32>("TRIM2").unwrap_or(0);
|
||||
let trim3 = header.get_parsed::<u32>("TRIM3").unwrap_or(0);
|
||||
|
||||
let wcs = hdu.wcs().ok();
|
||||
|
||||
let off = hdu.get_data_unit_byte_offset() as usize;
|
||||
let len = hdu.get_data_unit_byte_size() as usize;
|
||||
|
||||
let data_byte_offset = off..(off + len);
|
||||
|
||||
let mut bitpix = *bitpix;
|
||||
let raw_bytes = match fits.get_data(&hdu) {
|
||||
BinaryTableData::TileCompressed(Pixels::U8(pixels)) => {
|
||||
Some(pixels.collect::<Vec<_>>())
|
||||
}
|
||||
BinaryTableData::TileCompressed(Pixels::I16(pixels)) => {
|
||||
Some(pixels.flat_map(|p| p.to_be_bytes()).collect::<Vec<_>>())
|
||||
}
|
||||
BinaryTableData::TileCompressed(Pixels::I32(pixels)) => {
|
||||
Some(pixels.flat_map(|p| p.to_be_bytes()).collect::<Vec<_>>())
|
||||
}
|
||||
BinaryTableData::TileCompressed(Pixels::F32(pixels)) => {
|
||||
Some(pixels.flat_map(|p| p.to_be_bytes()).collect::<Vec<_>>())
|
||||
}
|
||||
BinaryTableData::TileCompressed(Pixels::F64(pixels)) => {
|
||||
bitpix = Bitpix::F32;
|
||||
let raw_bytes =
|
||||
pixels.flat_map(|p| p.to_be_bytes()).collect::<Vec<_>>();
|
||||
|
||||
Some(raw_bytes)
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(raw_bytes) = raw_bytes {
|
||||
images.push(Self {
|
||||
trim1,
|
||||
trim2,
|
||||
trim3,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
bitpix,
|
||||
bscale,
|
||||
wcs,
|
||||
bzero,
|
||||
blank,
|
||||
data_byte_offset,
|
||||
raw_bytes: Cow::Owned(raw_bytes),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
// Tile size
|
||||
size: Vector2::new(*width as i32, *height as i32),
|
||||
|
||||
// Allocation info of the layout
|
||||
data
|
||||
})
|
||||
if !images.is_empty() {
|
||||
Ok(images)
|
||||
} else {
|
||||
Err(JsValue::from_str("Image HDU not found in the FITS"))
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
use crate::{image::Image, texture::Tex3D};
|
||||
impl Image for Fits<'_> {
|
||||
use std::convert::TryInto;
|
||||
impl Image for FitsImage<'_> {
|
||||
fn insert_into_3d_texture<T: Tex3D>(
|
||||
&self,
|
||||
// The texture array
|
||||
@@ -125,89 +190,57 @@ impl Image for Fits<'_> {
|
||||
// An offset to write the image in the texture array
|
||||
offset: &Vector3<i32>,
|
||||
) -> Result<(), JsValue> {
|
||||
match &self.data {
|
||||
Data::U8(data) => {
|
||||
let view = unsafe { R8UI::view(&data) };
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x,
|
||||
offset.y,
|
||||
offset.z,
|
||||
self.size.x,
|
||||
self.size.y,
|
||||
1,
|
||||
Some(view.as_ref()),
|
||||
);
|
||||
let view = unsafe {
|
||||
match self.bitpix {
|
||||
Bitpix::I64 => {
|
||||
// convert to i64 first
|
||||
let new_bytes: Vec<_> = self
|
||||
.raw_bytes
|
||||
.chunks_exact(8)
|
||||
.flat_map(|chunk| {
|
||||
let bytes: [u8; 8] = chunk.try_into().unwrap();
|
||||
let value = i64::from_be_bytes(bytes);
|
||||
|
||||
(value as i32).to_be_bytes()
|
||||
})
|
||||
.collect();
|
||||
|
||||
R8U::view(&new_bytes)
|
||||
}
|
||||
Bitpix::F64 => {
|
||||
// convert to i64 first
|
||||
let new_bytes: Vec<_> = self
|
||||
.raw_bytes
|
||||
.chunks_exact(8)
|
||||
.flat_map(|chunk| {
|
||||
let bytes: [u8; 8] = chunk.try_into().unwrap();
|
||||
let value = f64::from_be_bytes(bytes);
|
||||
|
||||
(value as f32).to_be_bytes()
|
||||
})
|
||||
.collect();
|
||||
|
||||
R8U::view(&new_bytes)
|
||||
}
|
||||
_ => R8U::view(&self.raw_bytes),
|
||||
}
|
||||
Data::I16(data) => {
|
||||
let view = unsafe { R16I::view(&data) };
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x,
|
||||
offset.y,
|
||||
offset.z,
|
||||
self.size.x,
|
||||
self.size.y,
|
||||
1,
|
||||
Some(view.as_ref()),
|
||||
);
|
||||
}
|
||||
Data::I32(data) => {
|
||||
let view = unsafe { R32I::view(&data) };
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x,
|
||||
offset.y,
|
||||
offset.z,
|
||||
self.size.x,
|
||||
self.size.y,
|
||||
1,
|
||||
Some(view.as_ref()),
|
||||
);
|
||||
}
|
||||
Data::F32(data) => {
|
||||
let view = unsafe { R8UI::view(&std::slice::from_raw_parts(data.as_ptr() as *const u8, data.len() * 4)) };
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x,
|
||||
offset.y,
|
||||
offset.z,
|
||||
self.size.x,
|
||||
self.size.y,
|
||||
1,
|
||||
Some(view.as_ref()),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x + self.trim1 as i32,
|
||||
offset.y + self.trim2 as i32,
|
||||
offset.z + self.trim3 as i32,
|
||||
self.width as i32,
|
||||
self.height as i32,
|
||||
self.depth as i32,
|
||||
Some(view.as_ref()),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
use crate::image::format::ImageFormat;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
pub trait FitsImageFormat: ImageFormat {
|
||||
const BITPIX: i8;
|
||||
}
|
||||
|
||||
use crate::image::R32F;
|
||||
impl FitsImageFormat for R32F {
|
||||
const BITPIX: i8 = -32;
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
use crate::image::{R16I, R32I, R64F, R8UI};
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl FitsImageFormat for R64F {
|
||||
const BITPIX: i8 = -64;
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl FitsImageFormat for R32I {
|
||||
const BITPIX: i8 = 32;
|
||||
}
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl FitsImageFormat for R16I {
|
||||
const BITPIX: i8 = 16;
|
||||
}
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl FitsImageFormat for R8UI {
|
||||
const BITPIX: i8 = 8;
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
// The true image size is given by ONAXISi keywords
|
||||
(self.width, self.height, self.depth)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,314 +1,9 @@
|
||||
use crate::texture::pixel::Pixel;
|
||||
use crate::texture::format::PixelType;
|
||||
use al_api::hips::ImageExt;
|
||||
|
||||
pub enum Bytes<'a> {
|
||||
Borrowed(&'a [u8]),
|
||||
Owned(Vec<u8>),
|
||||
}
|
||||
|
||||
pub trait ImageFormat {
|
||||
type P: Pixel;
|
||||
type ArrayBufferView: AsRef<js_sys::Object>;
|
||||
|
||||
const NUM_CHANNELS: usize;
|
||||
|
||||
const FORMAT: u32;
|
||||
const INTERNAL_FORMAT: i32;
|
||||
const TYPE: u32;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType;
|
||||
|
||||
/// Creates a JS typed array which is a view into wasm's linear memory at the slice specified.
|
||||
/// This function returns a new typed array which is a view into wasm's memory. This view does not copy the underlying data.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Views into WebAssembly memory are only valid so long as the backing buffer isn't resized in JS. Once this function is called any future calls to Box::new (or malloc of any form) may cause the returned value here to be invalidated. Use with caution!
|
||||
///
|
||||
/// Additionally the returned object can be safely mutated but the input slice isn't guaranteed to be mutable.
|
||||
///
|
||||
/// Finally, the returned object is disconnected from the input slice's lifetime, so there's no guarantee that the data is read at the right time.
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str>;
|
||||
}
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGB8U;
|
||||
impl ImageFormat for RGB8U {
|
||||
type P = [u8; 3];
|
||||
|
||||
const NUM_CHANNELS: usize = 3;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGB as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGB8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::RGB8U;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
let mut decoder = jpeg::Decoder::new(raw_bytes);
|
||||
let bytes = decoder
|
||||
.decode()
|
||||
.map_err(|_| "Cannot decoder jpeg. This image may not be compressed.")?;
|
||||
|
||||
Ok(Bytes::Owned(bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGBA8U;
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl ImageFormat for RGBA8U {
|
||||
type P = [u8; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::RGBA8U;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
let mut decoder = jpeg::Decoder::new(raw_bytes);
|
||||
let bytes = decoder
|
||||
.decode()
|
||||
.map_err(|_| "Cannot decoder png. This image may not be compressed.")?;
|
||||
|
||||
Ok(Bytes::Owned(bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGBA32F;
|
||||
impl ImageFormat for RGBA32F {
|
||||
type P = [f32; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA as u32;
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA32F as i32;
|
||||
#[cfg(feature = "webgl1")]
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA as i32;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::RGBA32F;
|
||||
|
||||
const TYPE: u32 = WebGlRenderingCtx::FLOAT;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Float32Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGB32F;
|
||||
impl ImageFormat for RGB32F {
|
||||
type P = [f32; 3];
|
||||
|
||||
const NUM_CHANNELS: usize = 3;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGB as u32;
|
||||
#[cfg(feature = "webgl2")]
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGB32F as i32;
|
||||
#[cfg(feature = "webgl1")]
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGB as i32;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::RGB32F;
|
||||
|
||||
const TYPE: u32 = WebGlRenderingCtx::FLOAT;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Float32Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R32F;
|
||||
impl ImageFormat for R32F {
|
||||
type P = [u8; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::R32F;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R64F;
|
||||
impl ImageFormat for R64F {
|
||||
type P = [u8; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::R32F;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R8UI;
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl ImageFormat for R8UI {
|
||||
type P = [u8; 1];
|
||||
|
||||
const NUM_CHANNELS: usize = 1;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RED_INTEGER as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::R8UI as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::R8UI;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R16I;
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl ImageFormat for R16I {
|
||||
type P = [i16; 1];
|
||||
|
||||
const NUM_CHANNELS: usize = 1;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RED_INTEGER as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::R16I as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::SHORT;
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::R16I;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Int16Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R32I;
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl ImageFormat for R32I {
|
||||
type P = [i32; 1];
|
||||
|
||||
const NUM_CHANNELS: usize = 1;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RED_INTEGER as u32;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::R32I as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::INT;
|
||||
|
||||
const CHANNEL_TYPE: ChannelType = ChannelType::R32I;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Int32Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||
pub enum ChannelType {
|
||||
RGBA32F,
|
||||
RGB32F,
|
||||
RGBA8U,
|
||||
RGB8U,
|
||||
R32F,
|
||||
#[cfg(feature = "webgl2")]
|
||||
R64F,
|
||||
#[cfg(feature = "webgl2")]
|
||||
R8UI,
|
||||
#[cfg(feature = "webgl2")]
|
||||
R16I,
|
||||
#[cfg(feature = "webgl2")]
|
||||
R32I,
|
||||
}
|
||||
|
||||
impl ChannelType {
|
||||
pub fn is_colored(&self) -> bool {
|
||||
match self {
|
||||
ChannelType::RGBA32F
|
||||
| ChannelType::RGB32F
|
||||
| ChannelType::RGBA8U
|
||||
| ChannelType::RGB8U => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const NUM_CHANNELS: usize = 9;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||
pub struct ImageFormatType {
|
||||
pub ext: ImageExt,
|
||||
pub channel: ChannelType,
|
||||
pub fmt: PixelType,
|
||||
}
|
||||
|
||||
impl ImageFormatType {
|
||||
@@ -316,11 +11,11 @@ impl ImageFormatType {
|
||||
&self.ext
|
||||
}
|
||||
|
||||
pub fn get_channel(&self) -> ChannelType {
|
||||
self.channel
|
||||
pub fn get_pixel_format(&self) -> PixelType {
|
||||
self.fmt
|
||||
}
|
||||
|
||||
pub fn is_colored(&self) -> bool {
|
||||
self.channel.is_colored()
|
||||
!matches!(self.ext, ImageExt::Fits)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* ------------------------------------------------------ */
|
||||
#[derive(Debug)]
|
||||
pub struct HTMLImage<F> {
|
||||
image: web_sys::HtmlImageElement,
|
||||
pub image: web_sys::HtmlImageElement,
|
||||
format: std::marker::PhantomData<F>,
|
||||
}
|
||||
|
||||
impl<F> HTMLImage<F>
|
||||
where
|
||||
F: ImageFormat + Clone,
|
||||
F: TextureFormat + Clone,
|
||||
{
|
||||
pub fn new(image: web_sys::HtmlImageElement) -> Self {
|
||||
Self {
|
||||
@@ -15,16 +15,20 @@ where
|
||||
format: std::marker::PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn element(&self) -> &web_sys::HtmlImageElement {
|
||||
&self.image
|
||||
}
|
||||
}
|
||||
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::image::Image;
|
||||
use crate::texture::format::TextureFormat;
|
||||
use crate::texture::Tex3D;
|
||||
use cgmath::Vector3;
|
||||
use wasm_bindgen::JsValue;
|
||||
impl<F> Image for HTMLImage<F>
|
||||
where
|
||||
F: ImageFormat,
|
||||
F: TextureFormat,
|
||||
{
|
||||
fn insert_into_3d_texture<T: Tex3D>(
|
||||
&self,
|
||||
@@ -42,4 +46,8 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
(self.image.width(), self.image.height(), 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ pub mod format;
|
||||
pub mod html;
|
||||
pub mod raw;
|
||||
|
||||
use crate::image::bitmap::Bitmap;
|
||||
use crate::image::raw::ImageBuffer;
|
||||
use crate::texture::format::RGB8U;
|
||||
use crate::texture::format::RGBA8U;
|
||||
pub trait ArrayBuffer: AsRef<js_sys::Object> + std::fmt::Debug {
|
||||
type Item: std::cmp::PartialOrd + Clone + Copy + std::fmt::Debug + cgmath::Zero;
|
||||
|
||||
@@ -33,8 +37,7 @@ impl ArrayBuffer for ArrayU8 {
|
||||
|
||||
fn empty(size: u32, blank_value: Self::Item) -> Self {
|
||||
let uint8_arr = js_sys::Uint8Array::new_with_length(size).fill(blank_value, 0, size);
|
||||
let array = ArrayU8(uint8_arr);
|
||||
array
|
||||
ArrayU8(uint8_arr)
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<Self::Item> {
|
||||
@@ -65,8 +68,7 @@ impl ArrayBuffer for ArrayI16 {
|
||||
|
||||
fn empty(size: u32, blank_value: Self::Item) -> Self {
|
||||
let int16_arr = js_sys::Int16Array::new_with_length(size).fill(blank_value, 0, size);
|
||||
let array = ArrayI16(int16_arr);
|
||||
array
|
||||
ArrayI16(int16_arr)
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<Self::Item> {
|
||||
@@ -97,8 +99,7 @@ impl ArrayBuffer for ArrayI32 {
|
||||
|
||||
fn empty(size: u32, blank_value: Self::Item) -> Self {
|
||||
let int32_arr = js_sys::Int32Array::new_with_length(size).fill(blank_value, 0, size);
|
||||
let array = ArrayI32(int32_arr);
|
||||
array
|
||||
ArrayI32(int32_arr)
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<Self::Item> {
|
||||
@@ -129,8 +130,7 @@ impl ArrayBuffer for ArrayF32 {
|
||||
}
|
||||
fn empty(size: u32, blank_value: Self::Item) -> Self {
|
||||
let f32_arr = js_sys::Float32Array::new_with_length(size).fill(blank_value, 0, size);
|
||||
let array = ArrayF32(f32_arr);
|
||||
array
|
||||
ArrayF32(f32_arr)
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<Self::Item> {
|
||||
@@ -162,8 +162,7 @@ impl ArrayBuffer for ArrayF64 {
|
||||
}
|
||||
fn empty(size: u32, blank_value: Self::Item) -> Self {
|
||||
let f64_arr = js_sys::Float64Array::new_with_length(size).fill(blank_value, 0, size);
|
||||
let array = ArrayF64(f64_arr);
|
||||
array
|
||||
ArrayF64(f64_arr)
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<Self::Item> {
|
||||
@@ -180,6 +179,7 @@ impl ArrayBuffer for ArrayF64 {
|
||||
}
|
||||
|
||||
use self::canvas::Canvas;
|
||||
use self::fits::FitsImage;
|
||||
use self::html::HTMLImage;
|
||||
use wasm_bindgen::JsValue;
|
||||
pub trait Image {
|
||||
@@ -190,9 +190,11 @@ pub trait Image {
|
||||
// An offset to write the image in the texture array
|
||||
offset: &Vector3<i32>,
|
||||
) -> Result<(), JsValue>;
|
||||
|
||||
fn get_size(&self) -> (u32, u32, u32);
|
||||
}
|
||||
|
||||
impl<'a, I> Image for &'a I
|
||||
impl<I> Image for &I
|
||||
where
|
||||
I: Image,
|
||||
{
|
||||
@@ -208,9 +210,15 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
let image = &**self;
|
||||
image.get_size()
|
||||
}
|
||||
}
|
||||
|
||||
use std::{io::Cursor, rc::Rc};
|
||||
use std::rc::Rc;
|
||||
impl<I> Image for Rc<I>
|
||||
where
|
||||
I: Image,
|
||||
@@ -227,65 +235,56 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/*impl<I> Image for Arc<Mutex<Option<I>>>
|
||||
where
|
||||
I: Image,
|
||||
{
|
||||
fn tex_sub_image_3d(
|
||||
&self,
|
||||
// The texture array
|
||||
textures: &Texture2DArray,
|
||||
// An offset to write the image in the texture array
|
||||
offset: &Vector3<i32>,
|
||||
) -> Result<(), JsValue> {
|
||||
if let Some(image) = &*self.lock().unwrap_abort() {
|
||||
image.tex_sub_image_3d(textures, offset)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
#[inline]
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
let image = &**self;
|
||||
image.get_size()
|
||||
}
|
||||
}*/
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
use crate::image::format::{R16I, R32I, R64F, R8UI};
|
||||
use crate::{
|
||||
image::format::{R32F, RGB8U, RGBA8U},
|
||||
texture::Tex3D,
|
||||
};
|
||||
|
||||
use bitmap::Bitmap;
|
||||
use fits::Fits;
|
||||
use raw::ImageBuffer;
|
||||
#[derive(Debug)]
|
||||
#[cfg(feature = "webgl2")]
|
||||
pub enum ImageType {
|
||||
FitsImage { raw_bytes: js_sys::Uint8Array },
|
||||
Canvas { canvas: Canvas<RGBA8U> },
|
||||
ImageRgba8u { image: Bitmap<RGBA8U> },
|
||||
ImageRgb8u { image: Bitmap<RGB8U> },
|
||||
HTMLImageRgba8u { image: HTMLImage<RGBA8U> },
|
||||
HTMLImageRgb8u { image: HTMLImage<RGB8U> },
|
||||
RawRgb8u { image: ImageBuffer<RGB8U> },
|
||||
RawRgba8u { image: ImageBuffer<RGBA8U> },
|
||||
RawR32f { image: ImageBuffer<R32F> },
|
||||
RawR32i { image: ImageBuffer<R32I> },
|
||||
RawR16i { image: ImageBuffer<R16I> },
|
||||
RawR8ui { image: ImageBuffer<R8UI> },
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl1")]
|
||||
use crate::texture::format::{R16I, R32F, R32I, R8U};
|
||||
use crate::texture::Tex3D;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ImageType {
|
||||
FitsImage { raw_bytes: js_sys::Uint8Array },
|
||||
Canvas { canvas: Canvas<RGBA8U> },
|
||||
PngHTMLImageRgba8u { image: HTMLImage<RGBA8U> },
|
||||
JpgHTMLImageRgb8u { image: HTMLImage<RGB8U> },
|
||||
PngImageRgba8u { image: Bitmap<RGBA8U> },
|
||||
JpgImageRgb8u { image: Bitmap<RGB8U> },
|
||||
RawRgb8u { image: ImageBuffer<RGB8U> },
|
||||
RawRgba8u { image: ImageBuffer<RGBA8U> },
|
||||
RawR32f { image: ImageBuffer<R32F> },
|
||||
FitsRawBytes {
|
||||
raw_bytes: js_sys::Uint8Array,
|
||||
size: (u32, u32, u32),
|
||||
},
|
||||
Canvas {
|
||||
canvas: Canvas<RGBA8U>,
|
||||
},
|
||||
ImageRgba8u {
|
||||
image: Bitmap<RGBA8U>,
|
||||
},
|
||||
ImageRgb8u {
|
||||
image: Bitmap<RGB8U>,
|
||||
},
|
||||
HTMLImageRgba8u {
|
||||
image: HTMLImage<RGBA8U>,
|
||||
},
|
||||
HTMLImageRgb8u {
|
||||
image: HTMLImage<RGB8U>,
|
||||
},
|
||||
RawRgb8u {
|
||||
image: ImageBuffer<RGB8U>,
|
||||
},
|
||||
RawRgba8u {
|
||||
image: ImageBuffer<RGBA8U>,
|
||||
},
|
||||
RawR32f {
|
||||
image: ImageBuffer<R32F>,
|
||||
},
|
||||
RawR32i {
|
||||
image: ImageBuffer<R32I>,
|
||||
},
|
||||
RawR16i {
|
||||
image: ImageBuffer<R16I>,
|
||||
},
|
||||
RawR8ui {
|
||||
image: ImageBuffer<R8U>,
|
||||
},
|
||||
}
|
||||
|
||||
use cgmath::Vector3;
|
||||
@@ -298,24 +297,24 @@ impl Image for ImageType {
|
||||
offset: &Vector3<i32>,
|
||||
) -> Result<(), JsValue> {
|
||||
match self {
|
||||
ImageType::FitsImage {
|
||||
ImageType::FitsRawBytes {
|
||||
raw_bytes: raw_bytes_buf,
|
||||
..
|
||||
} => {
|
||||
let num_bytes = raw_bytes_buf.length() as usize;
|
||||
let mut raw_bytes = vec![0; num_bytes];
|
||||
raw_bytes_buf.copy_to(&mut raw_bytes[..]);
|
||||
let raw_bytes = raw_bytes_buf.to_vec();
|
||||
|
||||
let mut bytes_reader = Cursor::new(raw_bytes.as_slice());
|
||||
let fits_img = Fits::from_byte_slice(&mut bytes_reader)?;
|
||||
fits_img.insert_into_3d_texture(textures, offset)?
|
||||
let images = FitsImage::from_raw_bytes(&raw_bytes)?;
|
||||
for image in images {
|
||||
image.insert_into_3d_texture(textures, offset)?
|
||||
}
|
||||
}
|
||||
ImageType::Canvas { canvas } => canvas.insert_into_3d_texture(textures, offset)?,
|
||||
ImageType::ImageRgba8u { image } => image.insert_into_3d_texture(textures, offset)?,
|
||||
ImageType::ImageRgb8u { image } => image.insert_into_3d_texture(textures, offset)?,
|
||||
ImageType::HTMLImageRgba8u { image } => {
|
||||
ImageType::HTMLImageRgba8u { image, .. } => {
|
||||
image.insert_into_3d_texture(textures, offset)?
|
||||
}
|
||||
ImageType::HTMLImageRgb8u { image } => {
|
||||
ImageType::HTMLImageRgb8u { image, .. } => {
|
||||
image.insert_into_3d_texture(textures, offset)?
|
||||
}
|
||||
ImageType::RawRgb8u { image } => image.insert_into_3d_texture(textures, offset)?,
|
||||
@@ -328,4 +327,21 @@ impl Image for ImageType {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
match self {
|
||||
ImageType::FitsRawBytes { size, .. } => *size,
|
||||
ImageType::Canvas { canvas } => canvas.get_size(),
|
||||
ImageType::ImageRgba8u { image } => image.get_size(),
|
||||
ImageType::ImageRgb8u { image } => image.get_size(),
|
||||
ImageType::HTMLImageRgba8u { image } => image.get_size(),
|
||||
ImageType::HTMLImageRgb8u { image } => image.get_size(),
|
||||
ImageType::RawRgb8u { image } => image.get_size(),
|
||||
ImageType::RawRgba8u { image } => image.get_size(),
|
||||
ImageType::RawR32f { image } => image.get_size(),
|
||||
ImageType::RawR32i { image } => image.get_size(),
|
||||
ImageType::RawR16i { image } => image.get_size(),
|
||||
ImageType::RawR8ui { image } => image.get_size(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::texture::format::TextureFormat;
|
||||
|
||||
use crate::texture::pixel::Pixel;
|
||||
use crate::texture::Tex3D;
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
pub struct ImageBuffer<T>
|
||||
where
|
||||
T: ImageFormat,
|
||||
T: TextureFormat,
|
||||
{
|
||||
pub data: Vec<<<T as ImageFormat>::P as Pixel>::Item>,
|
||||
pub size: Vector2<i32>,
|
||||
pub data: Box<[<<T as TextureFormat>::P as Pixel>::Item]>,
|
||||
pub size: (u32, u32, u32),
|
||||
}
|
||||
|
||||
use crate::image::format::Bytes;
|
||||
use crate::texture::format::Bytes;
|
||||
|
||||
pub struct ImageBufferView {
|
||||
pub x: i32,
|
||||
@@ -22,56 +23,66 @@ pub struct ImageBufferView {
|
||||
use wasm_bindgen::JsValue;
|
||||
impl<T> ImageBuffer<T>
|
||||
where
|
||||
T: ImageFormat,
|
||||
T: TextureFormat,
|
||||
{
|
||||
pub fn new(data: Vec<<<T as ImageFormat>::P as Pixel>::Item>, width: i32, height: i32) -> Self {
|
||||
let size_buf = width * height * (T::NUM_CHANNELS as i32);
|
||||
debug_assert!(size_buf == data.len() as i32);
|
||||
pub fn new(
|
||||
data: Box<[<<T as TextureFormat>::P as Pixel>::Item]>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
depth: u32,
|
||||
) -> Self {
|
||||
let size_buf = width * height * depth * (T::NUM_CHANNELS as u32);
|
||||
debug_assert!(size_buf == data.len() as u32);
|
||||
//let buf = <<T as ImageFormat>::P as Pixel>::Container::new(buf);
|
||||
let size = Vector2::new(width, height);
|
||||
let size = (width, height, depth);
|
||||
Self { data, size }
|
||||
}
|
||||
|
||||
pub fn from_encoded_raw_bytes(
|
||||
raw_bytes: &[u8],
|
||||
width: i32,
|
||||
height: i32,
|
||||
width: u32,
|
||||
height: u32,
|
||||
) -> Result<Self, JsValue> {
|
||||
let mut decoded_bytes = match T::decode(raw_bytes).map_err(|e| JsValue::from_str(e))? {
|
||||
let mut decoded_bytes = match T::decode(raw_bytes).map_err(JsValue::from_str)? {
|
||||
Bytes::Borrowed(bytes) => bytes.to_vec(),
|
||||
Bytes::Owned(bytes) => bytes,
|
||||
};
|
||||
|
||||
let decoded_pixels = unsafe {
|
||||
decoded_bytes.set_len(
|
||||
decoded_bytes.len() / std::mem::size_of::<<<T as ImageFormat>::P as Pixel>::Item>(),
|
||||
decoded_bytes.len()
|
||||
/ std::mem::size_of::<<<T as TextureFormat>::P as Pixel>::Item>(),
|
||||
);
|
||||
std::mem::transmute(decoded_bytes)
|
||||
std::mem::transmute::<Vec<u8>, Vec<<<T as TextureFormat>::P as Pixel>::Item>>(
|
||||
decoded_bytes,
|
||||
)
|
||||
.into_boxed_slice()
|
||||
};
|
||||
|
||||
Ok(Self::new(decoded_pixels, width, height))
|
||||
Ok(Self::new(decoded_pixels, width, height, 1))
|
||||
}
|
||||
|
||||
pub fn from_raw_bytes(mut raw_bytes: Vec<u8>, width: i32, height: i32) -> Self {
|
||||
let size_buf = width * height * (std::mem::size_of::<T::P>() as i32);
|
||||
debug_assert!(size_buf == raw_bytes.len() as i32);
|
||||
pub fn from_raw_bytes(mut raw_bytes: Vec<u8>, width: u32, height: u32) -> Self {
|
||||
let size_buf = width * height * (std::mem::size_of::<T::P>() as u32);
|
||||
debug_assert!(size_buf == raw_bytes.len() as u32);
|
||||
|
||||
let decoded_pixels = unsafe {
|
||||
raw_bytes.set_len(
|
||||
raw_bytes.len() / std::mem::size_of::<<<T as ImageFormat>::P as Pixel>::Item>(),
|
||||
);
|
||||
std::mem::transmute(raw_bytes)
|
||||
raw_bytes.set_len(raw_bytes.len() / std::mem::size_of::<<T::P as Pixel>::Item>());
|
||||
std::mem::transmute::<Vec<u8>, Vec<<T::P as Pixel>::Item>>(raw_bytes).into_boxed_slice()
|
||||
};
|
||||
|
||||
Self::new(decoded_pixels, width, height)
|
||||
Self::new(decoded_pixels, width, height, 1)
|
||||
}
|
||||
|
||||
pub fn empty() -> Self {
|
||||
let size = Vector2::new(0, 0);
|
||||
Self { data: vec![], size }
|
||||
let size = (0, 0, 0);
|
||||
Self {
|
||||
data: Box::new([]),
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn allocate(pixel_fill: &<T as ImageFormat>::P, width: i32, height: i32) -> ImageBuffer<T> {
|
||||
pub fn allocate(pixel_fill: &T::P, width: u32, height: u32) -> ImageBuffer<T> {
|
||||
let size_buf = ((width * height) as usize) * (T::NUM_CHANNELS);
|
||||
|
||||
let data = pixel_fill
|
||||
@@ -80,9 +91,10 @@ where
|
||||
.cloned()
|
||||
.cycle()
|
||||
.take(size_buf)
|
||||
.collect::<Vec<_>>();
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice();
|
||||
|
||||
ImageBuffer::<T>::new(data, width, height)
|
||||
ImageBuffer::<T>::new(data, width, height, 1)
|
||||
}
|
||||
|
||||
pub fn tex_sub(&mut self, src: &Self, s: &ImageBufferView, d: &ImageBufferView) {
|
||||
@@ -91,8 +103,8 @@ where
|
||||
|
||||
for ix in s.x..(s.x + s.w) {
|
||||
for iy in s.y..(s.y + s.h) {
|
||||
let s_idx = (iy * src.width() + ix) as usize;
|
||||
let d_idx = (di * self.width() + dj) as usize;
|
||||
let s_idx = ((iy * src.width() as i32) + ix) as usize;
|
||||
let d_idx = ((di * self.width() as i32) + dj) as usize;
|
||||
|
||||
for i in 0..T::NUM_CHANNELS {
|
||||
let si = s_idx * T::NUM_CHANNELS + i;
|
||||
@@ -110,38 +122,38 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &<<T as ImageFormat>::P as Pixel>::Item> {
|
||||
pub fn iter(&self) -> impl Iterator<Item = &<T::P as Pixel>::Item> {
|
||||
self.data.iter()
|
||||
}
|
||||
|
||||
pub fn get_data(&self) -> &[<<T as ImageFormat>::P as Pixel>::Item] {
|
||||
pub fn get_data(&self) -> &[<T::P as Pixel>::Item] {
|
||||
&self.data
|
||||
}
|
||||
|
||||
pub fn width(&self) -> i32 {
|
||||
self.size.x
|
||||
pub fn width(&self) -> u32 {
|
||||
self.size.0
|
||||
}
|
||||
|
||||
pub fn height(&self) -> i32 {
|
||||
self.size.y
|
||||
pub fn height(&self) -> u32 {
|
||||
self.size.1
|
||||
}
|
||||
}
|
||||
|
||||
use crate::image::format::{R16I, R32F, R32I, R8UI, RGB8U, RGBA8U};
|
||||
use crate::texture::format::{R16I, R32F, R32I, R8U, RGB8U, RGBA8U};
|
||||
pub enum ImageBufferType {
|
||||
JPG(ImageBuffer<RGB8U>),
|
||||
PNG(ImageBuffer<RGBA8U>),
|
||||
R32F(ImageBuffer<R32F>),
|
||||
R8UI(ImageBuffer<R8UI>),
|
||||
R8UI(ImageBuffer<R8U>),
|
||||
R16I(ImageBuffer<R16I>),
|
||||
R32I(ImageBuffer<R32I>),
|
||||
}
|
||||
|
||||
use crate::image::{ArrayBuffer, Image};
|
||||
use cgmath::{Vector2, Vector3};
|
||||
use cgmath::Vector3;
|
||||
impl<I> Image for ImageBuffer<I>
|
||||
where
|
||||
I: ImageFormat,
|
||||
I: TextureFormat,
|
||||
{
|
||||
fn insert_into_3d_texture<T: Tex3D>(
|
||||
&self,
|
||||
@@ -150,15 +162,14 @@ where
|
||||
// An offset to write the image in the texture array
|
||||
offset: &Vector3<i32>,
|
||||
) -> Result<(), JsValue> {
|
||||
let js_array =
|
||||
<<<I as ImageFormat>::P as Pixel>::Container as ArrayBuffer>::new(&self.data);
|
||||
let js_array = <<I::P as Pixel>::Container as ArrayBuffer>::new(&self.data);
|
||||
textures.tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
offset.x,
|
||||
offset.y,
|
||||
offset.z,
|
||||
self.width(),
|
||||
self.height(),
|
||||
1,
|
||||
self.width() as i32,
|
||||
self.height() as i32,
|
||||
self.size.2 as i32,
|
||||
Some(js_array.as_ref()),
|
||||
);
|
||||
|
||||
@@ -166,7 +177,7 @@ where
|
||||
}
|
||||
|
||||
// The size of the image
|
||||
/*fn get_size(&self) -> &Vector2<i32> {
|
||||
&self.size
|
||||
}*/
|
||||
fn get_size(&self) -> (u32, u32, u32) {
|
||||
self.size
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern crate futures;
|
||||
extern crate jpeg_decoder as jpeg;
|
||||
extern crate png;
|
||||
//extern crate jpeg_decoder as jpeg;
|
||||
//extern crate png;
|
||||
extern crate serde_json;
|
||||
extern crate wasm_streams;
|
||||
//extern crate wasm_streams;
|
||||
|
||||
pub mod convert;
|
||||
pub mod image;
|
||||
|
||||
@@ -6,6 +6,11 @@ extern "C" {
|
||||
pub fn log(s: &str);
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! al_print {
|
||||
($($arg:tt)*) => { al_core::log(&format!("{:?}", $($arg),*)) };
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Helpers to hide some of the verbosity of web_sys
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ pub trait VertexAttribPointerType: std::marker::Sized {
|
||||
}
|
||||
}
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
use js_sys::WebAssembly;
|
||||
use wasm_bindgen::JsCast;
|
||||
impl VertexAttribPointerType for u8 {
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
@@ -308,7 +306,7 @@ impl VertexAttribPointerType for f32 {
|
||||
type ArrayBufferView = Float32Array;
|
||||
|
||||
fn array_buffer_view<'a, B: BufferDataStorage<'a, Self>>(data: B) -> Self::ArrayBufferView {
|
||||
let data = data.get_slice();
|
||||
/*let data = data.get_slice();
|
||||
//unsafe { Self::ArrayBufferView::view(&data) }
|
||||
let memory_buffer = wasm_bindgen::memory()
|
||||
.unchecked_ref::<WebAssembly::Memory>()
|
||||
@@ -316,7 +314,9 @@ impl VertexAttribPointerType for f32 {
|
||||
|
||||
let len = data.len();
|
||||
let ptr = data.as_ptr() as u32 / 4;
|
||||
Float32Array::new(&memory_buffer).subarray(ptr, ptr + len as u32)
|
||||
Float32Array::new(&memory_buffer).subarray(ptr, ptr + len as u32)*/
|
||||
let data = data.get_slice();
|
||||
unsafe { Self::ArrayBufferView::view(data) }
|
||||
}
|
||||
|
||||
fn buffer_sub_data_with_i32_and_array_buffer_view<'a, B: BufferDataStorage<'a, Self>>(
|
||||
@@ -409,9 +409,9 @@ impl ArrayBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_vertex_attrib_pointer_by_name<'a, T: VertexAttribPointerType>(
|
||||
pub fn set_vertex_attrib_pointer_by_name<T: VertexAttribPointerType>(
|
||||
&self,
|
||||
shader: &ShaderBound<'a>,
|
||||
shader: &ShaderBound<'_>,
|
||||
location: &str,
|
||||
) {
|
||||
let loc = shader.get_attrib_location(&self.gl, location);
|
||||
@@ -434,11 +434,7 @@ impl ArrayBuffer {
|
||||
.vertex_attrib_divisor_angle(loc as u32, 0);
|
||||
}
|
||||
|
||||
pub fn disable_vertex_attrib_pointer_by_name<'a>(
|
||||
&self,
|
||||
shader: &ShaderBound<'a>,
|
||||
location: &str,
|
||||
) {
|
||||
pub fn disable_vertex_attrib_pointer_by_name(&self, shader: &ShaderBound<'_>, location: &str) {
|
||||
let loc = shader.get_attrib_location(&self.gl, location);
|
||||
self.gl.disable_vertex_attrib_array(loc as u32);
|
||||
}
|
||||
@@ -466,6 +462,30 @@ impl ArrayBuffer {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*pub fn update_from_js_array<'a, T: VertexAttribPointerType>(
|
||||
&mut self,
|
||||
usage: u32,
|
||||
data: T::ArrayBufferView,
|
||||
) {
|
||||
self.bind();
|
||||
if self.len >= data.len() {
|
||||
T::buffer_sub_data_with_i32_and_array_buffer_view(
|
||||
&self.gl,
|
||||
data,
|
||||
WebGlRenderingCtx::ARRAY_BUFFER,
|
||||
);
|
||||
} else {
|
||||
self.len = data.len();
|
||||
|
||||
T::buffer_data_with_array_buffer_view(
|
||||
&self.gl,
|
||||
data,
|
||||
WebGlRenderingCtx::ARRAY_BUFFER,
|
||||
usage,
|
||||
);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
impl VertexBufferObject for ArrayBuffer {
|
||||
|
||||
@@ -49,7 +49,7 @@ impl ArrayBufferInstanced {
|
||||
// Total length
|
||||
let num_f32_in_buf = data.len() as i32;
|
||||
|
||||
let num_instances = num_f32_in_buf / (num_f32_per_instance as i32);
|
||||
let num_instances = num_f32_in_buf / num_f32_per_instance;
|
||||
let len = data.len();
|
||||
|
||||
let buffer = gl
|
||||
@@ -98,9 +98,9 @@ impl ArrayBufferInstanced {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_vertex_attrib_pointer_by_name<'a, T: VertexAttribPointerType>(
|
||||
pub fn set_vertex_attrib_pointer_by_name<T: VertexAttribPointerType>(
|
||||
&self,
|
||||
shader: &ShaderBound<'a>,
|
||||
shader: &ShaderBound<'_>,
|
||||
location: &str,
|
||||
) {
|
||||
let loc = shader.get_attrib_location(&self.gl, location);
|
||||
@@ -124,11 +124,7 @@ impl ArrayBufferInstanced {
|
||||
.vertex_attrib_divisor_angle(loc as u32, 1);
|
||||
}
|
||||
|
||||
pub fn disable_vertex_attrib_pointer_by_name<'a>(
|
||||
&self,
|
||||
shader: &ShaderBound<'a>,
|
||||
location: &str,
|
||||
) {
|
||||
pub fn disable_vertex_attrib_pointer_by_name(&self, shader: &ShaderBound<'_>, location: &str) {
|
||||
let loc = shader.get_attrib_location(&self.gl, location);
|
||||
|
||||
self.gl.disable_vertex_attrib_array(loc as u32);
|
||||
|
||||
@@ -37,7 +37,10 @@ impl ElementArrayBuffer {
|
||||
usage: u32,
|
||||
data: B,
|
||||
) -> ElementArrayBuffer {
|
||||
let buffer = gl.create_buffer().ok_or("failed to create buffer").unwrap_abort();
|
||||
let buffer = gl
|
||||
.create_buffer()
|
||||
.ok_or("failed to create buffer")
|
||||
.unwrap_abort();
|
||||
// Bind the buffer
|
||||
gl.bind_buffer(
|
||||
WebGlRenderingCtx::ELEMENT_ARRAY_BUFFER,
|
||||
|
||||
@@ -2,7 +2,7 @@ use {wasm_bindgen::prelude::*, web_sys::WebGlFramebuffer};
|
||||
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
// Internal format used for the framebuffer final texture
|
||||
use crate::image::format::RGBA8U;
|
||||
use crate::texture::format::RGBA8U;
|
||||
|
||||
pub struct FrameBufferObject {
|
||||
gl: WebGlContext,
|
||||
|
||||
@@ -117,7 +117,7 @@ pub mod vao {
|
||||
}
|
||||
|
||||
use web_sys::WebGl2RenderingContext;
|
||||
impl<'a, 'b> ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
impl<'a> ShaderVertexArrayObjectBound<'a, '_> {
|
||||
pub fn update_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
@@ -132,6 +132,20 @@ pub mod vao {
|
||||
self
|
||||
}
|
||||
|
||||
/*pub fn update_from_js_array<T: VertexAttribPointerType>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
js_array: T::ArrayBufferView,
|
||||
) -> &mut Self {
|
||||
self.vao
|
||||
.array_buffer
|
||||
.get_mut(attr)
|
||||
.unwrap_abort()
|
||||
.update_from_js_array::<T>(usage, js_array);
|
||||
self
|
||||
}*/
|
||||
|
||||
pub fn update_element_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
usage: u32,
|
||||
@@ -162,7 +176,7 @@ pub mod vao {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Drop for ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
impl Drop for ShaderVertexArrayObjectBound<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
@@ -173,7 +187,7 @@ pub mod vao {
|
||||
_shader: &'b ShaderBound<'b>,
|
||||
}
|
||||
|
||||
impl<'a, 'b> ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
impl ShaderVertexArrayObjectBoundRef<'_, '_> {
|
||||
pub fn draw_arrays(&self, mode: u32, byte_offset: i32, size: i32) {
|
||||
self.vao.gl.draw_arrays(mode, byte_offset, size);
|
||||
}
|
||||
@@ -211,7 +225,7 @@ pub mod vao {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Drop for ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
impl Drop for ShaderVertexArrayObjectBoundRef<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
@@ -362,373 +376,7 @@ pub mod vao {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for VertexArrayObjectBound<'a> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl1")]
|
||||
pub mod vao {
|
||||
use crate::object::array_buffer::ArrayBuffer;
|
||||
use crate::object::array_buffer_instanced::ArrayBufferInstanced;
|
||||
use crate::object::buffer_data::BufferDataStorage;
|
||||
use crate::object::element_array_buffer::ElementArrayBuffer;
|
||||
|
||||
use crate::webgl_ctx::WebGlContext;
|
||||
use crate::Abort;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct VertexArrayObject {
|
||||
array_buffer: HashMap<&'static str, ArrayBuffer>,
|
||||
array_buffer_instanced: HashMap<&'static str, ArrayBufferInstanced>,
|
||||
element_array_buffer: Option<ElementArrayBuffer>,
|
||||
|
||||
idx: u32, // Number of vertex attributes
|
||||
|
||||
gl: WebGlContext,
|
||||
}
|
||||
|
||||
impl VertexArrayObject {
|
||||
pub fn new(gl: &WebGlContext) -> VertexArrayObject {
|
||||
let array_buffer = HashMap::new();
|
||||
let array_buffer_instanced = HashMap::new();
|
||||
|
||||
let element_array_buffer = None;
|
||||
|
||||
let idx = 0;
|
||||
|
||||
let gl = gl.clone();
|
||||
VertexArrayObject {
|
||||
array_buffer,
|
||||
array_buffer_instanced,
|
||||
element_array_buffer,
|
||||
|
||||
idx,
|
||||
|
||||
gl,
|
||||
}
|
||||
}
|
||||
|
||||
// Shader has to be already bound before calling this
|
||||
// This returns a ShaderVertexArrayObjectBound for which it is possible
|
||||
// to add some buffers and or draw the buffers
|
||||
pub fn bind<'a, 'b>(
|
||||
&'a mut self,
|
||||
_shader: &'b ShaderBound<'b>,
|
||||
) -> ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
//self.gl.bind_vertex_array(Some(self.vao.as_ref()));
|
||||
|
||||
ShaderVertexArrayObjectBound { vao: self, _shader }
|
||||
}
|
||||
// Shader has to be already bound before calling this
|
||||
// This returns a ShaderVertexArrayObjectBound for which it is possible
|
||||
// to add some buffers and or draw the buffers
|
||||
pub fn bind_ref<'a, 'b>(
|
||||
&'a self,
|
||||
shader: &'b ShaderBound<'b>,
|
||||
) -> ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
//self.gl.bind_vertex_array(Some(self.vao.as_ref()));
|
||||
|
||||
ShaderVertexArrayObjectBoundRef { vao: self, shader }
|
||||
}
|
||||
|
||||
// No need to bind a shader here
|
||||
// This returns a VertexArrayObjectBound for which it is only possible to
|
||||
// update the buffers
|
||||
pub fn bind_for_update<'a>(&'a mut self) -> VertexArrayObjectBound<'a> {
|
||||
//self.gl.bind_vertex_array(Some(self.vao.as_ref()));
|
||||
|
||||
VertexArrayObjectBound { vao: self }
|
||||
}
|
||||
|
||||
/*pub fn bind_ref(&self) {
|
||||
self.gl.bind_vertex_array(Some(self.vao.as_ref()));
|
||||
}*/
|
||||
|
||||
pub fn num_elements(&self) -> usize {
|
||||
self.element_array_buffer
|
||||
.as_ref()
|
||||
.unwrap_abort()
|
||||
.num_elements()
|
||||
}
|
||||
|
||||
pub fn num_instances(&self) -> i32 {
|
||||
self.array_buffer_instanced
|
||||
.values()
|
||||
.next()
|
||||
.unwrap_abort()
|
||||
.num_instances()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for VertexArrayObject {
|
||||
fn drop(&mut self) {
|
||||
//self.unbind();
|
||||
//self.gl.delete_vertex_array(Some(self.vao.as_ref()));
|
||||
}
|
||||
}
|
||||
|
||||
use crate::shader::ShaderBound;
|
||||
pub struct ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
vao: &'a mut VertexArrayObject,
|
||||
_shader: &'b ShaderBound<'b>,
|
||||
}
|
||||
|
||||
use crate::VertexAttribPointerType;
|
||||
impl<'a, 'b> ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
pub fn update_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
array_data: B,
|
||||
) -> &mut Self {
|
||||
self.vao
|
||||
.array_buffer
|
||||
.get_mut(attr)
|
||||
.unwrap_abort()
|
||||
.update(usage, array_data);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn update_element_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
usage: u32,
|
||||
element_data: B,
|
||||
) -> &mut Self {
|
||||
if let Some(ref mut element_array_buffer) = self.vao.element_array_buffer {
|
||||
element_array_buffer.update(usage, element_data);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn update_instanced_array<B: BufferDataStorage<'a, f32>>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
array_data: B,
|
||||
) -> &mut Self {
|
||||
self.vao
|
||||
.array_buffer_instanced
|
||||
.get_mut(attr)
|
||||
.unwrap_abort()
|
||||
.update(array_data);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn unbind(&self) {
|
||||
//self.vao.gl.bind_vertex_array(None);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Drop for ShaderVertexArrayObjectBound<'a, 'b> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
pub struct ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
vao: &'a VertexArrayObject,
|
||||
shader: &'b ShaderBound<'b>,
|
||||
}
|
||||
use crate::object::array_buffer::VertexBufferObject;
|
||||
impl<'a, 'b> ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
pub fn draw_arrays(&self, mode: u32, byte_offset: i32, size: i32) {
|
||||
for (attr, buf) in self.vao.array_buffer.iter() {
|
||||
buf.bind();
|
||||
buf.set_vertex_attrib_pointer_by_name::<f32>(self.shader, attr);
|
||||
}
|
||||
|
||||
self.vao.gl.draw_arrays(mode, byte_offset, size);
|
||||
}
|
||||
|
||||
pub fn draw_elements_with_i32(
|
||||
&self,
|
||||
mode: u32,
|
||||
num_elements: Option<i32>,
|
||||
type_: u32,
|
||||
byte_offset: i32,
|
||||
) {
|
||||
for (attr, buf) in self.vao.array_buffer.iter() {
|
||||
buf.bind();
|
||||
buf.set_vertex_attrib_pointer_by_name::<f32>(self.shader, attr);
|
||||
}
|
||||
|
||||
let e = self.vao.element_array_buffer.as_ref().unwrap_abort();
|
||||
e.bind();
|
||||
let num_elements = num_elements.unwrap_or(self.vao.num_elements() as i32);
|
||||
self.vao
|
||||
.gl
|
||||
.draw_elements_with_i32(mode, num_elements, type_, byte_offset);
|
||||
}
|
||||
|
||||
pub fn draw_elements_instanced_with_i32(
|
||||
&self,
|
||||
mode: u32,
|
||||
offset_element_idx: i32,
|
||||
num_instances: i32,
|
||||
) {
|
||||
for (attr, buf) in self.vao.array_buffer.iter() {
|
||||
buf.bind();
|
||||
buf.set_vertex_attrib_pointer_by_name::<f32>(self.shader, attr);
|
||||
}
|
||||
|
||||
for (attr, inst_buf) in self.vao.array_buffer_instanced.iter() {
|
||||
inst_buf.bind();
|
||||
inst_buf.set_vertex_attrib_pointer_by_name::<f32>(self.shader, attr);
|
||||
}
|
||||
|
||||
let e = self.vao.element_array_buffer.as_ref().unwrap_abort();
|
||||
e.bind();
|
||||
|
||||
self.vao
|
||||
.gl
|
||||
.ext
|
||||
.angles
|
||||
.draw_elements_instanced_angle_with_i32(
|
||||
mode,
|
||||
self.vao.num_elements() as i32,
|
||||
WebGlRenderingCtx::UNSIGNED_SHORT,
|
||||
offset_element_idx,
|
||||
num_instances,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn unbind(&self) {
|
||||
//self.vao.gl.bind_vertex_array(None);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Drop for ShaderVertexArrayObjectBoundRef<'a, 'b> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
// Struct defined when only the Vertex Array Object is
|
||||
// defined
|
||||
pub struct VertexArrayObjectBound<'a> {
|
||||
vao: &'a mut VertexArrayObject,
|
||||
}
|
||||
|
||||
impl<'a> VertexArrayObjectBound<'a> {
|
||||
/// Precondition: self must be bound
|
||||
pub fn add_array_buffer<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
size: usize,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
data: B,
|
||||
) -> &mut Self {
|
||||
let array_buffer =
|
||||
ArrayBuffer::new(&self.vao.gl, self.vao.idx, 0, &[size], &[0], usage, data);
|
||||
|
||||
// Update the number of vertex attrib
|
||||
self.vao.idx += 1;
|
||||
|
||||
self.vao.array_buffer.insert(attr, array_buffer);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Precondition: self must be bound
|
||||
pub fn add_instanced_array_buffer<B: BufferDataStorage<'a, f32>>(
|
||||
&mut self,
|
||||
size: usize,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
data: B,
|
||||
) -> &mut Self {
|
||||
let array_buffer = ArrayBufferInstanced::new(
|
||||
&self.vao.gl,
|
||||
self.vao.idx,
|
||||
0,
|
||||
&[size],
|
||||
&[0],
|
||||
usage,
|
||||
data,
|
||||
);
|
||||
|
||||
// Update the number of vertex attrib
|
||||
self.vao.idx += 1;
|
||||
|
||||
self.vao.array_buffer_instanced.insert(attr, array_buffer);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Precondition: self must be bound
|
||||
pub fn add_element_buffer<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
usage: u32,
|
||||
data: B,
|
||||
) -> &mut Self {
|
||||
let element_buffer = ElementArrayBuffer::new(&self.vao.gl, usage, data);
|
||||
|
||||
self.vao.element_array_buffer = Some(element_buffer);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn update_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
array_data: B,
|
||||
) -> &mut Self {
|
||||
self.vao
|
||||
.array_buffer
|
||||
.get_mut(attr)
|
||||
.expect("cannot get attribute from the array buffer")
|
||||
.update(usage, array_data);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn update_element_array<T: VertexAttribPointerType, B: BufferDataStorage<'a, T>>(
|
||||
&mut self,
|
||||
usage: u32,
|
||||
element_data: B,
|
||||
) -> &mut Self {
|
||||
if let Some(ref mut element_array_buffer) = self.vao.element_array_buffer {
|
||||
element_array_buffer.update(usage, element_data);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
pub fn update_instanced_array<B: BufferDataStorage<'a, f32>>(
|
||||
&mut self,
|
||||
attr: &'static str,
|
||||
usage: u32,
|
||||
array_data: B,
|
||||
) -> &mut Self {
|
||||
self.vao
|
||||
.array_buffer_instanced
|
||||
.get_mut(attr)
|
||||
.expect("cannot get attribute from the array buffer")
|
||||
.update(usage, array_data);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/*pub fn append_to_instanced_array<B: BufferDataStorage<'a, f32>>(
|
||||
&mut self,
|
||||
idx: usize,
|
||||
buffer: B,
|
||||
) -> &mut Self {
|
||||
self.vao.array_buffer_instanced[idx].append(buffer);
|
||||
self
|
||||
}*/
|
||||
|
||||
pub fn unbind(&self) {
|
||||
//self.vao.gl.bind_vertex_array(None);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for VertexArrayObjectBound<'a> {
|
||||
impl Drop for VertexArrayObjectBound<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl Shader {
|
||||
pub trait UniformType {
|
||||
fn uniform(gl: &WebGlContext, location: Option<&WebGlUniformLocation>, value: &Self);
|
||||
|
||||
fn attach_uniform<'a>(name: &str, value: &Self, shader: &ShaderBound<'a>) {
|
||||
fn attach_uniform(name: &str, value: &Self, shader: &ShaderBound<'_>) {
|
||||
let location = shader.get_uniform_location(name);
|
||||
Self::uniform(&shader.gl, location, value);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ impl UniformType for ColorRGB {
|
||||
gl.uniform3f(location, value.r, value.g, value.b);
|
||||
}
|
||||
}
|
||||
impl<'a> UniformType for &'a ColorRGB {
|
||||
impl UniformType for &ColorRGB {
|
||||
fn uniform(gl: &WebGlContext, location: Option<&WebGlUniformLocation>, value: &Self) {
|
||||
gl.uniform3f(location, value.r, value.g, value.b);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ impl UniformType for ColorRGBA {
|
||||
gl.uniform4f(location, value.r, value.g, value.b, value.a);
|
||||
}
|
||||
}
|
||||
impl<'a> UniformType for &'a ColorRGBA {
|
||||
impl UniformType for &ColorRGBA {
|
||||
fn uniform(gl: &WebGlContext, location: Option<&WebGlUniformLocation>, value: &Self) {
|
||||
gl.uniform4f(location, value.r, value.g, value.b, value.a);
|
||||
}
|
||||
@@ -328,8 +328,9 @@ impl SendUniformsWithParams<Colormaps> for HiPSColor {
|
||||
) -> &'a ShaderBound<'a> {
|
||||
let reversed = self.reversed as u8 as f32;
|
||||
|
||||
let cmap = cmaps.get(&self.cmap_name.as_ref());
|
||||
let cmap = cmaps.get(self.cmap_name.as_ref());
|
||||
shader
|
||||
.attach_uniforms_from(cmaps)
|
||||
.attach_uniforms_with_params_from(cmap, cmaps)
|
||||
.attach_uniform("H", &self.stretch)
|
||||
.attach_uniform("min_value", &self.min_cut.unwrap_or(0.0))
|
||||
@@ -407,7 +408,7 @@ impl<'a> ShaderBound<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for ShaderBound<'a> {
|
||||
impl Drop for ShaderBound<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.unbind(&self.gl);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::texture::format::TextureFormat;
|
||||
use web_sys::HtmlCanvasElement;
|
||||
use web_sys::WebGlTexture;
|
||||
|
||||
@@ -19,11 +19,10 @@ pub struct Texture3D {
|
||||
texture: Option<WebGlTexture>,
|
||||
|
||||
metadata: Option<Rc<RefCell<Texture2DMeta>>>,
|
||||
_depth: i32,
|
||||
}
|
||||
|
||||
impl Texture3D {
|
||||
pub fn create_empty<F: ImageFormat>(
|
||||
pub fn create_empty<F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
// The weight of the individual textures
|
||||
width: i32,
|
||||
@@ -54,15 +53,14 @@ impl Texture3D {
|
||||
let metadata = Some(Rc::new(RefCell::new(Texture2DMeta {
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
internal_format: F::INTERNAL_FORMAT,
|
||||
format: F::FORMAT,
|
||||
type_: F::TYPE,
|
||||
ty: F::TYPE,
|
||||
pixel_type: F::PIXEL_TYPE,
|
||||
})));
|
||||
|
||||
Ok(Texture3D {
|
||||
texture,
|
||||
gl: gl.clone(),
|
||||
_depth: depth,
|
||||
metadata,
|
||||
})
|
||||
}
|
||||
@@ -71,7 +69,7 @@ impl Texture3D {
|
||||
self.gl.generate_mipmap(WebGlRenderingCtx::TEXTURE_3D);
|
||||
}
|
||||
|
||||
pub fn bind(&self) -> Texture3DBound {
|
||||
pub fn bind(&self) -> Texture3DBound<'_> {
|
||||
self.gl
|
||||
.bind_texture(WebGlRenderingCtx::TEXTURE_3D, self.texture.as_ref());
|
||||
|
||||
@@ -113,7 +111,7 @@ pub struct Texture3DBound<'a> {
|
||||
tex: &'a Texture3D,
|
||||
}
|
||||
|
||||
impl<'a> Texture3DBound<'a> {
|
||||
impl Texture3DBound<'_> {
|
||||
pub fn tex_sub_image_3d_with_html_image_element(
|
||||
&self,
|
||||
dx: i32,
|
||||
@@ -135,7 +133,7 @@ impl<'a> Texture3DBound<'a> {
|
||||
image.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 3d");
|
||||
@@ -162,7 +160,7 @@ impl<'a> Texture3DBound<'a> {
|
||||
canvas.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
canvas,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -189,12 +187,13 @@ impl<'a> Texture3DBound<'a> {
|
||||
image.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
&self,
|
||||
dx: i32,
|
||||
@@ -219,13 +218,14 @@ impl<'a> Texture3DBound<'a> {
|
||||
h,
|
||||
d,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn tex_sub_image_3d_with_opt_u8_array(
|
||||
&self,
|
||||
idx: i32,
|
||||
@@ -249,7 +249,7 @@ impl<'a> Texture3DBound<'a> {
|
||||
h,
|
||||
d,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
pixels,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::image::format::ImageFormat;
|
||||
use crate::texture::format::PixelType;
|
||||
use crate::texture::format::TextureFormat;
|
||||
use web_sys::HtmlCanvasElement;
|
||||
use web_sys::WebGlTexture;
|
||||
|
||||
@@ -21,7 +22,7 @@ pub struct Texture2DArray {
|
||||
}
|
||||
|
||||
impl Texture2DArray {
|
||||
pub fn create_empty<F: ImageFormat>(
|
||||
pub fn create_empty<F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
// The weight of the individual textures
|
||||
width: i32,
|
||||
@@ -52,9 +53,9 @@ impl Texture2DArray {
|
||||
let metadata = Some(Rc::new(RefCell::new(Texture2DMeta {
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
internal_format: F::INTERNAL_FORMAT,
|
||||
pixel_type: F::PIXEL_TYPE,
|
||||
ty: F::TYPE,
|
||||
format: F::FORMAT,
|
||||
type_: F::TYPE,
|
||||
})));
|
||||
|
||||
Ok(Texture2DArray {
|
||||
@@ -69,7 +70,7 @@ impl Texture2DArray {
|
||||
self.gl.generate_mipmap(WebGlRenderingCtx::TEXTURE_2D_ARRAY);
|
||||
}
|
||||
|
||||
pub fn bind(&self) -> Texture2DArrayBound {
|
||||
pub fn bind(&self) -> Texture2DArrayBound<'_> {
|
||||
self.gl
|
||||
.bind_texture(WebGlRenderingCtx::TEXTURE_2D_ARRAY, self.texture.as_ref());
|
||||
|
||||
@@ -90,7 +91,7 @@ impl Texture2DArray {
|
||||
|
||||
// Attach the texture as the first color attachment
|
||||
self.gl.framebuffer_texture_layer(
|
||||
WebGlRenderingCtx::READ_FRAMEBUFFER,
|
||||
WebGlRenderingCtx::FRAMEBUFFER,
|
||||
WebGlRenderingCtx::COLOR_ATTACHMENT0,
|
||||
self.texture.as_ref(),
|
||||
0,
|
||||
@@ -114,35 +115,31 @@ impl Texture2DArray {
|
||||
self.gl
|
||||
.viewport(0, 0, metadata.width as i32, metadata.height as i32);
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
let value = match (metadata.format, metadata.type_) {
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
let value = match metadata.pixel_type {
|
||||
PixelType::R8U => {
|
||||
let p = <[u8; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::SHORT) => {
|
||||
PixelType::R16I => {
|
||||
let p = <[i16; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::INT) => {
|
||||
PixelType::R32I => {
|
||||
let p = <[i32; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED, WebGlRenderingCtx::FLOAT) => {
|
||||
PixelType::R32F => {
|
||||
let p = <[f32; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RGB, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
PixelType::RGB8U => {
|
||||
let p = <[u8; 3]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p)?)
|
||||
}
|
||||
(WebGlRenderingCtx::RGBA, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
PixelType::RGBA8U => {
|
||||
let p = <[u8; 4]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p)?)
|
||||
}
|
||||
_ => Err(JsValue::from_str(
|
||||
"Pixel retrieval not implemented for that texture format.",
|
||||
)),
|
||||
};
|
||||
|
||||
// Unbind the framebuffer
|
||||
@@ -194,7 +191,7 @@ pub struct Texture2DArrayBound<'a> {
|
||||
tex: &'a Texture2DArray,
|
||||
}
|
||||
|
||||
impl<'a> Texture2DArrayBound<'a> {
|
||||
impl Texture2DArrayBound<'_> {
|
||||
pub fn tex_sub_image_3d_with_html_image_element(
|
||||
&self,
|
||||
dx: i32,
|
||||
@@ -216,7 +213,7 @@ impl<'a> Texture2DArrayBound<'a> {
|
||||
image.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 3d");
|
||||
@@ -243,7 +240,7 @@ impl<'a> Texture2DArrayBound<'a> {
|
||||
canvas.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
canvas,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -270,7 +267,7 @@ impl<'a> Texture2DArrayBound<'a> {
|
||||
image.height() as i32,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -299,7 +296,7 @@ impl<'a> Texture2DArrayBound<'a> {
|
||||
h,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -328,7 +325,7 @@ impl<'a> Texture2DArrayBound<'a> {
|
||||
h,
|
||||
1,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
pixels,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
|
||||
205
src/core/al-core/src/texture/format.rs
Normal file
@@ -0,0 +1,205 @@
|
||||
use crate::texture::pixel::Pixel;
|
||||
|
||||
pub type Bytes<'a> = std::borrow::Cow<'a, [u8]>;
|
||||
|
||||
pub trait TextureFormat {
|
||||
type P: Pixel;
|
||||
type ArrayBufferView: AsRef<js_sys::Object>;
|
||||
|
||||
const NUM_CHANNELS: usize;
|
||||
|
||||
const FORMAT: u32;
|
||||
const INTERNAL_FORMAT: i32;
|
||||
const TYPE: u32;
|
||||
|
||||
const PIXEL_TYPE: PixelType;
|
||||
|
||||
/// Creates a JS typed array which is a view into wasm's linear memory at the slice specified.
|
||||
/// This function returns a new typed array which is a view into wasm's memory. This view does not copy the underlying data.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// Views into WebAssembly memory are only valid so long as the backing buffer isn't resized in JS. Once this function is called any future calls to Box::new (or malloc of any form) may cause the returned value here to be invalidated. Use with caution!
|
||||
///
|
||||
/// Additionally the returned object can be safely mutated but the input slice isn't guaranteed to be mutable.
|
||||
///
|
||||
/// Finally, the returned object is disconnected from the input slice's lifetime, so there's no guarantee that the data is read at the right time.
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str>;
|
||||
}
|
||||
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGB8U;
|
||||
impl TextureFormat for RGB8U {
|
||||
type P = [u8; 3];
|
||||
|
||||
const NUM_CHANNELS: usize = 3;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGB;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGB8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const PIXEL_TYPE: PixelType = PixelType::RGB8U;
|
||||
|
||||
fn decode(_raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
todo!()
|
||||
/*let mut decoder = jpeg::Decoder::new(raw_bytes);
|
||||
let bytes = decoder
|
||||
.decode()
|
||||
.map_err(|_| "Cannot decoder jpeg. This image may not be compressed.")?;
|
||||
|
||||
Ok(Bytes::Owned(bytes))*/
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct RGBA8U;
|
||||
impl TextureFormat for RGBA8U {
|
||||
type P = [u8; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const PIXEL_TYPE: PixelType = PixelType::RGBA8U;
|
||||
|
||||
fn decode(_raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
/*let mut decoder = jpeg::Decoder::new(raw_bytes);
|
||||
let bytes = decoder
|
||||
.decode()
|
||||
.map_err(|_| "Cannot decoder png. This image may not be compressed.")?;
|
||||
|
||||
Ok(Bytes::Owned(bytes))
|
||||
*/
|
||||
todo!()
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R32F;
|
||||
impl TextureFormat for R32F {
|
||||
type P = [u8; 4];
|
||||
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const PIXEL_TYPE: PixelType = PixelType::R32F;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R8U;
|
||||
impl TextureFormat for R8U {
|
||||
type P = [u8; 1];
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RED;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::R8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const NUM_CHANNELS: usize = 1;
|
||||
const PIXEL_TYPE: PixelType = PixelType::R8U;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R16I;
|
||||
impl TextureFormat for R16I {
|
||||
type P = [u8; 2];
|
||||
|
||||
const NUM_CHANNELS: usize = 2;
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RG;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RG8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
|
||||
const PIXEL_TYPE: PixelType = PixelType::R16I;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
|
||||
pub struct R32I;
|
||||
impl TextureFormat for R32I {
|
||||
type P = [u8; 4];
|
||||
|
||||
const FORMAT: u32 = WebGlRenderingCtx::RGBA;
|
||||
const INTERNAL_FORMAT: i32 = WebGlRenderingCtx::RGBA8 as i32;
|
||||
const TYPE: u32 = WebGlRenderingCtx::UNSIGNED_BYTE;
|
||||
const NUM_CHANNELS: usize = 4;
|
||||
|
||||
const PIXEL_TYPE: PixelType = PixelType::R32I;
|
||||
|
||||
fn decode(raw_bytes: &[u8]) -> Result<Bytes<'_>, &'static str> {
|
||||
Ok(Bytes::Borrowed(raw_bytes))
|
||||
}
|
||||
|
||||
type ArrayBufferView = js_sys::Uint8Array;
|
||||
|
||||
unsafe fn view(s: &[<Self::P as Pixel>::Item]) -> Self::ArrayBufferView {
|
||||
Self::ArrayBufferView::view(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
||||
pub enum PixelType {
|
||||
R8U,
|
||||
R16I,
|
||||
R32I,
|
||||
R32F,
|
||||
RGB8U,
|
||||
RGBA8U,
|
||||
}
|
||||
|
||||
impl PixelType {
|
||||
pub const fn num_channels(&self) -> usize {
|
||||
match self {
|
||||
Self::RGB8U => 3,
|
||||
Self::RGBA8U => 4,
|
||||
_ => 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod array;
|
||||
pub use array::Texture2DArray;
|
||||
|
||||
pub mod format;
|
||||
pub mod pixel;
|
||||
pub use pixel::*;
|
||||
|
||||
@@ -11,6 +12,7 @@ pub use mod_3d::Texture3D;
|
||||
use web_sys::HtmlCanvasElement;
|
||||
use web_sys::WebGlTexture;
|
||||
|
||||
use crate::texture::format::PixelType;
|
||||
use crate::webgl_ctx::WebGlContext;
|
||||
use crate::webgl_ctx::WebGlRenderingCtx;
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -23,8 +25,8 @@ pub static mut CUR_IDX_TEX_UNIT: u8 = 0;
|
||||
#[allow(dead_code)]
|
||||
pub struct Texture2DMeta {
|
||||
pub format: u32,
|
||||
pub internal_format: i32,
|
||||
pub type_: u32,
|
||||
pub ty: u32,
|
||||
pub pixel_type: PixelType,
|
||||
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
@@ -45,13 +47,13 @@ pub enum SamplerType {
|
||||
Unsigned,
|
||||
}
|
||||
|
||||
use crate::image::format::ImageFormat;
|
||||
//use super::pixel::PixelType;
|
||||
use crate::texture::format::TextureFormat;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
impl Texture2D {
|
||||
pub fn create_from_path<P: AsRef<Path>, F: ImageFormat>(
|
||||
pub fn create_from_path<P: AsRef<Path>, F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
name: &'static str,
|
||||
src: &P,
|
||||
@@ -59,12 +61,11 @@ impl Texture2D {
|
||||
) -> Result<Texture2D, JsValue> {
|
||||
let image = HtmlImageElement::new().unwrap_abort();
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
let texture = gl.create_texture();
|
||||
|
||||
let onerror = {
|
||||
Closure::wrap(Box::new(move || {
|
||||
println!("Cannot load texture located at: {:?}", name);
|
||||
println!("Cannot load texture located at: {name:?}");
|
||||
}) as Box<dyn Fn()>)
|
||||
};
|
||||
|
||||
@@ -72,14 +73,13 @@ impl Texture2D {
|
||||
let height = image.height();
|
||||
|
||||
let metadata = Rc::new(RefCell::new(Texture2DMeta {
|
||||
width: width,
|
||||
height: height,
|
||||
internal_format: F::INTERNAL_FORMAT,
|
||||
width,
|
||||
height,
|
||||
format: F::FORMAT,
|
||||
type_: F::TYPE,
|
||||
ty: F::TYPE,
|
||||
pixel_type: F::PIXEL_TYPE,
|
||||
}));
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
let onload = {
|
||||
let image = image.clone();
|
||||
let gl = gl.clone();
|
||||
@@ -129,7 +129,6 @@ impl Texture2D {
|
||||
|
||||
let gl = gl.clone();
|
||||
Ok(Texture2D {
|
||||
#[cfg(feature = "webgl2")]
|
||||
texture,
|
||||
|
||||
gl,
|
||||
@@ -138,7 +137,7 @@ impl Texture2D {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn create_from_raw_pixels<F: ImageFormat>(
|
||||
pub fn create_from_raw_pixels<F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
width: i32,
|
||||
height: i32,
|
||||
@@ -163,12 +162,12 @@ impl Texture2D {
|
||||
Ok(texture)
|
||||
}
|
||||
|
||||
pub fn create_from_raw_bytes<F: ImageFormat>(
|
||||
pub fn create_from_raw_bytes<F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
width: i32,
|
||||
height: i32,
|
||||
tex_params: &'static [(u32, u32)],
|
||||
bytes: Option<&[u8]>,
|
||||
bytes: &[u8],
|
||||
) -> Result<Texture2D, JsValue> {
|
||||
let texture = gl.create_texture();
|
||||
|
||||
@@ -185,7 +184,14 @@ impl Texture2D {
|
||||
width,
|
||||
height,
|
||||
);
|
||||
gl.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_u8_array(
|
||||
let view = unsafe {
|
||||
let len = bytes.len() / (std::mem::size_of::<<F::P as Pixel>::Item>());
|
||||
let pixels =
|
||||
std::slice::from_raw_parts(bytes.as_ptr() as *const <F::P as Pixel>::Item, len);
|
||||
F::view(pixels)
|
||||
};
|
||||
|
||||
gl.tex_sub_image_2d_with_i32_and_i32_and_u32_and_type_and_opt_array_buffer_view(
|
||||
WebGlRenderingCtx::TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
@@ -194,7 +200,7 @@ impl Texture2D {
|
||||
height,
|
||||
F::FORMAT,
|
||||
F::TYPE,
|
||||
bytes,
|
||||
Some(view.as_ref()),
|
||||
)
|
||||
.expect("Texture 2D");
|
||||
|
||||
@@ -202,9 +208,9 @@ impl Texture2D {
|
||||
let metadata = Some(Rc::new(RefCell::new(Texture2DMeta {
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
internal_format: F::INTERNAL_FORMAT,
|
||||
format: F::FORMAT,
|
||||
type_: F::TYPE,
|
||||
ty: F::TYPE,
|
||||
pixel_type: F::PIXEL_TYPE,
|
||||
})));
|
||||
|
||||
Ok(Texture2D {
|
||||
@@ -216,7 +222,7 @@ impl Texture2D {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn create_empty_with_format<F: ImageFormat>(
|
||||
pub fn create_empty_with_format<F: TextureFormat>(
|
||||
gl: &WebGlContext,
|
||||
width: i32,
|
||||
height: i32,
|
||||
@@ -242,15 +248,14 @@ impl Texture2D {
|
||||
let metadata = Some(Rc::new(RefCell::new(Texture2DMeta {
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
internal_format: F::INTERNAL_FORMAT,
|
||||
format: F::FORMAT,
|
||||
type_: F::TYPE,
|
||||
ty: F::TYPE,
|
||||
pixel_type: F::PIXEL_TYPE,
|
||||
})));
|
||||
|
||||
Ok(Texture2D {
|
||||
texture,
|
||||
|
||||
gl,
|
||||
|
||||
metadata,
|
||||
})
|
||||
}
|
||||
@@ -290,7 +295,7 @@ impl Texture2D {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn bind(&self) -> Texture2DBound {
|
||||
pub fn bind(&self) -> Texture2DBound<'_> {
|
||||
self.gl
|
||||
.bind_texture(WebGlRenderingCtx::TEXTURE_2D, self.texture.as_ref());
|
||||
|
||||
@@ -306,7 +311,7 @@ impl Texture2D {
|
||||
// Attach the texture as the first color attachment
|
||||
//self.attach_to_framebuffer();
|
||||
self.gl.framebuffer_texture_2d(
|
||||
WebGlRenderingCtx::READ_FRAMEBUFFER,
|
||||
WebGlRenderingCtx::FRAMEBUFFER,
|
||||
WebGlRenderingCtx::COLOR_ATTACHMENT0,
|
||||
WebGlRenderingCtx::TEXTURE_2D,
|
||||
self.texture.as_ref(),
|
||||
@@ -330,35 +335,31 @@ impl Texture2D {
|
||||
self.gl
|
||||
.viewport(0, 0, metadata.width as i32, metadata.height as i32);
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
let value = match (metadata.format, metadata.type_) {
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
let value = match metadata.pixel_type {
|
||||
PixelType::R8U => {
|
||||
let p = <[u8; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::SHORT) => {
|
||||
PixelType::R16I => {
|
||||
let p = <[i16; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED_INTEGER, WebGlRenderingCtx::INT) => {
|
||||
PixelType::R32I => {
|
||||
let p = <[i32; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RED, WebGlRenderingCtx::FLOAT) => {
|
||||
PixelType::R32F => {
|
||||
let p = <[f32; 1]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p[0])?)
|
||||
}
|
||||
(WebGlRenderingCtx::RGB, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
PixelType::RGB8U => {
|
||||
let p = <[u8; 3]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p)?)
|
||||
}
|
||||
(WebGlRenderingCtx::RGBA, WebGlRenderingCtx::UNSIGNED_BYTE) => {
|
||||
PixelType::RGBA8U => {
|
||||
let p = <[u8; 4]>::read_pixel(&self.gl, x, y)?;
|
||||
Ok(serde_wasm_bindgen::to_value(&p)?)
|
||||
}
|
||||
_ => Err(JsValue::from_str(
|
||||
"Pixel retrieval not implemented for that texture format.",
|
||||
)),
|
||||
};
|
||||
|
||||
// Unbind the framebuffer
|
||||
@@ -399,7 +400,7 @@ pub struct Texture2DBound<'a> {
|
||||
texture_2d: &'a Texture2D,
|
||||
}
|
||||
|
||||
impl<'a> Texture2DBound<'a> {
|
||||
impl Texture2DBound<'_> {
|
||||
pub fn tex_sub_image_2d_with_u32_and_u32_and_html_image_element(
|
||||
&self,
|
||||
dx: i32,
|
||||
@@ -417,24 +418,10 @@ impl<'a> Texture2DBound<'a> {
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
#[cfg(feature = "webgl1")]
|
||||
self.texture_2d
|
||||
.gl
|
||||
.tex_sub_image_2d_with_u32_and_u32_and_image(
|
||||
WebGlRenderingCtx::TEXTURE_2D,
|
||||
0,
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
//self.texture_2d.gl.flush();
|
||||
}
|
||||
|
||||
pub fn tex_sub_image_2d_with_u32_and_u32_and_html_canvas_element(
|
||||
@@ -454,24 +441,10 @@ impl<'a> Texture2DBound<'a> {
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
canvas,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
#[cfg(feature = "webgl1")]
|
||||
self.texture_2d
|
||||
.gl
|
||||
.tex_sub_image_2d_with_u32_and_u32_and_canvas(
|
||||
WebGlRenderingCtx::TEXTURE_2D,
|
||||
0,
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
canvas,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
//self.texture_2d.gl.flush();
|
||||
}
|
||||
|
||||
pub fn tex_sub_image_2d_with_u32_and_u32_and_image_bitmap(
|
||||
@@ -491,7 +464,7 @@ impl<'a> Texture2DBound<'a> {
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -504,7 +477,7 @@ impl<'a> Texture2DBound<'a> {
|
||||
dx,
|
||||
dy,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -530,7 +503,7 @@ impl<'a> Texture2DBound<'a> {
|
||||
width,
|
||||
height,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
image,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -556,7 +529,7 @@ impl<'a> Texture2DBound<'a> {
|
||||
width,
|
||||
height,
|
||||
metadata.format,
|
||||
metadata.type_,
|
||||
metadata.ty,
|
||||
pixels,
|
||||
)
|
||||
.expect("Sub texture 2d");
|
||||
@@ -588,6 +561,7 @@ pub trait Tex3D {
|
||||
image: &web_sys::ImageBitmap,
|
||||
);
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn tex_sub_image_3d_with_opt_array_buffer_view(
|
||||
&self,
|
||||
dx: i32,
|
||||
@@ -599,6 +573,7 @@ pub trait Tex3D {
|
||||
view: Option<&js_sys::Object>,
|
||||
);
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn tex_sub_image_3d_with_opt_u8_array(
|
||||
&self,
|
||||
dx: i32,
|
||||
|
||||
@@ -21,133 +21,6 @@ pub trait Pixel:
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue>;
|
||||
}
|
||||
|
||||
impl Pixel for [f32; 4] {
|
||||
type Item = f32;
|
||||
type Container = ArrayF32;
|
||||
const BLACK: Self = [std::f32::NAN; 4];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Float32Array::new_with_length(4);
|
||||
#[cfg(feature = "webgl2")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGBA32F,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
#[cfg(feature = "webgl1")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGBA,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
|
||||
let pixels = pixels.to_vec();
|
||||
Ok([pixels[0], pixels[1], pixels[2], pixels[3]])
|
||||
}
|
||||
}
|
||||
impl Pixel for [f32; 3] {
|
||||
type Item = f32;
|
||||
type Container = ArrayF32;
|
||||
const BLACK: Self = [std::f32::NAN; 3];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Float32Array::new_with_length(3);
|
||||
#[cfg(feature = "webgl2")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGB32F,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
#[cfg(feature = "webgl1")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGB,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
|
||||
let pixels = pixels.to_vec();
|
||||
Ok([pixels[0], pixels[1], pixels[2]])
|
||||
}
|
||||
}
|
||||
impl Pixel for [f32; 1] {
|
||||
type Item = f32;
|
||||
type Container = ArrayF32;
|
||||
const BLACK: Self = [std::f32::NAN];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Float32Array::new_with_length(1);
|
||||
#[cfg(feature = "webgl2")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RED,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
#[cfg(feature = "webgl1")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::LUMINANCE_ALPHA,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
|
||||
Ok([pixels.to_vec()[0]])
|
||||
}
|
||||
}
|
||||
/*use crate::image::ArrayF64;
|
||||
impl Pixel for [f64; 1] {
|
||||
type Item = f64;
|
||||
type Container = ArrayF64;
|
||||
const BLACK: Self = [std::f64::NAN];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Float32Array::new_with_length(1);
|
||||
#[cfg(feature = "webgl2")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RED,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
#[cfg(feature = "webgl1")]
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::LUMINANCE_ALPHA,
|
||||
WebGlRenderingCtx::FLOAT,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
|
||||
Ok([pixels.to_vec()[0] as f64])
|
||||
}
|
||||
}*/
|
||||
impl Pixel for [u8; 4] {
|
||||
type Item = u8;
|
||||
type Container = ArrayU8;
|
||||
@@ -175,13 +48,13 @@ impl Pixel for [u8; 3] {
|
||||
const BLACK: Self = [0, 0, 0];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Uint8Array::new_with_length(3);
|
||||
let pixels = js_sys::Uint8Array::new_with_length(4);
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGB,
|
||||
WebGlRenderingCtx::RGBA,
|
||||
WebGlRenderingCtx::UNSIGNED_BYTE,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
@@ -189,7 +62,27 @@ impl Pixel for [u8; 3] {
|
||||
Ok([pixels[0], pixels[1], pixels[2]])
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "webgl2")]
|
||||
impl Pixel for [u8; 2] {
|
||||
type Item = u8;
|
||||
type Container = ArrayU8;
|
||||
const BLACK: Self = [0, 0];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Uint8Array::new_with_length(2);
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RG,
|
||||
WebGlRenderingCtx::UNSIGNED_BYTE,
|
||||
Some(&pixels),
|
||||
)?;
|
||||
let pixels = pixels.to_vec();
|
||||
Ok([pixels[0], pixels[1]])
|
||||
}
|
||||
}
|
||||
|
||||
impl Pixel for [u8; 1] {
|
||||
type Item = u8;
|
||||
type Container = ArrayU8;
|
||||
@@ -210,45 +103,76 @@ impl Pixel for [u8; 1] {
|
||||
Ok([pixels.to_vec()[0]])
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "webgl2")]
|
||||
|
||||
impl Pixel for [i16; 1] {
|
||||
type Item = i16;
|
||||
type Container = ArrayI16;
|
||||
const BLACK: Self = [std::i16::MIN];
|
||||
const BLACK: Self = [i16::MIN];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Int16Array::new_with_length(1);
|
||||
let p = js_sys::Uint8Array::new_with_length(2);
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RED_INTEGER,
|
||||
WebGlRenderingCtx::SHORT,
|
||||
Some(&pixels),
|
||||
WebGlRenderingCtx::RG,
|
||||
WebGlRenderingCtx::UNSIGNED_BYTE,
|
||||
Some(&p),
|
||||
)?;
|
||||
|
||||
Ok([pixels.to_vec()[0]])
|
||||
Ok([i16::from_le_bytes([p.at(1).unwrap(), p.at(0).unwrap()])])
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "webgl2")]
|
||||
|
||||
impl Pixel for [i32; 1] {
|
||||
type Item = i32;
|
||||
type Container = ArrayI32;
|
||||
const BLACK: Self = [std::i32::MIN];
|
||||
const BLACK: Self = [i32::MIN];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let pixels = js_sys::Int32Array::new_with_length(1);
|
||||
let p = js_sys::Uint8Array::new_with_length(4);
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RED_INTEGER,
|
||||
WebGlRenderingCtx::INT,
|
||||
Some(&pixels),
|
||||
WebGlRenderingCtx::RGBA,
|
||||
WebGlRenderingCtx::UNSIGNED_BYTE,
|
||||
Some(&p),
|
||||
)?;
|
||||
|
||||
Ok([pixels.to_vec()[0]])
|
||||
Ok([i32::from_le_bytes([
|
||||
p.at(3).unwrap(),
|
||||
p.at(2).unwrap(),
|
||||
p.at(1).unwrap(),
|
||||
p.at(0).unwrap(),
|
||||
])])
|
||||
}
|
||||
}
|
||||
|
||||
impl Pixel for [f32; 1] {
|
||||
type Item = f32;
|
||||
type Container = ArrayF32;
|
||||
const BLACK: Self = [f32::NAN];
|
||||
|
||||
fn read_pixel(gl: &WebGlContext, x: i32, y: i32) -> Result<Self, JsValue> {
|
||||
let p = js_sys::Uint8Array::new_with_length(4);
|
||||
gl.read_pixels_with_opt_array_buffer_view(
|
||||
x,
|
||||
y,
|
||||
1,
|
||||
1,
|
||||
WebGlRenderingCtx::RGBA,
|
||||
WebGlRenderingCtx::UNSIGNED_BYTE,
|
||||
Some(&p),
|
||||
)?;
|
||||
|
||||
Ok([f32::from_le_bytes([
|
||||
p.at(3).unwrap(),
|
||||
p.at(2).unwrap(),
|
||||
p.at(1).unwrap(),
|
||||
p.at(0).unwrap(),
|
||||
])])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,17 +4,11 @@ use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::HtmlElement;
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
pub type WebGlRenderingCtx = web_sys::WebGl2RenderingContext;
|
||||
#[cfg(feature = "webgl1")]
|
||||
pub type WebGlRenderingCtx = web_sys::WebGlRenderingContext;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WebGlContext {
|
||||
inner: Rc<WebGlRenderingCtx>,
|
||||
|
||||
#[cfg(feature = "webgl1")]
|
||||
pub ext: WebGlExt,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -55,32 +49,19 @@ impl WebGlContext {
|
||||
|
||||
#[cfg(feature = "webgl2")]
|
||||
{
|
||||
if let Ok(r) =
|
||||
/*if let Ok(r) =
|
||||
get_extension::<web_sys::ExtColorBufferFloat>(&gl, "EXT_color_buffer_float")
|
||||
{
|
||||
let _ = r;
|
||||
}
|
||||
}*/
|
||||
|
||||
let ctx = WebGlContext { inner: gl };
|
||||
Ok(ctx)
|
||||
}
|
||||
|
||||
#[cfg(feature = "webgl1")]
|
||||
{
|
||||
let angles_ext =
|
||||
get_extension::<web_sys::AngleInstancedArrays>(&gl, "ANGLE_instanced_arrays")?;
|
||||
let _ = get_extension::<web_sys::OesTextureFloat>(&gl, "OES_texture_float")?;
|
||||
let _ = get_extension::<web_sys::ExtSRgb>(&gl, "EXT_sRGB")?;
|
||||
|
||||
Ok(WebGlContext {
|
||||
inner: gl,
|
||||
ext: WebGlExt { angles: angles_ext },
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_extension<T>(context: &WebGlRenderingCtx, name: &str) -> Result<T, JsValue>
|
||||
fn _get_extension<T>(context: &WebGlRenderingCtx, name: &str) -> Result<T, JsValue>
|
||||
where
|
||||
T: wasm_bindgen::JsCast,
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@ use walkdir::WalkDir;
|
||||
extern crate walkdir;
|
||||
use std::io::BufRead;
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
// All my shaders reside in the 'src/shaders' directory
|
||||
fn generate_shaders() -> std::result::Result<(), Box<dyn Error>> {
|
||||
println!("generate shaders");
|
||||
@@ -23,16 +25,54 @@ fn generate_shaders() -> std::result::Result<(), Box<dyn Error>> {
|
||||
.unwrap()
|
||||
//.with_extension("")
|
||||
.to_string_lossy()
|
||||
.to_owned()
|
||||
.into_owned()
|
||||
.replace("/", "_")
|
||||
.replace("\\", "_");
|
||||
//let out_name = format!("{}/{}", OUT_PATH, out_file_name);
|
||||
|
||||
let src = read_shader(path)?;
|
||||
let mut src = read_shader(path)?;
|
||||
|
||||
if std::env::var("CARGO_FEATURE_MINIFY_SHADERS").is_ok() {
|
||||
println!("Feature `minify_shaders` enabled: running shader minifier");
|
||||
|
||||
// save to a minified path
|
||||
let mut tmp_path = PathBuf::from(path);
|
||||
let mut min_path = PathBuf::from(path);
|
||||
|
||||
let stem = path.file_stem().unwrap();
|
||||
// Build new filename: stem + ".min" + extension
|
||||
let tmp_file_name =
|
||||
format!("{}.{}.tmp", stem.to_string_lossy(), ext.to_string_lossy());
|
||||
tmp_path.set_file_name(tmp_file_name);
|
||||
|
||||
let min_file_name =
|
||||
format!("{}.{}.min", stem.to_string_lossy(), ext.to_string_lossy());
|
||||
min_path.set_file_name(min_file_name);
|
||||
|
||||
fs::write(tmp_path.clone(), &src)?;
|
||||
|
||||
Command::new("mono")
|
||||
.args([
|
||||
"/Users/matthieubaumann/Downloads/shader_minifier.exe",
|
||||
"--format",
|
||||
"text",
|
||||
"--aggressive-inlining",
|
||||
"--preserve-externals",
|
||||
"--move-declarations",
|
||||
"-o",
|
||||
min_path.as_os_str().to_str().expect("Invalid UTF-8!"),
|
||||
tmp_path.as_os_str().to_str().expect("Invalid UTF-8!"),
|
||||
])
|
||||
.status()
|
||||
.expect("Failed to run shader_minifier");
|
||||
|
||||
src = read_shader(min_path)?;
|
||||
} else {
|
||||
println!("Feature `minify_shaders` not enabled: skipping");
|
||||
}
|
||||
|
||||
shaders.insert(out_file_name, src);
|
||||
|
||||
//fs::write(&out_name, result)?;
|
||||
println!("cargo:rerun-if-changed=src/shaders/{}", file_name);
|
||||
println!("cargo:rerun-if-changed=src/shaders/{file_name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,16 +89,21 @@ fn read_shader<P: AsRef<std::path::Path>>(path: P) -> std::io::Result<String> {
|
||||
|
||||
let shader_src = std::io::BufReader::new(file)
|
||||
.lines()
|
||||
.flatten()
|
||||
.map(|l| {
|
||||
.map_while(Result::ok)
|
||||
.filter_map(|l| {
|
||||
if l.starts_with("#include") {
|
||||
let incl_file_names: Vec<_> = l.split_terminator(&[';', ' '][..]).collect();
|
||||
let incl_file_name_rel = incl_file_names[1];
|
||||
let incl_file_name = path.parent().unwrap().join(incl_file_name_rel);
|
||||
|
||||
read_shader(incl_file_name.to_str().unwrap()).unwrap()
|
||||
println!("{}", incl_file_name.to_string_lossy());
|
||||
|
||||
Some(read_shader(incl_file_name.to_str().unwrap()).unwrap())
|
||||
} else if l.trim_start().starts_with("//") {
|
||||
// comment
|
||||
None
|
||||
} else {
|
||||
l
|
||||
Some(l)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
@@ -76,7 +121,6 @@ pub fn write(path: PathBuf, entries: HashMap<String, String>) -> Result<(), Box<
|
||||
let mut all_the_files = File::create(&path)?;
|
||||
|
||||
writeln!(&mut all_the_files, r#"use std::collections::HashMap;"#,)?;
|
||||
writeln!(&mut all_the_files, r#""#,)?;
|
||||
writeln!(&mut all_the_files, r#"#[allow(dead_code)]"#,)?;
|
||||
writeln!(
|
||||
&mut all_the_files,
|
||||
@@ -87,7 +131,10 @@ pub fn write(path: PathBuf, entries: HashMap<String, String>) -> Result<(), Box<
|
||||
for (name, content) in entries {
|
||||
writeln!(
|
||||
&mut all_the_files,
|
||||
r##" out.insert(r"{name}", r#"{content}"#);"##,
|
||||
r##" out.insert(
|
||||
r"{name}",
|
||||
r#"{content}"#,
|
||||
);"##,
|
||||
)?;
|
||||
}
|
||||
|
||||
|
||||
1205
src/core/src/app.rs
25
src/core/src/browser_support.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use js_sys::Reflect;
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::window;
|
||||
|
||||
pub struct BrowserFeaturesSupport {
|
||||
pub create_image_bitmap: bool,
|
||||
}
|
||||
|
||||
impl Default for BrowserFeaturesSupport {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl BrowserFeaturesSupport {
|
||||
pub fn new() -> Self {
|
||||
let window = window().expect("no global `window` exists");
|
||||
let create_image_bitmap =
|
||||
Reflect::has(&window, &JsValue::from_str("createImageBitmap")).unwrap_or(false);
|
||||
|
||||
Self {
|
||||
create_image_bitmap,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,8 @@ fn linspace(a: f64, b: f64, num: usize) -> Vec<f64> {
|
||||
res
|
||||
}
|
||||
|
||||
const NUM_VERTICES_WIDTH: usize = 3;
|
||||
const NUM_VERTICES_HEIGHT: usize = 3;
|
||||
const NUM_VERTICES_WIDTH: usize = 4;
|
||||
const NUM_VERTICES_HEIGHT: usize = 4;
|
||||
const NUM_VERTICES: usize = 4 + 2 * NUM_VERTICES_WIDTH + 2 * NUM_VERTICES_HEIGHT;
|
||||
// This struct belongs to the CameraViewPort
|
||||
pub struct FieldOfView {
|
||||
@@ -79,16 +79,14 @@ impl FieldOfView {
|
||||
) -> Self {
|
||||
let mut x_ndc = linspace(-1., 1., NUM_VERTICES_WIDTH + 2);
|
||||
|
||||
x_ndc.extend(iter::repeat(1.0).take(NUM_VERTICES_HEIGHT));
|
||||
x_ndc.extend(iter::repeat_n(1.0, NUM_VERTICES_HEIGHT));
|
||||
x_ndc.extend(linspace(1., -1., NUM_VERTICES_WIDTH + 2));
|
||||
x_ndc.extend(iter::repeat(-1.0).take(NUM_VERTICES_HEIGHT));
|
||||
x_ndc.extend(iter::repeat_n(-1.0, NUM_VERTICES_HEIGHT));
|
||||
|
||||
let mut y_ndc = iter::repeat(-1.0)
|
||||
.take(NUM_VERTICES_WIDTH + 1)
|
||||
.collect::<Vec<_>>();
|
||||
let mut y_ndc = iter::repeat_n(-1.0, NUM_VERTICES_WIDTH + 1).collect::<Vec<_>>();
|
||||
|
||||
y_ndc.extend(linspace(-1., 1., NUM_VERTICES_HEIGHT + 2));
|
||||
y_ndc.extend(iter::repeat(1.0).take(NUM_VERTICES_WIDTH));
|
||||
y_ndc.extend(iter::repeat_n(1.0, NUM_VERTICES_WIDTH));
|
||||
y_ndc.extend(linspace(1., -1., NUM_VERTICES_HEIGHT + 2));
|
||||
y_ndc.pop();
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ pub use fov::FieldOfView;
|
||||
pub mod view_hpx_cells;
|
||||
|
||||
use crate::CooSystem;
|
||||
use crate::HEALPixCoverage;
|
||||
use crate::ProjectionType;
|
||||
use crate::SpaceMoc;
|
||||
|
||||
pub fn build_fov_coverage(
|
||||
depth: u8,
|
||||
@@ -18,7 +18,7 @@ pub fn build_fov_coverage(
|
||||
camera_frame: CooSystem,
|
||||
frame: CooSystem,
|
||||
proj: &ProjectionType,
|
||||
) -> HEALPixCoverage {
|
||||
) -> SpaceMoc {
|
||||
if let Some(vertices) = fov.get_vertices() {
|
||||
// The vertices coming from the camera are in a specific coo sys
|
||||
// but cdshealpix accepts them to be given in ICRS coo sys
|
||||
@@ -44,21 +44,20 @@ pub fn build_fov_coverage(
|
||||
::healpix::nested::hash(depth, lon.to_radians(), lat.to_radians())
|
||||
});
|
||||
|
||||
HEALPixCoverage::from_fixed_hpx_cells(depth, hpx_idxs_iter, Some(vertices.len()))
|
||||
SpaceMoc::from_fixed_hpx_cells(depth, hpx_idxs_iter, Some(vertices.len()))
|
||||
} else {
|
||||
// The polygon is not too small for the depth asked
|
||||
let inside_vertex = crate::coosys::apply_coo_system(camera_frame, frame, camera_center);
|
||||
|
||||
// Prefer to query from_polygon with depth >= 2
|
||||
let moc = HEALPixCoverage::from_3d_coos(depth, vertices_iter, &inside_vertex);
|
||||
|
||||
moc
|
||||
SpaceMoc::from_3d_coos(depth, vertices_iter, &inside_vertex)
|
||||
}
|
||||
} else {
|
||||
let center_xyz = crate::coosys::apply_coo_system(camera_frame, frame, camera_center);
|
||||
|
||||
let biggest_fov_rad = proj.aperture_start().to_radians();
|
||||
let lonlat = center_xyz.lonlat();
|
||||
HEALPixCoverage::from_cone(&lonlat, biggest_fov_rad * 0.5, depth)
|
||||
SpaceMoc::from_cone(&lonlat, biggest_fov_rad * 0.5, depth)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::healpix::cell::HEALPixCell;
|
||||
|
||||
use crate::math::projection::*;
|
||||
|
||||
use crate::HEALPixCoverage;
|
||||
use crate::SpaceMoc;
|
||||
|
||||
use moclib::moc::{range::op::degrade::degrade, RangeMOCIterator};
|
||||
|
||||
@@ -84,7 +84,7 @@ impl ViewHpxCells {
|
||||
self.hpx_cells[frame as usize].get_cells(depth)
|
||||
}
|
||||
|
||||
pub(super) fn get_cov(&self, frame: CooSystem) -> &HEALPixCoverage {
|
||||
pub(super) fn get_cov(&self, frame: CooSystem) -> &SpaceMoc {
|
||||
self.hpx_cells[frame as usize].get_cov()
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ pub struct HpxCells {
|
||||
// An index vector referring to the indices of each depth cells
|
||||
//idx_rng: [Option<Range<usize>>; MAX_HPX_DEPTH as usize + 1],
|
||||
// Coverage created in the frame
|
||||
cov: HEALPixCoverage,
|
||||
cov: SpaceMoc,
|
||||
// boolean refering to if the cells in the view has changed
|
||||
//new_cells: bool,
|
||||
}
|
||||
@@ -127,7 +127,7 @@ use super::FieldOfView;
|
||||
impl HpxCells {
|
||||
pub fn new(frame: CooSystem) -> Self {
|
||||
//let cells = Vec::new();
|
||||
let cov = HEALPixCoverage::empty(29);
|
||||
let cov = SpaceMoc::empty(29);
|
||||
|
||||
//let idx_rng = Default::default();
|
||||
|
||||
@@ -203,7 +203,7 @@ impl HpxCells {
|
||||
if depth == cov_depth {
|
||||
self.cov
|
||||
.flatten_to_fixed_depth_cells()
|
||||
.map(move |idx| HEALPixCell(depth, idx))
|
||||
.map(|idx| HEALPixCell(depth, idx))
|
||||
.collect()
|
||||
} else if depth > self.cov.depth_max() {
|
||||
let cov_d = self.cov.depth_max();
|
||||
@@ -212,7 +212,7 @@ impl HpxCells {
|
||||
|
||||
self.cov
|
||||
.flatten_to_fixed_depth_cells()
|
||||
.flat_map(move |idx| {
|
||||
.flat_map(|idx| {
|
||||
// idx is at depth_max
|
||||
HEALPixCell(cov_d, idx).get_children_cells(dd)
|
||||
})
|
||||
@@ -221,7 +221,7 @@ impl HpxCells {
|
||||
// compute the cells from the coverage
|
||||
degrade((&self.cov.0).into_range_moc_iter(), depth)
|
||||
.flatten_to_fixed_depth_cells()
|
||||
.map(move |idx| HEALPixCell(depth, idx))
|
||||
.map(|idx| HEALPixCell(depth, idx))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ impl HpxCells {
|
||||
}*/
|
||||
|
||||
#[inline(always)]
|
||||
pub fn get_cov(&self) -> &HEALPixCoverage {
|
||||
pub fn get_cov(&self) -> &SpaceMoc {
|
||||
&self.cov
|
||||
}
|
||||
|
||||
|
||||
@@ -8,18 +8,14 @@ pub enum UserAction {
|
||||
|
||||
use web_sys::WebGl2RenderingContext;
|
||||
// Longitude reversed identity matrix
|
||||
const ID_R: &Matrix3<f64> = &Matrix3::new(
|
||||
-1.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0,
|
||||
0.0, 0.0, 1.0,
|
||||
);
|
||||
const ID_R: &Matrix3<f64> = &Matrix3::new(-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
use cgmath::{Vector3, InnerSpace};
|
||||
use super::{fov::FieldOfView, view_hpx_cells::ViewHpxCells};
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
use crate::healpix::coverage::HEALPixCoverage;
|
||||
use crate::healpix::moc::SpaceMoc;
|
||||
use crate::math::angle::ToAngle;
|
||||
use crate::math::{projection::coo_space::XYZModel, projection::domain::sdf::ProjDef};
|
||||
use cgmath::{InnerSpace, Vector3};
|
||||
|
||||
use cgmath::{Matrix3, Vector2};
|
||||
const APERTURE_LOWER_LIMIT_RAD: f64 = (1.0_f64 / 36000.0).to_radians();
|
||||
@@ -220,7 +216,7 @@ impl CameraViewPort {
|
||||
self.view_hpx_cells.has_changed()
|
||||
}*/
|
||||
|
||||
pub fn get_cov(&self, frame: CooSystem) -> &HEALPixCoverage {
|
||||
pub fn get_cov(&self, frame: CooSystem) -> &SpaceMoc {
|
||||
self.view_hpx_cells.get_cov(frame)
|
||||
}
|
||||
|
||||
@@ -285,8 +281,8 @@ impl CameraViewPort {
|
||||
}
|
||||
|
||||
pub fn set_screen_size(&mut self, width: f32, height: f32, projection: &ProjectionType) {
|
||||
self.width = (width as f32) * self.dpi;
|
||||
self.height = (height as f32) * self.dpi;
|
||||
self.width = width * self.dpi;
|
||||
self.height = height * self.dpi;
|
||||
|
||||
self.aspect = width / height;
|
||||
// Compute the new clip zoom factor
|
||||
@@ -319,11 +315,7 @@ impl CameraViewPort {
|
||||
}
|
||||
|
||||
pub fn compute_ndc_to_clip_factor(&mut self, proj: &ProjectionType) {
|
||||
self.ndc_to_clip = if self.height < self.width {
|
||||
Vector2::new(1.0, (self.height as f64) / (self.width as f64))
|
||||
} else {
|
||||
Vector2::new((self.width as f64) / (self.height as f64), 1.0)
|
||||
};
|
||||
self.ndc_to_clip = Vector2::new(1.0, (self.height as f64) / (self.width as f64));
|
||||
|
||||
let bounds_size_ratio = proj.bounds_size_ratio();
|
||||
self.ndc_to_clip.y *= bounds_size_ratio;
|
||||
@@ -378,10 +370,10 @@ impl CameraViewPort {
|
||||
}
|
||||
}
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
let can_unzoom_more = !matches!(
|
||||
proj,
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_)
|
||||
);
|
||||
|
||||
if !can_unzoom_more && self.zoom_factor >= 1.0 {
|
||||
return true;
|
||||
@@ -414,10 +406,10 @@ impl CameraViewPort {
|
||||
self.last_user_action
|
||||
};
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
let can_unzoom_more = !matches!(
|
||||
proj,
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_)
|
||||
);
|
||||
|
||||
let aperture_start: f64 = proj.aperture_start().to_radians();
|
||||
|
||||
@@ -491,10 +483,10 @@ impl CameraViewPort {
|
||||
self.last_user_action
|
||||
};
|
||||
|
||||
let can_unzoom_more = match proj {
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_) => false,
|
||||
_ => true,
|
||||
};
|
||||
let can_unzoom_more = !matches!(
|
||||
proj,
|
||||
ProjectionType::Tan(_) | ProjectionType::Mer(_) | ProjectionType::Stg(_)
|
||||
);
|
||||
|
||||
// Set the zoom factor
|
||||
self.zoom_factor = zoom_factor;
|
||||
@@ -574,42 +566,48 @@ impl CameraViewPort {
|
||||
}
|
||||
|
||||
fn compute_texture_depth(&mut self) {
|
||||
/*// Compute a depth from a number of pixels on screen
|
||||
let width = self.width;
|
||||
let aperture = self.aperture.0 as f32;
|
||||
// Compute a depth from a number of pixels on screen
|
||||
/*let width = self.width;
|
||||
let aperture = self.aperture as f32;
|
||||
|
||||
let angle_per_pixel = aperture / width;
|
||||
let angle_per_pixel = aperture / width;
|
||||
|
||||
let two_power_two_times_depth_pixel =
|
||||
std::f32::consts::PI / (3.0 * angle_per_pixel * angle_per_pixel);
|
||||
let depth_pixel = (two_power_two_times_depth_pixel.log2() / 2.0).floor() as u32;
|
||||
let two_power_two_times_depth_pixel =
|
||||
std::f32::consts::PI / (3.0 * angle_per_pixel * angle_per_pixel);
|
||||
let depth_pixel = (two_power_two_times_depth_pixel.log2() / 2.0).ceil() as u32;
|
||||
|
||||
//let survey_max_depth = conf.get_max_depth();
|
||||
// The depth of the texture
|
||||
// A texture of 512x512 pixels will have a depth of 9
|
||||
const DEPTH_OFFSET_TEXTURE: u32 = 9;
|
||||
// The depth of the texture corresponds to the depth of a pixel
|
||||
// minus the offset depth of the texture
|
||||
self.texture_depth = if DEPTH_OFFSET_TEXTURE > depth_pixel {
|
||||
0_u8
|
||||
} else {
|
||||
(depth_pixel - DEPTH_OFFSET_TEXTURE) as u8
|
||||
};*/
|
||||
//let survey_max_depth = conf.get_max_depth();
|
||||
// The depth of the texture
|
||||
// A texture of 512x512 pixels will have a depth of 9
|
||||
const DEPTH_OFFSET_TEXTURE: u32 = 9;
|
||||
// The depth of the texture corresponds to the depth of a pixel
|
||||
// minus the offset depth of the texture
|
||||
self.texture_depth = if DEPTH_OFFSET_TEXTURE > depth_pixel {
|
||||
0_u8
|
||||
} else {
|
||||
(depth_pixel - DEPTH_OFFSET_TEXTURE) as u8
|
||||
};
|
||||
*/
|
||||
let w_screen_device_px = self.width as f64 / (self.dpi as f64);
|
||||
//let depth_pixel = 29_usize;
|
||||
|
||||
let w_screen_px = self.width as f64;
|
||||
let smallest_cell_size_px = self.dpi as f64;
|
||||
let mut depth_pixel = 29 as usize;
|
||||
let pixel_angle_rad = self.get_aperture() / w_screen_device_px;
|
||||
|
||||
let hpx_cell_size_rad = (smallest_cell_size_px / w_screen_px) * self.get_aperture();
|
||||
|
||||
while depth_pixel > 0 {
|
||||
if crate::healpix::utils::MEAN_HPX_CELL_RES[depth_pixel] > hpx_cell_size_rad {
|
||||
break;
|
||||
// Find the smallest depth such that MEAN_HPX_CELL_RES[depth] > pixel_angle_rad
|
||||
let depth_pixel = match crate::healpix::utils::MEAN_HPX_CELL_RES.binary_search_by(|&res| {
|
||||
if res < pixel_angle_rad {
|
||||
std::cmp::Ordering::Greater
|
||||
} else if res > pixel_angle_rad {
|
||||
std::cmp::Ordering::Less
|
||||
} else {
|
||||
std::cmp::Ordering::Equal
|
||||
}
|
||||
}) {
|
||||
Ok(idx) => idx, // exact match
|
||||
Err(idx) => idx,
|
||||
};
|
||||
|
||||
depth_pixel = depth_pixel - 1;
|
||||
}
|
||||
depth_pixel += 1;
|
||||
//al_core::log(&format!("{:?}", depth_pixel));
|
||||
const DEPTH_OFFSET_TEXTURE: usize = 9;
|
||||
self.texture_depth = if DEPTH_OFFSET_TEXTURE > depth_pixel {
|
||||
0_u8
|
||||
@@ -618,7 +616,7 @@ impl CameraViewPort {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_texture_depth(&self) -> u8 {
|
||||
pub fn get_tile_depth(&self) -> u8 {
|
||||
self.texture_depth
|
||||
}
|
||||
|
||||
@@ -639,10 +637,13 @@ impl CameraViewPort {
|
||||
&mut self,
|
||||
dlon: Angle<f64>,
|
||||
dlat: Angle<f64>,
|
||||
proj: &ProjectionType
|
||||
proj: &ProjectionType,
|
||||
) {
|
||||
let center = self.get_center();
|
||||
let rot = Rotation::from_axis_angle(&Vector3::new(center.z, 0.0, -center.x).normalize(), dlat) * Rotation::from_axis_angle(&Vector3::unit_y(), -dlon) * Rotation::from_sky_position(¢er);
|
||||
let rot =
|
||||
Rotation::from_axis_angle(&Vector3::new(center.z, 0.0, -center.x).normalize(), dlat)
|
||||
* Rotation::from_axis_angle(&Vector3::unit_y(), -dlon)
|
||||
* Rotation::from_sky_position(center);
|
||||
|
||||
self.set_rotation(&rot, proj);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use cgmath::Vector3;
|
||||
use al_api::coo_system::CooSystem;
|
||||
use cgmath::Vector3;
|
||||
|
||||
/// This is conversion method returning a transformation
|
||||
/// matrix when the system requested by the user is not
|
||||
|
||||
@@ -10,13 +10,19 @@ pub struct Downloader {
|
||||
requests: Vec<RequestType>,
|
||||
queried_list: HashSet<QueryId>,
|
||||
|
||||
cache: Cache<QueryId, Resource>,
|
||||
cache: Cache<QueryId, RequestType>,
|
||||
}
|
||||
|
||||
use crate::fifo_cache::Cache;
|
||||
|
||||
use query::Query;
|
||||
use request::{RequestType, Resource};
|
||||
use request::RequestType;
|
||||
|
||||
impl Default for Downloader {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Downloader {
|
||||
pub fn new() -> Downloader {
|
||||
@@ -56,26 +62,23 @@ impl Downloader {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_received_resources(&mut self) -> Vec<Resource> {
|
||||
pub fn get_received_resources(&mut self) -> Vec<RequestType> {
|
||||
let mut rscs = vec![];
|
||||
let mut not_finished_requests = vec![];
|
||||
|
||||
let mut finished_query_list = vec![];
|
||||
self.requests = self
|
||||
.requests
|
||||
.drain(..)
|
||||
.filter(|request| {
|
||||
// If the request resolves into a resource
|
||||
if let Some(rsc) = request.into() {
|
||||
rscs.push(rsc);
|
||||
finished_query_list.push(request.id().clone());
|
||||
|
||||
false
|
||||
// The request is not resolved, we keep it
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
while let Some(request) = self.requests.pop() {
|
||||
if request.is_resolved() {
|
||||
finished_query_list.push(request.id().clone());
|
||||
rscs.push(request);
|
||||
// The request is not resolved, we keep it
|
||||
} else {
|
||||
not_finished_requests.push(request);
|
||||
}
|
||||
}
|
||||
|
||||
self.requests = not_finished_requests;
|
||||
|
||||
for query_id in finished_query_list.into_iter() {
|
||||
self.queried_list.remove(&query_id);
|
||||
@@ -92,18 +95,8 @@ impl Downloader {
|
||||
self.queried_list.contains(id)
|
||||
}
|
||||
|
||||
pub fn delay(&mut self, r: Resource) {
|
||||
match r {
|
||||
Resource::Tile(tile) => {
|
||||
let k = format!(
|
||||
"{:?}{:?}/{:?}",
|
||||
tile.get_hips_cdid(),
|
||||
tile.cell.depth(),
|
||||
tile.cell.idx()
|
||||
);
|
||||
self.cache.insert(k, Resource::Tile(tile));
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
pub fn delay(&mut self, r: RequestType) {
|
||||
let id = r.id().to_owned();
|
||||
self.cache.insert(id, r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,65 @@ pub trait Query: Sized {
|
||||
|
||||
fn id(&self) -> &QueryId;
|
||||
}
|
||||
|
||||
pub type QueryId = String;
|
||||
|
||||
use crate::browser_support::BrowserFeaturesSupport;
|
||||
use crate::healpix::cell::HEALPixFreqCell;
|
||||
use al_api::hips::DataproductType;
|
||||
use al_core::image::format::ImageFormatType;
|
||||
|
||||
/// Description of a cell to query
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum CellDesc {
|
||||
HiPS2D {
|
||||
// A description of the tile in space
|
||||
cell: HEALPixCell,
|
||||
// Size of the tile requested
|
||||
tile_size: u32,
|
||||
},
|
||||
HiPS3D {
|
||||
// A description of the tile in space and frequency
|
||||
cell: HEALPixFreqCell,
|
||||
// Size of the tile requested
|
||||
tile_size: u32,
|
||||
// Depth of the cubic tile
|
||||
tile_depth: u32,
|
||||
},
|
||||
HiPSCube {
|
||||
// A description of the tile in space
|
||||
cell: HEALPixCell,
|
||||
// size of the tile requested
|
||||
tile_size: u32,
|
||||
// The channel number to query
|
||||
channel: u32,
|
||||
},
|
||||
}
|
||||
|
||||
impl CellDesc {
|
||||
/*fn get_size(&self) -> (u32, u32, u32) {
|
||||
match self {
|
||||
Self::HiPS2D { tile_size, .. } => (*tile_size, *tile_size, 1),
|
||||
Self::HiPSCube { tile_size, .. } => (*tile_size, *tile_size, 1),
|
||||
Self::HiPS3D {
|
||||
tile_size,
|
||||
tile_depth,
|
||||
..
|
||||
} => (*tile_size, *tile_size, *tile_depth),
|
||||
}
|
||||
}*/
|
||||
|
||||
pub fn get_hpx(&self) -> &HEALPixCell {
|
||||
match self {
|
||||
Self::HiPS2D { cell, .. } => cell,
|
||||
Self::HiPS3D { cell, .. } => &cell.hpx,
|
||||
Self::HiPSCube { cell, .. } => cell,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone)]
|
||||
pub struct Tile {
|
||||
pub cell: HEALPixCell,
|
||||
pub cell: CellDesc,
|
||||
pub format: ImageFormatType,
|
||||
// The root url of the HiPS
|
||||
pub hips_cdid: CreatorDid,
|
||||
@@ -22,15 +73,20 @@ pub struct Tile {
|
||||
pub credentials: RequestCredentials,
|
||||
pub mode: RequestMode,
|
||||
pub id: QueryId,
|
||||
pub channel: Option<u32>,
|
||||
pub create_bitmap_support: bool,
|
||||
}
|
||||
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
use crate::renderable::hips::config::HiPSConfig;
|
||||
use crate::renderable::CreatorDid;
|
||||
use crate::tile_fetcher::HiPSLocalFiles;
|
||||
use web_sys::{RequestCredentials, RequestMode};
|
||||
impl Tile {
|
||||
pub fn new(cell: &HEALPixCell, channel: Option<u32>, cfg: &HiPSConfig) -> Self {
|
||||
pub fn new(
|
||||
cell: &HEALPixCell,
|
||||
cfg: &HiPSConfig,
|
||||
browser_support: &BrowserFeaturesSupport,
|
||||
) -> Self {
|
||||
let hips_cdid = cfg.get_creator_did();
|
||||
let hips_url = cfg.get_root_url();
|
||||
let format = cfg.get_format();
|
||||
@@ -43,36 +99,108 @@ impl Tile {
|
||||
|
||||
let dir_idx = (idx / 10000) * 10000;
|
||||
|
||||
let mut url = format!("{}/Norder{}/Dir{}/Npix{}", hips_url, depth, dir_idx, idx);
|
||||
let url = format!("{hips_url}/Norder{depth}/Dir{dir_idx}/Npix{idx}.{ext}");
|
||||
|
||||
// handle cube case
|
||||
if let Some(channel) = channel {
|
||||
if channel > 0 {
|
||||
url.push_str(&format!("_{:?}", channel));
|
||||
}
|
||||
}
|
||||
|
||||
// add the tile format
|
||||
url.push_str(&format!(".{}", ext));
|
||||
|
||||
let id = format!(
|
||||
"{}{}{}{}{}",
|
||||
hips_cdid,
|
||||
depth,
|
||||
idx,
|
||||
channel.unwrap_or(0),
|
||||
ext
|
||||
);
|
||||
let id = format!("{}_{}_{}_{}", hips_cdid, depth, idx, ext);
|
||||
|
||||
let tile_size = cfg.get_tile_size() as u32;
|
||||
Tile {
|
||||
hips_cdid: hips_cdid.to_string(),
|
||||
url,
|
||||
cell: *cell,
|
||||
cell: CellDesc::HiPS2D {
|
||||
cell: *cell,
|
||||
tile_size,
|
||||
},
|
||||
format,
|
||||
credentials,
|
||||
mode,
|
||||
id,
|
||||
channel,
|
||||
create_bitmap_support: browser_support.create_image_bitmap,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_channel(
|
||||
cell: &HEALPixCell,
|
||||
channel: u32,
|
||||
cfg: &HiPSConfig,
|
||||
browser_support: &BrowserFeaturesSupport,
|
||||
) -> Self {
|
||||
let hips_cdid = cfg.get_creator_did();
|
||||
let hips_url = cfg.get_root_url();
|
||||
let format = cfg.get_format();
|
||||
let credentials = cfg.get_request_credentials();
|
||||
let mode = cfg.get_request_mode();
|
||||
|
||||
let ext = format.get_ext_file();
|
||||
|
||||
let HEALPixCell(depth, idx) = *cell;
|
||||
|
||||
let dir_idx = (idx / 10000) * 10000;
|
||||
|
||||
let url = format!("{hips_url}/Norder{depth}/Dir{dir_idx}/Npix{idx}_{channel:?}.{ext}");
|
||||
|
||||
let id = format!("{}_{}_{}_{}_{}", hips_cdid, depth, idx, channel, ext);
|
||||
|
||||
let tile_size = cfg.get_tile_size() as u32;
|
||||
Tile {
|
||||
hips_cdid: hips_cdid.to_string(),
|
||||
url,
|
||||
cell: CellDesc::HiPSCube {
|
||||
cell: *cell,
|
||||
tile_size,
|
||||
channel,
|
||||
},
|
||||
format,
|
||||
credentials,
|
||||
mode,
|
||||
id,
|
||||
create_bitmap_support: browser_support.create_image_bitmap,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_cubic(
|
||||
hpx_f_cell: &HEALPixFreqCell,
|
||||
cfg: &HiPSConfig,
|
||||
browser_support: &BrowserFeaturesSupport,
|
||||
) -> Self {
|
||||
let hips_cdid = cfg.get_creator_did();
|
||||
let hips_url = cfg.get_root_url();
|
||||
let format = cfg.get_format();
|
||||
let credentials = cfg.get_request_credentials();
|
||||
let mode = cfg.get_request_mode();
|
||||
|
||||
let ext = format.get_ext_file();
|
||||
|
||||
// f hash at order_f
|
||||
|
||||
let HEALPixFreqCell {
|
||||
hpx: HEALPixCell(k, n),
|
||||
f_hash: m,
|
||||
f_depth: l,
|
||||
} = *hpx_f_cell;
|
||||
|
||||
let d = (n / 10000) * 10000;
|
||||
let e = (m / 10) * 10;
|
||||
|
||||
let url = format!("{hips_url}/Norder{k}_{l}/Dir{d}_{e}/Npix{n}_{m}.{ext}");
|
||||
|
||||
let id = format!("{hips_cdid}_{k}_{l}_{n}_{m}_{ext}");
|
||||
|
||||
let tile_size = cfg.get_tile_size() as u32;
|
||||
let tile_depth = cfg.tile_depth.unwrap_or(1) as u32;
|
||||
Tile {
|
||||
hips_cdid: hips_cdid.to_string(),
|
||||
url,
|
||||
cell: CellDesc::HiPS3D {
|
||||
cell: hpx_f_cell.clone(),
|
||||
tile_size,
|
||||
tile_depth,
|
||||
},
|
||||
format,
|
||||
credentials,
|
||||
mode,
|
||||
id,
|
||||
create_bitmap_support: browser_support.create_image_bitmap,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +218,7 @@ impl Query for Tile {
|
||||
pub struct Allsky {
|
||||
pub format: ImageFormatType,
|
||||
pub tile_size: i32,
|
||||
pub texture_size: i32,
|
||||
pub allsky_tile_size: i32,
|
||||
pub channel: Option<u32>,
|
||||
// The root url of the HiPS
|
||||
pub hips_cdid: CreatorDid,
|
||||
@@ -104,8 +232,10 @@ pub struct Allsky {
|
||||
impl Allsky {
|
||||
pub fn new(cfg: &HiPSConfig, channel: Option<u32>) -> Self {
|
||||
let hips_cdid = cfg.get_creator_did().to_string();
|
||||
let allsky_tile_size = cfg.allsky_tile_size();
|
||||
|
||||
let tile_size = cfg.get_tile_size();
|
||||
let texture_size = cfg.get_texture_size();
|
||||
|
||||
let format = cfg.get_format();
|
||||
let ext = format.get_ext_file();
|
||||
let credentials = cfg.get_request_credentials();
|
||||
@@ -116,12 +246,12 @@ impl Allsky {
|
||||
// handle cube case
|
||||
if let Some(channel) = channel {
|
||||
if channel > 0 {
|
||||
url.push_str(&format!("_{:?}", channel));
|
||||
url.push_str(&format!("_{channel:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
// add the tile format
|
||||
url.push_str(&format!(".{}", ext));
|
||||
url.push_str(&format!(".{ext}"));
|
||||
|
||||
let id = format!(
|
||||
"{}Allsky{}{}",
|
||||
@@ -132,14 +262,14 @@ impl Allsky {
|
||||
|
||||
Allsky {
|
||||
tile_size,
|
||||
texture_size,
|
||||
allsky_tile_size,
|
||||
hips_cdid,
|
||||
url,
|
||||
format,
|
||||
id,
|
||||
credentials,
|
||||
mode,
|
||||
channel
|
||||
channel,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,43 +284,8 @@ impl Query for Allsky {
|
||||
}
|
||||
|
||||
/* ---------------------------------- */
|
||||
pub struct PixelMetadata {
|
||||
pub format: ImageFormatType,
|
||||
// The root url of the HiPS
|
||||
pub hips_cdid: CreatorDid,
|
||||
// The total url of the query
|
||||
pub url: Url,
|
||||
pub id: QueryId,
|
||||
}
|
||||
|
||||
impl PixelMetadata {
|
||||
pub fn new(cfg: &HiPSConfig) -> Self {
|
||||
let hips_cdid = cfg.get_creator_did().to_string();
|
||||
let format = cfg.get_format();
|
||||
let ext = format.get_ext_file();
|
||||
|
||||
let url = format!("{}/Norder3/Allsky.{}", cfg.get_root_url(), ext);
|
||||
|
||||
let id = format!("{}Allsky{}", hips_cdid, ext);
|
||||
PixelMetadata {
|
||||
hips_cdid,
|
||||
url,
|
||||
format,
|
||||
id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use super::request::blank::PixelMetadataRequest;
|
||||
impl Query for PixelMetadata {
|
||||
type Request = PixelMetadataRequest;
|
||||
|
||||
fn id(&self) -> &QueryId {
|
||||
&self.id
|
||||
}
|
||||
}
|
||||
use al_api::moc::MOCOptions;
|
||||
/* ---------------------------------- */
|
||||
|
||||
pub struct Moc {
|
||||
// The total url of the query
|
||||
pub url: Url,
|
||||
@@ -198,21 +293,41 @@ pub struct Moc {
|
||||
pub credentials: RequestCredentials,
|
||||
pub params: MOCOptions,
|
||||
pub hips_cdid: CreatorDid,
|
||||
pub dataproduct_type: DataproductType,
|
||||
}
|
||||
use std::collections::HashMap;
|
||||
impl Moc {
|
||||
pub fn new(
|
||||
url: String,
|
||||
mode: RequestMode,
|
||||
credentials: RequestCredentials,
|
||||
hips_cdid: CreatorDid,
|
||||
cfg: &HiPSConfig,
|
||||
hips_local_files: &HashMap<String, HiPSLocalFiles>,
|
||||
params: MOCOptions,
|
||||
) -> Self {
|
||||
// Try to fetch the MOC
|
||||
let hips_cdid = cfg.get_creator_did();
|
||||
let url = if let Some(local_hips) = hips_local_files.get(hips_cdid) {
|
||||
if let Ok(url) =
|
||||
web_sys::Url::create_object_url_with_blob(local_hips.get_moc().as_ref())
|
||||
{
|
||||
url
|
||||
} else {
|
||||
format!("{}/Moc.fits", cfg.get_root_url())
|
||||
}
|
||||
} else {
|
||||
format!("{}/Moc.fits", cfg.get_root_url())
|
||||
};
|
||||
|
||||
let mode = cfg.get_request_mode();
|
||||
let credentials = cfg.get_request_credentials();
|
||||
let hips_cdid = cfg.get_creator_did().to_string();
|
||||
let dataproduct_type = cfg.dataproduct_type;
|
||||
|
||||
Moc {
|
||||
url,
|
||||
params,
|
||||
hips_cdid,
|
||||
mode,
|
||||
credentials,
|
||||
dataproduct_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
use std::io::Cursor;
|
||||
|
||||
use crate::downloader::query;
|
||||
use crate::renderable::CreatorDid;
|
||||
use al_core::image::format::ChannelType;
|
||||
use al_core::image::fits::FitsImage;
|
||||
use al_core::image::ImageType;
|
||||
|
||||
use fitsrs::{fits::Fits, hdu::data::InMemData};
|
||||
use al_core::texture::format::PixelType;
|
||||
use fitsrs::hdu::header::Bitpix;
|
||||
|
||||
use super::{Request, RequestType};
|
||||
use crate::downloader::QueryId;
|
||||
pub struct AllskyRequest {
|
||||
pub hips_cdid: CreatorDid,
|
||||
pub url: Url,
|
||||
pub depth_tile: u8,
|
||||
//pub depth_tile: u8,
|
||||
pub id: QueryId,
|
||||
pub channel: Option<u32>,
|
||||
|
||||
request: Request<Vec<ImageType>>,
|
||||
pub request: Request<Vec<ImageType>>,
|
||||
}
|
||||
|
||||
impl AllskyRequest {
|
||||
pub fn missing(&self) -> bool {
|
||||
self.request.data.borrow().is_none()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<AllskyRequest> for RequestType {
|
||||
@@ -28,32 +32,17 @@ impl From<AllskyRequest> for RequestType {
|
||||
use super::Url;
|
||||
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{RequestInit, Response, RequestCredentials};
|
||||
use web_sys::{RequestCredentials, RequestInit, Response};
|
||||
|
||||
use al_core::{image::raw::ImageBuffer, texture::pixel::Pixel};
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
async fn query_image(url: &str, credentials: RequestCredentials) -> Result<ImageBuffer<RGBA8U>, JsValue> {
|
||||
let image = web_sys::HtmlImageElement::new().unwrap_abort();
|
||||
let image_cloned = image.clone();
|
||||
|
||||
let cors_value = match credentials {
|
||||
RequestCredentials::Include => Some("use-credentials"),
|
||||
RequestCredentials::SameOrigin => Some("anonymous"),
|
||||
_ => Some("")
|
||||
};
|
||||
|
||||
let html_img_elt_promise = js_sys::Promise::new(
|
||||
&mut (Box::new(move |resolve, reject| {
|
||||
image_cloned.set_cross_origin(cors_value);
|
||||
image_cloned.set_onload(Some(&resolve));
|
||||
image_cloned.set_onerror(Some(&reject));
|
||||
image_cloned.set_src(&url);
|
||||
}) as Box<dyn FnMut(js_sys::Function, js_sys::Function)>),
|
||||
);
|
||||
|
||||
let _ = JsFuture::from(html_img_elt_promise).await?;
|
||||
async fn query_allsky(
|
||||
url: &str,
|
||||
credentials: RequestCredentials,
|
||||
) -> Result<ImageBuffer<RGBA8U>, JsValue> {
|
||||
let image = super::query_html_image(url, credentials).await?;
|
||||
|
||||
// The image has been received here
|
||||
let document = web_sys::window().unwrap_abort().document().unwrap_abort();
|
||||
@@ -74,7 +63,7 @@ async fn query_image(url: &str, credentials: RequestCredentials) -> Result<Image
|
||||
|
||||
let raw_bytes = image_data.data();
|
||||
|
||||
Ok(ImageBuffer::from_raw_bytes(raw_bytes.0, w as i32, h as i32))
|
||||
Ok(ImageBuffer::from_raw_bytes(raw_bytes.0, w, h))
|
||||
}
|
||||
|
||||
impl From<query::Allsky> for AllskyRequest {
|
||||
@@ -85,55 +74,52 @@ impl From<query::Allsky> for AllskyRequest {
|
||||
tile_size,
|
||||
url,
|
||||
hips_cdid,
|
||||
texture_size,
|
||||
allsky_tile_size,
|
||||
id,
|
||||
credentials,
|
||||
mode,
|
||||
channel: slice,
|
||||
} = query;
|
||||
|
||||
let depth_tile = crate::math::utils::log_2_unchecked(texture_size / tile_size) as u8;
|
||||
let channel = format.get_channel();
|
||||
//let depth_tile = crate::math::utils::log_2_unchecked(texture_size / tile_size) as u8;
|
||||
let channel = format.get_pixel_format();
|
||||
let url_clone = url.clone();
|
||||
|
||||
let request = Request::new(async move {
|
||||
match channel {
|
||||
ChannelType::RGB8U => {
|
||||
let allsky_tile_size = std::cmp::min(tile_size, 64);
|
||||
let allsky = query_image(&url_clone, credentials).await?;
|
||||
PixelType::RGB8U => {
|
||||
let allsky = query_allsky(&url_clone, credentials).await?;
|
||||
|
||||
let allsky_tiles = handle_allsky_file::<RGBA8U>(
|
||||
allsky,
|
||||
allsky_tile_size,
|
||||
texture_size,
|
||||
tile_size,
|
||||
)?
|
||||
.into_iter()
|
||||
.map(|image| {
|
||||
let ImageBuffer { data, size } = image;
|
||||
let data = data
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter(|&(i, _)| i % 4 != 3)
|
||||
.map(|(_, v)| v)
|
||||
let allsky_tiles =
|
||||
handle_allsky_file::<RGBA8U>(allsky, allsky_tile_size, tile_size)?
|
||||
.map(|image| {
|
||||
let ImageBuffer { data, size } = image;
|
||||
let data = data
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|&(i, _)| i % 4 != 3)
|
||||
.map(|(_, v)| *v)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let image = ImageBuffer::new(
|
||||
data.into_boxed_slice(),
|
||||
size.0,
|
||||
size.1,
|
||||
size.2,
|
||||
);
|
||||
|
||||
ImageType::RawRgb8u { image }
|
||||
})
|
||||
.collect();
|
||||
let image = ImageBuffer::new(data, size.x, size.y);
|
||||
|
||||
ImageType::RawRgb8u { image }
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(allsky_tiles)
|
||||
}
|
||||
ChannelType::RGBA8U => {
|
||||
let allsky_tile_size = std::cmp::min(tile_size, 64);
|
||||
let allsky = query_image(&url_clone, credentials).await?;
|
||||
PixelType::RGBA8U => {
|
||||
let allsky = query_allsky(&url_clone, credentials).await?;
|
||||
|
||||
let allsky_tiles =
|
||||
handle_allsky_file(allsky, allsky_tile_size, texture_size, tile_size)?
|
||||
.into_iter()
|
||||
.map(|image| ImageType::RawRgba8u { image })
|
||||
.collect();
|
||||
let allsky_tiles = handle_allsky_file(allsky, allsky_tile_size, tile_size)?
|
||||
.map(|image| ImageType::RawRgba8u { image })
|
||||
.collect();
|
||||
|
||||
Ok(allsky_tiles)
|
||||
}
|
||||
@@ -156,64 +142,66 @@ impl From<query::Allsky> for AllskyRequest {
|
||||
// Convert the JS ReadableStream to a Rust stream
|
||||
let mut reader = body.try_into_async_read().map_err(|_| JsValue::from_str("readable stream locked"))?;*/
|
||||
|
||||
let array_buffer = JsFuture::from(resp.array_buffer()?).await?;
|
||||
let bytes_buffer = js_sys::Uint8Array::new(&array_buffer);
|
||||
let buf = JsFuture::from(resp.array_buffer()?).await?;
|
||||
let raw_bytes = js_sys::Uint8Array::new(&buf).to_vec();
|
||||
|
||||
let num_bytes = bytes_buffer.length() as usize;
|
||||
let mut raw_bytes = Vec::with_capacity(num_bytes);
|
||||
unsafe {
|
||||
raw_bytes.set_len(num_bytes);
|
||||
}
|
||||
bytes_buffer.copy_to(&mut raw_bytes[..]);
|
||||
let mut reader = Cursor::new(&raw_bytes[..]);
|
||||
let Fits { hdu } = Fits::from_reader(&mut reader)
|
||||
.map_err(|_| JsValue::from_str("Parsing fits error of allsky"))?;
|
||||
|
||||
let data = hdu.get_data();
|
||||
|
||||
match data {
|
||||
InMemData::U8(data) => {
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
let FitsImage {
|
||||
raw_bytes, bitpix, ..
|
||||
} = &FitsImage::from_raw_bytes(raw_bytes.as_slice())?[0];
|
||||
match bitpix {
|
||||
Bitpix::U8 => {
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawR8ui { image })
|
||||
.collect())
|
||||
}
|
||||
InMemData::I16(data) => {
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
Bitpix::I16 => {
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawR16i { image })
|
||||
.collect())
|
||||
}
|
||||
InMemData::I32(data) => {
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
Bitpix::I32 => {
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawR32i { image })
|
||||
.collect())
|
||||
}
|
||||
InMemData::I64(data) => {
|
||||
let data = data.iter().map(|v| *v as i32).collect::<Vec<_>>();
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
.map(|image| ImageType::RawR32i { image })
|
||||
.collect())
|
||||
}
|
||||
InMemData::F32(data) => {
|
||||
Bitpix::I64 => {
|
||||
let data = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
raw_bytes.as_ptr() as *const i64,
|
||||
raw_bytes.len() / 8,
|
||||
)
|
||||
};
|
||||
let data = data.iter().map(|v| *v as i32).collect::<Vec<_>>();
|
||||
let raw_bytes = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
data.as_ptr() as *const u8,
|
||||
data.len() * 4,
|
||||
)
|
||||
};
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawR32i { image })
|
||||
.collect())
|
||||
}
|
||||
Bitpix::F32 => {
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawRgba8u { image })
|
||||
.collect())
|
||||
}
|
||||
InMemData::F64(data) => {
|
||||
let data = data.iter().map(|v| *v as f32).collect::<Vec<_>>();
|
||||
Bitpix::F64 => {
|
||||
let data = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
raw_bytes.as_ptr() as *const f64,
|
||||
raw_bytes.len() / 8,
|
||||
)
|
||||
};
|
||||
let data = data.iter().map(|v| *v as f32).collect::<Vec<_>>();
|
||||
let raw_bytes = unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
data.as_ptr() as *const u8,
|
||||
data.len() * 4,
|
||||
)
|
||||
};
|
||||
|
||||
Ok(handle_allsky_fits(&data, tile_size, texture_size)?
|
||||
Ok(handle_allsky_fits(raw_bytes, tile_size, allsky_tile_size)?
|
||||
.map(|image| ImageType::RawRgba8u { image })
|
||||
.collect())
|
||||
}
|
||||
@@ -225,7 +213,6 @@ impl From<query::Allsky> for AllskyRequest {
|
||||
Self {
|
||||
id,
|
||||
hips_cdid,
|
||||
depth_tile,
|
||||
url,
|
||||
request,
|
||||
channel: slice,
|
||||
@@ -233,44 +220,43 @@ impl From<query::Allsky> for AllskyRequest {
|
||||
}
|
||||
}
|
||||
|
||||
use al_core::image::format::ImageFormat;
|
||||
use al_core::image::raw::ImageBufferView;
|
||||
fn handle_allsky_file<F: ImageFormat>(
|
||||
allsky: ImageBuffer<F>,
|
||||
use al_core::texture::format::TextureFormat;
|
||||
fn handle_allsky_file<F: TextureFormat>(
|
||||
image: ImageBuffer<F>,
|
||||
allsky_tile_size: i32,
|
||||
texture_size: i32,
|
||||
tile_size: i32,
|
||||
) -> Result<impl Iterator<Item = ImageBuffer<F>>, JsValue> {
|
||||
let num_tiles_per_texture = (texture_size / tile_size) * (texture_size / tile_size);
|
||||
let num_tiles = num_tiles_per_texture * 12;
|
||||
|
||||
let num_allsky_tiles_per_tile = (tile_size / allsky_tile_size) * (tile_size / allsky_tile_size);
|
||||
let d3_tile_allsky_size = std::cmp::min(tile_size, 64);
|
||||
|
||||
let mut src_idx = 0;
|
||||
let tiles = (0..num_tiles).map(move |_| {
|
||||
let mut base_tile =
|
||||
ImageBuffer::<F>::allocate(&<F as ImageFormat>::P::BLACK, tile_size, tile_size);
|
||||
for idx_tile in 0..num_allsky_tiles_per_tile {
|
||||
let tiles = (0..12).map(move |_| {
|
||||
let mut base_tile = ImageBuffer::<F>::allocate(
|
||||
&F::P::BLACK,
|
||||
allsky_tile_size as u32,
|
||||
allsky_tile_size as u32,
|
||||
);
|
||||
for idx_tile in 0..64 {
|
||||
let (x, y) = crate::utils::unmortonize(idx_tile as u64);
|
||||
let dx = x * (allsky_tile_size as u32);
|
||||
let dy = y * (allsky_tile_size as u32);
|
||||
let dx = x * (d3_tile_allsky_size as u32);
|
||||
let dy = y * (d3_tile_allsky_size as u32);
|
||||
|
||||
let sx = (src_idx % 27) * allsky_tile_size;
|
||||
let sy = (src_idx / 27) * allsky_tile_size;
|
||||
let sx = (src_idx % 27) * d3_tile_allsky_size;
|
||||
let sy = (src_idx / 27) * d3_tile_allsky_size;
|
||||
let s = ImageBufferView {
|
||||
x: sx as i32,
|
||||
y: sy as i32,
|
||||
w: allsky_tile_size as i32,
|
||||
h: allsky_tile_size as i32,
|
||||
x: sx,
|
||||
y: sy,
|
||||
w: d3_tile_allsky_size,
|
||||
h: d3_tile_allsky_size,
|
||||
};
|
||||
let d = ImageBufferView {
|
||||
x: dx as i32,
|
||||
y: dy as i32,
|
||||
w: allsky_tile_size as i32,
|
||||
h: allsky_tile_size as i32,
|
||||
w: d3_tile_allsky_size,
|
||||
h: d3_tile_allsky_size,
|
||||
};
|
||||
|
||||
base_tile.tex_sub(&allsky, &s, &d);
|
||||
base_tile.tex_sub(&image, &s, &d);
|
||||
|
||||
src_idx += 1;
|
||||
}
|
||||
@@ -281,103 +267,56 @@ fn handle_allsky_file<F: ImageFormat>(
|
||||
Ok(tiles)
|
||||
}
|
||||
|
||||
fn handle_allsky_fits<F: ImageFormat>(
|
||||
allsky_data: &[<<F as ImageFormat>::P as Pixel>::Item],
|
||||
fn handle_allsky_fits<F: TextureFormat>(
|
||||
image: &[<F::P as Pixel>::Item],
|
||||
|
||||
tile_size: i32,
|
||||
texture_size: i32,
|
||||
allsky_tile_size: i32,
|
||||
) -> Result<impl Iterator<Item = ImageBuffer<F>>, JsValue> {
|
||||
let allsky_tile_size = std::cmp::min(tile_size, 64);
|
||||
let width_allsky_px = 27 * allsky_tile_size;
|
||||
let height_allsky_px = 29 * allsky_tile_size;
|
||||
let d3_tile_allsky_size = std::cmp::min(tile_size, 64);
|
||||
let width_allsky_px = 27 * d3_tile_allsky_size;
|
||||
let height_allsky_px = 29 * d3_tile_allsky_size;
|
||||
// The fits image layout stores rows in reverse
|
||||
let reversed_rows_data = allsky_data
|
||||
let reversed_rows_data = image
|
||||
.chunks(width_allsky_px as usize * F::NUM_CHANNELS)
|
||||
.rev()
|
||||
.flatten()
|
||||
.copied()
|
||||
.collect::<Vec<_>>();
|
||||
let allsky = ImageBuffer::<F>::new(reversed_rows_data, width_allsky_px, height_allsky_px);
|
||||
.collect::<Vec<_>>()
|
||||
.into_boxed_slice();
|
||||
let image = ImageBuffer::<F>::new(
|
||||
reversed_rows_data,
|
||||
width_allsky_px as u32,
|
||||
height_allsky_px as u32,
|
||||
1,
|
||||
);
|
||||
|
||||
let allsky_tiles_iter =
|
||||
handle_allsky_file::<F>(allsky, allsky_tile_size, texture_size, tile_size)?.map(
|
||||
move |image| {
|
||||
// The GPU does a specific transformation on the UV for FITS tiles
|
||||
// We must revert this to be compatible with this GPU transformation
|
||||
let new_image_data = image
|
||||
.get_data()
|
||||
.chunks((tile_size * tile_size) as usize * F::NUM_CHANNELS)
|
||||
.flat_map(|c| {
|
||||
c.chunks(tile_size as usize * F::NUM_CHANNELS)
|
||||
.rev()
|
||||
.flatten()
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
handle_allsky_file::<F>(image, allsky_tile_size, tile_size)?.map(move |image| {
|
||||
// The GPU does a specific transformation on the UV for FITS tiles
|
||||
// We must revert this to be compatible with this GPU transformation
|
||||
let new_image_data = image
|
||||
.get_data()
|
||||
.chunks((allsky_tile_size * allsky_tile_size) as usize * F::NUM_CHANNELS)
|
||||
.flat_map(|c| {
|
||||
c.chunks(allsky_tile_size as usize * F::NUM_CHANNELS)
|
||||
.rev()
|
||||
.flatten()
|
||||
})
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
ImageBuffer::<F>::new(new_image_data, tile_size, tile_size)
|
||||
},
|
||||
);
|
||||
ImageBuffer::<F>::new(
|
||||
new_image_data,
|
||||
allsky_tile_size as u32,
|
||||
allsky_tile_size as u32,
|
||||
1,
|
||||
)
|
||||
});
|
||||
|
||||
Ok(allsky_tiles_iter)
|
||||
}
|
||||
|
||||
use al_core::image::format::RGBA8U;
|
||||
|
||||
use crate::time::Time;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub struct Allsky {
|
||||
pub image: Rc<RefCell<Option<Vec<ImageType>>>>,
|
||||
pub time_req: Time,
|
||||
pub depth_tile: u8,
|
||||
|
||||
pub hips_cdid: CreatorDid,
|
||||
url: Url,
|
||||
pub channel: Option<u32>,
|
||||
}
|
||||
use al_core::texture::format::RGBA8U;
|
||||
|
||||
use crate::Abort;
|
||||
|
||||
impl Allsky {
|
||||
pub fn missing(&self) -> bool {
|
||||
self.image.borrow().is_none()
|
||||
}
|
||||
|
||||
pub fn get_hips_cdid(&self) -> &CreatorDid {
|
||||
&self.hips_cdid
|
||||
}
|
||||
|
||||
pub fn get_url(&self) -> &Url {
|
||||
&self.url
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a AllskyRequest> for Option<Allsky> {
|
||||
fn from(request: &'a AllskyRequest) -> Self {
|
||||
let AllskyRequest {
|
||||
request,
|
||||
hips_cdid,
|
||||
depth_tile,
|
||||
url,
|
||||
channel,
|
||||
..
|
||||
} = request;
|
||||
if request.is_resolved() {
|
||||
let Request::<Vec<ImageType>> {
|
||||
time_request, data, ..
|
||||
} = request;
|
||||
Some(Allsky {
|
||||
time_req: *time_request,
|
||||
// This is a clone on a Arc, it is supposed to be fast
|
||||
image: data.clone(),
|
||||
hips_cdid: hips_cdid.clone(),
|
||||
url: url.clone(),
|
||||
depth_tile: *depth_tile,
|
||||
channel: *channel,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
use al_core::image::format::ChannelType;
|
||||
use std::io::Cursor;
|
||||
|
||||
use crate::downloader::query;
|
||||
use crate::renderable::CreatorDid;
|
||||
use fitsrs::fits::Fits;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Metadata {
|
||||
pub blank: f32,
|
||||
pub scale: f32,
|
||||
pub offset: f32,
|
||||
}
|
||||
|
||||
impl Default for Metadata {
|
||||
fn default() -> Self {
|
||||
Metadata {
|
||||
blank: -1.0,
|
||||
scale: 1.0,
|
||||
offset: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use super::{Request, RequestType};
|
||||
use crate::downloader::QueryId;
|
||||
|
||||
pub struct PixelMetadataRequest {
|
||||
pub id: QueryId,
|
||||
pub url: Url,
|
||||
pub hips_cdid: CreatorDid,
|
||||
request: Request<Metadata>,
|
||||
}
|
||||
|
||||
impl From<PixelMetadataRequest> for RequestType {
|
||||
fn from(request: PixelMetadataRequest) -> Self {
|
||||
RequestType::PixelMetadata(request)
|
||||
}
|
||||
}
|
||||
|
||||
use super::Url;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{RequestInit, RequestMode, Response};
|
||||
impl From<query::PixelMetadata> for PixelMetadataRequest {
|
||||
// Create a tile request associated to a HiPS
|
||||
fn from(query: query::PixelMetadata) -> Self {
|
||||
let query::PixelMetadata {
|
||||
format,
|
||||
url,
|
||||
hips_cdid,
|
||||
id,
|
||||
} = query;
|
||||
|
||||
let url_clone = url.clone();
|
||||
|
||||
let channel = format.get_channel();
|
||||
|
||||
let window = web_sys::window().unwrap_abort();
|
||||
let request = match channel {
|
||||
ChannelType::R32F | ChannelType::R32I | ChannelType::R16I | ChannelType::R8UI => {
|
||||
Request::new(async move {
|
||||
let mut opts = RequestInit::new();
|
||||
opts.method("GET");
|
||||
opts.mode(RequestMode::Cors);
|
||||
|
||||
let request =
|
||||
web_sys::Request::new_with_str_and_init(&url_clone, &opts).unwrap_abort();
|
||||
let resp_value = JsFuture::from(window.fetch_with_request(&request)).await?;
|
||||
// `resp_value` is a `Response` object.
|
||||
debug_assert!(resp_value.is_instance_of::<Response>());
|
||||
let resp: Response = resp_value.dyn_into()?;
|
||||
// See https://github.com/MattiasBuelens/wasm-streams/blob/f6dacf58a8826dc67923ab4a3bae87635690ca64/examples/fetch_as_stream.rs#L25-L33
|
||||
/*let raw_body = resp.body().ok_or(JsValue::from_str("Cannot extract readable stream"))?;
|
||||
let body = ReadableStream::from_raw(raw_body.dyn_into()?);
|
||||
|
||||
// Convert the JS ReadableStream to a Rust stream
|
||||
let mut reader = body.try_into_async_read().map_err(|_| JsValue::from_str("readable stream locked"))?;
|
||||
let image = Fits::new(reader).await?;*/
|
||||
|
||||
let array_buffer = JsFuture::from(resp.array_buffer()?).await?;
|
||||
let bytes_buffer = js_sys::Uint8Array::new(&array_buffer);
|
||||
|
||||
let num_bytes = bytes_buffer.length() as usize;
|
||||
let mut raw_bytes = Vec::with_capacity(num_bytes);
|
||||
unsafe {
|
||||
raw_bytes.set_len(num_bytes);
|
||||
}
|
||||
bytes_buffer.copy_to(&mut raw_bytes[..]);
|
||||
|
||||
let mut reader = Cursor::new(&raw_bytes[..]);
|
||||
let Fits { hdu } = Fits::from_reader(&mut reader)
|
||||
.map_err(|_| JsValue::from_str("Parsing fits error"))?;
|
||||
|
||||
let header = hdu.get_header();
|
||||
let scale =
|
||||
if let Some(fitsrs::card::Value::Float(bscale)) = header.get(b"BSCALE ") {
|
||||
*bscale as f32
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
let offset =
|
||||
if let Some(fitsrs::card::Value::Float(bzero)) = header.get(b"BZERO ") {
|
||||
*bzero as f32
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let blank =
|
||||
if let Some(fitsrs::card::Value::Float(blank)) = header.get(b"BLANK ") {
|
||||
*blank as f32
|
||||
} else {
|
||||
std::f32::NAN
|
||||
};
|
||||
|
||||
Ok(Metadata {
|
||||
blank,
|
||||
scale,
|
||||
offset,
|
||||
})
|
||||
})
|
||||
}
|
||||
_ => Request::new(async move { Ok(Metadata::default()) }),
|
||||
};
|
||||
|
||||
Self {
|
||||
id,
|
||||
url,
|
||||
hips_cdid,
|
||||
request,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
#[derive(Debug)]
|
||||
pub struct PixelMetadata {
|
||||
pub value: Rc<RefCell<Option<Metadata>>>,
|
||||
pub hips_cdid: CreatorDid,
|
||||
pub url: String,
|
||||
}
|
||||
use crate::Abort;
|
||||
impl<'a> From<&'a PixelMetadataRequest> for Option<PixelMetadata> {
|
||||
fn from(request: &'a PixelMetadataRequest) -> Self {
|
||||
let PixelMetadataRequest {
|
||||
request,
|
||||
hips_cdid,
|
||||
url,
|
||||
..
|
||||
} = request;
|
||||
if request.is_resolved() {
|
||||
let Request::<Metadata> { data, .. } = request;
|
||||
// It will always be resolved and found as we will request a well know tile (Norder0/Tile0)
|
||||
Some(PixelMetadata {
|
||||
hips_cdid: hips_cdid.clone(),
|
||||
url: url.to_string(),
|
||||
value: data.clone(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,15 @@ use crate::renderable::CreatorDid;
|
||||
|
||||
use super::{Request, RequestType};
|
||||
|
||||
use crate::healpix::coverage::Smoc;
|
||||
use moclib::deser::fits::MocType;
|
||||
use moclib::qty::Hpx;
|
||||
use crate::healpix::moc::Moc;
|
||||
use crate::healpix::moc::{FreqSpaceMoc, SpaceMoc};
|
||||
use al_api::hips::DataproductType;
|
||||
|
||||
pub struct MOCRequest {
|
||||
//pub id: QueryId,
|
||||
pub hips_cdid: CreatorDid,
|
||||
pub params: MOCOptions,
|
||||
request: Request<HEALPixCoverage>,
|
||||
pub request: Request<Moc>,
|
||||
}
|
||||
|
||||
impl From<MOCRequest> for RequestType {
|
||||
@@ -19,35 +19,14 @@ impl From<MOCRequest> for RequestType {
|
||||
RequestType::Moc(request)
|
||||
}
|
||||
}
|
||||
use super::Url;
|
||||
|
||||
use moclib::deser::fits;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{RequestInit, Response};
|
||||
|
||||
use moclib::moc::range::op::convert::convert_to_u64;
|
||||
|
||||
/// Convenient type for Space-MOCs
|
||||
pub fn from_fits_hpx<T: Idx>(moc: MocType<T, Hpx<T>, Cursor<&[u8]>>) -> Smoc {
|
||||
match moc {
|
||||
MocType::Ranges(moc) => convert_to_u64::<T, Hpx<T>, _, Hpx<u64>>(moc).into_range_moc(),
|
||||
MocType::Cells(moc) => {
|
||||
convert_to_u64::<T, Hpx<T>, _, Hpx<u64>>(moc.into_cell_moc_iter().ranges())
|
||||
.into_range_moc()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use crate::healpix::coverage::HEALPixCoverage;
|
||||
use crate::Abort;
|
||||
use al_api::moc::MOCOptions;
|
||||
use moclib::deser::fits::MocIdxType;
|
||||
use moclib::deser::fits::MocQtyType;
|
||||
use moclib::idx::Idx;
|
||||
use moclib::moc::{CellMOCIntoIterator, CellMOCIterator, RangeMOCIterator};
|
||||
use std::io::Cursor;
|
||||
use wasm_bindgen::JsValue;
|
||||
|
||||
impl From<query::Moc> for MOCRequest {
|
||||
// Create a tile request associated to a HiPS
|
||||
fn from(query: query::Moc) -> Self {
|
||||
@@ -56,7 +35,8 @@ impl From<query::Moc> for MOCRequest {
|
||||
params,
|
||||
hips_cdid,
|
||||
credentials,
|
||||
mode
|
||||
mode,
|
||||
dataproduct_type,
|
||||
} = query;
|
||||
|
||||
let url_clone = url.clone();
|
||||
@@ -75,25 +55,20 @@ impl From<query::Moc> for MOCRequest {
|
||||
let resp: Response = resp_value.dyn_into()?;
|
||||
let array_buffer = JsFuture::from(resp.array_buffer()?).await?;
|
||||
|
||||
let bytes_buf = js_sys::Uint8Array::new(&array_buffer);
|
||||
let num_bytes = bytes_buf.length() as usize;
|
||||
let mut bytes = Vec::with_capacity(num_bytes);
|
||||
unsafe {
|
||||
bytes.set_len(num_bytes);
|
||||
}
|
||||
bytes_buf.copy_to(&mut bytes[..]);
|
||||
let buf = js_sys::Uint8Array::new(&array_buffer);
|
||||
let bytes = buf.to_vec();
|
||||
|
||||
// Coosys is permissive because we load a moc
|
||||
let smoc = match fits::from_fits_ivoa_custom(Cursor::new(&bytes[..]), true)
|
||||
.map_err(|e| JsValue::from_str(&e.to_string()))?
|
||||
{
|
||||
MocIdxType::U16(MocQtyType::<u16, _>::Hpx(moc)) => Ok(from_fits_hpx(moc)),
|
||||
MocIdxType::U32(MocQtyType::<u32, _>::Hpx(moc)) => Ok(from_fits_hpx(moc)),
|
||||
MocIdxType::U64(MocQtyType::<u64, _>::Hpx(moc)) => Ok(from_fits_hpx(moc)),
|
||||
_ => Err(JsValue::from_str("MOC not supported. Must be a HPX MOC")),
|
||||
}?;
|
||||
|
||||
Ok(HEALPixCoverage(smoc))
|
||||
Ok(match dataproduct_type {
|
||||
DataproductType::SpectralCube => {
|
||||
Moc::FreqSpace(FreqSpaceMoc::from_fits_raw_bytes(&bytes)?)
|
||||
}
|
||||
DataproductType::Cube => {
|
||||
let moc = SpaceMoc::from_fits_raw_bytes(&bytes)?;
|
||||
Moc::FreqSpace(FreqSpaceMoc::from_space_moc(moc))
|
||||
}
|
||||
_ => Moc::Space(SpaceMoc::from_fits_raw_bytes(&bytes)?),
|
||||
})
|
||||
});
|
||||
|
||||
Self {
|
||||
@@ -105,39 +80,3 @@ impl From<query::Moc> for MOCRequest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
pub struct Moc {
|
||||
pub moc: Rc<RefCell<Option<HEALPixCoverage>>>,
|
||||
pub params: MOCOptions,
|
||||
pub hips_cdid: Url,
|
||||
}
|
||||
|
||||
impl Moc {
|
||||
pub fn get_hips_cdid(&self) -> &Url {
|
||||
&self.hips_cdid
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a MOCRequest> for Option<Moc> {
|
||||
fn from(request: &'a MOCRequest) -> Self {
|
||||
let MOCRequest {
|
||||
request,
|
||||
hips_cdid,
|
||||
params,
|
||||
..
|
||||
} = request;
|
||||
if request.is_resolved() {
|
||||
let Request::<HEALPixCoverage> { data, .. } = request;
|
||||
Some(Moc {
|
||||
// This is a clone on a Arc, it is supposed to be fast
|
||||
moc: data.clone(),
|
||||
hips_cdid: hips_cdid.clone(),
|
||||
params: params.clone(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||