-
Notifications
You must be signed in to change notification settings - Fork 77
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
Implement Timecycle lighting for viewer #410
Open
test137E29B
wants to merge
6
commits into
PrismarineJS:master
Choose a base branch
from
test137E29B:feature/timecycle-lighting
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5a8dde5
Implement Timecycle lighting for viewer
test137E29B f1fd79a
Formatting
test137E29B b5e57a9
Remove blank line
test137E29B e83ce65
Improvements
test137E29B c6b0647
Merge branch 'master' into feature/timecycle-lighting
rom1504 6b7e4c7
Merge branch 'master' into feature/timecycle-lighting
rom1504 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 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,6 +1,7 @@ | ||
node_modules | ||
package-lock.json | ||
/test/*.png | ||
/test/server_* | ||
versions/ | ||
public/index.js* | ||
public/worker.js* | ||
|
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ class WorldView extends EventEmitter { | |
this.loadedChunks = {} | ||
this.lastPos = new Vec3(0, 0, 0).update(position) | ||
this.emitter = emitter || this | ||
this._timecycleUpdateInterval = null | ||
|
||
this.listeners = {} | ||
this.emitter.on('mouseClick', async (click) => { | ||
|
@@ -54,13 +55,20 @@ class WorldView extends EventEmitter { | |
this.emitter.emit('entity', { id: e.id, name: e.name, pos: e.position, width: e.width, height: e.height, username: e.username }) | ||
} | ||
} | ||
|
||
this._timecycleUpdateInterval = setInterval(() => { | ||
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. I am not sure about this. Shouldn't it be controlled by the client ticks ? eg mineflayer |
||
this.emitter.emit('timecycleUpdate', { timeOfDay: bot.time.timeOfDay, moonPhase: bot.time.moonPhase }) | ||
}, 1000) | ||
} | ||
|
||
removeListenersFromBot (bot) { | ||
for (const [evt, listener] of Object.entries(this.listeners[bot.username])) { | ||
bot.removeListener(evt, listener) | ||
} | ||
delete this.listeners[bot.username] | ||
|
||
clearInterval(this._timecycleUpdateInterval) | ||
this._timecycleUpdateInterval = null | ||
} | ||
|
||
async init (pos) { | ||
|
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.
Hey! I was interested in wether it could improve the day cycle. When I was trying to port it to TS i noticed it gives a type error because it should be
intensity
instead ofitensity
(a typo). However I'm still not sure of using intensity like this w setting position like this, it still looks not accurate (on the left side is the original client with minimal brightness and this code on the right. time=18000):At the very least you should not use intervals since time can be updated at any moment (night skip, time command), also isRaining can affect the sky color:
commit
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.
Any improvements are very welcome - I will do a bit more testing but wont be able to do much about specific changes for weather lighting etc.
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.
As I remember weather don't affect lighting much - sky gets darker a bit and that's it (and imo it's enough). Anyway, it's too dark at almost any time. Also if you set evening you can see like native client doesn't really change directional light positioning. Really recommend running both clients connected to the same server so it's easy to compare
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 should be fixed
itensity -> intensity at least