-
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
base: master
Are you sure you want to change the base?
Implement Timecycle lighting for viewer #410
Conversation
package.json
Outdated
"process": "^0.11.10", | ||
"node-canvas-webgl": "PrismarineJS/node-canvas-webgl", | ||
"minecraft-assets": "^1.9.0", | ||
"fs-extra": "^11.0.0", | ||
"jest": "^27.0.4", | ||
"jest-puppeteer": "^6.0.0", | ||
"minecraft-assets": "^1.9.0", | ||
"minecraft-wrap": "^1.3.0", | ||
"minecrafthawkeye": "^1.2.5", | ||
"mineflayer": "^4.0.0", | ||
"mineflayer-pathfinder": "^2.0.0", | ||
"node-canvas-webgl": "PrismarineJS/node-canvas-webgl", | ||
"prismarine-schematic": "^1.2.0", | ||
"minecrafthawkeye": "^1.2.5", | ||
"prismarine-viewer": "file:./", | ||
"process": "^0.11.10", | ||
"puppeteer": "^16.0.0", | ||
"standard": "^17.0.0", | ||
"webpack": "^5.10.2", | ||
"webpack-cli": "^5.1.1", | ||
"fs-extra": "^11.0.0" | ||
"webpack-cli": "^5.1.1" |
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.
No version changes here, just alphabetical re-order for readability
I've added some improvements while testing this to make the code a little easier to understand, as well as to better follow the minecraft vanilla timecycle. The directional light in vanilla doesn't move around, but I decided to keep this as it at least adds a nice touch to the viewer. I noticed a few errors in the 1.8.8 - 1.10 tests with entity names, so fixed a broad range by ensuring the entity name is lowercased. Not a huge improvement to anyone on current versions, but actually uses entity models correctly for most entities on lower versions now instead of pink boxes. Some improvements could be made there to fix more such as Workflows seem to be broken, but works fine when I test locally with |
this.scene.background = new THREE.Color(newSkyColor) | ||
const newAmbientIntensity = Math.min(0.43, lightIntensity * 0.75) + (0.04 - (moonPhase / 100)) | ||
const newDirectionalIntensity = Math.min(0.63, lightIntensity) + (0.06 - (moonPhase / 100)) | ||
this.ambientLight.itensity = newAmbientIntensity |
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 of itensity
(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
can you fix CI ? |
I fixed the ci |
@@ -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 comment
The 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
My main concern here is I think mineflayer should be controlling the time cycle, so it should be the one sending the event telling the viewer to update its time. |
Implements PrismarineJS/prismarine-web-client#315 by @kf106 into the viewer instead of web client. Looks like it got closed before being merged, and there was talk of moving it to the viewer anyway on that PR.
First actual contribution to the project, so let me know if there's any kind of formatting or requested changes for code structure.