UNPKG

@xeokit/xeokit-sdk

Version:

3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision

356 lines (353 loc) 4.99 MB
/** * xeokit-sdk v2.6.78 * Commit: 17c76751873b26ec38b03ae632f1d2003dc7a98a * Built: 2025-06-18T11:33:48.212Z */ var _globalThis$loaders3,_DRACO_EXTERNAL_LIBRA,_DEFAULT_SAMPLER_PARA;var _marked=/*#__PURE__*/_regeneratorRuntime().mark(makeStringIterator),_marked2=/*#__PURE__*/_regeneratorRuntime().mark(makeArrayBufferIterator),_marked3=/*#__PURE__*/_regeneratorRuntime().mark(makeMeshPrimitiveIterator);function _wrapNativeSuper(Class){var _cache=typeof Map==="function"?new Map():undefined;_wrapNativeSuper=function _wrapNativeSuper(Class){if(Class===null||!_isNativeFunction(Class))return Class;if(typeof Class!=="function"){throw new TypeError("Super expression must either be null or a function");}if(typeof _cache!=="undefined"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper);}function Wrapper(){return _construct(Class,arguments,_getPrototypeOf(this).constructor);}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _setPrototypeOf(Wrapper,Class);};return _wrapNativeSuper(Class);}function _construct(Parent,args,Class){if(_isNativeReflectConstruct()){_construct=Reflect.construct.bind();}else{_construct=function _construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor();if(Class)_setPrototypeOf(instance,Class.prototype);return instance;};}return _construct.apply(null,arguments);}function _isNativeFunction(fn){return Function.toString.call(fn).indexOf("[native code]")!==-1;}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */_regeneratorRuntime=function _regeneratorRuntime(){return exports;};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key];}try{define({},"");}catch(err){define=function define(obj,key,value){return obj[key]=value;};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return generator._invoke=function(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult();}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult;}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done};}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}};}(innerFn,self,context),generator;}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)};}catch(err){return{type:"throw",arg:err};}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this;});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg);});});}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==_typeof(value)&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject);},function(err){invoke("throw",err,resolve,reject);}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result);},function(error){return invoke("throw",error,resolve,reject);});}reject(record.arg);}var previousPromise;this._invoke=function(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject);});}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();};}function maybeInvokeDelegate(delegate,context){var method=delegate.iterator[context.method];if(undefined===method){if(context.delegate=null,"throw"===context.method){if(delegate.iterator["return"]&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method))return ContinueSentinel;context.method="throw",context.arg=new TypeError("The iterator does not provide a 'throw' method");}return ContinueSentinel;}var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel);}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;){if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;}return next.value=undefined,next.done=!0,next;};return next.next=next;}}return{next:doneResult};}function doneResult(){return{value:undefined,done:!0};}return GeneratorFunction.prototype=GeneratorFunctionPrototype,define(Gp,"constructor",GeneratorFunctionPrototype),define(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return!!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name));},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun;},exports.awrap=function(arg){return{__await:arg};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this;}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next();});},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this;}),define(Gp,"toString",function(){return"[object Generator]";}),exports.keys=function(object){var keys=[];for(var key in object){keys.push(key);}return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next;}return next.done=!0,next;};},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this){"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);}},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval;},dispatchException:function dispatchException(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught;}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);}else{if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}}}},abrupt:function abrupt(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break;}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record);},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return"break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel;},finish:function finish(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel;}},"catch":function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel;}},exports;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e14){throw _e14;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e15){didErr=true;err=_e15;},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]();}finally{if(didErr)throw err;}}};}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArray(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter);}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr);}function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind();}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver);}return desc.value;};}return _get.apply(this,arguments);}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break;}return object;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function");}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget);}else{result=Super.apply(this,arguments);}return _possibleConstructorReturn(this,result);};}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call;}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined");}return _assertThisInitialized(self);}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true;}catch(e){return false;}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o);};return _getPrototypeOf(o);}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj;}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;},_typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _awaitAsyncGenerator(value){return new _AwaitValue(value);}function _wrapAsyncGenerator(fn){return function(){return new _AsyncGenerator(fn.apply(this,arguments));};}function _AsyncGenerator(gen){var front,back;function send(key,arg){return new Promise(function(resolve,reject){var request={key:key,arg:arg,resolve:resolve,reject:reject,next:null};if(back){back=back.next=request;}else{front=back=request;resume(key,arg);}});}function resume(key,arg){try{var result=gen[key](arg);var value=result.value;var wrappedAwait=value instanceof _AwaitValue;Promise.resolve(wrappedAwait?value.wrapped:value).then(function(arg){if(wrappedAwait){resume(key==="return"?"return":"next",arg);return;}settle(result.done?"return":"normal",arg);},function(err){resume("throw",err);});}catch(err){settle("throw",err);}}function settle(type,value){switch(type){case"return":front.resolve({value:value,done:true});break;case"throw":front.reject(value);break;default:front.resolve({value:value,done:false});break;}front=front.next;if(front){resume(front.key,front.arg);}else{back=null;}}this._invoke=send;if(typeof gen["return"]!=="function"){this["return"]=undefined;}}_AsyncGenerator.prototype[typeof Symbol==="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this;};_AsyncGenerator.prototype.next=function(arg){return this._invoke("next",arg);};_AsyncGenerator.prototype["throw"]=function(arg){return this._invoke("throw",arg);};_AsyncGenerator.prototype["return"]=function(arg){return this._invoke("return",arg);};function _AwaitValue(value){this.wrapped=value;}function _asyncIterator(iterable){var method,async,sync,retry=2;for("undefined"!=typeof Symbol&&(async=Symbol.asyncIterator,sync=Symbol.iterator);retry--;){if(async&&null!=(method=iterable[async]))return method.call(iterable);if(sync&&null!=(method=iterable[sync]))return new AsyncFromSyncIterator(method.call(iterable));async="@@asyncIterator",sync="@@iterator";}throw new TypeError("Object is not async iterable");}function AsyncFromSyncIterator(s){function AsyncFromSyncIteratorContinuation(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var done=r.done;return Promise.resolve(r.value).then(function(value){return{value:value,done:done};});}return AsyncFromSyncIterator=function AsyncFromSyncIterator(s){this.s=s,this.n=s.next;},AsyncFromSyncIterator.prototype={s:null,n:null,next:function next(){return AsyncFromSyncIteratorContinuation(this.n.apply(this.s,arguments));},"return":function _return(value){var ret=this.s["return"];return void 0===ret?Promise.resolve({value:value,done:!0}):AsyncFromSyncIteratorContinuation(ret.apply(this.s,arguments));},"throw":function _throw(value){var thr=this.s["return"];return void 0===thr?Promise.reject(value):AsyncFromSyncIteratorContinuation(thr.apply(this.s,arguments));}},new AsyncFromSyncIterator(s);}/** @private */var Map$1=/*#__PURE__*/function(){function Map$1(items,baseId){_classCallCheck(this,Map$1);this.items=items||[];this._lastUniqueId=(baseId||0)+1;}/** * Usage: * * id = myMap.addItem("foo") // ID internally generated * id = myMap.addItem("foo", "bar") // ID is "foo" */_createClass(Map$1,[{key:"addItem",value:function addItem(){var item;if(arguments.length===2){var id=arguments[0];item=arguments[1];if(this.items[id]){// Won't happen if given ID is string throw"ID clash: '"+id+"'";}this.items[id]=item;return id;}else{item=arguments[0]||{};while(true){var findId=this._lastUniqueId++;if(!this.items[findId]){this.items[findId]=item;return findId;}}}}},{key:"removeItem",value:function removeItem(id){var item=this.items[id];delete this.items[id];return item;}}]);return Map$1;}();var idMap=new Map$1();/** * Internal data class that represents the state of a menu or a submenu. * @private */var Menu=/*#__PURE__*/_createClass(function Menu(id){_classCallCheck(this,Menu);this.id=id;this.parentItem=null;// Set to an Item when this Menu is a submenu this.groups=[];this.menuElement=null;this.shown=false;this.mouseOver=0;});/** * Internal data class that represents a group of Items in a Menu. * @private */var Group=/*#__PURE__*/_createClass(function Group(){_classCallCheck(this,Group);this.items=[];});/** * Internal data class that represents the state of a menu item. * @private */var Item=/*#__PURE__*/_createClass(function Item(id,getTitle,doAction,getEnabled,getShown){_classCallCheck(this,Item);this.id=id;this.getTitle=getTitle;this.doAction=doAction;this.getEnabled=getEnabled;this.getShown=getShown;this.itemElement=null;this.subMenu=null;this.enabled=true;});/** * @desc A customizable HTML context menu. * * [<img src="http://xeokit.io/img/docs/ContextMenu/ContextMenu.gif">](https://xeokit.github.io/xeokit-sdk/examples/index.html#ContextMenu_Canvas_TreeViewPlugin_Custom) * * * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/index.html#ContextMenu_Canvas_TreeViewPlugin_Custom)] * * ## Overview * * * A pure JavaScript, lightweight context menu * * Dynamically configure menu items * * Dynamically enable or disable items * * Dynamically show or hide items * * Supports cascading sub-menus * * Configure custom style with CSS (see examples above) * * ## Usage * * In the example below we'll create a ````ContextMenu```` that pops up whenever we right-click on an {@link Entity} within * our {@link Scene}. * * First, we'll create the ````ContextMenu````, configuring it with a list of menu items. * * Each item has: * * * a ````title```` for the item, * * a ````doAction()```` callback to fire when the item's title is clicked, * * an optional ````getShown()```` callback that indicates if the item should shown in the menu or not, and * * an optional ````getEnabled()```` callback that indicates if the item should be shown enabled in the menu or not. * * <br> * * The ````getShown()```` and ````getEnabled()```` callbacks are invoked whenever the menu is shown. * * When an item's ````getShown()```` callback * returns ````true````, then the item is shown. When it returns ````false````, then the item is hidden. An item without * a ````getShown()```` callback is always shown. * * When an item's ````getEnabled()```` callback returns ````true````, then the item is enabled and clickable (as long as it's also shown). When it * returns ````false````, then the item is disabled and cannot be clicked. An item without a ````getEnabled()```` * callback is always enabled and clickable. * * Note how the ````doAction()````, ````getShown()```` and ````getEnabled()```` callbacks accept a ````context```` * object. That must be set on the ````ContextMenu```` before we're able to we show it. The context object can be anything. In this example, * we'll use the context object to provide the callbacks with the Entity that we right-clicked. * * We'll also initially enable the ````ContextMenu````. * * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/index.html#ContextMenu_Canvas_Custom)] * * ````javascript * const canvasContextMenu = new ContextMenu({ * * enabled: true, * * items: [ * [ * { * title: "Hide Object", * getEnabled: (context) => { * return context.entity.visible; // Can't hide entity if already hidden * }, * doAction: function (context) { * context.entity.visible = false; * } * } * ], * [ * { * title: "Select Object", * getEnabled: (context) => { * return (!context.entity.selected); // Can't select an entity that's already selected * }, * doAction: function (context) { * context.entity.selected = true; * } * } * ], * [ * { * title: "X-Ray Object", * getEnabled: (context) => { * return (!context.entity.xrayed); // Can't X-ray an entity that's already X-rayed * }, * doAction: (context) => { * context.entity.xrayed = true; * } * } * ] * ] * }); * ```` * * Next, we'll make the ````ContextMenu```` appear whenever we right-click on an Entity. Whenever we right-click * on the canvas, we'll attempt to pick the Entity at those mouse coordinates. If we succeed, we'll feed the * Entity into ````ContextMenu```` via the context object, then show the ````ContextMenu````. * * From there, each ````ContextMenu```` item's ````getEnabled()```` callback will be invoked (if provided), to determine if the item should * be enabled. If we click an item, its ````doAction()```` callback will be invoked with our context object. * * Remember that we must set the context on our ````ContextMenu```` before we show it, otherwise it will log an error to the console, * and ignore our attempt to show it. * * ````javascript* * viewer.scene.canvas.canvas.oncontextmenu = (e) => { // Right-clicked on the canvas * * if (!objectContextMenu.enabled) { * return; * } * * var hit = viewer.scene.pick({ // Try to pick an Entity at the coordinates * canvasPos: [e.pageX, e.pageY] * }); * * if (hit) { // Picked an Entity * * objectContextMenu.context = { // Feed entity to ContextMenu * entity: hit.entity * }; * * objectContextMenu.show(e.pageX, e.pageY); // Show the ContextMenu * } * * e.preventDefault(); * }); * ```` * * Note how we only show the ````ContextMenu```` if it's enabled. We can use that mechanism to switch between multiple * ````ContextMenu```` instances depending on what we clicked. * * ## Dynamic Item Titles * * To make an item dynamically regenerate its title text whenever we show the ````ContextMenu````, provide its title with a * ````getTitle()```` callback. The callback will fire each time you show ````ContextMenu````, which will dynamically * set the item title text. * * In the example below, we'll create a simple ````ContextMenu```` that allows us to toggle the selection of an object * via its first item, which changes text depending on whether we are selecting or deselecting the object. * * [[Run an example](https://xeokit.github.io/xeokit-sdk/examples/index.html#ContextMenu_dynamicItemTitles)] * * ````javascript * const canvasContextMenu = new ContextMenu({ * * enabled: true, * * items: [ * [ * { * getTitle: (context) => { * return (!context.entity.selected) ? "Select" : "Undo Select"; * }, * doAction: function (context) { * context.entity.selected = !context.entity.selected; * } * }, * { * title: "Clear Selection", * getEnabled: function (context) { * return (context.viewer.scene.numSelectedObjects > 0); * }, * doAction: function (context) { * context.viewer.scene.setObjectsSelected(context.viewer.scene.selectedObjectIds, false); * } * } * ] * ] * }); * ```` * * ## Sub-menus * * Each menu item can optionally have a sub-menu, which will appear when we hover over the item. * * In the example below, we'll create a much simpler ````ContextMenu```` that has only one item, called "Effects", which * will open a cascading sub-menu whenever we hover over that item. * * Note that our "Effects" item has no ````doAction```` callback, because an item with a sub-menu performs no * action of its own. * * [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/index.html#ContextMenu_subMenus)] * * ````javascript * const canvasContextMenu = new ContextMenu({ * items: [ // Top level items * [ * { * getTitle: (context) => { * return "Effects"; * }, * * items: [ // Sub-menu * [ * { * getTitle: (context) => { * return (!context.entity.visible) ? "Show" : "Hide"; * }, * doAction: function (context) { * context.entity.visible = !context.entity.visible; * } * }, * { * getTitle: (context) => { * return (!context.entity.selected) ? "Select" : "Undo Select"; * }, * doAction: function (context) { * context.entity.selected = !context.entity.selected; * } * }, * { * getTitle: (context) => { * return (!context.entity.highlighted) ? "Highlight" : "Undo Highlight"; * }, * doAction: function (context) { * context.entity.highlighted = !context.entity.highlighted; * } * } * ] * ] * } * ] * ] * }); * ```` */var ContextMenu=/*#__PURE__*/function(){/** * Creates a ````ContextMenu````. * * The ````ContextMenu```` will be initially hidden. * * @param {Object} [cfg] ````ContextMenu```` configuration. * @param {Object} [cfg.items] The context menu items. These can also be dynamically set on {@link ContextMenu#items}. See the class documentation for an example. * @param {Object} [cfg.context] The context, which is passed into the item callbacks. This can also be dynamically set on {@link ContextMenu#context}. This must be set before calling {@link ContextMenu#show}. * @param {Boolean} [cfg.enabled=true] Whether this ````ContextMenu```` is initially enabled. {@link ContextMenu#show} does nothing while this is ````false````. * @param {Boolean} [cfg.hideOnMouseDown=true] Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page. * @param {Boolean} [cfg.hideOnAction=true] Whether this ````ContextMenu```` automatically hides after we select a menu item. Se false if we want the menu to remain shown and show any updates to its item titles, after we've selected an item. * @param {Node | undefined} [cfg.parentNode] Optional reference to an existing DOM Node (e.g. ShadowRoot), to which the menu's HTML element will be appended, defaults to ````document.body````. */function ContextMenu(){var _this2=this;var cfg=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,ContextMenu);this._id=idMap.addItem();this._context=null;this._enabled=false;// True when the ContextMenu is enabled this._itemsCfg=[];// Items as given as configs this._rootMenu=null;// The root Menu in the tree this._menuList=[];// List of Menus this._menuMap={};// Menus mapped to their IDs this._itemList=[];// List of Items this._itemMap={};// Items mapped to their IDs this._shown=false;// True when the ContextMenu is visible this._nextId=0;this._parentNode=cfg.parentNode||document.body;this._offsetParent=this._parentNode instanceof ShadowRoot?this._parentNode.host:this._parentNode;/** * Subscriptions to events fired at this ContextMenu. * @private */this._eventSubs={};if(cfg.hideOnMouseDown!==false){this._parentNode.addEventListener("mousedown",function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this2.hide();}});this._parentNode.addEventListener("touchstart",this._canvasTouchStartHandler=function(event){if(!event.target.classList.contains("xeokit-context-menu-item")){_this2.hide();}});}if(cfg.items){this.items=cfg.items;}this._hideOnAction=cfg.hideOnAction!==false;this.context=cfg.context;this.enabled=cfg.enabled!==false;this.hide();}/** Subscribes to an event fired at this ````ContextMenu````. @param {String} event The event @param {Function} callback Callback fired on the event */_createClass(ContextMenu,[{key:"on",value:function on(event,callback){var subs=this._eventSubs[event];if(!subs){subs=[];this._eventSubs[event]=subs;}subs.push(callback);}/** Fires an event at this ````ContextMenu````. @param {String} event The event type name @param {Object} value The event parameters */},{key:"fire",value:function fire(event,value){var subs=this._eventSubs[event];if(subs){for(var _i2=0,len=subs.length;_i2<len;_i2++){subs[_i2](value);}}}/** * Sets the ````ContextMenu```` items. * * These can be updated dynamically at any time. * * See class documentation for an example. * * @type {Object[]} */},{key:"items",get:/** * Gets the ````ContextMenu```` items. * * @type {Object[]} */function get(){return this._itemsCfg;}/** * Sets whether this ````ContextMenu```` is enabled. * * Hides the menu when disabling. * * @type {Boolean} */,set:function set(itemsCfg){this._clear();this._itemsCfg=itemsCfg||[];this._parseItems(itemsCfg);this._createUI();}},{key:"enabled",get:/** * Gets whether this ````ContextMenu```` is enabled. * * {@link ContextMenu#show} does nothing while this is ````false````. * * @type {Boolean} */function get(){return this._enabled;}/** * Sets the ````ContextMenu```` context. * * The context can be any object that you need to be provides to the callbacks configured on {@link ContextMenu#items}. * * This must be set before calling {@link ContextMenu#show}. * * @type {Object} */,set:function set(enabled){enabled=!!enabled;if(enabled===this._enabled){return;}this._enabled=enabled;if(!this._enabled){this.hide();}}},{key:"context",get:/** * Gets the ````ContextMenu```` context. * * @type {Object} */function get(){return this._context;}/** * Shows this ````ContextMenu```` at the given page coordinates. * * Does nothing when {@link ContextMenu#enabled} is ````false````. * * Logs error to console and does nothing if {@link ContextMenu#context} has not been set. * * Fires a "shown" event when shown. * * @param {Number} pageX Page X-coordinate. * @param {Number} pageY Page Y-coordinate. */,set:function set(context){this._context=context;}},{key:"show",value:function show(pageX,pageY){if(!this._context){console.error("ContextMenu cannot be shown without a context - set context first");return;}if(!this._enabled){return;}if(this._shown){return;}this._hideAllMenus();this._updateItemsTitles();this._updateItemsEnabledStatus();this._showMenu(this._rootMenu.id,pageX,pageY);this._updateSubMenuInfo();this._shown=true;this.fire("shown",{});}/** * Gets whether this ````ContextMenu```` is currently shown or not. * * @returns {Boolean} Whether this ````ContextMenu```` is shown. */},{key:"shown",get:function get(){return this._shown;}/** * Hides this ````ContextMenu````. * * Fires a "hidden" event when hidden. */},{key:"hide",value:function hide(){if(!this._enabled){return;}if(!this._shown){return;}this._hideAllMenus();this._shown=false;this.fire("hidden",{});}/** * Destroys this ````ContextMenu````. */},{key:"destroy",value:function destroy(){this._context=null;this._clear();if(this._id!==null){idMap.removeItem(this._id);this._id=null;}}},{key:"_clear",value:function _clear(){// Destroys DOM elements, clears menu data for(var _i3=0,len=this._menuList.length;_i3<len;_i3++){var menu=this._menuList[_i3];var menuElement=menu.menuElement;menuElement.remove();}this._itemsCfg=[];this._rootMenu=null;this._menuList=[];this._menuMap={};this._itemList=[];this._itemMap={};}},{key:"_parseItems",value:function _parseItems(itemsCfg){var _this3=this;// Parses "items" config into menu data var visitItems=function visitItems(itemsCfg){var menuId=_this3._getNextId();var menu=new Menu(menuId);for(var _i4=0,len=itemsCfg.length;_i4<len;_i4++){var itemsGroupCfg=itemsCfg[_i4];var group=new Group();menu.groups.push(group);var _loop=function _loop(j,lenj){var itemCfg=itemsGroupCfg[j];var subItemsCfg=itemCfg.items;var hasSubItems=subItemsCfg&&subItemsCfg.length>0;var itemId=_this3._getNextId();var getTitle=itemCfg.getTitle||function(){return itemCfg.title||"";};var doAction=itemCfg.doAction||itemCfg.callback||function(){};var getEnabled=itemCfg.getEnabled||function(){return true;};var getShown=itemCfg.getShown||function(){return true;};var item=new Item(itemId,getTitle,doAction,getEnabled,getShown);item.parentMenu=menu;group.items.push(item);if(hasSubItems){var subMenu=visitItems(subItemsCfg);item.subMenu=subMenu;subMenu.parentItem=item;}_this3._itemList.push(item);_this3._itemMap[item.id]=item;};for(var j=0,lenj=itemsGroupCfg.length;j<lenj;j++){_loop(j,lenj);}}_this3._menuList.push(menu);_this3._menuMap[menu.id]=menu;return menu;};this._rootMenu=visitItems(itemsCfg);}},{key:"_getNextId",value:function _getNextId(){// Returns a unique ID return"ContextMenu_"+this._id+"_"+this._nextId++;// Start ID with alpha chars to make a valid DOM element selector }},{key:"_createUI",value:function _createUI(){var _this4=this;// Builds DOM elements for the entire menu tree var visitMenu=function visitMenu(menu){_this4._createMenuUI(menu);var groups=menu.groups;for(var _i5=0,len=groups.length;_i5<len;_i5++){var group=groups[_i5];var groupItems=group.items;for(var j=0,lenj=groupItems.length;j<lenj;j++){var item=groupItems[j];var subMenu=item.subMenu;if(subMenu){visitMenu(subMenu);}}}};visitMenu(this._rootMenu);}},{key:"_createMenuUI",value:function _createMenuUI(menu){var _this5=this;// Builds DOM elements for a menu var groups=menu.groups;var html=[];var menuElement=document.createElement("div");menuElement.classList.add("xeokit-context-menu",menu.id);menuElement.style.zIndex=300000;menuElement.style.position="absolute";html.push('<ul>');if(groups){for(var _i6=0,len=groups.length;_i6<len;_i6++){var group=groups[_i6];var groupIdx=_i6;var groupLen=len;var groupItems=group.items;if(groupItems){for(var j=0,lenj=groupItems.length;j<lenj;j++){var item=groupItems[j];var itemSubMenu=item.subMenu;var actionTitle=item.title||"";if(itemSubMenu){html.push('<li id="'+item.id+'" class="xeokit-context-menu-item xeokit-context-menu-submenu">'+actionTitle+'</li>');if(!(groupIdx===groupLen-1||j<lenj-1)){html.push('<li id="'+item.id+'" class="xeokit-context-menu-item-separator"></li>');}}else{html.push('<li id="'+item.id+'" class="xeokit-context-menu-item">'+actionTitle+'</li>');if(!(groupIdx===groupLen-1||j<lenj-1)){html.push('<li id="'+item.id+'" class="xeokit-context-menu-item-separator"></li>');}}}}}}html.push('</ul>');var htmlString=html.join("");menuElement.innerHTML=htmlString;this._parentNode.appendChild(menuElement);menu.menuElement=menuElement;menuElement.style["border-radius"]=4+"px";menuElement.style.display='none';menuElement.style["z-index"]=300000;menuElement.style.background="white";menuElement.style.border="1px solid black";menuElement.style["box-shadow"]="0 4px 5px 0 gray";menuElement.oncontextmenu=function(e){e.preventDefault();};// Bind event handlers var self=this;var lastSubMenu=null;if(groups){for(var _i7=0,_len=groups.length;_i7<_len;_i7++){var _group=groups[_i7];var _groupItems=_group.items;if(_groupItems){var _loop2=function _loop2(_j2,_lenj){var item=_groupItems[_j2];var itemSubMenu=item.subMenu;item.itemElement=_this5._parentNode.querySelector("#".concat(item.id));if(!item.itemElement){console.error("ContextMenu item element not found: "+item.id);return"continue";}item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();var subMenu=item.subMenu;if(!subMenu){if(lastSubMenu){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}return;}if(lastSubMenu&&lastSubMenu.id!==subMenu.id){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}if(item.enabled===false){return;}var itemElement=item.itemElement;var subMenuElement=subMenu.menuElement;var itemRect=itemElement.getBoundingClientRect();subMenuElement.getBoundingClientRect();var offsetRect=self._offsetParent.getBoundingClientRect();var subMenuWidth=200;// TODO var showOnRight=itemRect.right+subMenuWidth<offsetRect.right;var showOnLeft=itemRect.left-subMenuWidth>offsetRect.left;if(showOnRight)self._showMenu(subMenu.id,itemRect.right+window.scrollX-5,itemRect.top+window.scrollY-1);else if(showOnLeft)self._showMenu(subMenu.id,itemRect.left-subMenuWidth+window.scrollX,itemRect.top+window.scrollY-1);else{var spaceOnLeft=itemRect.left-offsetRect.left,spaceOnRight=offsetRect.right-itemRect.right;if(spaceOnRight>spaceOnLeft)self._showMenu(subMenu.id,itemRect.right-5-(subMenuWidth-spaceOnRight),itemRect.top+window.scrollY-1);else self._showMenu(subMenu.id,itemRect.left-spaceOnLeft,itemRect.top+window.scrollY-1);}lastSubMenu=subMenu;});if(!itemSubMenu){// Item without sub-menu // clicking item fires the item's action callback item.itemElement.addEventListener("click",function(event){event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this5._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseup",function(event){if(event.which!==3){return;}event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this5._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();if(item.enabled===false){return;}if(item.doHover){item.doHover(self._context);}});}};for(var _j2=0,_lenj=_groupItems.length;_j2<_lenj;_j2++){var _ret=_loop2(_j2,_lenj);if(_ret==="continue")continue;}}}}}},{key:"_updateItemsTitles",value:function _updateItemsTitles(){// Dynamically updates the title of each Item to the result of Item#getTitle() if(!this._context){return;}for(var _i8=0,len=this._itemList.length;_i8<len;_i8++){var item=this._itemList[_i8];var itemElement=item.itemElement;if(!itemElement){continue;}var getShown=item.getShown;if(!getShown||!getShown(this._context)){continue;}var title=item.getTitle(this._context);if(item.subMenu){itemElement.innerText=title;}else{itemElement.innerText=title;}}}},{key:"_updateItemsEnabledStatus",value:function _updateItemsEnabledStatus(){// Enables or disables each Item, depending on the result of Item#getEnabled() if(!this._context){return;}for(var _i9=0,len=this._itemList.length;_i9<len;_i9++){var item=this._itemList[_i9];var itemElement=item.itemElement;if(!itemElement){continue;}var getEnabled=item.getEnabled;if(!getEnabled){continue;}var getShown=item.getShown;if(!getShown){continue;}var shown=getShown(this._context);item.shown=shown;if(!shown){itemElement.style.display="none";continue;}else{itemElement.style.display="";}var enabled=getEnabled(this._context);item.enabled=enabled;if(!enabled){itemElement.classList.add("disabled");}else{itemElement.classList.remove("disabled");}}}},{key:"_updateSubMenuInfo",value:function _updateSubMenuInfo(){if(!this._context)return;var itemElement,itemRect,subMenuElement,initialStyles,showOnLeft,subMenuWidth;this._itemList.forEach(function(item){if(item.subMenu){itemElement=item.itemElement;itemRect=itemElement.getBoundingClientRect();subMenuElement=item.subMenu.menuElement;initialStyles={visibility:subMenuElement.style.visibility,display:subMenuElement.style.display};subMenuElement.style.display="block";subMenuElement.style.visibility="hidden";subMenuWidth=item.subMenu.menuElement.getBoundingClientRect().width;subMenuElement.style.visibility=initialStyles.visibility;subMenuElement.style.display=initialStyles.display;showOnLeft=itemRect.right+subMenuWidth>window.innerWidth;itemElement.setAttribute("data-submenuposition",showOnLeft?"left":"right");}});}},{key:"_showMenu",value:function _showMenu(menuId,pageX,pageY){// Shows the given menu, at the specified page coordinates var menu=this._menuMap[menuId];if(!menu){console.error("Menu not found: "+menuId);return;}if(menu.shown){return;}var menuElement=menu.menuElement;if(menuElement){this._showMenuElement(menuElement,pageX,pageY);menu.shown=true;}}},{key:"_hideMenu",value:function _hideMenu(menuId){// Hides the given menu var menu=this._menuMap[menuId];if(!menu){console.error("Menu not found: "+menuId);return;}if(!menu.shown){return;}var menuElement=menu.menuElement;if(menuElement){this._hideMenuElement(menuElement);menu.shown=false;}}},{key:"_hideAllMenus",value:function _hideAllMenus(){for(var _i10=0,len=this._menuList.length;_i10<len;_i10++){var menu=this._menuList[_i10];this._hideMenu(menu.id);}}},{key:"_showMenuElement",value:function _showMenuElement(menuElement,pageX,pageY){// Shows the given menu element, at the specified page coordinates menuElement.style.display='block';var menuHeight=menuElement.offsetHeight;var menuWidth=menuElement.offsetWidth;var offsetRect=this._offsetParent.getBoundingClientRect();var bottomContainerBorder=offsetRect.bottom+window.scrollY;var rightContainerBorder=offsetRect.right+window.scrollX;if(pageY+menuHeight>bottomContainerBorder){pageY=bottomContainerBorder-menuHeight;}if(pageX+menuWidth>rightContainerBorder){pageX=rightContainerBorder-menuWidth;}menuElement.style.left=pageX-offsetRect.left-window.scrollX+'px';menuElement.style.top=pageY-offsetRect.top-window.scrollY+'px';}},{key:"_hideMenuElement",value:function _hideMenuElement(menuElement){menuElement.style.display='none';}}]);return ContextMenu;}();/** * A PointerLens shows a magnified view of a {@link Viewer}'s canvas, centered at the position of the * mouse or touch pointer. * * This component is used