content/hifi-content/sean/Henkel/cardWorkmatClientEntity.js
2022-02-14 02:04:11 +01:00

25 lines
No EOL
859 B
JavaScript

(function() {
this.clickDownOnEntity = function(entityID, mouseEvent) {
if (!mouseEvent.isLeftButton) return;
var entity = Entities.getEntityProperties(entityID, ["position", "dimensions", "modelURL"]);
// get type of card
var filename = entity.modelURL.split("/").pop();
var results = new RegExp(/([ABC])_(value|function)(.*?)_(card|workmat)(?:_[A-Z]|)\.fbx/).exec(filename);
if (results<4) return;
// send info to the message mixer
Messages.sendMessage("com.henkel."+results[1].toLowerCase(), JSON.stringify({
room: results[1], // A,B,C
type: results[2], // value,function
number: parseFloat(results[3]),
position: results[4], // card,workmatt
modelURL: entity.modelURL,
workmat: {
position: entity.position,
rotation: entity.rotation,
dimensions: entity.dimensions,
}
}));
}
})