2023年4月5日 星期三

Using MQTT commands to control lights in Three.js

In the upper right corner of the picture above, we can see two light control buttons are 'toggle directional light' and 'toggle hemisphere light', separately. You can try it out and learn how the two different lights work. For directional light, it is used to gets emitted in a specific direction but the light source of the hemisphere light position is located directly above the scene and the color of the light will gradually change from the color of the sky to the color of the ground.

1. three.js example: three.js examples (threejs.org)

2.MQTT example:Light Control

3.Publish

Topic:LightControlinHTML

Command 1:toggleHemisphereLight

Command 2:toggleDirectionalLight

4.Subscribe:

Topic: LightControl

We use MQTTBOX to test the issuance of commands as follows.


Host:test.mosquitto.org

Protocol:mqtt/tcp





沒有留言:

張貼留言