-
Notifications
You must be signed in to change notification settings - Fork 100
Gaussians LOD #189
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
Open
HectorArellanoDev
wants to merge
29
commits into
master
Choose a base branch
from
gaussians-lod
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Gaussians LOD #189
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c7fab8f
start integration
dc481e4
integrating
95651ae
testing mobile version
f6b0583
setting up a way to define if the harmonics should be loaded
8c1368d
setup a way to check if it is IOS, define a way to see if the renderi…
e03f2e9
testing memory, defining parameters
d70ba47
remove flickering
5ad1005
using a defer function to check the next frame so the data is updated…
77c0d40
cleaning
5bc9c9a
refactoring the delay function
fe641f4
remove splats scenes
cd3afe1
setup the decoding worker for the splats to work without Three
e07bd85
updates for the shader to test harmonics
9c7144b
changes from Thibault requests
2e789b2
inserting the splats into the octree from Potree
54a0382
include the splats mesh into the octree
bd69f09
testing Thibault requests
b1b4df8
testing
a640039
solving the loading issue for the new decoder refactoring
c87bc09
level of detail for the splats size implementation
f7b382a
adding the sorter as base64 and implement the splats scale based on t…
fdb835e
modify the splats to be adaptive to the LOD and the camera distance
e2cdc7a
yarn lock as master
57f4973
updates from Thibault
5e9aebd
Delete example/.DS_Store
HectorArellanoDev b63c50c
Delete .DS_Store
HectorArellanoDev 4dcc8cc
fix the example to load V1, V2 and splats
2fbe25a
fix issue with DS_Store
733af0b
Delete .DS_Store
HectorArellanoDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,3 @@ | ||||||||
import { Vector3 } from 'three'; | ||||||||
import { ClipMode, PointCloudOctree } from '../src'; | ||||||||
import { Viewer } from './viewer'; | ||||||||
|
||||||||
|
@@ -19,13 +18,14 @@ interface PointCloudsConfig { | |||||||
|
||||||||
const examplePointClouds: PointCloudsConfig[] = [ | ||||||||
{ | ||||||||
file: 'cloud.js', | ||||||||
url: 'https://raw.githubusercontent.com/potree/potree/develop/pointclouds/lion_takanawa/', | ||||||||
version: 'v1' | ||||||||
}, { | ||||||||
file: 'metadata.json', | ||||||||
url: 'https://test-pix4d-cloud-eu-central-1.s3.eu-central-1.amazonaws.com/lion_takanawa_converted/', | ||||||||
version: 'v2' | ||||||||
version: 'v1', | ||||||||
}, | ||||||||
{ | ||||||||
file: 'metadata.json', | ||||||||
url: 'https://www.mdbm.es/alamedilla/', | ||||||||
version: 'v2', | ||||||||
} | ||||||||
]; | ||||||||
|
||||||||
|
@@ -47,7 +47,7 @@ const loaded: LoadedState = { | |||||||
v2: false | ||||||||
}; | ||||||||
|
||||||||
function createButton(text: string, onClick: () => void): HTMLButtonElement { | ||||||||
function createButton(text: string, onClick: (e: MouseEvent) => void): HTMLButtonElement { | ||||||||
const button: HTMLButtonElement = document.createElement('button'); | ||||||||
button.textContent = text; | ||||||||
button.addEventListener('click', onClick); | ||||||||
|
@@ -58,45 +58,86 @@ function createSlider(version: string): HTMLInputElement { | |||||||
const slider: HTMLInputElement = document.createElement('input'); | ||||||||
slider.type = 'range'; | ||||||||
slider.min = '10000'; | ||||||||
slider.max = '500000'; | ||||||||
slider.max = '1000000'; | ||||||||
slider.value = '1000000'; | ||||||||
slider.className = 'budget-slider'; | ||||||||
slider.addEventListener('change', () => { | ||||||||
const cloud = pointClouds[version]; | ||||||||
if (!cloud) { | ||||||||
return; | ||||||||
} | ||||||||
cloud.potree.pointBudget = parseInt(slider.value, 10); | ||||||||
viewer.update(0); | ||||||||
console.log(cloud.potree.pointBudget); | ||||||||
}); | ||||||||
return slider; | ||||||||
} | ||||||||
|
||||||||
function createHarmonicsSlider(): HTMLInputElement { | ||||||||
const slider: HTMLInputElement = document.createElement('input'); | ||||||||
slider.type = 'range'; | ||||||||
slider.min = '0'; | ||||||||
slider.max = '3'; | ||||||||
slider.value = "0"; | ||||||||
slider.className = 'harmonics-slider'; | ||||||||
slider.addEventListener('change', () => { | ||||||||
viewer.pointClouds[0].material.uniforms.harmonicsDegree.value = slider.value; | ||||||||
}); | ||||||||
return slider; | ||||||||
} | ||||||||
|
||||||||
|
||||||||
function setupPointCloud(version: 'v1' | 'v2', file: string, url: string): void { | ||||||||
if (loaded[version]) { | ||||||||
return; | ||||||||
} | ||||||||
loaded[version] = true; | ||||||||
|
||||||||
viewer.load(file, url, version) | ||||||||
//TODO: check for mobile, not noly IOS | ||||||||
function isIOS() { | ||||||||
const ua = navigator.userAgent; | ||||||||
return ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0; | ||||||||
} | ||||||||
|
||||||||
viewer.load(file, url, 'v2', !isIOS()) | ||||||||
.then(pco => { | ||||||||
pointClouds[version] = pco; | ||||||||
pco.rotateX(-Math.PI / 2); | ||||||||
pco.material.size = 1.0; | ||||||||
|
||||||||
pco.material.pointColorType = 0; | ||||||||
|
||||||||
pco.material.clipMode = ClipMode.CLIP_HORIZONTALLY; | ||||||||
pco.material.clipExtent = [0.0, 0.0, 1.0, 1.0]; | ||||||||
pco.position.set(0, 0, 0); | ||||||||
|
||||||||
//pco.rotateX(-Math.PI * 0.5); | ||||||||
|
||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
|
||||||||
const camera = viewer.camera; | ||||||||
camera.up.set(0, 0, 1); | ||||||||
camera.far = 1000; | ||||||||
camera.updateProjectionMatrix(); | ||||||||
camera.position.set(0, 0, 10); | ||||||||
camera.lookAt(new Vector3()); | ||||||||
camera.position.set(-4, 4, 16); | ||||||||
|
||||||||
viewer.add(pco); | ||||||||
}) | ||||||||
.catch(err => console.error(err)); | ||||||||
} | ||||||||
|
||||||||
function setupUI(cfg: PointCloudsConfig): void { | ||||||||
|
||||||||
const updateBtn = createButton("Update", (e: MouseEvent) => { | ||||||||
e.stopPropagation(); | ||||||||
viewer.enableUpdate = !viewer.enableUpdate; | ||||||||
updateBtn.style.backgroundColor = viewer.enableUpdate ? "#00ff00" : "#ff0000"; | ||||||||
}) | ||||||||
|
||||||||
updateBtn.style.backgroundColor ="#00ff00"; | ||||||||
|
||||||||
const slider = createSlider(cfg.version); | ||||||||
const harmonincsSlider = createHarmonicsSlider(); | ||||||||
|
||||||||
const unloadBtn = createButton('Unload', () => { | ||||||||
if (!loaded[cfg.version]) { | ||||||||
return; | ||||||||
|
@@ -109,18 +150,27 @@ function setupUI(cfg: PointCloudsConfig): void { | |||||||
viewer.disposePointCloud(pointCloud); | ||||||||
loaded[cfg.version] = false; | ||||||||
pointClouds[cfg.version] = undefined; | ||||||||
}); | ||||||||
|
||||||||
const loadBtn = createButton('Load', () => setupPointCloud(cfg.version, cfg.file, cfg.url)); | ||||||||
viewer.enableUpdate = true; | ||||||||
updateBtn.style.backgroundColor ="#00ff00"; | ||||||||
harmonincsSlider.value = "0"; | ||||||||
}); | ||||||||
|
||||||||
const slider = createSlider(cfg.version); | ||||||||
const loadBtn = createButton('Load', (e: MouseEvent) => { | ||||||||
e.stopPropagation(); | ||||||||
setupPointCloud(cfg.version, cfg.file, cfg.url) | ||||||||
} | ||||||||
); | ||||||||
|
||||||||
const btnContainer: HTMLDivElement = document.createElement('div'); | ||||||||
btnContainer.className = 'btn-container-' + cfg.version; | ||||||||
document.body.appendChild(btnContainer); | ||||||||
btnContainer.appendChild(unloadBtn); | ||||||||
btnContainer.appendChild(loadBtn); | ||||||||
btnContainer.append(updateBtn); | ||||||||
btnContainer.appendChild(slider); | ||||||||
btnContainer.appendChild(harmonincsSlider); | ||||||||
|
||||||||
} | ||||||||
|
||||||||
examplePointClouds.forEach(setupUI); |
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't look right. The v1 should still be in potree v1.
When I launch example, I cannot load the first model. In the console I get this error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general I see a few issues with the example. I got another error when I moved the second slider
Could we add some labels to the sliders to understand what they're doing? It would also be great to have both models described somehow so that we know what we're loading in the ui.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!