UNPKG

x_ite

Version:

X_ITE X3D Browser, view and manipulate X3D, VRML, glTF and other 3D sources in HTML.

2 lines 7.49 kB
/* X_ITE v12.2.3 */ const e=window[Symbol.for("X_ITE.X3D-12.2.3")];(()=>{var t={n:e=>{var s=e&&e.__esModule?()=>e.default:()=>e;return t.d(s,{a:s}),s},d:(e,s)=>{for(var a in s)t.o(s,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:s[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const s=e.Components;var a=t.n(s);const i=e.Namespace;var n=t.n(i);const r=Symbol(),o=Symbol(),c=Symbol();function h(){this[r]=new Set}Object.assign(h.prototype,{initialize(){const e=this.getElement();e.on("keydown.X3DKeyDeviceSensorContext",this[o].bind(this)),e.on("keyup.X3DKeyDeviceSensorContext",this[c].bind(this))},addKeyDeviceSensorNode(e){this[r].add(e)},removeKeyDeviceSensorNode(e){this[r].delete(e)},getKeyDeviceSensorNodes(){return this[r]},[o](e){for(const t of this[r])t.keydown(e)},[c](e){for(const t of this[r])t.keyup(e)},dispose(){this.getElement().off(".X3DKeyDeviceSensorContext")}});const l=h,y=n().add("X3DKeyDeviceSensorContext",l),d=e.Fields;var _=t.n(d);const b=e.X3DFieldDefinition;var k=t.n(b);const u=e.FieldDefinitionArray;var p=t.n(u);const K=e.X3DNode;var S=t.n(K);const w=e.X3DSensorNode;var v=t.n(w);const g=e.X3DConstants;var f=t.n(g);function D(e){v().call(this,e),this.addType(f().X3DKeyDeviceSensorNode)}Object.assign(Object.setPrototypeOf(D.prototype,v().prototype),{initialize(){v().prototype.initialize.call(this),this.getLive().addInterest("set_live__",this),this.set_live__()},set_live__(){this.getLive().getValue()?(this._enabled.addInterest("set_enabled__",this),this._enabled.getValue()&&this.enable()):(this._enabled.removeInterest("set_enabled__",this),this.disable())},set_enabled__(){this._enabled.getValue()?this.enable():this.disable()},enable(){this.getBrowser().addKeyDeviceSensorNode(this);for(const e of this.getBrowser().getKeyDeviceSensorNodes())e!==this&&e._enabled.getValue()&&(e._enabled=!1)},disable(){this.getBrowser().removeKeyDeviceSensorNode(this),this.release()},keydown(){},keyup(){},release(){}}),Object.defineProperties(D,S().getStaticProperties("X3DKeyDeviceSensorNode","KeyDeviceSensor",1));const P=D,O=n().add("X3DKeyDeviceSensorNode",P);function C(e){O.call(this,e),this.addType(f().KeySensor)}Object.assign(Object.setPrototypeOf(C.prototype,O.prototype),{keydown(e){switch(e.preventDefault(),this._isActive.getValue()||(this._isActive=!0),e.which){case 16:this._shiftKey=!0;break;case 17:this._controlKey=!0;break;case 18:this._altKey=!0;break;case 112:this._actionKeyPress=1;break;case 113:this._actionKeyPress=2;break;case 114:this._actionKeyPress=3;break;case 115:this._actionKeyPress=4;break;case 116:this._actionKeyPress=5;break;case 117:this._actionKeyPress=6;break;case 118:this._actionKeyPress=7;break;case 119:this._actionKeyPress=8;break;case 120:this._actionKeyPress=9;break;case 121:this._actionKeyPress=10;break;case 122:this._actionKeyPress=11;break;case 123:this._actionKeyPress=12;break;case 36:this._actionKeyPress=13;break;case 35:this._actionKeyPress=14;break;case 33:this._actionKeyPress=15;break;case 34:this._actionKeyPress=16;break;case 38:this._actionKeyPress=17;break;case 40:this._actionKeyPress=18;break;case 37:this._actionKeyPress=19;break;case 39:this._actionKeyPress=20;break;default:if(e.charCode||e.keyCode)switch(e.key){case"AltGraph":case"CapsLock":case"Insert":break;case"Backspace":this._keyPress=String.fromCharCode(8);break;case"Delete":this._keyPress=String.fromCharCode(127);break;case"Enter":this._keyPress="\n";break;case"Escape":this._keyPress=String.fromCharCode(27);break;case"Tab":this._keyPress="\t";break;default:1===e.key.length&&(this._keyPress=e.key)}}},keyup(e){switch(e.preventDefault(),e.which){case 16:this._shiftKey=!1;break;case 17:this._controlKey=!1;break;case 18:this._altKey=!1;break;case 112:this._actionKeyRelease=1;break;case 113:this._actionKeyRelease=2;break;case 114:this._actionKeyRelease=3;break;case 115:this._actionKeyRelease=4;break;case 116:this._actionKeyRelease=5;break;case 117:this._actionKeyRelease=6;break;case 118:this._actionKeyRelease=7;break;case 119:this._actionKeyRelease=8;break;case 120:this._actionKeyRelease=9;break;case 121:this._actionKeyRelease=10;break;case 122:this._actionKeyRelease=11;break;case 123:this._actionKeyRelease=12;break;case 36:this._actionKeyRelease=13;break;case 35:this._actionKeyRelease=14;break;case 33:this._actionKeyRelease=15;break;case 34:this._actionKeyRelease=16;break;case 38:this._actionKeyRelease=17;break;case 40:this._actionKeyRelease=18;break;case 37:this._actionKeyRelease=19;break;case 39:this._actionKeyRelease=20;break;default:if(e.charCode||e.keyCode)switch(e.key){case"AltGraph":case"CapsLock":case"Insert":break;case"Backspace":this._keyRelease=String.fromCharCode(8);break;case"Delete":this._keyRelease=String.fromCharCode(127);break;case"Enter":this._keyRelease="\n";break;case"Escape":this._keyRelease=String.fromCharCode(27);break;case"Tab":this._keyRelease="\t";break;default:1===e.key.length&&(this._keyRelease=e.key)}}this._isActive.getValue()&&(this._isActive=!1)},release(){this._shiftKey.getValue()&&(this._shiftKey=!1),this._controlKey.getValue()&&(this._controlKey=!1),this._altKey.getValue()&&(this._altKey=!1),this._isActive.getValue()&&(this._isActive=!1)}}),Object.defineProperties(C,{...S().getStaticProperties("KeySensor","KeyDeviceSensor",1,"children","3.0"),fieldDefinitions:{value:new(p())([new(k())(f().inputOutput,"metadata",new(_().SFNode)),new(k())(f().inputOutput,"description",new(_().SFString)),new(k())(f().inputOutput,"enabled",new(_().SFBool)(!0)),new(k())(f().outputOnly,"controlKey",new(_().SFBool)),new(k())(f().outputOnly,"shiftKey",new(_().SFBool)),new(k())(f().outputOnly,"altKey",new(_().SFBool)),new(k())(f().outputOnly,"actionKeyPress",new(_().SFInt32)),new(k())(f().outputOnly,"actionKeyRelease",new(_().SFInt32)),new(k())(f().outputOnly,"keyPress",new(_().SFString)),new(k())(f().outputOnly,"keyRelease",new(_().SFString)),new(k())(f().outputOnly,"isActive",new(_().SFBool))]),enumerable:!0}});const R=C,m=n().add("KeySensor",R);function F(e){O.call(this,e),this.addType(f().StringSensor)}Object.assign(Object.setPrototypeOf(F.prototype,O.prototype),{keydown(e){switch(e.preventDefault(),e.key){case"Backspace":this._isActive.getValue()&&this._deletionAllowed.getValue()&&this._enteredText.length&&(this._enteredText=this._enteredText.getValue().substring(0,this._enteredText.length-1));break;case"Enter":this._finalText=this._enteredText,this._enteredText.set(""),this._isActive.getValue()&&(this._isActive=!1);break;case"Escape":this._enteredText.set(""),this._isActive.getValue()&&(this._isActive=!1);break;case"Tab":break;default:(e.charCode||e.keyCode)&&1===e.key.length&&(this._isActive.getValue()||(this._isActive=!0,this._enteredText=""),this._enteredText=this._enteredText.getValue()+e.key)}}}),Object.defineProperties(F,{...S().getStaticProperties("StringSensor","KeyDeviceSensor",2,"children","3.0"),fieldDefinitions:{value:new(p())([new(k())(f().inputOutput,"metadata",new(_().SFNode)),new(k())(f().inputOutput,"description",new(_().SFString)),new(k())(f().inputOutput,"enabled",new(_().SFBool)(!0)),new(k())(f().inputOutput,"deletionAllowed",new(_().SFBool)(!0)),new(k())(f().outputOnly,"enteredText",new(_().SFString)),new(k())(f().outputOnly,"finalText",new(_().SFString)),new(k())(f().outputOnly,"isActive",new(_().SFBool))]),enumerable:!0}});const A=F,T=n().add("StringSensor",A);a().add({name:"KeyDeviceSensor",concreteNodes:[m,T],abstractNodes:[O],browserContext:y});n().add("KeyDeviceSensorComponent",undefined)})();