Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XCD-196 Render Zones ordered by camera distance #1769

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/plugins/ZonesPlugin/ZonesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,21 @@ class Zone extends Component {
}


const positions = [].concat(...pos);
const min = idx => Math.min(...pos.map(p => p[idx]));
const max = idx => Math.max(...pos.map(p => p[idx]));

const xmin = min(0);
const ymin = min(1);
const zmin = min(2);
const xmax = max(0);
const ymax = max(1);
const zmax = max(2);

this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);

const positions = [].concat(...pos.map(p => math.subVec3(p, this._center, p)));
this._zoneMesh = new Mesh(scene, {
origin: this._center,
edges: this._edges,
geometry: new ReadableGeometry(
scene,
Expand Down Expand Up @@ -524,19 +537,6 @@ class Zone extends Component {
}

this._metrics = null;


const min = idx => Math.min(...pos.map(p => p[idx]));
const max = idx => Math.max(...pos.map(p => p[idx]));

const xmin = min(0);
const ymin = min(1);
const zmin = min(2);
const xmax = max(0);
const ymax = max(1);
const zmax = max(2);

this._center = math.vec3([ (xmin + xmax) / 2, (ymin + ymax) / 2, (zmin + zmax) / 2 ]);
}

get baseArea() {
Expand Down
8 changes: 6 additions & 2 deletions src/viewer/scene/webgl/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {SAODepthLimitedBlurRenderer} from "./sao/SAODepthLimitedBlurRenderer.js"
import {RenderBufferManager} from "./RenderBufferManager.js";
import {getExtension} from "./getExtension.js";

const vec3_0 = math.vec3([0,0,0]);

/**
* @private
*/
Expand Down Expand Up @@ -713,9 +715,11 @@ const Renderer = function (scene, options) {
// Transparent color fill

if (normalFillTransparentBinLen > 0) {
const eye = frameCtx.pickOrigin || scene.camera.eye;
const byDist = normalFillTransparentBin.map(d => ({ drawable: d, distSq: math.distVec3(d.origin || vec3_0, eye) }));
byDist.sort((a, b) => b.distSq - a.distSq);
for (i = 0; i < normalFillTransparentBinLen; i++) {
drawable = normalFillTransparentBin[i];
drawable.drawColorTransparent(frameCtx);
byDist[i].drawable.drawColorTransparent(frameCtx);
}
}

Expand Down
Loading