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

Priority queue #2495

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"brotli-compress": "^1.3.3",
"copc": "^0.0.6",
"earcut": "^3.0.0",
"flatqueue": "^2.0.3",
"js-priority-queue": "^0.1.5",
"lru-cache": "^11.0.1",
"pbf": "^4.0.1",
Expand Down
55 changes: 2 additions & 53 deletions src/Core/MainLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,53 +28,6 @@ export const MAIN_LOOP_EVENTS = {
UPDATE_END: 'update_end',
};

function updateElements(context, geometryLayer, elements) {
if (!elements) {
return;
}
for (const element of elements) {
// update element
// TODO find a way to notify attachedLayers when geometryLayer deletes some elements
// and then update Debug.js:addGeometryLayerDebugFeatures
const newElementsToUpdate = geometryLayer.update(context, geometryLayer, element);

const sub = geometryLayer.getObjectToUpdateForAttachedLayers(element);

if (sub) {
if (sub.element) {
if (__DEBUG__) {
if (!(sub.element.isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
}
// update attached layers
for (const attachedLayer of geometryLayer.attachedLayers) {
if (attachedLayer.ready) {
attachedLayer.update(context, attachedLayer, sub.element, sub.parent);
}
}
} else if (sub.elements) {
for (let i = 0; i < sub.elements.length; i++) {
if (!(sub.elements[i].isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
// update attached layers
for (const attachedLayer of geometryLayer.attachedLayers) {
if (attachedLayer.ready) {
attachedLayer.update(context, attachedLayer, sub.elements[i], sub.parent);
}
}
}
}
}
updateElements(context, geometryLayer, newElementsToUpdate);
}
}

function filterChangeSources(updateSources, geometryLayer) {
let fullUpdate = false;
const filtered = new Set();
Expand Down Expand Up @@ -150,12 +103,8 @@ class MainLoop extends EventDispatcher {
attachedLayer.preUpdate(context, srcs);
}
}
// `preUpdate` returns an array of elements to update
const elementsToUpdate = geometryLayer.preUpdate(context, srcs);
// `update` is called in `updateElements`.
updateElements(context, geometryLayer, elementsToUpdate);
// `postUpdate` is called when this geom layer update process is finished
geometryLayer.postUpdate(context, geometryLayer, updateSources);

geometryLayer.updateAll(context, srcs);
}

// Clear the cache of expired resources
Expand Down
2 changes: 1 addition & 1 deletion src/Core/PointCloudNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PointCloudNode extends THREE.EventDispatcher {

this.children = [];
this.bbox = new THREE.Box3();
this.sse = -1;
this.sse = 1;
}

add(node, indexChild) {
Expand Down
56 changes: 56 additions & 0 deletions src/Layer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,62 @@
}
}

updateAll(context, srcs) {
const elementsToUpdate = this.preUpdate(context, srcs);
// `update` is called in `updateElements`.
this.updateElements(context, elementsToUpdate);
// `postUpdate` is called when this geom layer update process is finished
this.postUpdate(context, this, elementsToUpdate);
}

updateElements(context, elements) {
console.log('Layer.updateElements');

Check warning on line 279 in src/Layer/Layer.js

View workflow job for this annotation

GitHub Actions / Build bundle, check Linter and generate documentation

Unexpected console statement
if (!elements) {
return;
}
for (const element of elements) {
// update element
// TODO find a way to notify attachedLayers when geometryLayer deletes some elements
// and then update Debug.js:addGeometryLayerDebugFeatures
const newElementsToUpdate = this.update(context, this, element);

const sub = this.getObjectToUpdateForAttachedLayers(element);

if (sub) {
if (sub.element) {
if (__DEBUG__) {
if (!(sub.element.isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
}
// update attached layers
for (const attachedLayer of this.attachedLayers) {
if (attachedLayer.ready) {
attachedLayer.update(context, attachedLayer, sub.element, sub.parent);
}
}
} else if (sub.elements) {
for (let i = 0; i < sub.elements.length; i++) {
if (!(sub.elements[i].isObject3D)) {
throw new Error(`
Invalid object for attached layer to update.
Must be a THREE.Object and have a THREE.Material`);
}
// update attached layers
for (const attachedLayer of this.attachedLayers) {
if (attachedLayer.ready) {
attachedLayer.update(context, attachedLayer, sub.elements[i], sub.parent);
}
}
}
}
}
this.updateElements(context, newElementsToUpdate);
}
}

// Placeholder
// eslint-disable-next-line
convert(data) {
Expand Down
Loading
Loading