diff --git a/web/app/3d/cad-utils.js b/web/app/3d/cad-utils.js index 8401e688..7980915f 100644 --- a/web/app/3d/cad-utils.js +++ b/web/app/3d/cad-utils.js @@ -5,8 +5,8 @@ import * as math from '../math/math' import {Matrix3, AXIS, ORIGIN} from '../math/l3space' import Counters from './counters' import {Solid} from './solid' +import DPR from '../utils/dpr' -export const DPR = (window.devicePixelRatio) ? window.devicePixelRatio : 1; export const FACE_COLOR = 0xB0C4DE; export function createSquare(width) { diff --git a/web/app/3d/solid.js b/web/app/3d/solid.js index 24b46438..cb731cde 100644 --- a/web/app/3d/solid.js +++ b/web/app/3d/solid.js @@ -3,7 +3,8 @@ import Vector from '../math/vector' import Counters from './counters' import {reconstructSketchBounds} from './workbench' import {Matrix3, AXIS} from '../math/l3space' -import {DPR, arrFlatten1L} from './cad-utils' +import {arrFlatten1L} from './cad-utils' +import DPR from '../utils/dpr' /** @constructor */ export function Solid(csg, material, type) { @@ -201,12 +202,8 @@ function SketchFace(solid, csgGroup) { this.curvedSurfaces = null; } -if (typeof THREE !== "undefined") { - SketchFace.prototype.SKETCH_MATERIAL = new THREE.LineBasicMaterial({ - color: 0xFFFFFF, linewidth: 3/DPR}); - SketchFace.prototype.WIREFRAME_MATERIAL = new THREE.LineBasicMaterial({ - color: 0x2B3856, linewidth: 3/DPR}); -} +SketchFace.prototype.SKETCH_MATERIAL = new THREE.LineBasicMaterial({color: 0xFFFFFF, linewidth: 3/DPR}); +SketchFace.prototype.WIREFRAME_MATERIAL = new THREE.LineBasicMaterial({color: 0x2B3856, linewidth: 3/DPR}); SketchFace.prototype.calcBasis = function() { var normal = new Vector().setV(this.csgGroup.plane.normal); diff --git a/web/app/3d/viewer.js b/web/app/3d/viewer.js index 15c73f2d..6b6c1b44 100644 --- a/web/app/3d/viewer.js +++ b/web/app/3d/viewer.js @@ -1,5 +1,6 @@ import * as cad_utils from './cad-utils' import {Matrix3, AXIS, ORIGIN} from '../math/l3space' +import DPR from '../utils/dpr' function Viewer(bus) { this.bus = bus; @@ -18,7 +19,7 @@ function Viewer(bus) { scene.add(light); var renderer = new THREE.WebGLRenderer(); - renderer.setPixelRatio(cad_utils.DPR); + renderer.setPixelRatio(DPR); renderer.setClearColor(0x808080, 1); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); @@ -75,7 +76,7 @@ function Viewer(bus) { } function addAxis(axis, color) { - var lineMaterial = new THREE.LineBasicMaterial({color: color, linewidth: 1/cad_utils.DPR}); + var lineMaterial = new THREE.LineBasicMaterial({color: color, linewidth: 1/DPR}); var axisGeom = new THREE.Geometry(); axisGeom.vertices.push(axis.multiply(-1000).three()); axisGeom.vertices.push(axis.multiply(1000).three()); @@ -172,7 +173,7 @@ function SelectionManager(viewer, selectionColor, readOnlyColor, defaultColor) { arrow.matrixAutoUpdate = false; arrow.line.renderOrder = 1e11; arrow.cone.renderOrder = 1e11; - arrow.line.material.linewidth = 1/cad_utils.DPR; + arrow.line.material.linewidth = 1/DPR; arrow.line.material.depthWrite = false; arrow.line.material.depthTest = false; arrow.cone.material.depthWrite = false; diff --git a/web/app/3d/wizards/wizards.js b/web/app/3d/wizards/wizards.js index a9de72d9..2a33f03b 100644 --- a/web/app/3d/wizards/wizards.js +++ b/web/app/3d/wizards/wizards.js @@ -2,18 +2,19 @@ import Vector from '../../math/vector' import * as cad_utils from '../cad-utils' import * as math from '../../math/math' import {Matrix3, AXIS, ORIGIN, IDENTITY_BASIS} from '../../math/l3space' +import DPR from '../../utils/dpr' var IMAGINE_MATERIAL = new THREE.LineBasicMaterial({ color: 0xFA8072, - linewidth: 1/cad_utils.DPR, + linewidth: 1/DPR, depthWrite: false, depthTest: false }); var BASE_MATERIAL = new THREE.LineBasicMaterial({ color: 0x8B0000, - linewidth: 3/cad_utils.DPR, + linewidth: 3/DPR, depthWrite: false, depthTest: false }); diff --git a/web/app/utils/dpr.js b/web/app/utils/dpr.js new file mode 100644 index 00000000..70d0cf33 --- /dev/null +++ b/web/app/utils/dpr.js @@ -0,0 +1,2 @@ +const DPR = (window.devicePixelRatio) ? window.devicePixelRatio : 1; +export default DPR; \ No newline at end of file