-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
158 additions
and
213 deletions.
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 |
---|---|---|
|
@@ -135,3 +135,4 @@ dist | |
*.obj | ||
*.mtl | ||
public/assets/skybox.png | ||
public/assets/players/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import AFRAME from 'aframe'; | ||
import QuizzSceneController from './quizz/QuizzSceneController'; | ||
|
||
import './components/caustics'; | ||
import './components/floating-camera'; | ||
import './components/arc-layout'; | ||
import './components/texture-map'; | ||
import './components/look-towards'; | ||
|
||
import 'aframe-orbit-controls'; | ||
import 'aframe-extras'; | ||
import 'aframe-label'; | ||
import 'aframe-htmlembed-component'; | ||
|
||
|
||
// Polyfill global Buffer | ||
import { Buffer } from 'buffer'; | ||
window.Buffer = Buffer; | ||
|
||
const utils = AFRAME.utils; | ||
|
||
// AFRAME.registerComponent('scene-controller', { | ||
// init: function() { | ||
// // // Replace with your actual MQTT broker URL | ||
// this.controller = new QuizzSceneController('ws://localhost:9001'); | ||
|
||
// // // Add some initial corals | ||
// // this.controller.addCoral('coral1', 0.5); | ||
// // this.controller.addCoral('coral2', 0.7); | ||
// // this.controller.addCoral('coral3', 0.6); | ||
// // console.log("Hello Wonderful World"); | ||
// }, | ||
|
||
// // tick: function(time, timeDelta) { | ||
// // // You can add additional per-frame logic here if needed | ||
// // } | ||
// }); |
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { createMqttHomieObserver, HomiePropertyBuffer } from '@cmcrobotics/homie-lit'; | ||
import * as nools from 'nools'; | ||
|
||
|
||
class PropertyUpdate { | ||
constructor(deviceId, nodeId, propertyId, value) { | ||
this.deviceId = deviceId; | ||
this.nodeId = nodeId; | ||
this.propertyId = propertyId; | ||
this.value = value; | ||
} | ||
} | ||
|
||
class Tick { | ||
constructor(time) { | ||
this.time = time; | ||
} | ||
} | ||
|
||
class QuizzSceneController { | ||
constructor(brokerUrl, mqttOptions = {}) { | ||
this.homieObserver = createMqttHomieObserver(brokerUrl, mqttOptions); | ||
this.homieObserver.subscribe("gateway/#") | ||
this.propertyBuffer = new HomiePropertyBuffer(this.homieObserver); | ||
this.flow = this.initNoolsFlow(); | ||
this.session = this.flow.getSession(); | ||
this.tickInterval = 5000; | ||
|
||
this.setupPropertyGroups(); | ||
this.setupBufferedUpdates(); | ||
|
||
} | ||
|
||
initNoolsFlow() { | ||
const flow = nools.compile(` | ||
rule ProcessPropertyUpdate { | ||
when { | ||
update: PropertyUpdate | ||
} | ||
then { | ||
console.log("Processing property update:", update); | ||
// Implement logic to update AFrame entities based on property updates | ||
} | ||
} | ||
// rule GrowCoral { | ||
// when { | ||
// tick: Tick | ||
// } | ||
// then { | ||
// console.log("Tick received, growing coral at time:", tick.time); | ||
// // Implement coral growth logic | ||
// // This is where you'd update the scale of coral entities | ||
// homieObserver.publish("reef-1/asset-cluster-1/scale", "1.0"); | ||
// } | ||
// } | ||
`,{ | ||
define:{ | ||
PropertyUpdate : PropertyUpdate, | ||
Tick : Tick | ||
}, | ||
scope: { | ||
logger: console, | ||
homieObserver: this.homieObserver | ||
}, | ||
name: "quizz" | ||
}); | ||
|
||
return flow; | ||
} | ||
|
||
setupPropertyGroups() { | ||
this.propertyBuffer.addPropertyGroup({ | ||
name: 'coral', | ||
properties: ['coral/health', 'coral/size', 'coral/color'], | ||
priority: 1 | ||
}); | ||
// Add more property groups as needed | ||
} | ||
|
||
setupBufferedUpdates() { | ||
this.propertyBuffer.processBufferedUpdates((updates) => { | ||
updates.forEach(update => { | ||
this.session.assert(new this.flow.PropertyUpdate(update)); | ||
}); | ||
this.session.match(); | ||
}); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
export default QuizzSceneController; |
File renamed without changes.
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