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

World rendering improvements #408

Merged
merged 11 commits into from
Dec 31, 2023
Prev Previous commit
Next Next commit
utils: load browser version if in browser
zardoy committed Sep 18, 2023
commit dbba29fd75a2aaaac333ec39254d8db8ed0ad476
8 changes: 8 additions & 0 deletions viewer/lib/utils.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,12 @@ const THREE = require('three')
const path = require('path')

const textureCache = {}
// todo not ideal, export different functions for browser and node
function loadTexture (texture, cb) {
if (process.platform === 'browser') {
return require('./utils.web').loadTexture(texture, cb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? didn't it work before?

}

if (textureCache[texture]) {
cb(textureCache[texture])
} else {
@@ -22,6 +27,9 @@ function loadTexture (texture, cb) {
}

function loadJSON (json, cb) {
if (process.platform === 'browser') {
return require('./utils.web').loadJSON(json, cb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? didn't it work before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As said in the body I moved to esbuild in my p viewer setup so I guess that's why I added it. If this is the only thing that blocks merging the pr and you don't want to see it you can remove it (feel free to do it since you should have push access)

}
cb(require(path.resolve(__dirname, '../../public/' + json)))
}