mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 01:44:19 +01:00
move DPR constant to separate module
This commit is contained in:
parent
99bbe1b7ae
commit
54db6f81d6
5 changed files with 14 additions and 13 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
2
web/app/utils/dpr.js
Normal file
2
web/app/utils/dpr.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
const DPR = (window.devicePixelRatio) ? window.devicePixelRatio : 1;
|
||||
export default DPR;
|
||||
Loading…
Reference in a new issue