Browse Source

Fix clipping object angle (convert to rad)

David Sehnal 4 years ago
parent
commit
4e509fc479
2 changed files with 6 additions and 4 deletions
  1. 3 2
      src/mol-gl/renderer.ts
  2. 3 2
      src/mol-math/misc.ts

+ 3 - 2
src/mol-gl/renderer.ts

@@ -19,6 +19,7 @@ import { ParamDefinition as PD } from '../mol-util/param-definition';
 import { Clipping } from '../mol-theme/clipping';
 import { stringToWords } from '../mol-util/string';
 import { Transparency } from '../mol-theme/transparency';
+import { degToRad } from '../mol-math/misc';
 
 export interface RendererStats {
     programCount: number
@@ -83,7 +84,7 @@ export const RendererParams = {
             position: PD.Vec3(Vec3()),
             rotation: PD.Group({
                 axis: PD.Vec3(Vec3.create(1, 0, 0)),
-                angle: PD.Numeric(0, { min: -180, max: 180, step: 0.1 }),
+                angle: PD.Numeric(0, { min: -180, max: 180, step: 0.1 }, { description: 'Angle in Degrees' }),
             }, { isExpanded: true }),
             scale: PD.Vec3(Vec3.create(1, 1, 1)),
         }, o => stringToWords(o.type))
@@ -146,7 +147,7 @@ function getClip(props: RendererProps['clip'], clip?: Clip): Clip {
         const p = props.objects[i];
         type[i] = Clipping.Type[p.type];
         Vec3.toArray(p.position, position, i * 3);
-        Quat.toArray(Quat.setAxisAngle(tmpQuat, p.rotation.axis, p.rotation.angle), rotation, i * 4);
+        Quat.toArray(Quat.setAxisAngle(tmpQuat, p.rotation.axis, degToRad(p.rotation.angle)), rotation, i * 4);
         Vec3.toArray(p.scale, scale, i * 3);
     }
     return {

+ 3 - 2
src/mol-math/misc.ts

@@ -5,13 +5,14 @@
  */
 
 export const halfPI = Math.PI / 2;
+export const PiDiv180 = Math.PI / 180;
 
 export function degToRad (deg: number) {
-    return deg * 0.01745;  // deg * Math.PI / 180
+    return deg * PiDiv180;  // deg * Math.PI / 180
 }
 
 export function radToDeg (rad: number) {
-    return rad * 57.29578;  // rad * 180 / Math.PI
+    return rad / PiDiv180;  // rad * 180 / Math.PI
 }
 
 export function isPowerOfTwo (x: number) {