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

Implement Timecycle lighting for viewer #410

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

test137E29B
Copy link

@test137E29B test137E29B commented Nov 4, 2023

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.

package.json Outdated
Comment on lines 41 to 56
"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"
Copy link
Author

@test137E29B test137E29B Nov 4, 2023

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

@test137E29B test137E29B marked this pull request as draft November 4, 2023 13:37
@test137E29B
Copy link
Author

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 entityhorse and ozelot which are both not in entities.json since they're wrong for latter versions.

Workflows seem to be broken, but works fine when I test locally with npm run test so 🤷

@test137E29B test137E29B marked this pull request as ready for review November 4, 2023 16:54
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
Copy link
Contributor

@zardoy zardoy Nov 14, 2023

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

Copy link
Author

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.

Copy link
Contributor

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

Copy link
Member

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

@rom1504
Copy link
Member

rom1504 commented Dec 17, 2023

can you fix CI ?

@rom1504
Copy link
Member

rom1504 commented Dec 17, 2023

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(() => {
Copy link
Member

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

@rom1504
Copy link
Member

rom1504 commented Dec 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Almost too old
Development

Successfully merging this pull request may close these issues.

3 participants