Compare commits

...

3 Commits

Author SHA1 Message Date
4c11d44918 Bump version to 0.2.1
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
2025-04-02 15:41:09 -07:00
996a62f55a Improve rad to deg handling
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
2025-04-02 15:39:29 -07:00
99b84272c6 Add configuration descriptions to ReadMe 2025-03-25 20:57:25 -07:00
3 changed files with 35 additions and 4 deletions

View File

@@ -1,3 +1,33 @@
# GlModelViewer # GlModelViewer
MediaWiki extension for using model-viewer to display and annotate 3D models MediaWiki extension for using model-viewer to display and annotate 3D models
## Metadata
Model-viewer configurations and annotations can be added as a json string in the file's description.
### Viewer Configuration
Configuration of the model-viewer instance is contained in the `viewerConfig` object.
This object can contain any number of child objects each of which describes a different possible configuration.
Each configuration can have properties matching the any of the attributes of the model-viewer element except for `src`, `class`, `interpolation-delay`, and `interaction-prompt`.
### Annotations
Annotations can be configured using the `annotations` object.
This object can contain any number of child objects each of which describes a different possible annotation.
The label for each annotation is the name of the child object. Each object has two required properties and two optional properties.
| Property | Required | Description | Example |
|----------|----------|-------------|---------|
| `data-position` | Yes | String containing the X, Y, and Z coordinates of the annotation. | "0.02297m -0.02544m 0.01780m" |
| `data-normal` | Yes | String containing the X, Y, and Z coordinates of the normal vector of the annotation. | "0.78966m -0.53116m 0.30709m" |
| `data-orbit` | No | String containing the orbit vector of the camera to view annotation. | "2.31rad 2.01rad 0.65m" |
| `data-target` | No | String containing the X, Y, and Z coordinates of the camera target to view annotation. | "-0.01029m 0.00071m 0.01138m" |
### Annotation sets
Annotations sets are specific subsets of the listed annotations that can be shown on the model.
They are configured using the `annotationSets` object.
This object can contain any number of child objects each of which contains an array of strings matching the names of the annotation to be included.
By default, all annotations are rendered on a model.

View File

@@ -3,7 +3,7 @@
"author": "Justin Georgi", "author": "Justin Georgi",
"url": "https://gitea.azgeorgis.net/jgeorgi/mwModelViewer", "url": "https://gitea.azgeorgis.net/jgeorgi/mwModelViewer",
"description": "This extension allows .glb and .gltf files to be added, displayed, and annotated in MediaWiki", "description": "This extension allows .glb and .gltf files to be added, displayed, and annotated in MediaWiki",
"version": "0.2.0", "version": "0.2.1",
"license-name": "MIT", "license-name": "MIT",
"type": "media", "type": "media",
"manifest_version": 2, "manifest_version": 2,

View File

@@ -135,8 +135,9 @@ orb2degree = function(orbString, fix = null) {
} }
if (fix) { if (fix) {
degArray = degArray.map((v, idx) => { degArray = degArray.map((v, idx) => {
let fixReg = new RegExp('(\\d*.\\d{' + (((typeof fix) == 'object') ? fix[idx] : fix) + '})(\\d*)([a-z]*)') //let fixReg = new RegExp('(-?\\d*\\.\\d{' + (((typeof fix) == 'object') ? fix[idx] : fix) + '})(\\d*)([a-z]*)')
return v.replace(fixReg,'$1$3') //return v.replace(fixReg,'$1$3')
return Number.parseFloat(v).toFixed((typeof fix == 'object') ? fix[idx] : fix) + v.substring(v.search(/[a-z]/))
}) })
} }
return degArray.join(' ') return degArray.join(' ')