123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- this.getChildByName = function (name) {
- let nodes = this.children.filter(el => el.displayName == name);
- return nodes[0]
- }
- this.setGizmoMode = function (mode) {
- if (this.gizmo) {
- this.gizmo.properties.mode = mode
- }
- }
- this.showCloseGizmo = function () {
- let gizmoNode =
- {
- "extends": "http://vwf.example.com/aframe/gizmoComponent.vwf",
- "type": "component",
- "properties":
- {
- "mode": "translate"
- }
- }
- if (this.properties.edit) {
- this.children.create("gizmo", gizmoNode);
- } else {
- if (this.gizmo) {
- this.children.delete(this.gizmo)
- }
- }
- }
- // Parse a parameter as a translation specification.
- this.translationFromValue = function (propertyValue) {
- var value = goog.vec.Vec3.create();
- if (propertyValue.hasOwnProperty('x')) {
- value = goog.vec.Vec3.createFromValues(propertyValue.x, propertyValue.y, propertyValue.z)
- }
- else if (Array.isArray(propertyValue) || propertyValue instanceof Float32Array) {
- value = goog.vec.Vec3.createFromArray(propertyValue);
- }
- else if (typeof propertyValue === 'string') {
- let val = AFRAME.utils.coordinates.parse(propertyValue);
- value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
- }
- return value
- // return value && value.length >= 3 ?
- // value :
- // goog.vec.Vec3.create();
- };
- this.sendOSC = function (msg) {
- //sending OSC msg
- vwf_view.kernel.fireEvent(this.id, "sendOSC", [msg]);
- // if (_OSCManager.port !== null) {
- // _OSCManager.port.send(msg);
- // }
- //on driver side
- }
- // this.clickEvent = function () {
- // //this.intersectEventMethod();
- // }
- // this.intersectEvent = function () {
- // //this.intersectEventMethod();
- // }
- // this.clearIntersectEvent = function () {
- // //this.clearIntersectEventMethod();
- // }
- this.intersectEventMethod = function () {
- //intersect method
- }
- this.clearIntersectEventMethod = function () {
- //clearIntersect method
- }
- this.hitstartEventMethod = function () {
- //intersect method
- }
- this.hitendEventMethod = function () {
- //clearIntersect method
- }
- this.clickEventMethod = function () {
- //clickEventMethod
- }
- this.setOwner = function (param) {
- var clients = this.find("doc('http://vwf.example.com/clients.vwf')")[0];
- if (clients !== undefined) {
- //console.log(clients.children);
- let clientsArray = [];
- clients.children.forEach(function (element) {
- clientsArray.push(element.name);
- });
- //console.log(clientsArray);
- if (this.ownedBy) {
- if (clientsArray.includes(this.ownedBy)) {
- console.log(this.id + " already owned by: " + param);
- } else {
- this.ownedBy = param;
- //console.log(this.id + ' set owner to: ' + param);
- }
- } else {
- this.ownedBy = param;
- //console.log(this.id + ' set owner to: ' + param);
- }
- }
- }
- this.updateMethod = function (methodName, methodBody, params) {
- vwf_view.kernel.setMethod(this.id, methodName, { body: methodBody, type: "application/javascript", parameters: params});
- }
- this.callMethod = function(methodName, params){
- vwf_view.kernel.callMethod(this.id, methodName, params)
- }
|