Skip to content

Commit

Permalink
Correct deck trimming, + position jitter on objects in Ship3d_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasHasle committed Nov 18, 2019
1 parent 72e073b commit f538ce2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/Ship_in_regular_ocean.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
scene.add(zUpCont);

//Camera setup
camera = new THREE.PerspectiveCamera(26, window.innerWidth / window.innerHeight, 1, 1000000);
camera = new THREE.PerspectiveCamera(26, window.innerWidth / window.innerHeight, 1, 1.5*oSize);
let onResize = function() {
let w = container.clientWidth;
let h = container.clientHeight;
Expand Down
7 changes: 7 additions & 0 deletions examples/snippets/Ship3D_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function Ship3D(ship, {shipState, stlPath, deckOpacity = 0.2, objectOpacity = 0.
//Get zero-width sections
let x = stss[j];//d.xAft+(j/stss.length)*(d.xFwd-d.xAft);
if (isNaN(x)) x = stss[j-1];
x = Math.max(d.xAft, Math.min(d.xFwd, x));
let y1 = Vessel.f.linearFromArrays(stss, wlHigh, x);
let y2 = Vessel.f.linearFromArrays(stss, wlLow, x);
let y = Math.min(0.5 * d.breadth, y1, y2);
Expand Down Expand Up @@ -255,6 +256,12 @@ Object.assign(Ship3D.prototype, {
let y = s.yCentre;
let z = s.zBase;

//Small position jitter to avoid z-fighting
let n = 0.01*(2*Math.random()-1);
x += n;
y += n;
z += n;

//Scale
let d = bo.boxDimensions;

Expand Down

0 comments on commit f538ce2

Please sign in to comment.