Skip to content

Commit 279449f

Browse files
Add option to disable auto rescale
Update CHANGES.md. Update the documentation.
1 parent 32810c3 commit 279449f

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ dev
77
Improvements:
88
- Update three.js to r138 (#96)
99
- Add support to smartphones (#97)
10+
- Add option to disable `autoRescale` (#100)
1011

1112
Internals:
1213
- Rename branch master to main

docs/documentation.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ You can use mathics-threejs-backend in 2 ways:
3030
The main function of mathics-threejs-backend is `drawGraphics3d`, takes the following arguments:
3131
- `container` (type: HTMLElement)
3232
- `data` (type: object) — object with the following properties:
33+
- `autoRescale` (type: bool) — whether the plot should be rescaled after spin. Default: `true`
3334
- `axes` (type: object) — default: `{}`, object with the following properties:
3435
- `hasaxes` (type: bool\|bool[3]) — default: `false`
3536
- `ticks` (type: [number[], number[], string[]][3]) — array containing the ticks' information for, respectively, x, y and z axes. The ticks' information is an array of three elements: big ticks' 0-1 coordinates, small ticks' 0-1 coordinates, big ticks' labels. Default: `[]`
@@ -47,6 +48,8 @@ The main function of mathics-threejs-backend is `drawGraphics3d`, takes the foll
4748
- `protocol` (type: string) — protocol version (current is `1.2`), if it isn't compatible a warning is shown instead of the graphics. Only availiable in production version
4849
- `maxSize` (type: number) — default: `400`
4950
- `innerWidthMultiplier` (type: number) — the multiplier of the window inner width, the effective width is `min(maxSize, innerWidthMultiplier * window.innerWidth)`, default: `0.65`
51+
- `config` (type: object) — object with the following properties:
52+
- `autoRescale` (type: bool) — default: `true`
5053

5154
## Examples
5255
- ```js

src/graphics3d.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export default function (
2525
viewpoint = [1.3, -2.4, 2]
2626
},
2727
maxSize = 400,
28-
innerWidthMultiplier = 0.65
28+
innerWidthMultiplier = 0.65,
29+
{ autoRescale = true } = { autoRescale: true }
2930
) {
3031
axes.hasaxes ??= false;
3132
extent ??= calculateExtent(elements);
@@ -41,8 +42,7 @@ export default function (
4142
phi,
4243
onMouseDownPhi,
4344
onTouchStartFingersDistance,
44-
canvasSize = Math.min(maxSize, window.innerWidth * innerWidthMultiplier),
45-
autoRescale = true;
45+
canvasSize = Math.min(maxSize, window.innerWidth * innerWidthMultiplier);
4646

4747
const onMouseDownPosition = new Int16Array(2);
4848

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import drawGraphics3d from './graphics3d.js';
22

3-
function translationLayer(container, object, maxSize, innerWidthMultiplier) {
3+
function translationLayer(container, object, maxSize, innerWidthMultiplier, config) {
44
if (object.protocol) {
55
// protocol version is X.Y, so it is an array of two elements: major version and minor version
66
const versionArray = object.protocol.match(/\d/g);
@@ -38,7 +38,7 @@ function translationLayer(container, object, maxSize, innerWidthMultiplier) {
3838
light.type = light.type.toLowerCase();
3939
});
4040

41-
return drawGraphics3d(container, object, maxSize, innerWidthMultiplier);
41+
return drawGraphics3d(container, object, maxSize, innerWidthMultiplier, config);
4242
}
4343

4444
window.drawGraphics3d = translationLayer;

0 commit comments

Comments
 (0)